From: yangsheng Date: Wed, 21 Apr 2010 18:43:12 +0000 (-0700) Subject: b=19919 Supply a absolute path. X-Git-Tag: 1.10.0.41~31 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=87a333f85f29fe989997638ee2b7fd5c3a53608b b=19919 Supply a absolute path. i=andreas i=johann --- diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index a2aec03..626f4c0 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -7140,7 +7140,8 @@ TGTPOOL_MAX=$(($TGT_COUNT - 1)) TGTPOOL_STEP=2 TGTPOOL_LIST=`seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX` POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools} -POOL_DIR=$POOL_ROOT/dir_tst +POOL_DIR_NAME=dir_tst +POOL_DIR=$POOL_ROOT/$POOL_DIR_NAME POOL_FILE=$POOL_ROOT/file_tst check_file_in_pool() @@ -7190,6 +7191,18 @@ test_200c() { mkdir -p $POOL_DIR $SETSTRIPE -c 2 -p $POOL $POOL_DIR [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR" + # b-19919 test relative path works well + mkdir -p $POOL_DIR/$POOL_DIR_NAME + cd $POOL_DIR + $SETSTRIPE -c 2 -p $POOL $POOL_DIR_NAME + [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/$POOL_DIR_NAME" + $SETSTRIPE -c 2 -p $POOL ./$POOL_DIR_NAME + [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/./$POOL_DIR_NAME" + $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME + [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME" + $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME/$POOL_DIR_NAME + [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME/$POOL_DIR_NAME" + rm -rf $POOL_DIR_NAME; cd - } run_test 200c "Set pool on a directory =================================" diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 1614dd87..6fbf5d6 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -606,8 +606,19 @@ int llapi_search_mounts(const char *pathname, int index, char *mntdir, /* Given a path, find the corresponding Lustre fsname */ int llapi_search_fsname(const char *pathname, char *fsname) { + char *path = (char*)pathname, buf[PATH_MAX + 1]; + + if (pathname[0] != '/') { /* Need a absolute path */ + memset(buf, '\0', sizeof(buf)); + if (realpath(pathname, buf) == NULL) { + llapi_err(LLAPI_MSG_ERROR, "pathname '%s' cannot expand", + pathname); + return -EINVAL; + } + path = buf; + } return get_root_path(WANT_FSNAME | WANT_ERROR, fsname, NULL, - (char *)pathname, -1); + path, -1); } /* return the first file matching this pattern */