]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
Open channel files O_WRONLY, and improve mountlist support. nfs-utils-1-0-5-post1
authorneilbrown <neilbrown>
Mon, 4 Aug 2003 03:14:23 +0000 (03:14 +0000)
committerneilbrown <neilbrown>
Mon, 4 Aug 2003 03:14:23 +0000 (03:14 +0000)
ChangeLog
support/nfs/nfsexport.c
utils/mountd/cache.c
utils/mountd/mountd.c
utils/mountd/mountd.h
utils/mountd/rmtab.c

index bf1adc1a752e3da001f4243f7eb70c14543fa4b7..9f1d85a162604ef10d5b989f8a928bc707d08f05 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2003-08-04 NeilBrown <neilb@cse.unsw.edu.au>
+       * support/nfs/nfsexport.c: open channel file O_WRONLY when
+       only writing.
+       * utils/mountd/cache.c: maintain mountlist when new_cache is
+       active. Also use O_WRONLY for channel files.
+       * utils/mountd/mountd.h: mountlist_{del,add} now take a host name
+       rather than an nfs_export.
+       * utils/mountd/rmtab.c: ditto.
+       
 2003-07-24  Chip Salzenberg  <chip@pobox.com>
 
        * support/nfs/xlog.c (xlog): Revise buffer-overflow fix to
 2003-07-24  Chip Salzenberg  <chip@pobox.com>
 
        * support/nfs/xlog.c (xlog): Revise buffer-overflow fix to
index 0e8b52b334ba3e69e8bd676c64c7f3d66827e51a..782cc50806a9a5771c4d1084454c273f0e9ee3a4 100644 (file)
@@ -93,7 +93,7 @@ nfsexport(struct nfsctl_export *exp)
 {
        struct nfsctl_arg       arg;
        int fd;
 {
        struct nfsctl_arg       arg;
        int fd;
-       if ((fd=open("/proc/net/rpc/nfsd.fh/channel", O_RDWR))>= 0) {
+       if ((fd=open("/proc/net/rpc/nfsd.fh/channel", O_WRONLY))>= 0) {
                close(fd);
                return exp_unexp(exp, 1);
        }
                close(fd);
                return exp_unexp(exp, 1);
        }
@@ -108,7 +108,7 @@ nfsunexport(struct nfsctl_export *exp)
        struct nfsctl_arg       arg;
 
        int fd;
        struct nfsctl_arg       arg;
 
        int fd;
-       if ((fd=open("/proc/net/rpc/nfsd.fh/channel", O_RDWR))>= 0) {
+       if ((fd=open("/proc/net/rpc/nfsd.fh/channel", O_WRONLY))>= 0) {
                close(fd);
                return exp_unexp(exp, 0);
        }
                close(fd);
                return exp_unexp(exp, 0);
        }
index 3402d12b1e6468ebeaeb51c1fffa3fbc462daba8..2e35b17417173914899234d4cfe28f6ff9aa42a4 100644 (file)
@@ -78,6 +78,9 @@ void auth_unix_ip(FILE *f)
                qword_print(f, *client?client:"DEFAULT");
        qword_eol(f);
 
                qword_print(f, *client?client:"DEFAULT");
        qword_eol(f);
 
+       if (client && strcmp(ipaddr, client))
+               mountlist_add(ipaddr, *client?client:"DEFAULT");
+
        if (client) free(client);
        
 }
        if (client) free(client);
        
 }
@@ -258,6 +261,7 @@ void nfsd_export(FILE *f)
                qword_printint(f, found->m_export.e_anonuid);
                qword_printint(f, found->m_export.e_anongid);
                qword_printint(f, found->m_export.e_fsid);
                qword_printint(f, found->m_export.e_anonuid);
                qword_printint(f, found->m_export.e_anongid);
                qword_printint(f, found->m_export.e_fsid);
+               mountlist_add(dom, path);
        }
        qword_eol(f);
  out:
        }
        qword_eol(f);
  out:
@@ -320,7 +324,7 @@ int cache_process_req(fd_set *readfds)
 void cache_export_ent(char *domain, struct exportent *exp)
 {
 
 void cache_export_ent(char *domain, struct exportent *exp)
 {
 
-       FILE *f = fopen("/proc/net/rpc/nfsd.export/channel", "r+");
+       FILE *f = fopen("/proc/net/rpc/nfsd.export/channel", "w");
        if (!f)
                return;
 
        if (!f)
                return;
 
@@ -334,13 +338,15 @@ void cache_export_ent(char *domain, struct exportent *exp)
        qword_eol(f);
 
        fclose(f);
        qword_eol(f);
 
        fclose(f);
+
+       mountlist_add(domain, exp->e_path);
 }
 
 void cache_export(nfs_export *exp)
 {
        FILE *f;
 
 }
 
 void cache_export(nfs_export *exp)
 {
        FILE *f;
 
-       f = fopen("/proc/net/rpc/auth.unix.ip/channel", "r+");
+       f = fopen("/proc/net/rpc/auth.unix.ip/channel", "w");
        if (!f)
                return;
 
        if (!f)
                return;
 
@@ -352,6 +358,9 @@ void cache_export(nfs_export *exp)
        
        fclose(f);
 
        
        fclose(f);
 
+       if (strcmp(inet_ntoa(exp->m_client->m_addrlist[0]), exp->m_client->m_hostname))
+               mountlist_add(inet_ntoa(exp->m_client->m_addrlist[0]), exp->m_client->m_hostname);
+
        cache_export_ent(exp->m_client->m_hostname, &exp->m_export);
 }
 
        cache_export_ent(exp->m_client->m_hostname, &exp->m_export);
 }
 
