Beispiel #1
0
/**
 * nfsmount_string - Mount an NFS file system using C string options
 * @spec: C string specifying remote share to mount ("hostname:path")
 * @node: C string pathname of local mounted-on directory
 * @type: C string that represents file system type ("nfs" or "nfs4")
 * @flags: MS_ style mount flags
 * @extra_opts:	pointer to C string containing fs-specific mount options
 *		(input and output argument)
 * @fake: flag indicating whether to carry out the whole operation
 * @child: one if this is a mount daemon (bg)
 *
 * Returns a valid mount command exit code.
 */
int nfsmount_string(const char *spec, const char *node, const char *type,
		    int flags, char **extra_opts, int fake, int child)
{
	struct nfsmount_info mi = {
		.spec		= spec,
		.node		= node,
		.address	= NULL,
		.type		= type,
		.extra_opts	= extra_opts,
		.flags		= flags,
		.fake		= fake,
		.child		= child,
	};
	int retval = EX_FAIL;

	mi.options = po_split(*extra_opts);
	if (mi.options) {
		retval = nfsmount_start(&mi);
		po_destroy(mi.options);
	} else
		nfs_error(_("%s: internal option parsing error"), progname);

	freeaddrinfo(mi.address);
	free(mi.hostname);
	return retval;
}
Beispiel #2
0
static void pollable_destroy(pollable *p) {
  po_destroy(&p->po);
  if (p->epfd != -1) {
    close(p->epfd);
    grpc_wakeup_fd_destroy(&p->wakeup);
  }
}
Beispiel #3
0
static int nfs_do_mount_v4(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 (mi->version == 0) {
		if (po_contains(options, "mounthost") ||
			po_contains(options, "mountaddr") ||
			po_contains(options, "mountvers") ||
			po_contains(options, "mountproto")) {
		/*
		 * Since these mountd options are set assume version 3
		 * is wanted so error out with EPROTONOSUPPORT so the
		 * protocol negation starts with v3.
		 */
			errno = EPROTONOSUPPORT;
			goto out_fail;
		}
		if (po_append(options, "vers=4") == PO_FAILED) {
			errno = EINVAL;
			goto out_fail;
		}
	}

	if (!nfs_append_addr_option(sap, salen, options)) {
		errno = EINVAL;
		goto out_fail;
	}

	if (!nfs_append_clientaddr_option(sap, salen, options)) {
		errno = EINVAL;
		goto out_fail;
	}

	/*
	 * Update option string to be recorded in /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);

	result = nfs_sys_mount(mi, options);

out_fail:
	po_destroy(options);
	return result;
}
Beispiel #4
0
static int nfs_do_mount_v3v2(struct nfsmount_info *mi,
			     struct sockaddr *sap, socklen_t salen,
			     int checkv4)
{
	struct mount_options *options = po_dup(mi->options);
	int result = 0;

	if (!options) {
		errno = ENOMEM;
		return result;
	}
	errno = 0;
	if (!nfs_append_addr_option(sap, salen, options)) {
		if (errno == 0)
			errno = EINVAL;
		goto out_fail;
	}

	if (!nfs_fix_mounthost_option(options, mi->hostname)) {
		if (errno == 0)
			errno = EINVAL;
		goto out_fail;
	}
	if (!mi->fake && !nfs_verify_lock_option(options)) {
		if (errno == 0)
			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, checkv4, mi->local_ip))
		goto out_fail;

	result = nfs_sys_mount(mi, options);

out_fail:
	po_destroy(options);
	return result;
}
Beispiel #5
0
static void pg_unref(polling_group *pg) {
  if (gpr_unref(&pg->refs)) {
    po_destroy(&pg->po);
    gpr_free(pg);
  }
}
Beispiel #6
0
static void pollset_set_destroy(grpc_exec_ctx *exec_ctx,
                                grpc_pollset_set *pss) {
  po_destroy(&pss->po);
  gpr_free(pss);
}