Skip to content

Commit fa2fcf4

Browse files
author
Miklos Szeredi
committed
statx: add mount ID
Systemd is hacking around to get it and it's trivial to add to statx, so... Cc: [email protected] Cc: [email protected] Signed-off-by: Miklos Szeredi <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 761e28f commit fa2fcf4

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

fs/stat.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <asm/unistd.h>
2323

2424
#include "internal.h"
25+
#include "mount.h"
2526

2627
/**
2728
* generic_fillattr - Fill in the basic attributes from the inode struct
@@ -199,6 +200,8 @@ int vfs_statx(int dfd, const char __user *filename, int flags,
199200
goto out;
200201

201202
error = vfs_getattr(&path, stat, request_mask, flags);
203+
stat->mnt_id = real_mount(path.mnt)->mnt_id;
204+
stat->result_mask |= STATX_MNT_ID;
202205
path_put(&path);
203206
if (retry_estale(error, lookup_flags)) {
204207
lookup_flags |= LOOKUP_REVAL;
@@ -563,6 +566,7 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer)
563566
tmp.stx_rdev_minor = MINOR(stat->rdev);
564567
tmp.stx_dev_major = MAJOR(stat->dev);
565568
tmp.stx_dev_minor = MINOR(stat->dev);
569+
tmp.stx_mnt_id = stat->mnt_id;
566570

567571
return copy_to_user(buffer, &tmp, sizeof(tmp)) ? -EFAULT : 0;
568572
}

include/linux/stat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct kstat {
4747
struct timespec64 ctime;
4848
struct timespec64 btime; /* File creation time */
4949
u64 blocks;
50+
u64 mnt_id;
5051
};
5152

5253
#endif

include/uapi/linux/stat.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ struct statx {
123123
__u32 stx_dev_major; /* ID of device containing file [uncond] */
124124
__u32 stx_dev_minor;
125125
/* 0x90 */
126-
__u64 __spare2[14]; /* Spare space for future expansion */
126+
__u64 stx_mnt_id;
127+
__u64 __spare2;
128+
/* 0xa0 */
129+
__u64 __spare3[12]; /* Spare space for future expansion */
127130
/* 0x100 */
128131
};
129132

@@ -148,6 +151,7 @@ struct statx {
148151
#define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */
149152
#define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
150153
#define STATX_BTIME 0x00000800U /* Want/got stx_btime */
154+
#define STATX_MNT_ID 0x00001000U /* Got stx_mnt_id */
151155

152156
#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */
153157

0 commit comments

Comments
 (0)