]> arthur.barton.de Git - netatalk.git/commitdiff
Linux 2.6 quota interface. [Bjoern]
authorsrittau <srittau>
Sun, 28 Dec 2003 13:51:12 +0000 (13:51 +0000)
committersrittau <srittau>
Sun, 28 Dec 2003 13:51:12 +0000 (13:51 +0000)
Removed ultrix specific stuff (code cleanup).

etc/afpd/nfsquota.c
etc/afpd/quota.c
etc/afpd/unix.h

index 61a4b8ec435cedbf37cbd449240f8078556bec33..749ddf5c1952a466a4675d2d9b1c3edf2542644a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: nfsquota.c,v 1.10 2002-08-29 17:22:06 jmarcus Exp $
+ * $Id: nfsquota.c,v 1.11 2003-12-28 13:51:12 srittau Exp $
  *
  * parts of this are lifted from the bsd quota program and are
  * therefore under the following copyright:
@@ -38,7 +38,7 @@ char *strchr (), *strrchr ();
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/param.h> /* for DEV_BSIZE */
-#include <sys/time.h>  /* <rpc/rpc.h> on ultrix doesn't include this */
+#include <sys/time.h>
 #include <atalk/logger.h>
 
 #ifdef HAVE_NETDB_H
@@ -163,15 +163,15 @@ int getnfsquota(const struct vol *vol, const int uid, const u_int32_t bsize,
             gq_rslt.GQR_RQUOTA.rq_bhardlimit*NFS_BSIZE;
         dqp->dqb_bsoftlimit =
             gq_rslt.GQR_RQUOTA.rq_bsoftlimit*NFS_BSIZE;
+#ifdef HAVE_STRUCT_IF_DQBLK
+       dqp->dqb_curspace =
+#else
         dqp->dqb_curblocks =
+#endif
             gq_rslt.GQR_RQUOTA.rq_curblocks*NFS_BSIZE;
 
-#ifdef ultrix
-        dqp->dqb_bwarn = gq_rslt.GQR_RQUOTA.rq_btimeleft;
-#else /* ultrix */
         dqp->dqb_btimelimit =
             tv.tv_sec + gq_rslt.GQR_RQUOTA.rq_btimeleft;
-#endif /* ultrix */
 
         *hostpath = ':';
         return AFP_OK;
index 36bf3bc84f24b68ae63330ba6d3e29b71b50eced..242c5366c2a6b3630075f7a03751efc87d498931 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: quota.c,v 1.23 2003-12-15 04:49:56 srittau Exp $
+ * $Id: quota.c,v 1.24 2003-12-28 13:51:12 srittau Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -95,31 +95,6 @@ int         *nfs;
 }
 
 #else /* __svr4__ */
-#ifdef ultrix
-/*
-* Return the block-special device name associated with the filesystem
-* on which "file" resides.  Returns NULL on failure.
-*/
-
-static char *
-special( file, nfs )
-char *file;
-int  *nfs;
-{
-    static struct fs_data      fsd;
-
-    if ( getmnt(0, &fsd, 0, STAT_ONE, file ) < 0 ) {
-        LOG(log_info, logtype_afpd, "special: getmnt %s: %s", file, strerror(errno) );
-        return( NULL );
-    }
-
-    /* XXX: does this really detect an nfs mounted fs? */
-    if (strchr(fsd.fd_req.devname, ':'))
-        *nfs = 1;
-    return( fsd.fd_req.devname );
-}
-
-#else /* ultrix */
 #if (defined(HAVE_SYS_MOUNT_H) && !defined(__linux__)) || defined(BSD4_4) || defined(_IBMR2)
 
 static char *
@@ -188,7 +163,6 @@ int *nfs;
 }
 
 #endif /* BSD4_4 */
-#endif /* ultrix */
 #endif /* __svr4__ */
 
 
@@ -208,11 +182,6 @@ struct dqblk        *dq;
     }
 
 #else /* __svr4__ */
-#ifdef ultrix
-    if ( quota( Q_GETDLIM, uid, vol->v_gvs, dq ) != 0 ) {
-        return( AFPERR_PARAM );
-    }
-#else /* ultrix */
 
 #ifndef USRQUOTA
 #define USRQUOTA   0
@@ -271,8 +240,13 @@ struct dqblk        *dq;
     /* set stuff up for group quotas if necessary */
 
     /* max(user blocks, group blocks) */
+#ifdef HAVE_STRUCT_IF_DQBLK
+    if (dqg.dqb_curspace && (dq->dqb_curspace < dqg.dqb_curspace))
+        dq->dqb_curspace = dqg.dqb_curspace;
+#else
     if (dqg.dqb_curblocks && (dq->dqb_curblocks < dqg.dqb_curblocks))
         dq->dqb_curblocks = dqg.dqb_curblocks;
+#endif
 
     /* min(user limit, group limit) */
     if (dqg.dqb_bhardlimit && (!dq->dqb_bhardlimit ||
@@ -291,7 +265,6 @@ struct dqblk        *dq;
 
 #endif /* TRU64 */
 
-#endif /* ultrix */
 #endif /* __svr4__ */
 
     return AFP_OK;
@@ -389,14 +362,13 @@ struct dqblk      *dqblk;
 {
     struct timeval     tv;
 
+#ifdef HAVE_STRUCT_IF_DQBLK
+    if ( dqblk->dqb_curspace < dqblk->dqb_bsoftlimit ) {
+#else
     if ( dqblk->dqb_curblocks < dqblk->dqb_bsoftlimit ) {
-        return( 0 );
-    }
-#ifdef ultrix
-    if ( dqblk->dqb_bwarn ) {
-        return( 0 );
+#endif
+        return 0 ;
     }
-#else /* ultrix */
     if ( gettimeofday( &tv, 0 ) < 0 ) {
         LOG(log_error, logtype_afpd, "overquota: gettimeofday: %s", strerror(errno) );
         return( AFPERR_PARAM );
@@ -404,7 +376,6 @@ struct dqblk        *dqblk;
     if ( dqblk->dqb_btimelimit && dqblk->dqb_btimelimit > tv.tv_sec ) {
         return( 0 );
     }
-#endif /* ultrix */
     return( 1 );
 }
 
@@ -448,14 +419,23 @@ const u_int32_t bsize;
     if (dqblk.dqb_bsoftlimit == 0 && dqblk.dqb_bhardlimit == 0) {
         *btotal = *bfree = ~((VolSpace) 0);
     } else if ( overquota( &dqblk )) {
+#ifdef HAVE_STRUCT_IF_DQBLK
+        if ( tobytes( dqblk.dqb_curspace, bsize ) > tobytes( dqblk.dqb_bhardlimit, bsize ) ) {
+            *btotal = tobytes( dqblk.dqb_curspace, bsize );
+#else
         if ( tobytes( dqblk.dqb_curblocks, bsize ) > tobytes( dqblk.dqb_bhardlimit, bsize ) ) {
             *btotal = tobytes( dqblk.dqb_curblocks, bsize );
+#endif
             *bfree = 0;
         }
         else {
             *btotal = tobytes( dqblk.dqb_bhardlimit, bsize );
             *bfree = tobytes( dqblk.dqb_bhardlimit, bsize ) -
+#ifdef HAVE_STRUCT_IF_DQBLK
+                     tobytes( dqblk.dqb_curspace, bsize );
+#else
                      tobytes( dqblk.dqb_curblocks, bsize );
+#endif
         }
     } else {
         *btotal = tobytes( dqblk.dqb_bsoftlimit, bsize );
index a15cee23c031e6b76ca7194f6c4325b7bd5743fb..e3a4d86a9601bcba1545ca0d5d5f11dac49a4ae3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: unix.h,v 1.15 2003-12-15 04:59:45 srittau Exp $
+ * $Id: unix.h,v 1.16 2003-12-28 13:51:12 srittau Exp $
  */
 
 #ifndef AFPD_UNIX_H
@@ -42,10 +42,9 @@ 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)
+#ifdef HAVE_SYS_MOUNT_H
 #include <sys/mount.h>
-#endif /* HAVE_SYS_MOUNT_H || BSD4_4 || linux || ultrix */
+#endif /* HAVE_SYS_MOUNT_H */
 
 #if defined(linux) || defined(HAVE_MNTENT_H)
 #include <mntent.h>
@@ -79,6 +78,11 @@ typedef int  mode_t;
 #include <sys/stat.h>
 #include "directory.h"
 
+#ifdef HAVE_STRUCT_IF_DQBLK
+#undef dqblk
+#define dqblk if_dqblk
+#endif
+
 extern int getnfsquota __P((const struct vol *, const int, const u_int32_t,
                                 struct dqblk *));