| @@ -1,47 +1,110 @@ | | | @@ -1,47 +1,110 @@ |
1 | $NetBSD: patch-ab,v 1.4 2006/09/24 15:40:38 joerg Exp $ | | 1 | $NetBSD: patch-ab,v 1.5 2009/10/27 15:29:33 taca Exp $ |
2 | | | 2 | |
3 | --- quota.c.orig 2002-03-30 14:59:12.000000000 +0000 | | 3 | --- quota.c.orig 2002-03-30 23:59:12.000000000 +0900 |
4 | +++ quota.c | | 4 | +++ quota.c |
5 | @@ -51,6 +51,12 @@ | | 5 | @@ -5,9 +5,13 @@ |
| | | 6 | |
| | | 7 | #include "ruby.h" |
| | | 8 | |
| | | 9 | -#define RUBY_QUOTA_VERSION "0.4.1" |
| | | 10 | +#define RUBY_QUOTA_VERSION "0.5.1" |
| | | 11 | |
| | | 12 | -#ifdef HAVE_LINUX_QUOTA_H /* for linux-2.4.x */ |
| | | 13 | +#ifdef HAVE_UNISTD_H |
| | | 14 | +#include <unistd.h> |
| | | 15 | +#endif |
| | | 16 | + |
| | | 17 | +#ifdef HAVE_LINUX_QUOTA_H /* for linux */ |
| | | 18 | # define USE_LINUX_QUOTA |
| | | 19 | #endif |
| | | 20 | #ifdef HAVE_SYS_FS_UFS_QUOTA_H /* for Solaris-2.6,7,8 */ |
| | | 21 | @@ -29,10 +33,16 @@ |
| | | 22 | # include <sys/quota.h> |
| | | 23 | #endif |
| | | 24 | #include <linux/version.h> |
| | | 25 | -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) |
| | | 26 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) |
| | | 27 | +# define USE_LINUX_QUOTA_26 |
| | | 28 | +# define qid_t uid_t |
| | | 29 | +# define dqblk if_dqblk |
| | | 30 | +#else |
| | | 31 | +# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) |
| | | 32 | # define USE_LINUX_QUOTA_24 |
| | | 33 | # define uid_t qid_t |
| | | 34 | # define dqblk disk_dqblk |
| | | 35 | +# endif |
| | | 36 | #endif |
| | | 37 | #endif |
| | | 38 | |
| | | 39 | @@ -51,6 +61,12 @@ |
6 | #if defined(SYS_UCRED_H) | | 40 | #if defined(SYS_UCRED_H) |
7 | # include <sys/ucred.h> /* required by NetBSD,FreeBSD */ | | 41 | # include <sys/ucred.h> /* required by NetBSD,FreeBSD */ |
8 | #endif | | 42 | #endif |
9 | +#if defined(__DragonFly__) | | 43 | +#if defined(__DragonFly__) |
10 | +# include <sys/param.h> | | 44 | +# include <sys/param.h> |
11 | +# if __DragonFly_version >= 160000 | | 45 | +# if __DragonFly_version >= 160000 |
12 | +# define dqblk ufs_dqblk | | 46 | +# define dqblk ufs_dqblk |
13 | +# endif | | 47 | +# endif |
14 | +#endif | | 48 | +#endif |
15 | #endif | | 49 | #endif |
16 | | | 50 | |
17 | static VALUE rb_mQuota; | | 51 | static VALUE rb_mQuota; |
18 | @@ -159,7 +165,11 @@ rb_quotactl(int cmd, char *dev, VALUE vu | | 52 | @@ -159,7 +175,11 @@ rb_quotactl(int cmd, char *dev, VALUE vu |
19 | char *path; | | 53 | char *path; |
20 | int is_gid; | | 54 | int is_gid; |
21 | uid_t uid; | | 55 | uid_t uid; |
22 | +#if defined(HAVE_SYS_STATVFS_H) && !defined(__DragonFly__) | | 56 | +#if defined(HAVE_SYS_STATVFS_H) && !defined(__DragonFly__) |
23 | + struct statvfs *buff; | | 57 | + struct statvfs *buff; |
24 | +#else | | 58 | +#else |
25 | struct statfs *buff; | | 59 | struct statfs *buff; |
26 | +#endif | | 60 | +#endif |
27 | int i, count, ret; | | 61 | int i, count, ret; |
28 | | | 62 | |
29 | buff = 0; | | 63 | buff = 0; |
30 | @@ -187,12 +197,16 @@ rb_quotactl(int cmd, char *dev, VALUE vu | | 64 | @@ -187,12 +207,16 @@ rb_quotactl(int cmd, char *dev, VALUE vu |
31 | static int | | 65 | static int |
32 | rb_quotactl(int cmd, char *dev, VALUE vuid, caddr_t addr) | | 66 | rb_quotactl(int cmd, char *dev, VALUE vuid, caddr_t addr) |
33 | { | | 67 | { |
34 | - struct quotctl qctl = {cmd, uid, addr}; | | 68 | - struct quotctl qctl = {cmd, uid, addr}; |
35 | + struct quotctl qctl; | | 69 | + struct quotctl qctl; |
36 | int fd; | | 70 | int fd; |
37 | uid_t uid; | | 71 | uid_t uid; |
38 | | | 72 | |
39 | get_uid(vuid, &uid, 0); | | 73 | get_uid(vuid, &uid, 0); |
40 | | | 74 | |
41 | + qctl.op = cmd; | | 75 | + qctl.op = cmd; |
42 | + qctl.uid = uid; | | 76 | + qctl.uid = uid; |
43 | + qctl.addr = addr; | | 77 | + qctl.addr = addr; |
44 | + | | 78 | + |
45 | switch( cmd ){ | | 79 | switch( cmd ){ |
46 | case Q_QUOTAON: | | 80 | case Q_QUOTAON: |
47 | case Q_QUOTAOFF: | | 81 | case Q_QUOTAOFF: |
| | | 82 | @@ -235,7 +259,9 @@ rb_diskquota_get(VALUE dqb, struct dqblk |
| | | 83 | #if defined(USE_LINUX_QUOTA) |
| | | 84 | c_dqb->dqb_bhardlimit = GetMember("bhardlimit"); |
| | | 85 | c_dqb->dqb_bsoftlimit = GetMember("bsoftlimit"); |
| | | 86 | -#if !defined(USE_LINUX_QUOTA_24) |
| | | 87 | +#if defined(USE_LINUX_QUOTA_24) || defined(USE_LINUX_QUOTA_26) |
| | | 88 | + c_dqb->dqb_curspace = GetMember("curspace"); |
| | | 89 | +#else |
| | | 90 | c_dqb->dqb_curblocks = GetMember("curblocks"); |
| | | 91 | #endif |
| | | 92 | c_dqb->dqb_ihardlimit = GetMember("ihardlimit"); |
| | | 93 | @@ -274,7 +300,7 @@ rb_diskquota_new(struct dqblk *c_dqb) |
| | | 94 | dqb = rb_struct_new(rb_sDiskQuota, |
| | | 95 | UINT2NUM(c_dqb->dqb_bhardlimit), |
| | | 96 | UINT2NUM(c_dqb->dqb_bsoftlimit), |
| | | 97 | -#if defined(USE_LINUX_QUOTA_24) |
| | | 98 | +#if defined(USE_LINUX_QUOTA_24) || defined(USE_LINUX_QUOTA_26) |
| | | 99 | UINT2NUM(c_dqb->dqb_curspace), |
| | | 100 | #else |
| | | 101 | UINT2NUM(c_dqb->dqb_curblocks), |
| | | 102 | @@ -454,7 +480,7 @@ Init_quota() |
| | | 103 | DQ_ALIAS(fsoftlimit=, isoftlimit=); |
| | | 104 | DQ_ALIAS(curfiles=, curinodes=); |
| | | 105 | DQ_ALIAS(ftimelimit=, itimelimit=); |
| | | 106 | -#if defined(USE_LINUX_QUOTA_24) |
| | | 107 | +#if defined(USE_LINUX_QUOTA_24) || defined(USE_LINUX_QUOTA_26) |
| | | 108 | DQ_ALIAS(curspace, curblocks); |
| | | 109 | DQ_ALIAS(curspace=, curblocks=); |
| | | 110 | #endif |