index d0d8103583818fe50cd38653655f281449be50ef..6dbd224fc27af0e0422e0972d8ecf3599c415e0c 100644 (file)
@@ -117,8 +117,14 @@ mount_umnt_1_svc(struct svc_req *rqstp, dirpath *argp, void *resp)
        if (!(exp = auth_authenticate("unmount", sin, p))) {
                return 1;
        }
        if (!(exp = auth_authenticate("unmount", sin, p))) {
                return 1;
        }
-       mountlist_del(exp, p);
-       export_reset (exp);
+       if (new_cache) {
+               if (strcmp(inet_ntoa(exp->m_client->m_addrlist[0]), exp->m_client->m_hostname))
+                       mountlist_del(inet_ntoa(exp->m_client->m_addrlist[0]), exp->m_client->m_hostname);
+               mountlist_del(exp->m_client->m_hostname, p);
+       } else {
+               mountlist_del(exp->m_client->m_hostname, p);
+               export_reset (exp);
+       }
        return 1;
 }
 
        return 1;
 }
 
@@ -322,7 +328,7 @@ get_rootfh(struct svc_req *rqstp, dirpath *path, int *error, int v3)
                                                stb.st_dev, stb.st_ino);
                }
                if (fh != NULL) {
                                                stb.st_dev, stb.st_ino);
                }
                if (fh != NULL) {
-                       mountlist_add(exp, p);
+                       mountlist_add(exp->m_client->m_hostname, p);
                        *error = NFS_OK;
                        export_reset (exp);
                        return fh;
                        *error = NFS_OK;
                        export_reset (exp);
                        return fh;
index 9f9bc1fe1aac269faa6deb3ccb72a3cf039d4829..d64c17121006f3f433a38557adf0aa377412a194 100644 (file)
@@ -45,8 +45,8 @@ nfs_export *  auth_authenticate(char *what, struct sockaddr_in *sin,
                                        char *path);
 void           auth_export(nfs_export *exp);
 
                                        char *path);
 void           auth_export(nfs_export *exp);
 
-void           mountlist_add(nfs_export *exp, const char *path);
-void           mountlist_del(nfs_export *exp, const char *path);
+void           mountlist_add(char *host, const char *path);
+void           mountlist_del(char *host, const char *path);
 void           mountlist_del_all(struct sockaddr_in *sin);
 mountlist      mountlist_list(void);
 
 void           mountlist_del_all(struct sockaddr_in *sin);
 mountlist      mountlist_list(void);
 
index 8c4a5a978de904888bf9a5495b52095774fffeac..844de511f48b07d76baac5b0b828b9e5520af33f 100644 (file)
@@ -46,7 +46,7 @@ slink_safe_rename(const char * oldpath, const char * newpath)
 }
 
 void
 }
 
 void
-mountlist_add(nfs_export *exp, const char *path)
+mountlist_add(char *host, const char *path)
 {
        struct rmtabent xe;
        struct rmtabent *rep;
 {
        struct rmtabent xe;
        struct rmtabent *rep;
@@ -58,7 +58,7 @@ mountlist_add(nfs_export *exp, const char *path)
        setrmtabent("r+");
        while ((rep = getrmtabent(1, &pos)) != NULL) {
                if (strcmp (rep->r_client,
        setrmtabent("r+");
        while ((rep = getrmtabent(1, &pos)) != NULL) {
                if (strcmp (rep->r_client,
-                           exp->m_client->m_hostname) == 0
+                           host) == 0
                    && strcmp(rep->r_path, path) == 0) {
                        rep->r_count++;
                        putrmtabent(rep, &pos);
                    && strcmp(rep->r_path, path) == 0) {
                        rep->r_count++;
                        putrmtabent(rep, &pos);
@@ -68,7 +68,7 @@ mountlist_add(nfs_export *exp, const char *path)
                }
        }
        endrmtabent();
                }
        }
        endrmtabent();
-       strncpy(xe.r_client, exp->m_client->m_hostname,
+       strncpy(xe.r_client, host,
                sizeof (xe.r_client) - 1);
        xe.r_client [sizeof (xe.r_client) - 1] = '\0';
        strncpy(xe.r_path, path, sizeof (xe.r_path) - 1);
                sizeof (xe.r_client) - 1);
        xe.r_client [sizeof (xe.r_client) - 1] = '\0';
        strncpy(xe.r_path, path, sizeof (xe.r_path) - 1);
@@ -82,11 +82,10 @@ mountlist_add(nfs_export *exp, const char *path)
 }
 
 void
 }
 
 void
-mountlist_del(nfs_export *exp, const char *path)
+mountlist_del(char *hname, const char *path)
 {
        struct rmtabent *rep;
        FILE            *fp;
 {
        struct rmtabent *rep;
        FILE            *fp;
-       char            *hname = exp->m_client->m_hostname;
        int             lockid;
        int             match;
 
        int             lockid;
        int             match;