LU-19123 utils: allow 'lfs project' on bad symlinks
Running 'lfs project' on a bad symlink reports an error:
# ln -s foo /myth/tmp/projid-900/symlink
# lfs project -p 1000 /myth/tmp/projid-900/symlink
lfs: failed to stat '/myth/tmp/projid-900/symlink':
No such file or directory
# ln -s symlink3 /myth/tmp/projid-900/symlink3
# lfs project -p 1000 /myth/tmp/projid-900/symlink3
lfs: failed to stat '/myth/tmp/projid-900/symlink3':
Too many levels of symbolic links
Opening the symlink with open(O_NOFOLLOW) avoids following the
symlink and allows the project ID to be set on the symlink itself.
Fixes:
501e5b2c8a ("LU-18027 lfs: lfs find handling special files")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Ibe0504c63270306a68329d8b165e7b83276695c8
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59905
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Sergey Cheremencev <scherementsev@ddn.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>