]> andersk Git - moira.git/blob - gen/setquota.c
Disable shutdowns completely.
[moira.git] / gen / setquota.c
1 /*
2  *      $Source$
3  *      $Author$
4  *      $Header$
5  *
6  *      Copyright (C) 1987 by the Massachusetts Institute of Technology
7  *
8  *      Set quota on specified device for specified user to specified value.
9  *
10  *      Uses the NFS style quota system/quotactl rather than the Melbourne
11  * quota system.
12  *      
13  *      $Log$
14  *      Revision 1.1  1987-09-04 21:32:47  wesommer
15  *      Initial revision
16  *
17  */
18
19 #ifndef lint
20 static char *rcsid_setquota_c = "$Header$";
21 #endif lint
22
23 #include <stdio.h>
24 #include <ctype.h>
25 #include <sys/param.h>
26 #include <sys/time.h>
27 #include <ufs/quota.h>
28
29 #define kb(n)   (howmany(dbtob(n), 1024))
30
31 main(argc, argv)
32         int argc;
33         char **argv;
34 {
35         char *device;
36         int uid;
37         struct dqblk db;
38         
39         if (argc != 4) {
40         usage:
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");
44                 exit(1);
45         }
46
47         if (!isdigit(*argv[2]) || !isdigit(*argv[3])) {
48                 fprintf(stderr, "setquota: uid and quota must be numeric\n");
49                 goto usage;
50         }
51         
52         device = argv[1];
53         uid = atoi(argv[2]);
54         
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;
61
62         db.dqb_bsoftlimit *= btodb(1024);
63         db.dqb_bhardlimit *= btodb(1024);
64
65         if (quotactl(Q_SETQLIM, device, uid, &db) < 0) {
66                 fprintf (stderr, "quotactl: %d on ", uid);
67                 perror (device);
68                 exit (1);
69         }
70         if (quotactl(Q_SYNC, device, 0, 0) < 0) {
71                 perror ("can't sync disk quota");
72                 exit (1);
73         }
74         exit (0);
75 }
76         
This page took 0.047541 seconds and 5 git commands to generate.