Permalink
Browse files

added errno.EINVAL check to fallocate

On some systems (eg Illumos), posix_fallocate() returns
EINVAL when the underlying filesystem doesn't support the
operation. On Linux, the fallocate() call returns
EOPNOTSUPP.

The need for this patch was revealed by Victor Rodionov
<victor.rodionov@nexenta.com>.

Change-Id: I06fa9d49e7ec4084135843b7e0c91948dc098d27
  • Loading branch information...
1 parent a7e6d44 commit 2ca379d40f06d892fdf6e3430ccd8a78726e5626 @notmyname notmyname committed Sep 12, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 swift/common/utils.py
View
@@ -170,7 +170,8 @@ def fallocate(fd, size):
# 1 means "FALLOC_FL_KEEP_SIZE", which means it pre-allocates invisibly
ret = _sys_fallocate(fd, 1, 0, ctypes.c_uint64(size))
err = ctypes.get_errno()
- if ret and err not in (0, errno.ENOSYS, errno.EOPNOTSUPP):
+ if ret and err not in (0, errno.ENOSYS, errno.EOPNOTSUPP,
+ errno.EINVAL):
raise OSError(err, 'Unable to fallocate(%s)' % size)

0 comments on commit 2ca379d

Please sign in to comment.