diff options
author | Theodore Ts'o <tytso@mit.edu> | 2011-10-16 20:29:00 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-10-16 20:46:49 -0400 |
commit | 0c80c44bd08c60f3cd0ad87f12a71a75cac3bcaa (patch) | |
tree | 67a7c88cc9f1ec48d47664d8c06f655acf568ae4 /lib | |
parent | 515e555a0c36ae0294d71ba9ba45f7fa576cfd0f (diff) | |
download | e2fsprogs-0c80c44bd08c60f3cd0ad87f12a71a75cac3bcaa.tar.gz |
libext2fs: ext2fs_[set_]file_acl_block needs to check for 64-bit feature flag
The ext2fs_file_acl_block() and ext2fs_set_file_acl_block() needs to
only check i_file_acl_high if the 64-bit flag is set. This is needed
because otherwise we will run into problems on Hurd systems which
actually use that field for h_i_mode_high.
This involves an ABI change since we need to pass ext2_filsys to these
functions. Fortunately these functions were first included in the
1.42-WIP series, so it's OK for us to change them now. (This is why
we have 1.42-WIP releases. :-)
Addresses-Sourceforge-Bug: #3379227
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ext2fs/blknum.c | 19 | ||||
-rw-r--r-- | lib/ext2fs/bmove.c | 2 | ||||
-rw-r--r-- | lib/ext2fs/ext2fs.h | 8 | ||||
-rw-r--r-- | lib/ext2fs/valid_blk.c | 9 | ||||
-rw-r--r-- | lib/quota/quotaio.c | 2 |
5 files changed, 25 insertions, 15 deletions
diff --git a/lib/ext2fs/blknum.c b/lib/ext2fs/blknum.c index fd203b4d..33da7d6f 100644 --- a/lib/ext2fs/blknum.c +++ b/lib/ext2fs/blknum.c @@ -475,23 +475,24 @@ void ext2fs_bg_checksum_set(ext2_filsys fs, dgrp_t group, __u16 checksum) /* * Get the acl block of a file - * - * XXX Ignoring 64-bit file system flag - most places where this is - * called don't have access to the fs struct, and the high bits should - * be 0 in the non-64-bit case anyway. */ -blk64_t ext2fs_file_acl_block(const struct ext2_inode *inode) +blk64_t ext2fs_file_acl_block(ext2_filsys fs, const struct ext2_inode *inode) { - return (inode->i_file_acl | - (__u64) inode->osd2.linux2.l_i_file_acl_high << 32); + blk64_t blk = inode->i_file_acl; + + if (fs && fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) + blk |= ((__u64) inode->osd2.linux2.l_i_file_acl_high) << 32; + return blk; } /* * Set the acl block of a file */ -void ext2fs_file_acl_block_set(struct ext2_inode *inode, blk64_t blk) +void ext2fs_file_acl_block_set(ext2_filsys fs, struct ext2_inode *inode, + blk64_t blk) { inode->i_file_acl = blk; - inode->osd2.linux2.l_i_file_acl_high = (__u64) blk >> 32; + if (fs && fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) + inode->osd2.linux2.l_i_file_acl_high = (__u64) blk >> 32; } diff --git a/lib/ext2fs/bmove.c b/lib/ext2fs/bmove.c index d0579985..e2ea405a 100644 --- a/lib/ext2fs/bmove.c +++ b/lib/ext2fs/bmove.c @@ -141,7 +141,7 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs, while (ino) { if ((inode.i_links_count == 0) || - !ext2fs_inode_has_valid_blocks(&inode)) + !ext2fs_inode_has_valid_blocks2(fs, &inode)) goto next; pb.ino = ino; diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 411a383a..57c5bfaf 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -841,8 +841,10 @@ extern void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags); extern void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flags); extern __u16 ext2fs_bg_checksum(ext2_filsys fs, dgrp_t group); extern void ext2fs_bg_checksum_set(ext2_filsys fs, dgrp_t group, __u16 checksum); -extern blk64_t ext2fs_file_acl_block(const struct ext2_inode *inode); -extern void ext2fs_file_acl_block_set(struct ext2_inode *inode, blk64_t blk); +extern blk64_t ext2fs_file_acl_block(ext2_filsys fs, + const struct ext2_inode *inode); +extern void ext2fs_file_acl_block_set(ext2_filsys fs, + struct ext2_inode *inode, blk64_t blk); /* block.c */ extern errcode_t ext2fs_block_iterate(ext2_filsys fs, @@ -1396,6 +1398,8 @@ extern void ext2fs_swap_mmp(struct mmp_struct *mmp); /* valid_blk.c */ extern int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode); +extern int ext2fs_inode_has_valid_blocks2(ext2_filsys fs, + struct ext2_inode *inode); /* version.c */ extern int ext2fs_parse_version_string(const char *ver_string); diff --git a/lib/ext2fs/valid_blk.c b/lib/ext2fs/valid_blk.c index 9047f41f..895e36ef 100644 --- a/lib/ext2fs/valid_blk.c +++ b/lib/ext2fs/valid_blk.c @@ -24,7 +24,7 @@ * This function returns 1 if the inode's block entries actually * contain block entries. */ -int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode) +int ext2fs_inode_has_valid_blocks2(ext2_filsys fs, struct ext2_inode *inode) { /* * Only directories, regular files, and some symbolic links @@ -39,7 +39,7 @@ int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode) * target is stored in the block entries. */ if (LINUX_S_ISLNK (inode->i_mode)) { - if (ext2fs_file_acl_block(inode) == 0) { + if (ext2fs_file_acl_block(fs, inode) == 0) { /* With no EA block, we can rely on i_blocks */ if (inode->i_blocks == 0) return 0; @@ -54,3 +54,8 @@ int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode) } return 1; } + +int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode) +{ + return ext2fs_inode_has_valid_blocks2(NULL, inode); +} diff --git a/lib/quota/quotaio.c b/lib/quota/quotaio.c index 04578868..8430db14 100644 --- a/lib/quota/quotaio.c +++ b/lib/quota/quotaio.c @@ -110,7 +110,7 @@ void truncate_quota_inode(ext2_filsys fs, ext2_ino_t ino) return; inode.i_dtime = fs->now ? fs->now : time(0); - if (!ext2fs_inode_has_valid_blocks(&inode)) + if (!ext2fs_inode_has_valid_blocks2(fs, &inode)) return; ext2fs_block_iterate3(fs, ino, BLOCK_FLAG_READ_ONLY, NULL, |