X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Fnfs%2Fcacheio.c;h=55fa45d7e620c458917d0015c3af19fbf39bc452;hp=6a6ed5ac7f093a590e621895a03f2c9e3729683e;hb=e8a54a3d5e32c9de009f84d1ef3f26d2dffbf226;hpb=70561910500556c8109ca2e5683a92ed51c82bb7 diff --git a/support/nfs/cacheio.c b/support/nfs/cacheio.c index 6a6ed5a..55fa45d 100644 --- a/support/nfs/cacheio.c +++ b/support/nfs/cacheio.c @@ -148,6 +148,11 @@ void qword_printint(FILE *f, int num) fprintf(f, "%d ", num); } +void qword_printuint(FILE *f, unsigned int num) +{ + fprintf(f, "%u ", num); +} + int qword_eol(FILE *f) { int err; @@ -236,6 +241,20 @@ int qword_get_int(char **bpp, int *anint) return 0; } +int qword_get_uint(char **bpp, unsigned int *anint) +{ + char buf[50]; + char *ep; + unsigned int rv; + int len = qword_get(bpp, buf, 50); + if (len < 0) return -1; + if (len ==0) return -1; + rv = strtoul(buf, &ep, 0); + if (*ep) return -1; + *anint = rv; + return 0; +} + #define READLINE_BUFFER_INCREMENT 2048 int readline(int fd, char **buf, int *lenp) @@ -285,9 +304,8 @@ int readline(int fd, char **buf, int *lenp) int check_new_cache(void) { - struct stat stb; - return (stat("/proc/fs/nfs/filehandle", &stb) == 0) || - (stat("/proc/fs/nfsd/filehandle", &stb) == 0); + return (access("/proc/fs/nfs/filehandle", F_OK) == 0) || + (access("/proc/fs/nfsd/filehandle", F_OK) == 0); }