102
103
#if defined(_WIN32)
103
EXTERN int FileMapErrorToErrno(char *functionName,
106
EXTERN Bool FileRetryThisError(DWORD error,
110
EXTERN int FileAttributesRetry(ConstUnicode pathName,
111
uint32 msecMaxWaitTime,
114
EXTERN int FileRenameRetry(ConstUnicode fromPath,
116
uint32 msecMaxWaitTime);
118
EXTERN int FileDeletionRetry(ConstUnicode pathName,
120
uint32 msecMaxWaitTime);
122
EXTERN int FileCreateDirectoryRetry(ConstUnicode pathName,
123
uint32 msecMaxWaitTime);
125
EXTERN int FileRemoveDirectoryRetry(ConstUnicode pathName,
126
uint32 msecMaxWaitTime);
128
EXTERN int FileListDirectoryRetry(ConstUnicode pathName,
129
uint32 msecMaxWaitTime,
104
int FileMapErrorToErrno(char *functionName,
107
Bool FileRetryThisError(DWORD error,
111
int FileAttributesRetry(ConstUnicode pathName,
112
uint32 msecMaxWaitTime,
115
int FileRenameRetry(ConstUnicode fromPath,
117
uint32 msecMaxWaitTime);
119
int FileDeletionRetry(ConstUnicode pathName,
121
uint32 msecMaxWaitTime);
123
int FileCreateDirectoryRetry(ConstUnicode pathName,
124
uint32 msecMaxWaitTime);
126
int FileRemoveDirectoryRetry(ConstUnicode pathName,
127
uint32 msecMaxWaitTime);
129
int FileListDirectoryRetry(ConstUnicode pathName,
130
uint32 msecMaxWaitTime,
132
133
#define FileAttributes(a, b) FileAttributesRetry((a), 0, (b))
133
134
#define FileRename(a, b) FileRenameRetry((a), (b), 0)
150
151
#define FileRemoveDirectoryRobust(a) \
151
152
FileRemoveDirectoryRetry((a), FILE_MAX_WAIT_TIME_MS)
153
EXTERN char *FilePosixGetBlockDevice(char const *path);
155
EXTERN int FileAttributes(ConstUnicode pathName,
158
EXTERN int FileRename(ConstUnicode fromPath,
159
ConstUnicode toPath);
161
EXTERN int FileDeletion(ConstUnicode pathName,
164
EXTERN int FileCreateDirectory(ConstUnicode pathName);
166
EXTERN int FileRemoveDirectory(ConstUnicode pathName);
154
char *FilePosixGetBlockDevice(char const *path);
156
int FileAttributes(ConstUnicode pathName,
159
int FileRename(ConstUnicode fromPath,
160
ConstUnicode toPath);
162
int FileDeletion(ConstUnicode pathName,
165
int FileCreateDirectory(ConstUnicode pathName);
167
int FileRemoveDirectory(ConstUnicode pathName);
168
169
#define FileListDirectoryRobust(a, b) File_ListDirectory((a), (b))
169
170
#define FileAttributesRobust(a, b) FileAttributes((a), (b))
207
208
typedef int FILELOCK_FILE_HANDLE;
210
EXTERN uint32 FileSleeper(uint32 msecMinSleepTime,
211
uint32 msecMaxSleepTime);
213
EXTERN uint32 FileSimpleRandom(void);
215
EXTERN const char *FileLockGetMachineID(void);
217
EXTERN char *FileLockGetExecutionID(void);
219
EXTERN Bool FileLockMachineIDMatch(char *host,
222
EXTERN int FileLockMemberValues(ConstUnicode lockDir,
223
ConstUnicode fileName,
226
LockValues *memberValues);
228
EXTERN int FileLockHackVMX(ConstUnicode filePathName);
230
EXTERN int FileLockOpenFile(ConstUnicode pathName,
232
FILELOCK_FILE_HANDLE *handle);
234
EXTERN int FileLockCloseFile(FILELOCK_FILE_HANDLE handle);
236
EXTERN int FileLockReadFile(FILELOCK_FILE_HANDLE handle,
238
uint32 requestedBytes,
239
uint32 *resultantBytes);
241
EXTERN int FileLockWriteFile(FILELOCK_FILE_HANDLE handle,
243
uint32 requestedBytes,
244
uint32 *resultantBytes);
246
EXTERN void *FileLockIntrinsic(ConstUnicode filePathName,
248
uint32 msecMaxWaitTime,
252
EXTERN int FileUnlockIntrinsic(ConstUnicode filePathName,
253
const void *lockToken);
255
EXTERN Bool FileLockIsLocked(ConstUnicode filePath,
258
EXTERN Bool FileLockValidOwner(const char *executionID,
259
const char *payload);
261
EXTERN Bool FileLockValidName(ConstUnicode fileName);
263
EXTERN Bool FileIsWritableDir(ConstUnicode dirName);
211
uint32 FileSleeper(uint32 msecMinSleepTime,
212
uint32 msecMaxSleepTime);
214
uint32 FileSimpleRandom(void);
216
const char *FileLockGetMachineID(void);
218
char *FileLockGetExecutionID(void);
220
Bool FileLockMachineIDMatch(char *host,
223
int FileLockMemberValues(ConstUnicode lockDir,
224
ConstUnicode fileName,
227
LockValues *memberValues);
229
int FileLockHackVMX(ConstUnicode filePathName);
231
int FileLockOpenFile(ConstUnicode pathName,
233
FILELOCK_FILE_HANDLE *handle);
235
int FileLockCloseFile(FILELOCK_FILE_HANDLE handle);
237
int FileLockReadFile(FILELOCK_FILE_HANDLE handle,
239
uint32 requestedBytes,
240
uint32 *resultantBytes);
242
int FileLockWriteFile(FILELOCK_FILE_HANDLE handle,
244
uint32 requestedBytes,
245
uint32 *resultantBytes);
247
FileLockToken *FileLockIntrinsic(ConstUnicode filePathName,
249
uint32 msecMaxWaitTime,
253
int FileUnlockIntrinsic(FileLockToken *tokenPtr);
255
Bool FileLockIsLocked(ConstUnicode filePath,
258
Bool FileLockValidOwner(const char *executionID,
259
const char *payload);
261
Bool FileLockValidName(ConstUnicode fileName);
263
Bool FileIsWritableDir(ConstUnicode dirName);
267
* FileIOAligned_* are useful on hosted platforms where malloc/memalign/valloc
268
* for "large buffers" (in the range 64 KiB - 1 MiB) will generally fall
269
* through to mmap/munmap, which is expensive due to page table modifications
270
* and the attendant TLB flushing (which requires IPIs and possibly world
271
* switches) on other threads running in the same address space. In particular,
272
* on Mac OS 10.6.6 on a Westmere-class Mac Pro, mmap + memcpy + munmap adds
273
* around a millisecond of CPU time and a hundred IPIs to a 512 KiB write. See
276
* This isn't applicable to ESX because
277
* 1. we don't use this path for disk IO
278
* 2. we don't want to do extra large allocations
279
* 3. we don't have the same alignment constraints
280
* so simply define it away to nothing.
282
* Tools is another case, we can use this path for IO but we don't want to add
283
* MXUserExclLock dependencies.
286
#if defined(VMX86_TOOLS) || defined(VMX86_SERVER)
287
#define FileIOAligned_PoolInit() /* nothing */
288
#define FileIOAligned_PoolExit() /* nothing */
289
#define FileIOAligned_PoolMalloc(sz) NULL
290
#define FileIOAligned_PoolFree(ptr) FALSE
292
void FileIOAligned_PoolInit(void);
293
void FileIOAligned_PoolExit(void);
294
void *FileIOAligned_PoolMalloc(size_t);
295
Bool FileIOAligned_PoolFree(void *);
299
FileIOAligned_Malloc(size_t sz) // IN:
301
void *buf = FileIOAligned_PoolMalloc(sz);
304
buf = Aligned_Malloc(sz);
310
FileIOAligned_Free(void *ptr) // IN:
312
if (!FileIOAligned_PoolFree(ptr)) {
265
317
#if defined(__APPLE__)
266
EXTERN int PosixFileOpener(ConstUnicode pathName,
318
int PosixFileOpener(ConstUnicode pathName,
270
322
#define PosixFileOpener(a, b, c) Posix_Open(a, b, c);