summaryrefslogtreecommitdiffstats
path: root/support/nfs/rmtab.c
diff options
context:
space:
mode:
authorhjl <hjl>2000-06-01 00:57:09 +0000
committerhjl <hjl>2000-06-01 00:57:09 +0000
commit70a0e44cc77a7d8fc78c5514889bcd5d4fde3599 (patch)
treeb00d1063e2c1228d84d74c0aac0c82b7157b4963 /support/nfs/rmtab.c
parent62393e334ac95e4cd61d959a4a2e675cf32f58a7 (diff)
downloadnfs-utils-70a0e44cc77a7d8fc78c5514889bcd5d4fde3599.tar.gz
nfs-utils-70a0e44cc77a7d8fc78c5514889bcd5d4fde3599.tar.xz
nfs-utils-70a0e44cc77a7d8fc78c5514889bcd5d4fde3599.zip
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".
Diffstat (limited to 'support/nfs/rmtab.c')
-rw-r--r--support/nfs/rmtab.c41
1 files changed, 26 insertions, 15 deletions
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