6 * Copyright (C) 1987 by the Massachusetts Institute of Technology
8 * Set quota on specified device for specified user to specified value.
10 * Uses the NFS style quota system/quotactl rather than the Melbourne
14 * Revision 1.1 1987-09-04 21:32:47 wesommer
20 static char *rcsid_setquota_c = "$Header$";
25 #include <sys/param.h>
27 #include <ufs/quota.h>
29 #define kb(n) (howmany(dbtob(n), 1024))
41 fprintf(stderr, "usage: setquota special uid quota\n\
42 special is a mounted filesystem special device\n\
43 quota is in 1KB units\n");
47 if (!isdigit(*argv[2]) || !isdigit(*argv[3])) {
48 fprintf(stderr, "setquota: uid and quota must be numeric\n");
55 db.dqb_bsoftlimit = atoi(argv[3]);
56 db.dqb_bhardlimit = db.dqb_bsoftlimit * 1.2;
57 db.dqb_fsoftlimit = atoi(argv[3]) * .5;
58 db.dqb_fhardlimit = db.dqb_fsoftlimit * 1.2;
59 db.dqb_btimelimit = DQ_FTIMELIMIT;
60 db.dqb_btimelimit = DQ_BTIMELIMIT;
62 db.dqb_bsoftlimit *= btodb(1024);
63 db.dqb_bhardlimit *= btodb(1024);
65 if (quotactl(Q_SETQLIM, device, uid, &db) < 0) {
66 fprintf (stderr, "quotactl: %d on ", uid);
70 if (quotactl(Q_SYNC, device, 0, 0) < 0) {
71 perror ("can't sync disk quota");