Whamcloud - gitweb
LU-4961 lustre: remove liblustre.h and obd.h from userspace
[fs/lustre-release.git] / lustre / utils / mount_lustre.c
index c8fe8a6..7671da3 100644 (file)
@@ -53,6 +53,7 @@
 #include <lustre_ver.h>
 #include <ctype.h>
 #include <limits.h>
+#include <lustre/lustre_idl.h>
 #if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 10, 51, 0)
 /*
  * LU-1783
@@ -63,7 +64,7 @@
  * set of flag #defines we should stop including linux/fs.h
  */
 #warn remove kernel include
-#else
+#elif !defined(MS_RDONLY)
 #include <linux/fs.h>
 #endif
 
@@ -320,11 +321,17 @@ static int clear_update_ondisk(char *source, struct lustre_disk_data *ldd)
        char default_mountopts[512] = "";
        struct mkfs_opts mkop;
        int ret;
+       int ret2;
 
        memset(&mkop, 0, sizeof(mkop));
        mkop.mo_ldd = *ldd;
        mkop.mo_ldd.ldd_flags &= ~LDD_F_UPDATE;
-       strcpy(mkop.mo_device, source);
+       if (strlen(source) > sizeof(mkop.mo_device)-1) {
+               fatal();
+               fprintf(stderr, "Device name too long: %s\n", source);
+               return -E2BIG;
+       }
+       strncpy(mkop.mo_device, source, sizeof(mkop.mo_device));
 
        ret = osd_prepare_lustre(&mkop,
                        default_mountopts, sizeof(default_mountopts),
@@ -361,7 +368,10 @@ static int clear_update_ondisk(char *source, struct lustre_disk_data *ldd)
                fprintf(stderr, "failed to write local files: %s\n",
                        strerror(ret));
        }
-       loop_cleanup(&mkop);
+
+       ret2 = loop_cleanup(&mkop);
+       if (ret == 0)
+               ret = ret2;
 
        return ret;
 }