Whamcloud - gitweb
LU-8998 pfl: layout LFSCK handles PFL file
[fs/lustre-release.git] / lustre / ptlrpc / nodemap_lproc.c
index 49e7ac6..305f95b 100644 (file)
@@ -177,7 +177,7 @@ static int nodemap_ranges_open(struct inode *inode, struct file *file)
 static int nodemap_fileset_seq_show(struct seq_file *m, void *data)
 {
        struct lu_nodemap *nodemap;
-       int rc;
+       int rc = 0;
 
        mutex_lock(&active_config_lock);
        nodemap = nodemap_lookup(m->private);
@@ -189,7 +189,7 @@ static int nodemap_fileset_seq_show(struct seq_file *m, void *data)
                return rc;
        }
 
-       rc = seq_printf(m, "%s\n", nodemap->nm_fileset);
+       seq_printf(m, "%s\n", nodemap->nm_fileset);
        nodemap_putref(nodemap);
        return rc;
 }
@@ -210,15 +210,32 @@ nodemap_fileset_seq_write(struct file *file,
                                      size_t count, loff_t *off)
 {
        struct seq_file *m = file->private_data;
+       char *nm_fileset;
        int rc = 0;
+       ENTRY;
+
+       if (count == 0)
+               RETURN(0);
 
-       if (count > 0)
-               rc = nodemap_set_fileset(m->private, buffer);
+       if (count > PATH_MAX)
+               RETURN(-EINVAL);
+
+       OBD_ALLOC(nm_fileset, count);
+       if (nm_fileset == NULL)
+               RETURN(-ENOMEM);
+
+       if (copy_from_user(nm_fileset, buffer, count))
+               GOTO(out, rc = -EFAULT);
 
+       rc = nodemap_set_fileset(m->private, nm_fileset);
        if (rc != 0)
-               return -EINVAL;
+               GOTO(out, rc = -EINVAL);
 
-       return count;
+       rc = count;
+out:
+       OBD_FREE(nm_fileset, count);
+
+       return rc;
 }
 LPROC_SEQ_FOPS(nodemap_fileset);