Add readonly inode flag
authorYan <yanzheng@21cn.com>
Mon, 14 Jan 2008 18:35:00 +0000 (13:35 -0500)
committerDavid Woodhouse <dwmw2@hera.kernel.org>
Mon, 14 Jan 2008 18:35:00 +0000 (13:35 -0500)
This patch adds readonly inode flag support.  A file with this flag
can't be modified, but can be deleted.

convert.c
ctree.h

index c047620..86c41b0 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -1163,7 +1163,8 @@ static int create_ext2_image(struct btrfs_root *root, ext2_filsys ext2_fs,
        btrfs_set_stack_inode_nlink(&btrfs_inode, 1);
        btrfs_set_stack_inode_nblocks(&btrfs_inode, 0);
        btrfs_set_stack_inode_mode(&btrfs_inode, S_IFREG | 0400);
-       btrfs_set_stack_inode_flags(&btrfs_inode, BTRFS_INODE_NODATASUM);
+       btrfs_set_stack_inode_flags(&btrfs_inode, BTRFS_INODE_NODATASUM |
+                                   BTRFS_INODE_READONLY);
        btrfs_init_path(&path);
        trans = btrfs_start_transaction(root, 1);
        BUG_ON(!trans);
diff --git a/ctree.h b/ctree.h
index 444f47e..d619f30 100644 (file)
--- a/ctree.h
+++ b/ctree.h
@@ -418,8 +418,10 @@ struct btrfs_root {
 /*
  * Inode flags
  */
-#define BTRFS_INODE_NODATASUM          0x1
-#define BTRFS_INODE_NODATACOW          0x2
+#define BTRFS_INODE_NODATASUM          (1 << 0)
+#define BTRFS_INODE_NODATACOW          (1 << 1)
+#define BTRFS_INODE_READONLY           (1 << 2)
+
 #define read_eb_member(eb, ptr, type, member, result) (                        \
        read_extent_buffer(eb, (char *)(result),                        \
                           ((unsigned long)(ptr)) +                     \