idl/ioctl: change QAR response array to a DATA_BLOB
[samba.git] / source3 / lib / sysquotas.c
index d9bdbf402a65448cb860f96e37224acd06dcdc07..2ef1d1bf8f5a7d942b1ed8cc9dfbc902c3b57e69 100644 (file)
@@ -30,8 +30,6 @@
 /*#endif HAVE_QUOTACTL_4A */
 #elif defined(HAVE_QUOTACTL_4B)
 
-#error HAVE_QUOTACTL_4B not implemeted
-
 /*#endif HAVE_QUOTACTL_4B */
 #elif defined(HAVE_QUOTACTL_3)
 
@@ -60,7 +58,7 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char
        (*bdev) = NULL;
        (*fs) = NULL;
        
-       if ( sys_stat(path, &S, lp_fake_dir_create_times()) == -1 )
+       if ( sys_stat(path, &S, false) == -1 )
                return (-1);
 
        devno = S.st_ex_dev ;
@@ -71,8 +69,7 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char
        }
   
        while ((mnt = getmntent(fp))) {
-               if ( sys_stat(mnt->mnt_dir, &S, lp_fake_dir_create_times())
-                    == -1 )
+               if ( sys_stat(mnt->mnt_dir, &S, false) == -1 )
                        continue ;
 
                if (S.st_ex_dev == devno) {
@@ -115,7 +112,7 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char
        
        /* find the block device file */
 
-       if ((ret=sys_stat(path, &S, lp_fake_dir_create_times()))!=0) {
+       if ((ret=sys_stat(path, &S, false))!=0) {
                return ret;
        }
        
@@ -175,9 +172,15 @@ static struct {
        int (*get_quota)(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
        int (*set_quota)(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
 } sys_quota_backends[] = {
-#ifdef HAVE_XFS_QUOTAS
+#if defined HAVE_XFS_QUOTAS
        {"xfs", sys_get_xfs_quota,      sys_set_xfs_quota},
+       {"gfs", sys_get_xfs_quota,      sys_set_xfs_quota},
+       {"gfs2", sys_get_xfs_quota,     sys_set_xfs_quota},
 #endif /* HAVE_XFS_QUOTAS */
+#ifdef HAVE_NFS_QUOTAS
+       {"nfs", sys_get_nfs_quota,      sys_set_nfs_quota},
+       {"nfs4", sys_get_nfs_quota,     sys_set_nfs_quota},
+#endif /* HAVE_NFS_QUOTAS */
        {NULL,  NULL,                   NULL}
 };
 
@@ -186,7 +189,7 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
        const char *get_quota_command;
        char **lines = NULL;
 
-       get_quota_command = lp_get_quota_command();
+       get_quota_command = lp_get_quota_command(talloc_tos());
        if (get_quota_command && *get_quota_command) {
                const char *p;
                char *p2;
@@ -207,7 +210,7 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
                                return -1;
                }
 
-               if (asprintf(&syscmd, "%s \"%s\" %d %d",
+               if (asprintf(&syscmd, "%s %s %d %d",
                        get_quota_command, path, qtype, _id) < 0) {
                        return -1;
                }
@@ -224,7 +227,7 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
 
                        /* we need to deal with long long unsigned here, if supported */
 
-                       dp->qflags = (enum SMB_QUOTA_TYPE)strtoul(line, &p2, 10);
+                       dp->qflags = strtoul(line, &p2, 10);
                        p = p2;
                        while (p && *p && isspace(*p)) {
                                p++;
@@ -301,7 +304,6 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
 
                        DEBUG (3, ("Parsed output of get_quota, ...\n"));
 
-#ifdef LARGE_SMB_OFF_T
                        DEBUGADD (5,( 
                                "qflags:%u curblocks:%llu softlimit:%llu hardlimit:%llu\n"
                                "curinodes:%llu isoftlimit:%llu ihardlimit:%llu bsize:%llu\n", 
@@ -310,16 +312,6 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
                                (long long unsigned)dp->curinodes,
                                (long long unsigned)dp->isoftlimit,(long long unsigned)dp->ihardlimit,
                                (long long unsigned)dp->bsize));
-#else /* LARGE_SMB_OFF_T */
-                       DEBUGADD (5,( 
-                               "qflags:%u curblocks:%lu softlimit:%lu hardlimit:%lu\n"
-                               "curinodes:%lu isoftlimit:%lu ihardlimit:%lu bsize:%lu\n", 
-                               dp->qflags,(long unsigned)dp->curblocks,
-                               (long unsigned)dp->softlimit,(long unsigned)dp->hardlimit,
-                               (long unsigned)dp->curinodes,
-                               (long unsigned)dp->isoftlimit,(long unsigned)dp->ihardlimit,
-                               (long unsigned)dp->bsize));
-#endif /* LARGE_SMB_OFF_T */
                        return 0;
                }
 
@@ -341,7 +333,7 @@ static int command_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
 {
        const char *set_quota_command;
 
-       set_quota_command = lp_set_quota_command();
+       set_quota_command = lp_set_quota_command(talloc_tos());
        if (set_quota_command && *set_quota_command) {
                char **lines = NULL;
                char *syscmd = NULL;
@@ -360,9 +352,8 @@ static int command_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
                                return -1;
                }
 
-#ifdef LARGE_SMB_OFF_T
                if (asprintf(&syscmd,
-                       "%s \"%s\" %d %d "
+                       "%s %s %d %d "
                        "%u %llu %llu "
                        "%llu %llu %llu ",
                        set_quota_command, path, qtype, _id, dp->qflags,
@@ -371,18 +362,6 @@ static int command_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
                        (long long unsigned)dp->bsize) < 0) {
                        return -1;
                }
-#else /* LARGE_SMB_OFF_T */
-               if (asprintf(&syscmd,
-                       "%s \"%s\" %d %d "
-                       "%u %lu %lu "
-                       "%lu %lu %lu ",
-                       set_quota_command, path, qtype, _id, dp->qflags,
-                       (long unsigned)dp->softlimit,(long unsigned)dp->hardlimit,
-                       (long unsigned)dp->isoftlimit,(long unsigned)dp->ihardlimit,
-                       (long unsigned)dp->bsize) < 0) {
-                       return -1;
-               }
-#endif /* LARGE_SMB_OFF_T */
 
                DEBUG (3, ("get_quota: Running command %s\n", syscmd));
 
@@ -429,7 +408,7 @@ int sys_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DI
        }
 
        errno = 0;
-       DEBUG(10,("sys_get_quota() uid(%u, %u)\n", (unsigned)getuid(), (unsigned)geteuid()));
+       DEBUG(10,("sys_get_quota() uid(%u, %u), fs(%s)\n", (unsigned)getuid(), (unsigned)geteuid(), fs));
 
        for (i=0;(fs && sys_quota_backends[i].name && sys_quota_backends[i].get_quota);i++) {
                if (strcmp(fs,sys_quota_backends[i].name)==0) {