Some filesystem have non-persistent UUIDs, that can change between mounting, even if the filesystem is not modified. To prevent false-positives when mounting overlayfs with index enabled, use the fsid reported from statfs that is persistent across mounts. Signed-off-by: André Almeida --- This patch is just for illustrative purposes and doesn't work. --- fs/overlayfs/copy_up.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index aac7e34f56c1..633d9470a089 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -421,9 +422,14 @@ struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct inode *realinode, struct ovl_fh *fh; int fh_type, dwords; int buflen = MAX_HANDLE_SZ; - uuid_t *uuid = &realinode->i_sb->s_uuid; + uuid_t uuid; + struct kstatfs ks; int err; + // RFC: dentry can't be NULL, uuid needs a type cast + realinode->i_sb->s_op->statfs(NULL, &ks); + uuid.b = ks.f_fsid; + /* Make sure the real fid stays 32bit aligned */ BUILD_BUG_ON(OVL_FH_FID_OFFSET % 4); BUILD_BUG_ON(MAX_HANDLE_SZ + OVL_FH_FID_OFFSET > 255); -- 2.51.0