Linux group quota Patch for Samba 3.0.0

Heinreichsberger, Helmut Helmut.Heinreichsberger at wincor-nixdorf.com
Tue Nov 18 20:44:56 GMT 2003


Hi,
I found, that Samba 3.0.0 dosn't support group quotas on XFS filesystems.
When you have many projects and you have to resize the available space then
ist is the best way to use group quotas and a large disk array.
But the shown available space is wrong.
This patch corrects the problem of the displayed disk size and available
space

quotas.c.orig ist the original quotas.c from samba 3.0.0

--- quotas.c.orig	Fri Jun  6 16:53:27 2003
+++ quotas.c	Tue Nov 18 20:38:12 2003
@@ -98,8 +98,18 @@
 #ifdef HAVE_LINUX_XQM_H
        struct fs_disk_quota D;
+	   gid_t egrp_id;
+
        ZERO_STRUCT(D);
+       egrp_id = getdgid();
+
+       ret = quotactl(QCMD(Q_XGETQUOTA,USRQUOTA), path, euser_id,
(caddr_t)&D);
+
+       /* As XFS has group quotas, if getting the user
+          quota fails, try getting the group instead. */
+       if (ret)
+           ret = quotactl(QCMD(Q_XGETQUOTA,GRPQUOTA), path, egrp_id,
(caddr_t)&D);
 
-       if ((ret = quotactl(QCMD(Q_XGETQUOTA,USRQUOTA), path, euser_id,
(caddr_t)&D)))
-               return ret;
+       if (ret)
+           return ret;
 
        dp->bsize = (SMB_BIG_UINT)512;
@@ -120,5 +130,6 @@
 static int get_smb_linux_vfs_quota(char *path, uid_t euser_id,
LINUX_SMB_DISK_QUOTA *dp)
 {
-	int ret;
+	int ret = -1;
+	gid_t egrp_id;
 #ifdef LINUX_QUOTAS_1
 	struct dqblk D;
@@ -134,6 +145,15 @@
 #endif
 
-	if ((ret = quotactl(QCMD(Q_GETQUOTA,USRQUOTA), path, euser_id,
(caddr_t)&D)))
-		return -1;
+	egrp_id = getegid();
+
+	ret = quotactl(QCMD(Q_GETQUOTA,USRQUOTA), path, euser_id,
(caddr_t)&D);
+
+	/* Linux can have group quotas, if getting the user
+       quota fails, try getting the group instead. */
+	if (ret)
+		ret = quotactl(QCMD(Q_GETQUOTA,GRPQUOTA), path, egrp_id,
(caddr_t)&D);
+
+	if (ret)
+		return ret;
 
 	dp->softlimit = (SMB_BIG_UINT)D.dqb_bsoftlimit;
@@ -149,5 +169,5 @@
 #endif
 
-	return 0;
+	return ret;
 }
--------------------------------------- Patch End


Regards
Helmut Heinreichsberger
Email: Helmut.Heinreichsberger at chello.at



More information about the samba-technical mailing list