X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmount%2Fmount.c;h=2909595b5926d63501c5dbf970e7372d19ace231;hp=a7539324122c68b1281ac9b127a9ed3b5add0a90;hb=e2b6d9cbaf20df26dd371a715fce3ae158f37126;hpb=58080798db321d025143df39c97f707ea994ba26 diff --git a/utils/mount/mount.c b/utils/mount/mount.c index a753932..2909595 100644 --- a/utils/mount/mount.c +++ b/utils/mount/mount.c @@ -24,12 +24,12 @@ #include #include +#include #include #include #include #include #include -#include #include #include #include @@ -38,6 +38,7 @@ #include "xcommon.h" #include "nls.h" #include "mount_constants.h" +#include "mount_config.h" #include "nfs_paths.h" #include "nfs_mntent.h" @@ -45,8 +46,8 @@ #include "nfs4_mount.h" #include "mount.h" #include "error.h" -#include "network.h" #include "stropts.h" +#include "version.h" char *progname; int nfs_mount_data_version; @@ -146,24 +147,8 @@ static const struct opt_map opt_map[] = { { NULL, 0, 0, 0 } }; -#define MAKE_VERSION(p,q,r) (65536 * (p) + 256 * (q) + (r)) - static void parse_opts(const char *options, int *flags, char **extra_opts); -int linux_version_code(void) -{ - struct utsname my_utsname; - int p, q, r; - - if (uname(&my_utsname) == 0) { - p = atoi(strtok(my_utsname.release, ".")); - q = atoi(strtok(NULL, ".")); - r = atoi(strtok(NULL, ".")); - return MAKE_VERSION(p,q,r); - } - return 0; -} - /* * Choose the version of the nfs_mount_data structure that is appropriate * for the kernel that is doing the mount. @@ -173,7 +158,7 @@ int linux_version_code(void) */ static void discover_nfs_mount_data_version(void) { - int kernel_version = linux_version_code(); + unsigned int kernel_version = linux_version_code(); if (kernel_version) { if (kernel_version < MAKE_VERSION(2, 1, 32)) @@ -336,7 +321,7 @@ static int add_mtab(char *spec, char *mount_point, char *fstype, return result; } -void mount_usage(void) +static void mount_usage(void) { printf(_("usage: %s remotetarget dir [-rvVwfnsih] [-o nfsoptions]\n"), progname); @@ -352,7 +337,7 @@ void mount_usage(void) printf(_("\tnfsoptions\tRefer to mount.nfs(8) or nfs(5)\n\n")); } -static void parse_opt(const char *opt, int *mask, char *extra_opts, int len) +static void parse_opt(const char *opt, int *mask, char *extra_opts, size_t len) { const struct opt_map *om; @@ -386,7 +371,7 @@ static void parse_opts(const char *options, int *flags, char **extra_opts) if (options != NULL) { char *opts = xstrdup(options); char *opt, *p; - int len = strlen(opts) + 1; /* include room for a null */ + size_t len = strlen(opts) + 1; /* include room for a null */ int open_quote = 0; *extra_opts = xmalloc(len); @@ -434,7 +419,7 @@ static int chk_mountpoint(char *mount_point) static int try_mount(char *spec, char *mount_point, int flags, char *fs_type, char **extra_opts, char *mount_opts, - int fake, int nomtab, int bg) + int fake, int bg) { int ret; @@ -491,6 +476,8 @@ int main(int argc, char *argv[]) spec = argv[1]; mount_point = argv[2]; + mount_config_init(progname); + argv[2] = argv[0]; /* so that getopt error messages are correct */ while ((c = getopt_long(argc - 2, argv + 2, "rvVwfno:hs", longopts, NULL)) != -1) { @@ -576,6 +563,10 @@ int main(int argc, char *argv[]) mnt_err = EX_USAGE; goto out; } + /* + * Concatenate mount options from the configuration file + */ + mount_opts = mount_config_opts(spec, mount_point, mount_opts); parse_opts(mount_opts, &flags, &extra_opts); @@ -599,10 +590,13 @@ int main(int argc, char *argv[]) } mnt_err = try_mount(spec, mount_point, flags, fs_type, &extra_opts, - mount_opts, fake, nomtab, FOREGROUND); + mount_opts, fake, FOREGROUND); if (mnt_err == EX_BG) { printf(_("%s: backgrounding \"%s\"\n"), progname, spec); + printf(_("%s: mount options: \"%s\"\n"), + progname, extra_opts); + fflush(stdout); /* @@ -617,7 +611,7 @@ int main(int argc, char *argv[]) mnt_err = try_mount(spec, mount_point, flags, fs_type, &extra_opts, mount_opts, fake, - nomtab, BACKGROUND); + BACKGROUND); if (verbose && mnt_err) printf(_("%s: giving up \"%s\"\n"), progname, spec);