]> arthur.barton.de Git - netatalk.git/commitdiff
Fix for linux quotas, this needs testing on different kernel versions
authorbfernhomberg <bfernhomberg>
Tue, 9 Sep 2003 18:18:53 +0000 (18:18 +0000)
committerbfernhomberg <bfernhomberg>
Tue, 9 Sep 2003 18:18:53 +0000 (18:18 +0000)
configure.in
etc/afpd/quota.c
etc/afpd/unix.h

index d6b48cd23a0673f80a8020c059e6bd254a585fcd..2c9518e95c8560e68b5a9fb44cf700816f88a697 100644 (file)
@@ -1,4 +1,4 @@
-dnl $Id: configure.in,v 1.179.2.3.2.1 2003-09-09 16:42:19 didg Exp $
+dnl $Id: configure.in,v 1.179.2.3.2.2 2003-09-09 18:18:53 bfernhomberg Exp $
 dnl configure.in for netatalk
 
 AC_INIT(bin/adv1tov2/adv1tov2.c)
@@ -667,11 +667,18 @@ if test x"$this_os" = "xlinux"; then
        AC_MSG_RESULT([ * Linux specific configuration])
 
        dnl ----- check if we need the quotactl wrapper
-       AC_CHECK_HEADERS(sys/quota.h linux/quota.h)
-       AC_CHECK_FUNC(quotactl,,
-               AC_DEFINE(NEED_QUOTACTL_WRAPPER, 1, [Define if the quotactl wrapper is needed])
-               AC_MSG_RESULT([enabling quotactl wrapper])
-       )
+#      AC_CHECK_HEADERS(sys/quota.h linux/quota.h)
+#      AC_CHECK_FUNC(quotactl,,
+#              AC_DEFINE(NEED_QUOTACTL_WRAPPER, 1, [Define if the quotactl wrapper is needed])
+#              AC_MSG_RESULT([enabling quotactl wrapper])
+#      )
+
+        # For quotas on Linux XFS filesystems
+        AC_CHECK_HEADERS(linux/xqm.h linux/xfs_fs.h)
+        AC_CHECK_HEADERS(xfs/libxfs.h xfs/xqm.h xfs/xfs_fs.h)
+        # For linux > 2.5.56
+        AC_CHECK_HEADERS(linux/dqblk_xfs.h)
+
 
        dnl ----- as far as I can tell, dbtob always does the wrong thing
        dnl ----- on every single version of linux I've ever played with.
index dded3350b29e10450fa011a547c5626d2aa0fb2b..a29b8322e70982a0ea0112b9f66302be9578a33b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: quota.c,v 1.22 2002-08-29 17:22:06 jmarcus Exp $
+ * $Id: quota.c,v 1.22.8.1 2003-09-09 18:18:54 bfernhomberg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
-
+#include <sys/types.h>
 /* STDC check */
 #if STDC_HEADERS
 #include <string.h>
@@ -46,6 +46,10 @@ char *strchr (), *strrchr ();
 #include "volume.h"
 #include "unix.h"
 
+#define DEBUG_QUOTA 1
+#define WANT_USER_QUOTA 0
+#define WANT_GROUP_QUOTA 1
+
 #ifndef NO_QUOTA_SUPPORT
 #ifdef NEED_QUOTACTL_WRAPPER
 int quotactl(int cmd, const char *special, int id, caddr_t addr)
@@ -54,6 +58,229 @@ int quotactl(int cmd, const char *special, int id, caddr_t addr)
 }
 #endif /* NEED_QUOTACTL_WRAPPER */
 
