]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
Add IO_FLAG_EXCLUSIVE flag to io_channel abstraction
authorTheodore Ts'o <tytso@mit.edu>
Sat, 18 Mar 2006 23:57:44 +0000 (18:57 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 18 Mar 2006 23:57:44 +0000 (18:57 -0500)
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" <tytso@mit.edu>
lib/ext2fs/ChangeLog
lib/ext2fs/ext2_io.h
lib/ext2fs/unix_io.c

index 857cdf0ceec8ed740115a7aba58318700951d41a..2227cb8db9acb9d98f6f27605b42de56f25eb242 100644 (file)
@@ -1,5 +1,9 @@
 2006-03-18  Theodore Ts'o  <tytso@mit.edu>
 
+       * 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)
 
index e17886c857a394a060802f3b17614cde476f2e2d..eada278ea6753b45f406f042717827921bd78f60 100644 (file)
@@ -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....
index e1df0d6ce84c98a1f3966ac4097b33bd490abcd3..0f04cfa3d68377ba68522a61431759c8b32a412d 100644 (file)
@@ -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