Commit 39ba2b9a authored by Hongbo Li's avatar Hongbo Li Committed by Richard Weinberger
Browse files

ubifs: add support for FS_IOC_GETFSSYSFSPATH



In commit ae8c5117 ("fs: add FS_IOC_GETFSSYSFSPATH"), a
new fs ioctl was introduced to standardize exporting data from
sysfs across filesystems. The returned path will always be of the
form "$FSTYP/$SYSFS_IDENTIFIER", where the sysfs identifier may
be a UUID or a device name.

The ubifs is a file system based on char device, and the common
method to fill s_sysfs_name (super_set_sysfs_name_bdev) is
unavialable. So in order to support FS_IOC_GETFSSYSFSPATH ioctl,
we fill the s_sysfs_name with ubi_volume_info member which keeps
the format defined in macro UBIFS_DFS_DIR_NAME by using
super_set_sysfs_name_generic.

That's for ubifs, it will output "ubifs/<dev>".

```
$ ./ioctl_getfssysfs_path /mnt/ubifs/testfile
path: ubifs/ubi0_0

$ ls /sys/fs/ubifs/ubi0_0/
errors_crc  errors_magic  errors_node
```

Signed-off-by: default avatarHongbo Li <lihongbo22@huawei.com>
Reviewed-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 919cc964
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2249,6 +2249,8 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
	}

	super_set_uuid(sb, c->uuid, sizeof(c->uuid));
	super_set_sysfs_name_generic(sb, UBIFS_DFS_DIR_NAME,
				     c->vi.ubi_num, c->vi.vol_id);

	mutex_unlock(&c->umount_mutex);
	return 0;