+#ifdef linux
+
+#ifdef HAVE_LINUX_XQM_H
+#include <linux/xqm.h>
+#else
+#ifdef HAVE_XFS_XQM_H
+#include <xfs/xqm.h>
+#define HAVE_LINUX_XQM_H
+#endif /* HAVE_XFS_XQM_H */
+#endif /* HAVE_LINUX_XQM_H */
+
+#include <linux/unistd.h>
+
+static int is_xfs = 0;
+
+static int get_linux_xfs_quota(int, char*, uid_t, struct dqblk *);
+static int get_linux_fs_quota(int, char*, uid_t, struct dqblk *);
+
+/* format supported by current kernel */
+static int kernel_iface = IFACE_UNSET;
+
+/*
+**  Check kernel quota version
+**  Taken from quota-tools 3.08 by Jan Kara <jack@suse.cz>
+*/
+static void linuxquota_get_api( void )
+{
+#ifndef LINUX_API_VERSION
+    struct stat st;
+
+    if (stat("/proc/sys/fs/quota", &st) == 0) {
+        kernel_iface = IFACE_GENERIC;
+    }
+    else {
+        struct dqstats_v2 v2_stats;
+        struct sigaction  sig;
+        struct sigaction  oldsig;
+
+        /* This signal handling is needed because old kernels send us SIGSEGV as they try to resolve the device */
+        sig.sa_handler   = SIG_IGN;
+        sig.sa_sigaction = NULL;
+        sig.sa_flags     = 0;
+        sigemptyset(&sig.sa_mask);
+        if (sigaction(SIGSEGV, &sig, &oldsig) < 0) {
+           LOG( log_error, logtype_afpd, "cannot set SEGV signal handler: %s\n", strerror(errno));
+            goto failure;
+        }
+        if (quotactl(QCMD(Q_V2_GETSTATS, 0), NULL, 0, (void *)&v2_stats) >= 0) {
+            kernel_iface = IFACE_VFSV0;
+        }
+        else if (errno != ENOSYS && errno != ENOTSUP) {
+            /* RedHat 7.1 (2.4.2-2) newquota check 
+             * Q_V2_GETSTATS in it's old place, Q_GETQUOTA in the new place
+             * (they haven't moved Q_GETSTATS to its new value) */
+            int err_stat = 0;
+            int err_quota = 0;
+            char tmp[1024];         /* Just temporary buffer */
+
+            if (quotactl(QCMD(Q_V1_GETSTATS, 0), NULL, 0, tmp))
+                err_stat = errno;
+            if (quotactl(QCMD(Q_V1_GETQUOTA, 0), "/dev/null", 0, tmp))
+                err_quota = errno;
+
+            /* On a RedHat 2.4.2-2     we expect 0, EINVAL
+             * On a 2.4.x              we expect 0, ENOENT
+             * On a 2.4.x-ac   we wont get here */
+            if (err_stat == 0 && err_quota == EINVAL) {
+                kernel_iface = IFACE_VFSV0;
+            }
+            else {
+                kernel_iface = IFACE_VFSOLD;
+            }
+        }
+        else {
+            /* This branch is *not* in quota-tools 3.08
+            ** but without it quota version is not correctly
+            ** identified for the original SuSE 8.0 kernel */
+            unsigned int vers_no;
+            FILE * qf;
+
+            if ((qf = fopen("/proc/fs/quota", "r"))) {
+                if (fscanf(qf, "Version %u", &vers_no) == 1) {
+                    if ( (vers_no == (6*10000 + 5*100 + 0)) ||
+                         (vers_no == (6*10000 + 5*100 + 1)) ) {
+                        kernel_iface = IFACE_VFSV0;
+                    }
+                }
+                fclose(qf);
+            }
+        }
+        if (sigaction(SIGSEGV, &oldsig, NULL) < 0) {
+           LOG(log_error, logtype_afpd, "cannot reset signal handler: %s\n", strerror(errno));
+            goto failure;
+        }
+    }
+
+failure:
+    if (kernel_iface == IFACE_UNSET)
+       kernel_iface = IFACE_VFSOLD;
+
+#else /* defined LINUX_API_VERSION */
+    kernel_iface = LINUX_API_VERSION;
+#endif
+}
+
+/****************************************************************************/
+
+static int get_linux_quota(int what, char *path, uid_t euser_id, struct dqblk *dp)
+{
+       int r; /* result */
+
+       if ( is_xfs )
+               r=get_linux_xfs_quota(what, path, euser_id, dp);
+       else
+               r=get_linux_fs_quota(what, path, euser_id, dp);
+    
+       return r;
+}
+
+/****************************************************************************
+ Abstract out the XFS Quota Manager quota get call.
+****************************************************************************/
+
+static int get_linux_xfs_quota(what, path, euser_id, dp)
+int what;
+char *path;
+uid_t euser_id;
+struct dqblk *dp;
+{
+       int ret = -1;
+#ifdef HAVE_LINUX_XQM_H
+       struct fs_disk_quota D;
+       
+       memset (&D, 0, sizeof(fs_disk_quota));
+
+       if ((ret = quotactl(QCMD(Q_XGETQUOTA,USRQUOTA), path, euser_id, (caddr_t)&D)))
+               return ret;
+
+       dp->bsize = (u_int64_t)512;
+       dp->softlimit  = (u_int64_t)D.d_blk_softlimit;
+       dp->hardlimit  = (u_int64_t)D.d_blk_hardlimit;
+       dp->ihardlimit = (u_int64_t)D.d_ino_hardlimit;
+       dp->isoftlimit = (u_int64_t)D.d_ino_softlimit;
+       dp->curinodes  = (u_int64_t)D.d_icount;
+       dp->curblocks  = (u_int64_t)D.d_bcount;
+#endif
+       return ret;
+}
+
+/*
+** Wrapper for the quotactl(GETQUOTA) call.
+** For API v2 the results are copied back into a v1 structure.
+** Taken from quota-1.4.8 perl module
+*/
+static int get_linux_fs_quota( what, path, euser_id, dqb)
+int what;
+char *path;
+uid_t euser_id;
+struct dqblk *dqb;
+{
+       int ret;
+
+       if (kernel_iface == IFACE_UNSET)
+               linuxquota_get_api();
+
+       if (kernel_iface == IFACE_GENERIC)
+       {
+               struct dqblk_v3 dqb3;
+
+               ret = quotactl(QCMD(Q_V3_GETQUOTA, (what ? GRPQUOTA : USRQUOTA)), path, euser_id, (caddr_t) &dqb3);
+               if (ret == 0)
+               {
+                       dqb->dqb_bhardlimit = dqb3.dqb_bhardlimit;
+                       dqb->dqb_bsoftlimit = dqb3.dqb_bsoftlimit;
+                       dqb->dqb_curblocks  = dqb3.dqb_curspace / DEV_QBSIZE;
+                       dqb->dqb_ihardlimit = dqb3.dqb_ihardlimit;
+                       dqb->dqb_isoftlimit = dqb3.dqb_isoftlimit;
+                       dqb->dqb_curinodes  = dqb3.dqb_curinodes;
+                       dqb->dqb_btime      = dqb3.dqb_btime;
+                       dqb->dqb_itime      = dqb3.dqb_itime;
+                       dqb->bsize          = DEV_QBSIZE;
+               }
+       }
+       else if (kernel_iface == IFACE_VFSV0)
+       {
+               struct dqblk_v2 dqb2;
+
+               ret = quotactl(QCMD(Q_V2_GETQUOTA, (what ? GRPQUOTA : USRQUOTA)), path, euser_id, (caddr_t) &dqb2);
+               if (ret == 0)
+               {
+                       dqb->dqb_bhardlimit = dqb2.dqb_bhardlimit;
+                       dqb->dqb_bsoftlimit = dqb2.dqb_bsoftlimit;
+                       dqb->dqb_curblocks  = dqb2.dqb_curspace / DEV_QBSIZE;
+                       dqb->dqb_ihardlimit = dqb2.dqb_ihardlimit;
+                       dqb->dqb_isoftlimit = dqb2.dqb_isoftlimit;
+                       dqb->dqb_curinodes  = dqb2.dqb_curinodes;
+                       dqb->dqb_btime      = dqb2.dqb_btime;
+                       dqb->dqb_itime      = dqb2.dqb_itime;
+                       dqb->bsize          = DEV_QBSIZE;
+               }
+       }
+       else /* if (kernel_iface == IFACE_VFSOLD) */
+       {
+               struct dqblk_v1 dqb1;
+
+               ret = quotactl(QCMD(Q_V1_GETQUOTA, (what ? GRPQUOTA : USRQUOTA)), path, euser_id, (caddr_t) &dqb1);
+               if (ret == 0)
+               {
+                       dqb->dqb_bhardlimit = dqb1.dqb_bhardlimit;
+                       dqb->dqb_bsoftlimit = dqb1.dqb_bsoftlimit;
+                       dqb->dqb_curblocks  = dqb1.dqb_curblocks;
+                       dqb->dqb_ihardlimit = dqb1.dqb_ihardlimit;
+                       dqb->dqb_isoftlimit = dqb1.dqb_isoftlimit;
+                       dqb->dqb_curinodes  = dqb1.dqb_curinodes;
+                       dqb->dqb_btime      = dqb1.dqb_btime;
+                       dqb->dqb_itime      = dqb1.dqb_itime;
+                       dqb->bsize          = DEV_QBSIZE;
+               }
+       }
+       return ret;
+}
+
+#endif /* linux */
 
 #if defined(HAVE_SYS_MNTTAB_H) || defined(__svr4__)
 /*
@@ -162,6 +389,7 @@ int *nfs;
     FILE               *mtab;
     dev_t              devno;
     struct mntent      *mnt;
+    int                found=0;
 
     if ( stat( file, &sb ) < 0 ) {
         return( NULL );
@@ -175,8 +403,8 @@ int *nfs;
     while (( mnt = getmntent( mtab )) != NULL ) {
         /* check for local fs */
         if ( (stat( mnt->mnt_fsname, &sb ) == 0) && devno == sb.st_rdev) {
-            endmntent( mtab );
-            return( mnt->mnt_fsname );
+           found = 1;
+           break;
         }
 
         /* check for an nfs mount entry. the alternative is to use
@@ -184,13 +412,21 @@ int *nfs;
         if ((stat(mnt->mnt_dir, &sb) == 0) && (devno == sb.st_dev) &&
                 strchr(mnt->mnt_fsname, ':')) {
             *nfs = 1;
-            endmntent( mtab );
-            return( mnt->mnt_fsname );
+           found = 1;
+           break;
         }
     }
 
     endmntent( mtab );
-    return( NULL );
+
+    if (!found)
+       return (NULL);
+#ifdef linux
+    if (strcmp(mnt->mnt_type, "xfs") == 0)
+       is_xfs = 1;
+#endif
+       
+    return( mnt->mnt_fsname );
 }
 
 #endif /* BSD4_4 */
