Whamcloud - gitweb
Add EXT2_FLAG_EXCLUSIVE to the ext2fs library.
authorTheodore Ts'o <tytso@mit.edu>
Sun, 19 Mar 2006 00:16:10 +0000 (19:16 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 19 Mar 2006 00:16:10 +0000 (19:16 -0500)
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>
lib/ext2fs/ChangeLog
lib/ext2fs/ext2fs.h
lib/ext2fs/initialize.c
lib/ext2fs/openfs.c

index 2227cb8..a93bfb9 100644 (file)
@@ -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.
index 809b602..c3d0428 100644 (file)
@@ -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
index 83eea72..05ba8c8 100644 (file)
@@ -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;
index 05de84f..4228c6e 100644 (file)
@@ -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 &&