Skip to content

Commit f93ca1e

Browse files
eafertorvalds
authored andcommitted
hfsplus: return file attributes on statx
The immutable, append-only and no-dump attributes can only be retrieved with an ioctl; implement the ->getattr() method to return them on statx. Do not return the inode birthtime yet, because the issue of how best to handle the post-2038 timestamps is still under discussion. This patch is needed to pass xfstests generic/424. Link: http://lkml.kernel.org/r/20181014163558.sxorxlzjqccq2lpw@eaf Signed-off-by: Ernesto A. Fernández <[email protected]> Cc: Viacheslav Dubeyko <[email protected]> Cc: Al Viro <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent f516221 commit f93ca1e

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

fs/hfsplus/dir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ const struct inode_operations hfsplus_dir_inode_operations = {
565565
.symlink = hfsplus_symlink,
566566
.mknod = hfsplus_mknod,
567567
.rename = hfsplus_rename,
568+
.getattr = hfsplus_getattr,
568569
.listxattr = hfsplus_listxattr,
569570
};
570571

fs/hfsplus/hfsplus_fs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ void hfsplus_inode_write_fork(struct inode *inode,
488488
struct hfsplus_fork_raw *fork);
489489
int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd);
490490
int hfsplus_cat_write_inode(struct inode *inode);
491+
int hfsplus_getattr(const struct path *path, struct kstat *stat,
492+
u32 request_mask, unsigned int query_flags);
491493
int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
492494
int datasync);
493495

fs/hfsplus/inode.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,26 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)
270270
return 0;
271271
}
272272

273+
int hfsplus_getattr(const struct path *path, struct kstat *stat,
274+
u32 request_mask, unsigned int query_flags)
275+
{
276+
struct inode *inode = d_inode(path->dentry);
277+
struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
278+
279+
if (inode->i_flags & S_APPEND)
280+
stat->attributes |= STATX_ATTR_APPEND;
281+
if (inode->i_flags & S_IMMUTABLE)
282+
stat->attributes |= STATX_ATTR_IMMUTABLE;
283+
if (hip->userflags & HFSPLUS_FLG_NODUMP)
284+
stat->attributes |= STATX_ATTR_NODUMP;
285+
286+
stat->attributes_mask |= STATX_ATTR_APPEND | STATX_ATTR_IMMUTABLE |
287+
STATX_ATTR_NODUMP;
288+
289+
generic_fillattr(inode, stat);
290+
return 0;
291+
}
292+
273293
int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
274294
int datasync)
275295
{
@@ -329,6 +349,7 @@ int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
329349

330350
static const struct inode_operations hfsplus_file_inode_operations = {
331351
.setattr = hfsplus_setattr,
352+
.getattr = hfsplus_getattr,
332353
.listxattr = hfsplus_listxattr,
333354
};
334355

0 commit comments

Comments
 (0)