summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2001-05-04 08:43:25 +0000
committerjkar8572 <jkar8572>2001-05-04 08:43:25 +0000
commit3dbd1e5a75e551d93ced9b3f698c29be91261415 (patch)
tree3570e31037e633f723b25e0320d71748ec4ec09c
parent79d6138d6e5764429d0a4e245f143ab62625ce3b (diff)
Fixed infinity loop for XFS repquota.
-rw-r--r--convertquota.c6
-rw-r--r--quotaio.h2
-rw-r--r--quotaio_v1.c11
-rw-r--r--quotaio_v2.c13
-rw-r--r--quotaio_xfs.c15
-rw-r--r--repquota.c6
-rw-r--r--warnquota.c21
7 files changed, 38 insertions, 36 deletions
diff --git a/convertquota.c b/convertquota.c
index 6d3afbf..d9a95bb 100644
--- a/convertquota.c
+++ b/convertquota.c
@@ -72,7 +72,7 @@ void parse_options(int argcnt, char **argstr)
mntpoint = argstr[optind];
}
-int convert_dquot(struct dquot *dquot)
+int convert_dquot(struct dquot *dquot, char *name)
{
struct dquot newdquot;
@@ -88,8 +88,8 @@ int convert_dquot(struct dquot *dquot)
newdquot.dq_dqb.dqb_btime = dquot->dq_dqb.dqb_btime;
newdquot.dq_dqb.dqb_itime = dquot->dq_dqb.dqb_itime;
if (qn->qh_ops->commit_dquot(&newdquot) < 0) {
- errstr(_("Can't commit dquot for id %u: %s\n"),
- (uint)dquot->dq_id, strerror(errno));
+ errstr(_("Can't commit dquot for id %u (%s): %s\n"),
+ (uint)dquot->dq_id, name, strerror(errno));
return -1;
}
return 0;
diff --git a/quotaio.h b/quotaio.h
index acd86c1..79e7ce0 100644
--- a/quotaio.h
+++ b/quotaio.h
@@ -122,7 +122,7 @@ struct quotafile_ops {
int (*write_info) (struct quota_handle * h); /* Write info about quotafile */
struct dquot *(*read_dquot) (struct quota_handle * h, qid_t id); /* Read dquot into memory */
int (*commit_dquot) (struct dquot * dquot); /* Write given dquot to disk */
- int (*scan_dquots) (struct quota_handle * h, int (*process_dquot) (struct dquot * dquot)); /* Scan quotafile and call callback on every structure */
+ int (*scan_dquots) (struct quota_handle * h, int (*process_dquot) (struct dquot * dquot, char * dqname)); /* Scan quotafile and call callback on every structure */
int (*report) (struct quota_handle * h, int verbose); /* Function called after 'repquota' to print format specific file information */
};
diff --git a/quotaio_v1.c b/quotaio_v1.c
index 405479e..92ee19d 100644
--- a/quotaio_v1.c
+++ b/quotaio_v1.c
@@ -34,7 +34,7 @@
#ident "$Copyright: (c) 1980, 1990 Regents of the University of California. $"
#ident "$Copyright: All rights reserved. $"
-#ident "$Id: quotaio_v1.c,v 1.4 2001/05/02 09:32:22 jkar8572 Exp $"
+#ident "$Id: quotaio_v1.c,v 1.5 2001/05/04 08:43:25 jkar8572 Exp $"
#include <unistd.h>
#include <errno.h>
@@ -46,13 +46,14 @@
#include "quotaio_v1.h"
#include "dqblk_v1.h"
#include "quotaio.h"
+#include "quotasys.h"
static int v1_init_io(struct quota_handle *h);
static int v1_new_io(struct quota_handle *h);
static int v1_write_info(struct quota_handle *h);
static struct dquot *v1_read_dquot(struct quota_handle *h, qid_t id);
static int v1_commit_dquot(struct dquot *dquot);
-static int v1_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot * dquot));
+static int v1_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot *dquot, char *dqname));
struct quotafile_ops quotafile_ops_1 = {
init_io: v1_init_io,
@@ -281,9 +282,10 @@ static int v1_commit_dquot(struct dquot *dquot)
/*
* Scan all dquots in file and call callback on each
*/
-static int v1_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot * dquot))
+static int v1_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot *, char *))
{
int rd;
+ char name[MAXNAMELEN];
struct v1_disk_dqblk ddqblk;
struct dquot *dquot = get_empty_dquot();
qid_t id = 0;
@@ -303,7 +305,8 @@ static int v1_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct d
continue;
v1_disk2memdqblk(&dquot->dq_dqb, &ddqblk);
dquot->dq_id = id;
- if ((rd = process_dquot(dquot)) < 0) {
+ id2name(dquot->dq_id, h->qh_type, name);
+ if ((rd = process_dquot(dquot, name)) < 0) {
free(dquot);
return rd;
}
diff --git a/quotaio_v2.c b/quotaio_v2.c
index b8c8f8f..76a3681 100644
--- a/quotaio_v2.c
+++ b/quotaio_v2.c
@@ -17,6 +17,7 @@
#include "quotaio_v2.h"
#include "dqblk_v2.h"
#include "quotaio.h"
+#include "quotasys.h"
typedef char *dqbuf_t;
@@ -25,7 +26,7 @@ static int v2_new_io(struct quota_handle *h);
static int v2_write_info(struct quota_handle *h);
static struct dquot *v2_read_dquot(struct quota_handle *h, qid_t id);
static int v2_commit_dquot(struct dquot *dquot);
-static int v2_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot * dquot));
+static int v2_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot *dquot, char *dqname));
static int v2_report(struct quota_handle *h, int verbose);
struct quotafile_ops quotafile_ops_2 = {
@@ -656,11 +657,12 @@ static int v2_commit_dquot(struct dquot *dquot)
#define get_bit(bmp, ind) ((bmp)[(ind) >> 3] & (1 << ((ind) & 7)))
static int report_block(struct dquot *dquot, uint blk, char *bitmap,
- int (*process_dquot) (struct dquot *))
+ int (*process_dquot) (struct dquot *, char *))
{
dqbuf_t buf = getdqbuf();
struct v2_disk_dqdbheader *dh;
struct v2_disk_dqblk *ddata;
+ char name[MAXNAMELEN];
int entries, i;
set_bit(bitmap, blk);
@@ -672,7 +674,8 @@ static int report_block(struct dquot *dquot, uint blk, char *bitmap,
if (!empty_dquot(ddata + i)) {
v2_disk2memdqblk(&dquot->dq_dqb, ddata + i);
dquot->dq_id = __le32_to_cpu(ddata[i].dqb_id);
- if (process_dquot(dquot) < 0)
+ id2name(dquot->dq_id, dquot->dq_h->qh_type, name);
+ if (process_dquot(dquot, name) < 0)
break;
}
freedqbuf(buf);
@@ -680,7 +683,7 @@ static int report_block(struct dquot *dquot, uint blk, char *bitmap,
}
static int report_tree(struct dquot *dquot, uint blk, int depth, char *bitmap,
- int (*process_dquot) (struct dquot *))
+ int (*process_dquot) (struct dquot *, char *))
{
int entries = 0, i;
dqbuf_t buf = getdqbuf();
@@ -714,7 +717,7 @@ static uint find_set_bits(char *bmp, int blocks)
return used;
}
-static int v2_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot * dquot))
+static int v2_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot *, char *))
{
char *bitmap;
struct v2_mem_dqinfo *info = &h->qh_info.u.v2_mdqi;
diff --git a/quotaio_xfs.c b/quotaio_xfs.c
index 653ce53..9656753 100644
--- a/quotaio_xfs.c
+++ b/quotaio_xfs.c
@@ -28,7 +28,7 @@ static int xfs_init_io(struct quota_handle *h);
static int xfs_write_info(struct quota_handle *h);
static struct dquot *xfs_read_dquot(struct quota_handle *h, qid_t id);
static int xfs_commit_dquot(struct dquot *dquot);
-static int xfs_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot * dquot));
+static int xfs_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot *dquot, char *dqname));
static int xfs_report(struct quota_handle *h, int verbose);
struct quotafile_ops quotafile_ops_xfs = {
@@ -166,7 +166,8 @@ static int xfs_commit_dquot(struct dquot *dquot)
*/
static int xfs_scan_dquot(struct quota_handle *h,
struct xfs_kern_dqblk *d,
- struct dquot *dq, int (*process_dquot) (struct dquot * dquot))
+ char *name, struct dquot *dq,
+ int (*process_dquot) (struct dquot *dquot, char *dqname))
{
int qcmd = QCMD(Q_XFS_GETQUOTA, h->qh_type);
@@ -180,13 +181,13 @@ static int xfs_scan_dquot(struct quota_handle *h,
d->d_ino_hardlimit == 0 &&
d->d_ino_softlimit == 0 && d->d_bcount == 0 && d->d_icount == 0) return 0;
xfs_kern2utildqblk(&dq->dq_dqb, d);
- return process_dquot(dq);
+ return process_dquot(dq, name);
}
/*
* Scan all known dquots and call callback on each
*/
-static int xfs_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot * dquot))
+static int xfs_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot *dquot, char *dqname))
{
struct dquot *dq;
struct xfs_kern_dqblk d;
@@ -203,7 +204,8 @@ static int xfs_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct
setpwent();
while ((usr = getpwent()) != NULL) {
dq->dq_id = usr->pw_uid;
- if ((rd = xfs_scan_dquot(h, &d, dq, process_dquot)) < 0)
+ rd = xfs_scan_dquot(h, &d, usr->pw_name, dq, process_dquot);
+ if (rd < 0)
break;
}
endpwent();
@@ -214,7 +216,8 @@ static int xfs_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct
setgrent();
while ((grp = getgrent()) != NULL) {
dq->dq_id = grp->gr_gid;
- if ((rd = xfs_scan_dquot(h, &d, dq, process_dquot)) < 0)
+ rd = xfs_scan_dquot(h, &d, grp->gr_name, dq, process_dquot);
+ if (rd < 0)
break;
}
endgrent();
diff --git a/repquota.c b/repquota.c
index 0ef7086..c57e377 100644
--- a/repquota.c
+++ b/repquota.c
@@ -29,7 +29,7 @@ char **mnt;
int mntcnt;
char *progname;
-static void usage()
+static void usage(void)
{
errstr(_("Utility for reporting quotas.\nUsage:\n%s [-vug] [-F quotaformat] (-a | mntpoint)\n"), progname);
errstr(_("Bugs to %s\n"), MY_EMAIL);
@@ -97,15 +97,13 @@ static char overlim(uint usage, uint softlim, uint hardlim)
return '-';
}
-static int print(struct dquot *dquot)
+static int print(struct dquot *dquot, char *name)
{
- char name[MAXNAMELEN];
char time[MAXTIMELEN];
struct util_dqblk *entry = &dquot->dq_dqb;
if (!entry->dqb_curspace && !entry->dqb_curinodes && !(flags & FL_VERBOSE))
return 0;
- id2name(dquot->dq_id, dquot->dq_h->qh_type, name);
difftime2str(entry->dqb_btime, time);
printf("%-10s%c%c%8Lu%8Lu%8Lu%7s", name,
overlim(qb2kb(toqb(entry->dqb_curspace)), qb2kb(entry->dqb_bsoftlimit),
diff --git a/warnquota.c b/warnquota.c
index 8c0a4de..dcfdf31 100644
--- a/warnquota.c
+++ b/warnquota.c
@@ -10,7 +10,7 @@
*
* Author: Marco van Wieringen <mvw@planets.elm.net>
*
- * Version: $Id: warnquota.c,v 1.2 2001/05/02 09:32:22 jkar8572 Exp $
+ * Version: $Id: warnquota.c,v 1.3 2001/05/04 08:43:25 jkar8572 Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -25,7 +25,6 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <pwd.h>
#include "mntopt.h"
#include "pot.h"
@@ -92,26 +91,22 @@ quotatable_t *quotatable = (quotatable_t *) NULL;
*/
static struct offenderlist *offenders = (struct offenderlist *)0;
-struct offenderlist *add_offender(int id)
+struct offenderlist *add_offender(int id, char *name)
{
- struct passwd *pwd;
struct offenderlist *offender;
- if ((pwd = getpwuid(id)) == (struct passwd *)0)
- return ((struct offenderlist *)0);
-
offender = (struct offenderlist *)smalloc(sizeof(struct offenderlist));
offender->offender_id = id;
- offender->offender_name = (char *)smalloc(strlen(pwd->pw_name) + 1);
+ offender->offender_name = (char *)smalloc(strlen(name) + 1);
offender->usage = (struct usage *)NULL;
- strcpy(offender->offender_name, pwd->pw_name);
+ strcpy(offender->offender_name, name);
offender->next = offenders;
offenders = offender;
return offender;
}
-void add_offence(struct dquot *dquot)
+void add_offence(struct dquot *dquot, char *name)
{
struct offenderlist *lptr;
struct usage *usage;
@@ -121,7 +116,7 @@ void add_offence(struct dquot *dquot)
break;
if (!lptr)
- if (!(lptr = add_offender(dquot->dq_id)))
+ if (!(lptr = add_offender(dquot->dq_id, name)))
return;
usage = (struct usage *)smalloc(sizeof(struct usage));
@@ -135,13 +130,13 @@ void add_offence(struct dquot *dquot)
lptr->usage = usage;
}
-int check_offence(struct dquot *dquot)
+int check_offence(struct dquot *dquot, char *name)
{
if (
(dquot->dq_dqb.dqb_bsoftlimit
&& toqb(dquot->dq_dqb.dqb_curspace) >= dquot->dq_dqb.dqb_bsoftlimit)
|| (dquot->dq_dqb.dqb_isoftlimit
- && dquot->dq_dqb.dqb_curinodes >= dquot->dq_dqb.dqb_isoftlimit)) add_offence(dquot);
+ && dquot->dq_dqb.dqb_curinodes >= dquot->dq_dqb.dqb_isoftlimit)) add_offence(dquot, name);
return 0;
}