@@ -1573,6 +1573,8 @@ extern int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry,
struct kstat *stat);
extern int ext4_file_getattr(struct vfsmount *mnt, struct dentry *dentry,
struct kstat *stat);
+extern int ext4_getattr_extra(struct vfsmount *, struct dentry *,
+ struct xstat_extra_result *);
extern void ext4_delete_inode(struct inode *);
extern int ext4_sync_inode(handle_t *, struct inode *);
extern void ext4_dirty_inode(struct inode *);
@@ -151,6 +151,7 @@ const struct inode_operations ext4_file_inode_operations = {
.truncate = ext4_truncate,
.setattr = ext4_setattr,
.getattr = ext4_file_getattr,
+ .getattr_extra = ext4_getattr_extra,
#ifdef CONFIG_EXT4_FS_XATTR
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
@@ -5595,6 +5595,56 @@ int ext4_file_getattr(struct vfsmount *mnt, struct dentry *dentry,
return 0;
}
+int ext4_getattr_inode_flags(struct inode *inode,
+ struct xstat_extra_result *extra)
+{
+ struct ext4_inode_info *ei = EXT4_I(inode);
+ struct xstat_inode_flags xif = { 0, 0 };
+
+#define _(FL, ST) \
+ xif.st_supported_flags |= ST; \
+ if (ei->i_flags & FL) \
+ xif.st_flags |= ST;
+
+ _(EXT4_COMPR_FL, UF_COMPRESSED);
+ _(EXT4_SYNC_FL, XSTAT_LF_SYNC);
+ _(EXT4_IMMUTABLE_FL, UF_IMMUTABLE | SF_IMMUTABLE);
+ _(EXT4_APPEND_FL, UF_APPEND | SF_APPEND);
+ _(EXT4_NODUMP_FL, UF_NODUMP);
+ _(EXT4_NOATIME_FL, XSTAT_LF_NOATIME);
+ _(EXT4_JOURNAL_DATA_FL, XSTAT_LF_JOURNALLED_DATA);
+
+ if (S_ISDIR(ei->vfs_inode.i_mode))
+ _(EXT4_DIRSYNC_FL, XSTAT_LF_SYNC);
+
+ return extra->pass_result(extra, ilog2(XSTAT_REQUEST_INODE_FLAGS),
+ &xif, sizeof(xif));
+}
+
+int ext4_getattr_extra(struct vfsmount *mnt, struct dentry *dentry,
+ struct xstat_extra_result *extra)
+{
+ struct inode *inode = dentry->d_inode;
+ u64 request_mask = extra->request_mask;
+ int request, ret;
+
+ do {
+ request = __ffs64(request_mask);
+ request_mask &= ~(1ULL << request);
+
+ switch (request) {
+ case ilog2(XSTAT_REQUEST_INODE_FLAGS):
+ ret = ext4_getattr_inode_flags(inode, extra);
+ break;
+ default:
+ ret = 0;
+ break;
+ }
+
+ } while (ret == 0 && request_mask);
+ return ret;
+}
+
static int ext4_indirect_trans_blocks(struct inode *inode, int nrblocks,
int chunk)
{
@@ -2543,6 +2543,7 @@ const struct inode_operations ext4_dir_inode_operations = {
.rename = ext4_rename,
.setattr = ext4_setattr,
.getattr = ext4_getattr,
+ .getattr_extra = ext4_getattr_extra,
#ifdef CONFIG_EXT4_FS_XATTR
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
@@ -2556,6 +2557,7 @@ const struct inode_operations ext4_dir_inode_operations = {
const struct inode_operations ext4_special_inode_operations = {
.setattr = ext4_setattr,
.getattr = ext4_getattr,
+ .getattr_extra = ext4_getattr_extra,
#ifdef CONFIG_EXT4_FS_XATTR
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
@@ -36,6 +36,7 @@ const struct inode_operations ext4_symlink_inode_operations = {
.put_link = page_put_link,
.setattr = ext4_setattr,
.getattr = ext4_getattr,
+ .getattr_extra = ext4_getattr_extra,
#ifdef CONFIG_EXT4_FS_XATTR
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
@@ -49,6 +50,7 @@ const struct inode_operations ext4_fast_symlink_inode_operations = {
.follow_link = ext4_follow_link,
.setattr = ext4_setattr,
.getattr = ext4_getattr,
+ .getattr_extra = ext4_getattr_extra,
#ifdef CONFIG_EXT4_FS_XATTR
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
@@ -107,7 +107,8 @@ struct xstat_parameters {
#define XSTAT_REQUEST_GEN 0x00001000ULL /* want/got st_gen */
#define XSTAT_REQUEST_DATA_VERSION 0x00002000ULL /* want/got st_data_version */
#define XSTAT_REQUEST__EXTENDED_STATS 0x00003fffULL /* the stuff in the xstat struct */
-#define XSTAT_REQUEST__ALL_STATS 0x00003fffULL /* the defined set of requestables */
+#define XSTAT_REQUEST_INODE_FLAGS 0x00004000ULL /* want/got xstat_inode_flags */
+#define XSTAT_REQUEST__ALL_STATS 0x00007fffULL /* the defined set of requestables */
#define XSTAT_REQUEST__EXTRA_STATS (XSTAT_REQUEST__ALL_STATS & ~XSTAT_REQUEST__EXTENDED_STATS)
};
@@ -140,6 +141,50 @@ struct xstat {
unsigned long long st_extra_results[0]; /* extra requested results */
};
+/*
+ * Extra result field for inode flags (XSTAT_REQUEST_INODE_FLAGS)
+ */
+struct xstat_inode_flags {
+ /* Flags set on the file
+ * - the LSW matches the BSD st_flags
+ * - the MSW are Linux-specific
+ */
+ unsigned long long st_flags;
+ /* st_flags that users can set */
+#define UF_SETTABLE 0x0000ffff
+#define UF_NODUMP 0x00000001 /* do not dump */
+#define UF_IMMUTABLE 0x00000002 /* immutable */
+#define UF_APPEND 0x00000004 /* append-only */
+#define UF_OPAQUE 0x00000008 /* directory is opaque (unionfs) */
+#define UF_NOUNLINK 0x00000010 /* can't be removed or renamed */
+#define UF_COMPRESSED 0x00000020 /* file is compressed */
+#define UF_HIDDEN 0x00008000 /* file shouldn't be displayed in a GUI */
+
+ /* st_flags that only root can set */
+#define SF_SETTABLE 0xffff0000
+#define SF_ARCHIVED 0x00010000 /* archived */
+#define SF_IMMUTABLE 0x00020000 /* immutable */
+#define SF_APPEND 0x00040000 /* append-only */
+#define SF_NOUNLINK 0x00100000 /* can't be removed or renamed */
+#define SF_SNAPSHOT 0x00200000 /* snapshot inode */
+
+ /* Linux-specific st_flags */
+#define XSTAT_LF_MAGIC_FILE (1ULL << 32) /* magic file, such as /proc/? and /sys/? */
+#define XSTAT_LF_SYNC (1ULL << 33) /* file is written synchronously */
+#define XSTAT_LF_NOATIME (1ULL << 34) /* atime is not updated on file */
+#define XSTAT_LF_JOURNALLED_DATA (1ULL << 35) /* data modifications to file are journalled */
+#define XSTAT_LF_ENCRYPTED (1ULL << 36) /* file is encrypted */
+#define XSTAT_LF_SYSTEM (1ULL << 37) /* system file */
+#define XSTAT_LF_TEMPORARY (1ULL << 38) /* temporary file */
+#define XSTAT_LF_OFFLINE (1ULL << 39) /* file is currently unavailable */
+
+ /* Which st_flags are actually supported by this filesystem for this
+ * file */
+ unsigned long long st_supported_flags;
+};
+#define XSTAT_LENGTH_INODE_FLAGS (sizeof(struct xstat_inode_flags))
+
+
#ifdef __KERNEL__
#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO)
#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)