summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2001-11-26 18:18:25 +0000
committerjkar8572 <jkar8572>2001-11-26 18:18:25 +0000
commit76dd02d322ec1301a5b95524a719cbca42d47ecd (patch)
treee9d454d2ba5cfd1863c4a5dfc9539488de7a8a7c
parentd3cedc2d4ad0e220a3c09e2a58312d306757fb26 (diff)
downloadlinuxquota-76dd02d322ec1301a5b95524a719cbca42d47ecd.tar.gz
Fixed initialization of mountpoint scanning (leading to rpc.rquotad SEGFAULT).
rpc.rquotad now doesn't need mountpoint to get quota.
-rw-r--r--Makefile.in2
-rw-r--r--convertquota.c2
-rw-r--r--quot.c2
-rw-r--r--quotacheck.c4
-rw-r--r--quotaon.c4
-rw-r--r--quotasys.c18
-rw-r--r--quotasys.h4
-rw-r--r--rquota_server.c6
8 files changed, 26 insertions, 16 deletions
diff --git a/Makefile.in b/Makefile.in
index d540373..3b522d4 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -38,6 +38,8 @@ IOOBJS += $(RPCCLNTOBJS)
LIBOBJS = bylabel.o common.o quotasys.o pot.o $(IOOBJS)
LIBOBJS += @LIBMALLOC@
+.PHONY: all clean clobber realclean pot mo inst_mo
+
.%.d: %.c
set -e; $(CC) -MM -MG $(CPPFLAGS) $< | \
sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
diff --git a/convertquota.c b/convertquota.c
index 69a14cf..5106a88 100644
--- a/convertquota.c
+++ b/convertquota.c
@@ -350,7 +350,7 @@ int main(int argc, char **argv)
parse_options(argc, argv);
if (init_mounts_scan(1, &mntpoint) < 0)
return 1;
- if (!(mnt = get_next_mount())) {
+ if (!(mnt = get_next_mount(0))) {
end_mounts_scan();
return 1;
}
diff --git a/quot.c b/quot.c
index 6738e45..4f855f5 100644
--- a/quot.c
+++ b/quot.c
@@ -131,7 +131,7 @@ static void mounttable(void)
int doit = 0;
struct mntent *mntp;
- while ((mntp = get_next_mount())) {
+ while ((mntp = get_next_mount(0))) {
/* Currently, only XFS is implemented... */
if (strcmp(mntp->mnt_type, MNTTYPE_XFS) == 0) {
checkXFS(mntp->mnt_fsname, mntp->mnt_dir);
diff --git a/quotacheck.c b/quotacheck.c
index e1a3bf9..cbf8163 100644
--- a/quotacheck.c
+++ b/quotacheck.c
@@ -8,7 +8,7 @@
* New quota format implementation - Jan Kara <jack@suse.cz> - Sponsored by SuSE CR
*/
-#ident "$Id: quotacheck.c,v 1.23 2001/10/09 07:57:53 jkar8572 Exp $"
+#ident "$Id: quotacheck.c,v 1.24 2001/11/26 18:18:25 jkar8572 Exp $"
#include <dirent.h>
#include <stdio.h>
@@ -832,7 +832,7 @@ static void check_all(void)
if (init_mounts_scan((flags & FL_ALL) ? 0 : 1, &mntpoint) < 0)
die(2, _("Can't initialize mountpoint scan.\n"));
- while ((mnt = get_next_mount())) {
+ while ((mnt = get_next_mount(0))) {
if (flags & FL_ALL && flags & FL_NOROOT && !strcmp(mnt->mnt_dir, "/"))
continue;
if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) || !strcmp(mnt->mnt_type, MNTTYPE_NFS)) {
diff --git a/quotaon.c b/quotaon.c
index f1575b3..20d94ea 100644
--- a/quotaon.c
+++ b/quotaon.c
@@ -34,7 +34,7 @@
#ident "$Copyright: (c) 1980, 1990 Regents of the University of California $"
#ident "$Copyright: All rights reserved. $"
-#ident "$Id: quotaon.c,v 1.8 2001/09/04 16:21:58 jkar8572 Exp $"
+#ident "$Id: quotaon.c,v 1.9 2001/11/26 18:18:25 jkar8572 Exp $"
/*
* Turn quota on/off for a filesystem.
@@ -155,7 +155,7 @@ int main(int argc, char **argv)
if (init_mounts_scan(aflag ? 0 : argc, argv) < 0)
return 1;
- while ((mnt = get_next_mount())) {
+ while ((mnt = get_next_mount(0))) {
if (!strcmp(mnt->mnt_type, MNTTYPE_NFS)) {
if (!aflag)
fprintf(stderr, "%s: Quota can't be turned on on NFS filesystem\n", mnt->mnt_fsname);
diff --git a/quotasys.c b/quotasys.c
index 9fecd53..9f0ccd2 100644
--- a/quotasys.c
+++ b/quotasys.c
@@ -396,7 +396,7 @@ struct quota_handle **create_handle_list(int count, char **mntpoints, int type,
if (init_mounts_scan(count, mntpoints) < 0)
die(2, _("Can't initialize mountpoint scan.\n"));
- while ((mnt = get_next_mount())) {
+ while ((mnt = get_next_mount(0))) {
if (strcmp(mnt->mnt_type, MNTTYPE_NFS)) { /* No NFS? */
if (gotmnt+1 == MAXMNTPOINTS)
die(2, _("Too many mountpoints with quota. Contact %s\n"), MY_EMAIL);
@@ -635,6 +635,7 @@ static int cache_mnt_table(void)
}
}
mnt_entries = smalloc(sizeof(struct mount_entry) * ALLOC_ENTRIES_NUM);
+ mnt_entries_cnt = 0;
allocated += ALLOC_ENTRIES_NUM;
while ((mnt = getmntent(mntf))) {
const char *devname;
@@ -753,7 +754,11 @@ int init_mounts_scan(int dcnt, char **dirs)
{
if (cache_mnt_table() < 0)
return -1;
- return process_dirs(dcnt, dirs);
+ if (process_dirs(dcnt, dirs) < 0) {
+ end_mounts_scan();
+ return -1;
+ }
+ return 0;
}
/* Find next usable mountpoint when scanning all mountpoints */
@@ -776,7 +781,7 @@ static int find_next_entry_all(int *pos)
}
/* Find next usable mountpoint when scanning selected mountpoints */
-static int find_next_entry_sel(int *pos)
+static int find_next_entry_sel(int *pos, int flags)
{
int i;
struct searched_dir *sd;
@@ -787,7 +792,8 @@ restart:
sd = check_dirs + act_checked;
for (i = 0; i < mnt_entries_cnt; i++) {
if (sd->sd_dir) {
- if (sd->sd_dev == mnt_entries[i].me_dev && sd->sd_ino == mnt_entries[i].me_ino)
+ if (sd->sd_dev == mnt_entries[i].me_dev &&
+ (flags & MS_NO_MNTPOINT || sd->sd_ino == mnt_entries[i].me_ino))
break;
}
else
@@ -805,7 +811,7 @@ restart:
/*
* Return next directory from the list
*/
-struct mntent *get_next_mount(void)
+struct mntent *get_next_mount(int flags)
{
static struct mntent mnt;
int mntpos;
@@ -816,7 +822,7 @@ struct mntent *get_next_mount(void)
mnt.mnt_dir = (char *)mnt_entries[mntpos].me_dir;
}
else {
- if (!find_next_entry_sel(&mntpos))
+ if (!find_next_entry_sel(&mntpos, flags))
return NULL;
mnt.mnt_dir = (char *)check_dirs[act_checked].sd_name;
}
diff --git a/quotasys.h b/quotasys.h
index a777453..95d0555 100644
--- a/quotasys.h
+++ b/quotasys.h
@@ -99,8 +99,10 @@ int kern_quota_on(const char *dev, int type, int fmt);
/* Initialize mountpoints scan */
int init_mounts_scan(int dcnt, char **dirs);
+/* Flags for get_next_mount() */
+#define MS_NO_MNTPOINT 0x01 /* Specified directory needn't be mountpoint */
/* Return next mountpoint for scan */
-struct mntent *get_next_mount(void);
+struct mntent *get_next_mount(int flags);
/* Free all structures associated with mountpoints scan */
void end_mounts_scan(void);
diff --git a/rquota_server.c b/rquota_server.c
index 43bd292..59c54f9 100644
--- a/rquota_server.c
+++ b/rquota_server.c
@@ -9,7 +9,7 @@
*
* This part does the lookup of the info.
*
- * Version: $Id: rquota_server.c,v 1.9 2001/09/27 21:34:58 jkar8572 Exp $
+ * Version: $Id: rquota_server.c,v 1.10 2001/11/26 18:18:25 jkar8572 Exp $
*
* Author: Marco van Wieringen <mvw@planets.elm.net>
*
@@ -160,7 +160,7 @@ setquota_rslt *setquotainfo(int flags, caddr_t * argp, struct svc_req *rqstp)
if (init_mounts_scan(1, &pathname) < 0)
goto out;
- if (!(mnt = get_next_mount())) {
+ if (!(mnt = get_next_mount(MS_NO_MNTPOINT))) {
end_mounts_scan();
goto out;
}
@@ -244,7 +244,7 @@ getquota_rslt *getquotainfo(int flags, caddr_t * argp, struct svc_req * rqstp)
if (init_mounts_scan(1, &pathname) < 0)
goto out;
- if (!(mnt = get_next_mount())) {
+ if (!(mnt = get_next_mount(MS_NO_MNTPOINT))) {
end_mounts_scan();
goto out;
}