]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
xfs-quota: do not fail if user has no quota
authorUri Simchoni <uri@samba.org>
Wed, 30 Mar 2016 10:00:29 +0000 (13:00 +0300)
committerJeremy Allison <jra@samba.org>
Thu, 31 Mar 2016 18:30:11 +0000 (20:30 +0200)
XFS fails quotactl(Q_XGETQUOTA) with ENOENT if the user
or group has no quota assigned to it. This is not an error
condition - simply report 0 quota in this case.

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/lib/sysquotas_xfs.c

index ccc7fc09111339909f7edc18693e7768de436d5a..bea86d5341dcda022d346e8e3731aeab1d31891b 100644 (file)
@@ -90,16 +90,28 @@ int sys_get_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
                        DEBUG(10,("sys_get_xfs_quota: path[%s] bdev[%s] SMB_USER_QUOTA_TYPE uid[%u]\n",
                                path, bdev, (unsigned)id.uid));
 
-                       if ((ret=quotactl(QCMD(Q_XGETQUOTA,USRQUOTA), bdev, id.uid, (caddr_t)&D)))
+                       ret=quotactl(QCMD(Q_XGETQUOTA,USRQUOTA), bdev, id.uid, (caddr_t)&D);
+                       /* XFS fails with ENOENT if the user has no
+                        * quota. Our protocol in that case is to
+                        * succeed and return 0 as quota.
+                        */
+                       if (ret != 0 && errno != ENOENT) {
                                return ret;
+                       }
                        break;
 #ifdef HAVE_GROUP_QUOTA
                case SMB_GROUP_QUOTA_TYPE:
                        DEBUG(10,("sys_get_xfs_quota: path[%s] bdev[%s] SMB_GROUP_QUOTA_TYPE gid[%u]\n",
                                path, bdev, (unsigned)id.gid));
 
-                       if ((ret=quotactl(QCMD(Q_XGETQUOTA,GRPQUOTA), bdev, id.gid, (caddr_t)&D)))
+                       ret=quotactl(QCMD(Q_XGETQUOTA,GRPQUOTA), bdev, id.gid, (caddr_t)&D);
+                       /* XFS fails with ENOENT if the user has no
+                        * quota. Our protocol in that case is to
+                        * succeed and return 0 as quota.
+                        */
+                       if (ret != 0 && errno != ENOENT) {
                                return ret;
+                       }
                        break;
 #endif /* HAVE_GROUP_QUOTA */
                case SMB_USER_FS_QUOTA_TYPE: