summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 929f095)
raw | patch | inline | side by side (parent: 929f095)
author | niki <niki> | |
Sat, 10 Dec 2005 16:19:49 +0000 (16:19 +0000) | ||
committer | niki <niki> | |
Sat, 10 Dec 2005 16:19:49 +0000 (16:19 +0000) |
it returns a pointer to the last entry now.
src/quota_fs.h | patch | blob | history | |
src/quota_mnt.c | patch | blob | history | |
src/quota_mnt.h | patch | blob | history | |
src/quota_plugin.c | patch | blob | history |
diff --git a/src/quota_fs.h b/src/quota_fs.h
index b6ec038aa3276996d1d808b7dae55f3b45c1e8b5..b689ae842229b914e6503c14bb0713356a45c21c 100644 (file)
--- a/src/quota_fs.h
+++ b/src/quota_fs.h
RETURN VALUE
The quota_fs_getquota() function returns a pointer to
- the last entry of the list, or NULL if an error occurs.
+ the last entry of the list, or NULL if an error occued.
NOTES
- In case of an error, quota is not modified.
+ In case of an error, *quota is not modified.
*/
quota_t *quota_fs_getquota(quota_t **quota, quota_mnt_t *m);
diff --git a/src/quota_mnt.c b/src/quota_mnt.c
index 921c589862a631658899482744e2854485d04c08..50b0f4ff9429166b7ed8b4b3bdda614403446789 100644 (file)
--- a/src/quota_mnt.c
+++ b/src/quota_mnt.c
} /* char *quota_mnt_getmountopt(char *line, char *keyword) */
#if HAVE_GETMNTENT
-static void
+static quota_mnt_t *
quota_mnt_getmntent(FILE *mntf, quota_mnt_t **list)
{
+ quota_mnt_t *last = *list;
struct mntent *mnt;
+#if HAVE_GETMNTENT1
while((mnt = getmntent(mntf)) != NULL) {
+#endif /* HAVE_GETMNTENT1 */
char *loop = NULL, *device = NULL;
char *usrjquota = NULL;
char *grpjquota = NULL;
char *jqfmt = NULL;
+ int opts = QMO_NONE;
#if 0
DBG("------------------");
device = loop;
}
+ if(quota_mnt_checkmountopt(mnt->mnt_opts, MNTOPT_QUOTA, 1) != NULL) {
+ opts |= QMO_USRQUOTA;
+ }
+ if(quota_mnt_checkmountopt(mnt->mnt_opts, MNTOPT_USRQUOTA, 1) != NULL) {
+ opts |= QMO_USRQUOTA;
+ }
usrjquota = quota_mnt_getmountopt(mnt->mnt_opts, "usrjquota=");
+ if(usrjquota != NULL) {
+ opts |= QMO_USRQUOTA;
+ }
+ if(quota_mnt_checkmountopt(mnt->mnt_opts, MNTOPT_GRPQUOTA, 1) != NULL) {
+ opts |= QMO_GRPQUOTA;
+ }
grpjquota = quota_mnt_getmountopt(mnt->mnt_opts, "grpjquota=");
+ if(grpjquota != NULL) {
+ opts |= QMO_GRPQUOTA;
+ }
jqfmt = quota_mnt_getmountopt(mnt->mnt_opts, "jqfmt=");
#if HAVE_XFS_XQM_H
}
} else {
#endif /* HAVE_XFS_XQM_H */
- if(quota_mnt_checkmountopt(mnt->mnt_opts, MNTOPT_QUOTA, 1)
- == NULL
- && quota_mnt_checkmountopt(mnt->mnt_opts, MNTOPT_USRQUOTA, 1)
- == NULL
- && quota_mnt_checkmountopt(mnt->mnt_opts, MNTOPT_GRPQUOTA, 1)
- == NULL
- && quota_fs_isnfs(mnt->mnt_type) == EXIT_FAILURE)
+ if((opts == QMO_NONE) && (quota_fs_isnfs(mnt->mnt_type) == EXIT_FAILURE))
{
- DBG("neither quota/usrquota/grpquota option"
- " nor nfs fs (%s) %s (%s): ignored",
+ DBG("neither quota/usrquota/grpquota/usrjquota/grpjquota"
+ " option nor nfs fs (%s) %s (%s): ignored",
mnt->mnt_type, mnt->mnt_dir, mnt->mnt_fsname);
sfree(loop);
sfree(usrjquota);
#if 0
DBG("------------------ OK");
#endif
- *list = (quota_mnt_t *)smalloc(sizeof(quota_mnt_t));
- (*list)->dir = sstrdup(mnt->mnt_dir);
- (*list)->device = device;
- (*list)->usrjquota = usrjquota;
- (*list)->grpjquota = grpjquota;
- (*list)->jqfmt = jqfmt;
- (*list)->type = sstrdup(mnt->mnt_type);
- (*list)->opts = QMO_NONE;
-/* TODO: this is not sufficient for XFS! */
-/* TODO: maybe we should anyway NOT rely on the option in the mountfile...
- ... maybe the fs should be asked direktly all time! */
- if(quota_mnt_checkmountopt(mnt->mnt_opts, MNTOPT_QUOTA, 1) != NULL
- || quota_mnt_checkmountopt(mnt->mnt_opts, MNTOPT_USRQUOTA, 1) != NULL) {
- (*list)->opts |= QMO_USRQUOTA;
- }
- if(quota_mnt_checkmountopt(mnt->mnt_opts, MNTOPT_GRPQUOTA, 1) != NULL) {
- (*list)->opts |= QMO_GRPQUOTA;
+ if(*list == NULL) {
+ *list = (quota_mnt_t *)smalloc(sizeof(quota_mnt_t));
+ last = *list;
+ } else {
+ last->next = (quota_mnt_t *)smalloc(sizeof(quota_mnt_t));
+ last = last->next;
}
- (*list)->next = NULL;
- list = &((*list)->next);
+ last->dir = sstrdup(mnt->mnt_dir);
+ last->device = device;
+ last->type = sstrdup(mnt->mnt_type);
+ last->options = sstrdup(mnt->mnt_opts);
+ last->usrjquota = usrjquota;
+ last->grpjquota = grpjquota;
+ last->jqfmt = jqfmt;
+ last->opts = opts;
+ last->next = NULL;
} /* while((mnt = getmntent(mntf)) != NULL) */
-}
+
+ return last;
+} /* static quota_mnt_t *quota_mnt_getmntent(FILE *mntf, quota_mnt_t **list) */
#endif /* HAVE_GETMNTENT */
quota_mnt_t *
quota_mnt_getlist(quota_mnt_t **list)
{
+ quota_mnt_t *last = NULL;
+
/* yes, i know that the indentation is wrong.
but show me a better way to do this... */
/* see lib/mountlist.c of coreutils for all
#endif
/* give up */
DBG("failed get local mountpoints");
- *list = NULL;
return(NULL);
#if HAVE_LISTMNTENT
- } else { quota_mnt_listmntent(mntlist, list); }
+ } else { last = quota_mnt_listmntent(mntlist, list); }
freemntlist(mntlist);
}
#endif
#if HAVE_GETVFSENT && defined(VFSTAB)
- } else { quota_mnt_getvfsmnt(mntf, list); }
+ } else { last = quota_mnt_getvfsmnt(mntf, list); }
(void)fclose(mntf);
}
#endif
#if HAVE_GETMNTENT && defined(_PATH_MNTTAB)
- } else { quota_mnt_getmntent(mntf, list); }
+ } else { last = quota_mnt_getmntent(mntf, list); }
(void)endmntent(mntf);
}
#endif
#if HAVE_GETMNTENT && defined(MNTTABNAME)
- } else { quota_mnt_getmntent(mntf, list); }
+ } else { last = quota_mnt_getmntent(mntf, list); }
(void)endmntent(mntf);
}
#endif
#if HAVE_GETMNTENT && defined(MNT_MNTTAB)
- } else { quota_mnt_getmntent(mntf, list); }
+ } else { last = quota_mnt_getmntent(mntf, list); }
(void)endmntent(mntf);
}
#endif
#if HAVE_GETMNTENT && defined(_PATH_MOUNTED)
- } else { quota_mnt_getmntent(mntf, list); }
+ } else { last = quota_mnt_getmntent(mntf, list); }
(void)endmntent(mntf);
}
#endif
- return(*list);
-}
+ return(last);
+} /* quota_mnt_t *quota_mnt_getlist(quota_mnt_t **list) */
void
quota_mnt_freelist(quota_mnt_t *list)
sfree(l->dir);
sfree(l->device);
sfree(l->type);
+ sfree(l->options);
sfree(l->usrjquota);
sfree(l->grpjquota);
sfree(l->jqfmt);
diff --git a/src/quota_mnt.h b/src/quota_mnt.h
index 7b56bf1cae34ed8bb02b64e6ac5a977fbdcb126d..36484f8fc3bf732f11c04b69c0dfc6115c6ecdff 100644 (file)
--- a/src/quota_mnt.h
+++ b/src/quota_mnt.h
struct _quota_mnt_t {
char *dir; /* "/sys" or "/" */
char *device; /* "none" or "/dev/hda1" */
- char *type; /* "sysfs" or "ext3"*/
- char *usrjquota;
- char *grpjquota;
- char *jqfmt;
+ char *type; /* "sysfs" or "ext3" */
+ char *options; /* "rw,noatime,commit=600,quota,grpquota" */
+ char *usrjquota; /* "q.u" */
+ char *grpjquota; /* "q.g" */
+ char *jqfmt; /* "TODO" */
int opts;
quota_mnt_t *next;
};
char *quota_mnt_getmountopt(char *line, char *keyword);
char *quota_mnt_checkmountopt(char *line, char *keyword, int full);
+/*
+ DESCRIPTION
+ The quota_mnt_getlist() function creates a list
+ of all mountpoints.
+
+ If *list is NULL, a new list is created and *list is
+ set to point to the first entry.
+
+ If *list is set, the list is appended and *list is
+ not changed.
+
+ RETURN VALUE
+ The quota_mnt_getlist() function returns a pointer to
+ the last entry of the list, or NULL if an error occured.
+
+ NOTES
+ In case of an error, *list is not modified.
+*/
quota_mnt_t *quota_mnt_getlist(quota_mnt_t **list);
void quota_mnt_freelist(quota_mnt_t *list);
diff --git a/src/quota_plugin.c b/src/quota_plugin.c
index 153779667d7fe7977a2624968e7f4b19831f386a..d2d629ab8c355b3b65c46a9340f60c7712ad7a8c 100644 (file)
--- a/src/quota_plugin.c
+++ b/src/quota_plugin.c
quota_mnt_t *list = NULL, *l = NULL;
quota_t *quota = NULL, *q = NULL;
- l = quota_mnt_getlist(&list);
+ (void)quota_mnt_getlist(&list);
+ l = list;
DBG("local mountpoints:");
while(l != NULL) {
DBG("\tdir: %s", l->dir);
DBG("\tdevice: %s", l->device);
DBG("\ttype: %s", l->type);
+ DBG("\toptions: %s", l->options);
DBG("\tusrjquota: %s", l->usrjquota);
DBG("\tgrpjquota: %s", l->grpjquota);
DBG("\tjqfmt: %s", l->jqfmt);
}
DBG("\t== ");
- q = quota_fs_getquota("a, list);
+ (void)quota_fs_getquota("a, list);
+ q = quota;
#if 0
DBG("quotas:");
#endif