summaryrefslogtreecommitdiff
path: root/fs/overlayfs
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2024-02-08 10:32:07 +0100
committerChristian Brauner <brauner@kernel.org>2024-02-12 13:14:21 +0100
commit01edea1bbd1768be41729fd018a82556fa1810ec (patch)
tree0d754800a9224b1d0f0a824dc03f00ef45461a65 /fs/overlayfs
parent6613476e225e090cc9aad49be7fa504e290dd33d (diff)
parent231e872529885483056c0170641ddd76686e3a89 (diff)
Merge series "filesystem visibility ioctls" of https://lore.kernel.org/r/20240207025624.1019754-1-kent.overstreet@linux.dev
Pull filesystem visibility ioctls series from Kent Overstreet: This patch series adds a few new ioctls to standardize a few interfaces to get and set filesystem uuid and retrieving the sysfs path. The get UUID ioctls are lifted versions of the ext4 ioctls with one difference, killing the flexible array member - we'll never have UUIDs more than 16 bytes, and getting rid of the flexible array member makes them easier to use. FS_IOC_GETFSSYSFSPATH is new, but it addresses something that we've been doing in fs specific code for awhile - "given a path on a mounted filesystem, tell me where it lives in sysfs". * series "filesystem visibility ioctls" of https://lore.kernel.org/r/20240207025624.1019754-1-kent.overstreet@linux.dev: (6 commits) xfs: add support for FS_IOC_GETFSSYSFSPATH fs: add FS_IOC_GETFSSYSFSPATH fat: Hook up sb->s_uuid fs: FS_IOC_GETUUID ovl: convert to super_set_uuid() fs: super_set_uuid() Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/overlayfs')
-rw-r--r--fs/overlayfs/util.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index 0217094c23ea..ed71480d8adb 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -760,13 +760,14 @@ bool ovl_init_uuid_xattr(struct super_block *sb, struct ovl_fs *ofs,
const struct path *upperpath)
{
bool set = false;
+ uuid_t uuid;
int res;
/* Try to load existing persistent uuid */
- res = ovl_path_getxattr(ofs, upperpath, OVL_XATTR_UUID, sb->s_uuid.b,
+ res = ovl_path_getxattr(ofs, upperpath, OVL_XATTR_UUID, uuid.b,
UUID_SIZE);
if (res == UUID_SIZE)
- return true;
+ goto set_uuid;
if (res != -ENODATA)
goto fail;
@@ -794,17 +795,20 @@ bool ovl_init_uuid_xattr(struct super_block *sb, struct ovl_fs *ofs,
}
/* Generate overlay instance uuid */
- uuid_gen(&sb->s_uuid);
+ uuid_gen(&uuid);
/* Try to store persistent uuid */
set = true;
- res = ovl_setxattr(ofs, upperpath->dentry, OVL_XATTR_UUID, sb->s_uuid.b,
+ res = ovl_setxattr(ofs, upperpath->dentry, OVL_XATTR_UUID, uuid.b,
UUID_SIZE);
- if (res == 0)
- return true;
+ if (res)
+ goto fail;
+
+set_uuid:
+ super_set_uuid(sb, uuid.b, sizeof(uuid));
+ return true;
fail:
- memset(sb->s_uuid.b, 0, UUID_SIZE);
ofs->config.uuid = OVL_UUID_NULL;
pr_warn("failed to %s uuid (%pd2, err=%i); falling back to uuid=null.\n",
set ? "set" : "get", upperpath->dentry, res);