Whamcloud - gitweb
b=22582 remove leading / from fid2path results print full path if given mountpoint
authorNathan Rutman <nathan.rutman@oracle.com>
Wed, 28 Apr 2010 18:04:59 +0000 (11:04 -0700)
committerRobert Read <robert.read@oracle.com>
Thu, 29 Apr 2010 18:12:36 +0000 (11:12 -0700)
i=manoj
i=rread

lustre/mdd/mdd_object.c
lustre/tests/sanity.sh
lustre/utils/lfs.c
lustre/utils/lustre_rsync.c

index 68504b0..49e8f66 100644 (file)
@@ -504,7 +504,7 @@ static int mdd_path_current(const struct lu_env *env,
                        PFID(&pli->pli_fid));
                 GOTO(out, rc = -EAGAIN);
         }
-
+        ptr++; /* skip leading / */
         memmove(pli->pli_path, ptr, pli->pli_path + pli->pli_pathlen - ptr);
 
         EXIT;
@@ -535,8 +535,7 @@ static int mdd_path(const struct lu_env *env, struct md_object *obj,
                 RETURN(-EOVERFLOW);
 
         if (mdd_is_root(mdo2mdd(obj), mdd_object_fid(md2mdd_obj(obj)))) {
-                path[0] = '/';
-                path[1] = '\0';
+                path[0] = '\0';
                 RETURN(0);
         }
 
index 626f4c0..5bc213e 100755 (executable)
@@ -6882,7 +6882,7 @@ test_161() {
     rm $DIR/$tdir/$tfile
     # rename
     mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
-    if [ "$($LFS fid2path $DIR --link 1 $FID)" != "/$tdir/foo2/maggie" ]
+    if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
        then
        $LFS fid2path $DIR $FID
        err17935 "bad link rename"
@@ -6929,20 +6929,20 @@ test_162() {
     mkdir -p $DIR/$tdir/d2/p/q/r
        # regular file
     FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[')
-    check_path "/$tdir/d2/$tfile" $DIR $FID --link 0
+    check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
 
        # softlink
     ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
     FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[')
-    check_path "/$tdir/d2/p/q/r/slink" $DIR $FID --link 0
+    check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
 
        # hardlink
     ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
     mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
     FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[')
     # fid2path dir/fsname should both work
-    check_path "/$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
-    check_path "/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
+    check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
+    check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
 
     # hardlink count: check that there are 2 links
     # Doesnt work with CMD yet: 17935
@@ -6951,7 +6951,7 @@ test_162() {
 
        # hardlink indexing: remove the first link
     rm $DIR/$tdir/d2/p/q/r/hlink
-    check_path "/$tdir/d2/a/b/c/new_file" $DIR $FID --link 0
+    check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
 
        return 0
 }
index 654d6c3..5156dec 100644 (file)
@@ -198,7 +198,7 @@ command_t cmdlist[] = {
          "       -i can be used instead of --inode-softlimit/--inode-grace\n"
          "       -I can be used instead of --inode-hardlimit"},
         {"quota", lfs_quota, 0, "Display disk usage and limits.\n"
-         "usage: quota [-v] [-o obd_uuid|-i mdt_idx|-I ost_idx]\n" 
+         "usage: quota [-v] [-o obd_uuid|-i mdt_idx|-I ost_idx]\n"
          "             [<-u|-g> <uname>|<uid>|<gname>|<gid>] <filesystem>\n"
          "       quota [-o obd_uuid|-i mdt_idx|-I ost_idx] -t <-u|-g> <filesystem>"},
         {"quotainv", lfs_quotainv, 0, "Invalidate quota data.\n"
@@ -625,7 +625,7 @@ static int lfs_find(int argc, char **argv)
                                                 "be found.\n", optarg);
                                         return -1;
                                 }
-                        }           
+                        }
                         param.exclude_gid = !!neg_opt;
                         param.check_gid = 1;
                         break;
@@ -1748,7 +1748,7 @@ int lfs_setquota(int argc, char **argv)
                                 qctl.qc_id = strtoul(optarg, &endptr, 10);
                                 if (*endptr != '\0') {
                                         fprintf(stderr, "error: can't find id "
-                                                "for name %s\n", optarg); 
+                                                "for name %s\n", optarg);
                                         return CMD_HELP;
                                 }
                         }
@@ -2459,9 +2459,15 @@ static int lfs_fid2path(int argc, char **argv)
                 }
 
                 if (printcur)
