(no message)
[unix-history] / usr / src / usr.bin / quota / quota.c
index 0d09e1f..eab9667 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)quota.c    4.1 (Berkeley, from Melbourne) %G%";
+static char sccsid[] = "@(#)quota.c    4.4 (Berkeley, from Melbourne) %G%";
 #endif
 
 /*
 #endif
 
 /*
@@ -11,7 +11,6 @@ static char sccsid[] = "@(#)quota.c   4.1 (Berkeley, from Melbourne) %G%";
 #include <pwd.h>
 
 #include <sys/param.h>
 #include <pwd.h>
 
 #include <sys/param.h>
-#define        QUOTA
 #include <sys/quota.h>
 #include <sys/file.h>
 #include <sys/stat.h>
 #include <sys/quota.h>
 #include <sys/file.h>
 #include <sys/stat.h>
@@ -20,6 +19,7 @@ int   qflag;
 int    vflag;
 int    done;
 int    morethanone;
 int    vflag;
 int    done;
 int    morethanone;
+char   *qfname = "quotas";
 
 main(argc, argv)
        char *argv[];
 
 main(argc, argv)
        char *argv[];
@@ -105,20 +105,20 @@ showquotas(uid, name)
                dev_t   fsdev;
                struct  stat statb;
                struct  dqblk dqblk;
                dev_t   fsdev;
                struct  stat statb;
                struct  dqblk dqblk;
-               char qfname[MAXPATHLEN + 1], iwarn[8], dwarn[8];
+               char qfilename[MAXPATHLEN + 1], iwarn[8], dwarn[8];
 
                if (stat(fs->fs_spec, &statb) < 0)
                        continue;
                fsdev = statb.st_rdev;
 
                if (stat(fs->fs_spec, &statb) < 0)
                        continue;
                fsdev = statb.st_rdev;
-               (void) sprintf(qfname, "%s/%s", fs->fs_file, fs->fs_quotafile);
-               if (stat(qfname, &statb) < 0 || statb.st_dev != fsdev)
+               (void) sprintf(qfilename, "%s/%s", fs->fs_file, qfname);
+               if (stat(qfilename, &statb) < 0 || statb.st_dev != fsdev)
                        continue;
                if (quota(Q_GETDLIM, uid, fsdev, &dqblk) != 0) {
                        continue;
                if (quota(Q_GETDLIM, uid, fsdev, &dqblk) != 0) {
-                       register fd = open(qfname, FRDONLY);
+                       register fd = open(qfilename, O_RDONLY);
 
                        if (fd < 0)
                                continue;
 
                        if (fd < 0)
                                continue;
-                       lseek(fd, (long)(uid * sizeof (dqblk)), FSEEK_ABSOLUTE);
+                       lseek(fd, (long)(uid * sizeof (dqblk)), L_SET);
                        if (read(fd, &dqblk, sizeof dqblk) != sizeof (dqblk)) {
                                close(fd);
                                continue;
                        if (read(fd, &dqblk, sizeof dqblk) != sizeof (dqblk)) {
                                close(fd);
                                continue;
@@ -164,17 +164,17 @@ showquotas(uid, name)
                }
                if (vflag || dqblk.dqb_curblocks || dqblk.dqb_curinodes) {
                        heading(uid, name);
                }
                if (vflag || dqblk.dqb_curblocks || dqblk.dqb_curinodes) {
                        heading(uid, name);
-                       printf("%8s%8d%c%7d%8d%8s%8d%c%7d%8d%8s\n"
+                       printf("%10s%8d%c%7d%8d%8s%8d%c%7d%8d%8s\n"
                                , fs->fs_file
                                , fs->fs_file
-                               , (dqblk.dqb_curblocks / (1024/DEV_BSIZE)) 
+                               , (dqblk.dqb_curblocks / btodb(1024)) 
                                , (msgb == (char *)0) ? ' ' : '*'
                                , (msgb == (char *)0) ? ' ' : '*'
-                               , (dqblk.dqb_bsoftlimit / (1024/DEV_BSIZE)) 
-                               , ((dqblk.dqb_bhardlimit-1) / (1024/DEV_BSIZE)) 
+                               , (dqblk.dqb_bsoftlimit / btodb(1024)) 
+                               , (dqblk.dqb_bhardlimit / btodb(1024)) 
                                , dwarn
                                , dqblk.dqb_curinodes
                                , (msgi == (char *)0) ? ' ' : '*'
                                , dqblk.dqb_isoftlimit
                                , dwarn
                                , dqblk.dqb_curinodes
                                , (msgi == (char *)0) ? ' ' : '*'
                                , dqblk.dqb_isoftlimit
-                               , dqblk.dqb_ihardlimit-1
+                               , dqblk.dqb_ihardlimit
                                , iwarn
                        );
                }
                                , iwarn
                        );
                }
@@ -207,7 +207,7 @@ heading(uid, name)
        putchar('\n');
        xprintf("Disc quotas for %s (uid %d):", name, uid);
        xprintf(0);
        putchar('\n');
        xprintf("Disc quotas for %s (uid %d):", name, uid);
        xprintf(0);
-       printf("%8s%8s %7s%8s%8s%8s %7s%8s%8s\n"
+       printf("%10s%8s %7s%8s%8s%8s %7s%8s%8s\n"
                , "Filsys"
                , "current"
                , "quota"
                , "Filsys"
                , "current"
                , "quota"