diff options
author | Jeremy Allison <jra@samba.org> | 2010-12-20 16:53:16 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2010-12-21 02:41:23 +0100 |
commit | 8998f4b01310e4b45e75d8d5f3260b5ba5c1cdf9 (patch) | |
tree | 21e648af9bd549f577ab8cbf59ebdeb89963cbd7 /source3/lib | |
parent | 09aea038139f8717d38f0fdae6be9cf46bd86b15 (diff) | |
download | samba-8998f4b01310e4b45e75d8d5f3260b5ba5c1cdf9.tar.gz samba-8998f4b01310e4b45e75d8d5f3260b5ba5c1cdf9.tar.bz2 samba-8998f4b01310e4b45e75d8d5f3260b5ba5c1cdf9.zip |
Added call out to a Linux-compatible fallocate() when we need to extend a file
allocation extent without changing end-of-file size.
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Tue Dec 21 02:41:24 CET 2010 on sn-devel-104
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/system.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/source3/lib/system.c b/source3/lib/system.c index 02322b72b5..4cf6a299da 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -695,6 +695,41 @@ int sys_posix_fallocate(int fd, SMB_OFF_T offset, SMB_OFF_T len) } /******************************************************************* + An fallocate() function that matches the semantics of the Linux one. +********************************************************************/ + +#ifdef HAVE_LINUX_FALLOC_H +#include <linux/falloc.h> +#endif + +int sys_fallocate(int fd, enum vfs_fallocate_mode mode, SMB_OFF_T offset, SMB_OFF_T len) +{ +#if defined(HAVE_LINUX_FALLOCATE64) || defined(HAVE_LINUX_FALLOCATE) + int lmode; + switch (mode) { + case VFS_FALLOCATE_EXTEND_SIZE: + lmode = 0; + break; + case VFS_FALLOCATE_KEEP_SIZE: + lmode = FALLOC_FL_KEEP_SIZE; + break; + default: + errno = EINVAL; + return -1; + } +#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_LINUX_FALLOCATE64) + return fallocate64(fd, lmode, offset, len); +#elif defined(HAVE_LINUX_FALLOCATE) + return fallocate(fd, lmode, offset, len); +#endif +#else + /* TODO - plumb in fallocate from other filesysetms like VXFS etc. JRA. */ + errno = ENOSYS; + return -1; +#endif +} + +/******************************************************************* An ftruncate() wrapper that will deal with 64 bit filesizes. ********************************************************************/ |