xfs
[Top] [All Lists]

Re: Samba 2.2.1 and Linux XFS quota

Subject: Re: Samba 2.2.1 and Linux XFS quota
From: Matthew Geier <matthew@xxxxxxxxxxxxxxxx>
Date: Tue, 24 Jul 2001 13:10:06 +1000
Cc: linux-xfs@xxxxxxxxxxx, samba-technical@xxxxxxxxx
Organization: Arts IT Unit, Sydney University
References: <3B52A14E.6D0D4FA5@ch.sauter-bc.com><3B563C52.A3101025@xfs.lists.logout.sh> <20010720010215.77ebf768.jpenix@projectdesign.com> <010d01c11103$53d55af0$2df958c1@mpb> <3B58C4BE.E2535CA0@arts.usyd.edu.au> <20010723074836.C230215@wobbly.melbourne.sgi.com>
Sender: owner-linux-xfs@xxxxxxxxxxx
Nathan Scott wrote:

> On Sat, Jul 21, 2001 at 09:54:38AM +1000, Matthew Geier wrote:
> > ...
> >  I did notice one problem with Samba on XFS systems. Quota support
> > doesn't work. After a look in smbd/quota.c, I see the quota's don't work


> look through that file.  In fact, having just looked through that file,
> I see the IRIX quota system call interface is recognised (which is quite
> similar to the Linux/XFS interface), so someone should be able to join
> the dots here and make this code work for Linux/XFS.
> 



 Here is a first attempt at it if any one is interested. Seems to work
for me, but I havent tested it to hard. Im also not sure I did it the
right way either :-)

 Its quite dumb - it assume XFS quotas or 'linux' quotas. I just wrapped
the changes around #ifdefs. I didn't try and copy the irix code where it
changes what structures it uses depending on the file system type it
finds.

Its also full of DEBUG(0 statements so I could 'trace' what ended up
where.

--- quotas.c.orig       Fri Jul  6 12:02:03 2001
+++ quotas.c    Mon Jul 23 18:44:19 2001
@@ -43,12 +43,18 @@
 
 #ifdef LINUX
 
+#define XFS    /* MG - Tag XFS quota changes, dunno how to configure */
+               /* Mostly pinched from the IRIX section */
+
 #include <sys/types.h>
 #include <asm/types.h>
 #include <sys/quota.h>
 
 #include <mntent.h>
 #include <linux/unistd.h>
+#ifdef XFS
+#include <linux/xqm.h>
+#endif
 
 _syscall4(int, quotactl, int, cmd, const char *, special, int, id,
caddr_t, addr);
 
@@ -60,6 +66,9 @@
 {
   int r;
   struct dqblk D;
+#ifdef XFS
+       struct fs_disk_quota F;
+#endif
   SMB_STRUCT_STAT S;
   FILE *fp;
   struct mntent *mnt;
@@ -96,6 +105,50 @@
 
   save_re_uid();
   set_effective_uid(0);  
+
+#ifdef XFS
+       r=quotactl (QCMD(Q_XGETQUOTA,USRQUOTA), mnt->mnt_fsname, euser_id,
(caddr_t) &F);
+
+    restore_re_uid();
+DEBUG(0,("xfs_quotas: %s, %i, used %i
\n",mnt->mnt_fsname,euser_id,F.d_bcount));
+DEBUG(0,("xfs_quotas:r is %i\n",r));
+/*   if (ret==-1)
+       {
+       DEBUG(0,("xfs_quotas: ret evaluated -1 r is %i\n",r));
+     return(False); 
+       }
+ */
+
+DEBUG(0,("xfs_quotas: d_blk_softlimit %i, d_blk_hardlimit %i\n"
+           ,F.d_blk_softlimit,F.d_blk_hardlimit));
+   /* Use softlimit to determine disk space, except when it has been
exceeded */
+    if (
+        (F.d_blk_softlimit && F.d_bcount>=F.d_blk_softlimit) ||
+        (F.d_blk_hardlimit && F.d_bcount>=F.d_blk_hardlimit) ||
+        (F.d_ino_softlimit && F.d_icount>=F.d_ino_softlimit) ||
+        (F.d_ino_hardlimit && F.d_icount>=F.d_ino_hardlimit)
+       )
+    {
+DEBUG(0,("xfs_quotas: No blocks free\n"));
+
+      *dfree = 0;
+      *dsize = F.d_bcount;
+    }
+    else if (F.d_blk_softlimit==0 && F.d_blk_hardlimit==0)
+    {
+      return(False);
+    }
+    else
+    {
+      *dfree = (F.d_blk_softlimit - F.d_bcount);
+      *dsize = F.d_blk_softlimit;
+    }
+
+
+  return (True);
+
+
+#else
   r=quotactl(QCMD(Q_GETQUOTA,USRQUOTA), mnt->mnt_fsname, euser_id,
(caddr_t)&D);
   restore_re_uid();
 
@@ -133,6 +186,9 @@
     *dsize = D.dqb_bsoftlimit;
   }
   return (True);
+
+#endif
+
 }
 
 #elif defined(CRAY)
sh-2.04# 

-- 
Matthew Geier                   matthew@xxxxxxxxxxxxxxxx
Arts IT Unit                    +61 2 9351 4713
Sydney University

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

<Prev in Thread] Current Thread [Next in Thread>