-                        fprintf(stdout, "%lld %s\n", rectmp, path);
-                else
-                        fprintf(stdout, "%s\n", path);
+                        fprintf(stdout, "%lld ", rectmp);
+                if (device[0] == '/') {
+                        fprintf(stdout, "%s", device);
+                        if (device[strlen(device) - 1] != '/')
+                                fprintf(stdout, "/");
+                } else if (path[0] == '\0') {
+                        fprintf(stdout, "/");
+                }
+                fprintf(stdout, "%s\n", path);
 
                 if (linkno >= 0)
                         /* specified linkno */
index ffe297f..67b53ff 100644 (file)
@@ -785,14 +785,14 @@ int lr_create(struct lr_info *info)
         /* Is f2p(pfid) present on the target? If not, the parent has
            moved */
         if (!mkspecial) {
-                snprintf(info->dest, PATH_MAX, "%s%s", status->ls_targets[0],
+                snprintf(info->dest, PATH_MAX, "%s/%s", status->ls_targets[0],
                         info->path);
                 if (access(info->dest, F_OK) != 0)
                         mkspecial = 1;
         }
         for (info->target_no = 0; info->target_no < status->ls_num_targets;
              info->target_no++) {
-                snprintf(info->dest, PATH_MAX, "%s%s",
+                snprintf(info->dest, PATH_MAX, "%s/%s",
                         status->ls_targets[info->target_no], info->savedpath);
                 lr_get_FID_PATH(status->ls_source, info->tfid, info->src,
                                     PATH_MAX);
@@ -831,7 +831,7 @@ int lr_remove(struct lr_info *info)
                         rc = rc1;
                         continue;
                 }
-                snprintf(info->dest, PATH_MAX, "%s%s/%s",
+                snprintf(info->dest, PATH_MAX, "%s/%s/%s",
                         status->ls_targets[info->target_no], info->path,
                         info->name);
 
@@ -871,13 +871,13 @@ int lr_move(struct lr_info *info, struct lr_info *ext)
              info->target_no++) {
 
                 if (!rc_dest) {
-                        snprintf(info->dest, PATH_MAX, "%s%s",
+                        snprintf(info->dest, PATH_MAX, "%s/%s",
                                 status->ls_targets[info->target_no],
                                 ext->path);
                         if (access(info->dest, F_OK) != 0) {
                                 rc_dest = -errno;
                         } else {
-                                snprintf(info->dest, PATH_MAX, "%s%s/%s",
+                                snprintf(info->dest, PATH_MAX, "%s/%s/%s",
                                         status->ls_targets[info->target_no],
                                         ext->path, ext->name);
                         }
@@ -890,7 +890,7 @@ int lr_move(struct lr_info *info, struct lr_info *ext)
                 }
 
                 if (!rc_src)
-                        snprintf(info->src, PATH_MAX, "%s%s/%s",
+                        snprintf(info->src, PATH_MAX, "%s/%s/%s",
                                 status->ls_targets[info->target_no],
                                 info->path, info->name);
                 if (rc_src == -ENOENT || (access(info->src, F_OK) != 0 &&
@@ -957,11 +957,11 @@ int lr_link(struct lr_info *info)
                         len = strlen(info->path) - strlen(info->name);
                         if (len > 0 && strcmp(info->path + len,
                                               info->name) == 0)
-                                snprintf(info->dest, PATH_MAX, "%s%s",
+                                snprintf(info->dest, PATH_MAX, "%s/%s",
                                         status->ls_targets[info->target_no],
                                         info->path);
                         else if (info->src[0] == 0)
-                                snprintf(info->src, PATH_MAX, "%s%s",
+                                snprintf(info->src, PATH_MAX, "%s/%s",
                                         status->ls_targets[info->target_no],
                                         info->path);
                 }
@@ -1014,7 +1014,7 @@ int lr_setattr(struct lr_info *info)
         for (info->target_no = 0; info->target_no < status->ls_num_targets;
              info->target_no++) {
 
-                snprintf(info->dest, PATH_MAX, "%s%s",
+                snprintf(info->dest, PATH_MAX, "%s/%s",
                          status->ls_targets[info->target_no], info->path);
                 lr_debug(DINFO, "setattr: %s %s %s", info->src, info->dest,
                          info->tfid);
@@ -1045,7 +1045,7 @@ int lr_setxattr(struct lr_info *info)
         for (info->target_no = 0; info->target_no < status->ls_num_targets;
              info->target_no++) {
 
-                snprintf(info->dest, PATH_MAX, "%s%s",
+                snprintf(info->dest, PATH_MAX, "%s/%s",
                         status->ls_targets[info->target_no], info->path);
                 lr_debug(DINFO, "setxattr: %s %s %s\n", info->src, info->dest,
                          info->tfid);