X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fmountd%2Fcache.c;h=a265ecda9f6412fefa457b79a915f32cfa0506c9;hb=d43405fcaf919152b42de4ae39d001b503a488dc;hp=2e35b17417173914899234d4cfe28f6ff9aa42a4;hpb=18fc7a86a2a1213762cc4107565903127efadafc;p=nfs-utils.git diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c index 2e35b17..a265ecd 100644 --- a/utils/mountd/cache.c +++ b/utils/mountd/cache.c @@ -368,15 +368,19 @@ void cache_export(nfs_export *exp) * { * echo $domain $path $length * read filehandle <&0 - * } <> /proc/fs/nfs/filehandle + * } <> /proc/fs/nfsd/filehandle */ struct nfs_fh_len * cache_get_filehandle(nfs_export *exp, int len, char *p) { - FILE *f = fopen("/proc/fs/nfs/filehandle", "r+"); + FILE *f = fopen("/proc/fs/nfsd/filehandle", "r+"); char buf[200]; char *bp = buf; + int failed; static struct nfs_fh_len fh; + + if (!f) + f = fopen("/proc/fs/nfs/filehandle", "r+"); if (!f) return NULL; @@ -385,7 +389,9 @@ cache_get_filehandle(nfs_export *exp, int len, char *p) qword_printint(f, len); qword_eol(f); - if (fgets(buf, sizeof(buf), f) == NULL) + failed = (fgets(buf, sizeof(buf), f) == NULL); + fclose(f); + if (failed) return NULL; memset(fh.fh_handle, 0, sizeof(fh.fh_handle)); fh.fh_size = qword_get(&bp, fh.fh_handle, NFS3_FHSIZE);