Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 229168
b: refs/heads/master
c: 9d5a643
h: refs/heads/master
v: v3
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed Dec 16, 2010
1 parent c482013 commit bdc0ec6
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 57 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 499ff710b2fd3a03c8195c82340e5166eed04205
refs/heads/master: 9d5a64343925a152e1907c652a0d71d6640868b3
111 changes: 55 additions & 56 deletions trunk/fs/nfs/nfs3xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,6 @@ xdr_decode_fhandle_stream(struct xdr_stream *xdr, struct nfs_fh *fh)
/*
* Encode/decode time.
*/
static inline __be32 *
xdr_encode_time3(__be32 *p, const struct timespec *timep)
{
*p++ = htonl(timep->tv_sec);
*p++ = htonl(timep->tv_nsec);
return p;
}

static inline __be32 *
xdr_decode_time3(__be32 *p, struct timespec *timep)
{
Expand Down Expand Up @@ -218,52 +210,6 @@ xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr)
return p;
}

static inline __be32 *
xdr_encode_sattr(__be32 *p, const struct iattr *attr)
{
if (attr->ia_valid & ATTR_MODE) {
*p++ = xdr_one;
*p++ = htonl(attr->ia_mode & S_IALLUGO);
} else {
*p++ = xdr_zero;
}
if (attr->ia_valid & ATTR_UID) {
*p++ = xdr_one;
*p++ = htonl(attr->ia_uid);
} else {
*p++ = xdr_zero;
}
if (attr->ia_valid & ATTR_GID) {
*p++ = xdr_one;
*p++ = htonl(attr->ia_gid);
} else {
*p++ = xdr_zero;
}
if (attr->ia_valid & ATTR_SIZE) {
*p++ = xdr_one;
p = xdr_encode_hyper(p, (__u64) attr->ia_size);
} else {
*p++ = xdr_zero;
}
if (attr->ia_valid & ATTR_ATIME_SET) {
*p++ = xdr_two;
p = xdr_encode_time3(p, &attr->ia_atime);
} else if (attr->ia_valid & ATTR_ATIME) {
*p++ = xdr_one;
} else {
*p++ = xdr_zero;
}
if (attr->ia_valid & ATTR_MTIME_SET) {
*p++ = xdr_two;
p = xdr_encode_time3(p, &attr->ia_mtime);
} else if (attr->ia_valid & ATTR_MTIME) {
*p++ = xdr_one;
} else {
*p++ = xdr_zero;
}
return p;
}

static inline __be32 *
xdr_decode_wcc_attr(__be32 *p, struct nfs_fattr *fattr)
{
Expand Down Expand Up @@ -452,6 +398,21 @@ static void encode_nfs_fh3(struct xdr_stream *xdr, const struct nfs_fh *fh)
xdr_encode_opaque(p, fh->data, fh->size);
}

/*
* nfstime3
*
* struct nfstime3 {
* uint32 seconds;
* uint32 nseconds;
* };
*/
static __be32 *xdr_encode_nfstime3(__be32 *p, const struct timespec *timep)
{
*p++ = cpu_to_be32(timep->tv_sec);
*p++ = cpu_to_be32(timep->tv_nsec);
return p;
}

/*
* sattr3
*
Expand Down Expand Up @@ -538,7 +499,45 @@ static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
nbytes += 8;
p = xdr_reserve_space(xdr, nbytes);

xdr_encode_sattr(p, attr);
if (attr->ia_valid & ATTR_MODE) {
*p++ = xdr_one;
*p++ = cpu_to_be32(attr->ia_mode & S_IALLUGO);
} else
*p++ = xdr_zero;

if (attr->ia_valid & ATTR_UID) {
*p++ = xdr_one;
*p++ = cpu_to_be32(attr->ia_uid);
} else
*p++ = xdr_zero;

if (attr->ia_valid & ATTR_GID) {
*p++ = xdr_one;
*p++ = cpu_to_be32(attr->ia_gid);
} else
*p++ = xdr_zero;

if (attr->ia_valid & ATTR_SIZE) {
*p++ = xdr_one;
p = xdr_encode_hyper(p, (u64)attr->ia_size);
} else
*p++ = xdr_zero;

if (attr->ia_valid & ATTR_ATIME_SET) {
*p++ = xdr_two;
p = xdr_encode_nfstime3(p, &attr->ia_atime);
} else if (attr->ia_valid & ATTR_ATIME) {
*p++ = xdr_one;
} else
*p++ = xdr_zero;

if (attr->ia_valid & ATTR_MTIME_SET) {
*p++ = xdr_two;
xdr_encode_nfstime3(p, &attr->ia_mtime);
} else if (attr->ia_valid & ATTR_MTIME) {
*p = xdr_one;
} else
*p = xdr_zero;
}

/*
Expand Down Expand Up @@ -605,7 +604,7 @@ static void encode_sattrguard3(struct xdr_stream *xdr,
if (args->guard) {
p = xdr_reserve_space(xdr, 4 + 8);
*p++ = xdr_one;
xdr_encode_time3(p, &args->guardtime);
xdr_encode_nfstime3(p, &args->guardtime);
} else {
p = xdr_reserve_space(xdr, 4);
*p = xdr_zero;
Expand Down

0 comments on commit bdc0ec6

Please sign in to comment.