E2fsprogs: use the generic inode flags
PATCH 1/2 E2fsprogs: use the generic inode flags
In reply to a message not in the archive--- debugfs/htree.c | 2 +- e2fsck/pass1.c | 22 +++++++++++----------- e2fsck/pass2.c | 2 +- e2fsck/pass4.c | 2 +- e2fsck/rehash.c | 4 ++-- ext2ed/inode_com.c | 14 +++++++------- lib/e2p/fgetflags.c | 6 +++--- lib/e2p/fsetflags.c | 6 +++--- lib/e2p/getflags.c | 6 +++--- lib/e2p/pf.c | 34 +++++++++++++++++----------------- lib/e2p/setflags.c | 6 +++--- lib/ext2fs/ext2_fs.h | 44 ++++++++++++++++++++++---------------------- lib/ext2fs/link.c | 4 ++-- lib/ext2fs/mkjournal.c | 2 +- misc/chattr.c | 26 +++++++++++++------------- misc/tune2fs.c | 2 +- 16 files changed, 91 insertions(+), 91 deletions(-)
debugfs/htree.c +1 -1
@@ -243,7 +243,7 @@ void do_htree_dump(int argc, char *argv[]) goto errout; } -if ((inode.i_flags &EXT2_BTREE_FL ) ==0 ) { +if ((inode.i_flags &FS_BTREE_FL ) ==0 ) {com_err (argv[0 ],0 ,"Not a hash-indexed directory" ); goto errout; }
e2fsck/pass1.c +11 -11
@@ -138,7 +138,7 @@ int e2fsck_pass1_check_device_inode(ext2_filsys fs EXT2FS_ATTR((unused)),* If the index flag is set, then this is a bogus * device/fifo/socket */ -if (inode->i_flags &EXT2_INDEX_FL ) +if (inode->i_flags &FS_INDEX_FL )return 0 ;/*
@@ -152,7 +152,7 @@ int e2fsck_pass1_check_device_inode(ext2_filsys fs EXT2FS_ATTR((unused)),* you can't set or clear immutable flags for devices.) Once * the kernel has been fixed we can change this... */ -if (inode->i_flags & (EXT2_IMMUTABLE_FL |EXT2_APPEND_FL )) { +if (inode->i_flags & (FS_IMMUTABLE_FL |FS_APPEND_FL )) {for (i=4 ; i <EXT2_N_BLOCKS ; i++)if (inode->i_block[i])return 0 ;
@@ -175,7 +175,7 @@ int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino,struct ext2fs_extent extent;if ((inode->i_size_high || inode->i_size ==0 ) || - (inode->i_flags &EXT2_INDEX_FL )) + (inode->i_flags &FS_INDEX_FL ))return 0 ;if (inode->i_flags &EXT4_EXTENTS_FL ) {
@@ -235,7 +235,7 @@ int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino,* If the immutable (or append-only) flag is set on the inode, offer * to clear it. */ -#define BAD_SPECIAL_FLAGS (EXT2_IMMUTABLE_FL | EXT2_APPEND_FL) +#define BAD_SPECIAL_FLAGS (FS_IMMUTABLE_FL | FS_APPEND_FL)static void check_immutable (e2fsck_t ctx,struct problem_context *pctx) {if (!(pctx->inode->i_flags &BAD_SPECIAL_FLAGS ))
@@ -989,7 +989,7 @@ void e2fsck_pass1(e2fsck_t ctx) EXT4_FEATURE_RO_COMPAT_HUGE_FILE) && (inode->osd2.linux2.l_i_blocks_hi != 0))mark_inode_bad (ctx, ino); -if (inode->i_flags &EXT2_IMAGIC_FL ) { +if (inode->i_flags &FS_IMAGIC_FL ) {if (imagic_fs) {if (!ctx->inode_imagic_map)alloc_imagic_map (ctx);
@@ -997,7 +997,7 @@ void e2fsck_pass1(e2fsck_t ctx) ino); }else {if (fix_problem (ctx,PR_1_SET_IMAGIC , &pctx)) { - inode->i_flags &= ~EXT2_IMAGIC_FL ; + inode->i_flags &= ~FS_IMAGIC_FL ;e2fsck_write_inode (ctx, ino, inode,"pass1" ); }
@@ -1893,13 +1893,13 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, extent_fs = (ctx->fs->super->s_feature_incompat &EXT3_FEATURE_INCOMPAT_EXTENTS ); -if (inode->i_flags &EXT2_COMPRBLK_FL ) { +if (inode->i_flags &FS_COMPRBLK_FL ) {if (fs->super->s_feature_incompat &EXT2_FEATURE_INCOMPAT_COMPRESSION ) pb.compressed =1 ;else {if (fix_problem (ctx,PR_1_COMPR_SET , pctx)) { - inode->i_flags &= ~EXT2_COMPRBLK_FL ; + inode->i_flags &= ~FS_COMPRBLK_FL ; dirty_inode++; } }
@@ -1940,9 +1940,9 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,return ; } -if (inode->i_flags &EXT2_INDEX_FL ) { +if (inode->i_flags &FS_INDEX_FL ) {if (handle_htree (ctx, pctx, ino, inode, block_buf)) { - inode->i_flags &= ~EXT2_INDEX_FL ; + inode->i_flags &= ~FS_INDEX_FL ; dirty_inode++; }else {#ifdef ENABLE_HTREE
@@ -2043,7 +2043,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, }if (ctx->dirs_to_hash && pb.is_dir && - !(inode->i_flags &EXT2_INDEX_FL ) && + !(inode->i_flags &FS_INDEX_FL ) && ((inode->i_size / fs->blocksize) >=3 ))ext2fs_u32_list_add (ctx->dirs_to_hash, ino);
e2fsck/pass2.c +1 -1
@@ -1240,7 +1240,7 @@ static void clear_htree(e2fsck_t ctx, ext2_ino_t ino)struct ext2_inode inode;e2fsck_read_inode (ctx, ino, &inode,"clear_htree" ); - inode.i_flags = inode.i_flags & ~EXT2_INDEX_FL ; + inode.i_flags = inode.i_flags & ~FS_INDEX_FL ;e2fsck_write_inode (ctx, ino, &inode,"clear_htree" );if (ctx->dirs_to_hash)ext2fs_u32_list_add (ctx->dirs_to_hash, ino);
e2fsck/pass4.c +1 -1
@@ -171,7 +171,7 @@ void e2fsck_pass4(e2fsck_t ctx)/* i_link_count was previously exceeded, but no longer * is, fix this but don't consider it an error */ if ((isdir && link_counted >1 && - (inode->i_flags &EXT2_INDEX_FL ) && + (inode->i_flags &FS_INDEX_FL ) && link_count ==1 && !(ctx->options &E2F_OPT_NO )) ||fix_problem (ctx,PR_4_BAD_REF_COUNT , &pctx)) { inode->i_links_count = link_counted;
e2fsck/rehash.c +2 -2
@@ -689,9 +689,9 @@ static errcode_t write_directory(e2fsck_t ctx, ext2_filsys fs,e2fsck_read_inode (ctx, ino, &inode,"rehash_dir" );if (compress) - inode.i_flags &= ~EXT2_INDEX_FL ; + inode.i_flags &= ~FS_INDEX_FL ;else - inode.i_flags |=EXT2_INDEX_FL ; + inode.i_flags |=FS_INDEX_FL ; inode.i_size = outdir->num * fs->blocksize;ext2fs_iblk_sub_blocks (fs, &inode, wd.cleared);e2fsck_write_inode (ctx, ino, &inode,"rehash_dir" );
ext2ed/inode_com.c +7 -7
@@ -169,38 +169,38 @@ void type_ext2_inode___show (char *command_line)wmove (show_pad,10 ,40 ); temp=inode_ptr->i_flags; -if (temp &EXT2_SECRM_FL ) +if (temp &FS_SECRM_FL )wprintw (show_pad,"s" );else wprintw (show_pad,"-" ); -if (temp &EXT2_UNRM_FL ) +if (temp &FS_UNRM_FL )wprintw (show_pad,"u" );else wprintw (show_pad,"-" ); -if (temp &EXT2_COMPR_FL ) +if (temp &FS_COMPR_FL )wprintw (show_pad,"c" );else wprintw (show_pad,"-" ); -if (temp &EXT2_SYNC_FL ) +if (temp &FS_SYNC_FL )wprintw (show_pad,"S" );else wprintw (show_pad,"-" ); -if (temp &EXT2_IMMUTABLE_FL ) +if (temp &FS_IMMUTABLE_FL )wprintw (show_pad,"i" );else wprintw (show_pad,"-" ); -if (temp &EXT2_APPEND_FL ) +if (temp &FS_APPEND_FL )wprintw (show_pad,"a" );else wprintw (show_pad,"-" ); -if (temp &EXT2_NODUMP_FL ) +if (temp &FS_NODUMP_FL )wprintw (show_pad,"d" );else wprintw (show_pad,"-" );
lib/e2p/fgetflags.c +3 -3
@@ -51,15 +51,15 @@ int fgetflags (const char * name, unsigned long * flags) *flags =0 ;#ifdef UF_IMMUTABLE if (buf.st_flags &UF_IMMUTABLE ) - *flags |=EXT2_IMMUTABLE_FL ; + *flags |=FS_IMMUTABLE_FL ;#endif #ifdef UF_APPEND if (buf.st_flags &UF_APPEND ) - *flags |=EXT2_APPEND_FL ; + *flags |=FS_APPEND_FL ;#endif #ifdef UF_NODUMP if (buf.st_flags &UF_NODUMP ) - *flags |=EXT2_NODUMP_FL ; + *flags |=FS_NODUMP_FL ;#endif return 0 ;
lib/e2p/fsetflags.c +3 -3
@@ -56,15 +56,15 @@ int fsetflags (const char * name, unsigned long flags)unsigned long bsd_flags =0 ;#ifdef UF_IMMUTABLE -if (flags &EXT2_IMMUTABLE_FL ) +if (flags &FS_IMMUTABLE_FL ) bsd_flags |=UF_IMMUTABLE ;#endif #ifdef UF_APPEND -if (flags &EXT2_APPEND_FL ) +if (flags &FS_APPEND_FL ) bsd_flags |=UF_APPEND ;#endif #ifdef UF_NODUMP -if (flags &EXT2_NODUMP_FL ) +if (flags &FS_NODUMP_FL ) bsd_flags |=UF_NODUMP ;#endif
lib/e2p/getflags.c +3 -3
@@ -38,15 +38,15 @@ int getflags (int fd, unsigned long * flags) *flags =0 ;#ifdef UF_IMMUTABLE if (buf.st_flags &UF_IMMUTABLE ) - *flags |=EXT2_IMMUTABLE_FL ; + *flags |=FS_IMMUTABLE_FL ;#endif #ifdef UF_APPEND if (buf.st_flags &UF_APPEND ) - *flags |=EXT2_APPEND_FL ; + *flags |=FS_APPEND_FL ;#endif #ifdef UF_NODUMP if (buf.st_flags &UF_NODUMP ) - *flags |=EXT2_NODUMP_FL ; + *flags |=FS_NODUMP_FL ;#endif return 0 ;
lib/e2p/pf.c +17 -17
@@ -27,25 +27,25 @@ struct flags_name { };static struct flags_name flags_array[] = { - {EXT2_SECRM_FL ,"s" ,"Secure_Deletion" }, - {EXT2_UNRM_FL ,"u" ,"Undelete" }, - {EXT2_SYNC_FL ,"S" ,"Synchronous_Updates" }, - {EXT2_DIRSYNC_FL ,"D" ,"Synchronous_Directory_Updates" }, - {EXT2_IMMUTABLE_FL ,"i" ,"Immutable" }, - {EXT2_APPEND_FL ,"a" ,"Append_Only" }, - {EXT2_NODUMP_FL ,"d" ,"No_Dump" }, - {EXT2_NOATIME_FL ,"A" ,"No_Atime" }, - {EXT2_COMPR_FL ,"c" ,"Compression_Requested" }, + {FS_SECRM_FL ,"s" ,"Secure_Deletion" }, + {FS_UNRM_FL ,"u" ,"Undelete" }, + {FS_SYNC_FL ,"S" ,"Synchronous_Updates" }, + {FS_DIRSYNC_FL ,"D" ,"Synchronous_Directory_Updates" }, + {FS_IMMUTABLE_FL ,"i" ,"Immutable" }, + {FS_APPEND_FL ,"a" ,"Append_Only" }, + {FS_NODUMP_FL ,"d" ,"No_Dump" }, + {FS_NOATIME_FL ,"A" ,"No_Atime" }, + {FS_COMPR_FL ,"c" ,"Compression_Requested" }, #ifdef ENABLE_COMPRESSION - {EXT2_COMPRBLK_FL ,"B" ,"Compressed_File" }, - {EXT2_DIRTY_FL ,"Z" ,"Compressed_Dirty_File" }, - {EXT2_NOCOMPR_FL ,"X" ,"Compression_Raw_Access" }, - {EXT2_ECOMPR_FL ,"E" ,"Compression_Error" }, + {FS_COMPRBLK_FL ,"B" ,"Compressed_File" }, + {FS_DIRTY_FL ,"Z" ,"Compressed_Dirty_File" }, + {FS_NOCOMPR_FL ,"X" ,"Compression_Raw_Access" }, + {FS_ECOMPR_FL ,"E" ,"Compression_Error" }, #endif - {EXT3_JOURNAL_DATA_FL ,"j" ,"Journaled_Data" }, - {EXT2_INDEX_FL ,"I" ,"Indexed_directory" }, - {EXT2_NOTAIL_FL ,"t" ,"No_Tailmerging" }, - {EXT2_TOPDIR_FL ,"T" ,"Top_of_Directory_Hierarchies" }, + {FS_JOURNAL_DATA_FL ,"j" ,"Journaled_Data" }, + {FS_INDEX_FL ,"I" ,"Indexed_directory" }, + {FS_NOTAIL_FL ,"t" ,"No_Tailmerging" }, + {FS_TOPDIR_FL ,"T" ,"Top_of_Directory_Hierarchies" }, {EXT4_EXTENTS_FL ,"e" ,"Extents" }, {EXT4_HUGE_FILE_FL ,"h" ,"Huge_file" }, {0 ,NULL ,NULL }
lib/e2p/setflags.c +3 -3
@@ -43,15 +43,15 @@ int setflags (int fd, unsigned long flags)unsigned long bsd_flags =0 ;#ifdef UF_IMMUTABLE -if (flags &EXT2_IMMUTABLE_FL ) +if (flags &FS_IMMUTABLE_FL ) bsd_flags |=UF_IMMUTABLE ;#endif #ifdef UF_APPEND -if (flags &EXT2_APPEND_FL ) +if (flags &FS_APPEND_FL ) bsd_flags |=UF_APPEND ;#endif #ifdef UF_NODUMP -if (flags &EXT2_NODUMP_FL ) +if (flags &FS_NODUMP_FL ) bsd_flags |=UF_NODUMP ;#endif
lib/ext2fs/ext2_fs.h +22 -22
59 lines not on this page · raw message
lib/ext2fs/link.c +2 -2
@@ -143,8 +143,8 @@ errcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name,if ((retval =ext2fs_read_inode (fs, dir, &inode)) !=0 )return retval; -if (inode.i_flags &EXT2_INDEX_FL ) { - inode.i_flags &= ~EXT2_INDEX_FL ; +if (inode.i_flags &FS_INDEX_FL ) { + inode.i_flags &= ~FS_INDEX_FL ;if ((retval =ext2fs_write_inode (fs, dir, &inode)) !=0 )return retval; }
lib/ext2fs/mkjournal.c +1 -1
@@ -521,7 +521,7 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags) retval = errno; goto errout; } - f |=EXT2_NODUMP_FL |EXT2_IMMUTABLE_FL ; + f |=FS_NODUMP_FL |FS_IMMUTABLE_FL ; retval =ioctl (fd,EXT2_IOC_SETFLAGS , &f);#endif #endif
misc/chattr.c +13 -13
@@ -93,19 +93,19 @@ struct flags_char { };static const struct flags_char flags_array[] = { - {EXT2_NOATIME_FL ,'A' }, - {EXT2_SYNC_FL ,'S' }, - {EXT2_DIRSYNC_FL ,'D' }, - {EXT2_APPEND_FL ,'a' }, - {EXT2_COMPR_FL ,'c' }, - {EXT2_NODUMP_FL ,'d' }, + {FS_NOATIME_FL ,'A' }, + {FS_SYNC_FL ,'S' }, + {FS_DIRSYNC_FL ,'D' }, + {FS_APPEND_FL ,'a' }, + {FS_COMPR_FL ,'c' }, + {FS_NODUMP_FL ,'d' }, {EXT4_EXTENTS_FL ,'e' }, - {EXT2_IMMUTABLE_FL ,'i' }, - {EXT3_JOURNAL_DATA_FL ,'j' }, - {EXT2_SECRM_FL ,'s' }, - {EXT2_UNRM_FL ,'u' }, - {EXT2_NOTAIL_FL ,'t' }, - {EXT2_TOPDIR_FL ,'T' }, + {FS_IMMUTABLE_FL ,'i' }, + {FS_JOURNAL_DATA_FL ,'j' }, + {FS_SECRM_FL ,'s' }, + {FS_UNRM_FL ,'u' }, + {FS_NOTAIL_FL ,'t' }, + {FS_TOPDIR_FL ,'T' }, {0 ,0 } };
@@ -242,7 +242,7 @@ static int change_attributes(const char * name)printf ("\n" ); }if (!S_ISDIR (st.st_mode)) - flags &= ~EXT2_DIRSYNC_FL ; + flags &= ~FS_DIRSYNC_FL ;if (fsetflags (name, flags) ==-1 ) {if (!silent) { com_err(program_name, errno,
misc/tune2fs.c +1 -1
@@ -303,7 +303,7 @@ static void remove_journal_inode(ext2_filsys fs)ext2fs_mark_bb_dirty (fs); fs->flags &= ~EXT2_FLAG_SUPER_ONLY ; }else - inode.i_flags &= ~EXT2_IMMUTABLE_FL ; + inode.i_flags &= ~FS_IMMUTABLE_FL ; retval =ext2fs_write_inode (fs, ino, &inode);if (retval) { com_err(program_name, retval,
Signature · 1 line
1.6.5.2
On 2011年04月18日 15:37, liubo Wrote:
Quoted 20 lines
Signed-off-by Liu Bo <[email protected]>--- debugfs/htree.c | 2 +- e2fsck/pass1.c | 22 +++++++++++----------- e2fsck/pass2.c | 2 +- e2fsck/pass4.c | 2 +- e2fsck/rehash.c | 4 ++-- ext2ed/inode_com.c | 14 +++++++------- lib/e2p/fgetflags.c | 6 +++--- lib/e2p/fsetflags.c | 6 +++--- lib/e2p/getflags.c | 6 +++--- lib/e2p/pf.c | 34 +++++++++++++++++----------------- lib/e2p/setflags.c | 6 +++--- lib/ext2fs/ext2_fs.h | 44 ++++++++++++++++++++++---------------------- lib/ext2fs/link.c | 4 ++-- lib/ext2fs/mkjournal.c | 2 +- misc/chattr.c | 26 +++++++++++++------------- misc/tune2fs.c | 2 +- 16 files changed, 91 insertions(+), 91 deletions(-)
Quoted 1 line
[snip]
Hi Bo,
Could you please to introduce the motivation of this patch set a little bit more? Thanks.
Signature · 5 lines
Coly Li -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 22 lines · Coly Li
On 2011年04月18日 15:37, liubo Wrote:
Quoted 19 lines
Signed-off-by Liu Bo <[email protected]>--- debugfs/htree.c | 2 +- e2fsck/pass1.c | 22 +++++++++++----------- e2fsck/pass2.c | 2 +- e2fsck/pass4.c | 2 +- e2fsck/rehash.c | 4 ++-- ext2ed/inode_com.c | 14 +++++++------- lib/e2p/fgetflags.c | 6 +++--- lib/e2p/fsetflags.c | 6 +++--- lib/e2p/getflags.c | 6 +++--- lib/e2p/pf.c | 34 +++++++++++++++++----------------- lib/e2p/setflags.c | 6 +++--- lib/ext2fs/ext2_fs.h | 44 ++++++++++++++++++++++---------------------- lib/ext2fs/link.c | 4 ++-- lib/ext2fs/mkjournal.c | 2 +- misc/chattr.c | 26 +++++++++++++------------- misc/tune2fs.c | 2 +- 16 files changed, 91 insertions(+), 91 deletions(-)Quoted 1 line
[snip]
Quoted 4 lines
Hi Bo,
Could you please to introduce the motivation of this patch set a little bit more? Thanks.
Hi Li,
Since we want to control COW and compression attribute on a per file or per directory basis, and find that the generic command "chattr" is the "Mr Right".
Currently only btrfs supports both, of course.
With these patches, we can do the followings:
c: compress
C: nocow
set compress & nocow:
# ./misc/chattr -V +c +C /mnt/btrfs/dir/ chattr 1.41.14 (22-Dec-2010) Flags of /mnt/btrfs/dir/ set as --------c------C
# ./misc/lsattr -d /mnt/btrfs/dir/ --------c------C /mnt/btrfs/dir/
thanks,
liubo
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
On 2011年04月18日 17:01, liubo Wrote:
Quoted 40 lines · Coly Li
Quoted 22 lines
On 2011年04月18日 15:37, liubo Wrote:
Quoted 19 lines
Signed-off-by Liu Bo <[email protected]>--- debugfs/htree.c | 2 +- e2fsck/pass1.c | 22 +++++++++++----------- e2fsck/pass2.c | 2 +- e2fsck/pass4.c | 2 +- e2fsck/rehash.c | 4 ++-- ext2ed/inode_com.c | 14 +++++++------- lib/e2p/fgetflags.c | 6 +++--- lib/e2p/fsetflags.c | 6 +++--- lib/e2p/getflags.c | 6 +++--- lib/e2p/pf.c | 34 +++++++++++++++++----------------- lib/e2p/setflags.c | 6 +++--- lib/ext2fs/ext2_fs.h | 44 ++++++++++++++++++++++---------------------- lib/ext2fs/link.c | 4 ++-- lib/ext2fs/mkjournal.c | 2 +- misc/chattr.c | 26 +++++++++++++------------- misc/tune2fs.c | 2 +- 16 files changed, 91 insertions(+), 91 deletions(-)Quoted 1 line
[snip]
Quoted 4 lines
Hi Bo,
Could you please to introduce the motivation of this patch set a little bit more? Thanks.
Hi Li,
Since we want to control COW and compression attribute on a per file or per directory basis, and find that the generic command "chattr" is the "Mr Right".
Currently only btrfs supports both, of course.
With these patches, we can do the followings:
c: compress
C: nocow
Quoted 9 lines
set compress & nocow:
# ./misc/chattr -V +c +C /mnt/btrfs/dir/ chattr 1.41.14 (22-Dec-2010) Flags of /mnt/btrfs/dir/ set as --------c------C# ./misc/lsattr -d /mnt/btrfs/dir/ --------c------C /mnt/btrfs/dir/
Thank you for the explaining. Now I understand this patch set is to make chattr of e2fsprogs to support a (currently-only) btrfs feature.
It seems chattr and lsattr is not an ext[234] only utilities any more...
Signature · 5 lines
Coly Li -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Coly Li
It seems chattr and lsattr is not an ext[234] only utilities any more...
They haven't been for a long time.