]> andersk Git - moira.git/commitdiff
(wesommer?) implemented -u flag to update quota values with increment
authorraeburn <raeburn>
Thu, 6 Oct 1988 10:41:55 +0000 (10:41 +0000)
committerraeburn <raeburn>
Thu, 6 Oct 1988 10:41:55 +0000 (10:41 +0000)
from current.

gen/setquota.c

index 3190685fd849e3e8fbdffc57254f9b48e2317e6d..b39794776ffa9a8d14f721da713b907704480072 100644 (file)
  * quota system.
  *     
  *     $Log$
- *     Revision 1.1  1987-09-04 21:32:47  wesommer
- *     Initial revision
+ *     Revision 1.2  1988-10-06 10:41:55  raeburn
+ *     (wesommer?) implemented -u flag to update quota values with increment
+ *     from current.
  *
+ * Revision 1.1  87/09/04  21:32:47  wesommer
+ * Initial revision
+ * 
  */
 
 #ifndef lint
@@ -34,11 +38,25 @@ main(argc, argv)
 {
        char *device;
        int uid;
-       struct dqblk db;
+       struct dqblk db, odb;
+       int uflag = 0;
+       
+       while (argc > 4 && *argv[1] == '-') {
+               switch(argv[1][1]) {
+               case 'u':
+                       uflag = 1;
+                       --argc;
+                       ++argv;
+                       break;
+               default:
+                       goto usage;
+               }
+       }
        
        if (argc != 4) {
        usage:
-               fprintf(stderr, "usage: setquota special uid quota\n\
+               fprintf(stderr, "usage: setquota [-u] special uid quota\n\
+-u means set limit to <quota> + cur usage\n\
 special is a mounted filesystem special device\n\
 quota is in 1KB units\n");
                exit(1);
@@ -62,6 +80,15 @@ quota is in 1KB units\n");
        db.dqb_bsoftlimit *= btodb(1024);
        db.dqb_bhardlimit *= btodb(1024);
 
+       if (uflag) {
+               if (quotactl(Q_GETQUOTA, device, uid, &odb) == 0) {
+                       db.dqb_bhardlimit += odb.dqb_curblocks;
+                       db.dqb_bsoftlimit += odb.dqb_curblocks;
+                       db.dqb_fhardlimit += odb.dqb_curfiles;
+                       db.dqb_fsoftlimit += odb.dqb_curfiles;
+               }
+       }
+       
        if (quotactl(Q_SETQLIM, device, uid, &db) < 0) {
                fprintf (stderr, "quotactl: %d on ", uid);
                perror (device);
This page took 0.211351 seconds and 5 git commands to generate.