]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
2000-05-31 H.J. Lu <hjl@lucon.org>
authorhjl <hjl>
Thu, 1 Jun 2000 00:57:09 +0000 (00:57 +0000)
committerhjl <hjl>
Thu, 1 Jun 2000 00:57:09 +0000 (00:57 +0000)
* configure.in (VERSION): Set to "0.1.7.5".
* configure: Regenerated.
* nfs-utils.spec: Updated.

* support/include/nfslib.h (exportent): Add a new field,
r_count, to count the number of mounts from a client.
(getrmtabent): Take a new argument for position in file.
(putrmtabent): Likewise.
(fgetrmtabent): Likewise.
(fputrmtabent): Likewise.
* support/nfs/rmtab.c (getrmtabent): Handle the new argument
for position in file.
(fgetrmtabent): Likewise.
(putrmtabent): Likewise.
(fputrmtabent): Likewise.

* support/nfs/rmtab.c (fgetrmtabent): Get value for the new
field, r_count.

* support/export/rmtab.c (rmtab_read): Pass NULL as the new
argument to getrmtabent (), fgetrmtabent (), putrmtabent ()
and fputrmtabent ().
* utils/mountd/rmtab.c (mountlist_add): Likewise.
(mountlist_del): Likewise.
(mountlist_del_all): Likewise.
(mountlist_list): Likewise.

* utils/mountd/rmtab.c (mountlist_add): Increment "r_count"
for the existing entry and initialize "r_count" to 1.
(mountlist_del): Decrement "r_count".

ChangeLog
configure
configure.in
nfs-utils.spec
support/export/rmtab.c
support/include/nfslib.h
support/nfs/rmtab.c
utils/mountd/rmtab.c

index fdd8e64b620ce304aefa41c3f4221f8db2c68eb5..21a263f01b4e04bd4e49123c90d8732ea67dadbc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2000-05-31  H.J. Lu <hjl@lucon.org>
+
+       * configure.in (VERSION): Set to "0.1.7.5".
+       * configure: Regenerated.
+       * nfs-utils.spec: Updated.
+
+       * support/include/nfslib.h (exportent): Add a new field,
+       r_count, to count the number of mounts from a client.
+       (getrmtabent): Take a new argument for position in file.
+       (putrmtabent): Likewise.
+       (fgetrmtabent): Likewise.
+       (fputrmtabent): Likewise.
+       * support/nfs/rmtab.c (getrmtabent): Handle the new argument
+       for position in file.
+       (fgetrmtabent): Likewise.
+       (putrmtabent): Likewise.
+       (fputrmtabent): Likewise.
+
+       * support/nfs/rmtab.c (fgetrmtabent): Get value for the new
+       field, r_count.
+
+       * support/export/rmtab.c (rmtab_read): Pass NULL as the new
+       argument to getrmtabent (), fgetrmtabent (), putrmtabent ()
+       and fputrmtabent ().
+       * utils/mountd/rmtab.c (mountlist_add): Likewise.
+       (mountlist_del): Likewise.
+       (mountlist_del_all): Likewise.
+       (mountlist_list): Likewise.
+
+       * utils/mountd/rmtab.c (mountlist_add): Increment "r_count"
+       for the existing entry and initialize "r_count" to 1.
+       (mountlist_del): Decrement "r_count".
+
 2000-05-18  H.J. Lu <hjl@lucon.org>
 
        * configure.in (VERSION): Set to "0.1.7.4".
 2000-05-18  H.J. Lu <hjl@lucon.org>
 
        * configure.in (VERSION): Set to "0.1.7.4".
index bc5685f772f233ee497e30a1687444ec2e2a5371..3458c308e74d23ba26b31aa70b765043fe41d1b7 100755 (executable)
--- a/configure
+++ b/configure
@@ -544,7 +544,7 @@ fi
 
 
 # The nfs-utils version
 
 
 # The nfs-utils version
-VERSION="0.1.7.4"
+VERSION="0.1.7.5"
 
 
 # Check whether --with-statedir or --without-statedir was given.
 
 
 # Check whether --with-statedir or --without-statedir was given.
index 637f2c5ffedc2c39ed76829aeb0e346f353f633f..0a5e4ebb91829b63c68a621ad5c0dd4b5424db7d 100644 (file)
@@ -4,7 +4,7 @@ AC_INIT(rules.mk)
 AC_PREFIX_DEFAULT(/usr)
 
 # The nfs-utils version
 AC_PREFIX_DEFAULT(/usr)
 
 # The nfs-utils version
