summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorBjörn Jacke <bj@sernet.de>2010-02-18 10:01:26 +0100
committerBjörn Jacke <bj@sernet.de>2010-02-18 22:45:46 +0100
commitc0ebca237c6748365b2400529e02b5c8342e6ecc (patch)
treead86da35000a8aab76e5e0bd428196f8c3ba9f92 /source3
parent77164a8a5de22c67cf8d86bda92408aef2ea146b (diff)
downloadsamba-c0ebca237c6748365b2400529e02b5c8342e6ecc.tar.gz
samba-c0ebca237c6748365b2400529e02b5c8342e6ecc.tar.bz2
samba-c0ebca237c6748365b2400529e02b5c8342e6ecc.zip
s3: optimize strict allocate for XFS on IRIX
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/system.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 9c1da3a78b..58240a34a8 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -627,6 +627,31 @@ int sys_posix_fallocate(int fd, SMB_OFF_T offset, SMB_OFF_T len)
return posix_fallocate64(fd, offset, len);
#elif defined(HAVE_POSIX_FALLOCATE) && !defined(HAVE_BROKEN_POSIX_FALLOCATE)
return posix_fallocate(fd, offset, len);
+#elif defined(F_RESVSP64)
+ /* this handles XFS on IRIX */
+ struct flock64 fl;
+ SMB_OFF_T new_len = offset + len;
+ int ret;
+ struct stat64 sbuf;
+
+ /* unlikely to get a too large file on a 64bit system but ... */
+ if (new_len < 0)
+ return EFBIG;
+
+ fl.l_whence = SEEK_SET;
+ fl.l_start = offset;
+ fl.l_len = len;
+
+ ret=fcntl(fd, F_RESVSP64, &fl);
+
+ if (ret != 0)
+ return errno;
+
+ /* Make sure the file gets enlarged after we allocated space: */
+ fstat64(fd, &sbuf);
+ if (new_len > sbuf.st_size)
+ ftruncate64(fd, new_len);
+ return 0;
#else
return ENOSYS;
#endif