From: Theodore Ts'o Date: Sat, 18 Mar 2006 23:57:44 +0000 (-0500) Subject: Add IO_FLAG_EXCLUSIVE flag to io_channel abstraction X-Git-Tag: E2FSPROGS-1.39-WIP-0330~27 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fa6c653ec3117dd689c8adb4ea2ebfc10f8cdd4a;p=thirdparty%2Fe2fsprogs.git Add IO_FLAG_EXCLUSIVE flag to io_channel abstraction Add a new io_channel open flag, IO_FLAG_EXCLUSIVE,which requests that the device be opened in exclusive (O_EXCL) mode. Add support to the unix_io implementation for this flag. Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 857cdf0ce..2227cb8db 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,5 +1,9 @@ 2006-03-18 Theodore Ts'o + * 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. + * ext2fs.h: Fix documentation so that BLOCK_FLAG_TRAVERSE is BLOCK_FLAG_DEPTH_TRAVERSE. (Addresses Debian Bug #351268) diff --git a/lib/ext2fs/ext2_io.h b/lib/ext2fs/ext2_io.h index e17886c85..eada278ea 100644 --- a/lib/ext2fs/ext2_io.h +++ b/lib/ext2fs/ext2_io.h @@ -73,7 +73,8 @@ struct struct_io_manager { int reserved[14]; }; -#define IO_FLAG_RW 1 +#define IO_FLAG_RW 0x0001 +#define IO_FLAG_EXCLUSIVE 0x0002 /* * Convenience functions.... diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index e1df0d6ce..0f04cfa3d 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -412,6 +412,8 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) goto cleanup; open_flags = (flags & IO_FLAG_RW) ? O_RDWR : O_RDONLY; + if (flags & IO_FLAG_EXCLUSIVE) + open_flags |= O_EXCL; #ifdef HAVE_OPEN64 data->dev = open64(io->name, open_flags); #else