I was thinking of a more generalized overlayfs solution that detects if file systems don't initialize the superblock uuid and overlayfs improvises by generating the internal overlayfs uuid, something like:
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 698d112bdb17..da3faaf68d69 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -248,6 +248,7 @@ struct ovl_fh *ovl_encode_real_fh(struct dentry *real, bool is_upper) void *buf; int buflen = MAX_HANDLE_SZ; uuid_t *uuid = &real->d_sb->s_uuid; + static const uuid_t z_uuid;
buf = kmalloc(buflen, GFP_KERNEL); if (!buf) @@ -289,7 +290,22 @@ struct ovl_fh *ovl_encode_real_fh(struct dentry *real, bool is_upper) if (is_upper) fh->flags |= OVL_FH_FLAG_PATH_UPPER; fh->len = fh_len; - fh->uuid = *uuid; + + if (uuid_equal(uuid, &z_uuid)) { + struct super_block *sb = real->d_sb; + u16 hash; + + pr_warn("ovl_encode_real_fh: ZERO UUID, generating one from superblock\n"); + + memcpy(&fh->uuid.b[0], &sb->s_magic, 8); + memcpy(&fh->uuid.b[8], &sb->s_dev, 6); + hash = ((long)sb ^ (long)sb->s_fs_info) >> 12; + memcpy(&fh->uuid.b[14], &hash, 2); + } else { + fh->uuid = *uuid; + } +
I was thinking of a more generalized overlayfs solution that detects if file systems don't initialize the superblock uuid and overlayfs improvises by generating the internal overlayfs uuid, something like:
diff --git a/fs/overlayfs/ copy_up. c b/fs/overlayfs/ copy_up. c .da3faaf68d69 100644 copy_up. c copy_up. c real_fh( struct dentry *real, bool is_upper) d_sb->s_ uuid;
index 698d112bdb17.
--- a/fs/overlayfs/
+++ b/fs/overlayfs/
@@ -248,6 +248,7 @@ struct ovl_fh *ovl_encode_
void *buf;
int buflen = MAX_HANDLE_SZ;
uuid_t *uuid = &real->
+ static const uuid_t z_uuid;
buf = kmalloc(buflen, GFP_KERNEL); real_fh( struct dentry *real, bool is_upper)
fh->flags |= OVL_FH_ FLAG_PATH_ UPPER; "ovl_encode_ real_fh: ZERO UUID, generating one from superblock\n"); &fh->uuid. b[0], &sb->s_magic, 8); &fh->uuid. b[8], &sb->s_dev, 6); >s_fs_info) >> 12; &fh->uuid. b[14], &hash, 2);
if (!buf)
@@ -289,7 +290,22 @@ struct ovl_fh *ovl_encode_
if (is_upper)
fh->len = fh_len;
- fh->uuid = *uuid;
+
+ if (uuid_equal(uuid, &z_uuid)) {
+ struct super_block *sb = real->d_sb;
+ u16 hash;
+
+ pr_warn(
+
+ memcpy(
+ memcpy(
+ hash = ((long)sb ^ (long)sb-
+ memcpy(
+ } else {
+ fh->uuid = *uuid;
+ }
+