summaryrefslogtreecommitdiffstats
path: root/source/smbd/quotas.c
diff options
context:
space:
mode:
authorSamba Release Account <samba-bugs@samba.org>1997-06-11 01:03:06 +0000
committerSamba Release Account <samba-bugs@samba.org>1997-06-11 01:03:06 +0000
commit957025bace1bcff34d21a6caeca498e85abccb23 (patch)
tree361b9ec5c43dbe8545f9a3b9423810f67339b072 /source/smbd/quotas.c
parent76647c0609773a190055f78486380218d6e080e7 (diff)
downloadsamba-957025bace1bcff34d21a6caeca498e85abccb23.tar.gz
samba-957025bace1bcff34d21a6caeca498e85abccb23.tar.xz
samba-957025bace1bcff34d21a6caeca498e85abccb23.zip
Makefile: Added quoata changes for Linux from Thorvald Natvig
Makefile.RPM: Added quoata changes for Linux from Thorvald Natvig charset.c: Large changes to add multiple client code pages. charset.h: Changed charset_initialise() proto. client.c: Fixed message sending bug. Changed charset_initialise(). ipc.c: Fixed #ifdef compile problems. loadparm.c: Added "client code page" option. nmbd.c: Changed charset_initialise(). Fixed lmhosts read. nmblookup.c: Changed charset_initialise(). proto.h: Added lp_client_code_page(void). quotas.c: Added quoata changes for Linux from Thorvald Natvig reply.c: Changed debug level. Made SMBecho ignore tid. server.c: Changed charset_initialise(). smb.h: Added DEFAULT_CLIENT_CODE_PAGE as 850. smbpasswd.c: Changed charset_initialise(). status.c: Changed charset_initialise(). testparm.c: Changed charset_initialise(). testprns.c: Changed charset_initialise(). Jeremy Allison (jallison@whistle.com)
Diffstat (limited to 'source/smbd/quotas.c')
-rw-r--r--source/smbd/quotas.c94
1 files changed, 42 insertions, 52 deletions
diff --git a/source/smbd/quotas.c b/source/smbd/quotas.c
index eba76d4c74b..a1d29bcd12e 100644
--- a/source/smbd/quotas.c
+++ b/source/smbd/quotas.c
@@ -33,47 +33,43 @@ extern int DEBUGLEVEL;
#ifdef LINUX
-#ifdef __KERNEL__
-# undef __KERNEL__
-# include <sys/quota.h>
-# define __KERNEL__
-#else
-# include <sys/quota.h>
-#endif
+#include <sys/types.h>
+#include <asm/types.h>
+#include <sys/quota.h>
#include <mntent.h>
+#include <linux/unistd.h>
+
+_syscall4(int, quotactl, int, cmd, const char *, special, int, id, caddr_t, addr);
/****************************************************************************
try to get the disk space from disk quotas (LINUX version)
****************************************************************************/
-/*
-If you didn't make the symlink to the quota package, too bad :(
-*/
-#include "quota/quotactl.c"
-#include "quota/hasquota.c"
+
BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
{
uid_t euser_id;
+ int r;
+ char dev_disk[256];
struct dqblk D;
struct stat S;
- dev_t devno ;
- struct mntent *mnt;
FILE *fp;
- int found ;
- int qcmd, fd ;
- char *qfpathname;
+ struct mntent *mnt;
+ int devno;
+ int found;
/* find the block device file */
- if ( stat(path, &S) == -1 )
+ if ( stat(path, &S) == -1 ) {
return(False) ;
+ }
devno = S.st_dev ;
fp = setmntent(MOUNTED,"r");
found = False ;
- while ((mnt = getmntent(fp)) != (struct mntent *) 0) {
+ while ((mnt = getmntent(fp))) {
if ( stat(mnt->mnt_dir,&S) == -1 )
continue ;
if (S.st_dev == devno) {
@@ -83,48 +79,42 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
}
endmntent(fp) ;
- if ( ! found )
- return(False) ;
-
- qcmd = QCMD(Q_GETQUOTA, USRQUOTA);
-
- if (hasmntopt(mnt, MNTOPT_NOAUTO) || hasmntopt(mnt, MNTOPT_NOQUOTA))
- return(False) ;
-
- if (!hasquota(mnt, USRQUOTA, &qfpathname))
- return(False) ;
-
- euser_id = geteuid();
- seteuid(0);
-
- if (quotactl(qcmd, mnt->mnt_fsname, euser_id, (caddr_t)&D) != 0) {
- if ((fd = open(qfpathname, O_RDONLY)) < 0) {
- seteuid(euser_id);
+ if (!found) {
return(False);
}
- lseek(fd, (long) dqoff(euser_id), L_SET);
- switch (read(fd, &D, sizeof(struct dqblk))) {
- case 0:/* EOF */
- memset((caddr_t)&D, 0, sizeof(struct dqblk));
- break;
- case sizeof(struct dqblk): /* OK */
- break;
- default: /* ERROR */
- close(fd);
+
+ euser_id=geteuid();
+ seteuid(0);
+ r=quotactl(QCMD(Q_GETQUOTA,USRQUOTA), mnt->mnt_fsname, euser_id, (caddr_t)&D);
seteuid(euser_id);
- return(False);
+
+ /* Use softlimit to determine disk space, except when it has been exceeded */
+ *bsize = 1024;
+ if (r)
+ {
+ if (errno == EDQUOT)
+ {
+ *dfree =0;
+ *dsize =D.dqb_curblocks;
+ return (True);
}
+ else return(False);
}
- seteuid(euser_id);
- *bsize=1024;
-
- if (D.dqb_bsoftlimit==0)
- return(False);
- if ((D.dqb_curblocks>D.dqb_bsoftlimit)||(D.dqb_curinodes>D.dqb_isoftlimit))
+ /* Use softlimit to determine disk space, except when it has been exceeded */
+ if (
+ (D.dqb_bsoftlimit && D.dqb_curblocks>=D.dqb_bsoftlimit) ||
+ (D.dqb_bhardlimit && D.dqb_curblocks>=D.dqb_bhardlimit) ||
+ (D.dqb_isoftlimit && D.dqb_curinodes>=D.dqb_isoftlimit) ||
+ (D.dqb_ihardlimit && D.dqb_curinodes>=D.dqb_ihardlimit)
+ )
{
*dfree = 0;
*dsize = D.dqb_curblocks;
}
+ else if (D.dqb_bsoftlimit==0 && D.dqb_bhardlimit==0)
+ {
+ return(False);
+ }
else {
*dfree = D.dqb_bsoftlimit - D.dqb_curblocks;
*dsize = D.dqb_bsoftlimit;