diff options
author | Theodore Ts'o <tytso@mit.edu> | 2006-03-18 19:16:10 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2006-03-18 19:16:10 -0500 |
commit | 39c47ce6417b81aa74596fd0d4d98d542525a444 (patch) | |
tree | 81d281a2ad5b6b75b4544662c113f9ec7a8ed83a /lib | |
parent | fa6c653ec3117dd689c8adb4ea2ebfc10f8cdd4a (diff) | |
download | e2fsprogs-39c47ce6417b81aa74596fd0d4d98d542525a444.tar.gz |
Add EXT2_FLAG_EXCLUSIVE to the ext2fs library.
This flag when specified to ext2fs_open or ext2fs_initialize indicates
that the application wants the io_channel to be opened in exclusive mode.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ext2fs/ChangeLog | 8 | ||||
-rw-r--r-- | lib/ext2fs/ext2fs.h | 1 | ||||
-rw-r--r-- | lib/ext2fs/initialize.c | 6 | ||||
-rw-r--r-- | lib/ext2fs/openfs.c | 11 |
4 files changed, 21 insertions, 5 deletions
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 2227cb8d..a93bfb97 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,5 +1,13 @@ 2006-03-18 Theodore Ts'o <tytso@mit.edu> + * ext2fs.h (EXT2_FLAG_EXCLUSIVE): Define new flag which requests + that the io_channel be opened in exclusive mode. + + * openfs.c (ext2fs_open2), initialize.c (ext2fs_initialize): If + EXT2_FLAG_EXCLUSIVE is passed to ext2fs_open or + ext2fs_initialize, then pass IO_FLAG_EXCLUSIVE to the + io_channel open routine. + * ext2_io.h (IO_FLAG_EXCLUSIVE), unix_io.c (unix_open): Add new io_channel open flag, IO_FLAG_EXCLUSIVE, which requests that the device be opened in exclusive (O_EXCL) mode. diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 809b6025..c3d04289 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -188,6 +188,7 @@ typedef struct ext2_file *ext2_file_t; #define EXT2_FLAG_SUPER_ONLY 0x800 #define EXT2_FLAG_JOURNAL_DEV_OK 0x1000 #define EXT2_FLAG_IMAGE_FILE 0x2000 +#define EXT2_FLAG_EXCLUSIVE 0x4000 /* * Special flag in the ext2 inode i_flag field that means that this is diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c index 83eea72e..05ba8c8a 100644 --- a/lib/ext2fs/initialize.c +++ b/lib/ext2fs/initialize.c @@ -104,6 +104,7 @@ errcode_t ext2fs_initialize(const char *name, int flags, dgrp_t i; blk_t numblocks; int rsv_gdt; + int io_flags; char *buf; if (!param || !param->s_blocks_count) @@ -120,7 +121,10 @@ errcode_t ext2fs_initialize(const char *name, int flags, #ifdef WORDS_BIGENDIAN fs->flags |= EXT2_FLAG_SWAP_BYTES; #endif - retval = manager->open(name, IO_FLAG_RW, &fs->io); + io_flags = IO_FLAG_RW; + if (flags & EXT2_FLAG_EXCLUSIVE) + io_flags |= IO_FLAG_EXCLUSIVE; + retval = manager->open(name, io_flags, &fs->io); if (retval) goto cleanup; fs->image_io = fs->io; diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index 05de84fc..4228c6ed 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -86,7 +86,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, ext2_filsys fs; errcode_t retval; unsigned long i; - int j, groups_per_block, blocks_per_group; + int j, groups_per_block, blocks_per_group, io_flags; blk_t group_block, blk; char *dest, *cp; struct ext2_group_desc *gdp; @@ -111,9 +111,12 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, io_options = cp; } - retval = manager->open(fs->device_name, - (flags & EXT2_FLAG_RW) ? IO_FLAG_RW : 0, - &fs->io); + io_flags = 0; + if (flags & EXT2_FLAG_RW) + io_flags |= IO_FLAG_RW; + if (flags & EXT2_FLAG_EXCLUSIVE) + io_flags |= IO_FLAG_EXCLUSIVE; + retval = manager->open(fs->device_name, io_flags, &fs->io); if (retval) goto cleanup; if (io_options && |