From 12a948bc73a0c87d7c97766bb6942d3ac51fecbd Mon Sep 17 00:00:00 2001 From: Ramana Raja Date: Fri, 3 Jul 2020 17:54:44 +0530 Subject: [PATCH] pybind/cephfs: add DiskQuotaExceeded exception Signed-off-by: Ramana Raja (cherry picked from commit 4cd247e6d0b7d38eb8e9bf5f6a656fd78393b4f6) Conflicts: src/test/pybind/test_cephfs.py - some cephfs pybind interfaces and their tests were missing in octopus --- src/pybind/cephfs/cephfs.pyx | 8 +++++++- src/test/pybind/test_cephfs.py | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index 916ef81eccc4a..83e6454bcbbcd 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -269,6 +269,10 @@ class ObjectNotEmpty(OSError): class NotDirectory(OSError): pass +class DiskQuotaExceeded(OSError): + pass + + IF UNAME_SYSNAME == "FreeBSD": cdef errno_to_exception = { errno.EPERM : PermissionError, @@ -282,6 +286,7 @@ IF UNAME_SYSNAME == "FreeBSD": errno.ERANGE : OutOfRange, errno.EWOULDBLOCK: WouldBlock, errno.ENOTEMPTY : ObjectNotEmpty, + errno.EDQUOT : DiskQuotaExceeded, } ELSE: cdef errno_to_exception = { @@ -296,7 +301,8 @@ ELSE: errno.ERANGE : OutOfRange, errno.EWOULDBLOCK: WouldBlock, errno.ENOTEMPTY : ObjectNotEmpty, - errno.ENOTDIR : NotDirectory + errno.ENOTDIR : NotDirectory, + errno.EDQUOT : DiskQuotaExceeded, } diff --git a/src/test/pybind/test_cephfs.py b/src/test/pybind/test_cephfs.py index e633ee0cd0176..c6bd0c9bea766 100644 --- a/src/test/pybind/test_cephfs.py +++ b/src/test/pybind/test_cephfs.py @@ -431,3 +431,12 @@ def test_futimens(): cephfs.close(fd) cephfs.unlink(b'/file-1') + +@with_setup(setup_test) +def test_disk_quota_exceeeded_error(): + cephfs.mkdir("/dir-1", 0o755) + cephfs.setxattr("/dir-1", "ceph.quota.max_bytes", b"5", 0) + fd = cephfs.open(b'/dir-1/file-1', 'w', 0o755) + assert_raises(libcephfs.DiskQuotaExceeded, cephfs.write, fd, b"abcdeghiklmnopqrstuvwxyz", 0) + cephfs.close(fd) + cephfs.unlink(b"/dir-1/file-1") -- 2.39.5