diff options
author | Jan Kara <jack@suse.cz> | 2012-05-23 10:44:48 +0200 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2012-05-23 10:49:05 +0200 |
commit | 127931f064d95229161b51a7b90bebf9f96ab1f3 (patch) | |
tree | b5ece1107bb083e5239b4f5fe27ed5ee1ae27abe | |
parent | 327138a5930a7ebf419fa06401a2836302188be6 (diff) | |
download | linuxquota-127931f064d95229161b51a7b90bebf9f96ab1f3.tar.gz |
Remove fixed limit on number of autofs mount points
Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r-- | quotasys.c | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -917,7 +917,6 @@ struct searched_dir { }; #define ALLOC_ENTRIES_NUM 16 /* Allocate entries by this number */ -#define AUTOFS_DIR_MAX 64 /* Maximum number of autofs directories */ static int mnt_entries_cnt; /* Number of cached mountpoint entries */ static struct mount_entry *mnt_entries; /* Cached mounted filesystems */ @@ -934,8 +933,8 @@ static int cache_mnt_table(int flags) int allocated = 0, i = 0; dev_t dev = 0; char mntpointbuf[PATH_MAX]; - int autofsdircnt = 0; - char autofsdir[AUTOFS_DIR_MAX][PATH_MAX]; + int autofsdircnt, autofsdir_allocated; + char **autofsdir; #ifdef ALT_MTAB mntf = setmntent(ALT_MTAB, "r"); @@ -951,9 +950,14 @@ static int cache_mnt_table(int flags) return -1; } alloc: + /* Prepare table of mount entries */ mnt_entries = smalloc(sizeof(struct mount_entry) * ALLOC_ENTRIES_NUM); mnt_entries_cnt = 0; allocated += ALLOC_ENTRIES_NUM; + /* Prepare table of autofs mountpoints */ + autofsdir = smalloc(sizeof(char *) * ALLOC_ENTRIES_NUM); + autofsdircnt = 0; + autofsdir_allocated = ALLOC_ENTRIES_NUM; while ((mnt = getmntent(mntf))) { const char *devname; char *opt; @@ -977,9 +981,14 @@ alloc: } if (flags & MS_NO_AUTOFS && !strcmp(mnt->mnt_type, MNTTYPE_AUTOFS)) { /* Autofs dir to remember? */ - if (autofsdircnt == AUTOFS_DIR_MAX) - die(3, "Too many autofs mountpoints. Please contact <jack@suse.cz>\n"); - snprintf(autofsdir[autofsdircnt++], PATH_MAX, "%s/", mnt->mnt_dir); + if (autofsdircnt == autofsdir_allocated) { + autofsdir_allocated += ALLOC_ENTRIES_NUM; + autofsdir = srealloc(autofsdir, autofsdir_allocated * sizeof(char *)); + } + autofsdir[autofsdircnt] = smalloc(strlen(mnt->mnt_dir) + 2); + strcpy(autofsdir[autofsdircnt], mnt->mnt_dir); + strcat(autofsdir[autofsdircnt], "/"); + autofsdircnt++; free((char *)devname); continue; } @@ -1081,6 +1090,9 @@ alloc: } endmntent(mntf); + for (i = 0; i < autofsdircnt; i++) + free(autofsdir[i]); + free(autofsdir); return 0; } |