@@ -199,10 +435,15 @@ int *nfs;
 
 
 static int getfsquota(vol, uid, dq)
-struct vol          *vol;
-const int           uid;
-struct dqblk        *dq;
+struct vol             *vol;
+const int              uid;
+struct dqblk           *dq;
+
 {
+       struct dqblk dqg;
+
+    memset(&dqg, 0, sizeof(dqg));
+       
 #ifdef __svr4__
     struct quotctl     qc;
 
@@ -231,9 +472,6 @@ struct dqblk        *dq;
 #ifndef TRU64
     /* for group quotas. we only use these if the user belongs
     * to one group. */
-    struct dqblk        dqg;
-
-    memset(&dqg, 0, sizeof(dqg));
 #endif /* TRU64 */
 
 #ifdef BSD4_4
@@ -263,14 +501,15 @@ struct dqblk        *dq;
     }
 
 #else /* BSD4_4 */
-    if ( quotactl(QCMD(Q_GETQUOTA, USRQUOTA), vol->v_gvs, uid,
-                  (caddr_t) dq ) != 0 ) {
-        return( AFPERR_PARAM );
-    }
-
-    if (ngroups >= 1)
-        quotactl(QCMD(Q_GETQUOTA, GRPQUOTA), vol->v_gvs,
-                 groups[0], (char *) &dqg);
+       if (get_linux_quota (WANT_USER_QUOTA, vol->v_gvs, uid, dq) !=0) {
+               return( AFPERR_PARAM );
+       }
+
+       if (ngroups >= 1)
+       {
+               if (get_linux_quota(WANT_GROUP_QUOTA, vol->v_gvs, groups[0],  &dqg) != 0)
+                       LOG(log_info, logtype_afpd, "group quota did not work!" );
+       }
 #endif  /* BSD4_4 */
 
 #ifndef TRU64
