From 70a0e44cc77a7d8fc78c5514889bcd5d4fde3599 Mon Sep 17 00:00:00 2001 From: hjl Date: Thu, 1 Jun 2000 00:57:09 +0000 Subject: 2000-05-31 H.J. Lu * 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". --- support/export/rmtab.c | 6 +++--- support/include/nfslib.h | 9 +++++---- support/nfs/rmtab.c | 41 ++++++++++++++++++++++++++--------------- 3 files changed, 34 insertions(+), 22 deletions(-) (limited to 'support') diff --git a/support/export/rmtab.c b/support/export/rmtab.c index 4d0bc02..4e141c3 100644 --- a/support/export/rmtab.c +++ b/support/export/rmtab.c @@ -24,7 +24,7 @@ rmtab_read(void) 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; @@ -65,8 +65,8 @@ rmtab_read(void) 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", diff --git a/support/include/nfslib.h b/support/include/nfslib.h index b5c7237..8736d49 100644 --- a/support/include/nfslib.h +++ b/support/include/nfslib.h @@ -77,6 +77,7 @@ struct exportent { 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); -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); -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); diff --git a/support/nfs/rmtab.c b/support/nfs/rmtab.c index b9b5ff1..da40e48 100644 --- a/support/nfs/rmtab.c +++ b/support/nfs/rmtab.c @@ -45,52 +45,63 @@ fsetrmtabent(char *fname, char *type) } struct rmtabent * -getrmtabent(int log) +getrmtabent(int log, long *pos) { - return fgetrmtabent(rmfp, log); + return fgetrmtabent(rmfp, log, pos); } struct rmtabent * -fgetrmtabent(FILE *fp, int log) +fgetrmtabent(FILE *fp, int log, long *pos) { static struct rmtabent re; - char buf[2048], *sp; + char buf[2048], *count, *host, *path; errno = 0; if (!fp) return NULL; do { + if (pos) + *pos = ftell (fp); 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; } - *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); - 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'; - 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 -putrmtabent(struct rmtabent *rep) +putrmtabent(struct rmtabent *rep, long *pos) { - fputrmtabent(rmfp, rep); + fputrmtabent(rmfp, rep, pos); } 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; - 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 -- cgit