$NetBSD: patch-ab,v 1.5 2009/10/27 15:29:33 taca Exp $

--- quota.c.orig	2002-03-30 23:59:12.000000000 +0900
+++ quota.c
@@ -5,9 +5,13 @@
 
 #include "ruby.h"
 
-#define RUBY_QUOTA_VERSION "0.4.1"
+#define RUBY_QUOTA_VERSION "0.5.1"
 
-#ifdef HAVE_LINUX_QUOTA_H       /* for linux-2.4.x */
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_LINUX_QUOTA_H       /* for linux */
 # define USE_LINUX_QUOTA
 #endif
 #ifdef HAVE_SYS_FS_UFS_QUOTA_H  /* for Solaris-2.6,7,8 */
@@ -29,10 +33,16 @@
 #  include <sys/quota.h>
 #endif
 #include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#  define USE_LINUX_QUOTA_26
+#  define qid_t uid_t
+#  define dqblk if_dqblk
+#else
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 #  define USE_LINUX_QUOTA_24
 #  define uid_t qid_t
 #  define dqblk disk_dqblk
+# endif
 #endif
 #endif
 
@@ -51,6 +61,12 @@
 #if defined(SYS_UCRED_H)
 # include <sys/ucred.h>  /* required by NetBSD,FreeBSD */
 #endif
+#if defined(__DragonFly__)
+#  include <sys/param.h>
+#  if __DragonFly_version >= 160000
+#    define dqblk ufs_dqblk
+#  endif
+#endif
 #endif
 
 static VALUE rb_mQuota;
@@ -159,7 +175,11 @@ rb_quotactl(int cmd, char *dev, VALUE vu
   char *path;
   int is_gid;
   uid_t uid;
+#if defined(HAVE_SYS_STATVFS_H) && !defined(__DragonFly__)
+  struct statvfs *buff;
+#else
   struct statfs *buff;
+#endif
   int i, count, ret;
   
   buff = 0;
@@ -187,12 +207,16 @@ rb_quotactl(int cmd, char *dev, VALUE vu
 static int
 rb_quotactl(int cmd, char *dev, VALUE vuid, caddr_t addr)
 {
-  struct quotctl qctl = {cmd, uid, addr};
+  struct quotctl qctl;
   int fd;
   uid_t uid;
 
   get_uid(vuid, &uid, 0);
 
+  qctl.op = cmd;
+  qctl.uid = uid;
+  qctl.addr = addr;
+
   switch( cmd ){
   case Q_QUOTAON:
   case Q_QUOTAOFF:
@@ -235,7 +259,9 @@ rb_diskquota_get(VALUE dqb, struct dqblk
 #if defined(USE_LINUX_QUOTA)
   c_dqb->dqb_bhardlimit = GetMember("bhardlimit");
   c_dqb->dqb_bsoftlimit = GetMember("bsoftlimit");
-#if !defined(USE_LINUX_QUOTA_24)
+#if defined(USE_LINUX_QUOTA_24) || defined(USE_LINUX_QUOTA_26)
+  c_dqb->dqb_curspace  = GetMember("curspace");
+#else
   c_dqb->dqb_curblocks  = GetMember("curblocks");
 #endif
   c_dqb->dqb_ihardlimit = GetMember("ihardlimit");
@@ -274,7 +300,7 @@ rb_diskquota_new(struct dqblk *c_dqb)
   dqb = rb_struct_new(rb_sDiskQuota,
 		      UINT2NUM(c_dqb->dqb_bhardlimit),
 		      UINT2NUM(c_dqb->dqb_bsoftlimit),
-#if defined(USE_LINUX_QUOTA_24)
+#if defined(USE_LINUX_QUOTA_24) || defined(USE_LINUX_QUOTA_26)
 		      UINT2NUM(c_dqb->dqb_curspace),
 #else
 		      UINT2NUM(c_dqb->dqb_curblocks),
@@ -454,7 +480,7 @@ Init_quota()
   DQ_ALIAS(fsoftlimit=, isoftlimit=);
   DQ_ALIAS(curfiles=,   curinodes=);
   DQ_ALIAS(ftimelimit=, itimelimit=);
-#if defined(USE_LINUX_QUOTA_24)
+#if defined(USE_LINUX_QUOTA_24) || defined(USE_LINUX_QUOTA_26)
   DQ_ALIAS(curspace, curblocks);
   DQ_ALIAS(curspace=, curblocks=);
 #endif
