Whamcloud - gitweb
LU-19123 utils: allow 'lfs project' on bad symlinks 05/59905/3
authorAndreas Dilger <adilger@whamcloud.com>
Tue, 24 Jun 2025 04:46:25 +0000 (22:46 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 8 Jul 2025 03:59:47 +0000 (03:59 +0000)
commit588850bbeb258bfaf4b0e9b002efa1d2ebf05790
tree9a365fa7f03d6f31b579e6f41169ba9802233816
parentb333f39b672bcc9639ac406bf4d63f2ea210930f
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>
lustre/tests/sanity-quota.sh
lustre/utils/lfs_project.c