From: srittau Date: Sun, 28 Dec 2003 13:51:12 +0000 (+0000) Subject: Linux 2.6 quota interface. [Bjoern] X-Git-Tag: HEAD-before-afp3-merge~1 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=0bec6e01d5a8c42cb5664846d7757904c7f95bfc Linux 2.6 quota interface. [Bjoern] Removed ultrix specific stuff (code cleanup). --- diff --git a/etc/afpd/nfsquota.c b/etc/afpd/nfsquota.c index 61a4b8ec..749ddf5c 100644 --- a/etc/afpd/nfsquota.c +++ b/etc/afpd/nfsquota.c @@ -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 #include #include /* for DEV_BSIZE */ -#include /* on ultrix doesn't include this */ +#include #include #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; diff --git a/etc/afpd/quota.c b/etc/afpd/quota.c index 36bf3bc8..242c5366 100644 --- a/etc/afpd/quota.c +++ b/etc/afpd/quota.c @@ -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 ); diff --git a/etc/afpd/unix.h b/etc/afpd/unix.h index a15cee23..e3a4d86a 100644 --- a/etc/afpd/unix.h +++ b/etc/afpd/unix.h @@ -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 #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 -#endif /* HAVE_SYS_MOUNT_H || BSD4_4 || linux || ultrix */ +#endif /* HAVE_SYS_MOUNT_H */ #if defined(linux) || defined(HAVE_MNTENT_H) #include @@ -79,6 +78,11 @@ typedef int mode_t; #include #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 *));