- * @spec: C string hostname:path specifying remoteshare to mount
- * @node: C string pathname of local mounted on directory
- * @flags: MS_ style flags
- * @extra_opts: pointer to C string containing fs-specific mount options
- * (possibly also a return argument)
- * @fake: flag indicating whether to carry out the whole operation
- * @bg: one if this is a backgrounded mount attempt
+ * Returns TRUE if successful, otherwise FALSE.
+ * "errno" is set to reflect the individual error.
+ */
+static int nfs_sys_mount(struct nfsmount_info *mi, struct mount_options *opts)
+{
+ char *options = NULL;
+ int result;
+
+ if (po_join(opts, &options) == PO_FAILED) {
+ errno = EIO;
+ return 0;
+ }
+
+ if (mi->fake)
+ return 1;
+
+ result = mount(mi->spec, mi->node, mi->type,
+ mi->flags & ~(MS_USER|MS_USERS), options);
+ if (verbose && result) {
+ int save = errno;
+ nfs_error(_("%s: mount(2): %s"), progname, strerror(save));
+ errno = save;
+ }
+ return !result;
+}
+
+static int nfs_do_mount_v3v2(struct nfsmount_info *mi,
+ struct sockaddr *sap, socklen_t salen)
+{
+ struct mount_options *options = po_dup(mi->options);
+ int result = 0;
+
+ if (!options) {
+ errno = ENOMEM;
+ return result;
+ }
+
+ if (!nfs_append_addr_option(sap, salen, options)) {
+ errno = EINVAL;
+ goto out_fail;
+ }
+
+ if (!nfs_fix_mounthost_option(options, mi->hostname)) {
+ errno = EINVAL;
+ goto out_fail;
+ }
+ if (!mi->fake && !nfs_verify_lock_option(options)) {
+ errno = EINVAL;
+ goto out_fail;
+ }
+
+ /*
+ * Options we negotiate below may be stale by the time this
+ * file system is unmounted. In order to force umount.nfs
+ * to renegotiate with the server, only write the user-
+ * specified options, and not negotiated options, to /etc/mtab.
+ */
+ if (po_join(options, mi->extra_opts) == PO_FAILED) {
+ errno = ENOMEM;
+ goto out_fail;
+ }
+
+ if (verbose)
+ printf(_("%s: trying text-based options '%s'\n"),
+ progname, *mi->extra_opts);
+
+ if (!nfs_rewrite_pmap_mount_options(options))
+ goto out_fail;
+
+ result = nfs_sys_mount(mi, options);
+
+out_fail:
+ po_destroy(options);
+ return result;
+}
+
+/*
+ * Attempt a "-t nfs vers=2" or "-t nfs vers=3" mount.