summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2005-01-21 11:03:59 +0000
committerjkar8572 <jkar8572>2005-01-21 11:03:59 +0000
commitcad562c709becac521a3e8ee36088badf70b4c88 (patch)
treeafdae76d5939ebe1a1ef41d717613580ae85f0de
parent5d74052db2404c791e2a7f6213032243b86cbd32 (diff)
downloadlinuxquota-cad562c709becac521a3e8ee36088badf70b4c88.tar.gz
Added dynamic allocation of mountpoint table (Jan Kara)
-rw-r--r--Changelog1
-rw-r--r--quotasys.c23
-rw-r--r--quotasys.h1
3 files changed, 16 insertions, 9 deletions
diff --git a/Changelog b/Changelog
index 9718d47..9bba65d 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,5 @@
Changes in quota-tools from 3.12 to 3.13
+* added dynamic mountpoint array allocation (Jan Kara)
* made quotacheck(8) more friendly for journaled quota (Jan Kara)
* changed configure to detect whether nls is needed (Tomasz Kloczko, Jan Kara)
* added JFS into a set of supported filesystems (David Kleikamp)
diff --git a/quotasys.c b/quotasys.c
index 16bb9fc..c6a6bb6 100644
--- a/quotasys.c
+++ b/quotasys.c
@@ -542,6 +542,8 @@ int get_qf_name(struct mntent *mnt, int type, int fmt, int flags, char **filenam
return -1;
}
+#define START_MNT_POINTS 256 /* The number of mount points we start with... */
+
/*
* Create NULL terminated list of quotafile handles from given list of mountpoints
* List of zero length means scan all entries in /etc/mtab
@@ -551,25 +553,30 @@ struct quota_handle **create_handle_list(int count, char **mntpoints, int type,
{
struct mntent *mnt;
int gotmnt = 0;
- static struct quota_handle *hlist[MAXMNTPOINTS];
+ static int hlist_allocated = 0;
+ static struct quota_handle **hlist = NULL;
+
+ if (!hlist_allocated) {
+ hlist = smalloc(START_MNT_POINTS * sizeof(struct quota_handle *));
+ hlist_allocated = START_MNT_POINTS;
+ }
if (init_mounts_scan(count, mntpoints, mntflags) < 0)
die(2, _("Can't initialize mountpoint scan.\n"));
while ((mnt = get_next_mount())) {
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);
+add_entry:
+ if (gotmnt+1 >= hlist_allocated) {
+ hlist_allocated += START_MNT_POINTS;
+ hlist = srealloc(hlist, hlist_allocated * sizeof(struct quota_handle *));
+ }
if (!(hlist[gotmnt] = init_io(mnt, type, fmt, ioflags)))
continue;
gotmnt++;
}
else if (!(ioflags & IOI_LOCALONLY) && (fmt == -1 || fmt == QF_RPC)) { /* Use NFS? */
#ifdef RPC
- if (gotmnt+1 == MAXMNTPOINTS)
- die(2, _("Too many mountpoints with quota. Contact %s\n"), MY_EMAIL);
- if (!(hlist[gotmnt] = init_io(mnt, type, fmt, ioflags)))
- continue;
- gotmnt++;
+ goto add_entry;
#endif
}
}
diff --git a/quotasys.h b/quotasys.h
index 79ecddc..f9a72f3 100644
--- a/quotasys.h
+++ b/quotasys.h
@@ -14,7 +14,6 @@
#define MAXNAMELEN 64 /* Maximal length of user/group name */
#define MAXTIMELEN 40 /* Maximal length of time string */
#define MAXNUMLEN 32 /* Maximal length of number */
-#define MAXMNTPOINTS 256 /* Maximal number of mountpoints with quota */
/* Flags for formatting time */
#define TF_ROUND 0x1 /* Should be printed time rounded? */