[libquota-perl] 01/08: Imported Upstream version 1.7.0+dfsg

Salvatore Bonaccorso carnil at debian.org
Sun Sep 22 20:41:14 UTC 2013


This is an automated email from the git hooks/post-receive script.

carnil pushed a commit to annotated tag debian/1.7.0+dfsg-1
in repository libquota-perl.

commit 42ee19e60876cfb50ec9471dd6236802e4ad7772
Author: Salvatore Bonaccorso <carnil at debian.org>
Date:   Sun Sep 22 22:27:30 2013 +0200

    Imported Upstream version 1.7.0+dfsg
---
 CHANGES           |    7 ++
 META.yml          |    2 +-
 Makefile.PL       |    9 +-
 Quota.pm          |    8 +-
 Quota.xs          |  310 ++++++++++++++++++++++++++++++++++++-----------------
 README            |   10 +-
 hints/aix_4_1.h   |    2 +
 hints/bsd.h       |   15 +++
 hints/dec_osf.h   |    2 +
 hints/hpux.h      |    2 +
 hints/irix_5.h    |    2 +
 hints/irix_6.h    |    2 +
 hints/linux.h     |    6 +-
 hints/none.h      |   14 +++
 hints/solaris_2.h |    2 +
 hints/sunos_4_1.h |    2 +
 16 files changed, 287 insertions(+), 108 deletions(-)

diff --git a/CHANGES b/CHANGES
index 0917266..5152108 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,10 @@
+Changes in 1.7.0 (August 2013)
+- Added support for the new NetBSD 6.0 quota system (libquota)
+  Thanks to David Holland and Edgar Fuss
+- To support limits and usage >= 2^32 on 32-bit clients, Quota::setqlim
+  and Quota::query interfaces were changed to use double (NV) instead
+  of integer (IV). This should be transparent to users of the module.
+
 Changes in 1.6.7 (November 2011)
 - Added support to detect 3.x Linux kernels
   Thanks to Salvatore Bonaccorso of the Debian Perl Group
diff --git a/META.yml b/META.yml
index 087ceed..be44439 100644
--- a/META.yml
+++ b/META.yml
@@ -1,7 +1,7 @@
 --- #YAML:1.0
 name: Quota
 abstract: Quota - Perl interface to file system quotas
-version: 1.6.7
+version: 1.7.0
 author:
   - Tom Zoerner <tomzo at users.sourceforge.net>
 license: perl
diff --git a/Makefile.PL b/Makefile.PL
index 36cdfa3..d139fc0 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -33,6 +33,7 @@ else {
   warn "WARNING: No appropriate hints found for this OS: '$os - see INSTALL'\n";
 }
 
+my $extralibs = "";
 
 # check whether the Andrew File System (AFS) is installed and running
 
@@ -42,7 +43,7 @@ if ( -d "/afs" ) {
     $hasafs = '-DAFSQUOTA';
     $AFSHOME = -d "/usr/afsws" ? "/usr/afsws" : "/usr";
     $extrainc = "-I$AFSHOME/include -I$AFSHOME/include/afs";
-    $extralibs = "-L$AFSHOME/lib -L$AFSHOME/lib/afs -lsys -lrx -lrxkad -llwp";
+    $extralibs .= " -L$AFSHOME/lib -L$AFSHOME/lib/afs -lsys -lrx -lrxkad -llwp";
     $afsquota = "afsquota.o";
   }
 }
@@ -60,6 +61,12 @@ if ( $os =~ /^SunOS/ ) {
    # }
 }
 
+# check whether wee are using the NetBSD quota library
+if ( ($os =~ /^NetBSD 6/) ||
+     (($os =~ /^NetBSD 5\.99\.(\d\d)/) && ($1 >= 59)) ) {
+  $extralibs .= " -lquota";
+}
+
 #-----------------------------------------------------------------------------#
 
 use ExtUtils::MakeMaker;
diff --git a/Quota.pm b/Quota.pm
index 5a12b28..1247381 100644
--- a/Quota.pm
+++ b/Quota.pm
@@ -1,5 +1,5 @@
 # ------------------------------------------------------------------------ #
-# Quota.pm - Copyright (C) 1995-2011 Tom Zoerner
+# Quota.pm - Copyright (C) 1995-2013 Tom Zoerner
 # ------------------------------------------------------------------------ #
 # This program is free software: you can redistribute it and/or modify
 # it either under the terms of the Perl Artistic License or the GNU
@@ -22,7 +22,7 @@ require DynaLoader;
 @ISA = qw(Exporter DynaLoader);
 @EXPORT = ();
 
-$VERSION = '1.6.7';
+$VERSION = '1.7.0';
 
 bootstrap Quota;
 
@@ -226,6 +226,10 @@ this flag is ignored.
 Sets quota limits for the given user. Meanings of I<$dev>, I<$uid>,
 I<$bs>, I<$bh>, I<$is> and I<$ih> are the same as in B<Quota::query>.
 
+For file systems exceeding 2 TB: To allow passing block or inode
+values larger or equal to 2^32 on 32-bit Perl versions, pass them
+either as strings or floating point.
+
 I<$tlo> decides how the time limits are initialized:
 I<0>: The time limits are set to B<NOT STARTED>, i.e. the time limits
 are not initialized until the first write attempt by this user.
