From: Andreas Dilger Date: Sat, 9 Dec 2017 08:23:36 +0000 (-0700) Subject: LU-5955 utils: lfs shouldn't skip .lustre directory X-Git-Tag: 2.10.58~80 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=e6a80a02e285c289f823f16cbdf8b46c1002b9f9 LU-5955 utils: lfs shouldn't skip .lustre directory Before Lustre 2.5.3 the MDS returned the .lustre directory to clients with readdir in the root directory. This has always been masked out for "lfs find" and "lfs getstripe" by llapi_semantic_traverse(), but had the side-effect of also skipping a real .lustre directory that may exist in the filesystem (for whatever reason, I'm not sure). Since 2.5.3-84-g2976f91 the /.lustre directory is no longer returned by the MDS, so there is no need to exclude it in the tools anymore. Add a sanity test to confirm that the .lustre directory is not listed (there already are many tests that verify it can be accessed). Test-Parameters: trivial Signed-off-by: Andreas Dilger Change-Id: I7ec6ee94b6012445d3bfd9a8a47497dacdbcab07 Reviewed-on: https://review.whamcloud.com/30463 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Hongchao Zhang Reviewed-by: Oleg Drokin --- diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index be29031..65d7461 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -10974,6 +10974,8 @@ test_154a() { dot_lustre_fid_permission_check "$fid" $DIR || error "dot lustre permission check $fid failed" + ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed" + rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked" touch $MOUNT/.lustre/file && diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index fb65b0d..7280528 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -1830,24 +1830,20 @@ static int llapi_semantic_traverse(char *path, int size, DIR *parent, while ((dent = readdir64(d)) != NULL) { int rc; - if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) - continue; - - /* Don't traverse .lustre directory */ - if (!(strcmp(dent->d_name, dot_lustre_name))) - continue; + if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) + continue; - path[len] = 0; - if ((len + dent->d_reclen + 2) > size) { - llapi_err_noerrno(LLAPI_MSG_ERROR, - "error: %s: string buffer is too small", - __func__); - break; - } - strcat(path, "/"); - strcat(path, dent->d_name); + path[len] = 0; + if ((len + dent->d_reclen + 2) > size) { + llapi_err_noerrno(LLAPI_MSG_ERROR, + "error: %s: string buffer too small", + __func__); + break; + } + strcat(path, "/"); + strcat(path, dent->d_name); - if (dent->d_type == DT_UNKNOWN) { + if (dent->d_type == DT_UNKNOWN) { lstat_t *st = ¶m->fp_lmd->lmd_st; rc = get_lmd_info(path, d, NULL, param->fp_lmd,