Whamcloud - gitweb
LU-2333 utils: mount.lustre to ignore fsname
[fs/lustre-release.git] / lustre / utils / mount_utils.c
index effa6c7..ae0316e 100644 (file)
@@ -37,6 +37,7 @@
 #  include "config.h"
 #endif /* HAVE_CONFIG_H */
 
+#include "mount_utils.h"
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
@@ -45,7 +46,6 @@
 #include <lustre_ver.h>
 #include <sys/stat.h>
 #include <sys/utsname.h>
-#include "mount_utils.h"
 
 extern char *progname;
 extern int verbose;
@@ -180,6 +180,20 @@ int check_mtab_entry(char *spec1, char *spec2, char *mtpt, char *type)
        return 0;
 }
 
+#define PROC_DIR       "/proc/"
+static int mtab_is_proc(const char *mtab)
+{
+       char path[16];
+
+       if (readlink(mtab, path, sizeof(path)) < 0)
+               return 0;
+
+       if (strncmp(path, PROC_DIR, strlen(PROC_DIR)))
+               return 0;
+
+       return 1;
+}
+
 int update_mtab_entry(char *spec, char *mtpt, char *type, char *opts,
                int flags, int freq, int pass)
 {
@@ -187,6 +201,10 @@ int update_mtab_entry(char *spec, char *mtpt, char *type, char *opts,
        struct mntent mnt;
        int rc = 0;
 
+       /* Don't update mtab if it is linked to any file in /proc direcotry.*/
+       if (mtab_is_proc(MOUNTED))
+               return 0;
+
        mnt.mnt_fsname = spec;
        mnt.mnt_dir = mtpt;
        mnt.mnt_type = type;
@@ -574,6 +592,37 @@ int osd_label_lustre(struct mount_opts *mop)
        return ret;
 }
 
+/* Enable quota accounting */
+int osd_enable_quota(struct mkfs_opts *mop)
+{
+       struct lustre_disk_data *ldd = &mop->mo_ldd;
+       int ret;
+
+       switch (ldd->ldd_mount_type) {
+#ifdef HAVE_LDISKFS_OSD
+       case LDD_MT_EXT3:
+       case LDD_MT_LDISKFS:
+       case LDD_MT_LDISKFS2:
+               ret = ldiskfs_enable_quota(mop);
+               break;
+#endif /* HAVE_LDISKFS_OSD */
+#ifdef HAVE_ZFS_OSD
+       case LDD_MT_ZFS:
+               fprintf(stderr, "this option is only valid for ldiskfs\n");
+               ret = EINVAL;
+               break;
+#endif /* HAVE_ZFS_OSD */
+       default:
+               fatal();
+               fprintf(stderr, "unknown fs type %d '%s'\n",
+                       ldd->ldd_mount_type, MT_STR(ldd));
+               ret = EINVAL;
+               break;
+       }
+
+       return ret;
+}
+
 int osd_init(void)
 {
        int ret = 0;