Details
-
Improvement
-
Resolution: Fixed
-
Minor
-
None
-
9223372036854775807
Description
Patch https://review.whamcloud.com/25851 "LU-6051 utils: allow lfs_migrate to handle hard links" adds the ability to migrate hard-linked files using "lfs fid2path" to determine the names of links to a file, but this command only works as the root user.
$ lfs fid2path myth [0x200016b84:0x10a9b:0x0] ioctl err -1: Operation not permitted (1) fid2path: error on FID [0x200016b84:0x10a9b:0x0]: Operation not permitted $ strace lfs fid2path myth [0x200016b84:0x10a9b:0x0] open("/etc/mtab", O_RDONLY) = 3 read(3, "/dev/mapper/vg_twoshoes-lvroot /"..., 4096) = 466 close(3) = 0 open("/myth", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = 3 ioctl(3, 0xffffffffc0086696, 0x1b19040) = -1 EPERM (Operation not permitted)
So the open of the root directory succeeded, but the ioctl failed. It would be useful if a regular user could run this same command on files that they own.
Also, the "lfs fid2path" command requires specifying the mountpoint of the filesystem (e.g. /mnt/testfs), but if e.g. "$PWD" is given as the mountpoint then it prepends the whole specified path to the start of the returned pathname rather than the actual mountpoint:
# df . Filesystem 1K-blocks Used Available Use% Mounted on mookie-gig:/myth 23322497088 16086795940 6593847700 71% /myth # lfs fid2path . [0x200016b84:0x10a9b:0x0] ioctl err -19: No such device (19) fid2path: error on FID [0x200016b84:0x10a9b:0x0]: No such device # pwd /myth/tmp/links # lfs fid2path $PWD [0x200016b84:0x10a9b:0x0] /myth/tmp/links/tmp/links/hosts /myth/tmp/links/tmp/links/link1 /myth/tmp/links/tmp/links/link2 :
It would be useful if specifying "." or any other pathname looked up the mountpoint of that directory based on the current working directory and showed the correct pathnames for the links. It is already looking up the mountpoint in /etc/mtab to open the root directory for the ioctl(), so this shouldn't be too much additional work.