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

📄 nfs3xdr.c

📁 嵌入式系统设计与实例开发实验教材二源码 多线程应用程序设计 串行端口程序设计 AD接口实验 CAN总线通信实验 GPS通信实验 Linux内核移植与编译实验 IC卡读写实验 SD驱动使
💻 C
📖 第 1 页 / 共 2 页
字号:
		args->minor = ntohl(*p++);	}	return xdr_argsize_check(rqstp, p);}intnfs3svc_decode_renameargs(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_renameargs *args){	if (!(p = decode_fh(p, &args->ffh))	 || !(p = decode_filename(p, &args->fname, &args->flen))	 || !(p = decode_fh(p, &args->tfh))	 || !(p = decode_filename(p, &args->tname, &args->tlen)))		return 0;	return xdr_argsize_check(rqstp, p);}intnfs3svc_decode_linkargs(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_linkargs *args){	if (!(p = decode_fh(p, &args->ffh))	 || !(p = decode_fh(p, &args->tfh))	 || !(p = decode_filename(p, &args->tname, &args->tlen)))		return 0;	return xdr_argsize_check(rqstp, p);}intnfs3svc_decode_readdirargs(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_readdirargs *args){	if (!(p = decode_fh(p, &args->fh)))		return 0;	p = xdr_decode_hyper(p, &args->cookie);	args->verf   = p; p += 2;	args->dircount = ~0;	args->count  = ntohl(*p++);	return xdr_argsize_check(rqstp, p);}intnfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_readdirargs *args){	if (!(p = decode_fh(p, &args->fh)))		return 0;	p = xdr_decode_hyper(p, &args->cookie);	args->verf     = p; p += 2;	args->dircount = ntohl(*p++);	args->count    = ntohl(*p++);	return xdr_argsize_check(rqstp, p);}intnfs3svc_decode_commitargs(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_commitargs *args){	if (!(p = decode_fh(p, &args->fh)))		return 0;	p = xdr_decode_hyper(p, &args->offset);	args->count = ntohl(*p++);	return xdr_argsize_check(rqstp, p);}/* * XDR encode functions *//* * There must be an encoding function for void results so svc_process * will work properly. */intnfs3svc_encode_voidres(struct svc_rqst *rqstp, u32 *p, void *dummy){	return xdr_ressize_check(rqstp, p);}/* GETATTR */intnfs3svc_encode_attrstat(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_attrstat *resp){	if (resp->status == 0)		p = encode_fattr3(rqstp, p, resp->fh.fh_dentry);	return xdr_ressize_check(rqstp, p);}/* SETATTR, REMOVE, RMDIR */intnfs3svc_encode_wccstat(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_attrstat *resp){	p = encode_wcc_data(rqstp, p, &resp->fh);	return xdr_ressize_check(rqstp, p);}/* LOOKUP */intnfs3svc_encode_diropres(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_diropres *resp){	if (resp->status == 0) {		p = encode_fh(p, &resp->fh);		p = encode_post_op_attr(rqstp, p, resp->fh.fh_dentry);	}	p = encode_post_op_attr(rqstp, p, resp->dirfh.fh_dentry);	return xdr_ressize_check(rqstp, p);}/* ACCESS */intnfs3svc_encode_accessres(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_accessres *resp){	p = encode_post_op_attr(rqstp, p, resp->fh.fh_dentry);	if (resp->status == 0)		*p++ = htonl(resp->access);	return xdr_ressize_check(rqstp, p);}/* READLINK */intnfs3svc_encode_readlinkres(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_readlinkres *resp){	p = encode_post_op_attr(rqstp, p, resp->fh.fh_dentry);	if (resp->status == 0) {		*p++ = htonl(resp->len);		p += XDR_QUADLEN(resp->len);	}	return xdr_ressize_check(rqstp, p);}/* READ */intnfs3svc_encode_readres(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_readres *resp){	p = encode_post_op_attr(rqstp, p, resp->fh.fh_dentry);	if (resp->status == 0) {		*p++ = htonl(resp->count);		*p++ = htonl(resp->eof);		*p++ = htonl(resp->count);	/* xdr opaque count */		p += XDR_QUADLEN(resp->count);	}	return xdr_ressize_check(rqstp, p);}/* WRITE */intnfs3svc_encode_writeres(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_writeres *resp){	p = encode_wcc_data(rqstp, p, &resp->fh);	if (resp->status == 0) {		*p++ = htonl(resp->count);		*p++ = htonl(resp->committed);		*p++ = htonl(nfssvc_boot.tv_sec);		*p++ = htonl(nfssvc_boot.tv_usec);	}	return xdr_ressize_check(rqstp, p);}/* CREATE, MKDIR, SYMLINK, MKNOD */intnfs3svc_encode_createres(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_diropres *resp){	if (resp->status == 0) {		*p++ = xdr_one;		p = encode_fh(p, &resp->fh);		p = encode_post_op_attr(rqstp, p, resp->fh.fh_dentry);	}	p = encode_wcc_data(rqstp, p, &resp->dirfh);	return xdr_ressize_check(rqstp, p);}/* RENAME */intnfs3svc_encode_renameres(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_renameres *resp){	p = encode_wcc_data(rqstp, p, &resp->ffh);	p = encode_wcc_data(rqstp, p, &resp->tfh);	return xdr_ressize_check(rqstp, p);}/* LINK */intnfs3svc_encode_linkres(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_linkres *resp){	p = encode_post_op_attr(rqstp, p, resp->fh.fh_dentry);	p = encode_wcc_data(rqstp, p, &resp->tfh);	return xdr_ressize_check(rqstp, p);}/* READDIR */intnfs3svc_encode_readdirres(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_readdirres *resp){	p = encode_post_op_attr(rqstp, p, resp->fh.fh_dentry);	if (resp->status == 0) {		/* stupid readdir cookie */		memcpy(p, resp->verf, 8); p += 2;		p += XDR_QUADLEN(resp->count);	}	return xdr_ressize_check(rqstp, p);}/* * Encode a directory entry. This one works for both normal readdir * and readdirplus. * The normal readdir reply requires 2 (fileid) + 1 (stringlen) * + string + 2 (cookie) + 1 (next) words, i.e. 6 + strlen. *  * The readdirplus baggage is 1+21 words for post_op_attr, plus the * file handle. */#define NFS3_ENTRY_BAGGAGE	(2 + 1 + 2 + 1)#define NFS3_ENTRYPLUS_BAGGAGE	(1 + 21 + 1 + (NFS3_FHSIZE >> 2))static intencode_entry(struct readdir_cd *cd, const char *name,	     int namlen, off_t offset, ino_t ino, unsigned int d_type, int plus){	u32		*p = cd->buffer;	int		buflen, slen, elen;	if (cd->offset)		xdr_encode_hyper(cd->offset, (u64) offset);	/* nfsd_readdir calls us with name == 0 when it wants us to	 * set the last offset entry. */	if (name == 0)		return 0;	/*	dprintk("encode_entry(%.*s @%ld%s)\n",		namlen, name, (long) offset, plus? " plus" : "");	 */	/* truncate filename if too long */	if (namlen > NFS3_MAXNAMLEN)		namlen = NFS3_MAXNAMLEN;	slen = XDR_QUADLEN(namlen);	elen = slen + NFS3_ENTRY_BAGGAGE		+ (plus? NFS3_ENTRYPLUS_BAGGAGE : 0);	if ((buflen = cd->buflen - elen) < 0) {		cd->eob = 1;		return -EINVAL;	}	*p++ = xdr_one;				 /* mark entry present */	p    = xdr_encode_hyper(p, ino);	 /* file id */	p    = xdr_encode_array(p, name, namlen);/* name length & name */	cd->offset = p;			/* remember pointer */	p = xdr_encode_hyper(p, NFS_OFFSET_MAX);	/* offset of next entry */	/* throw in readdirplus baggage */	if (plus) {		struct svc_fh	fh;		struct svc_export	*exp;		struct dentry		*dparent, *dchild;		dparent = cd->dirfh->fh_dentry;		exp  = cd->dirfh->fh_export;		fh_init(&fh, NFS3_FHSIZE);		if (isdotent(name, namlen)) {			dchild = dparent;			if (namlen == 2)				dchild = dchild->d_parent;			dchild = dget(dchild);		} else			dchild = lookup_one_len(name, dparent,namlen);		if (IS_ERR(dchild))			goto noexec;		if (fh_compose(&fh, exp, dchild, cd->dirfh) != 0 || !dchild->d_inode)			goto noexec;		p = encode_post_op_attr(cd->rqstp, p, fh.fh_dentry);		*p++ = xdr_one; /* yes, a file handle follows */		p = encode_fh(p, &fh);		fh_put(&fh);	}out:	cd->buflen = buflen;	cd->buffer = p;	return 0;noexec:	*p++ = 0;	*p++ = 0;	goto out;}intnfs3svc_encode_entry(struct readdir_cd *cd, const char *name,		     int namlen, loff_t offset, ino_t ino, unsigned int d_type){	return encode_entry(cd, name, namlen, offset, ino, d_type, 0);}intnfs3svc_encode_entry_plus(struct readdir_cd *cd, const char *name,			  int namlen, loff_t offset, ino_t ino, unsigned int d_type){	return encode_entry(cd, name, namlen, offset, ino, d_type, 1);}/* FSSTAT */intnfs3svc_encode_fsstatres(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_fsstatres *resp){	struct statfs	*s = &resp->stats;	u64		bs = s->f_bsize;	*p++ = xdr_zero;	/* no post_op_attr */	if (resp->status == 0) {		p = xdr_encode_hyper(p, bs * s->f_blocks);	/* total bytes */		p = xdr_encode_hyper(p, bs * s->f_bfree);	/* free bytes */		p = xdr_encode_hyper(p, bs * s->f_bavail);	/* user available bytes */		p = xdr_encode_hyper(p, s->f_files);	/* total inodes */		p = xdr_encode_hyper(p, s->f_ffree);	/* free inodes */		p = xdr_encode_hyper(p, s->f_ffree);	/* user available inodes */		*p++ = htonl(resp->invarsec);	/* mean unchanged time */	}	return xdr_ressize_check(rqstp, p);}/* FSINFO */intnfs3svc_encode_fsinfores(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_fsinfores *resp){	*p++ = xdr_zero;	/* no post_op_attr */	if (resp->status == 0) {		*p++ = htonl(resp->f_rtmax);		*p++ = htonl(resp->f_rtpref);		*p++ = htonl(resp->f_rtmult);		*p++ = htonl(resp->f_wtmax);		*p++ = htonl(resp->f_wtpref);		*p++ = htonl(resp->f_wtmult);		*p++ = htonl(resp->f_dtpref);		p = xdr_encode_hyper(p, resp->f_maxfilesize);		*p++ = xdr_one;		*p++ = xdr_zero;		*p++ = htonl(resp->f_properties);	}	return xdr_ressize_check(rqstp, p);}/* PATHCONF */intnfs3svc_encode_pathconfres(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_pathconfres *resp){	*p++ = xdr_zero;	/* no post_op_attr */	if (resp->status == 0) {		*p++ = htonl(resp->p_link_max);		*p++ = htonl(resp->p_name_max);		*p++ = htonl(resp->p_no_trunc);		*p++ = htonl(resp->p_chown_restricted);		*p++ = htonl(resp->p_case_insensitive);		*p++ = htonl(resp->p_case_preserving);	}	return xdr_ressize_check(rqstp, p);}/* COMMIT */intnfs3svc_encode_commitres(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_commitres *resp){	p = encode_wcc_data(rqstp, p, &resp->fh);	/* Write verifier */	if (resp->status == 0) {		*p++ = htonl(nfssvc_boot.tv_sec);		*p++ = htonl(nfssvc_boot.tv_usec);	}	return xdr_ressize_check(rqstp, p);}/* * XDR release functions */intnfs3svc_release_fhandle(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_attrstat *resp){	fh_put(&resp->fh);	return 1;}intnfs3svc_release_fhandle2(struct svc_rqst *rqstp, u32 *p,					struct nfsd3_fhandle_pair *resp){	fh_put(&resp->fh1);	fh_put(&resp->fh2);	return 1;}

⌨️ 快捷键说明

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