Whamcloud - gitweb
LU-2076 osp: fix typo in osp2fsname
[fs/lustre-release.git] / 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;
 }