From 95d08e4b5cd249a0d9b478c2c6b32403d27945b0 Mon Sep 17 00:00:00 2001 From: raeburn Date: Thu, 6 Oct 1988 10:41:55 +0000 Subject: [PATCH] (wesommer?) implemented -u flag to update quota values with increment from current. --- gen/setquota.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/gen/setquota.c b/gen/setquota.c index 3190685f..b3979477 100644 --- a/gen/setquota.c +++ b/gen/setquota.c @@ -11,9 +11,13 @@ * 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 + 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); -- 2.45.2