-VERSION="0.1.7.4"
+VERSION="0.1.7.5"
 AC_SUBST(VERSION)
 
 dnl *************************************************************
 AC_SUBST(VERSION)
 
 dnl *************************************************************
index fd2543eb80e3a9d26ad0153ce4350a501b14cbbf..d28137d8a549430538de8e93471fe74a03187e8b 100644 (file)
@@ -1,6 +1,6 @@
 Summary: NFS utlilities and supporting daemons for the kernel NFS server.
 Name: nfs-utils
 Summary: NFS utlilities and supporting daemons for the kernel NFS server.
 Name: nfs-utils
-Version: 0.1.7.4
+Version: 0.1.7.5
 Release: 1
 Source0: ftp://nfs.sourceforge.net/pub/nfs/%{name}-%{version}.tar.gz
 Group: System Environment/Daemons
 Release: 1
 Source0: ftp://nfs.sourceforge.net/pub/nfs/%{name}-%{version}.tar.gz
 Group: System Environment/Daemons
index 4d0bc028e8dd0aa55ee863fe3eb6e99f55291331..4e141c3516a34efc6c0a47adc16810939b0cf3ae 100644 (file)
@@ -24,7 +24,7 @@ rmtab_read(void)
        nfs_export              *exp;
 
        setrmtabent("r");
        nfs_export              *exp;
 
        setrmtabent("r");
-       while ((rep = getrmtabent(1)) != NULL) {
+       while ((rep = getrmtabent(1, NULL)) != NULL) {
                struct exportent        *xp;
                struct hostent          *hp = NULL;
                int                     htype;
                struct exportent        *xp;
                struct hostent          *hp = NULL;
                int                     htype;
@@ -65,8 +65,8 @@ rmtab_read(void)
                        xfunlock(lockid);
                        return -1;
                }
                        xfunlock(lockid);
                        return -1;
                }
