From 5dc7ec18c05c6b2596f76fdea04f3f1399dbde35 Mon Sep 17 00:00:00 2001 From: wesommer Date: Fri, 4 Sep 1987 21:32:47 +0000 Subject: [PATCH] Initial revision --- gen/setquota.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 gen/setquota.c diff --git a/gen/setquota.c b/gen/setquota.c new file mode 100644 index 00000000..3190685f --- /dev/null +++ b/gen/setquota.c @@ -0,0 +1,76 @@ +/* + * $Source$ + * $Author$ + * $Header$ + * + * Copyright (C) 1987 by the Massachusetts Institute of Technology + * + * Set quota on specified device for specified user to specified value. + * + * Uses the NFS style quota system/quotactl rather than the Melbourne + * quota system. + * + * $Log$ + * Revision 1.1 1987-09-04 21:32:47 wesommer + * Initial revision + * + */ + +#ifndef lint +static char *rcsid_setquota_c = "$Header$"; +#endif lint + +#include +#include +#include +#include +#include + +#define kb(n) (howmany(dbtob(n), 1024)) + +main(argc, argv) + int argc; + char **argv; +{ + char *device; + int uid; + struct dqblk db; + + if (argc != 4) { + usage: + fprintf(stderr, "usage: setquota special uid quota\n\ +special is a mounted filesystem special device\n\ +quota is in 1KB units\n"); + exit(1); + } + + if (!isdigit(*argv[2]) || !isdigit(*argv[3])) { + fprintf(stderr, "setquota: uid and quota must be numeric\n"); + goto usage; + } + + device = argv[1]; + uid = atoi(argv[2]); + + db.dqb_bsoftlimit = atoi(argv[3]); + db.dqb_bhardlimit = db.dqb_bsoftlimit * 1.2; + db.dqb_fsoftlimit = atoi(argv[3]) * .5; + db.dqb_fhardlimit = db.dqb_fsoftlimit * 1.2; + db.dqb_btimelimit = DQ_FTIMELIMIT; + db.dqb_btimelimit = DQ_BTIMELIMIT; + + db.dqb_bsoftlimit *= btodb(1024); + db.dqb_bhardlimit *= btodb(1024); + + if (quotactl(Q_SETQLIM, device, uid, &db) < 0) { + fprintf (stderr, "quotactl: %d on ", uid); + perror (device); + exit (1); + } + if (quotactl(Q_SYNC, device, 0, 0) < 0) { + perror ("can't sync disk quota"); + exit (1); + } + exit (0); +} + -- 2.45.2