Where to submit patches?

David Lee T.D.Lee at durham.ac.uk
Wed Aug 25 09:54:41 GMT 1999


On Wed, 25 Aug 1999, Jeremy Allison wrote:

> David Lee wrote:
> > 
> > The patches are:
> > 1. Implement quotas on Veritas File System (vxfs).
> 
> Sounds good.

Patch attached...

Veritas is available for many OSes.  Handling of quotas is very
OS-specific.  Also a system may have a mixture of native and Veritas
filesystems.  So I have separated out the handling of Veritas quotas into
a subroutine, callable from the OS-specific subroutine (in my test case,
Solaris 2.)

-- 

:  David Lee                                I.T. Service          :
:  Systems Programmer                       Computer Centre       :
:                                           University of Durham  :
:  Phone:    +44 191 374 2882 (ddi)         South Road            :
:  Fax:      +44 191 374 7759               Durham                :
:  Internet: T.D.Lee at durham.ac.uk           U.K.                  :
-------------- next part --------------
*** configure.in.orig	Mon May 17 23:28:10 1999
--- configure.in	Wed Aug 11 15:00:41 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_ioctl.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 13 11:40:09 1999
***************
*** 673,678 ****
--- 673,684 ----
  #define SYSV 1
  #endif
  
+ /* Veritas File System (often in addition to native).  Quotas different.
+  */
+ #if defined(HAVE_SYS_FS_VX_IOCTL_H)
+ #define VXFS
+ #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 13 11:40:52 1999
***************
*** 30,35 ****
--- 30,46 ----
  
  extern int DEBUGLEVEL;
  
+ #if defined(VXFS)
+ 
+ /*
+  * 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 */
+ 
  #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)
+   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,791 ----
  }
  
  #endif
+ 
+ /****************************************************************************
+ Try to get the disk space from Veritas disk quotas.
+ Potentially under many Operating Systems.  Initially Solaris 2.
+ Initial Solaris 2 code: David Lee <T.D.Lee at durham.ac.uk> August 1999.
+ ****************************************************************************/
+ 
+ #if defined(VXFS)
+ 
+ #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 s/h %ld/%ld; file s/h %ld/%ld\n",
+          path, D.dqb_bsoftlimit, D.dqb_bhardlimit, 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 /* VXFS */


More information about the samba-technical mailing list