-               while ((rep = getrmtabent(0)) != NULL) {
-                       fputrmtabent(fp, rep);
+               while ((rep = getrmtabent(0, NULL)) != NULL) {
+                       fputrmtabent(fp, rep, NULL);
                }
                if (rename(_PATH_RMTABTMP, _PATH_RMTAB) < 0) {
                        xlog(L_ERROR, "couldn't rename %s to %s",
                }
                if (rename(_PATH_RMTABTMP, _PATH_RMTAB) < 0) {
                        xlog(L_ERROR, "couldn't rename %s to %s",
index b5c72372af793080221ed3fed158ab33965e9eff..8736d49da9fbd89dd13c3bc0272bd6becaa2bc58 100644 (file)
@@ -77,6 +77,7 @@ struct exportent {
 struct rmtabent {
        char            r_client[NFSCLNT_IDMAX+1];
        char            r_path[NFS_MAXPATHLEN+1];
 struct rmtabent {
        char            r_client[NFSCLNT_IDMAX+1];
        char            r_path[NFS_MAXPATHLEN+1];
+       int             r_count;
 };
 
 /*
 };
 
 /*
@@ -92,13 +93,13 @@ void                        dupexportent(struct exportent *dst,
 int                    updateexportent(struct exportent *eep, char *options);
 
 int                    setrmtabent(char *type);
 int                    updateexportent(struct exportent *eep, char *options);
 
 int                    setrmtabent(char *type);
-struct rmtabent *      getrmtabent(int log);
-void                   putrmtabent(struct rmtabent *xep);
+struct rmtabent *      getrmtabent(int log, long *pos);
+void                   putrmtabent(struct rmtabent *xep, long *pos);
 void                   endrmtabent(void);
 void                   rewindrmtabent(void);
 FILE *                 fsetrmtabent(char *fname, char *type);
 void                   endrmtabent(void);
 void                   rewindrmtabent(void);
 FILE *                 fsetrmtabent(char *fname, char *type);
-struct rmtabent *      fgetrmtabent(FILE *fp, int log);
-void                   fputrmtabent(FILE *fp, struct rmtabent *xep);
+struct rmtabent *      fgetrmtabent(FILE *fp, int log, long *pos);
+void                   fputrmtabent(FILE *fp, struct rmtabent *xep, long *pos);
 void                   fendrmtabent(FILE *fp);
 void                   frewindrmtabent(FILE *fp);
 
 void                   fendrmtabent(FILE *fp);
 void                   frewindrmtabent(FILE *fp);
 
index b9b5ff1c6ae55f1f6e083309f0706acc127757a2..da40e486a052e45de082bf8dd654cbefd2e6bcc1 100644 (file)
@@ -45,52 +45,63 @@ fsetrmtabent(char *fname, char *type)
 }
 
 struct rmtabent *
 }
 
 struct rmtabent *
-getrmtabent(int log)
+getrmtabent(int log, long *pos)
 {
 {
-       return fgetrmtabent(rmfp, log);
+       return fgetrmtabent(rmfp, log, pos);
 }
 
 struct rmtabent *
 }
 
 struct rmtabent *
-fgetrmtabent(FILE *fp, int log)
+fgetrmtabent(FILE *fp, int log, long *pos)
 {
        static struct rmtabent  re;
 {
        static struct rmtabent  re;
-       char    buf[2048], *sp;
+       char    buf[2048], *count, *host, *path;
 
        errno = 0;
        if (!fp)
                return NULL;
        do {
 
        errno = 0;
        if (!fp)
                return NULL;
        do {
+               if (pos)
+                       *pos = ftell (fp);
                if (fgets(buf, sizeof(buf)-1, fp) == NULL)
                        return NULL;
                if (fgets(buf, sizeof(buf)-1, fp) == NULL)
                        return NULL;
-               if ((sp = strchr(buf, '\n')) != NULL)
-                       *sp = '\0';
-               if (!(sp = strchr(buf, ':'))) {
+               host = buf;
+               if ((path = strchr(host, '\n')) != NULL)
+                       *path = '\0';
+               if (!(path = strchr(host, ':'))) {
                        if (log)
                                xlog(L_ERROR, "malformed entry in rmtab file");
                        errno = EINVAL;
                        return NULL;
                }
                        if (log)
                                xlog(L_ERROR, "malformed entry in rmtab file");
                        errno = EINVAL;
                        return NULL;
                }
-               *sp++ = '\0';
+               *path++ = '\0';
+               count = strchr(path, ':');
+               if (count) {
+                       *count++ = '\0';
+                       re.r_count = strtol (count, NULL, 0);
+               }
+               else
+                       re.r_count = 1;
        } while (0);
        } while (0);
-       strncpy(re.r_client, buf, sizeof (re.r_client) - 1);
+       strncpy(re.r_client, host, sizeof (re.r_client) - 1);
        re.r_client[sizeof (re.r_client) - 1] = '\0';
        re.r_client[sizeof (re.r_client) - 1] = '\0';
-       strncpy(re.r_path, sp, sizeof (re.r_path) - 1);
+       strncpy(re.r_path, path, sizeof (re.r_path) - 1);
        re.r_path[sizeof (re.r_path) - 1] = '\0';
        return &re;
 }
 
 void
        re.r_path[sizeof (re.r_path) - 1] = '\0';
        return &re;
 }
 
 void
-putrmtabent(struct rmtabent *rep)
+putrmtabent(struct rmtabent *rep, long *pos)
 {
 {
-       fputrmtabent(rmfp, rep);
+       fputrmtabent(rmfp, rep, pos);
 }
 
 void
 }
 
 void
-fputrmtabent(FILE *fp, struct rmtabent *rep)
+fputrmtabent(FILE *fp, struct rmtabent *rep, long *pos)
 {
 {
-       if (!fp)
+       if (!fp || (pos && fseek (fp, *pos, SEEK_SET) != 0))
                return;
                return;
-       fprintf(fp, "%s:%s\n", rep->r_client, rep->r_path);
+       fprintf(fp, "%s:%s:0x%.8x\n", rep->r_client, rep->r_path,
+               rep->r_count);
 }
 
 void
 }
 
 void
index 289a42e2b95fe0a0089ea71b7c65a0e010e60637..170d8594e4371f7373f50b7ba78cfd6d620d3a8e 100644 (file)
@@ -24,14 +24,17 @@ mountlist_add(nfs_export *exp, const char *path)
        struct rmtabent xe;
        struct rmtabent *rep;
        int             lockid;
        struct rmtabent xe;
        struct rmtabent *rep;
        int             lockid;
+       long            pos;
 
        if ((lockid = xflock(_PATH_RMTAB, "a")) < 0)
                return;
 
        if ((lockid = xflock(_PATH_RMTAB, "a")) < 0)
                return;
-       setrmtabent("r");
-       while ((rep = getrmtabent(1)) != NULL) {
+       setrmtabent("r+");
+       while ((rep = getrmtabent(1, &pos)) != NULL) {
                if (strcmp (rep->r_client,
                            exp->m_client->m_hostname) == 0
                    && strcmp(rep->r_path, path) == 0) {
                if (strcmp (rep->r_client,
                            exp->m_client->m_hostname) == 0
                    && strcmp(rep->r_path, path) == 0) {
+                       rep->r_count++;
+                       putrmtabent(rep, &pos);
                        endrmtabent();
                        xfunlock(lockid);
                        return;
                        endrmtabent();
                        xfunlock(lockid);
                        return;
@@ -43,8 +46,9 @@ mountlist_add(nfs_export *exp, const char *path)
        xe.r_client [sizeof (xe.r_client) - 1] = '\0';
        strncpy(xe.r_path, path, sizeof (xe.r_path) - 1);
        xe.r_path [sizeof (xe.r_path) - 1] = '\0';
        xe.r_client [sizeof (xe.r_client) - 1] = '\0';
        strncpy(xe.r_path, path, sizeof (xe.r_path) - 1);
        xe.r_path [sizeof (xe.r_path) - 1] = '\0';
+       xe.r_count = 1;
        if (setrmtabent("a")) {
        if (setrmtabent("a")) {
-               putrmtabent(&xe);
+               putrmtabent(&xe, NULL);
                endrmtabent();
        }
        xfunlock(lockid);
                endrmtabent();
        }
        xfunlock(lockid);
@@ -57,6 +61,7 @@ mountlist_del(nfs_export *exp, const char *path)
        FILE            *fp;
        char            *hname = exp->m_client->m_hostname;
        int             lockid;
        FILE            *fp;
        char            *hname = exp->m_client->m_hostname;
        int             lockid;
+       int             match;
 
        if ((lockid = xflock(_PATH_RMTAB, "w")) < 0)
                return;
 
        if ((lockid = xflock(_PATH_RMTAB, "w")) < 0)
                return;
@@ -69,10 +74,13 @@ mountlist_del(nfs_export *exp, const char *path)
                xfunlock(lockid);
                return;
        }
                xfunlock(lockid);
                return;
        }
-       while ((rep = getrmtabent(1)) != NULL) {
-               if (strcmp (rep->r_client, hname)
-                   || strcmp(rep->r_path, path))
-                       fputrmtabent(fp, rep);
+       while ((rep = getrmtabent(1, NULL)) != NULL) {
+               match = !strcmp (rep->r_client, hname)
+                       && !strcmp(rep->r_path, path);
+               if (match)
+                       rep->r_count--;
+               if (!match || rep->r_count)
+                       fputrmtabent(fp, rep, NULL);
        }
        if (rename(_PATH_RMTABTMP, _PATH_RMTAB) < 0) {
                xlog(L_ERROR, "couldn't rename %s to %s",
        }
        if (rename(_PATH_RMTABTMP, _PATH_RMTAB) < 0) {
                xlog(L_ERROR, "couldn't rename %s to %s",
@@ -114,13 +122,13 @@ mountlist_del_all(struct sockaddr_in *sin)
                free (hp);
                return;
        }
                free (hp);
                return;
        }
-       while ((rep = getrmtabent(1)) != NULL) {
+       while ((rep = getrmtabent(1, NULL)) != NULL) {
                if (strcmp(rep->r_client, hp->h_name) == 0 &&
                    (exp = auth_authenticate("umountall", sin, rep->r_path))) {
                        export_reset(exp);
                        continue;
                }
                if (strcmp(rep->r_client, hp->h_name) == 0 &&
                    (exp = auth_authenticate("umountall", sin, rep->r_path))) {
                        export_reset(exp);
                        continue;
                }
-               fputrmtabent(fp, rep);
+               fputrmtabent(fp, rep, NULL);
        }
        if (rename(_PATH_RMTABTMP, _PATH_RMTAB) < 0) {
                xlog(L_ERROR, "couldn't rename %s to %s",
        }
        if (rename(_PATH_RMTABTMP, _PATH_RMTAB) < 0) {
                xlog(L_ERROR, "couldn't rename %s to %s",
@@ -158,7 +166,7 @@ mountlist_list(void)
                last_mtime = stb.st_mtime;
 
                setrmtabent("r");
                last_mtime = stb.st_mtime;
 
                setrmtabent("r");
-               while ((rep = getrmtabent(1)) != NULL) {
+               while ((rep = getrmtabent(1, NULL)) != NULL) {
                        m = (mountlist) xmalloc(sizeof(*m));
                        m->ml_hostname = xstrdup(rep->r_client);
                        m->ml_directory = xstrdup(rep->r_path);
                        m = (mountlist) xmalloc(sizeof(*m));
                        m->ml_hostname = xstrdup(rep->r_client);
                        m->ml_directory = xstrdup(rep->r_path);