Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!uwvax!oddjob!gargoyle!ihnp4!inuxc!iuvax!pur-ee!ea.ecn.purdue.edu!davy From: davy@ea.ecn.purdue.edu (Dave Curry) Newsgroups: comp.unix.questions Subject: Re: How to remove old uid's from quota file under 4.2 Unix Message-ID: <189@ea.ecn.purdue.edu> Date: Wed, 15-Jul-87 18:58:46 EDT Article-I.D.: ea.189 Posted: Wed Jul 15 18:58:46 1987 Date-Received: Sat, 18-Jul-87 06:05:57 EDT References: <480@drexel.Drexel.edu> Reply-To: davy@ea.ecn.purdue.edu.UUCP (Dave Curry) Organization: Purdue University Engineering Computer Network Lines: 58 In article <480@drexel.Drexel.edu> jeff@drexel.UUCP writes: > > Using the quota package under 4.2 BSD, can sometime tell me how (or if >it is possible) to remove old users's uids from the master quota file for >each file system? There's no existing way to do it, but how about: #include#include #include #include main() { FILE *fpr, *fpw; register int uid; struct dqblk dqblk; struct passwd *getpwuid(); /* * Use two file pointers to let stdio do buffering. */ if ((fpr = fopen("quotas", "r")) == NULL) { fprintf(stderr, "cannot open quotas file.\n"); exit(1); } if ((fpw = fopen("quotas", "w")) == NULL) { fprintf(stderr, "cannot open quotas file.\n"); exit(1); } i = 0; while (fread(&dqblk, sizeof(struct dqblk), 1, fpr) != NULL) { /* * Not there, so zip the entry. */ if (getpwuid(i) == NULL) { bzero(&dqblk, sizeof(struct dqblk)); fseek(fpw, (long) i * sizeof(struct dqblk), 0); fwrite(&dqblk, sizeof(struct dqblk), 1, fpw); } i++; } fclose(fpr); fclose(fpw); exit(0); } Note that I haven't tried this, I just wrote it off the top of my head, so I don't make any guarantees... --Dave Curry Purdue University Engineering Computer Network