#ifndef lint
/*static char sccsid[] = "from: @(#)repquota.c 8.1 (Berkeley) 6/6/93";*/
-static char *rcsid = "$Id: repquota.c,v 1.7 1996/05/04 12:30:21 deraadt Exp $";
+static char *rcsid = "$Id: repquota.c,v 1.8 1996/12/12 20:32:17 deraadt Exp $";
#endif /* not lint */
/*
#include <pwd.h>
#include <grp.h>
#include <stdio.h>
+#include <unistd.h>
#include <string.h>
#include <errno.h>
struct fileusage {
struct fileusage *fu_next;
struct dqblk fu_dqblk;
- u_long fu_id;
+ uid_t fu_id;
char fu_name[1];
/* actually bigger */
};
struct fileusage *fuhead[MAXQUOTAS][FUHASH];
struct fileusage *lookup();
struct fileusage *addid();
-u_long highid[MAXQUOTAS]; /* highest addid()'ed identifier per type */
+uid_t highid[MAXQUOTAS]; /* highest addid()'ed identifier per type */
int vflag; /* verbose */
int aflag; /* all file systems */
+void usage __P((void));
+int repquota __P((struct fstab *, int, char *));
+int hasquota __P((struct fstab *, int, char **));
+int oneof __P((char *, char *[], int));
+
+int
main(argc, argv)
int argc;
char **argv;
if (gflag) {
setgrent();
while ((gr = getgrent()) != 0)
- (void) addid((u_long)gr->gr_gid, GRPQUOTA, gr->gr_name);
+ (void) addid((uid_t)gr->gr_gid, GRPQUOTA, gr->gr_name);
endgrent();
}
if (uflag) {
setpwent();
while ((pw = getpwent()) != 0)
- (void) addid((u_long)pw->pw_uid, USRQUOTA, pw->pw_name);
+ (void) addid(pw->pw_uid, USRQUOTA, pw->pw_name);
endpwent();
}
setfsent();
if ((argnum = oneof(fs->fs_file, argv, argc)) >= 0 ||
(argnum = oneof(fs->fs_spec, argv, argc)) >= 0) {
done |= 1 << argnum;
- if (gflag)
+ if (gflag && hasquota(fs, GRPQUOTA, &qfnp))
errs += repquota(fs, GRPQUOTA, qfnp);
- if (uflag)
+ if (uflag && hasquota(fs, GRPQUOTA, &qfnp))
errs += repquota(fs, USRQUOTA, qfnp);
}
}
exit(errs);
}
+void
usage()
{
fprintf(stderr, "Usage:\n\t%s\n\t%s\n",
exit(1);
}
+int
repquota(fs, type, qfpathname)
register struct fstab *fs;
int type;
{
register struct fileusage *fup;
FILE *qf;
- u_long id;
+ uid_t id;
struct dqblk dqbuf;
char *timeprt();
static struct dqblk zerodqblk;
/*
* Check to see if target appears in list of size cnt.
*/
+int
oneof(target, list, cnt)
register char *target, *list[];
int cnt;
/*
* Check to see if a particular quota is to be enabled.
*/
+int
hasquota(fs, type, qfnamep)
register struct fstab *fs;
int type;
}
strcpy(buf, fs->fs_mntops);
for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) {
- if (cp = index(opt, '='))
+ if ((cp = index(opt, '=')))
*cp++ = '\0';
if (type == USRQUOTA && strcmp(opt, usrname) == 0)
break;
*/
struct fileusage *
lookup(id, type)
- u_long id;
+ uid_t id;
int type;
{
register struct fileusage *fup;
*/
struct fileusage *
addid(id, type, name)
- u_long id;
+ uid_t id;
int type;
char *name;
{
int len;
extern char *calloc();
- if (fup = lookup(id, type))
+ if ((fup = lookup(id, type)))
return (fup);
if (name)
len = strlen(name);
timeprt(seconds)
time_t seconds;
{
- time_t hours, minutes;
+ int hours, minutes;
static char buf[20];
static time_t now;