From e133a5e9fca8e4e582a9ec4f76bc2e6764311b58 Mon Sep 17 00:00:00 2001 From: dholland Date: Sat, 12 May 2012 23:10:29 +0000 Subject: Fix build on netbsd-6 and up. --- sysutils/ruby-quota/distinfo | 6 +- sysutils/ruby-quota/patches/patch-aa | 17 +- sysutils/ruby-quota/patches/patch-ab | 370 +++++++++++++++++++++++++++++++++-- 3 files changed, 369 insertions(+), 24 deletions(-) (limited to 'sysutils') diff --git a/sysutils/ruby-quota/distinfo b/sysutils/ruby-quota/distinfo index 435d8b210b7..f145ae17c91 100644 --- a/sysutils/ruby-quota/distinfo +++ b/sysutils/ruby-quota/distinfo @@ -1,7 +1,7 @@ -$NetBSD: distinfo,v 1.14 2010/09/10 07:58:44 taca Exp $ +$NetBSD: distinfo,v 1.15 2012/05/12 23:10:29 dholland Exp $ SHA1 (ruby-quota-0.5.1.tar.gz) = 9edf6054c465af80d7a3534b8fed89fbafc01ec1 RMD160 (ruby-quota-0.5.1.tar.gz) = 85189827a256d0cfeaa0e755db37b85c625c18df Size (ruby-quota-0.5.1.tar.gz) = 5110 bytes -SHA1 (patch-aa) = 651521b6e9945320623f9c8abff27b705bb476b6 -SHA1 (patch-ab) = fa97c6cf71cc8b7144ee8f76ba9f00e28d0855fb +SHA1 (patch-aa) = 6fed720916737852bcc89608708f38fe7260033b +SHA1 (patch-ab) = 0977d6a6d14ffd69967f5d2ef280a714f8030eb5 diff --git a/sysutils/ruby-quota/patches/patch-aa b/sysutils/ruby-quota/patches/patch-aa index da3812411de..7d969f1c2ac 100644 --- a/sysutils/ruby-quota/patches/patch-aa +++ b/sysutils/ruby-quota/patches/patch-aa @@ -1,6 +1,10 @@ -$NetBSD: patch-aa,v 1.2 2009/10/27 15:29:33 taca Exp $ +$NetBSD: patch-aa,v 1.3 2012/05/12 23:10:30 dholland Exp $ ---- extconf.rb.orig 2002-03-21 03:09:14.000000000 +0900 +- need unistd.h for some things, so test for it (just in case it's not there, I guess) +- check for statvfs.h for netbsd-3 and up +- add support for netbsd-6 and up quotas + +--- extconf.rb.orig 2002-03-20 18:09:14.000000000 +0000 +++ extconf.rb @@ -7,6 +7,8 @@ @@ -11,9 +15,14 @@ $NetBSD: patch-aa,v 1.2 2009/10/27 15:29:33 taca Exp $ have_header("linux/quota.h") # for linux have_header("linux/types.h") have_header("sys/quota.h") -@@ -16,5 +18,6 @@ have_header("sys/fs/ufs_quota.h") # for +@@ -14,7 +16,10 @@ have_header("sys/types.h") + + have_header("sys/fs/ufs_quota.h") # for solaris - have_header("ufs/ufs/quota.h") # for *bsd +-have_header("ufs/ufs/quota.h") # for *bsd ++have_header("quota.h") # for netbsd-6 and up ++ ++have_header("ufs/ufs/quota.h") # for traditional *bsd have_header("sys/ucred.h") # required by FreeBSD and NetBSD +have_header("sys/statvfs.h") # required by NetBSD diff --git a/sysutils/ruby-quota/patches/patch-ab b/sysutils/ruby-quota/patches/patch-ab index e7ff1c51f79..6eab0d737d0 100644 --- a/sysutils/ruby-quota/patches/patch-ab +++ b/sysutils/ruby-quota/patches/patch-ab @@ -1,8 +1,19 @@ -$NetBSD: patch-ab,v 1.9 2010/09/10 07:58:45 taca Exp $ +$NetBSD: patch-ab,v 1.10 2012/05/12 23:10:30 dholland Exp $ + +- fix package's version number +- remove a debug printout +- need unistd.h for some things +- support dragonfly +- support linux 2.6+ with slightly different API +- support netbsd-3+ with statvfs +- support netbsd-6+ with libquota +- fix solaris code +- ruby API fixes +- ...? --- quota.c.orig 2002-03-30 14:59:12.000000000 +0000 +++ quota.c -@@ -5,9 +5,13 @@ +@@ -5,17 +5,25 @@ #include "ruby.h" @@ -18,7 +29,20 @@ $NetBSD: patch-ab,v 1.9 2010/09/10 07:58:45 taca Exp $ # define USE_LINUX_QUOTA #endif #ifdef HAVE_SYS_FS_UFS_QUOTA_H /* for Solaris-2.6,7,8 */ -@@ -29,10 +33,16 @@ + # define USE_SOLARIS_QUOTA + #endif +-#ifdef HAVE_UFS_UFS_QUOTA_H /* for *BSD */ ++#ifdef HAVE_QUOTA_H /* for NetBSD-6 and up */ ++# define USE_NETBSD_QUOTA ++#else ++#ifdef HAVE_UFS_UFS_QUOTA_H /* for traditional *BSD */ + # define USE_BSD_QUOTA + #endif ++#endif + + #ifdef USE_LINUX_QUOTA + #ifdef HAVE_LINUX_TYPES_H +@@ -29,10 +37,16 @@ # include #endif #include @@ -36,7 +60,20 @@ $NetBSD: patch-ab,v 1.9 2010/09/10 07:58:45 taca Exp $ #endif #endif -@@ -51,6 +61,12 @@ +@@ -42,6 +56,12 @@ + #include + #endif + ++#ifdef USE_NETBSD_QUOTA ++#include ++#include ++#include ++#endif ++ + #ifdef USE_BSD_QUOTA + #include + #include +@@ -51,6 +71,12 @@ #if defined(SYS_UCRED_H) # include /* required by NetBSD,FreeBSD */ #endif @@ -49,7 +86,7 @@ $NetBSD: patch-ab,v 1.9 2010/09/10 07:58:45 taca Exp $ #endif static VALUE rb_mQuota; -@@ -144,7 +160,6 @@ rb_quotactl(int cmd, char *dev, VALUE vu +@@ -144,7 +170,6 @@ rb_quotactl(int cmd, char *dev, VALUE vu uid_t uid; get_uid(vuid, &uid, &is_gid); @@ -57,7 +94,15 @@ $NetBSD: patch-ab,v 1.9 2010/09/10 07:58:45 taca Exp $ if( is_gid ){ return quotactl(QCMD(cmd,GRPQUOTA),dev,(qid_t)uid,addr); } -@@ -159,7 +174,11 @@ rb_quotactl(int cmd, char *dev, VALUE vu +@@ -152,14 +177,18 @@ rb_quotactl(int cmd, char *dev, VALUE vu + return quotactl(QCMD(cmd,USRQUOTA),dev,(qid_t)uid,addr); + }; + }; +-#elif defined(USE_BSD_QUOTA) /* for *BSD */ ++#elif defined(USE_BSD_QUOTA) /* for traditional *BSD */ + static int + rb_quotactl(int cmd, char *dev, VALUE vuid, caddr_t addr) + { char *path; int is_gid; uid_t uid; @@ -69,7 +114,7 @@ $NetBSD: patch-ab,v 1.9 2010/09/10 07:58:45 taca Exp $ int i, count, ret; buff = 0; -@@ -187,12 +206,16 @@ rb_quotactl(int cmd, char *dev, VALUE vu +@@ -187,12 +216,16 @@ rb_quotactl(int cmd, char *dev, VALUE vu static int rb_quotactl(int cmd, char *dev, VALUE vuid, caddr_t addr) { @@ -87,7 +132,204 @@ $NetBSD: patch-ab,v 1.9 2010/09/10 07:58:45 taca Exp $ switch( cmd ){ case Q_QUOTAON: case Q_QUOTAOFF: -@@ -230,12 +253,20 @@ rb_diskquota_get(VALUE dqb, struct dqblk +@@ -225,17 +258,217 @@ rb_quotactl(int cmd, char *dev, VALUE vu + }; + #endif + ++#ifdef USE_NETBSD_QUOTA ++ ++static struct quotahandle * ++rb_quotaopen(char *dev) ++{ ++ char *path; ++#if defined(HAVE_SYS_STATVFS_H) && !defined(__DragonFly__) ++ struct statvfs *buff; ++#else ++ struct statfs *buff; ++#endif ++ int i, count; ++ ++ buff = 0; ++ path = dev; ++ count = getmntinfo(&buff, MNT_WAIT); ++ for( i=0; iqv_hardlimit = GetMemberU("bhardlimit"); ++ c_blocks->qv_softlimit = GetMemberU("bsoftlimit"); ++ c_blocks->qv_usage = GetMemberU("curblocks"); ++ c_blocks->qv_expiretime = GetMemberS("btimelimit"); ++ c_blocks->qv_grace = GetMemberS("bgrace"); ++ c_files->qv_hardlimit = GetMemberU("ihardlimit"); ++ c_files->qv_softlimit = GetMemberU("isoftlimit"); ++ c_files->qv_usage = GetMemberU("curinodes"); ++ c_files->qv_expiretime = GetMemberS("itimelimit"); ++ c_files->qv_grace = GetMemberS("igrace"); ++ ++#undef GetMemberU ++#undef GetMemberS ++} ++ ++VALUE ++rb_diskquota_new(struct quotaval *c_blocks, struct quotaval *c_files) ++{ ++ VALUE dqb; ++ ++ dqb = rb_struct_new(rb_sDiskQuota, ++ ULL2NUM(c_blocks->qv_hardlimit), ++ ULL2NUM(c_blocks->qv_softlimit), ++ ULL2NUM(c_blocks->qv_usage), ++ ULL2NUM(c_files->qv_hardlimit), ++ ULL2NUM(c_files->qv_softlimit), ++ ULL2NUM(c_files->qv_usage), ++ LL2NUM(c_blocks->qv_expiretime), ++ LL2NUM(c_files->qv_expiretime), ++#if 0 /* not yet */ ++ LL2NUM(c_blocks->qv_grace), ++ LL2NUM(c_files->qv_grace), ++#endif ++ 0); ++ return dqb; ++} ++ ++#else /* not USE_NETBSD_QUOTA */ ++ + void + rb_diskquota_get(VALUE dqb, struct dqblk * c_dqb) { VALUE v; @@ -109,7 +351,7 @@ $NetBSD: patch-ab,v 1.9 2010/09/10 07:58:45 taca Exp $ c_dqb->dqb_curblocks = GetMember("curblocks"); #endif c_dqb->dqb_ihardlimit = GetMember("ihardlimit"); -@@ -271,20 +302,29 @@ rb_diskquota_new(struct dqblk *c_dqb) +@@ -271,20 +504,29 @@ rb_diskquota_new(struct dqblk *c_dqb) VALUE dqb; #if defined(USE_LINUX_QUOTA) @@ -143,25 +385,71 @@ $NetBSD: patch-ab,v 1.9 2010/09/10 07:58:45 taca Exp $ #elif defined(USE_BSD_QUOTA) dqb = rb_struct_new(rb_sDiskQuota, UINT2NUM(c_dqb->dqb_bhardlimit), -@@ -314,7 +354,7 @@ rb_diskquota_new(struct dqblk *c_dqb) +@@ -296,7 +538,7 @@ rb_diskquota_new(struct dqblk *c_dqb) + UINT2NUM(c_dqb->dqb_btime), + UINT2NUM(c_dqb->dqb_itime), + 0); +-#elif defined(USE_SOLARIS) ++#elif defined(USE_SOLARIS_QUOTA) + dqb = rb_struct_new(rb_sDiskQuota, + UINT2NUM(c_dqb->dqb_bhardlimit), + UINT2NUM(c_dqb->dqb_bsoftlimit), +@@ -311,18 +553,34 @@ rb_diskquota_new(struct dqblk *c_dqb) + return dqb; + }; + ++#endif /* USE_NETBSD_QUOTA */ ++ static VALUE rb_quota_getquota(VALUE self, VALUE dev, VALUE uid) { - char *c_dev = STR2CSTR(dev); + char *c_dev = StringValuePtr(dev); ++#ifdef USE_NETBSD_QUOTA ++ struct quotaval c_blocks, c_files; ++#else struct dqblk c_dqb; ++#endif VALUE dqb = Qnil; -@@ -330,7 +370,7 @@ rb_quota_getquota(VALUE self, VALUE dev, ++#ifdef USE_NETBSD_QUOTA ++ if( rb_quotaget(c_dev, uid, &c_blocks, &c_files) == -1 ){ ++ rb_sys_fail("quota_get"); ++ }; ++#else + if( rb_quotactl(Q_GETQUOTA,c_dev,uid,(caddr_t)(&c_dqb)) == -1 ){ + rb_sys_fail("quotactl"); + }; ++#endif + ++#ifdef USE_NETBSD_QUOTA ++ dqb = rb_diskquota_new(&c_blocks, &c_files); ++#else + dqb = rb_diskquota_new(&c_dqb); ++#endif + + return dqb; + }; +@@ -330,11 +588,17 @@ rb_quota_getquota(VALUE self, VALUE dev, VALUE rb_quota_quotaoff(VALUE self, VALUE dev) { - char *c_dev = STR2CSTR(dev); + char *c_dev = StringValuePtr(dev); ++#ifdef USE_NETBSD_QUOTA ++ if( rb_quotaoff(c_dev) == -1 ){ ++ rb_sys_fail("quota_quotaoff"); ++ }; ++#else if( rb_quotactl(Q_QUOTAOFF,c_dev,Qnil,NULL) == -1 ){ rb_sys_fail("quotactl"); -@@ -342,8 +382,8 @@ rb_quota_quotaoff(VALUE self, VALUE dev) + }; ++#endif + + return Qnil; + }; +@@ -342,12 +606,20 @@ rb_quota_quotaoff(VALUE self, VALUE dev) VALUE rb_quota_quotaon(VALUE self, VALUE dev, VALUE quotas) { @@ -170,18 +458,51 @@ $NetBSD: patch-ab,v 1.9 2010/09/10 07:58:45 taca Exp $ + char *c_dev = StringValuePtr(dev); + char *c_quotas = StringValuePtr(quotas); ++#ifdef USE_NETBSD_QUOTA ++ /* ignore the quota file names - they must be placed in /etc/fstab */ ++ (void)quotas; ++ if( rb_quotaon(c_dev) == -1 ){ ++ rb_sys_fail("quota_quotaon"); ++ }; ++#else if( rb_quotactl(Q_QUOTAON,c_dev,Qnil,(caddr_t)c_quotas) == -1 ){ rb_sys_fail("quotactl"); -@@ -355,7 +395,7 @@ rb_quota_quotaon(VALUE self, VALUE dev, + }; ++#endif + + return Qnil; + }; +@@ -355,14 +627,28 @@ rb_quota_quotaon(VALUE self, VALUE dev, VALUE rb_quota_setquota(VALUE self, VALUE dev, VALUE uid, VALUE dqb) { - char *c_dev = STR2CSTR(dev); + char *c_dev = StringValuePtr(dev); ++#ifdef USE_NETBSD_QUOTA ++ struct quotaval c_qvb, c_qvf; ++#else struct dqblk c_dqb; ++#endif ++#ifdef USE_NETBSD_QUOTA ++ rb_diskquota_get(dqb, &c_qvb, &c_qvf); ++#else rb_diskquota_get(dqb, &c_dqb); -@@ -371,7 +411,7 @@ VALUE ++#endif + ++#ifdef USE_NETBSD_QUOTA ++ if( rb_quotaput(c_dev,uid,&c_qvb, &c_qvf) == -1 ){ ++ rb_sys_fail("quota_put"); ++ }; ++#else + if( rb_quotactl(Q_SETQUOTA,c_dev,uid,(caddr_t)(&c_dqb)) == -1 ){ + rb_sys_fail("quotactl"); + }; ++#endif + + return Qnil; + }; +@@ -371,7 +657,7 @@ VALUE rb_quota_setqlim(VALUE self, VALUE dev, VALUE uid, VALUE dqb) { #ifdef Q_SETQLIM @@ -190,7 +511,16 @@ $NetBSD: patch-ab,v 1.9 2010/09/10 07:58:45 taca Exp $ struct dqblk c_dqb; rb_diskquota_get(dqb, &c_dqb); -@@ -398,7 +438,7 @@ rb_quota_sync(VALUE self, VALUE dev) +@@ -392,18 +678,22 @@ rb_quota_setqlim(VALUE self, VALUE dev, + VALUE + rb_quota_sync(VALUE self, VALUE dev) + { ++#ifdef USE_NETBSD_QUOTA ++ /* nothing */ ++#else + char *c_dev; + + if( dev == Qnil ){ c_dev = NULL; } else{ @@ -199,7 +529,13 @@ $NetBSD: patch-ab,v 1.9 2010/09/10 07:58:45 taca Exp $ }; if( rb_quotactl(Q_SYNC,c_dev,Qnil,NULL) == -1 ){ /* uid and addr are ignored */ -@@ -442,7 +482,7 @@ Init_quota() + rb_sys_fail("quotactl"); + }; ++#endif /* USE_NETBSD_QUOTA */ + + return Qnil; + }; +@@ -442,7 +732,7 @@ Init_quota() "curinodes", "btimelimit", "itimelimit", @@ -208,7 +544,7 @@ $NetBSD: patch-ab,v 1.9 2010/09/10 07:58:45 taca Exp $ /* for compatibility */ #define DQ_ALIAS(a,b) rb_alias(rb_sDiskQuota,rb_intern(#a),rb_intern(#b)) -@@ -454,7 +494,7 @@ Init_quota() +@@ -454,7 +744,7 @@ Init_quota() DQ_ALIAS(fsoftlimit=, isoftlimit=); DQ_ALIAS(curfiles=, curinodes=); DQ_ALIAS(ftimelimit=, itimelimit=); -- cgit v1.2.3