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

📄 nfs3proc.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	/* Unlink. -S_IFDIR means file must not be a directory */	fh_copy(&resp->fh, &argp->fh);	nfserr = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR, argp->name, argp->len);	RETURN_STATUS(nfserr);}/* * Remove a directory */static __be32nfsd3_proc_rmdir(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp,					 struct nfsd3_attrstat  *resp){	__be32	nfserr;	dprintk("nfsd: RMDIR(3)    %s %.*s\n",				SVCFH_fmt(&argp->fh),				argp->len,				argp->name);	fh_copy(&resp->fh, &argp->fh);	nfserr = nfsd_unlink(rqstp, &resp->fh, S_IFDIR, argp->name, argp->len);	RETURN_STATUS(nfserr);}static __be32nfsd3_proc_rename(struct svc_rqst *rqstp, struct nfsd3_renameargs *argp,					  struct nfsd3_renameres  *resp){	__be32	nfserr;	dprintk("nfsd: RENAME(3)   %s %.*s ->\n",				SVCFH_fmt(&argp->ffh),				argp->flen,				argp->fname);	dprintk("nfsd: -> %s %.*s\n",				SVCFH_fmt(&argp->tfh),				argp->tlen,				argp->tname);	fh_copy(&resp->ffh, &argp->ffh);	fh_copy(&resp->tfh, &argp->tfh);	nfserr = nfsd_rename(rqstp, &resp->ffh, argp->fname, argp->flen,				    &resp->tfh, argp->tname, argp->tlen);	RETURN_STATUS(nfserr);}static __be32nfsd3_proc_link(struct svc_rqst *rqstp, struct nfsd3_linkargs *argp,					struct nfsd3_linkres  *resp){	__be32	nfserr;	dprintk("nfsd: LINK(3)     %s ->\n",				SVCFH_fmt(&argp->ffh));	dprintk("nfsd:   -> %s %.*s\n",				SVCFH_fmt(&argp->tfh),				argp->tlen,				argp->tname);	fh_copy(&resp->fh,  &argp->ffh);	fh_copy(&resp->tfh, &argp->tfh);	nfserr = nfsd_link(rqstp, &resp->tfh, argp->tname, argp->tlen,				  &resp->fh);	RETURN_STATUS(nfserr);}/* * Read a portion of a directory. */static __be32nfsd3_proc_readdir(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp,					   struct nfsd3_readdirres  *resp){	__be32		nfserr;	int		count;	dprintk("nfsd: READDIR(3)  %s %d bytes at %d\n",				SVCFH_fmt(&argp->fh),				argp->count, (u32) argp->cookie);	/* Make sure we've room for the NULL ptr & eof flag, and shrink to	 * client read size */	count = (argp->count >> 2) - 2;	/* Read directory and encode entries on the fly */	fh_copy(&resp->fh, &argp->fh);	resp->buflen = count;	resp->common.err = nfs_ok;	resp->buffer = argp->buffer;	resp->rqstp = rqstp;	nfserr = nfsd_readdir(rqstp, &resp->fh, (loff_t*) &argp->cookie, 					&resp->common, nfs3svc_encode_entry);	memcpy(resp->verf, argp->verf, 8);	resp->count = resp->buffer - argp->buffer;	if (resp->offset)		xdr_encode_hyper(resp->offset, argp->cookie);	RETURN_STATUS(nfserr);}/* * Read a portion of a directory, including file handles and attrs. * For now, we choose to ignore the dircount parameter. */static __be32nfsd3_proc_readdirplus(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp,					       struct nfsd3_readdirres  *resp){	__be32	nfserr;	int	count = 0;	loff_t	offset;	int	i;	caddr_t	page_addr = NULL;	dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n",				SVCFH_fmt(&argp->fh),				argp->count, (u32) argp->cookie);	/* Convert byte count to number of words (i.e. >> 2),	 * and reserve room for the NULL ptr & eof flag (-2 words) */	resp->count = (argp->count >> 2) - 2;	/* Read directory and encode entries on the fly */	fh_copy(&resp->fh, &argp->fh);	resp->common.err = nfs_ok;	resp->buffer = argp->buffer;	resp->buflen = resp->count;	resp->rqstp = rqstp;	offset = argp->cookie;	nfserr = nfsd_readdir(rqstp, &resp->fh,				     &offset,				     &resp->common,				     nfs3svc_encode_entry_plus);	memcpy(resp->verf, argp->verf, 8);	for (i=1; i<rqstp->rq_resused ; i++) {		page_addr = page_address(rqstp->rq_respages[i]);		if (((caddr_t)resp->buffer >= page_addr) &&		    ((caddr_t)resp->buffer < page_addr + PAGE_SIZE)) {			count += (caddr_t)resp->buffer - page_addr;			break;		}		count += PAGE_SIZE;	}	resp->count = count >> 2;	if (resp->offset) {		if (unlikely(resp->offset1)) {			/* we ended up with offset on a page boundary */			*resp->offset = htonl(offset >> 32);			*resp->offset1 = htonl(offset & 0xffffffff);			resp->offset1 = NULL;		} else {			xdr_encode_hyper(resp->offset, offset);		}	}	RETURN_STATUS(nfserr);}/* * Get file system stats */static __be32nfsd3_proc_fsstat(struct svc_rqst * rqstp, struct nfsd_fhandle    *argp,					   struct nfsd3_fsstatres *resp){	__be32	nfserr;	dprintk("nfsd: FSSTAT(3)   %s\n",				SVCFH_fmt(&argp->fh));	nfserr = nfsd_statfs(rqstp, &argp->fh, &resp->stats);	fh_put(&argp->fh);	RETURN_STATUS(nfserr);}/* * Get file system info */static __be32nfsd3_proc_fsinfo(struct svc_rqst * rqstp, struct nfsd_fhandle    *argp,					   struct nfsd3_fsinfores *resp){	__be32	nfserr;	u32	max_blocksize = svc_max_payload(rqstp);	dprintk("nfsd: FSINFO(3)   %s\n",				SVCFH_fmt(&argp->fh));	resp->f_rtmax  = max_blocksize;	resp->f_rtpref = max_blocksize;	resp->f_rtmult = PAGE_SIZE;	resp->f_wtmax  = max_blocksize;	resp->f_wtpref = max_blocksize;	resp->f_wtmult = PAGE_SIZE;	resp->f_dtpref = PAGE_SIZE;	resp->f_maxfilesize = ~(u32) 0;	resp->f_properties = NFS3_FSF_DEFAULT;	nfserr = fh_verify(rqstp, &argp->fh, 0, MAY_NOP);	/* Check special features of the file system. May request	 * different read/write sizes for file systems known to have	 * problems with large blocks */	if (nfserr == 0) {		struct super_block *sb = argp->fh.fh_dentry->d_inode->i_sb;		/* Note that we don't care for remote fs's here */		if (sb->s_magic == 0x4d44 /* MSDOS_SUPER_MAGIC */) {			resp->f_properties = NFS3_FSF_BILLYBOY;		}		resp->f_maxfilesize = sb->s_maxbytes;	}	fh_put(&argp->fh);	RETURN_STATUS(nfserr);}/* * Get pathconf info for the specified file */static __be32nfsd3_proc_pathconf(struct svc_rqst * rqstp, struct nfsd_fhandle      *argp,					     struct nfsd3_pathconfres *resp){	__be32	nfserr;	dprintk("nfsd: PATHCONF(3) %s\n",				SVCFH_fmt(&argp->fh));	/* Set default pathconf */	resp->p_link_max = 255;		/* at least */	resp->p_name_max = 255;		/* at least */	resp->p_no_trunc = 0;	resp->p_chown_restricted = 1;	resp->p_case_insensitive = 0;	resp->p_case_preserving = 1;	nfserr = fh_verify(rqstp, &argp->fh, 0, MAY_NOP);	if (nfserr == 0) {		struct super_block *sb = argp->fh.fh_dentry->d_inode->i_sb;		/* Note that we don't care for remote fs's here */		switch (sb->s_magic) {		case EXT2_SUPER_MAGIC:			resp->p_link_max = EXT2_LINK_MAX;			resp->p_name_max = EXT2_NAME_LEN;			break;		case 0x4d44:	/* MSDOS_SUPER_MAGIC */			resp->p_case_insensitive = 1;			resp->p_case_preserving  = 0;			break;		}	}	fh_put(&argp->fh);	RETURN_STATUS(nfserr);}/* * Commit a file (range) to stable storage. */static __be32nfsd3_proc_commit(struct svc_rqst * rqstp, struct nfsd3_commitargs *argp,					   struct nfsd3_commitres  *resp){	__be32	nfserr;	dprintk("nfsd: COMMIT(3)   %s %u@%Lu\n",				SVCFH_fmt(&argp->fh),				argp->count,				(unsigned long long) argp->offset);	if (argp->offset > NFS_OFFSET_MAX)		RETURN_STATUS(nfserr_inval);	fh_copy(&resp->fh, &argp->fh);	nfserr = nfsd_commit(rqstp, &resp->fh, argp->offset, argp->count);	RETURN_STATUS(nfserr);}/* * NFSv3 Server procedures. * Only the results of non-idempotent operations are cached. */#define nfs3svc_decode_voidargs		NULL#define nfs3svc_release_void		NULL#define nfs3svc_decode_fhandleargs	nfs3svc_decode_fhandle#define nfs3svc_encode_attrstatres	nfs3svc_encode_attrstat#define nfs3svc_encode_wccstatres	nfs3svc_encode_wccstat#define nfsd3_mkdirargs			nfsd3_createargs#define nfsd3_readdirplusargs		nfsd3_readdirargs#define nfsd3_fhandleargs		nfsd_fhandle#define nfsd3_fhandleres		nfsd3_attrstat#define nfsd3_attrstatres		nfsd3_attrstat#define nfsd3_wccstatres		nfsd3_attrstat#define nfsd3_createres			nfsd3_diropres#define nfsd3_voidres			nfsd3_voidargsstruct nfsd3_voidargs { int dummy; };#define PROC(name, argt, rest, relt, cache, respsize)	\ { (svc_procfunc) nfsd3_proc_##name,		\   (kxdrproc_t) nfs3svc_decode_##argt##args,	\   (kxdrproc_t) nfs3svc_encode_##rest##res,	\   (kxdrproc_t) nfs3svc_release_##relt,		\   sizeof(struct nfsd3_##argt##args),		\   sizeof(struct nfsd3_##rest##res),		\   0,						\   cache,					\   respsize,					\ }#define ST 1		/* status*/#define FH 17		/* filehandle with length */#define AT 21		/* attributes */#define pAT (1+AT)	/* post attributes - conditional */#define WC (7+pAT)	/* WCC attributes */static struct svc_procedure		nfsd_procedures3[22] = {  PROC(null,	 void,		void,		void,	  RC_NOCACHE, ST),  PROC(getattr,	 fhandle,	attrstat,	fhandle,  RC_NOCACHE, ST+AT),  PROC(setattr,  sattr,		wccstat,	fhandle,  RC_REPLBUFF, ST+WC),  PROC(lookup,	 dirop,		dirop,		fhandle2, RC_NOCACHE, ST+FH+pAT+pAT),  PROC(access,	 access,	access,		fhandle,  RC_NOCACHE, ST+pAT+1),  PROC(readlink, readlink,	readlink,	fhandle,  RC_NOCACHE, ST+pAT+1+NFS3_MAXPATHLEN/4),  PROC(read,	 read,		read,		fhandle,  RC_NOCACHE, ST+pAT+4+NFSSVC_MAXBLKSIZE/4),  PROC(write,	 write,		write,		fhandle,  RC_REPLBUFF, ST+WC+4),  PROC(create,	 create,	create,		fhandle2, RC_REPLBUFF, ST+(1+FH+pAT)+WC),  PROC(mkdir,	 mkdir,		create,		fhandle2, RC_REPLBUFF, ST+(1+FH+pAT)+WC),  PROC(symlink,	 symlink,	create,		fhandle2, RC_REPLBUFF, ST+(1+FH+pAT)+WC),  PROC(mknod,	 mknod,		create,		fhandle2, RC_REPLBUFF, ST+(1+FH+pAT)+WC),  PROC(remove,	 dirop,		wccstat,	fhandle,  RC_REPLBUFF, ST+WC),  PROC(rmdir,	 dirop,		wccstat,	fhandle,  RC_REPLBUFF, ST+WC),  PROC(rename,	 rename,	rename,		fhandle2, RC_REPLBUFF, ST+WC+WC),  PROC(link,	 link,		link,		fhandle2, RC_REPLBUFF, ST+pAT+WC),  PROC(readdir,	 readdir,	readdir,	fhandle,  RC_NOCACHE, 0),  PROC(readdirplus,readdirplus,	readdir,	fhandle,  RC_NOCACHE, 0),  PROC(fsstat,	 fhandle,	fsstat,		void,     RC_NOCACHE, ST+pAT+2*6+1),  PROC(fsinfo,   fhandle,	fsinfo,		void,     RC_NOCACHE, ST+pAT+12),  PROC(pathconf, fhandle,	pathconf,	void,     RC_NOCACHE, ST+pAT+6),  PROC(commit,	 commit,	commit,		fhandle,  RC_NOCACHE, ST+WC+2),};struct svc_version	nfsd_version3 = {		.vs_vers	= 3,		.vs_nproc	= 22,		.vs_proc	= nfsd_procedures3,		.vs_dispatch	= nfsd_dispatch,		.vs_xdrsize	= NFS3_SVC_XDRSIZE,};

⌨️ 快捷键说明

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