示例#1
0
/*
 *  Get the NFS port numbers and file handle, and return the prepared 'data'
 *  argument for ->read_super() if everything went OK. Return NULL otherwise.
 */
void * __init nfs_root_data(void)
{
	if (root_nfs_init() < 0
	 || root_nfs_ports() < 0
	 || root_nfs_get_handle() < 0)
		return NULL;
	set_sockaddr((struct sockaddr_in *) &nfs_data.addr, servaddr, nfs_port);
	return (void*)&nfs_data;
}
示例#2
0
/*
 *  Get a file handle from the server for the directory which is to be
 *  mounted.
 */
static int __init root_nfs_get_handle(void)
{
	struct sockaddr_in sin;
	unsigned int auth_flav_len = 0;
	struct nfs_mount_request request = {
		.sap		= (struct sockaddr *)&sin,
		.salen		= sizeof(sin),
		.dirpath	= nfs_export_path,
		.version	= (nfs_data.flags & NFS_MOUNT_VER3) ?
					NFS_MNT3_VERSION : NFS_MNT_VERSION,
		.protocol	= (nfs_data.flags & NFS_MOUNT_TCP) ?
					XPRT_TRANSPORT_TCP : XPRT_TRANSPORT_UDP,
		.auth_flav_len	= &auth_flav_len,
	};
	int status = -ENOMEM;

	request.fh = nfs_alloc_fhandle();
	if (!request.fh)
		goto out;
	set_sockaddr(&sin, servaddr, htons(mount_port));
	status = nfs_mount(&request);
	if (status < 0)
		printk(KERN_ERR "Root-NFS: Server returned error %d "
				"while mounting %s\n", status, nfs_export_path);
	else {
		nfs_data.root.size = request.fh->size;
		memcpy(&nfs_data.root.data, request.fh->data, request.fh->size);
	}
	nfs_free_fhandle(request.fh);
out:
	return status;
}

/*
 *  Get the NFS port numbers and file handle, and return the prepared 'data'
 *  argument for mount() if everything went OK. Return NULL otherwise.
 */
void * __init nfs_root_data(void)
{
	if (root_nfs_init() < 0
	 || root_nfs_ports() < 0
	 || root_nfs_get_handle() < 0)
		return NULL;
	set_sockaddr((struct sockaddr_in *) &nfs_data.addr, servaddr, htons(nfs_port));
	return (void*)&nfs_data;
}