diff options
author | des <des@FreeBSD.org> | 2008-07-02 15:51:59 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2008-07-02 15:51:59 +0000 |
commit | 34dee8955f391d91a8b5086854e45c2180ed3717 (patch) | |
tree | c88748d4f89996f5936c4807089d632cd5f2286a /usr.sbin | |
parent | 2af52bdb8e74ce2b6e8b81230d001b2cdcbe2e10 (diff) | |
download | FreeBSD-src-34dee8955f391d91a8b5086854e45c2180ed3717.zip FreeBSD-src-34dee8955f391d91a8b5086854e45c2180ed3717.tar.gz |
Drag this code kicking and screaming into the twenty-first century.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/edquota/edquota.c | 89 | ||||
-rw-r--r-- | usr.sbin/quot/quot.c | 126 | ||||
-rw-r--r-- | usr.sbin/quotaon/quotaon.c | 18 | ||||
-rw-r--r-- | usr.sbin/repquota/repquota.c | 42 |
4 files changed, 101 insertions, 174 deletions
diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c index 83de530..f38fa77 100644 --- a/usr.sbin/edquota/edquota.c +++ b/usr.sbin/edquota/edquota.c @@ -98,7 +98,7 @@ int writetimes(struct quotause *, int, int); int writeprivs(struct quotause *, int, char *, int); int -main(int argc, char **argv) +main(int argc, char *argv[]) { struct quotause *qup, *protoprivs, *curprivs; long id, protoid; @@ -245,7 +245,7 @@ main(int argc, char **argv) curprivs->fsname); } } - putprivs(id, quotatype, protoprivs); + putprivs(id, quotatype, protoprivs); } } exit(0); @@ -279,7 +279,7 @@ main(int argc, char **argv) } static void -usage() +usage(void) { fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", "usage: edquota [-u] [-f fspath] [-p username] username ...", @@ -299,9 +299,7 @@ usage() * getinoquota as to the interpretation of quota types. */ int -getentry(name, quotatype) - const char *name; - int quotatype; +getentry(const char *name, int quotatype) { struct passwd *pw; struct group *gr; @@ -331,13 +329,10 @@ getentry(name, quotatype) * Collect the requested quota information. */ struct quotause * -getprivs(id, quotatype, fspath) - register long id; - int quotatype; - char *fspath; +getprivs(long id, int quotatype, char *fspath) { - register struct fstab *fs; - register struct quotause *qup, *quptail; + struct fstab *fs; + struct quotause *qup, *quptail; struct quotause *quphead; int qcmd, qupsize, fd; char *qfpathname; @@ -358,7 +353,7 @@ getprivs(id, quotatype, fspath) if ((qup = (struct quotause *)malloc(qupsize)) == NULL) errx(2, "out of memory"); if (quotactl(fs->fs_file, qcmd, id, &qup->dqblk) != 0) { - if (errno == EOPNOTSUPP && !warned) { + if (errno == EOPNOTSUPP && !warned) { warned++; warnx("warning: quotas are not compiled into this kernel"); sleep(3); @@ -421,12 +416,9 @@ getprivs(id, quotatype, fspath) * Store the requested quota information. */ void -putprivs(id, quotatype, quplist) - long id; - int quotatype; - struct quotause *quplist; +putprivs(long id, int quotatype, struct quotause *quplist) { - register struct quotause *qup; + struct quotause *qup; int qcmd, fd; struct dqblk dqbuf; @@ -463,7 +455,7 @@ putprivs(id, quotatype, quplist) /* * Reset time limit if have a soft limit and were * previously under it, but are now over it - * or if there previously was no soft limit, but + * or if there previously was no soft limit, but * now have one and are over it. */ if (dqbuf.dqb_bsoftlimit && id != 0 && @@ -499,8 +491,7 @@ putprivs(id, quotatype, quplist) * Take a list of priviledges and get it edited. */ int -editit(tmpf) - char *tmpf; +editit(char *tmpf) { long omask; int pid, status; @@ -521,7 +512,7 @@ editit(tmpf) return (0); } if (pid == 0) { - register const char *ed; + const char *ed; sigsetmask(omask); setgid(getgid()); @@ -542,13 +533,9 @@ editit(tmpf) * Convert a quotause list to an ASCII file. */ int -writeprivs(quplist, outfd, name, quotatype) - struct quotause *quplist; - int outfd; - char *name; - int quotatype; +writeprivs(struct quotause *quplist, int outfd, char *name, int quotatype) { - register struct quotause *qup; + struct quotause *qup; FILE *fd; ftruncate(outfd, 0); @@ -576,16 +563,14 @@ writeprivs(quplist, outfd, name, quotatype) * Merge changes to an ASCII file into a quotause list. */ int -readprivs(quplist, inname) - struct quotause *quplist; - char *inname; +readprivs(struct quotause *quplist, char *inname) { - register struct quotause *qup; + struct quotause *qup; FILE *fd; unsigned long bhardlimit, bsoftlimit, curblocks; unsigned long ihardlimit, isoftlimit, curinodes; int cnt; - register char *cp; + char *cp; struct dqblk dqblk; char *fsp, line1[BUFSIZ], line2[BUFSIZ]; @@ -686,12 +671,9 @@ readprivs(quplist, inname) * Convert a quotause list to an ASCII file of grace times. */ int -writetimes(quplist, outfd, quotatype) - struct quotause *quplist; - int outfd; - int quotatype; +writetimes(struct quotause *quplist, int outfd, int quotatype) { - register struct quotause *qup; + struct quotause *qup; FILE *fd; ftruncate(outfd, 0); @@ -715,14 +697,12 @@ writetimes(quplist, outfd, quotatype) * Merge changes of grace times in an ASCII file into a quotause list. */ int -readtimes(quplist, inname) - struct quotause *quplist; - char *inname; +readtimes(struct quotause *quplist, char *inname) { - register struct quotause *qup; + struct quotause *qup; FILE *fd; int cnt; - register char *cp; + char *cp; time_t itime, btime, iseconds, bseconds; long l_itime, l_btime; char *fsp, bunits[10], iunits[10], line1[BUFSIZ]; @@ -788,8 +768,7 @@ readtimes(quplist, inname) * Convert seconds to ASCII times. */ char * -cvtstoa(secs) - time_t secs; +cvtstoa(time_t secs) { static char buf[20]; @@ -811,10 +790,7 @@ cvtstoa(secs) * Convert ASCII input times to seconds. */ int -cvtatos(period, units, seconds) - time_t period; - char *units; - time_t *seconds; +cvtatos(time_t period, char *units, time_t *seconds) { if (bcmp(units, "second", 6) == 0) @@ -837,10 +813,9 @@ cvtatos(period, units, seconds) * Free a list of quotause structures. */ void -freeprivs(quplist) - struct quotause *quplist; +freeprivs(struct quotause *quplist) { - register struct quotause *qup, *nextqup; + struct quotause *qup, *nextqup; for (qup = quplist; qup; qup = nextqup) { nextqup = qup->next; @@ -852,10 +827,9 @@ freeprivs(quplist) * Check whether a string is completely composed of digits. */ int -alldigits(s) - register const char *s; +alldigits(const char *s) { - register int c; + int c; c = *s++; do { @@ -869,10 +843,7 @@ alldigits(s) * Check to see if a particular quota is to be enabled. */ int -hasquota(fs, type, qfnamep) - struct fstab *fs; - int type; - char **qfnamep; +hasquota(struct fstab *fs, int type, char **qfnamep) { char *opt; char *cp; diff --git a/usr.sbin/quot/quot.c b/usr.sbin/quot/quot.c index 84892b0..0d61fbb 100644 --- a/usr.sbin/quot/quot.c +++ b/usr.sbin/quot/quot.c @@ -106,17 +106,14 @@ union dinode { (dp)->dp1.field : (dp)->dp2.field) static union dinode * -get_inode(fd,super,ino) - int fd; - struct fs *super; - ino_t ino; +get_inode(int fd, struct fs *super, ino_t ino) { static caddr_t ipbuf; static struct cg *cgp; static ino_t last; static int cg; struct ufs2_dinode *di2; - + if (fd < 0) { /* flush cache */ if (ipbuf) { free(ipbuf); @@ -128,7 +125,7 @@ get_inode(fd,super,ino) } return 0; } - + if (!ipbuf || ino < last || ino >= last + INOCNT(super)) { if (super->fs_magic == FS_UFS2_MAGIC && (!cgp || cg != ino_to_cg(super, ino))) { @@ -150,7 +147,7 @@ get_inode(fd,super,ino) || read(fd, ipbuf, INOSZ(super)) != (ssize_t)INOSZ(super)) err(1, "read inodes"); } - + if (super->fs_magic == FS_UFS1_MAGIC) return ((union dinode *) &((struct ufs1_dinode *)ipbuf)[ino % INOCNT(super)]); @@ -167,12 +164,10 @@ get_inode(fd,super,ino) #define actualblocks(fs, dp) DIP(fs, dp, di_blocks) #endif -static int virtualblocks(super, dp) - struct fs *super; - union dinode *dp; +static int virtualblocks(struct fs *super, union dinode *dp) { - register off_t nblk, sz; - + off_t nblk, sz; + sz = DIP(super, dp, di_size); #ifdef COMPAT if (lblkno(super,sz) >= NDADDR) { @@ -180,11 +175,11 @@ static int virtualblocks(super, dp) if (sz == nblk) nblk += super->fs_bsize; } - + return sz / 1024; - + #else /* COMPAT */ - + if (lblkno(super,sz) >= NDADDR) { nblk = blkroundup(super,sz); sz = lblkno(super,nblk); @@ -196,20 +191,18 @@ static int virtualblocks(super, dp) } } else nblk = fragroundup(super,sz); - + return nblk / 512; #endif /* COMPAT */ } static int -isfree(super, dp) - struct fs *super; - union dinode *dp; +isfree(struct fs *super, union dinode *dp) { #ifdef COMPAT return (DIP(super, dp, di_mode) & IFMT) == 0; #else /* COMPAT */ - + switch (DIP(super, dp, di_mode) & IFMT) { case IFIFO: case IFLNK: /* should check FASTSYMLINK? */ @@ -240,11 +233,11 @@ static struct user { static int nusers; static void -inituser() +inituser(void) { - register int i; - register struct user *usr; - + int i; + struct user *usr; + if (!nusers) { nusers = 8; if (!(users = @@ -259,12 +252,12 @@ inituser() } static void -usrrehash() +usrrehash(void) { - register int i; - register struct user *usr, *usrn; + int i; + struct user *usr, *usrn; struct user *svusr; - + svusr = users; nusers <<= 1; if (!(users = (struct user *)calloc(nusers,sizeof(struct user)))) @@ -280,19 +273,18 @@ usrrehash() } static struct user * -user(uid) - uid_t uid; +user(uid_t uid) { - register struct user *usr; - register int i; + struct user *usr; + int i; struct passwd *pwd; - + while (1) { for (usr = users + (uid&(nusers - 1)), i = nusers; --i >= 0; usr--) { if (!usr->name) { usr->uid = uid; - + if (!(pwd = getpwuid(uid))) { if ((usr->name = (char *)malloc(7))) sprintf(usr->name,"#%d",uid); @@ -303,9 +295,9 @@ user(uid) } if (!usr->name) errx(1, "allocate users"); - + return usr; - + } else if (usr->uid == uid) return usr; @@ -317,8 +309,7 @@ user(uid) } static int -cmpusers(v1,v2) - const void *v1, *v2; +cmpusers(const void *v1, const void *v2) { const struct user *u1, *u2; u1 = (const struct user *)v1; @@ -331,21 +322,18 @@ cmpusers(v1,v2) cmpusers)) static void -uses(uid,blks,act) - uid_t uid; - daddr_t blks; - time_t act; +uses(uid_t uid, daddr_t blks, time_t act) { static time_t today; - register struct user *usr; - + struct user *usr; + if (!today) time(&today); - + usr = user(uid); usr->count++; usr->space += blks; - + if (today - act > 90L * 24L * 60L * 60L) usr->spc90 += blks; if (today - act > 60L * 24L * 60L * 60L) @@ -367,11 +355,11 @@ struct fsizes { } *fsizes; static void -initfsizes() +initfsizes(void) { - register struct fsizes *fp; - register int i; - + struct fsizes *fp; + int i; + for (fp = fsizes; fp; fp = fp->fsz_next) { for (i = FSZCNT; --i >= 0;) { fp->fsz_count[i] = 0; @@ -381,17 +369,14 @@ initfsizes() } static void -dofsizes(fd, super, name) - int fd; - struct fs *super; - char *name; +dofsizes(int fd, struct fs *super, char *name) { ino_t inode, maxino; union dinode *dp; daddr_t sz, ksz; struct fsizes *fp, **fsp; - register int i; - + int i; + maxino = super->fs_ncg * super->fs_ipg - 1; #ifdef COMPAT if (!(fsizes = (struct fsizes *)malloc(sizeof(struct fsizes)))) @@ -456,16 +441,13 @@ dofsizes(fd, super, name) } static void -douser(fd, super, name) - int fd; - struct fs *super; - char *name; +douser(int fd, struct fs *super, char *name) { ino_t inode, maxino; struct user *usr, *usrs; union dinode *dp; - register int n; - + int n; + maxino = super->fs_ncg * super->fs_ipg - 1; for (inode = 0; inode < maxino; inode++) { errno = 0; @@ -499,16 +481,13 @@ douser(fd, super, name) } static void -donames(fd, super, name) - int fd; - struct fs *super; - char *name; +donames(int fd, struct fs *super, char *name) { int c; ino_t inode; ino_t maxino; union dinode *dp; - + maxino = super->fs_ncg * super->fs_ipg - 1; /* first skip the name of the filesystem */ while ((c = getchar()) != EOF && (c < '0' || c > '9')) @@ -544,7 +523,7 @@ donames(fd, super, name) } static void -usage() +usage(void) { #ifdef COMPAT fprintf(stderr,"usage: quot [-nfcvha] [filesystem ...]\n"); @@ -561,12 +540,11 @@ static int sblock_try[] = SBLOCKSEARCH; static char superblock[SBLOCKSIZE]; void -quot(name,mp) - char *name, *mp; +quot(char *name, char *mp) { int i, fd; struct fs *fs; - + get_inode(-1, NULL, 0); /* flush cache */ inituser(); initfsizes(); @@ -606,9 +584,7 @@ quot(name,mp) } int -main(argc,argv) - int argc; - char **argv; +main(int argc, char *argv[]) { char all = 0; struct statfs *mp; @@ -616,7 +592,7 @@ main(argc,argv) char dev[MNAMELEN + 1]; char *nm; int cnt; - + func = douser; #ifndef COMPAT header = getbsize(&headerlen,&blocksize); diff --git a/usr.sbin/quotaon/quotaon.c b/usr.sbin/quotaon/quotaon.c index 03df4e2..314f596 100644 --- a/usr.sbin/quotaon/quotaon.c +++ b/usr.sbin/quotaon/quotaon.c @@ -75,7 +75,7 @@ static void usage(void); int main(int argc, char **argv) { - register struct fstab *fs; + struct fstab *fs; char *qfnp, *whoami; long argnum, done = 0; int ch, i, offmode = 0, errs = 0; @@ -142,7 +142,7 @@ main(int argc, char **argv) } static void -usage() +usage(void) { fprintf(stderr, "%s\n%s\n%s\n%s\n", @@ -186,11 +186,9 @@ quotaonoff(fs, offmode, type, qfpathname) * Check to see if target appears in list of size cnt. */ int -oneof(target, list, cnt) - register char *target, *list[]; - int cnt; +oneof(char *target, char *list[], int cnt) { - register int i; + int i; for (i = 0; i < cnt; i++) if (strcmp(target, list[i]) == 0) @@ -202,10 +200,7 @@ oneof(target, list, cnt) * Check to see if a particular quota is to be enabled. */ int -hasquota(fs, type, qfnamep) - struct fstab *fs; - int type; - char **qfnamep; +hasquota(struct fstab *fs, int type, char **qfnamep) { char *opt; char *cp; @@ -254,8 +249,7 @@ hasquota(fs, type, qfnamep) * Verify filesystem is mounted and not readonly. */ int -readonly(fs) - register struct fstab *fs; +readonly(struct fstab *fs) { struct statfs fsbuf; diff --git a/usr.sbin/repquota/repquota.c b/usr.sbin/repquota/repquota.c index 4f88bff..19c1858 100644 --- a/usr.sbin/repquota/repquota.c +++ b/usr.sbin/repquota/repquota.c @@ -102,11 +102,11 @@ char *timeprt(time_t); static void usage(void); int -main(int argc, char **argv) +main(int argc, char *argv[]) { - register struct fstab *fs; - register struct passwd *pw; - register struct group *gr; + struct fstab *fs; + struct passwd *pw; + struct group *gr; int ch, gflag = 0, uflag = 0, errs = 0; long i, argnum, done = 0; char *qfnp; @@ -181,7 +181,7 @@ main(int argc, char **argv) } static void -usage() +usage(void) { fprintf(stderr, "%s\n%s\n", "usage: repquota [-v] [-g] [-n] [-u] -a", @@ -190,12 +190,9 @@ usage() } int -repquota(fs, type, qfpathname) - register struct fstab *fs; - int type; - char *qfpathname; +repquota(struct fstab *fs, int type, char *qfpathname) { - register struct fileusage *fup; + struct fileusage *fup; FILE *qf; u_long id; struct dqblk dqbuf; @@ -272,11 +269,9 @@ repquota(fs, type, qfpathname) * Check to see if target appears in list of size cnt. */ int -oneof(target, list, cnt) - register char *target, *list[]; - int cnt; +oneof(char *target, char *list[], int cnt) { - register int i; + int i; for (i = 0; i < cnt; i++) if (strcmp(target, list[i]) == 0) @@ -288,10 +283,7 @@ oneof(target, list, cnt) * Check to see if a particular quota is to be enabled. */ int -hasquota(fs, type, qfnamep) - struct fstab *fs; - int type; - char **qfnamep; +hasquota(struct fstab *fs, int type, char **qfnamep) { char *opt; char *cp; @@ -342,11 +334,9 @@ hasquota(fs, type, qfnamep) * Lookup an id of a specific type. */ struct fileusage * -lookup(id, type) - u_long id; - int type; +lookup(u_long id, int type) { - register struct fileusage *fup; + struct fileusage *fup; for (fup = fuhead[type][id & (FUHASH-1)]; fup != 0; fup = fup->fu_next) if (fup->fu_id == id) @@ -358,10 +348,7 @@ lookup(id, type) * Add a new file usage id if it does not already exist. */ struct fileusage * -addid(id, type, name) - u_long id; - int type; - char *name; +addid(u_long id, int type, char *name) { struct fileusage *fup, **fhp; int len; @@ -392,8 +379,7 @@ addid(id, type, name) * Calculate the grace period and return a printable string for it. */ char * -timeprt(seconds) - time_t seconds; +timeprt(time_t seconds) { time_t hours, minutes; static char buf[20]; |