diff options
Diffstat (limited to 'nfs')
-rw-r--r-- | nfs/nfs.c | 46 | ||||
-rw-r--r-- | nfs/ops.c | 15 |
2 files changed, 40 insertions, 21 deletions
@@ -273,10 +273,26 @@ xdr_encode_sattr_times (int *p, struct timespec *atime, struct timespec *mtime) *(p++) = -1; /* uid */ *(p++) = -1; /* gid */ *(p++) = -1; /* size */ - *(p++) = htonl (atime->tv_sec); - *(p++) = htonl (atime->tv_nsec / 1000); - *(p++) = htonl (mtime->tv_sec); - *(p++) = htonl (mtime->tv_nsec / 1000); + if (atime) + { + *(p++) = htonl (atime->tv_sec); + *(p++) = htonl (atime->tv_nsec / 1000); + } + else + { + *(p++) = -1; /* no atime */ + *(p++) = -1; + } + if (mtime) + { + *(p++) = htonl (mtime->tv_sec); + *(p++) = htonl (mtime->tv_nsec / 1000); + } + else + { + *(p++) = -1; /* no mtime */ + *(p++) = -1; + } } else { @@ -284,12 +300,22 @@ xdr_encode_sattr_times (int *p, struct timespec *atime, struct timespec *mtime) *(p++) = 0; /* no uid */ *(p++) = 0; /* no gid */ *(p++) = 0; /* no size */ - *(p++) = htonl (SET_TO_CLIENT_TIME); /* atime */ - *(p++) = htonl (atime->tv_sec); - *(p++) = htonl (atime->tv_nsec); - *(p++) = htonl (SET_TO_CLIENT_TIME); /* mtime */ - *(p++) = htonl (mtime->tv_sec); - *(p++) = htonl (mtime->tv_nsec); + if (atime) + { + *(p++) = htonl (SET_TO_CLIENT_TIME); /* atime */ + *(p++) = htonl (atime->tv_sec); + *(p++) = htonl (atime->tv_nsec); + } + else + *(p++) = DONT_CHANGE; /* no atime */ + if (mtime) + { + *(p++) = htonl (SET_TO_CLIENT_TIME); /* mtime */ + *(p++) = htonl (mtime->tv_sec); + *(p++) = htonl (mtime->tv_nsec); + } + else + *(p++) = DONT_CHANGE; /* no mtime */ } return p; } @@ -297,17 +297,12 @@ netfs_attempt_utimes (struct iouser *cred, struct node *np, int *p; void *rpcbuf; error_t err; - struct timeval tv; - struct timespec current; + + if (!atime && !mtime) + return 0; /* nothing to update */ /* XXX For version 3 we can actually do this right, but we don't just yet. */ - if (!atime || !mtime) - { - maptime_read (mapped_time, &tv); - current.tv_sec = tv.tv_sec; - current.tv_nsec = tv.tv_usec * 1000; - } p = nfs_initialize_rpc (NFSPROC_SETATTR (protocol_version), cred, 0, &rpcbuf, np, -1); @@ -315,9 +310,7 @@ netfs_attempt_utimes (struct iouser *cred, struct node *np, return errno; p = xdr_encode_fhandle (p, &np->nn->handle); - p = xdr_encode_sattr_times (p, - atime ?: ¤t, - mtime ?: ¤t); + p = xdr_encode_sattr_times (p, atime, mtime); if (protocol_version == 3) *(p++) = 0; /* guard check == 0 */ |