Linux group quota Patch for Samba 3.0.1pre3

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


Hi,
I found, that Samba 3.0.1pre3 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.1pre3

--- quotas.c.orig	Sat Jun  7 19:57:39 2003
+++ quotas.c	Tue Nov 18 20:46:15 2003
@@ -98,8 +98,18 @@
 #ifdef HAVE_LINUX_XQM_H
        struct fs_disk_quota D;
+	   gid_t egrp_id;
+
        ZERO_STRUCT(D);
+       egrp_id = getegid();
+
+       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;
@@ -121,4 +131,5 @@
 {
 	int ret;
+	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