Whamcloud - gitweb
LU-2076 osp: fix typo in osp2fsname
authorwangdi <di.wang@whamcloud.com>
Tue, 2 Oct 2012 10:49:47 +0000 (03:49 -0700)
committerOleg Drokin <green@whamcloud.com>
Wed, 3 Oct 2012 22:51:44 +0000 (18:51 -0400)
Fix name converstion problem for ospname-->fsname.

Signed-off-by: Wang Di <di.wang@whamcloud.com>
Change-Id: I402639e0b5bce49af844e7979b290267e689c9dc
Reviewed-on: http://review.whamcloud.com/4157
Tested-by: Hudson
Reviewed-by: Johann Lombardi <johann.lombardi@intel.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Niu Yawei <niu@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Mike Pershin <tappro@whamcloud.com>
lustre/osp/osp_ost.c

index 2fb6a55..b619275 100644 (file)
@@ -53,10 +53,17 @@ static int osp_name2fsname(char *ospname, char *fsname)
        sprintf(fsname, "-%s-", LUSTRE_OSP_NAME);
 
        ptr = strstr(ospname, fsname);
-       if (ptr) {
-               strncpy(fsname, ospname, ptr - ospname);
-               fsname[ptr - ospname] = '\0';
+       if (ptr == NULL)
+               return -EINVAL;
+
+       while (*(--ptr) != '-') {
+               if (ptr == ospname)
+                       return -EINVAL;
        }
+
+       strncpy(fsname, ospname, ptr - ospname);
+       fsname[ptr - ospname] = '\0';
+
        return 0;
 }