@@ -278,8 +517,7 @@ struct dqblk        *dq;
 
     /* max(user blocks, group blocks) */
     if (dqg.dqb_curblocks && (dq->dqb_curblocks < dqg.dqb_curblocks))
-        dq->dqb_curblocks = dqg.dqb_curblocks;
-
+        dq->dqb_curblocks = dqg.dqb_curblocks; 
     /* min(user limit, group limit) */
     if (dqg.dqb_bhardlimit && (!dq->dqb_bhardlimit ||
                                (dq->dqb_bhardlimit > dqg.dqb_bhardlimit)))
@@ -306,8 +544,8 @@ struct dqblk        *dq;
 
 static int getquota( vol, dq, bsize)
 struct vol             *vol;
-struct dqblk   *dq;
-const u_int32_t     bsize;
+struct dqblk           *dq;
+const u_int32_t                bsize;
 {
     char *p;
 
@@ -391,7 +629,7 @@ const u_int32_t     bsize;
 }
 
 static int overquota( dqblk )
-struct dqblk   *dqblk;
+struct dqblk     *dqblk;
 {
     struct timeval     tv;
 
@@ -439,36 +677,67 @@ struct dqblk      *dqblk;
 #else 
 #define tobytes(a, b)  dbtob((VolSpace) (a))
 #endif
+
 int uquota_getvolspace( vol, bfree, btotal, bsize)
 const struct vol       *vol;
 VolSpace       *bfree, *btotal;
 const u_int32_t bsize;
 {
-    struct dqblk       dqblk;
+       u_int64_t this_bsize;
+       struct dqblk dqblk;
 
-    if (getquota( vol, &dqblk, bsize) != 0 ) {
-        return( AFPERR_PARAM );
-    }
+       this_bsize = bsize;
+                       
+       if (getquota( vol, &dqblk, bsize) != 0 ) {
+               return( AFPERR_PARAM );
+       }
 
-    /* no limit set for this user. it might be set in the future. */
-    if (dqblk.dqb_bsoftlimit == 0 && dqblk.dqb_bhardlimit == 0) {
-        *btotal = *bfree = ~((VolSpace) 0);
-    } else if ( overquota( &dqblk )) {
-        if ( tobytes( dqblk.dqb_curblocks, bsize ) > tobytes( dqblk.dqb_bhardlimit, bsize ) ) {
-            *btotal = tobytes( dqblk.dqb_curblocks, bsize );
-            *bfree = 0;
-        }
-        else {
-            *btotal = tobytes( dqblk.dqb_bhardlimit, bsize );
-            *bfree = tobytes( dqblk.dqb_bhardlimit, bsize ) -
-                     tobytes( dqblk.dqb_curblocks, bsize );
-        }
-    } else {
-        *btotal = tobytes( dqblk.dqb_bsoftlimit, bsize );
-        *bfree = tobytes( dqblk.dqb_bsoftlimit, bsize  ) -
-                 tobytes( dqblk.dqb_curblocks, bsize );
-    }
+#ifdef linux
+       this_bsize = dqblk.bsize;
+#endif
+
+#if DEBUG_QUOTA
+        LOG(log_info, logtype_afpd, "after calling getquota in uquota_getvolspace!" );
+        LOG(log_info, logtype_afpd, "dqb_ihardlimit: %u", dqblk.dqb_ihardlimit );
+        LOG(log_info, logtype_afpd, "dqb_isoftlimit: %u", dqblk.dqb_isoftlimit );
+        LOG(log_info, logtype_afpd, "dqb_curinodes : %u", dqblk.dqb_curinodes );
+        LOG(log_info, logtype_afpd, "dqb_bhardlimit: %u", dqblk.dqb_bhardlimit );
+        LOG(log_info, logtype_afpd, "dqb_bsoftlimit: %u", dqblk.dqb_bsoftlimit );
+        LOG(log_info, logtype_afpd, "dqb_curblocks : %u", dqblk.dqb_curblocks );
+        LOG(log_info, logtype_afpd, "dqb_btime     : %u", dqblk.dqb_btime );
+        LOG(log_info, logtype_afpd, "dqb_itime     : %u", dqblk.dqb_itime );
+        LOG(log_info, logtype_afpd, "bsize/this_bsize : %u/%u", bsize, this_bsize );
+       LOG(log_info, logtype_afpd, "dqblk.dqb_bhardlimit size: %u", tobytes( dqblk.dqb_bhardlimit, this_bsize ));
+       LOG(log_info, logtype_afpd, "dqblk.dqb_bsoftlimit size: %u", tobytes( dqblk.dqb_bsoftlimit, this_bsize ));
+       LOG(log_info, logtype_afpd, "dqblk.dqb_curblocks  size: %u", tobytes( dqblk.dqb_curblocks, this_bsize ));
+#endif /* DEBUG_QUOTA */ 
+
+       /* no limit set for this user. it might be set in the future. */
+       if (dqblk.dqb_bsoftlimit == 0 && dqblk.dqb_bhardlimit == 0) {
+               *btotal = *bfree = ~((VolSpace) 0);
+       } else if ( overquota( &dqblk )) {
+               if ( tobytes( dqblk.dqb_curblocks, this_bsize ) > tobytes( dqblk.dqb_bhardlimit, this_bsize ) ) {
+                       *btotal = tobytes( dqblk.dqb_curblocks, this_bsize );
+                       *bfree = 0;
+               }
+               else {
+                       *btotal = tobytes( dqblk.dqb_bhardlimit, this_bsize );
+                       *bfree  = tobytes( dqblk.dqb_bhardlimit, this_bsize ) -
+                                 tobytes( dqblk.dqb_curblocks, this_bsize );
+               }
+       } else {
+               *btotal = tobytes( dqblk.dqb_bsoftlimit, this_bsize );
+               *bfree  = tobytes( dqblk.dqb_bsoftlimit, this_bsize  ) -
+                         tobytes( dqblk.dqb_curblocks, this_bsize );
+       }
+
+#if DEBUG_QUOTA
+        LOG(log_info, logtype_afpd, "bfree          : %u", *bfree );
+        LOG(log_info, logtype_afpd, "btotal         : %u", *btotal );
+        LOG(log_info, logtype_afpd, "bfree          : %uKB", *bfree/1024 );
+        LOG(log_info, logtype_afpd, "btotal         : %uKB", *btotal/1024 );
+#endif
 
-    return( AFP_OK );
+       return( AFP_OK );
 }
 #endif
index aa95930ee072b6862079ff8104b4c3488a782324..a58eb997569ec7cea30b0d44020cd8c777317a12 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: unix.h,v 1.12.2.1 2003-07-21 05:50:54 didg Exp $
+ * $Id: unix.h,v 1.12.2.1.2.1 2003-09-09 18:18:54 bfernhomberg Exp $
  */
 
 #ifndef AFPD_UNIX_H
@@ -9,6 +9,7 @@
 #include <sys/cdefs.h>
 #endif /* HAVE_SYS_CDEFS_H */
 #include <netatalk/endian.h>
+#include "config.h"
 #include "volume.h"
 
 #if defined( sun ) && !defined( __svr4__ )
@@ -42,6 +43,8 @@ typedef int   mode_t;
 #include <sys/mnttab.h>
 #endif /* __svr4__ || HAVE_SYS_MNTTAB_H */
 
+
+
 #if defined(HAVE_SYS_MOUNT_H) || defined(BSD4_4) || \
     defined(linux) || defined(ultrix)
 #include <sys/mount.h>
@@ -60,7 +63,10 @@ typedef int  mode_t;
 
 #if defined(linux) || defined(ultrix) || defined(HAVE_QUOTA_H)
 #ifndef NEED_QUOTACTL_WRAPPER
-#include <sys/quota.h>
+/*#include <sys/quota.h>*/
+/*long quotactl __P((int, const char *, unsigned int, caddr_t)); */
+/* extern long quotactl __P((int, const char *, long, caddr_t)); */
+
 #else /* ! NEED_QUOTACTL_WRAPPER */
 #include <asm/types.h>
 #include <asm/unistd.h>
@@ -89,6 +95,116 @@ typedef int mode_t;
 #include <sys/stat.h>
 #include "directory.h"
 
+
+#if defined (linux)
+
+#define MAXQUOTAS 2
+
+/* definitions from sys/quota.h */
+#define USRQUOTA  0             /* element used for user quotas */
+#define GRPQUOTA  1             /* element used for group quotas */
+
+/*
+ * Command definitions for the 'quotactl' system call.
+ * The commands are broken into a main command defined below
+ * and a subcommand that is used to convey the type of
+ * quota that is being manipulated (see above).
+ */
+#define SUBCMDMASK  0x00ff
+#define SUBCMDSHIFT 8
+#define QCMD(cmd, type)  (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
+
+/* declare an internal version of the quota block struct */
+typedef u_int64_t qsize_t;     /* Type in which we store size limitations */
+typedef u_int32_t qid_t;       /* Type in which we store ids in memory */
+
+struct dqblk {
+  qsize_t bsize;
+  qsize_t dqb_ihardlimit;   /* absolute limit on allocated inodes */
+  qsize_t dqb_isoftlimit;   /* preferred inode limit */
+  qsize_t dqb_curinodes;    /* current # allocated inodes */
+  qsize_t dqb_bhardlimit;   /* absolute limit on disk blks alloc */
+  qsize_t dqb_bsoftlimit;   /* preferred limit on disk blks */
+  qsize_t dqb_curblocks;    /* current block count */
+  time_t  dqb_btime;        /* time limit for excessive disk use */
+  time_t  dqb_itime;        /* time limit for excessive inode use */
+};
+
+/* API v1 command definitions */
+#define Q_V1_GETQUOTA  0x0300
+#define Q_V1_SYNC      0x0600
+#define Q_V1_SETQLIM   0x0700
+#define Q_V1_GETSTATS  0x0800
+/* API v2 command definitions */
+#define Q_V2_SYNC      0x0600
+#define Q_V2_SETQLIM   0x0700
+#define Q_V2_GETQUOTA  0x0D00
+#define Q_V2_GETSTATS  0x1100
+/* proc API command definitions */
+#define Q_V3_SYNC      0x800001
+#define Q_V3_GETQUOTA  0x800007
+#define Q_V3_SETQUOTA  0x800008
+
+/* Interface versions */
+#define IFACE_UNSET 0
+#define IFACE_VFSOLD 1
+#define IFACE_VFSV0 2
+#define IFACE_GENERIC 3
+
+#define DEV_QBSIZE 1024
+
+struct dqblk_v3 {
+  u_int64_t dqb_bhardlimit;
+  u_int64_t dqb_bsoftlimit;
+  u_int64_t dqb_curspace;
+  u_int64_t dqb_ihardlimit;
+  u_int64_t dqb_isoftlimit;
+  u_int64_t dqb_curinodes;
+  u_int64_t dqb_btime;
+  u_int64_t dqb_itime;
+  u_int32_t dqb_valid;
+};
+
+struct dqblk_v2 {
+  unsigned int dqb_ihardlimit;
+  unsigned int dqb_isoftlimit;
+  unsigned int dqb_curinodes;
+  unsigned int dqb_bhardlimit;
+  unsigned int dqb_bsoftlimit;
+  qsize_t dqb_curspace;
+  time_t dqb_btime;
+  time_t dqb_itime;
+};
+
+struct dqstats_v2 {
+  u_int32_t lookups;
+  u_int32_t drops;
+  u_int32_t reads;
+  u_int32_t writes;
+  u_int32_t cache_hits;
+  u_int32_t allocated_dquots;
+  u_int32_t free_dquots;
+  u_int32_t syncs;
+  u_int32_t version;
+};
+
+struct dqblk_v1 {
+  u_int32_t dqb_bhardlimit;
+  u_int32_t dqb_bsoftlimit;
+  u_int32_t dqb_curblocks;
+  u_int32_t dqb_ihardlimit;
+  u_int32_t dqb_isoftlimit;
+  u_int32_t dqb_curinodes;
+  time_t dqb_btime;
+  time_t dqb_itime;
+};
+
+extern long quotactl __P ((unsigned int, const char *, int, caddr_t));
+
+
+
+#endif /* linux */
+
 extern int getnfsquota __P((const struct vol *, const int, const u_int32_t,
                                 struct dqblk *));