Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  linux/fs/nfs/proc.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright (C) 1992, 1993, 1994  Rick Sladkey
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  OS-independent nfs remote procedure call functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *  Tuned by Alan Cox <A.Cox@swansea.ac.uk> for >3K buffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *  so at last we can have decent(ish) throughput off a 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *  Sun server.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *  Coding optimized and cleaned up by Florian La Roche.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *  Note: Error returns are optimized for NFS_OK, which isn't translated via
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *  nfs_stat_to_errno(), but happens to be already the right return code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *  Also, the code currently doesn't check the size of the packet, when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *  it decodes the packet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *  Feel free to fix it and mail me the diffs if it worries you.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *  Completely rewritten to support the new RPC call interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *  rewrote and moved the entire XDR stuff to xdr.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *  --Olaf Kirch June 1996
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *  The code below initializes all auto variables explicitly, otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *  it will fail to work as a module (gcc generates a memset call for an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *  incomplete struct).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include <linux/param.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <linux/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include <linux/in.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include <linux/pagemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include <linux/sunrpc/clnt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #include <linux/nfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #include <linux/nfs2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #include <linux/nfs_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #include <linux/nfs_page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #include <linux/lockd/bind.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #include <linux/freezer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #include "internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define NFSDBG_FACILITY		NFSDBG_PROC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * Bare-bones access to getattr: this is for nfs_read_super.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		  struct nfs_fsinfo *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	struct nfs_fattr *fattr = info->fattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	struct nfs2_fsstat fsinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		.rpc_proc	= &nfs_procedures[NFSPROC_GETATTR],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		.rpc_argp	= fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		.rpc_resp	= fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	dprintk("%s: call getattr\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	nfs_fattr_init(fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	status = rpc_call_sync(server->client, &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	/* Retry with default authentication if different */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	if (status && server->nfs_client->cl_rpcclient != server->client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	dprintk("%s: reply getattr: %d\n", __func__, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	dprintk("%s: call statfs\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	msg.rpc_proc = &nfs_procedures[NFSPROC_STATFS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	msg.rpc_resp = &fsinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	status = rpc_call_sync(server->client, &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	/* Retry with default authentication if different */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	if (status && server->nfs_client->cl_rpcclient != server->client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	dprintk("%s: reply statfs: %d\n", __func__, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	info->rtmax  = NFS_MAXDATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	info->rtpref = fsinfo.tsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	info->rtmult = fsinfo.bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	info->wtmax  = NFS_MAXDATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	info->wtpref = fsinfo.tsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	info->wtmult = fsinfo.bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	info->dtpref = fsinfo.tsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	info->maxfilesize = 0x7FFFFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	info->lease_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  * One function for each procedure in the NFS protocol.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		struct nfs_fattr *fattr, struct nfs4_label *label,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		.rpc_proc	= &nfs_procedures[NFSPROC_GETATTR],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		.rpc_argp	= fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		.rpc_resp	= fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	int	status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	unsigned short task_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	/* Is this is an attribute revalidation, subject to softreval? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	if (inode && (server->flags & NFS_MOUNT_SOFTREVAL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		task_flags |= RPC_TASK_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	dprintk("NFS call  getattr\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	nfs_fattr_init(fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	status = rpc_call_sync(server->client, &msg, task_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	dprintk("NFS reply getattr: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		 struct iattr *sattr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	struct inode *inode = d_inode(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	struct nfs_sattrargs	arg = { 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		.fh	= NFS_FH(inode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		.sattr	= sattr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		.rpc_proc	= &nfs_procedures[NFSPROC_SETATTR],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		.rpc_argp	= &arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		.rpc_resp	= fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	int	status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	/* Mask out the non-modebit related stuff from attr->ia_mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	sattr->ia_mode &= S_IALLUGO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	dprintk("NFS call  setattr\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	if (sattr->ia_valid & ATTR_FILE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		msg.rpc_cred = nfs_file_cred(sattr->ia_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	nfs_fattr_init(fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	if (status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		nfs_setattr_update_inode(inode, sattr, fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	dprintk("NFS reply setattr: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) nfs_proc_lookup(struct inode *dir, struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		struct nfs_fh *fhandle, struct nfs_fattr *fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		struct nfs4_label *label)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	struct nfs_diropargs	arg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		.fh		= NFS_FH(dir),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		.name		= dentry->d_name.name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		.len		= dentry->d_name.len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	struct nfs_diropok	res = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		.fh		= fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		.fattr		= fattr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		.rpc_proc	= &nfs_procedures[NFSPROC_LOOKUP],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		.rpc_argp	= &arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		.rpc_resp	= &res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	int			status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	unsigned short task_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	/* Is this is an attribute revalidation, subject to softreval? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	if (nfs_lookup_is_soft_revalidate(dentry))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		task_flags |= RPC_TASK_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	dprintk("NFS call  lookup %pd2\n", dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	nfs_fattr_init(fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, task_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	dprintk("NFS reply lookup: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) static int nfs_proc_readlink(struct inode *inode, struct page *page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		unsigned int pgbase, unsigned int pglen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	struct nfs_readlinkargs	args = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		.fh		= NFS_FH(inode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		.pgbase		= pgbase,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		.pglen		= pglen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		.pages		= &page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		.rpc_proc	= &nfs_procedures[NFSPROC_READLINK],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		.rpc_argp	= &args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	int			status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	dprintk("NFS call  readlink\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	dprintk("NFS reply readlink: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) struct nfs_createdata {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	struct nfs_createargs arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	struct nfs_diropok res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	struct nfs_fh fhandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	struct nfs_fattr fattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) static struct nfs_createdata *nfs_alloc_createdata(struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		struct dentry *dentry, struct iattr *sattr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	struct nfs_createdata *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	data = kmalloc(sizeof(*data), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	if (data != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		data->arg.fh = NFS_FH(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		data->arg.name = dentry->d_name.name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		data->arg.len = dentry->d_name.len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		data->arg.sattr = sattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		nfs_fattr_init(&data->fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		data->fhandle.size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		data->res.fh = &data->fhandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		data->res.fattr = &data->fattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	return data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) static void nfs_free_createdata(const struct nfs_createdata *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	kfree(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	struct nfs_createdata *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		.rpc_proc	= &nfs_procedures[NFSPROC_CREATE],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	int status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	dprintk("NFS call  create %pd\n", dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	data = nfs_alloc_createdata(dir, dentry, sattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	if (data == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	msg.rpc_argp = &data->arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	msg.rpc_resp = &data->res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	nfs_mark_for_revalidate(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	if (status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		status = nfs_instantiate(dentry, data->res.fh, data->res.fattr, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	nfs_free_createdata(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	dprintk("NFS reply create: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)  * In NFSv2, mknod is grafted onto the create call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	       dev_t rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	struct nfs_createdata *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		.rpc_proc	= &nfs_procedures[NFSPROC_CREATE],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	umode_t mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	int status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	dprintk("NFS call  mknod %pd\n", dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	mode = sattr->ia_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	if (S_ISFIFO(mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		sattr->ia_mode = (mode & ~S_IFMT) | S_IFCHR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		sattr->ia_valid &= ~ATTR_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	} else if (S_ISCHR(mode) || S_ISBLK(mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		sattr->ia_valid |= ATTR_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		sattr->ia_size = new_encode_dev(rdev);/* get out your barf bag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	data = nfs_alloc_createdata(dir, dentry, sattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	if (data == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	msg.rpc_argp = &data->arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	msg.rpc_resp = &data->res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	nfs_mark_for_revalidate(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	if (status == -EINVAL && S_ISFIFO(mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 		sattr->ia_mode = mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 		nfs_fattr_init(data->res.fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	if (status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		status = nfs_instantiate(dentry, data->res.fh, data->res.fattr, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	nfs_free_createdata(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	dprintk("NFS reply mknod: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)   
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) nfs_proc_remove(struct inode *dir, struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	struct nfs_removeargs arg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 		.fh = NFS_FH(dir),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		.name = dentry->d_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	struct rpc_message msg = { 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 		.rpc_proc = &nfs_procedures[NFSPROC_REMOVE],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		.rpc_argp = &arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	int			status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	dprintk("NFS call  remove %pd2\n",dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	nfs_mark_for_revalidate(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	dprintk("NFS reply remove: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) nfs_proc_unlink_setup(struct rpc_message *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) static void nfs_proc_unlink_rpc_prepare(struct rpc_task *task, struct nfs_unlinkdata *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	rpc_call_start(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) static int nfs_proc_unlink_done(struct rpc_task *task, struct inode *dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	nfs_mark_for_revalidate(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) nfs_proc_rename_setup(struct rpc_message *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		struct dentry *old_dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 		struct dentry *new_dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	msg->rpc_proc = &nfs_procedures[NFSPROC_RENAME];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) static void nfs_proc_rename_rpc_prepare(struct rpc_task *task, struct nfs_renamedata *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	rpc_call_start(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) nfs_proc_rename_done(struct rpc_task *task, struct inode *old_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 		     struct inode *new_dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	nfs_mark_for_revalidate(old_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	nfs_mark_for_revalidate(new_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) nfs_proc_link(struct inode *inode, struct inode *dir, const struct qstr *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	struct nfs_linkargs	arg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 		.fromfh		= NFS_FH(inode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		.tofh		= NFS_FH(dir),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		.toname		= name->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 		.tolen		= name->len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 		.rpc_proc	= &nfs_procedures[NFSPROC_LINK],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		.rpc_argp	= &arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	int			status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	dprintk("NFS call  link %s\n", name->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	nfs_mark_for_revalidate(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	nfs_mark_for_revalidate(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	dprintk("NFS reply link: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		 unsigned int len, struct iattr *sattr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	struct nfs_fh *fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	struct nfs_fattr *fattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	struct nfs_symlinkargs	arg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 		.fromfh		= NFS_FH(dir),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		.fromname	= dentry->d_name.name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		.fromlen	= dentry->d_name.len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 		.pages		= &page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		.pathlen	= len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 		.sattr		= sattr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		.rpc_proc	= &nfs_procedures[NFSPROC_SYMLINK],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		.rpc_argp	= &arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	int status = -ENAMETOOLONG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	dprintk("NFS call  symlink %pd\n", dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	if (len > NFS2_MAXPATHLEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	fh = nfs_alloc_fhandle();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	fattr = nfs_alloc_fattr();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	if (fh == NULL || fattr == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 		goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	nfs_mark_for_revalidate(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	 * V2 SYMLINK requests don't return any attributes.  Setting the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	 * filehandle size to zero indicates to nfs_instantiate that it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	 * should fill in the data with a LOOKUP call on the wire.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	if (status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 		status = nfs_instantiate(dentry, fh, fattr, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) out_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	nfs_free_fattr(fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	nfs_free_fhandle(fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	dprintk("NFS reply symlink: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) nfs_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	struct nfs_createdata *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 		.rpc_proc	= &nfs_procedures[NFSPROC_MKDIR],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	int status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	dprintk("NFS call  mkdir %pd\n", dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	data = nfs_alloc_createdata(dir, dentry, sattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	if (data == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	msg.rpc_argp = &data->arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	msg.rpc_resp = &data->res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	nfs_mark_for_revalidate(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	if (status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		status = nfs_instantiate(dentry, data->res.fh, data->res.fattr, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	nfs_free_createdata(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	dprintk("NFS reply mkdir: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) nfs_proc_rmdir(struct inode *dir, const struct qstr *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	struct nfs_diropargs	arg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 		.fh		= NFS_FH(dir),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 		.name		= name->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 		.len		= name->len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 		.rpc_proc	= &nfs_procedures[NFSPROC_RMDIR],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 		.rpc_argp	= &arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	int			status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	dprintk("NFS call  rmdir %s\n", name->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	nfs_mark_for_revalidate(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	dprintk("NFS reply rmdir: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)  * The READDIR implementation is somewhat hackish - we pass a temporary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)  * buffer to the encode function, which installs it in the receive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)  * the receive iovec. The decode function just parses the reply to make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)  * sure it is syntactically correct; the entries itself are decoded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500)  * from nfs_readdir by calling the decode_entry function directly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) nfs_proc_readdir(struct dentry *dentry, const struct cred *cred,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 		 u64 cookie, struct page **pages, unsigned int count, bool plus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 	struct inode		*dir = d_inode(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	struct nfs_readdirargs	arg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 		.fh		= NFS_FH(dir),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 		.cookie		= cookie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 		.count		= count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 		.pages		= pages,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 	struct rpc_message	msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 		.rpc_proc	= &nfs_procedures[NFSPROC_READDIR],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 		.rpc_argp	= &arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 		.rpc_cred	= cred,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	int			status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 	dprintk("NFS call  readdir %d\n", (unsigned int)cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	nfs_invalidate_atime(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	dprintk("NFS reply readdir: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) nfs_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 			struct nfs_fsstat *stat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	struct nfs2_fsstat fsinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 		.rpc_proc	= &nfs_procedures[NFSPROC_STATFS],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 		.rpc_argp	= fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 		.rpc_resp	= &fsinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 	int	status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 	dprintk("NFS call  statfs\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	nfs_fattr_init(stat->fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 	status = rpc_call_sync(server->client, &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	dprintk("NFS reply statfs: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 	stat->tbytes = (u64)fsinfo.blocks * fsinfo.bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	stat->fbytes = (u64)fsinfo.bfree  * fsinfo.bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	stat->abytes = (u64)fsinfo.bavail * fsinfo.bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	stat->tfiles = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	stat->ffiles = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 	stat->afiles = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) nfs_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 			struct nfs_fsinfo *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	struct nfs2_fsstat fsinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 		.rpc_proc	= &nfs_procedures[NFSPROC_STATFS],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 		.rpc_argp	= fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 		.rpc_resp	= &fsinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 	int	status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	dprintk("NFS call  fsinfo\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 	nfs_fattr_init(info->fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	status = rpc_call_sync(server->client, &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	dprintk("NFS reply fsinfo: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	info->rtmax  = NFS_MAXDATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 	info->rtpref = fsinfo.tsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	info->rtmult = fsinfo.bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	info->wtmax  = NFS_MAXDATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	info->wtpref = fsinfo.tsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	info->wtmult = fsinfo.bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	info->dtpref = fsinfo.tsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	info->maxfilesize = 0x7FFFFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	info->lease_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) nfs_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 		  struct nfs_pathconf *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	info->max_link = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	info->max_namelen = NFS2_MAXNAMLEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) static int nfs_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 	struct inode *inode = hdr->inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 	nfs_invalidate_atime(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 	if (task->tk_status >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 		nfs_refresh_inode(inode, hdr->res.fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 		/* Emulate the eof flag, which isn't normally needed in NFSv2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 		 * as it is guaranteed to always return the file attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 		if ((hdr->res.count == 0 && hdr->args.count > 0) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 		    hdr->args.offset + hdr->res.count >= hdr->res.fattr->size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 			hdr->res.eof = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) static void nfs_proc_read_setup(struct nfs_pgio_header *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 				struct rpc_message *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 	msg->rpc_proc = &nfs_procedures[NFSPROC_READ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) static int nfs_proc_pgio_rpc_prepare(struct rpc_task *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 				     struct nfs_pgio_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 	rpc_call_start(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) static int nfs_write_done(struct rpc_task *task, struct nfs_pgio_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 	if (task->tk_status >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 		hdr->res.count = hdr->args.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 		nfs_writeback_update_inode(hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) static void nfs_proc_write_setup(struct nfs_pgio_header *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 				 struct rpc_message *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 				 struct rpc_clnt **clnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 	/* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	hdr->args.stable = NFS_FILE_SYNC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	msg->rpc_proc = &nfs_procedures[NFSPROC_WRITE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) static void nfs_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 	BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) nfs_proc_commit_setup(struct nfs_commit_data *data, struct rpc_message *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 			struct rpc_clnt **clnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 	struct inode *inode = file_inode(filp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 	return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) /* Helper functions for NFS lock bounds checking */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) #define NFS_LOCK32_OFFSET_MAX ((__s32)0x7fffffffUL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) static int nfs_lock_check_bounds(const struct file_lock *fl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 	__s32 start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 	start = (__s32)fl->fl_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 	if ((loff_t)start != fl->fl_start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 		goto out_einval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 	if (fl->fl_end != OFFSET_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 		end = (__s32)fl->fl_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 		if ((loff_t)end != fl->fl_end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 			goto out_einval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 		end = NFS_LOCK32_OFFSET_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 	if (start < 0 || start > end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 		goto out_einval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) out_einval:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) static int nfs_have_delegation(struct inode *inode, fmode_t flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) static const struct inode_operations nfs_dir_inode_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 	.create		= nfs_create,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 	.lookup		= nfs_lookup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 	.link		= nfs_link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 	.unlink		= nfs_unlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 	.symlink	= nfs_symlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 	.mkdir		= nfs_mkdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 	.rmdir		= nfs_rmdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 	.mknod		= nfs_mknod,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 	.rename		= nfs_rename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 	.permission	= nfs_permission,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 	.getattr	= nfs_getattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 	.setattr	= nfs_setattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) static const struct inode_operations nfs_file_inode_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 	.permission	= nfs_permission,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 	.getattr	= nfs_getattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 	.setattr	= nfs_setattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) const struct nfs_rpc_ops nfs_v2_clientops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 	.version	= 2,		       /* protocol version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 	.dentry_ops	= &nfs_dentry_operations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 	.dir_inode_ops	= &nfs_dir_inode_operations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 	.file_inode_ops	= &nfs_file_inode_operations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 	.file_ops	= &nfs_file_operations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 	.getroot	= nfs_proc_get_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 	.submount	= nfs_submount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 	.try_get_tree	= nfs_try_get_tree,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 	.getattr	= nfs_proc_getattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 	.setattr	= nfs_proc_setattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 	.lookup		= nfs_proc_lookup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) 	.access		= NULL,		       /* access */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 	.readlink	= nfs_proc_readlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 	.create		= nfs_proc_create,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) 	.remove		= nfs_proc_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) 	.unlink_setup	= nfs_proc_unlink_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) 	.unlink_rpc_prepare = nfs_proc_unlink_rpc_prepare,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) 	.unlink_done	= nfs_proc_unlink_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) 	.rename_setup	= nfs_proc_rename_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) 	.rename_rpc_prepare = nfs_proc_rename_rpc_prepare,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) 	.rename_done	= nfs_proc_rename_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 	.link		= nfs_proc_link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 	.symlink	= nfs_proc_symlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 	.mkdir		= nfs_proc_mkdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) 	.rmdir		= nfs_proc_rmdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) 	.readdir	= nfs_proc_readdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) 	.mknod		= nfs_proc_mknod,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) 	.statfs		= nfs_proc_statfs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) 	.fsinfo		= nfs_proc_fsinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) 	.pathconf	= nfs_proc_pathconf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) 	.decode_dirent	= nfs2_decode_dirent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) 	.pgio_rpc_prepare = nfs_proc_pgio_rpc_prepare,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) 	.read_setup	= nfs_proc_read_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) 	.read_done	= nfs_read_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) 	.write_setup	= nfs_proc_write_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) 	.write_done	= nfs_write_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) 	.commit_setup	= nfs_proc_commit_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) 	.commit_rpc_prepare = nfs_proc_commit_rpc_prepare,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) 	.lock		= nfs_proc_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) 	.lock_check_bounds = nfs_lock_check_bounds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) 	.close_context	= nfs_close_context,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) 	.have_delegation = nfs_have_delegation,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) 	.alloc_client	= nfs_alloc_client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) 	.init_client	= nfs_init_client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) 	.free_client	= nfs_free_client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) 	.create_server	= nfs_create_server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) 	.clone_server	= nfs_clone_server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) };