Whamcloud - gitweb
LU-2200 obdclass: be more careful processing server name
[fs/lustre-release.git] / lustre / mgs / mgs_llog.c
index 49b1a96..d4c70c0 100644 (file)
@@ -1206,26 +1206,24 @@ out_put:
  */
 static int mgs_parse_devname(char *devname, char *fsname, __u32 *index)
 {
-       char *ptr;
+       int rc;
        ENTRY;
 
        /* Extract fsname */
-       ptr = strrchr(devname, '-');
-
        if (fsname) {
-               if (!ptr) {
+               rc = server_name2fsname(devname, fsname, NULL);
+               if (rc < 0) {
                        CDEBUG(D_MGS, "Device name %s without fsname\n",
                               devname);
                        RETURN(-EINVAL);
                }
-               memset(fsname, 0, MTI_NAME_MAXLEN);
-               strncpy(fsname, devname, ptr - devname);
-               fsname[MTI_NAME_MAXLEN - 1] = 0;
        }
 
        if (index) {
-               if (server_name2index(ptr, index, NULL) < 0) {
-                       CDEBUG(D_MGS, "Device name with wrong index\n");
+               rc = server_name2index(devname, index, NULL);
+               if (rc < 0) {
+                       CDEBUG(D_MGS, "Device name %s with wrong index\n",
+                              devname);
                        RETURN(-EINVAL);
                }
        }