mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
add unique mount ID
If a mount is released then its mnt_id can immediately be reused. This is bad news for user interfaces that want to uniquely identify a mount. Implementing a unique mount ID is trivial (use a 64bit counter). Unfortunately userspace assumes 32bit size and would overflow after the counter reaches 2^32. Introduce a new 64bit ID alongside the old one. Initialize the counter to 2^32, this guarantees that the old and new IDs are never mixed up. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Link: https://lore.kernel.org/r/20231025140205.3586473-2-mszeredi@redhat.com Reviewed-by: Ian Kent <raven@themaw.net> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
committed by
Christian Brauner
parent
b85ea95d08
commit
98d2b43081
@@ -243,8 +243,13 @@ retry:
|
||||
|
||||
error = vfs_getattr(&path, stat, request_mask, flags);
|
||||
|
||||
stat->mnt_id = real_mount(path.mnt)->mnt_id;
|
||||
stat->result_mask |= STATX_MNT_ID;
|
||||
if (request_mask & STATX_MNT_ID_UNIQUE) {
|
||||
stat->mnt_id = real_mount(path.mnt)->mnt_id_unique;
|
||||
stat->result_mask |= STATX_MNT_ID_UNIQUE;
|
||||
} else {
|
||||
stat->mnt_id = real_mount(path.mnt)->mnt_id;
|
||||
stat->result_mask |= STATX_MNT_ID;
|
||||
}
|
||||
|
||||
if (path.mnt->mnt_root == path.dentry)
|
||||
stat->attributes |= STATX_ATTR_MOUNT_ROOT;
|
||||
|
||||
Reference in New Issue
Block a user