ruby-quota 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +1 -0
- data/MANIFEST +1 -1
- data/README.md +58 -0
- data/extconf.rb +6 -3
- data/quota.c +157 -91
- metadata +6 -6
- data/README +0 -48
data/COPYING
CHANGED
data/MANIFEST
CHANGED
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
Ruby/Quota
|
2
|
+
==========
|
3
|
+
|
4
|
+
This module provides Ruby access to manipulating the disk quotas.
|
5
|
+
|
6
|
+
|
7
|
+
Supported systems
|
8
|
+
-----------------
|
9
|
+
|
10
|
+
* Linux 2.4.x, 2.6.x and newer
|
11
|
+
* Solaris 2.6, 7, 8
|
12
|
+
* FreeBSD
|
13
|
+
* NetBSD
|
14
|
+
* OpenBSD
|
15
|
+
* Dragonfly BSD
|
16
|
+
* Mac OS X
|
17
|
+
|
18
|
+
|
19
|
+
Usage
|
20
|
+
-----
|
21
|
+
|
22
|
+
Common parameters:
|
23
|
+
|
24
|
+
* `dev` is a device file (e.g. /dev/hda0) or a mount point (e.g. /mnt/foo), where
|
25
|
+
supported. Mount point look up is implemented on BSD and Linux targets.
|
26
|
+
|
27
|
+
* `quotafile` is a quota(s) file
|
28
|
+
|
29
|
+
* `id` can be an integer to mean uid, otherwise it can be a UserID or a GroupID
|
30
|
+
object to signal uid or gid respectively.
|
31
|
+
|
32
|
+
* `diskquota` is a DiskQuota structure. It stores all the fields of the quota
|
33
|
+
settings. For possible field names and meaning of them see the local quotactl
|
34
|
+
man pages on your system.
|
35
|
+
|
36
|
+
|
37
|
+
Functions:
|
38
|
+
|
39
|
+
* `Quota.quotaon(dev, quotafile)` to turn quota on.
|
40
|
+
|
41
|
+
* `Quota.quotaoff(dev)` to turn quota off.
|
42
|
+
|
43
|
+
* `Quota.getquota(dev, id)` returns a DiskQuota structure on success.
|
44
|
+
|
45
|
+
* `Quota.setquota(dev, id, diskquota)` updates both the limit and usage settings
|
46
|
+
from the provided quota structure.
|
47
|
+
|
48
|
+
* `Quota.setlimit(dev, id, diskquota)` updates only the limit settings from the
|
49
|
+
provided quota structure. This is not supported on all systems.
|
50
|
+
|
51
|
+
* `Quota.setusage(dev, id, diskquota)` updates only the usage settings from the
|
52
|
+
provided quota structure. This is not supported on all systems.
|
53
|
+
|
54
|
+
* `Quota.sync(dev)` flushes all the changes made to the quota system.
|
55
|
+
|
56
|
+
* `Quota::UserID.new(id)` or `Quota::UserID[id]` to create a new uid object.
|
57
|
+
|
58
|
+
* `Quota::GroupID.new(id)` or `Quota::GroupID[id]` to create a new gid object.
|
data/extconf.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
#
|
2
2
|
# extconf.rb
|
3
3
|
#
|
4
|
-
# Resource
|
5
4
|
# Copyright (C) 2000 by Takaaki Tateishi <ttate@jaist.ac.jp>
|
6
|
-
#
|
5
|
+
#
|
7
6
|
|
8
7
|
require "mkmf"
|
9
8
|
|
10
9
|
have_header("unistd.h")
|
11
10
|
|
12
|
-
|
11
|
+
# ensure we do not enable the known broken version:
|
12
|
+
# http://lkml.indiana.edu/hypermail/linux/kernel/0705.0/1234.html
|
13
|
+
if try_link("#include <ruby.h>\n#include <linux/quota.h>\nvoid main() {}")
|
14
|
+
have_header("linux/quota.h") # for linux
|
15
|
+
end
|
13
16
|
have_header("linux/types.h")
|
14
17
|
have_header("sys/quota.h")
|
15
18
|
have_header("sys/types.h")
|
data/quota.c
CHANGED
@@ -1,16 +1,11 @@
|
|
1
|
-
/* -*- C -*-
|
2
|
-
* $Id: quota.c,v 1.3 2004/08/25 16:27:50 ttate Exp $
|
3
|
-
* Copyright (C) 2000,2001,2002,2003,2004 Takaaki Tateishi <ttate@ttsky.net>
|
4
|
-
*/
|
5
|
-
|
6
1
|
/*
|
7
|
-
*
|
8
|
-
*
|
2
|
+
* Copyright (C) 2000,2001,2002,2003,2004 Takaaki Tateishi <ttate@ttsky.net>
|
3
|
+
* Copyright (C) 2009-2012 Alex Beregszaszi
|
9
4
|
*/
|
10
5
|
|
11
6
|
#include "ruby.h"
|
12
7
|
|
13
|
-
#define RUBY_QUOTA_VERSION "0.
|
8
|
+
#define RUBY_QUOTA_VERSION "0.8.0"
|
14
9
|
|
15
10
|
#ifdef HAVE_UNISTD_H
|
16
11
|
#include <unistd.h>
|
@@ -39,6 +34,8 @@
|
|
39
34
|
#else
|
40
35
|
# include <sys/types.h>
|
41
36
|
#endif
|
37
|
+
#include <mntent.h>
|
38
|
+
#include <sys/stat.h>
|
42
39
|
#ifdef HAVE_LINUX_QUOTA_H
|
43
40
|
# include <linux/quota.h>
|
44
41
|
# /* defined for 64bit quota fields */
|
@@ -52,12 +49,38 @@
|
|
52
49
|
#else
|
53
50
|
# include <sys/quota.h>
|
54
51
|
#endif
|
52
|
+
|
53
|
+
/* FIXME: there must be a more sophisticated way for this (hint: use extconf's have_macro) */
|
54
|
+
#if defined(dbtob) && defined(btodb)
|
55
|
+
|
56
|
+
#define BYTE2BLOCK(x) btodb(x)
|
57
|
+
#define BLOCK2BYTE(x) dbtob(x)
|
58
|
+
|
59
|
+
#else
|
60
|
+
|
61
|
+
#ifndef QIF_DQBLKSIZE /* The change happened midway through 2.6 */
|
62
|
+
# define QIF_DQBLKSIZE QUOTABLOCK_SIZE
|
63
|
+
#endif
|
64
|
+
#define BYTE2BLOCK(x) ((x) / QIF_DQBLKSIZE)
|
65
|
+
#define BLOCK2BYTE(x) ((x) * QIF_DQBLKSIZE)
|
66
|
+
|
67
|
+
#endif
|
68
|
+
|
69
|
+
/* In 2.4.22 the curblocks field was renamed to curspace */
|
70
|
+
/* FIXME: should use extconf to determine this */
|
71
|
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,22)
|
72
|
+
#define USE_LINUX_CURBLOCKS
|
73
|
+
#endif
|
74
|
+
|
55
75
|
#endif /* USE_LINUX_QUOTA */
|
56
76
|
|
57
77
|
#ifdef USE_SOLARIS_QUOTA
|
58
78
|
#include <sys/types.h>
|
59
79
|
#include <sys/fcntl.h>
|
60
80
|
#include <sys/fs/ufs_quota.h>
|
81
|
+
|
82
|
+
#define BYTE2BLOCK(x) btodb(x)
|
83
|
+
#define BLOCK2BYTE(x) dbtob(x)
|
61
84
|
#endif
|
62
85
|
|
63
86
|
#ifdef USE_BSD_QUOTA
|
@@ -75,6 +98,9 @@
|
|
75
98
|
# define dqblk ufs_dqblk
|
76
99
|
# endif
|
77
100
|
#endif
|
101
|
+
|
102
|
+
#define BYTE2BLOCK(x) btodb(x)
|
103
|
+
#define BLOCK2BYTE(x) dbtob(x)
|
78
104
|
#endif
|
79
105
|
|
80
106
|
/* XXX: bad workaround for Snow Leopard/Lion */
|
@@ -82,6 +108,10 @@
|
|
82
108
|
#include <sys/quota.h>
|
83
109
|
#include <sys/mount.h>
|
84
110
|
#define USE_BSD_QUOTA
|
111
|
+
|
112
|
+
// blocksize 1
|
113
|
+
#define BYTE2BLOCK(x) (x)
|
114
|
+
#define BLOCK2BYTE(x) (x)
|
85
115
|
#endif
|
86
116
|
|
87
117
|
/* XXX: Ruby 1.9 workaround */
|
@@ -102,13 +132,13 @@ static uid_t
|
|
102
132
|
rb_quota_uid(VALUE vuid)
|
103
133
|
{
|
104
134
|
return ((q_uid_data*)DATA_PTR(vuid))->uid;
|
105
|
-
}
|
135
|
+
}
|
106
136
|
|
107
137
|
static void
|
108
138
|
rb_quota_uid_free(q_uid_data *data)
|
109
139
|
{
|
110
140
|
if( data ) free(data);
|
111
|
-
}
|
141
|
+
}
|
112
142
|
|
113
143
|
static VALUE
|
114
144
|
rb_quota_uid_new(VALUE klass, uid_t uid)
|
@@ -120,7 +150,7 @@ rb_quota_uid_new(VALUE klass, uid_t uid)
|
|
120
150
|
data->uid = uid;
|
121
151
|
|
122
152
|
return obj;
|
123
|
-
}
|
153
|
+
}
|
124
154
|
|
125
155
|
static VALUE
|
126
156
|
rb_quota_uid_s_new(int argc, VALUE argv[], VALUE klass)
|
@@ -133,19 +163,19 @@ rb_quota_uid_s_new(int argc, VALUE argv[], VALUE klass)
|
|
133
163
|
rb_obj_call_init(obj, argc, argv);
|
134
164
|
|
135
165
|
return obj;
|
136
|
-
}
|
166
|
+
}
|
137
167
|
|
138
168
|
static VALUE
|
139
169
|
rb_quota_uid_initialize(int argc, VALUE argv[], VALUE self)
|
140
170
|
{
|
141
171
|
return Qnil;
|
142
|
-
}
|
172
|
+
}
|
143
173
|
|
144
174
|
static VALUE
|
145
175
|
rb_quota_uid_to_i(VALUE self)
|
146
176
|
{
|
147
177
|
return UINT2NUM(((q_uid_data*)DATA_PTR(self))->uid);
|
148
|
-
}
|
178
|
+
}
|
149
179
|
|
150
180
|
static void
|
151
181
|
get_uid(VALUE vuid, uid_t *uid, int *is_gid)
|
@@ -168,9 +198,56 @@ get_uid(VALUE vuid, uid_t *uid, int *is_gid)
|
|
168
198
|
}
|
169
199
|
else{
|
170
200
|
rb_raise(rb_eTypeError, "An uid or gid is expected.");
|
171
|
-
}
|
172
|
-
}
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
static char *
|
205
|
+
__getdevice(char *dev)
|
206
|
+
{
|
207
|
+
#if defined(USE_LINUX_QUOTA)
|
208
|
+
FILE *f;
|
209
|
+
|
210
|
+
f = setmntent("/proc/mounts", "r");
|
211
|
+
if (f) {
|
212
|
+
struct mntent *e;
|
213
|
+
struct stat buf;
|
214
|
+
|
215
|
+
while (e = getmntent(f)) {
|
216
|
+
//printf("%s -> %s\n", e->mnt_dir, e->mnt_fsname);
|
217
|
+
if (!strcmp(e->mnt_dir, dev)) {
|
218
|
+
struct stat buf;
|
219
|
+
|
220
|
+
/* needed as modern Linux's will have generic entries first */
|
221
|
+
/* such as rootfs -> / */
|
222
|
+
if (!stat(e->mnt_fsname, &buf) && S_ISBLK(buf.st_mode)) {
|
223
|
+
dev = e->mnt_fsname;
|
224
|
+
break;
|
225
|
+
}
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
endmntent(f);
|
230
|
+
}
|
231
|
+
#elif defined(USE_BSD_QUOTA)
|
232
|
+
#if defined(HAVE_SYS_STATVFS_H) && defined(__NetBSD__)
|
233
|
+
struct statvfs *buff;
|
234
|
+
#else
|
235
|
+
struct statfs *buff;
|
236
|
+
#endif
|
237
|
+
int i, count;
|
238
|
+
|
239
|
+
buff = 0;
|
240
|
+
count = getmntinfo(&buff, MNT_WAIT);
|
241
|
+
for( i=0; i<count; i++ ){
|
242
|
+
if( strcmp(buff[i].f_mntfromname, dev) == 0 ){
|
243
|
+
dev = buff[i].f_mntonname;
|
244
|
+
break;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
#endif
|
173
248
|
|
249
|
+
return dev;
|
250
|
+
}
|
174
251
|
|
175
252
|
#if defined(USE_LINUX_QUOTA) /* for Linux */
|
176
253
|
static int
|
@@ -179,6 +256,8 @@ rb_quotactl(int cmd, char *dev, VALUE vuid, caddr_t addr)
|
|
179
256
|
int is_gid;
|
180
257
|
uid_t uid;
|
181
258
|
|
259
|
+
dev = __getdevice(dev);
|
260
|
+
|
182
261
|
get_uid(vuid, &uid, &is_gid);
|
183
262
|
#ifdef DEBUG
|
184
263
|
printf("cmd = %d, dev = %s, uid = %d, gid? = %d\n", cmd, dev, uid, is_gid);
|
@@ -188,43 +267,25 @@ rb_quotactl(int cmd, char *dev, VALUE vuid, caddr_t addr)
|
|
188
267
|
}
|
189
268
|
else{
|
190
269
|
return quotactl(QCMD(cmd,USRQUOTA),dev,(uid_t)uid,addr);
|
191
|
-
}
|
192
|
-
}
|
270
|
+
}
|
271
|
+
}
|
193
272
|
#elif defined(USE_BSD_QUOTA) /* for *BSD */
|
194
273
|
static int
|
195
274
|
rb_quotactl(int cmd, char *dev, VALUE vuid, caddr_t addr)
|
196
275
|
{
|
197
|
-
char *path;
|
198
276
|
int is_gid;
|
199
277
|
uid_t uid;
|
200
|
-
|
201
|
-
|
202
|
-
#else
|
203
|
-
struct statfs *buff;
|
204
|
-
#endif
|
205
|
-
int i, count, ret;
|
206
|
-
|
207
|
-
buff = 0;
|
208
|
-
path = dev;
|
209
|
-
count = getmntinfo(&buff, MNT_WAIT);
|
210
|
-
for( i=0; i<count; i++ ){
|
211
|
-
if( strcmp(buff[i].f_mntfromname, dev) == 0 ){
|
212
|
-
path = buff[i].f_mntonname;
|
213
|
-
break;
|
214
|
-
};
|
215
|
-
};
|
278
|
+
|
279
|
+
dev = __getdevice(dev);
|
216
280
|
|
217
281
|
get_uid(vuid, &uid, &is_gid);
|
218
282
|
if( is_gid ){
|
219
|
-
|
283
|
+
return quotactl(dev,QCMD(cmd,GRPQUOTA),uid,addr);
|
220
284
|
}
|
221
285
|
else{
|
222
|
-
|
223
|
-
}
|
224
|
-
|
225
|
-
|
226
|
-
return ret;
|
227
|
-
};
|
286
|
+
return quotactl(dev,QCMD(cmd,USRQUOTA),uid,addr);
|
287
|
+
}
|
288
|
+
}
|
228
289
|
#elif defined(USE_SOLARIS_QUOTA) /* for Solaris */
|
229
290
|
static int
|
230
291
|
rb_quotactl(int cmd, char *dev, VALUE vuid, caddr_t addr)
|
@@ -254,22 +315,22 @@ rb_quotactl(int cmd, char *dev, VALUE vuid, caddr_t addr)
|
|
254
315
|
}
|
255
316
|
else{
|
256
317
|
fd = open("/",O_RDWR); /* maybe is it ignored anyways? */
|
257
|
-
}
|
318
|
+
}
|
258
319
|
break;
|
259
320
|
default:
|
260
321
|
return -1;
|
261
322
|
}
|
262
323
|
if( fd < 0 ){
|
263
324
|
return -1;
|
264
|
-
}
|
325
|
+
}
|
265
326
|
if( ioctl(fd,Q_QUOTACTL,&qctl) == -1 ){
|
266
327
|
close(fd);
|
267
328
|
return -1;
|
268
|
-
}
|
329
|
+
}
|
269
330
|
close(fd);
|
270
331
|
|
271
332
|
return 0; /* success */
|
272
|
-
}
|
333
|
+
}
|
273
334
|
#endif
|
274
335
|
|
275
336
|
static void
|
@@ -288,7 +349,7 @@ rb_diskquota_get(VALUE dqb, struct dqblk * c_dqb)
|
|
288
349
|
#if defined(USE_LINUX_QUOTA)
|
289
350
|
c_dqb->dqb_bhardlimit = GetMember("bhardlimit");
|
290
351
|
c_dqb->dqb_bsoftlimit = GetMember("bsoftlimit");
|
291
|
-
#if defined(
|
352
|
+
#if !defined(USE_LINUX_CURBLOCKS)
|
292
353
|
c_dqb->dqb_curspace = GetMember("curspace");
|
293
354
|
#else
|
294
355
|
c_dqb->dqb_curblocks = GetMember("curblocks");
|
@@ -322,7 +383,7 @@ rb_diskquota_get(VALUE dqb, struct dqblk * c_dqb)
|
|
322
383
|
c_dqb->dqb_ftimelimit = GetMember("itimelimit");
|
323
384
|
#endif
|
324
385
|
#undef GetMember
|
325
|
-
}
|
386
|
+
}
|
326
387
|
|
327
388
|
static VALUE
|
328
389
|
rb_diskquota_new(struct dqblk *c_dqb)
|
@@ -344,7 +405,7 @@ rb_diskquota_new(struct dqblk *c_dqb)
|
|
344
405
|
dqb = rb_struct_new(rb_sDiskQuota,
|
345
406
|
UINT2NUM(c_dqb->dqb_bhardlimit),
|
346
407
|
UINT2NUM(c_dqb->dqb_bsoftlimit),
|
347
|
-
#if defined(
|
408
|
+
#if !defined(USE_LINUX_CURBLOCKS)
|
348
409
|
UINT2NUM(c_dqb->dqb_curspace),
|
349
410
|
#else
|
350
411
|
UINT2NUM(c_dqb->dqb_curblocks),
|
@@ -383,7 +444,7 @@ rb_diskquota_new(struct dqblk *c_dqb)
|
|
383
444
|
0);
|
384
445
|
#endif
|
385
446
|
return dqb;
|
386
|
-
}
|
447
|
+
}
|
387
448
|
|
388
449
|
static VALUE
|
389
450
|
rb_quota_getquota(VALUE self, VALUE dev, VALUE uid)
|
@@ -394,12 +455,12 @@ rb_quota_getquota(VALUE self, VALUE dev, VALUE uid)
|
|
394
455
|
|
395
456
|
if( rb_quotactl(Q_GETQUOTA,c_dev,uid,(caddr_t)(&c_dqb)) == -1 ){
|
396
457
|
rb_sys_fail("quotactl");
|
397
|
-
}
|
458
|
+
}
|
398
459
|
|
399
460
|
dqb = rb_diskquota_new(&c_dqb);
|
400
461
|
|
401
462
|
return dqb;
|
402
|
-
}
|
463
|
+
}
|
403
464
|
|
404
465
|
static VALUE
|
405
466
|
rb_quota_quotaoff(VALUE self, VALUE dev)
|
@@ -408,10 +469,10 @@ rb_quota_quotaoff(VALUE self, VALUE dev)
|
|
408
469
|
|
409
470
|
if( rb_quotactl(Q_QUOTAOFF,c_dev,Qnil,NULL) == -1 ){
|
410
471
|
rb_sys_fail("quotactl");
|
411
|
-
}
|
472
|
+
}
|
412
473
|
|
413
474
|
return Qnil;
|
414
|
-
}
|
475
|
+
}
|
415
476
|
|
416
477
|
static VALUE
|
417
478
|
rb_quota_quotaon(VALUE self, VALUE dev, VALUE quotas)
|
@@ -421,66 +482,65 @@ rb_quota_quotaon(VALUE self, VALUE dev, VALUE quotas)
|
|
421
482
|
|
422
483
|
if( rb_quotactl(Q_QUOTAON,c_dev,Qnil,(caddr_t)c_quotas) == -1 ){
|
423
484
|
rb_sys_fail("quotactl");
|
424
|
-
}
|
485
|
+
}
|
425
486
|
|
426
487
|
return Qnil;
|
427
|
-
}
|
488
|
+
}
|
428
489
|
|
429
490
|
static VALUE
|
430
|
-
|
491
|
+
__rb_quota_set(VALUE self, VALUE dev, VALUE uid, VALUE dqb, int cmd)
|
431
492
|
{
|
432
493
|
char *c_dev = STR2CSTR(dev);
|
433
494
|
struct dqblk c_dqb;
|
434
495
|
|
435
496
|
rb_diskquota_get(dqb, &c_dqb);
|
436
497
|
|
437
|
-
if( rb_quotactl(
|
498
|
+
if( rb_quotactl(cmd,c_dev,uid,(caddr_t)(&c_dqb)) == -1 ){
|
438
499
|
rb_sys_fail("quotactl");
|
439
|
-
}
|
500
|
+
}
|
440
501
|
|
441
502
|
return Qnil;
|
442
|
-
}
|
503
|
+
}
|
504
|
+
|
505
|
+
static VALUE
|
506
|
+
rb_quota_setquota(VALUE self, VALUE dev, VALUE uid, VALUE dqb)
|
507
|
+
{
|
508
|
+
return __rb_quota_set(self,dev,uid,dqb,Q_SETQUOTA);
|
509
|
+
}
|
443
510
|
|
444
511
|
static VALUE
|
445
512
|
rb_quota_setqlim(VALUE self, VALUE dev, VALUE uid, VALUE dqb)
|
446
513
|
{
|
447
514
|
#ifdef Q_SETQLIM
|
448
|
-
|
449
|
-
struct dqblk c_dqb;
|
450
|
-
|
451
|
-
rb_diskquota_get(dqb, &c_dqb);
|
452
|
-
|
453
|
-
if( rb_quotactl(Q_SETQLIM,c_dev,uid,(caddr_t)(&c_dqb)) == -1 ){
|
454
|
-
rb_sys_fail("quotactl");
|
455
|
-
};
|
456
|
-
|
457
|
-
#ifdef DEBUG
|
458
|
-
printf("bhardlimit = %d\n",c_dqb.dqb_bhardlimit);
|
459
|
-
#endif
|
515
|
+
return __rb_quota_set(self,dev,uid,dqb,Q_SETQLIM);
|
460
516
|
#else
|
461
517
|
rb_raise(rb_eQuotaError, "the system don't have Q_SETQLIM");
|
462
518
|
#endif
|
463
519
|
return Qnil;
|
464
|
-
}
|
520
|
+
}
|
465
521
|
|
466
522
|
static VALUE
|
467
|
-
|
523
|
+
rb_quota_setuse(VALUE self, VALUE dev, VALUE uid, VALUE dqb)
|
468
524
|
{
|
469
|
-
|
525
|
+
#ifdef Q_SETUSE
|
526
|
+
return __rb_quota_set(self,dev,uid,dqb,Q_SETUSE);
|
527
|
+
#else
|
528
|
+
rb_raise(rb_eQuotaError, "the system don't have Q_SETUSE");
|
529
|
+
#endif
|
530
|
+
return Qnil;
|
531
|
+
}
|
470
532
|
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
c_dev = STR2CSTR(dev);
|
476
|
-
};
|
533
|
+
static VALUE
|
534
|
+
rb_quota_sync(VALUE self, VALUE dev)
|
535
|
+
{
|
536
|
+
char *c_dev = (dev == Qnil) ? NULL : STR2CSTR(dev);
|
477
537
|
|
478
538
|
if( rb_quotactl(Q_SYNC,c_dev,Qnil,NULL) == -1 ){ /* uid and addr are ignored */
|
479
539
|
rb_sys_fail("quotactl");
|
480
|
-
}
|
540
|
+
}
|
481
541
|
|
482
542
|
return Qnil;
|
483
|
-
}
|
543
|
+
}
|
484
544
|
|
485
545
|
void
|
486
546
|
Init_quota()
|
@@ -528,7 +588,7 @@ Init_quota()
|
|
528
588
|
DQ_ALIAS(fsoftlimit=, isoftlimit=);
|
529
589
|
DQ_ALIAS(curfiles=, curinodes=);
|
530
590
|
DQ_ALIAS(ftimelimit=, itimelimit=);
|
531
|
-
#if defined(
|
591
|
+
#if !defined(USE_LINUX_CURBLOCKS)
|
532
592
|
DQ_ALIAS(curspace, curblocks);
|
533
593
|
DQ_ALIAS(curspace=, curblocks=);
|
534
594
|
#endif
|
@@ -540,10 +600,16 @@ Init_quota()
|
|
540
600
|
|
541
601
|
rb_define_const(rb_mQuota, "DiskQuota", rb_sDiskQuota);
|
542
602
|
|
543
|
-
|
544
|
-
|
545
|
-
rb_define_module_function(rb_mQuota,"
|
546
|
-
rb_define_module_function(rb_mQuota,"
|
547
|
-
rb_define_module_function(rb_mQuota,"
|
548
|
-
rb_define_module_function(rb_mQuota,"
|
549
|
-
|
603
|
+
rb_define_const(rb_mQuota, "BlockSize", UINT2NUM(BLOCK2BYTE(1)));
|
604
|
+
|
605
|
+
rb_define_module_function(rb_mQuota, "quotaon", rb_quota_quotaon, 2);
|
606
|
+
rb_define_module_function(rb_mQuota, "quotaoff", rb_quota_quotaoff, 1);
|
607
|
+
rb_define_module_function(rb_mQuota, "getquota", rb_quota_getquota, 2);
|
608
|
+
rb_define_module_function(rb_mQuota, "setquota", rb_quota_setquota, 3);
|
609
|
+
rb_define_module_function(rb_mQuota, "setqlim", rb_quota_setqlim, 3);
|
610
|
+
rb_define_module_function(rb_mQuota, "setuse", rb_quota_setuse, 3);
|
611
|
+
rb_define_module_function(rb_mQuota, "sync", rb_quota_sync, 1);
|
612
|
+
|
613
|
+
rb_alias(CLASS_OF(rb_mQuota), rb_intern("setlimit"), rb_intern("setqlim"));
|
614
|
+
rb_alias(CLASS_OF(rb_mQuota), rb_intern("setusage"), rb_intern("setuse"));
|
615
|
+
}
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 8
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.8.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Takaaki Tateishi, Alex Beregszaszi
|
@@ -14,12 +14,12 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-
|
17
|
+
date: 2012-05-16 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
21
|
-
description: Ruby-quota is a Ruby extension providing access to filesystem quota. Supported systems Linux, FreeBSD, NetBSD, Dragonfly BSD, Solaris and Mac OS X.
|
22
|
-
email: ttate@jaist.ac.jp
|
21
|
+
description: Ruby-quota is a Ruby extension providing access to filesystem quota. Supported systems Linux, FreeBSD, NetBSD, OpenBSD, Dragonfly BSD, Solaris and Mac OS X.
|
22
|
+
email: ttate@jaist.ac.jp alex@rtfs.hu
|
23
23
|
executables: []
|
24
24
|
|
25
25
|
extensions:
|
@@ -28,7 +28,7 @@ extra_rdoc_files: []
|
|
28
28
|
|
29
29
|
files:
|
30
30
|
- COPYING
|
31
|
-
- README
|
31
|
+
- README.md
|
32
32
|
- MANIFEST
|
33
33
|
- ChangeLog
|
34
34
|
- test.rb
|
data/README
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
Ruby/Quota
|
2
|
-
|
3
|
-
-------------------------------------------------------------------------------
|
4
|
-
This module provides functions which manipulate disk quotas.
|
5
|
-
-------------------------------------------------------------------------------
|
6
|
-
|
7
|
-
SUPPORTED ENVIRONMENT
|
8
|
-
|
9
|
-
* Linux 2.4.x, 2.6.x
|
10
|
-
* Solaris 2.6, 7, 8
|
11
|
-
* FreeBSD
|
12
|
-
* NetBSD
|
13
|
-
* Dragonfly BSD
|
14
|
-
* Mac OS X
|
15
|
-
|
16
|
-
UNTESTED
|
17
|
-
|
18
|
-
* OpenBSD
|
19
|
-
|
20
|
-
-------------------------------------------------------------------------------
|
21
|
-
|
22
|
-
SYNOPSIS
|
23
|
-
|
24
|
-
|
25
|
-
Quota::GroupID.new(id)
|
26
|
-
Quota::GroupID[id]
|
27
|
-
Quota::UserID.new(id)
|
28
|
-
Quota::UserID[id]
|
29
|
-
|
30
|
-
Quota.quotaon(dev, quotas)
|
31
|
-
Quota.quotaoff(dev)
|
32
|
-
Quota.getquota(dev, uid)
|
33
|
-
Quota.setquota(dev, uid, dq)
|
34
|
-
Quota.setqlim(dev, uid, dq) # *BSD does not have this function.
|
35
|
-
Quota.sync(dev)
|
36
|
-
|
37
|
-
* 'dev' is a device file or a mount point (e.g. /dev/hda0, /mnt/foo). On *
|
38
|
-
BSD, this library will try to find a mounted directory from a given filesystem
|
39
|
-
using getmntinfo().
|
40
|
-
|
41
|
-
* 'quotas' is a quotas file.
|
42
|
-
|
43
|
-
* 'uid' can be a integer, in this case it is treated as a user id. If it is
|
44
|
-
a UserID or a GroupID object, it will be treated as desired.
|
45
|
-
|
46
|
-
* 'dq' is an entry of the quotas. its members are same as 'dqblk' structure
|
47
|
-
(e.g. dqb_curblocks => dq.curblocks). see also the quotactl man pages and
|
48
|
-
header files (e.g. linux/quota.h).
|