diff --git a/Quota.xs b/Quota.xs
index 34b085c..af6af25 100644
--- a/Quota.xs
+++ b/Quota.xs
@@ -58,6 +58,17 @@ static struct
     char          hostname[MAX_MACHINE_NAME + 1];
 } quota_rpc_auth = {-1, -1, {0} };
 
+struct quota_xs_nfs_rslt {
+  double bhard;
+  double bsoft;
+  double bcur;
+  time_t btime;
+  double fhard;
+  double fsoft;
+  double fcur;
+  time_t ftime;
+};
+
 /*
  * fetch quotas from remote host
  */
@@ -135,11 +146,8 @@ callaurpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
 }
 
 int
-getnfsquota(hostp, fsnamep, uid, kind, dqp)
-  char *hostp, *fsnamep;
-  int uid;
-  int kind;
-  struct dqblk *dqp;
+getnfsquota( char *hostp, char *fsnamep, int uid, int kind,
+             struct quota_xs_nfs_rslt *rslt )
 {
   struct getquota_args gq_args;
   struct getquota_rslt gq_rslt;
@@ -151,7 +159,7 @@ getnfsquota(hostp, fsnamep, uid, kind, dqp)
    */
   ext_gq_args.gqa_pathp = fsnamep;
   ext_gq_args.gqa_id = uid;
-  ext_gq_args.gqa_type = ((kind != 0) ? GRPQUOTA : USRQUOTA);
+  ext_gq_args.gqa_type = ((kind != 0) ? GQA_TYPE_GRP : GQA_TYPE_USR);
 
   if (callaurpc(hostp, RQUOTAPROG, EXT_RQUOTAVERS, RQUOTAPROC_GETQUOTA,
                 xdr_ext_getquota_args, &ext_gq_args,
@@ -186,53 +194,55 @@ getnfsquota(hostp, fsnamep, uid, kind, dqp)
        * If you have a mixed environment, you have a problem though.
        * Complain to the Linux authors or apply my patch (see INSTALL)
        */
-      dqp->QS_BHARD = gq_rslt.GQR_RQUOTA.rq_bhardlimit;
-      dqp->QS_BSOFT = gq_rslt.GQR_RQUOTA.rq_bsoftlimit;
-      dqp->QS_BCUR = gq_rslt.GQR_RQUOTA.rq_curblocks;
+      rslt->bhard = gq_rslt.GQR_RQUOTA.rq_bhardlimit;
+      rslt->bsoft = gq_rslt.GQR_RQUOTA.rq_bsoftlimit;
+      rslt->bcur = gq_rslt.GQR_RQUOTA.rq_curblocks;
 #else /* not buggy */
       if (gq_rslt.GQR_RQUOTA.rq_bsize >= DEV_QBSIZE) {
         /* assign first, multiply later:
-        ** so that mult works with the possibly larger type in dqp */
-        dqp->QS_BHARD = gq_rslt.GQR_RQUOTA.rq_bhardlimit;
-        dqp->QS_BSOFT = gq_rslt.GQR_RQUOTA.rq_bsoftlimit;
-        dqp->QS_BCUR = gq_rslt.GQR_RQUOTA.rq_curblocks;
+        ** so that mult works with the possibly larger type in rslt */
+        rslt->bhard = gq_rslt.GQR_RQUOTA.rq_bhardlimit;
+        rslt->bsoft = gq_rslt.GQR_RQUOTA.rq_bsoftlimit;
+        rslt->bcur = gq_rslt.GQR_RQUOTA.rq_curblocks;
 
         /* we rely on the fact that block sizes are always powers of 2 */
         /* so the conversion factor will never be a fraction */
         qb_fac = gq_rslt.GQR_RQUOTA.rq_bsize / DEV_QBSIZE;
-        dqp->QS_BHARD *= qb_fac;
-        dqp->QS_BSOFT *= qb_fac;
-        dqp->QS_BCUR *= qb_fac;
+        rslt->bhard *= qb_fac;
+        rslt->bsoft *= qb_fac;
+        rslt->bcur *= qb_fac;
       }
       else {
         qb_fac = DEV_QBSIZE / gq_rslt.GQR_RQUOTA.rq_bsize;
-        dqp->QS_BHARD = gq_rslt.GQR_RQUOTA.rq_bhardlimit / qb_fac;
-        dqp->QS_BSOFT = gq_rslt.GQR_RQUOTA.rq_bsoftlimit / qb_fac;
-        dqp->QS_BCUR = gq_rslt.GQR_RQUOTA.rq_curblocks / qb_fac;
+        rslt->bhard = gq_rslt.GQR_RQUOTA.rq_bhardlimit / qb_fac;
+        rslt->bsoft = gq_rslt.GQR_RQUOTA.rq_bsoftlimit / qb_fac;
+        rslt->bcur = gq_rslt.GQR_RQUOTA.rq_curblocks / qb_fac;
       }
 #endif /* LINUX_RQUOTAD_BUG */
-      dqp->QS_FHARD = gq_rslt.GQR_RQUOTA.rq_fhardlimit;
-      dqp->QS_FSOFT = gq_rslt.GQR_RQUOTA.rq_fsoftlimit;
-      dqp->QS_FCUR = gq_rslt.GQR_RQUOTA.rq_curfiles;
+      rslt->fhard = gq_rslt.GQR_RQUOTA.rq_fhardlimit;
+      rslt->fsoft = gq_rslt.GQR_RQUOTA.rq_fsoftlimit;
+      rslt->fcur = gq_rslt.GQR_RQUOTA.rq_curfiles;
 
       /* if time is given relative to actual time, add actual time */
       /* Note: all systems except Linux return relative times */
       if (gq_rslt.GQR_RQUOTA.rq_btimeleft == 0)
-        dqp->QS_BTIME = 0;
+        rslt->btime = 0;
       else if (gq_rslt.GQR_RQUOTA.rq_btimeleft + 10*365*24*60*60 < tv.tv_sec)
-        dqp->QS_BTIME = tv.tv_sec + gq_rslt.GQR_RQUOTA.rq_btimeleft;
+        rslt->btime = tv.tv_sec + gq_rslt.GQR_RQUOTA.rq_btimeleft;
       else
-        dqp->QS_BTIME = gq_rslt.GQR_RQUOTA.rq_btimeleft;
+        rslt->btime = gq_rslt.GQR_RQUOTA.rq_btimeleft;
 
       if (gq_rslt.GQR_RQUOTA.rq_ftimeleft == 0)
-        dqp->QS_FTIME = 0;
+        rslt->ftime = 0;
       else if (gq_rslt.GQR_RQUOTA.rq_ftimeleft + 10*365*24*60*60 < tv.tv_sec)
-        dqp->QS_FTIME = tv.tv_sec + gq_rslt.GQR_RQUOTA.rq_ftimeleft;
+        rslt->ftime = tv.tv_sec + gq_rslt.GQR_RQUOTA.rq_ftimeleft;
       else
-        dqp->QS_FTIME = gq_rslt.GQR_RQUOTA.rq_ftimeleft;
+        rslt->ftime = gq_rslt.GQR_RQUOTA.rq_ftimeleft;
 
-      if(dqp->QS_BHARD==0 && dqp->QS_BSOFT==0 &&
-         dqp->QS_FHARD==0 && dqp->QS_FSOFT==0) {
+      if((gq_rslt.GQR_RQUOTA.rq_bhardlimit == 0) &&
+         (gq_rslt.GQR_RQUOTA.rq_bsoftlimit == 0) &&
+         (gq_rslt.GQR_RQUOTA.rq_fhardlimit == 0) &&
+         (gq_rslt.GQR_RQUOTA.rq_fsoftlimit == 0)) {
         errno = ESRCH;
 	return(-1);
       }
@@ -328,13 +338,8 @@ query(dev,uid=getuid(),kind=0)
 	int     kind
 	PPCODE:
 	{
-	  struct dqblk dqblk;
 	  char *p = NULL;
 	  int err;
-#ifdef USE_IOCTL
-	  struct quotactl qp;
-	  int fd = -1;
-#endif
 #ifdef SGI_XFS
 	  if(!strncmp(dev, "(XFS)", 5)) {
 	    fs_disk_quota_t xfs_dqblk;
@@ -345,13 +350,13 @@ query(dev,uid=getuid(),kind=0)
 #endif
 	    if(!err) {
 	      EXTEND(SP, 8);
-	      PUSHs(sv_2mortal(newSViv(QX_DIV(xfs_dqblk.d_bcount))));
-	      PUSHs(sv_2mortal(newSViv(QX_DIV(xfs_dqblk.d_blk_softlimit))));
-	      PUSHs(sv_2mortal(newSViv(QX_DIV(xfs_dqblk.d_blk_hardlimit))));
+	      PUSHs(sv_2mortal(newSVnv(QX_DIV(xfs_dqblk.d_bcount))));
+	      PUSHs(sv_2mortal(newSVnv(QX_DIV(xfs_dqblk.d_blk_softlimit))));
+	      PUSHs(sv_2mortal(newSVnv(QX_DIV(xfs_dqblk.d_blk_hardlimit))));
 	      PUSHs(sv_2mortal(newSViv(xfs_dqblk.d_btimer)));
-	      PUSHs(sv_2mortal(newSViv(xfs_dqblk.d_icount)));
-	      PUSHs(sv_2mortal(newSViv(xfs_dqblk.d_ino_softlimit)));
-	      PUSHs(sv_2mortal(newSViv(xfs_dqblk.d_ino_hardlimit)));
+	      PUSHs(sv_2mortal(newSVnv(xfs_dqblk.d_icount)));
+	      PUSHs(sv_2mortal(newSVnv(xfs_dqblk.d_ino_softlimit)));
+	      PUSHs(sv_2mortal(newSVnv(xfs_dqblk.d_ino_hardlimit)));
 	      PUSHs(sv_2mortal(newSViv(xfs_dqblk.d_itimer)));
 	    }
 	  }
@@ -363,13 +368,13 @@ query(dev,uid=getuid(),kind=0)
             err = vx_quotactl(VX_GETQUOTA, dev+6, uid, CADR &vxfs_dqb);
             if(!err) {
               EXTEND(SP,8);
-              PUSHs(sv_2mortal(newSViv(Q_DIV(vxfs_dqb.dqb_curblocks))));
-              PUSHs(sv_2mortal(newSViv(Q_DIV(vxfs_dqb.dqb_bsoftlimit))));
-              PUSHs(sv_2mortal(newSViv(Q_DIV(vxfs_dqb.dqb_bhardlimit))));
+              PUSHs(sv_2mortal(newSVnv(Q_DIV(vxfs_dqb.dqb_curblocks))));
+              PUSHs(sv_2mortal(newSVnv(Q_DIV(vxfs_dqb.dqb_bsoftlimit))));
+              PUSHs(sv_2mortal(newSVnv(Q_DIV(vxfs_dqb.dqb_bhardlimit))));
               PUSHs(sv_2mortal(newSViv(vxfs_dqb.dqb_btimelimit)));
-              PUSHs(sv_2mortal(newSViv(vxfs_dqb.dqb_curfiles)));
-              PUSHs(sv_2mortal(newSViv(vxfs_dqb.dqb_fsoftlimit)));
-              PUSHs(sv_2mortal(newSViv(vxfs_dqb.dqb_fhardlimit)));
+              PUSHs(sv_2mortal(newSVnv(vxfs_dqb.dqb_curfiles)));
+              PUSHs(sv_2mortal(newSVnv(vxfs_dqb.dqb_fsoftlimit)));
+              PUSHs(sv_2mortal(newSVnv(vxfs_dqb.dqb_fhardlimit)));
               PUSHs(sv_2mortal(newSViv(vxfs_dqb.dqb_ftimelimit)));
             }
           }
@@ -402,21 +407,68 @@ query(dev,uid=getuid(),kind=0)
 	  {
 	    if((*dev != '/') && (p = strchr(dev, ':'))) {
 #ifndef NO_RPC
-	      *p = '\0';
-              err = getnfsquota(dev, p+1, uid, kind, &dqblk);
-	      *p = ':';
+              struct quota_xs_nfs_rslt rslt;
+              *p = '\0';
+              err = getnfsquota(dev, p+1, uid, kind, &rslt);
+              if (!err) {
+                EXTEND(SP, 8);
+                PUSHs(sv_2mortal(newSVnv(Q_DIV(rslt.bcur))));
+                PUSHs(sv_2mortal(newSVnv(Q_DIV(rslt.bsoft))));
+                PUSHs(sv_2mortal(newSVnv(Q_DIV(rslt.bhard))));
+                PUSHs(sv_2mortal(newSViv(rslt.btime)));
+                PUSHs(sv_2mortal(newSVnv(rslt.fcur)));
+                PUSHs(sv_2mortal(newSVnv(rslt.fsoft)));
+                PUSHs(sv_2mortal(newSVnv(rslt.fhard)));
+                PUSHs(sv_2mortal(newSViv(rslt.ftime)));
+              }
+              *p = ':';
 #else /* NO_RPC */
 	      errno = ENOSYS;
               err = -1;
 #endif /* NO_RPC */
             }
-	    else {
+            else {
+#ifdef NETBSD_LIBQUOTA
+              struct quotahandle *qh = quota_open(dev);
+              if (qh != NULL) {
+                struct quotakey qk_blocks, qk_files;
+                struct quotaval qv_blocks, qv_files;
+
+                qk_blocks.qk_idtype = qk_files.qk_idtype = kind ? QUOTA_IDTYPE_GROUP : QUOTA_IDTYPE_USER;
+                qk_blocks.qk_id = qk_files.qk_id = uid;
+                qk_blocks.qk_objtype = QUOTA_OBJTYPE_BLOCKS;
+                qk_files.qk_objtype = QUOTA_OBJTYPE_FILES;
+
+                if ( (quota_get(qh, &qk_blocks, &qv_blocks) >= 0) &&
+                     (quota_get(qh, &qk_files, &qv_files) >= 0) ) {
+                  EXTEND(SP, 8);
+                  PUSHs(sv_2mortal(newSVnv(Q_DIV(qv_blocks.qv_usage))));
+                  PUSHs(sv_2mortal(newSVnv(Q_DIV(qv_blocks.qv_softlimit))));
+                  PUSHs(sv_2mortal(newSVnv(Q_DIV(qv_blocks.qv_hardlimit))));
+                  PUSHs(sv_2mortal(newSViv(qv_blocks.qv_expiretime)));
+                  PUSHs(sv_2mortal(newSVnv(qv_files.qv_usage)));
+                  PUSHs(sv_2mortal(newSVnv(qv_files.qv_softlimit)));
+                  PUSHs(sv_2mortal(newSVnv(qv_files.qv_hardlimit)));
+                  PUSHs(sv_2mortal(newSViv(qv_files.qv_expiretime)));
+                }
+                quota_close(qh);
+              }
+#else /* not NETBSD_LIBQUOTA */
+	      struct dqblk dqblk;
 #ifdef USE_IOCTL
+	      struct quotactl qp;
+	      int fd = -1;
+
 	      qp.op = Q_GETQUOTA;
 	      qp.uid = uid;
 	      qp.addr = (char *)&dqblk;
-	      err = (((fd = open(dev, O_RDONLY)) == -1) ||
-		     (ioctl(fd, Q_QUOTACTL, &qp) == -1));
+	      if ((fd = open(dev, O_RDONLY)) != -1) {
+	        err = (ioctl(fd, Q_QUOTACTL, &qp) == -1);
+	        close(fd);
+	      }
+	      else {
+	        err = 1;
+	      }
 #else /* not USE_IOCTL */
 #ifdef Q_CTL_V3  /* Linux */
 	      err = linuxquota_query(dev, uid, (kind != 0), &dqblk);
@@ -427,23 +479,24 @@ query(dev,uid=getuid(),kind=0)
               struct stat st;
 #if defined(HAVE_JFS2)
               if (strncmp(dev, "(JFS2)", 6) == 0) {
-                if (stat(dev + 6, &st)) {
-		  err = 1;
-                }
-		else {
-		  quota64_t user_quota;
+                if (stat(dev + 6, &st) == 0) {
+                  quota64_t user_quota;
 
-		  err = quotactl(dev + 6, QCMD(Q_J2GETQUOTA, ((kind != 0) ? GRPQUOTA : USRQUOTA)),
+                  err = quotactl(dev + 6, QCMD(Q_J2GETQUOTA, ((kind != 0) ? GRPQUOTA : USRQUOTA)),
                                  uid, CADR &user_quota);
-		  dqblk.dqb_curblocks  = user_quota.bused;
-		  dqblk.dqb_bsoftlimit = user_quota.bsoft;
-		  dqblk.dqb_bhardlimit = user_quota.bhard;
-		  dqblk.dqb_ihardlimit = user_quota.ihard;
-		  dqblk.dqb_isoftlimit = user_quota.isoft;
-		  dqblk.dqb_curinodes = user_quota.iused;
-		  dqblk.dqb_btime = user_quota.btime;
-		  dqblk.dqb_itime = user_quota.itime;
-		}
+                  if (!err) {
+                    EXTEND(SP, 8);
+                    PUSHs(sv_2mortal(newSVnv(user_quota.bused)));
+                    PUSHs(sv_2mortal(newSVnv(user_quota.bsoft)));
+                    PUSHs(sv_2mortal(newSVnv(user_quota.bhard)));
+                    PUSHs(sv_2mortal(newSViv(user_quota.btime)));
+                    PUSHs(sv_2mortal(newSVnv(user_quota.ihard)));
+                    PUSHs(sv_2mortal(newSVnv(user_quota.isoft)));
+                    PUSHs(sv_2mortal(newSVnv(user_quota.iused)));
+                    PUSHs(sv_2mortal(newSViv(user_quota.itime)));
+                  }
+                }
+                err = 1; /* dummy to suppress duplicate push below */
               }
 #endif /* HAVE_JFS2 */
               else if (stat(dev, &st)) {
@@ -457,21 +510,19 @@ query(dev,uid=getuid(),kind=0)
 #endif /* not Q_CTL_V2 */
 #endif /* Q_CTL_V3 */
 #endif /* not USE_IOCTL */
+	      if(!err) {
+	        EXTEND(SP, 8);
+	        PUSHs(sv_2mortal(newSVnv(Q_DIV(dqblk.QS_BCUR))));
+	        PUSHs(sv_2mortal(newSVnv(Q_DIV(dqblk.QS_BSOFT))));
+	        PUSHs(sv_2mortal(newSVnv(Q_DIV(dqblk.QS_BHARD))));
+	        PUSHs(sv_2mortal(newSViv(dqblk.QS_BTIME)));
+	        PUSHs(sv_2mortal(newSVnv(dqblk.QS_FCUR)));
+	        PUSHs(sv_2mortal(newSVnv(dqblk.QS_FSOFT)));
+	        PUSHs(sv_2mortal(newSVnv(dqblk.QS_FHARD)));
+	        PUSHs(sv_2mortal(newSViv(dqblk.QS_FTIME)));
+	      }
+#endif /* not NETBSD_LIBQUOTA */
 	    }
-	    if(!err) {
-	      EXTEND(SP, 8);
-	      PUSHs(sv_2mortal(newSViv(Q_DIV(dqblk.QS_BCUR))));
-	      PUSHs(sv_2mortal(newSViv(Q_DIV(dqblk.QS_BSOFT))));
-	      PUSHs(sv_2mortal(newSViv(Q_DIV(dqblk.QS_BHARD))));
-	      PUSHs(sv_2mortal(newSViv(dqblk.QS_BTIME)));
-	      PUSHs(sv_2mortal(newSViv(dqblk.QS_FCUR)));
-	      PUSHs(sv_2mortal(newSViv(dqblk.QS_FSOFT)));
-	      PUSHs(sv_2mortal(newSViv(dqblk.QS_FHARD)));
-	      PUSHs(sv_2mortal(newSViv(dqblk.QS_FTIME)));
-	    }
-#ifdef USE_IOCTL
-	    if(fd != -1) close(fd);
-#endif
 	  }
         }
 
@@ -479,15 +530,17 @@ int
 setqlim(dev,uid,bs,bh,fs,fh,timelimflag=0,kind=0)
 	char *	dev
 	int	uid
-	long	bs
-	long	bh
-	long	fs
-	long	fh
+	double	bs
+	double	bh
+	double	fs
+	double	fh
 	int	timelimflag
 	int     kind
 	CODE:
 	{
+#ifndef NETBSD_LIBQUOTA
 	  struct dqblk dqblk;
+#endif
 #ifdef USE_IOCTL
 	  struct quotactl qp;
 	  int fd;
@@ -529,8 +582,8 @@ setqlim(dev,uid,bs,bh,fs,fh,timelimflag=0,kind=0)
             vxfs_dqb.dqb_fhardlimit = fh;
             vxfs_dqb.dqb_ftimelimit = timelimflag;
             RETVAL = vx_quotactl(VX_SETQUOTA, dev+6, uid, CADR &vxfs_dqb);
-        }
-        else
+          }
+          else
 #endif
 #ifdef AFSQUOTA
 	  if(!strncmp(dev, "(AFS)", 5)) {
@@ -563,6 +616,61 @@ setqlim(dev,uid,bs,bh,fs,fh,timelimflag=0,kind=0)
           else
 #endif /* HAVE_JFS2 */
 	  {
+#ifdef NETBSD_LIBQUOTA
+            struct quotahandle *qh;
+            struct quotakey qk;
+            struct quotaval qv;
+
+            RETVAL = -1;
+            qh = quota_open(dev);
+            if (qh != NULL) {
+              qk.qk_idtype = kind ? QUOTA_IDTYPE_GROUP : QUOTA_IDTYPE_USER;
+              qk.qk_id = uid;
+
+              qk.qk_objtype = QUOTA_OBJTYPE_BLOCKS;
+
+              /* set the grace period for blocks */
+              if (timelimflag) { /* seven days */
+                qv.qv_grace = 7*24*60*60;
+              } else if (quota_get(qh, &qk, &qv) >= 0) { /* use user's current setting */
+		/* OK */
+              } else if (qk.qk_id = QUOTA_DEFAULTID, quota_get(qh, &qk, &qv) >= 0) { /* use default setting */
+		/* OK, reset qk_id */
+                qk.qk_id = uid;
+              } else {
+                qv.qv_grace = 0; /* XXX */
+              }
+
+              qv.qv_usage = 0;
+              qv.qv_hardlimit = Q_MUL(bh);
+              qv.qv_softlimit = Q_MUL(bs);
+              qv.qv_expiretime = 0;
+              if (quota_put(qh, &qk, &qv) >= 0) {
+                qk.qk_objtype = QUOTA_OBJTYPE_FILES;
+
+                /* set the grace period for files, see comments above */
+                if (timelimflag) {
+                  qv.qv_grace = 7*24*60*60;
+                } else if (quota_get(qh, &qk, &qv) >= 0) {
+		  /* OK */
+                } else if (qk.qk_id = QUOTA_DEFAULTID, quota_get(qh, &qk, &qv) >= 0) {
+		  /* OK, reset qk_id */
+                  qk.qk_id = uid;
+                } else {
+                  qv.qv_grace = 0; /* XXX */
+                }
+
+                qv.qv_usage = 0;
+                qv.qv_hardlimit = fh;
+                qv.qv_softlimit = fs;
+                qv.qv_expiretime = 0;
+                if (quota_put(qh, &qk, &qv) >= 0) {
+                  RETVAL = 0;
+                }
+              }
+              quota_close(qh);
+            }
+#else /* not NETBSD_LIBQUOTA */
             memset(&dqblk, 0, sizeof(dqblk));
 	    dqblk.QS_BSOFT = Q_MUL(bs);
 	    dqblk.QS_BHARD = Q_MUL(bh);
@@ -588,6 +696,7 @@ setqlim(dev,uid,bs,bh,fs,fh,timelimflag=0,kind=0)
 #endif
 #endif
 #endif
+#endif /* not NETBSD_LIBQUOTA */
 	  }
 	}
 	OUTPUT:
@@ -616,6 +725,9 @@ sync(dev=NULL)
 	}
 	else
 #endif
+#ifdef NETBSD_LIBQUOTA
+	RETVAL = 0;
+#else /* not NETBSD_LIBQUOTA */
 #ifdef USE_IOCTL
 	{
 	  struct quotactl qp;
@@ -698,6 +810,7 @@ sync(dev=NULL)
 #endif
         }
 #endif
+#endif /* NETBSD_LIBQUOTA */
 	OUTPUT:
 	RETVAL
 
@@ -711,18 +824,17 @@ rpcquery(host,path,uid=getuid(),kind=0)
 	PPCODE:
 	{
 #ifndef NO_RPC
-	  struct dqblk dqblk;
-          if (getnfsquota(host, path, uid, kind, &dqblk) == 0) {
+          struct quota_xs_nfs_rslt rslt;
+          if (getnfsquota(host, path, uid, kind, &rslt) == 0) {
 	    EXTEND(SP, 8);
-	    PUSHs(sv_2mortal(newSViv(Q_DIV(dqblk.QS_BCUR))));
-	    PUSHs(sv_2mortal(newSViv(Q_DIV(dqblk.QS_BSOFT))));
-	    PUSHs(sv_2mortal(newSViv(Q_DIV(dqblk.QS_BHARD))));
-	    PUSHs(sv_2mortal(newSViv(dqblk.QS_BTIME)));
-
-	    PUSHs(sv_2mortal(newSViv((int) dqblk.QS_FCUR)));
-	    PUSHs(sv_2mortal(newSViv((int) dqblk.QS_FSOFT)));
-	    PUSHs(sv_2mortal(newSViv((int) dqblk.QS_FHARD)));
-	    PUSHs(sv_2mortal(newSViv((int) dqblk.QS_FTIME)));
+            PUSHs(sv_2mortal(newSVnv(Q_DIV(rslt.bcur))));
+            PUSHs(sv_2mortal(newSVnv(Q_DIV(rslt.bsoft))));
+            PUSHs(sv_2mortal(newSVnv(Q_DIV(rslt.bhard))));
+            PUSHs(sv_2mortal(newSViv(rslt.btime)));
+            PUSHs(sv_2mortal(newSVnv(rslt.fcur)));
+            PUSHs(sv_2mortal(newSVnv(rslt.fsoft)));
+            PUSHs(sv_2mortal(newSVnv(rslt.fhard)));
+            PUSHs(sv_2mortal(newSViv(rslt.ftime)));
 	  }
 #else
 	  errno = ENOSYS;
diff --git a/README b/README
index 7e35c1a..51768c0 100644
--- a/README
+++ b/README
@@ -3,8 +3,8 @@ Quota extension module for Perl
 
 Author:    Tom Zoerner (tomzo AT users.sourceforge.net)
 
-Version:   1.6.7
-Date:      November 2011
+Version:   1.7.0
+Date:      August 2013
 DLSIP-Code:Rcdfg
            - stable release
            - C compiler required for installation
@@ -16,7 +16,7 @@ DLSIP-Code:Rcdfg
 Location:  http://www.perl.com/CPAN/authors/Tom_Zoerner/
 
 Supported: SunOS 4.1.3,
-           Solaris 2.4 & 2.5 & 2.6 & 2.8,
+           Solaris 2.4 - 2.10,
            HP-UX 9.0x & 10.10 & 10.20 & 11.00,
            IRIX 5.2 & 5.3 & 6.2 - 6.5,
            OSF/1 & Digital Unix 4,
@@ -126,6 +126,10 @@ DESCRIPTION
          $uid, $bs, $bh, $is and $ih are the same as in
          Quota::query.
 
+         For file systems exceeding 2 TB: To allow passing block or
+         inode values larger or equal to 2^32 on 32-bit Perl versions,
+         pass them either as strings or floating point.
+
          $tlo decides how the time limits are initialized:  0:
          The time limits are set to NOT STARTED, i.e. the time
          limits are not initialized until the first write attempt
diff --git a/hints/aix_4_1.h b/hints/aix_4_1.h
index 2c6f613..17eae9c 100644
--- a/hints/aix_4_1.h
+++ b/hints/aix_4_1.h
@@ -38,6 +38,8 @@
 
 #define CADR (caddr_t)
 
+#define GQA_TYPE_USR USRQUOTA  /* RQUOTA_USRQUOTA */
+#define GQA_TYPE_GRP GRPQUOTA  /* RQUOTA_GRPQUOTA */
 #define GQR_STATUS status
 #define GQR_RQUOTA getquota_rslt_u.gqr_rquota
 
diff --git a/hints/bsd.h b/hints/bsd.h
index 1c95449..255c8cd 100644
--- a/hints/bsd.h
+++ b/hints/bsd.h
@@ -9,6 +9,7 @@
  *           and Jon Schewe <schewe at tcfreenet.org>
  *   NetBSD mods and merge of *BSD-related hints provided by
  *           Jaromir Dolecek <jdolecek at NetBSD.org>
+ *   NetBSD libquota mods by David Holland <dholland at netbsd.org>
  */
 
 /*   See hints/none.h for a complete list of options with explanations */
@@ -16,7 +17,19 @@
 #include <sys/param.h>
 #include <sys/mount.h>
 #include <fstab.h>
+
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 599004800 && __NetBSD_Version__ < 599005900
+#error "NetBSD 5.99 proplib-based quotas not supported"
+#endif
+
+#if defined(__NetBSD__) && (__NetBSD_Version__ >= 599005900) /* NetBSD 5.99.59 */
+#include <quota.h>
+/* defining this will force the XS to use the libquota API for all file systems
+ * except RPC; defines below such as Q_CTL_V2 have no effect */
+#define NETBSD_LIBQUOTA
+#else
 #include <ufs/ufs/quota.h>
+#endif
 
 #if defined(__NetBSD__) && (__NetBSD_Version__ >= 299000900) /* NetBSD 2.99.9 */
 /* NetBSD 3.0 has no statfs anymore */
@@ -58,6 +71,8 @@
 
 #define NO_MNTENT
 
+#define GQA_TYPE_USR RQUOTA_USRQUOTA
+#define GQA_TYPE_GRP RQUOTA_GRPQUOTA
 #define GQR_STATUS status
 #define GQR_RQUOTA getquota_rslt_u.gqr_rquota
 
diff --git a/hints/dec_osf.h b/hints/dec_osf.h
index 717b5e8..c814d2e 100644
--- a/hints/dec_osf.h
+++ b/hints/dec_osf.h
@@ -30,6 +30,8 @@
 #define OSF_QUOTA
 extern char *getvfsbynumber();  /* prototype missing!? */
 
+#define GQA_TYPE_USR USRQUOTA  /* RQUOTA_USRQUOTA */
+#define GQA_TYPE_GRP GRPQUOTA  /* RQUOTA_GRPQUOTA */
 #define GQR_STATUS gqr_status
 #define GQR_RQUOTA gqr_rquota
 
diff --git a/hints/hpux.h b/hints/hpux.h
index f3bbb49..7a945ca 100644
--- a/hints/hpux.h
+++ b/hints/hpux.h
@@ -32,6 +32,8 @@
  */
 #define MY_XDR
 
+#define GQA_TYPE_USR USRQUOTA  /* RQUOTA_USRQUOTA */
+#define GQA_TYPE_GRP GRPQUOTA  /* RQUOTA_GRPQUOTA */
 #define GQR_STATUS gqr_status
 #define GQR_RQUOTA gqr_rquota
 
diff --git a/hints/irix_5.h b/hints/irix_5.h
index b1855b0..1a313fe 100644
--- a/hints/irix_5.h
+++ b/hints/irix_5.h
@@ -25,6 +25,8 @@
 
 #define MNTENT mntent
 
+#define GQA_TYPE_USR USRQUOTA  /* RQUOTA_USRQUOTA */
+#define GQA_TYPE_GRP GRPQUOTA  /* RQUOTA_GRPQUOTA */
 #define GQR_STATUS gqr_status
 #define GQR_RQUOTA gqr_rquota
 
diff --git a/hints/irix_6.h b/hints/irix_6.h
index e5f36fc..475fbab 100644
--- a/hints/irix_6.h
+++ b/hints/irix_6.h
@@ -33,6 +33,8 @@
 
 #define MNTENT mntent
 
+#define GQA_TYPE_USR USRQUOTA  /* RQUOTA_USRQUOTA */
+#define GQA_TYPE_GRP GRPQUOTA  /* RQUOTA_GRPQUOTA */
 #define GQR_STATUS gqr_status
 #define GQR_RQUOTA gqr_rquota
 
diff --git a/hints/linux.h b/hints/linux.h
index f2ddef7..ee95971 100644
--- a/hints/linux.h
+++ b/hints/linux.h
@@ -70,6 +70,8 @@ int linuxquota_sync( const char * dev, int isgrp );
 
 #define MNTENT mntent
 
+#define GQA_TYPE_USR USRQUOTA  /* RQUOTA_USRQUOTA */
+#define GQA_TYPE_GRP GRPQUOTA  /* RQUOTA_GRPQUOTA */
 #define GQR_STATUS status
 #define GQR_RQUOTA getquota_rslt_u.gqr_rquota
 
@@ -93,7 +95,7 @@ int linuxquota_sync( const char * dev, int isgrp );
 
 /* optional: for support of SGI XFS file systems - comment out if not needed */
 #define SGI_XFS
-#define QX_DIV(X) ((X) >> 1)
-#define QX_MUL(X) ((X) << 1)
+#define QX_DIV(X) ((X) / 2)
+#define QX_MUL(X) ((X) * 2)
 #include "include/quotaio_xfs.h"
 
diff --git a/hints/none.h b/hints/none.h
index 9febfe5..bcaa621 100644
--- a/hints/none.h
+++ b/hints/none.h
@@ -81,6 +81,13 @@
    you can generate these routines with rpcgen, too */
 /* #define MY_XDR /**/
 
+/* define this to enable support for extended quota RPC (i.e. quota RPC
+ * version 2), which is needed to allow querying group quotas via RPC. To
+ * check if your OS supports it, search for EXT_RQUOTAVERS in the system
+ * header files. If not, you can define MY_XDR to use module internal
+ * support. */
+/* #define USE_EXT_RQUOTA /**/
+
 /* needed only if MOUNTED is not defined in <mnttab.h> (see above) */
 /* define MOUNTED mnttab /**/
 
@@ -94,6 +101,13 @@
    use getmntinfo instead then (e.g. in OSF) */
 /* #define NO_MNTENT /**/
 
+/* With USE_EXT_RQUOTA these constants distinguish queries for user and
+ * group quota respectively. Only BSD defines these constants properly. For
+ * others use USRQUTA and GRPQUOTA, or simply the real constants (these must
+ * be the same for all OS to allow inter-operability.) */
+#define GQA_TYPE_USR 0 /* RQUOTA_USRQUOTA */
+#define GQA_TYPE_GRP 1 /* RQUOTA_GRPQUOTA */
+
 /* name of the status entry in struc getquota_rslt and name of the struct
  * or union that contains the quota values. See include <rpcsvc/rquota.h>
  * or "include/rquota.h" if you're using MY_XDR */
diff --git a/hints/solaris_2.h b/hints/solaris_2.h
index b74726b..d222b1f 100644
--- a/hints/solaris_2.h
+++ b/hints/solaris_2.h
@@ -43,6 +43,8 @@ struct quotactl {
  */
 #define MY_XDR
 
+#define GQA_TYPE_USR USRQUOTA  /* RQUOTA_USRQUOTA */
+#define GQA_TYPE_GRP GRPQUOTA  /* RQUOTA_GRPQUOTA */
 #define GQR_STATUS status
 #define GQR_RQUOTA getquota_rslt_u.gqr_rquota
 
diff --git a/hints/sunos_4_1.h b/hints/sunos_4_1.h
index 0f7937f..71a5b9a 100644
--- a/hints/sunos_4_1.h
+++ b/hints/sunos_4_1.h
@@ -27,6 +27,8 @@
 
 #define MNTENT mntent
 
+#define GQA_TYPE_USR USRQUOTA  /* RQUOTA_USRQUOTA */
+#define GQA_TYPE_GRP GRPQUOTA  /* RQUOTA_GRPQUOTA */
 #define GQR_STATUS gqr_status
 #define GQR_RQUOTA gqr_rquota
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libquota-perl.git



More information about the Pkg-perl-cvs-commits mailing list