From c0ebca237c6748365b2400529e02b5c8342e6ecc Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Thu, 18 Feb 2010 10:01:26 +0100 Subject: s3: optimize strict allocate for XFS on IRIX --- source3/lib/system.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source3/lib') 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 -- cgit