Unverified Commit a4af51ce authored by Kent Overstreet's avatar Kent Overstreet Committed by Christian Brauner
Browse files

fs: super_set_uuid()



Some weird old filesytems have UUID-like things that we wish to expose
as UUIDs, but are smaller; add a length field so that the new
FS_IOC_(GET|SET)UUID ioctls can handle them in generic code.

And add a helper super_set_uuid(), for setting nonstandard length uuids.

Helper is now required for the new FS_IOC_GETUUID ioctl; if
super_set_uuid() hasn't been called, the ioctl won't be supported.

Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
Link: https://lore.kernel.org/r/20240207025624.1019754-2-kent.overstreet@linux.dev


Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 6613476e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5346,7 +5346,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
		sb->s_qcop = &ext4_qctl_operations;
	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
#endif
	memcpy(&sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
	super_set_uuid(sb, es->s_uuid, sizeof(es->s_uuid));

	INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
	mutex_init(&sbi->s_orphan_lock);
+1 −1
Original line number Diff line number Diff line
@@ -4496,7 +4496,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
	sb->s_time_gran = 1;
	sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
		(test_opt(sbi, POSIX_ACL) ? SB_POSIXACL : 0);
	memcpy(&sb->s_uuid, raw_super->uuid, sizeof(raw_super->uuid));
	super_set_uuid(sb, (void *) raw_super->uuid, sizeof(raw_super->uuid));
	sb->s_iflags |= SB_I_CGROUPWB;

	/* init f2fs-specific super block info */
+1 −1
Original line number Diff line number Diff line
@@ -214,7 +214,7 @@ static void gfs2_sb_in(struct gfs2_sbd *sdp, const void *buf)

	memcpy(sb->sb_lockproto, str->sb_lockproto, GFS2_LOCKNAME_LEN);
	memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN);
	memcpy(&s->s_uuid, str->sb_uuid, 16);
	super_set_uuid(s, str->sb_uuid, 16);
}

/**
+3 −1
Original line number Diff line number Diff line
@@ -358,7 +358,9 @@ int kernfs_get_tree(struct fs_context *fc)
		}
		sb->s_flags |= SB_ACTIVE;

		uuid_gen(&sb->s_uuid);
		uuid_t uuid;
		uuid_gen(&uuid);
		super_set_uuid(sb, uuid.b, sizeof(uuid));

		down_write(&root->kernfs_supers_rwsem);
		list_add(&info->node, &info->root->supers);
+2 −2
Original line number Diff line number Diff line
@@ -2027,7 +2027,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
	cbits = le32_to_cpu(di->id2.i_super.s_clustersize_bits);
	bbits = le32_to_cpu(di->id2.i_super.s_blocksize_bits);
	sb->s_maxbytes = ocfs2_max_file_offset(bbits, cbits);
	memcpy(&sb->s_uuid, di->id2.i_super.s_uuid,
	super_set_uuid(sb, di->id2.i_super.s_uuid,
		       sizeof(di->id2.i_super.s_uuid));

	osb->osb_dx_mask = (1 << (cbits - bbits)) - 1;
Loading