VxFS quotas

David Lee T.D.Lee at durham.ac.uk
Fri Aug 27 16:44:58 GMT 1999


On Thu, 26 Aug 1999, Dirk De Wachter wrote:

> On 26 Aug 99, at 2:34, David Lee wrote about Re: VxFS quotas (Was: Where to subm:
> 
> > [...]
> > Summary:
> > 1. Change the "#define" from "VXFS" to "VXFS_QUOTA"
> > 2. Make the "include/includes.h" stuff dependent on ths OS-specific file
> >    (e.g. "vx_solaris.h") for those systems that need it (e.g Solaris 2
> >    and NOT HPUX 10.)
> > 3. "#includes ..." (quotas.c line 725) need checking on other OSs
> >    (how relevant is HPUX here?)
> Certainly true. But also, the code that you wrote may work only on 
> SunOS, as many of the defines and struct I cannot find in the HPUX 
> include files. So I would suggest to integrate your code either in 
> the SUNOS part of quotas.c (no influence to other OS) or - for the 
> moment - only activate VXFS(_QUOTA) for SUNOS.

Various "#if defined(...)" ensure that the subroutine is only compiled,
and calling code only inserted, on systems which have both Veritas, and
for which a port has been done.  (So if HPUX handles Veritas quotas
without any change, then the port is null and so, in effect, already
done.)  See the comments in the revised patch, which outline the
assumptions made and hints for further porting (including "#include ...").

> > Shall I produce a revised patch, in accordance with the above summary?
> Please do.

Revised patch (2.0.4b) attached.  (It adjusts configure.in, so remember
to run autoconf and autoheader to regenerate "configure" etc.)

-- 

:  David Lee                                I.T. Service          :
:  Systems Programmer                       Computer Centre       :
:                                           University of Durham  :
:  http://www.dur.ac.uk/~dcl0tdl            South Road            :
:                                           Durham                :
:  Phone: +44 191 374 2882                  U.K.                  :
-------------- next part --------------
*** configure.in.orig	Mon May 17 23:28:10 1999
--- configure.in	Thu Aug 26 18:00:02 1999
***************
*** 194,199 ****
--- 194,202 ----
  AC_CHECK_HEADERS(readline/history.h sys/capability.h syscall.h sys/syscall.h)
  AC_CHECK_HEADERS(sys/acl.h sys/cdefs.h glob.h)
  
+ # For quotas on Veritas VxFS filesystems
+ AC_CHECK_HEADERS(sys/fs/vx_quota.h)
+ 
  AC_CHECK_SIZEOF(int,cross)
  AC_CHECK_SIZEOF(long,cross)
  AC_CHECK_SIZEOF(short,cross)
*** include/includes.h.orig	Sun May  9 05:44:16 1999
--- include/includes.h	Fri Aug 27 14:06:54 1999
***************
*** 673,678 ****
--- 673,686 ----
  #define SYSV 1
  #endif
  
+ /*
+  * Veritas File System.  Often in addition to native.
+  * Quotas different.
+  */
+ #if defined(HAVE_SYS_FS_VX_QUOTA_H)
+ #define VXFS_QUOTA
+ #endif
+ 
  #ifndef DEFAULT_PRINTING
  #ifdef SYSV
  #define DEFAULT_PRINTING PRINT_SYSV
*** smbd/quotas.c.orig	Fri Feb 12 21:41:05 1999
--- smbd/quotas.c	Fri Aug 27 16:57:53 1999
***************
*** 30,35 ****
--- 30,46 ----
  
  extern int DEBUGLEVEL;
  
+ #if defined(VXFS_QUOTA)
+ 
+ /*
+  * In addition to their native filesystems, some systems have Veritas VxFS.
+  * Declare here, define at end: reduces likely "include" interaction problems.
+  *	David Lee <T.D.Lee at durham.ac.uk>
+  */
+ BOOL disk_quotas_vxfs(const pstring name, char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);
+ 
+ #endif /* VXFS_QUOTA */
+ 
  #ifdef LINUX
  
  #include <sys/types.h>
***************
*** 249,255 ****
  #if defined(SUNOS5)
    struct quotctl command;
    int file;
!   struct mnttab mnt;
    static pstring name;
  #else /* SunOS4 */
    struct mntent *mnt;
--- 260,266 ----
  #if defined(SUNOS5)
    struct quotctl command;
    int file;
!   static struct mnttab mnt;
    static pstring name;
  #else /* SunOS4 */
    struct mntent *mnt;
***************
*** 285,291 ****
      }
      
      pstrcpy(name,mnt.mnt_mountp) ;
-     pstrcat(name,"/quotas") ;
      fclose(fd) ;
  #else /* SunOS4 */
      if ((fd = setmntent(MOUNTED, "r")) == NULL)
--- 296,301 ----
***************
*** 311,320 ****
--- 321,340 ----
        return(False) ;
    }
  
