X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=support%2Fnfs%2Fnfssvc.c;h=ef7d8e1109cbb616a8b37e825f852ad191f2fed4;hb=f9cfe7c8a02ef187e411d5019ee0b6fe266e0cb1;hp=1feffdde3283f57c53bb1ab3f34b8dcd92154fd1;hpb=b0c3cbfee702c019dab0a22557bbf38e24dfcee1;p=nfs-utils.git diff --git a/support/nfs/nfssvc.c b/support/nfs/nfssvc.c index 1feffdd..ef7d8e1 100644 --- a/support/nfs/nfssvc.c +++ b/support/nfs/nfssvc.c @@ -28,11 +28,25 @@ static void nfssvc_setfds(int port, unsigned int ctlbits, char *haddr) { - int fd, on=1; + int fd, n, on=1; char buf[BUFSIZ]; int udpfd = -1, tcpfd = -1; struct sockaddr_in sin; + fd = open(NFSD_PORTS_FILE, O_RDONLY); + if (fd < 0) + return; + n = read(fd, buf, BUFSIZ); + close(fd); + if (n != 0) + return; + /* there are no ports currently open, so it is safe to + * try to open some and pass them through. + * Note: If the user explicitly asked for 'udp', then + * we should probably check if that is open, and should + * open it if not. However we don't yet. All sockets + * have to be opened when the first daemon is started. + */ fd = open(NFSD_PORTS_FILE, O_WRONLY); if (fd < 0) return;