]> andersk Git - moira.git/commitdiff
Initial revision
authorwesommer <wesommer>
Fri, 4 Sep 1987 21:32:47 +0000 (21:32 +0000)
committerwesommer <wesommer>
Fri, 4 Sep 1987 21:32:47 +0000 (21:32 +0000)
gen/setquota.c [new file with mode: 0644]

diff --git a/gen/setquota.c b/gen/setquota.c
new file mode 100644 (file)
index 0000000..3190685
--- /dev/null
@@ -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 <stdio.h>
+#include <ctype.h>
+#include <sys/param.h>
+#include <sys/time.h>
+#include <ufs/quota.h>
+
+#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);
+}
+       
This page took 0.079922 seconds and 5 git commands to generate.