X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmount%2Fmount.c;h=21946f727990af960e72ca2ad768b91adf134388;hp=31e196952a0d53ab689d8b94a2a70b3216727adf;hb=b9f4b66a81420b0832ce4ef6965b1cdc9615772c;hpb=d97d88b288413b4e528e22739bfb08594efe9940 diff --git a/utils/mount/mount.c b/utils/mount/mount.c index 31e1969..21946f7 100644 --- a/utils/mount/mount.c +++ b/utils/mount/mount.c @@ -376,14 +376,10 @@ static int try_mount(char *spec, char *mount_point, int flags, { int ret; - if (string) { - if (strcmp(fs_type, "nfs4") == 0) - ret = nfs4mount_s(spec, mount_point, flags, - extra_opts, fake, bg); - else - ret = nfsmount_s(spec, mount_point, flags, - extra_opts, fake, bg); - } else { + if (string) + ret = nfsmount_string(spec, mount_point, fs_type, flags, + extra_opts, fake, bg); + else { if (strcmp(fs_type, "nfs4") == 0) ret = nfs4mount(spec, mount_point, flags, extra_opts, fake, bg); @@ -470,19 +466,19 @@ int main(int argc, char *argv[]) nfs_error(_("%s: Passing mount options via a" " string is unsupported by this" " kernel\n"), progname); - exit(EX_USAGE); + goto out_usage; } if (uid != 0) { nfs_error(_("%s: -i option is restricted to 'root'\n"), progname); - exit(EX_USAGE); + goto out_usage; } ++string; break; case 'h': default: mount_usage(); - exit(EX_USAGE); + goto out_usage; } } @@ -491,7 +487,7 @@ int main(int argc, char *argv[]) */ if (optind != argc - 2) { mount_usage(); - exit(EX_USAGE); + goto out_usage; } if (strcmp(progname, "mount.nfs4") == 0) @@ -510,7 +506,7 @@ int main(int argc, char *argv[]) strcmp(mc->m.mnt_type, fs_type) != 0) { nfs_error(_("%s: permission denied: no match for %s " "found in /etc/fstab"), progname, mount_point); - exit(EX_USAGE); + goto out_usage; } /* @@ -525,7 +521,7 @@ int main(int argc, char *argv[]) mount_point = canonicalize(mount_point); if (!mount_point) { nfs_error(_("%s: no mount point provided"), progname); - exit(EX_USAGE); + goto out_usage; } if (mount_point[0] != '/') { nfs_error(_("%s: unrecognized mount point %s"), @@ -575,6 +571,12 @@ int main(int argc, char *argv[]) } out: + free(mount_opts); + free(extra_opts); free(mount_point); exit(mnt_err); + +out_usage: + free(mount_opts); + exit(EX_USAGE); }