[LU-11188] Add to "lfs find" the ability to check on permissions Created: 27/Jul/18  Updated: 30/Jun/21  Resolved: 02/Jun/21

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.12.0
Fix Version/s: Lustre 2.15.0

Type: Improvement Priority: Minor
Reporter: Megan Larko Assignee: Guillaume Courrier
Resolution: Fixed Votes: 0
Labels: easy, lfs
Environment:

CentOS 7.3 Lustre 2.9 and 2.10.4 clients


Issue Links:
Blocker
is blocked by LU-14801 Improve the performance of "lfs find ... Resolved
Related
is related to LU-5170 lfs usability Open
is related to LU-7495 lfs find is missing "-links" support Resolved
Rank (Obsolete): 9223372036854775807

 Description   

Adding the capability to "lfs find" to search/locate on permission of file, matching the find -perm behaviour of find(1).



 Comments   
Comment by Andreas Dilger [ 27/Jul/18 ]

This should just be a matter of copying the code that handles "-type" or similar (with new params.fp_mode and params.fp_mode_sign fields), and then modifying it to compare the mode. The tricky part is getting the semantics correct with +/-mode, and converting symbolic modes to octal (the find(1) man page goes into depth on this issue). Starting with only "[+-]octal" may be enough for initial usefulness. The OSX find(1) man page summarizes the desired semantics nicely:

If the mode is preceded by a dash ('-'), this primary evaluates to true if at least all of the bits in the mode are set in the file's mode bits. If the mode is preceded by a plus ('+'), this primary evaluates to true if any of the bits in the mode are set in the file's mode bits. Otherwise, this primary evaluates to true if the bits in the mode exactly match the file's mode bits.

This appears to equate to st_mode & fp_mode == fp_mode and st_mode & fp_mode != 0 for '-' and '+' respectively.

Newer versions of find also accept the '/' modifier as equivalent to the '+' modifier, since it avoids ambiguity with symbolic mode parsing.

Comment by Andreas Dilger [ 26/Apr/21 ]

Hi courrier, thanks for taking on this work. Please let me know if you have any questions.

For a change like this it should typically include a new sanity test as well as an update to the lustre/doc/lfs-find.1 man page.

The LU-7495 ticket is very similar (possibly a bit easier than this one), while LU-10378 would be somewhat more complex.

Comment by Guillaume Courrier [ 27/Apr/21 ]

Hi, thanks for your help. As I'm new on this project, I'll be discovering the code as I'm working on this patch.

I'll come back to you if I have questions.

Comment by Gerrit Updater [ 17/May/21 ]

Guillaume Courrier (guillaume.courrier@cea.fr) uploaded a new patch: https://review.whamcloud.com/43715
Subject: LU-11188 lfs: add "--perm" option to "lfs find"
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 964b32570787f96cc615fae17049211f591bc4eb

Comment by Gerrit Updater [ 02/Jun/21 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/43715/
Subject: LU-11188 lfs: add "--perm" option to "lfs find"
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 06588e4a22b0ff037eafa1eee5e22521b1626904

Comment by Peter Jones [ 02/Jun/21 ]

Landed for 2.15. Congratulations courrier

Generated at Sat Feb 10 02:41:43 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.