コード例 #1
0
ファイル: nfs3xdr.c プロジェクト: Anjali05/linux
static __be32 *
encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
	      struct kstat *stat)
{
	struct timespec ts;
	*p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
	*p++ = htonl((u32) (stat->mode & S_IALLUGO));
	*p++ = htonl((u32) stat->nlink);
	*p++ = htonl((u32) from_kuid(&init_user_ns, stat->uid));
	*p++ = htonl((u32) from_kgid(&init_user_ns, stat->gid));
	if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
		p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
	} else {
		p = xdr_encode_hyper(p, (u64) stat->size);
	}
	p = xdr_encode_hyper(p, ((u64)stat->blocks) << 9);
	*p++ = htonl((u32) MAJOR(stat->rdev));
	*p++ = htonl((u32) MINOR(stat->rdev));
	p = encode_fsid(p, fhp);
	p = xdr_encode_hyper(p, stat->ino);
	ts = timespec64_to_timespec(stat->atime);
	p = encode_time3(p, &ts);
	ts = timespec64_to_timespec(stat->mtime);
	p = encode_time3(p, &ts);
	ts = timespec64_to_timespec(stat->ctime);
	p = encode_time3(p, &ts);

	return p;
}
コード例 #2
0
int vfs_encode_dummy_handle(vfs_file_handle_t *fh,
			    struct fsal_filesystem *fs)
{
	xfs_handle_t *hdl = (xfs_handle_t *) fh->handle_data;
	char handle_data[sizeof(struct fsal_fsid__)];
	int rc;

	memset(handle_data, 0, sizeof(handle_data));

	/* Pack fsid into handle_data */
	rc = encode_fsid(handle_data,
			 sizeof(handle_data),
			 &fs->fsid,
			 fs->fsid_type);

	if (rc < 0) {
		errno = EINVAL;
		return rc;
	}

	assert(sizeof(handle_data) ==
	       (sizeof(hdl->ha_fsid) + sizeof(hdl->ha_fid.fid_ino)));

	memcpy(&hdl->ha_fsid, handle_data, sizeof(hdl->ha_fsid));
	memcpy(&hdl->ha_fid.fid_ino,
	       handle_data + sizeof(hdl->ha_fsid),
	       sizeof(hdl->ha_fid.fid_ino));
	hdl->ha_fid.fid_len = sizeof(xfs_handle_t) -
			      sizeof(xfs_fsid_t) -
			      sizeof(hdl->ha_fid.fid_len);
	hdl->ha_fid.fid_pad = fs->fsid_type + 1;
	hdl->ha_fid.fid_gen = 0;
	fh->handle_len = sizeof(*hdl);

	LogXFSHandle(fh);

	return 0;
}