1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

s3: optimize strict allocate for XFS on IRIX

This commit is contained in:
Björn Jacke 2010-02-18 10:01:26 +01:00
parent 77164a8a5d
commit c0ebca237c

View File

@ -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