Use {u,}int64_t instead of SMB_BIG_{U,}INT.
[samba.git] / source3 / lib / sysquotas_4A.c
index 66b367f0990425db45817b7a5fb8c2acc27fac37..8a1b12238cca88e449297eca1381da6dee785a06 100644 (file)
@@ -5,7 +5,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 
 #include "includes.h"
 
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_QUOTA
+
+#ifndef HAVE_SYS_QUOTAS
+#ifdef HAVE_QUOTACTL_4A
+#undef HAVE_QUOTACTL_4A
+#endif
+#endif
+
 #ifdef HAVE_QUOTACTL_4A
 /* long quotactl(int cmd, char *special, qid_t id, caddr_t addr) */
 /* this is used by: HPUX,IRIX */
@@ -81,7 +89,7 @@ int sys_get_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
        int ret = -1;
        uint32 qflags = 0;
        struct dqblk D;
-       SMB_BIG_UINT bsize = (SMB_BIG_UINT)QUOTABLOCK_SIZE;
+       uint64_t bsize = (uint64_t)QUOTABLOCK_SIZE;
 
        ZERO_STRUCT(D);
        ZERO_STRUCT(*dp);
@@ -89,7 +97,10 @@ int sys_get_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
 
        switch (qtype) {
                case SMB_USER_QUOTA_TYPE:
-                       if ((ret = quotactl(QCMD(Q_GETQUOTA,USRQUOTA), bdev, id.uid, (void *)&D))&&errno != EDQUOT) {
+                       DEBUG(10,("sys_get_vfs_quota: path[%s] bdev[%s] SMB_USER_QUOTA_TYPE uid[%u]\n",
+                               path, bdev, (unsigned)id.uid));
+
+                       if ((ret = quotactl(QCMD(Q_GETQUOTA,USRQUOTA), (caddr_t)bdev, id.uid, (void *)&D))&&errno != EDQUOT) {
                                return ret;
                        }
 
@@ -103,7 +114,10 @@ int sys_get_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
                        break;
 #ifdef HAVE_GROUP_QUOTA
                case SMB_GROUP_QUOTA_TYPE:
-                       if ((ret = quotactl(QCMD(Q_GETQUOTA,GRPQUOTA), bdev, id.gid, (void *)&D))&&errno != EDQUOT) {
+                       DEBUG(10,("sys_get_vfs_quota: path[%s] bdev[%s] SMB_GROUP_QUOTA_TYPE gid[%u]\n",
+                               path, bdev, (unsigned)id.gid));
+
+                       if ((ret = quotactl(QCMD(Q_GETQUOTA,GRPQUOTA), (caddr_t)bdev, id.gid, (void *)&D))&&errno != EDQUOT) {
                                return ret;
                        }
 
@@ -119,7 +133,10 @@ int sys_get_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
                case SMB_USER_FS_QUOTA_TYPE:
                        id.uid = getuid();
 
-                       if ((ret = quotactl(QCMD(Q_GETQUOTA,USRQUOTA), bdev, id.uid, (void *)&D))==0) {
+                       DEBUG(10,("sys_get_vfs_quota: path[%s] bdev[%s] SMB_USER_FS_QUOTA_TYPE (uid[%u])\n",
+                               path, (caddr_t)bdev, (unsigned)id.uid));
+
+                       if ((ret = quotactl(QCMD(Q_GETQUOTA,USRQUOTA), (caddr_t)bdev, id.uid, (void *)&D))==0) {
                                qflags |= QUOTAS_DENY_DISK;
                        }
 
@@ -129,7 +146,10 @@ int sys_get_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
                case SMB_GROUP_FS_QUOTA_TYPE:
                        id.gid = getgid();
 
-                       if ((ret = quotactl(QCMD(Q_GETQUOTA,GRPQUOTA), bdev, id.gid, (void *)&D))==0) {
+                       DEBUG(10,("sys_get_vfs_quota: path[%s] bdev[%s] SMB_GROUP_FS_QUOTA_TYPE (gid[%u])\n",
+                               path, bdev, (unsigned)id.gid));
+
+                       if ((ret = quotactl(QCMD(Q_GETQUOTA,GRPQUOTA), (caddr_t)bdev, id.gid, (void *)&D))==0) {
                                qflags |= QUOTAS_DENY_DISK;
                        }
 
@@ -142,12 +162,12 @@ int sys_get_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
        }
 
        dp->bsize = bsize;
-       dp->softlimit = (SMB_BIG_UINT)D.dqb_bsoftlimit;
-       dp->hardlimit = (SMB_BIG_UINT)D.dqb_bhardlimit;
-       dp->ihardlimit = (SMB_BIG_UINT)D.dqb_ihardlimit;
-       dp->isoftlimit = (SMB_BIG_UINT)D.dqb_isoftlimit;
-       dp->curinodes = (SMB_BIG_UINT)D.dqb_curinodes;
-       dp->curblocks = (SMB_BIG_UINT)D.dqb_curblocks;
+       dp->softlimit = (uint64_t)D.dqb_bsoftlimit;
+       dp->hardlimit = (uint64_t)D.dqb_bhardlimit;
+       dp->ihardlimit = (uint64_t)D.dqb_ihardlimit;
+       dp->isoftlimit = (uint64_t)D.dqb_isoftlimit;
+       dp->curinodes = (uint64_t)D.dqb_curinodes;
+       dp->curblocks = (uint64_t)D.dqb_curblocks;
 
 
        dp->qflags = qflags;
@@ -164,7 +184,7 @@ int sys_set_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
        uint32 qflags = 0;
        uint32 oldqflags = 0;
        struct dqblk D;
-       SMB_BIG_UINT bsize = (SMB_BIG_UINT)QUOTABLOCK_SIZE;
+       uint64_t bsize = (uint64_t)QUOTABLOCK_SIZE;
 
        ZERO_STRUCT(D);
 
@@ -184,11 +204,17 @@ int sys_set_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
 
        switch (qtype) {
                case SMB_USER_QUOTA_TYPE:
-                       ret = quotactl(QCMD(Q_SETQLIM,USRQUOTA), bdev, id.uid, (void *)&D);
+                       DEBUG(10,("sys_set_vfs_quota: path[%s] bdev[%s] SMB_USER_QUOTA_TYPE uid[%u]\n",
+                               path, bdev, (unsigned)id.uid));
+
+                       ret = quotactl(QCMD(Q_SETQLIM,USRQUOTA), (caddr_t)bdev, id.uid, (void *)&D);
                        break;
 #ifdef HAVE_GROUP_QUOTA
                case SMB_GROUP_QUOTA_TYPE:
-                       ret = quotactl(QCMD(Q_SETQLIM,GRPQUOTA), bdev, id.gid, (void *)&D);
+                       DEBUG(10,("sys_set_vfs_quota: path[%s] bdev[%s] SMB_GROUP_QUOTA_TYPE gid[%u]\n",
+                               path, bdev, (unsigned)id.gid));
+
+                       ret = quotactl(QCMD(Q_SETQLIM,GRPQUOTA), (caddr_t)bdev, id.gid, (void *)&D);
                        break;
 #endif /* HAVE_GROUP_QUOTA */
                case SMB_USER_FS_QUOTA_TYPE:
@@ -202,10 +228,12 @@ int sys_set_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
                         * we need to fix sys_path_to_bdev()
                         *
                         */
-#if 0
                        id.uid = getuid();
+                       DEBUG(10,("sys_set_vfs_quota: path[%s] bdev[%s] SMB_USER_FS_QUOTA_TYPE (uid[%u])\n",
+                               path, bdev, (unsigned)id.uid));
 
-                       ret = quotactl(QCMD(Q_GETQUOTA,USRQUOTA), bdev, id.uid, (void *)&D);
+#if 0
+                       ret = quotactl(QCMD(Q_GETQUOTA,USRQUOTA), (caddr_t)bdev, id.uid, (void *)&D);
 
                        if ((qflags&QUOTAS_DENY_DISK)||(qflags&QUOTAS_ENABLED)) {
                                if (ret == 0) {
@@ -218,25 +246,23 @@ int sys_set_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
                                                return -1;
                                        }
                                        
-                                       ret = quotactl(QCMD(Q_QUOTAON,USRQUOTA), bdev, -1,(void *)quota_file);
+                                       ret = quotactl(QCMD(Q_QUOTAON,USRQUOTA), (caddr_t)bdev, -1,(void *)quota_file);
                                } else {
                                        ret = 0;        
                                }
                        } else {
                                if (ret != 0) {
                                        /* turn off */
-                                       ret = quotactl(QCMD(Q_QUOTAOFF,USRQUOTA), bdev, -1, (void *)0); 
+                                       ret = quotactl(QCMD(Q_QUOTAOFF,USRQUOTA), (caddr_t)bdev, -1, (void *)0);        
                                } else {
                                        ret = 0;
                                }               
                        }
 
-                       DEBUG(0,("vfs_fs_quota: ret(%d) errno(%d)[%s] uid(%d) bdev[%s]\n",
+                       DEBUG(0,("sys_set_vfs_quota: ret(%d) errno(%d)[%s] uid(%d) bdev[%s]\n",
                                ret,errno,strerror(errno),id.uid,bdev));
 #else
-                       id.uid = getuid();
-
-                       if ((ret = quotactl(QCMD(Q_GETQUOTA,USRQUOTA), bdev, id.uid, (void *)&D))==0) {
+                       if ((ret = quotactl(QCMD(Q_GETQUOTA,USRQUOTA), (caddr_t)bdev, id.uid, (void *)&D))==0) {
                                oldqflags |= QUOTAS_DENY_DISK;
                        }
 
@@ -259,9 +285,11 @@ int sys_set_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
                         * we need to fix sys_path_to_bdev()
                         *
                         */
-#if 0
                        id.gid = getgid();
+                       DEBUG(10,("sys_set_vfs_quota: path[%s] bdev[%s] SMB_GROUP_FS_QUOTA_TYPE (gid[%u])\n",
+                               path, bdev, (unsigned)id.gid));
 
+#if 0
                        ret = quotactl(QCMD(Q_GETQUOTA,GRPQUOTA), bdev, id, (void *)&D);
 
                        if ((qflags&QUOTAS_DENY_DISK)||(qflags&QUOTAS_ENABLED)) {
@@ -275,25 +303,23 @@ int sys_set_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
                                                return -1;
                                        }
                                        
-                                       ret = quotactl(QCMD(Q_QUOTAON,GRPQUOTA), bdev, -1,(void *)quota_file);
+                                       ret = quotactl(QCMD(Q_QUOTAON,GRPQUOTA), (caddr_t)bdev, -1,(void *)quota_file);
                                } else {
                                        ret = 0;        
                                }
                        } else {
                                if (ret != 0) {
                                        /* turn off */
-                                       ret = quotactl(QCMD(Q_QUOTAOFF,GRPQUOTA), bdev, -1, (void *)0); 
+                                       ret = quotactl(QCMD(Q_QUOTAOFF,GRPQUOTA), (caddr_t)bdev, -1, (void *)0);        
                                } else {
                                        ret = 0;
                                }               
                        }
 
-                       DEBUG(0,("vfs_fs_quota: ret(%d) errno(%d)[%s] uid(%d) bdev[%s]\n",
+                       DEBUG(0,("sys_set_vfs_quota: ret(%d) errno(%d)[%s] uid(%d) bdev[%s]\n",
                                ret,errno,strerror(errno),id.gid,bdev));
 #else
-                       id.gid = getgid();
-
-                       if ((ret = quotactl(QCMD(Q_GETQUOTA,GRPQUOTA), bdev, id.gid, (void *)&D))==0) {
+                       if ((ret = quotactl(QCMD(Q_GETQUOTA,GRPQUOTA), (caddr_t)bdev, id.gid, (void *)&D))==0) {
                                oldqflags |= QUOTAS_DENY_DISK;
                        }
 
@@ -314,5 +340,7 @@ int sys_set_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
 }
 
 #else /* HAVE_QUOTACTL_4A */
+ void dummy_sysquotas_4A(void);
+
  void dummy_sysquotas_4A(void){}
 #endif /* HAVE_QUOTACTL_4A */