Diff for /src/usr.sbin/repquota/repquota.c between versions 1.4 and 1.5

version 1.4, 2003/11/03 19:31:41 version 1.5, 2004/03/21 22:41:24
Line 95  char *timeprt(time_t); Line 95  char *timeprt(time_t);
 static void usage(void);  static void usage(void);
   
 int  int
 main(argc, argv)  main(int argc, char **argv)
         int argc;  
         char **argv;  
 {  {
         register struct fstab *fs;          struct fstab *fs;
         register struct passwd *pw;          struct passwd *pw;
         register struct group *gr;          struct group *gr;
         int gflag = 0, uflag = 0, errs = 0;          int gflag = 0, uflag = 0, errs = 0;
         long i, argnum, done = 0;          long i, argnum, done = 0;
         char ch, *qfnp;          char ch, *qfnp;
Line 136  main(argc, argv) Line 134  main(argc, argv)
         if (gflag) {          if (gflag) {
                 setgrent();                  setgrent();
                 while ((gr = getgrent()) != 0)                  while ((gr = getgrent()) != 0)
                         (void) addid((u_long)gr->gr_gid, GRPQUOTA, gr->gr_name);                          addid((u_long)gr->gr_gid, GRPQUOTA, gr->gr_name);
                 endgrent();                  endgrent();
         }          }
         if (uflag) {          if (uflag) {
                 setpwent();                  setpwent();
                 while ((pw = getpwent()) != 0)                  while ((pw = getpwent()) != 0)
                         (void) addid((u_long)pw->pw_uid, USRQUOTA, pw->pw_name);                          addid((u_long)pw->pw_uid, USRQUOTA, pw->pw_name);
                 endpwent();                  endpwent();
         }          }
         setfsent();          setfsent();
Line 173  main(argc, argv) Line 171  main(argc, argv)
 }  }
   
 static void  static void
 usage()  usage(void)
 {  {
         fprintf(stderr, "%s\n%s\n",          fprintf(stderr, "%s\n%s\n",
                 "usage: repquota [-v] [-g] [-u] -a",              "usage: repquota [-v] [-g] [-u] -a",
                 "       repquota [-v] [-g] [-u] filesystem ...");              "       repquota [-v] [-g] [-u] filesystem ...");
         exit(1);          exit(1);
 }  }
   
 int  int
 repquota(fs, type, qfpathname)  repquota(struct fstab *fs, int type, char *qfpathname)
         register struct fstab *fs;  
         int type;  
         char *qfpathname;  
 {  {
         register struct fileusage *fup;          struct fileusage *fup;
         FILE *qf;          FILE *qf;
         u_long id;          u_long id;
         struct dqblk dqbuf;          struct dqblk dqbuf;
Line 264  repquota(fs, type, qfpathname) Line 259  repquota(fs, type, qfpathname)
  * Check to see if target appears in list of size cnt.   * Check to see if target appears in list of size cnt.
  */   */
 int  int
 oneof(target, list, cnt)  oneof(char *target, char *list[], int cnt)
         register char *target, *list[];  
         int cnt;  
 {  {
         register int i;          int i;
   
         for (i = 0; i < cnt; i++)          for (i = 0; i < cnt; i++)
                 if (strcmp(target, list[i]) == 0)                  if (strcmp(target, list[i]) == 0)
Line 280  oneof(target, list, cnt) Line 273  oneof(target, list, cnt)
  * Check to see if a particular quota is to be enabled.   * Check to see if a particular quota is to be enabled.
  */   */
 int  int
 hasquota(fs, type, qfnamep)  hasquota(struct fstab *fs, int type, char **qfnamep)
         register struct fstab *fs;  
         int type;  
         char **qfnamep;  
 {  {
         register char *opt;          char *opt;
         char *cp;          char *cp;
         static char initname, usrname[100], grpname[100];          static char initname, usrname[100], grpname[100];
         static char buf[BUFSIZ];          static char buf[BUFSIZ];
Line 310  hasquota(fs, type, qfnamep) Line 300  hasquota(fs, type, qfnamep)
                 *qfnamep = cp;                  *qfnamep = cp;
                 return (1);                  return (1);
         }          }
         (void) sprintf(buf, "%s/%s.%s", fs->fs_file, qfname, qfextension[type]);          sprintf(buf, "%s/%s.%s", fs->fs_file, qfname, qfextension[type]);
         *qfnamep = buf;          *qfnamep = buf;
         return (1);          return (1);
 }  }
Line 321  hasquota(fs, type, qfnamep) Line 311  hasquota(fs, type, qfnamep)
  * Lookup an id of a specific type.   * Lookup an id of a specific type.
  */   */
 struct fileusage *  struct fileusage *
 lookup(id, type)  lookup(u_long id, int type)
         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)          for (fup = fuhead[type][id & (FUHASH-1)]; fup != 0; fup = fup->fu_next)
                 if (fup->fu_id == id)                  if (fup->fu_id == id)
Line 337  lookup(id, type) Line 325  lookup(id, type)
  * Add a new file usage id if it does not already exist.   * Add a new file usage id if it does not already exist.
  */   */
 struct fileusage *  struct fileusage *
 addid(id, type, name)  addid(u_long id, int type, char *name)
         u_long id;  
         int type;  
         char *name;  
 {  {
         struct fileusage *fup, **fhp;          struct fileusage *fup, **fhp;
         int len;          int len;
Line 371  addid(id, type, name) Line 356  addid(id, type, name)
  * Calculate the grace period and return a printable string for it.   * Calculate the grace period and return a printable string for it.
  */   */
 char *  char *
 timeprt(seconds)  timeprt(time_t seconds)
         time_t seconds;  
 {  {
         time_t hours, minutes;          time_t hours, minutes;
         static char buf[20];          static char buf[20];

Removed from v.1.4  
changed lines
  Added in v.1.5