[LU-16605] lfs fid2path should allow null byte separated output Created: 01/Mar/23  Updated: 08/Sep/23  Resolved: 31/Aug/23

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Upstream
Fix Version/s: Lustre 2.16.0

Type: Bug Priority: Minor
Reporter: Simon Westersund Assignee: Arshad Hussain
Resolution: Fixed Votes: 0
Labels: easy, lug23dd

Attachments: File lfs-fid2path.patch    
Issue Links:
Related
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

When using 'lfs fid2path' to find all hardlinks of a FID, the links are printed out with newline characters separating them. This is unsafe, since file paths are allowed to contain newline characters as well, which makes fid2path unreliable for non-interactive use (i.e. as part of other tools, without human supervision).

This issue is present in the master branch, so I assume it might affect all current versions.

To mitigate this problem and not break backwards compatibility, perhaps one could add a new command line argument that changes the path separator from '\n' to '\0'? Similar to "find . -print0", for example.

# Suggested usage:
lfs fid2path -0 <FID>

 



 Comments   
Comment by Simon Westersund [ 01/Mar/23 ]

I'll attach a patch suggestion based on our current 2.12.8_ddn18 (DDN Exascaler 5.2.6) version: lfs-fid2path.patch

It should be fairly easy to adapt this to the master branch.

Comment by Andreas Dilger [ 01/Mar/23 ]

I think it is prett reasonable to have a "-0" option for this.

One related improvement that I've wanted for a while is to allow printing only the filename(s) of the file instead of the whole pathname. That can be useful for debugging if the pathname is broken for some reason. There is already "-f" to print the FID, so something like "-n" to print the name(s) only. Both "-f" and "-n" could be used together.

Comment by Gerrit Updater [ 11/Jul/23 ]

"Arshad Hussain <arshad.hussain@aeoncomputing.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51626
Subject: LU-16605 lfs: Add -n option to fid2path
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 16272732f122b903d7f2896182fb626aad216d40

Comment by Gerrit Updater [ 21/Jul/23 ]

"Arshad Hussain <arshad.hussain@aeoncomputing.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51736
Subject: LU-16605 lfs: Add -0 option to fid2path
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: dd442430705836fece9a51b5833cad8e21ce10ac

Comment by Gerrit Updater [ 07/Aug/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/51736/
Subject: LU-16605 lfs: Add -0 option to fid2path
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 8d4f9d1befb9962335d4cbc5b89cafced286b066

Comment by Gerrit Updater [ 31/Aug/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/51626/
Subject: LU-16605 lfs: Add -n option to fid2path
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: a1bc7a84ce5b3b649fd590a80645f299205024c2

Comment by Peter Jones [ 31/Aug/23 ]

Landed for 2.16

Generated at Sat Feb 10 03:28:27 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.