+ #if defined(SUNOS5) && defined(VXFS_QUOTA)
+   DEBUG(5,("disk_quotas: mount type \"%s\"\n", mnt.mnt_fstype));
+   if ( 0 == strcmp ( mnt.mnt_fstype, "vxfs" )) {
+     ret = disk_quotas_vxfs(name, path, bsize, dfree, dsize);
+ 
+     return(ret);
+   }
+ #endif
+ 
    euser_id = geteuid();
    set_effective_uid(0);
  
  #if defined(SUNOS5)
+   pstrcat(name,"/quotas") ;
    DEBUG(5,("disk_quotas: looking for quotas file \"%s\"\n", name));
    if((file=sys_open(name, O_RDONLY,0))<0) {
      set_effective_uid(euser_id);
***************
*** 688,690 ****
--- 708,819 ----
  }
  
  #endif
+ 
+ #if defined(VXFS_QUOTA)
+ 
+ /****************************************************************************
+ Try to get the disk space from Veritas disk quotas.
+     David Lee <T.D.Lee at durham.ac.uk> August 1999.
+ 
+ Background assumptions:
+     Potentially under many Operating Systems.  Initially Solaris 2.
+ 
+     My guess is that Veritas is largely, though not entirely,
+     independent of OS.  So I have separated it out.
+ 
+     There may be some details.  For example, OS-specific "include" files.
+ 
+     It is understood that HPUX 10 somehow gets Veritas quotas without
+     any special effort; if so, this routine need not be compiled in.
+         Dirk De Wachter <Dirk.DeWachter at rug.ac.be>
+ 
+ Hints for porting:
+     Add your OS to "IFLIST" below.
+     Get it to compile successfully:
+         Almost certainly "include"s require attention: see SUNOS5.
+     In the main code above, arrange for it to be called: see SUNOS5.
+     Test!
+     
+ ****************************************************************************/
+ 
+ /* "IFLIST"
+  * This "if" is a list of ports:
+  *	if defined(OS1) || defined(OS2) || ...
+  */
+ #if defined(SUNOS5)
+ 
+ #if defined(SUNOS5)
+ #include <sys/fs/vx_solaris.h>
+ #endif
+ #include <sys/fs/vx_machdep.h>
+ #include <sys/fs/vx_layout.h>
+ #include <sys/fs/vx_quota.h>
+ #include <sys/fs/vx_aioctl.h>
+ #include <sys/fs/vx_ioctl.h>
+ 
+ BOOL disk_quotas_vxfs(const pstring name, char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
+ {
+   uid_t user_id, euser_id;
+   int ret;
+   struct vx_dqblk D;
+   struct vx_quotctl quotabuf;
+   struct vx_genioctl genbuf;
+   pstring qfname;
+   int file;
+ 
+   pstrcpy(qfname, name) ;
+   pstrcat(qfname, "/quotas") ;
+ 
+   euser_id = geteuid();
+   set_effective_uid(0);
+ 
+   DEBUG(5,("disk_quotas: looking for VxFS quotas file \"%s\"\n", qfname));
+   if((file=sys_open(qfname, O_RDONLY,0))<0) {
+     set_effective_uid(euser_id);
+     return(False);
+   }
+   genbuf.ioc_cmd = VX_QUOTACTL;
+   genbuf.ioc_up = (void *) &quotabuf;
+ 
+   quotabuf.cmd = VX_GETQUOTA;
+   quotabuf.uid = euser_id;
+   quotabuf.addr = (caddr_t) &D;
+   ret = ioctl(file, VX_ADMIN_IOCTL, &genbuf);
+   close(file);
+ 
+   set_effective_uid(euser_id);
+ 
+   if (ret < 0) {
+     DEBUG(5,("disk_quotas ioctl (VxFS) failed. Error = %s\n", strerror(errno) ));
+     return(False);
+   }
+ 
+   /* Use softlimit to determine disk space. A user exceeding the quota is told
+    * that there's no space left. Writes might actually work for a bit if the
+    * hardlimit is set higher than softlimit. Effectively the disk becomes
+    * made of rubber latex and begins to expand to accommodate the user :-)
+    */
+   DEBUG(5,("disk_quotas for path \"%s\" block c/s/h %ld/%ld/%ld; file c/s/h %ld/%ld/%ld\n",
+          path, D.dqb_curblocks, D.dqb_bsoftlimit, D.dqb_bhardlimit,
+          D.dqb_curfiles, D.dqb_fsoftlimit, D.dqb_fhardlimit));
+ 
+   if (D.dqb_bsoftlimit==0)
+     return(False);
+   *bsize = DEV_BSIZE;
+   *dsize = D.dqb_bsoftlimit;
+ 
+   if (D.dqb_curblocks > D.dqb_bsoftlimit) {
+      *dfree = 0;
+      *dsize = D.dqb_curblocks;
+   } else
+     *dfree = D.dqb_bsoftlimit - D.dqb_curblocks;
+       
+   DEBUG(5,("disk_quotas for path \"%s\" returning  bsize %.0f, dfree %.0f, dsize %.0f\n",
+          path,(double)*bsize,(double)*dfree,(double)*dsize));
+ 
+   return(True);
+ }
+ 
+ #endif /* SUNOS5 || ... */
+ 
+ #endif /* VXFS_QUOTA */


More information about the samba-technical mailing list