Changeset 59511 in vbox
- Timestamp:
- Jan 28, 2016 2:02:39 PM (9 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/Makefile.kmk
r59461 r59511 1126 1126 generic/RTDirSetTimes-generic.cpp \ 1127 1127 generic/RTFileMove-generic.cpp \ 1128 generic/RTFileSetAllocationSize-generic.cpp \1129 1128 generic/RTLogWriteDebugger-generic.cpp \ 1130 1129 generic/RTPathAbs-generic.cpp \ … … 1144 1143 r3/generic/allocex-r3-generic.cpp \ 1145 1144 r3/posix/RTFileQueryFsSizes-posix.cpp \ 1145 r3/posix/RTFileSetAllocationSize-posix.cpp \ 1146 1146 r3/posix/RTHandleGetStandard-posix.cpp \ 1147 1147 r3/posix/RTMemProtect-posix.cpp \ -
trunk/src/VBox/Runtime/r3/posix/RTFileSetAllocationSize-posix.cpp
r59505 r59511 39 39 #include <errno.h> 40 40 #include <unistd.h> 41 #include < sys/fcntl.h>41 #include <fcntl.h> 42 42 43 43 /** 44 * The Linux specificfallocate() method.44 * The posix_fallocate() method. 45 45 */ 46 typedef int (*PFNLNXFALLOCATE) (int iFd, int fMode, off_t offStart, off_t cb); 47 /** Flag to specify that the file size should not be extended. */ 48 #define LNX_FALLOC_FL_KEEP_SIZE 1 46 typedef int (*PFNPOSIXFALLOCATE) (int iFd, off_t offStart, off_t cb); 49 47 50 48 RTDECL(int) RTFileSetAllocationSize(RTFILE hFile, uint64_t cbSize, uint32_t fFlags) … … 57 55 */ 58 56 if ( sizeof(off_t) < sizeof(cbSize) 59 && (cbSize >> 32) != 0)57 && RT_HIDWORD(cbSize) != 0) 60 58 { 61 59 AssertMsgFailed(("64-bit filesize not supported! cbSize=%lld\n", cbSize)); … … 63 61 } 64 62 63 if (fFlags & RTFILE_ALLOC_SIZE_F_KEEP_SIZE) 64 return VERR_NOT_SUPPORTED; 65 65 66 int rc = VINF_SUCCESS; 66 PFN LNXFALLOCATE pfnLnxFAllocate = (PFNLNXFALLOCATE)(uintptr_t)dlsym(RTLD_DEFAULT, "fallocate");67 if (VALID_PTR(pfn LnxFAllocate))67 PFNPOSIXFALLOCATE pfnPosixFAllocate = (PFNPOSIXFALLOCATE)(uintptr_t)dlsym(RTLD_DEFAULT, "posix_fallocate"); 68 if (VALID_PTR(pfnPosixFAllocate)) 68 69 { 69 int fLnxFlags = (fFlags & RTFILE_ALLOC_SIZE_F_KEEP_SIZE) ? LNX_FALLOC_FL_KEEP_SIZE : 0; 70 int rcLnx = pfnLnxFAllocate(RTFileToNative(hFile), fLnxFlags, 0, cbSize); 71 if (rcLnx != 0) 70 int rcPosix = pfnPosixFAllocate(RTFileToNative(hFile), 0, cbSize); 71 if (rcPosix != 0) 72 72 { 73 73 if (errno == EOPNOTSUPP)
Note:
See TracChangeset
for help on using the changeset viewer.