Whamcloud - gitweb
LU-15940 build: add a required dependency for libmount
[fs/lustre-release.git] / lustre / utils / mount_utils.c
index be5d46b..663ff6b 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
 #if HAVE_CONFIG_H
 #include <dirent.h>
 #include <sys/types.h>
 #include <sys/xattr.h>
+#include <libmount/libmount.h>
 
 #ifdef HAVE_GSS
+#ifdef HAVE_LIBKEYUTILS
 #include <keyutils.h>
+#endif
 #include <lustre/utils/gss/sk_utils.h>
 #endif
 
 #include "mount_utils.h"
 
-extern char *progname;
-extern int verbose;
-
 #define vprint(fmt, arg...) if (verbose > 0) printf(fmt, ##arg)
 #define verrprint(fmt, arg...) if (verbose >= 0) fprintf(stderr, fmt, ##arg)
 
@@ -253,10 +252,6 @@ static int mtab_is_proc(const char *mtab)
        return (s.f_type == PROC_SUPER_MAGIC);
 }
 
-#ifdef HAVE_LIBMOUNT
-
-# include <libmount/libmount.h>
-
 /*
  * The libmount is part of util-linux since 2.18.
  * We use it to update utab to avoid umount would
@@ -292,12 +287,6 @@ int update_utab_entry(struct mount_opts *mop)
 
        return rc;
 }
-#else
-int update_utab_entry(struct mount_opts *mop)
-{
-       return 0;
-}
-#endif /* HAVE_LIBMOUNT */
 
 int update_mtab_entry(char *spec, char *mtpt, char *type, char *opts,
                      int flags, int freq, int pass)
@@ -426,7 +415,6 @@ int loop_setup(struct mkfs_opts *mop)
                char cmd[PATH_MAX];
                int cmdsz = sizeof(cmd);
 
-#ifdef HAVE_LOOP_CTL_GET_FREE
                ret = open("/dev/loop-control", O_RDWR);
                if (ret < 0) {
                        fprintf(stderr, "%s: can't access loop control\n",
@@ -442,11 +430,7 @@ int loop_setup(struct mkfs_opts *mop)
                        return EACCES;
                }
                sprintf(l_device, "%s%d", loop_base, i);
-#else
-               sprintf(l_device, "%s%d", loop_base, i);
-               if (access(l_device, F_OK | R_OK))
-                       break;
-#endif
+
                snprintf(cmd, cmdsz, "losetup %s > /dev/null 2>&1", l_device);
                ret = system(cmd);
 
@@ -535,7 +519,7 @@ int loop_format(struct mkfs_opts *mop)
 #ifdef PLUGIN_DIR
 #define DLSYM(prefix, sym, func)                                       \
        do {                                                            \
-               char _fname[64];                                        \
+               char _fname[PATH_MAX];                                  \
                snprintf(_fname, sizeof(_fname), "%s_%s", prefix, #func); \
                sym->func = (typeof(sym->func))dlsym(sym->dl_handle, _fname); \
        } while (0)