⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proc.c

📁 Linux Kernel 2.6.9 for OMAP1710
💻 C
📖 第 1 页 / 共 2 页
字号:
/* *  linux/fs/nfs/proc.c * *  Copyright (C) 1992, 1993, 1994  Rick Sladkey * *  OS-independent nfs remote procedure call functions * *  Tuned by Alan Cox <A.Cox@swansea.ac.uk> for >3K buffers *  so at last we can have decent(ish) throughput off a  *  Sun server. * *  Coding optimized and cleaned up by Florian La Roche. *  Note: Error returns are optimized for NFS_OK, which isn't translated via *  nfs_stat_to_errno(), but happens to be already the right return code. * *  Also, the code currently doesn't check the size of the packet, when *  it decodes the packet. * *  Feel free to fix it and mail me the diffs if it worries you. * *  Completely rewritten to support the new RPC call interface; *  rewrote and moved the entire XDR stuff to xdr.c *  --Olaf Kirch June 1996 * *  The code below initializes all auto variables explicitly, otherwise *  it will fail to work as a module (gcc generates a memset call for an *  incomplete struct). */#include <linux/types.h>#include <linux/param.h>#include <linux/slab.h>#include <linux/time.h>#include <linux/mm.h>#include <linux/utsname.h>#include <linux/errno.h>#include <linux/string.h>#include <linux/in.h>#include <linux/pagemap.h>#include <linux/sunrpc/clnt.h>#include <linux/nfs.h>#include <linux/nfs2.h>#include <linux/nfs_fs.h>#include <linux/nfs_page.h>#include <linux/lockd/bind.h>#include <linux/smp_lock.h>#define NFSDBG_FACILITY		NFSDBG_PROCextern struct rpc_procinfo nfs_procedures[];/* * Bare-bones access to getattr: this is for nfs_read_super. */static intnfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,		  struct nfs_fsinfo *info){	struct nfs_fattr *fattr = info->fattr;	struct nfs2_fsstat fsinfo;	int status;	dprintk("%s: call getattr\n", __FUNCTION__);	fattr->valid = 0;	status = rpc_call(server->client_sys, NFSPROC_GETATTR, fhandle, fattr, 0);	dprintk("%s: reply getattr %d\n", __FUNCTION__, status);	if (status)		return status;	dprintk("%s: call statfs\n", __FUNCTION__);	status = rpc_call(server->client_sys, NFSPROC_STATFS, fhandle, &fsinfo, 0);	dprintk("%s: reply statfs %d\n", __FUNCTION__, status);	if (status)		return status;	info->rtmax  = NFS_MAXDATA;	info->rtpref = fsinfo.tsize;	info->rtmult = fsinfo.bsize;	info->wtmax  = NFS_MAXDATA;	info->wtpref = fsinfo.tsize;	info->wtmult = fsinfo.bsize;	info->dtpref = fsinfo.tsize;	info->maxfilesize = 0x7FFFFFFF;	info->lease_time = 0;	return 0;}/* * One function for each procedure in the NFS protocol. */static intnfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,		struct nfs_fattr *fattr){	int	status;	dprintk("NFS call  getattr\n");	fattr->valid = 0;	status = rpc_call(server->client, NFSPROC_GETATTR,				fhandle, fattr, 0);	dprintk("NFS reply getattr\n");	return status;}static intnfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,		 struct iattr *sattr){	struct inode *inode = dentry->d_inode;	struct nfs_sattrargs	arg = { 		.fh	= NFS_FH(inode),		.sattr	= sattr	};	int	status;	dprintk("NFS call  setattr\n");	fattr->valid = 0;	status = rpc_call(NFS_CLIENT(inode), NFSPROC_SETATTR, &arg, fattr, 0);	dprintk("NFS reply setattr\n");	return status;}static intnfs_proc_lookup(struct inode *dir, struct qstr *name,		struct nfs_fh *fhandle, struct nfs_fattr *fattr){	struct nfs_diropargs	arg = {		.fh		= NFS_FH(dir),		.name		= name->name,		.len		= name->len	};	struct nfs_diropok	res = {		.fh		= fhandle,		.fattr		= fattr	};	int			status;	dprintk("NFS call  lookup %s\n", name->name);	fattr->valid = 0;	status = rpc_call(NFS_CLIENT(dir), NFSPROC_LOOKUP, &arg, &res, 0);	dprintk("NFS reply lookup: %d\n", status);	return status;}static int nfs_proc_readlink(struct inode *inode, struct page *page,		unsigned int pgbase, unsigned int pglen){	struct nfs_readlinkargs	args = {		.fh		= NFS_FH(inode),		.pgbase		= pgbase,		.pglen		= pglen,		.pages		= &page	};	int			status;	dprintk("NFS call  readlink\n");	status = rpc_call(NFS_CLIENT(inode), NFSPROC_READLINK, &args, NULL, 0);	dprintk("NFS reply readlink: %d\n", status);	return status;}static int nfs_proc_read(struct nfs_read_data *rdata){	int			flags = rdata->flags;	struct inode *		inode = rdata->inode;	struct nfs_fattr *	fattr = rdata->res.fattr;	struct rpc_message	msg = {		.rpc_proc	= &nfs_procedures[NFSPROC_READ],		.rpc_argp	= &rdata->args,		.rpc_resp	= &rdata->res,		.rpc_cred	= rdata->cred,	};	int			status;	dprintk("NFS call  read %d @ %Ld\n", rdata->args.count,			(long long) rdata->args.offset);	fattr->valid = 0;	status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);	if (status >= 0) {		nfs_refresh_inode(inode, fattr);		/* Emulate the eof flag, which isn't normally needed in NFSv2		 * as it is guaranteed to always return the file attributes		 */		if (rdata->args.offset + rdata->args.count >= fattr->size)			rdata->res.eof = 1;	}	dprintk("NFS reply read: %d\n", status);	return status;}static int nfs_proc_write(struct nfs_write_data *wdata){	int			flags = wdata->flags;	struct inode *		inode = wdata->inode;	struct nfs_fattr *	fattr = wdata->res.fattr;	struct rpc_message	msg = {		.rpc_proc	= &nfs_procedures[NFSPROC_WRITE],		.rpc_argp	= &wdata->args,		.rpc_resp	= &wdata->res,		.rpc_cred	= wdata->cred,	};	int			status;	dprintk("NFS call  write %d @ %Ld\n", wdata->args.count,			(long long) wdata->args.offset);	fattr->valid = 0;	status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);	if (status >= 0) {		nfs_refresh_inode(inode, fattr);		wdata->res.count = wdata->args.count;		wdata->verf.committed = NFS_FILE_SYNC;	}	dprintk("NFS reply write: %d\n", status);	return status < 0? status : wdata->res.count;}static struct inode *nfs_proc_create(struct inode *dir, struct qstr *name, struct iattr *sattr,		int flags){	struct nfs_fh		fhandle;	struct nfs_fattr	fattr;	struct nfs_createargs	arg = {		.fh		= NFS_FH(dir),		.name		= name->name,		.len		= name->len,		.sattr		= sattr	};	struct nfs_diropok	res = {		.fh		= &fhandle,		.fattr		= &fattr	};	int			status;	fattr.valid = 0;	dprintk("NFS call  create %s\n", name->name);	status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0);	dprintk("NFS reply create: %d\n", status);	if (status == 0) {		struct inode *inode;		inode = nfs_fhget(dir->i_sb, &fhandle, &fattr);		if (inode)			return inode;		status = -ENOMEM;	}	return ERR_PTR(status);}/* * In NFSv2, mknod is grafted onto the create call. */static intnfs_proc_mknod(struct inode *dir, struct qstr *name, struct iattr *sattr,	       dev_t rdev, struct nfs_fh *fhandle, struct nfs_fattr *fattr){	struct nfs_createargs	arg = {		.fh		= NFS_FH(dir),		.name		= name->name,		.len		= name->len,		.sattr		= sattr	};	struct nfs_diropok	res = {		.fh		= fhandle,		.fattr		= fattr	};	int			status, mode;	dprintk("NFS call  mknod %s\n", name->name);	mode = sattr->ia_mode;	if (S_ISFIFO(mode)) {		sattr->ia_mode = (mode & ~S_IFMT) | S_IFCHR;		sattr->ia_valid &= ~ATTR_SIZE;	} else if (S_ISCHR(mode) || S_ISBLK(mode)) {		sattr->ia_valid |= ATTR_SIZE;		sattr->ia_size = new_encode_dev(rdev);/* get out your barf bag */	}	fattr->valid = 0;	status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0);	if (status == -EINVAL && S_ISFIFO(mode)) {		sattr->ia_mode = mode;		fattr->valid = 0;		status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0);	}	dprintk("NFS reply mknod: %d\n", status);	return status;}  static intnfs_proc_remove(struct inode *dir, struct qstr *name){	struct nfs_diropargs	arg = {		.fh		= NFS_FH(dir),		.name		= name->name,		.len		= name->len	};	struct rpc_message	msg = { 		.rpc_proc	= &nfs_procedures[NFSPROC_REMOVE],		.rpc_argp	= &arg,		.rpc_resp	= NULL,		.rpc_cred	= NULL	};	int			status;	dprintk("NFS call  remove %s\n", name->name);	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);	dprintk("NFS reply remove: %d\n", status);	return status;}static intnfs_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr *name){	struct nfs_diropargs	*arg;	arg = (struct nfs_diropargs *)kmalloc(sizeof(*arg), GFP_KERNEL);	if (!arg)		return -ENOMEM;	arg->fh = NFS_FH(dir->d_inode);	arg->name = name->name;	arg->len = name->len;	msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE];	msg->rpc_argp = arg;	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -