VirtualBox

source: vbox/trunk/include/iprt/file.h@ 23305

Last change on this file since 23305 was 23047, checked in by vboxsync, 15 years ago

Fix RTFILE_O_NO_CACHE on Windows. Document that FILE_APPEND_DATA is disabled and how to workaround it

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 47.1 KB
Line 
1/** @file
2 * IPRT - File I/O.
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___iprt_file_h
31#define ___iprt_file_h
32
33#include <iprt/cdefs.h>
34#include <iprt/types.h>
35#ifdef IN_RING3
36# include <iprt/fs.h>
37#endif
38
39RT_C_DECLS_BEGIN
40
41/** @defgroup grp_rt_fileio RTFile - File I/O
42 * @ingroup grp_rt
43 * @{
44 */
45
46/** Platform specific text line break.
47 * @deprecated Use text I/O streams and '\\n'. See iprt/stream.h. */
48#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
49# define RTFILE_LINEFEED "\r\n"
50#else
51# define RTFILE_LINEFEED "\n"
52#endif
53
54
55#ifdef IN_RING3
56
57/**
58 * Checks if the specified file name exists and is a regular file.
59 *
60 * Symbolic links will be resolved.
61 *
62 * @returns true if it's a regular file, false if it isn't.
63 * @param pszPath The path to the file.
64 *
65 * @sa RTDirExists, RTPathExists, RTSymlinkExists.
66 */
67RTDECL(bool) RTFileExists(const char *pszPath);
68
69
70/** @name Open flags
71 * @{ */
72/** Open the file with read access. */
73#define RTFILE_O_READ 0x00000001
74/** Open the file with write access. */
75#define RTFILE_O_WRITE 0x00000002
76/** Open the file with read & write access. */
77#define RTFILE_O_READWRITE 0x00000003
78/** The file access mask.
79 * @remarks The value 0 is invalid. */
80#define RTFILE_O_ACCESS_MASK 0x00000003
81
82/** Open file in APPEND mode, so all writes to the file handle will
83 * append data at the end of the file.
84 * @remarks It is ignored if write access is not requested, that is
85 * RTFILE_O_WRITE is not set. */
86#define RTFILE_O_APPEND 0x00000004
87 /* 0x00000008 is unused atm. */
88
89/** Sharing mode: deny none (the default mode). */
90#define RTFILE_O_DENY_NONE 0x00000000
91/** Sharing mode: deny read. */
92#define RTFILE_O_DENY_READ 0x00000010
93/** Sharing mode: deny write. */
94#define RTFILE_O_DENY_WRITE 0x00000020
95/** Sharing mode: deny read and write. */
96#define RTFILE_O_DENY_READWRITE 0x00000030
97/** Sharing mode: deny all. */
98#define RTFILE_O_DENY_ALL RTFILE_O_DENY_READWRITE
99/** Sharing mode: do NOT deny delete (NT).
100 * @remarks This might not be implemented on all platforms, and will be
101 * defaulted & ignored on those.
102 */
103#define RTFILE_O_DENY_NOT_DELETE 0x00000040
104/** Sharing mode mask. */
105#define RTFILE_O_DENY_MASK 0x00000070
106
107/** Action: Open an existing file (the default action). */
108#define RTFILE_O_OPEN 0x00000000
109/** Action: Create a new file or open an existing one. */
110#define RTFILE_O_OPEN_CREATE 0x00000100
111/** Action: Create a new a file. */
112#define RTFILE_O_CREATE 0x00000200
113/** Action: Create a new file or replace an existing one. */
114#define RTFILE_O_CREATE_REPLACE 0x00000300
115/** Action mask. */
116#define RTFILE_O_ACTION_MASK 0x00000300
117
118 /*0x00000400
119 and 0x00000800 are unused atm. */
120/** Turns off indexing of files on Windows hosts, *CREATE* only.
121 * @remarks Window only. */
122#define RTFILE_O_NOT_CONTENT_INDEXED 0x00000800
123/** Truncate the file.
124 * @remarks This will not truncate files opened for read-only.
125 * @remarks The trunction doesn't have to be atomically, so anyone else opening
126 * the file may be racing us. The caller is responsible for not causing
127 * this race. */
128#define RTFILE_O_TRUNCATE 0x00001000
129/** Make the handle inheritable on RTProcessCreate(/exec). */
130#define RTFILE_O_INHERIT 0x00002000
131/** Open file in non-blocking mode - non-portable.
132 * @remarks This flag may not be supported on all platforms, in which case it's
133 * considered an invalid parameter. */
134#define RTFILE_O_NON_BLOCK 0x00004000
135/** Write through directly to disk. Workaround to avoid iSCSI
136 * initiator deadlocks on Windows hosts.
137 * @remarks This might not be implemented on all platforms, and will be ignored
138 * on those. */
139#define RTFILE_O_WRITE_THROUGH 0x00008000
140
141/** Attribute access: Attributes can be read if the file is being opened with
142 * read access, and can be written with write access. */
143#define RTFILE_O_ACCESS_ATTR_DEFAULT 0x00000000
144/** Attribute access: Attributes can be read.
145 * @remarks Windows only. */
146#define RTFILE_O_ACCESS_ATTR_READ 0x00010000
147/** Attribute access: Attributes can be written.
148 * @remarks Windows only. */
149#define RTFILE_O_ACCESS_ATTR_WRITE 0x00020000
150/** Attribute access: Attributes can be both read & written.
151 * @remarks Windows only. */
152#define RTFILE_O_ACCESS_ATTR_READWRITE 0x00030000
153/** Attribute access: The file attributes access mask.
154 * @remarks Windows only. */
155#define RTFILE_O_ACCESS_ATTR_MASK 0x00030000
156
157/** Open file for async I/O
158 * @remarks This flag may not be needed on all platforms, and will be ignored on
159 * those. */
160#define RTFILE_O_ASYNC_IO 0x00040000
161
162/** Disables caching.
163 *
164 * Useful when using very big files which might bring the host I/O scheduler to
165 * its knees during high I/O load.
166 *
167 * @remarks This flag might impose restrictions
168 * on the buffer alignment, start offset and/or transfer size.
169 *
170 * On Linux the buffer needs to be aligned to the 512 sector
171 * boundary.
172 *
173 * On Windows the FILE_FLAG_NO_BUFFERING is used (see
174 * http://msdn.microsoft.com/en-us/library/cc644950(VS.85).aspx ).
175 * The buffer address, the transfer size and offset needs to be
176 * aligned to the sector size of the volume. Furthermore FILE_APPEND_DATA
177 * is disabled. To write beyond the size of file use RTFileSetSize prior
178 * writing the data to the file.
179 *
180 * This flag does not work on Solaris if the target filesystem is ZFS. RTFileOpen will return an
181 * error with that configuration. When used with UFS the same alginment restrictions
182 * apply like Linux and Windows.
183 *
184 * @remarks This might not be implemented on all platforms,
185 * and will be ignored on those.
186 */
187#define RTFILE_O_NO_CACHE 0x00080000
188
189/** Unix file mode mask for use when creating files. */
190#define RTFILE_O_CREATE_MODE_MASK 0x1ff00000
191/** The number of bits to shift to get the file mode mask.
192 * To extract it: (fFlags & RTFILE_O_CREATE_MODE_MASK) >> RTFILE_O_CREATE_MODE_SHIFT.
193 */
194#define RTFILE_O_CREATE_MODE_SHIFT 20
195
196 /*0x20000000,
197 0x40000000
198 and 0x80000000 are unused atm. */
199
200/** Mask of all valid flags.
201 * @remark This doesn't validate the access mode properly.
202 */
203#define RTFILE_O_VALID_MASK 0x1ffFFB77
204
205/** @} */
206
207
208/**
209 * Force the use of open flags for all files opened after the setting is
210 * changed. The caller is responsible for not causing races with RTFileOpen().
211 *
212 * @returns iprt status code.
213 * @param fOpenForAccess Access mode to which the set/mask settings apply.
214 * @param fSet Open flags to be forced set.
215 * @param fMask Open flags to be masked out.
216 */
217RTR3DECL(int) RTFileSetForceFlags(unsigned fOpenForAccess, unsigned fSet, unsigned fMask);
218
219/**
220 * Open a file.
221 *
222 * @returns iprt status code.
223 * @param pFile Where to store the handle to the opened file.
224 * @param pszFilename Path to the file which is to be opened. (UTF-8)
225 * @param fOpen Open flags, i.e a combination of the RTFILE_O_* defines.
226 */
227RTR3DECL(int) RTFileOpen(PRTFILE pFile, const char *pszFilename, unsigned fOpen);
228
229/**
230 * Close a file opened by RTFileOpen().
231 *
232 * @returns iprt status code.
233 * @param File The file handle to close.
234 */
235RTR3DECL(int) RTFileClose(RTFILE File);
236
237/**
238 * Creates an IPRT file handle from a native one.
239 *
240 * @returns IPRT status code.
241 * @param pFile Where to store the IPRT file handle.
242 * @param uNative The native handle.
243 */
244RTR3DECL(int) RTFileFromNative(PRTFILE pFile, RTHCINTPTR uNative);
245
246/**
247 * Gets the native handle for an IPRT file handle.
248 *
249 * @return The native handle.
250 * @params File The IPRT file handle.
251 */
252RTR3DECL(RTHCINTPTR) RTFileToNative(RTFILE File);
253
254/**
255 * Delete a file.
256 *
257 * @returns iprt status code.
258 * @param pszFilename Path to the file which is to be deleted. (UTF-8)
259 * @todo This is a RTPath api!
260 */
261RTR3DECL(int) RTFileDelete(const char *pszFilename);
262
263/** @name Seek flags.
264 * @{ */
265/** Seek from the start of the file. */
266#define RTFILE_SEEK_BEGIN 0x00
267/** Seek from the current file position. */
268#define RTFILE_SEEK_CURRENT 0x01
269/** Seek from the end of the file. */
270#define RTFILE_SEEK_END 0x02
271/** @internal */
272#define RTFILE_SEEK_FIRST RTFILE_SEEK_BEGIN
273/** @internal */
274#define RTFILE_SEEK_LAST RTFILE_SEEK_END
275/** @} */
276
277
278/**
279 * Changes the read & write position in a file.
280 *
281 * @returns iprt status code.
282 * @param File Handle to the file.
283 * @param offSeek Offset to seek.
284 * @param uMethod Seek method, i.e. one of the RTFILE_SEEK_* defines.
285 * @param poffActual Where to store the new file position.
286 * NULL is allowed.
287 */
288RTR3DECL(int) RTFileSeek(RTFILE File, int64_t offSeek, unsigned uMethod, uint64_t *poffActual);
289
290/**
291 * Read bytes from a file.
292 *
293 * @returns iprt status code.
294 * @param File Handle to the file.
295 * @param pvBuf Where to put the bytes we read.
296 * @param cbToRead How much to read.
297 * @param *pcbRead How much we actually read .
298 * If NULL an error will be returned for a partial read.
299 */
300RTR3DECL(int) RTFileRead(RTFILE File, void *pvBuf, size_t cbToRead, size_t *pcbRead);
301
302/**
303 * Read bytes from a file at a given offset.
304 * This function may modify the file position.
305 *
306 * @returns iprt status code.
307 * @param File Handle to the file.
308 * @param off Where to read.
309 * @param pvBuf Where to put the bytes we read.
310 * @param cbToRead How much to read.
311 * @param *pcbRead How much we actually read .
312 * If NULL an error will be returned for a partial read.
313 */
314RTR3DECL(int) RTFileReadAt(RTFILE File, RTFOFF off, void *pvBuf, size_t cbToRead, size_t *pcbRead);
315
316/**
317 * Write bytes to a file.
318 *
319 * @returns iprt status code.
320 * @param File Handle to the file.
321 * @param pvBuf What to write.
322 * @param cbToWrite How much to write.
323 * @param *pcbWritten How much we actually wrote.
324 * If NULL an error will be returned for a partial write.
325 */
326RTR3DECL(int) RTFileWrite(RTFILE File, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
327
328/**
329 * Write bytes to a file at a given offset.
330 * This function may modify the file position.
331 *
332 * @returns iprt status code.
333 * @param File Handle to the file.
334 * @param off Where to write.
335 * @param pvBuf What to write.
336 * @param cbToWrite How much to write.
337 * @param *pcbWritten How much we actually wrote.
338 * If NULL an error will be returned for a partial write.
339 */
340RTR3DECL(int) RTFileWriteAt(RTFILE File, RTFOFF off, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
341
342/**
343 * Flushes the buffers for the specified file.
344 *
345 * @returns iprt status code.
346 * @param File Handle to the file.
347 */
348RTR3DECL(int) RTFileFlush(RTFILE File);
349
350/**
351 * Set the size of the file.
352 *
353 * @returns iprt status code.
354 * @param File Handle to the file.
355 * @param cbSize The new file size.
356 */
357RTR3DECL(int) RTFileSetSize(RTFILE File, uint64_t cbSize);
358
359/**
360 * Query the size of the file.
361 *
362 * @returns iprt status code.
363 * @param File Handle to the file.
364 * @param pcbSize Where to store the filesize.
365 */
366RTR3DECL(int) RTFileGetSize(RTFILE File, uint64_t *pcbSize);
367
368/**
369 * Determine the maximum file size.
370 *
371 * @returns The max size of the file.
372 * -1 on failure, the file position is undefined.
373 * @param File Handle to the file.
374 * @see RTFileGetMaxSizeEx.
375 */
376RTR3DECL(RTFOFF) RTFileGetMaxSize(RTFILE File);
377
378/**
379 * Determine the maximum file size.
380 *
381 * @returns IPRT status code.
382 * @param File Handle to the file.
383 * @param pcbMax Where to store the max file size.
384 * @see RTFileGetMaxSize.
385 */
386RTR3DECL(int) RTFileGetMaxSizeEx(RTFILE File, PRTFOFF pcbMax);
387
388/**
389 * Determine the maximum file size depending on the file system the file is stored on.
390 *
391 * @returns The max size of the file.
392 * -1 on failure.
393 * @param File Handle to the file.
394 */
395RTR3DECL(RTFOFF) RTFileGetMaxSize(RTFILE File);
396
397/**
398 * Gets the current file position.
399 *
400 * @returns File offset.
401 * @returns ~0UUL on failure.
402 * @param File Handle to the file.
403 */
404RTDECL(uint64_t) RTFileTell(RTFILE File);
405
406/**
407 * Checks if the supplied handle is valid.
408 *
409 * @returns true if valid.
410 * @returns false if invalid.
411 * @param File The file handle
412 */
413RTR3DECL(bool) RTFileIsValid(RTFILE File);
414
415/**
416 * Copies a file.
417 *
418 * @returns VERR_ALREADY_EXISTS if the destination file exists.
419 * @returns VBox Status code.
420 *
421 * @param pszSrc The path to the source file.
422 * @param pszDst The path to the destination file.
423 * This file will be created.
424 */
425RTDECL(int) RTFileCopy(const char *pszSrc, const char *pszDst);
426
427/**
428 * Copies a file given the handles to both files.
429 *
430 * @returns VBox Status code.
431 *
432 * @param FileSrc The source file. The file position is unaltered.
433 * @param FileDst The destination file.
434 * On successful returns the file position is at the end of the file.
435 * On failures the file position and size is undefined.
436 */
437RTDECL(int) RTFileCopyByHandles(RTFILE FileSrc, RTFILE FileDst);
438
439/** Flags for RTFileCopyEx().
440 * @{ */
441/** Do not use RTFILE_O_DENY_WRITE on the source file to allow for copying files opened for writing. */
442#define RTFILECOPY_FLAGS_NO_SRC_DENY_WRITE RT_BIT(0)
443/** Do not use RTFILE_O_DENY_WRITE on the target file. */
444#define RTFILECOPY_FLAGS_NO_DST_DENY_WRITE RT_BIT(1)
445/** Do not use RTFILE_O_DENY_WRITE on either of the two files. */
446#define RTFILECOPY_FLAGS_NO_DENY_WRITE ( RTFILECOPY_FLAGS_NO_SRC_DENY_WRITE | RTFILECOPY_FLAGS_NO_DST_DENY_WRITE )
447/** */
448#define RTFILECOPY_FLAGS_MASK UINT32_C(0x00000003)
449/** @} */
450
451/**
452 * Copies a file.
453 *
454 * @returns VERR_ALREADY_EXISTS if the destination file exists.
455 * @returns VBox Status code.
456 *
457 * @param pszSrc The path to the source file.
458 * @param pszDst The path to the destination file.
459 * This file will be created.
460 * @param fFlags Flags (RTFILECOPY_*).
461 * @param pfnProgress Pointer to callback function for reporting progress.
462 * @param pvUser User argument to pass to pfnProgress along with the completion precentage.
463 */
464RTDECL(int) RTFileCopyEx(const char *pszSrc, const char *pszDst, uint32_t fFlags, PFNRTPROGRESS pfnProgress, void *pvUser);
465
466/**
467 * Copies a file given the handles to both files and
468 * provide progress callbacks.
469 *
470 * @returns IPRT status code.
471 *
472 * @param FileSrc The source file. The file position is unaltered.
473 * @param FileDst The destination file.
474 * On successful returns the file position is at the end of the file.
475 * On failures the file position and size is undefined.
476 * @param pfnProgress Pointer to callback function for reporting progress.
477 * @param pvUser User argument to pass to pfnProgress along with the completion precentage.
478 */
479RTDECL(int) RTFileCopyByHandlesEx(RTFILE FileSrc, RTFILE FileDst, PFNRTPROGRESS pfnProgress, void *pvUser);
480
481/**
482 * Renames a file.
483 *
484 * Identical to RTPathRename except that it will ensure that the source is not a directory.
485 *
486 * @returns IPRT status code.
487 * @returns VERR_ALREADY_EXISTS if the destination file exists.
488 *
489 * @param pszSrc The path to the source file.
490 * @param pszDst The path to the destination file.
491 * This file will be created.
492 * @param fRename See RTPathRename.
493 */
494RTDECL(int) RTFileRename(const char *pszSrc, const char *pszDst, unsigned fRename);
495
496
497/** @name RTFileMove flags (bit masks).
498 * @{ */
499/** Replace destination file if present. */
500#define RTFILEMOVE_FLAGS_REPLACE 0x1
501/** @} */
502
503/**
504 * Moves a file.
505 *
506 * RTFileMove differs from RTFileRename in that it works across volumes.
507 *
508 * @returns IPRT status code.
509 * @returns VERR_ALREADY_EXISTS if the destination file exists.
510 *
511 * @param pszSrc The path to the source file.
512 * @param pszDst The path to the destination file.
513 * This file will be created.
514 * @param fMove A combination of the RTFILEMOVE_* flags.
515 */
516RTDECL(int) RTFileMove(const char *pszSrc, const char *pszDst, unsigned fMove);
517
518
519/** @page pg_rt_filelock RT File locking API description
520 *
521 * File locking general rules:
522 *
523 * Region to lock or unlock can be located beyond the end of file, this can be used for
524 * growing files.
525 * Read (or Shared) locks can be acquired held by an unlimited number of processes at the
526 * same time, but a Write (or Exclusive) lock can only be acquired by one process, and
527 * cannot coexist with a Shared lock. To acquire a Read lock, a process must wait until
528 * there are no processes holding any Write locks. To acquire a Write lock, a process must
529 * wait until there are no processes holding either kind of lock.
530 * By default, RTFileLock and RTFileChangeLock calls returns error immediately if the lock
531 * can't be acquired due to conflict with other locks, however they can be called in wait mode.
532 *
533 * Differences in implementation:
534 *
535 * Win32, OS/2: Locking is mandatory, since locks are enforced by the operating system.
536 * I.e. when file region is locked in Read mode, any write in it will fail; in case of Write
537 * lock - region can be readed and writed only by lock's owner.
538 *
539 * Win32: File size change (RTFileSetSize) is not controlled by locking at all (!) in the
540 * operation system. Also see comments to RTFileChangeLock API call.
541 *
542 * Linux/Posix: By default locks in Unixes are advisory. This means that cooperating processes
543 * may use locks to coordinate access to a file between themselves, but programs are also free
544 * to ignore locks and access the file in any way they choose to.
545 *
546 * Additional reading:
547 * http://en.wikipedia.org/wiki/File_locking
548 * http://unixhelp.ed.ac.uk/CGI/man-cgi?fcntl+2
549 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/lockfileex.asp
550 */
551
552/** @name Lock flags (bit masks).
553 * @{ */
554/** Read access, can be shared with others. */
555#define RTFILE_LOCK_READ 0x00
556/** Write access, one at a time. */
557#define RTFILE_LOCK_WRITE 0x01
558/** Don't wait for other locks to be released. */
559#define RTFILE_LOCK_IMMEDIATELY 0x00
560/** Wait till conflicting locks have been released. */
561#define RTFILE_LOCK_WAIT 0x02
562/** Valid flags mask */
563#define RTFILE_LOCK_MASK 0x03
564/** @} */
565
566
567/**
568 * Locks a region of file for read (shared) or write (exclusive) access.
569 *
570 * @returns iprt status code.
571 * @returns VERR_FILE_LOCK_VIOLATION if lock can't be acquired.
572 * @param File Handle to the file.
573 * @param fLock Lock method and flags, see RTFILE_LOCK_* defines.
574 * @param offLock Offset of lock start.
575 * @param cbLock Length of region to lock, may overlap the end of file.
576 */
577RTR3DECL(int) RTFileLock(RTFILE File, unsigned fLock, int64_t offLock, uint64_t cbLock);
578
579/**
580 * Changes a lock type from read to write or from write to read.
581 * The region to type change must correspond exactly to an existing locked region.
582 * If change can't be done due to locking conflict and non-blocking mode is used, error is
583 * returned and lock keeps its state (see next warning).
584 *
585 * WARNING: win32 implementation of this call is not atomic, it transforms to a pair of
586 * calls RTFileUnlock and RTFileLock. Potentially the previously acquired lock can be
587 * lost, i.e. function is called in non-blocking mode, previous lock is freed, new lock can't
588 * be acquired, and old lock (previous state) can't be acquired back too. This situation
589 * may occurs _only_ if the other process is acquiring a _write_ lock in blocking mode or
590 * in race condition with the current call.
591 * In this very bad case special error code VERR_FILE_LOCK_LOST will be returned.
592 *
593 * @returns iprt status code.
594 * @returns VERR_FILE_NOT_LOCKED if region was not locked.
595 * @returns VERR_FILE_LOCK_VIOLATION if lock type can't be changed, lock remains its type.
596 * @returns VERR_FILE_LOCK_LOST if lock was lost, we haven't this lock anymore :(
597 * @param File Handle to the file.
598 * @param fLock Lock method and flags, see RTFILE_LOCK_* defines.
599 * @param offLock Offset of lock start.
600 * @param cbLock Length of region to lock, may overlap the end of file.
601 */
602RTR3DECL(int) RTFileChangeLock(RTFILE File, unsigned fLock, int64_t offLock, uint64_t cbLock);
603
604/**
605 * Unlocks previously locked region of file.
606 * The region to unlock must correspond exactly to an existing locked region.
607 *
608 * @returns iprt status code.
609 * @returns VERR_FILE_NOT_LOCKED if region was not locked.
610 * @param File Handle to the file.
611 * @param offLock Offset of lock start.
612 * @param cbLock Length of region to unlock, may overlap the end of file.
613 */
614RTR3DECL(int) RTFileUnlock(RTFILE File, int64_t offLock, uint64_t cbLock);
615
616
617/**
618 * Query information about an open file.
619 *
620 * @returns iprt status code.
621 *
622 * @param File Handle to the file.
623 * @param pObjInfo Object information structure to be filled on successful return.
624 * @param enmAdditionalAttribs Which set of additional attributes to request.
625 * Use RTFSOBJATTRADD_NOTHING if this doesn't matter.
626 */
627RTR3DECL(int) RTFileQueryInfo(RTFILE File, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs);
628
629/**
630 * Changes one or more of the timestamps associated of file system object.
631 *
632 * @returns iprt status code.
633 * @returns VERR_NOT_SUPPORTED is returned if the operation isn't supported by the OS.
634 *
635 * @param File Handle to the file.
636 * @param pAccessTime Pointer to the new access time. NULL if not to be changed.
637 * @param pModificationTime Pointer to the new modifcation time. NULL if not to be changed.
638 * @param pChangeTime Pointer to the new change time. NULL if not to be changed.
639 * @param pBirthTime Pointer to the new time of birth. NULL if not to be changed.
640 *
641 * @remark The file system might not implement all these time attributes,
642 * the API will ignore the ones which aren't supported.
643 *
644 * @remark The file system might not implement the time resolution
645 * employed by this interface, the time will be chopped to fit.
646 *
647 * @remark The file system may update the change time even if it's
648 * not specified.
649 *
650 * @remark POSIX can only set Access & Modification and will always set both.
651 */
652RTR3DECL(int) RTFileSetTimes(RTFILE File, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
653 PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime);
654
655/**
656 * Gets one or more of the timestamps associated of file system object.
657 *
658 * @returns iprt status code.
659 * @param File Handle to the file.
660 * @param pAccessTime Where to store the access time. NULL is ok.
661 * @param pModificationTime Where to store the modifcation time. NULL is ok.
662 * @param pChangeTime Where to store the change time. NULL is ok.
663 * @param pBirthTime Where to store the time of birth. NULL is ok.
664 *
665 * @remark This is wrapper around RTFileQueryInfo() and exists to complement RTFileSetTimes().
666 */
667RTR3DECL(int) RTFileGetTimes(RTFILE File, PRTTIMESPEC pAccessTime, PRTTIMESPEC pModificationTime,
668 PRTTIMESPEC pChangeTime, PRTTIMESPEC pBirthTime);
669
670/**
671 * Changes the mode flags of an open file.
672 *
673 * The API requires at least one of the mode flag sets (Unix/Dos) to
674 * be set. The type is ignored.
675 *
676 * @returns iprt status code.
677 * @param File Handle to the file.
678 * @param fMode The new file mode, see @ref grp_rt_fs for details.
679 */
680RTR3DECL(int) RTFileSetMode(RTFILE File, RTFMODE fMode);
681
682/**
683 * Gets the mode flags of an open file.
684 *
685 * @returns iprt status code.
686 * @param File Handle to the file.
687 * @param pfMode Where to store the file mode, see @ref grp_rt_fs for details.
688 *
689 * @remark This is wrapper around RTFileQueryInfo()
690 * and exists to complement RTFileSetMode().
691 */
692RTR3DECL(int) RTFileGetMode(RTFILE File, uint32_t *pfMode);
693
694/**
695 * Changes the owner and/or group of an open file.
696 *
697 * @returns iprt status code.
698 * @param File Handle to the file.
699 * @param uid The new file owner user id. Use -1 (or ~0) to leave this unchanged.
700 * @param gid The new group id. Use -1 (or ~0) to leave this unchanged.
701 */
702RTR3DECL(int) RTFileSetOwner(RTFILE File, uint32_t uid, uint32_t gid);
703
704/**
705 * Gets the owner and/or group of an open file.
706 *
707 * @returns iprt status code.
708 * @param File Handle to the file.
709 * @param pUid Where to store the owner user id. NULL is ok.
710 * @param pGid Where to store the group id. NULL is ok.
711 *
712 * @remark This is wrapper around RTFileQueryInfo() and exists to complement RTFileGetOwner().
713 */
714RTR3DECL(int) RTFileGetOwner(RTFILE File, uint32_t *pUid, uint32_t *pGid);
715
716/**
717 * Executes an IOCTL on a file descriptor.
718 *
719 * This function is currently only available in L4 and posix environments.
720 * Attemps at calling it from code shared with any other platforms will break things!
721 *
722 * The rational for defining this API is to simplify L4 porting of audio drivers,
723 * and to remove some of the assumptions on RTFILE being a file descriptor on
724 * platforms using the posix file implementation.
725 *
726 * @returns iprt status code.
727 * @param File Handle to the file.
728 * @param iRequest IOCTL request to carry out.
729 * @param pvData IOCTL data.
730 * @param cbData Size of the IOCTL data.
731 * @param piRet Return value of the IOCTL request.
732 */
733RTR3DECL(int) RTFileIoCtl(RTFILE File, int iRequest, void *pvData, unsigned cbData, int *piRet);
734
735/**
736 * Reads the file into memory.
737 *
738 * The caller must free the memory using RTFileReadAllFree().
739 *
740 * @returns IPRT status code.
741 * @param pszFilename The name of the file.
742 * @param ppvFile Where to store the pointer to the memory on successful return.
743 * @param pcbFile Where to store the size of the returned memory.
744 *
745 * @remarks Note that this function may be implemented using memory mapping, which means
746 * that the file may remain open until RTFileReadAllFree() is called. It also
747 * means that the return memory may reflect the state of the file when it's
748 * accessed instead of when this call was done. So, in short, don't use this
749 * API for volatile files, then rather use the extended variant with a
750 * yet-to-be-defined.
751 */
752RTDECL(int) RTFileReadAll(const char *pszFilename, void **ppvFile, size_t *pcbFile);
753
754/**
755 * Reads the file into memory.
756 *
757 * The caller must free the memory using RTFileReadAllFree().
758 *
759 * @returns IPRT status code.
760 * @param pszFilename The name of the file.
761 * @param off The offset to start reading at.
762 * @param cbMax The maximum number of bytes to read into memory. Specify RTFOFF_MAX
763 * to read to the end of the file.
764 * @param fFlags See RTFILE_RDALL_*.
765 * @param ppvFile Where to store the pointer to the memory on successful return.
766 * @param pcbFile Where to store the size of the returned memory.
767 *
768 * @remarks See the remarks for RTFileReadAll.
769 */
770RTDECL(int) RTFileReadAllEx(const char *pszFilename, RTFOFF off, RTFOFF cbMax, uint32_t fFlags, void **ppvFile, size_t *pcbFile);
771
772/**
773 * Reads the file into memory.
774 *
775 * The caller must free the memory using RTFileReadAllFree().
776 *
777 * @returns IPRT status code.
778 * @param File The handle to the file.
779 * @param ppvFile Where to store the pointer to the memory on successful return.
780 * @param pcbFile Where to store the size of the returned memory.
781 *
782 * @remarks See the remarks for RTFileReadAll.
783 */
784RTDECL(int) RTFileReadAllByHandle(RTFILE File, void **ppvFile, size_t *pcbFile);
785
786/**
787 * Reads the file into memory.
788 *
789 * The caller must free the memory using RTFileReadAllFree().
790 *
791 * @returns IPRT status code.
792 * @param File The handle to the file.
793 * @param off The offset to start reading at.
794 * @param cbMax The maximum number of bytes to read into memory. Specify RTFOFF_MAX
795 * to read to the end of the file.
796 * @param fFlags See RTFILE_RDALL_*.
797 * @param ppvFile Where to store the pointer to the memory on successful return.
798 * @param pcbFile Where to store the size of the returned memory.
799 *
800 * @remarks See the remarks for RTFileReadAll.
801 */
802RTDECL(int) RTFileReadAllByHandleEx(RTFILE File, RTFOFF off, RTFOFF cbMax, uint32_t fFlags, void **ppvFile, size_t *pcbFile);
803
804/**
805 * Frees the memory returned by one of the RTFileReadAll(), RTFileReadAllEx(),
806 * RTFileReadAllByHandle() and RTFileReadAllByHandleEx() functions.
807 *
808 * @param pvFile Pointer to the memory.
809 * @param cbFile The size of the memory.
810 */
811RTDECL(void) RTFileReadAllFree(void *pvFile, size_t cbFile);
812
813/** @name RTFileReadAllEx and RTFileReadAllHandleEx flags
814 * The open flags are ignored by RTFileReadAllHandleEx.
815 * @{ */
816#define RTFILE_RDALL_O_DENY_NONE RTFILE_O_DENY_NONE
817#define RTFILE_RDALL_O_DENY_READ RTFILE_O_DENY_READ
818#define RTFILE_RDALL_O_DENY_WRITE RTFILE_O_DENY_WRITE
819#define RTFILE_RDALL_O_DENY_READWRITE RTFILE_O_DENY_READWRITE
820#define RTFILE_RDALL_O_DENY_ALL RTFILE_O_DENY_ALL
821#define RTFILE_RDALL_O_DENY_NOT_DELETE RTFILE_O_DENY_NOT_DELETE
822#define RTFILE_RDALL_O_DENY_MASK RTFILE_O_DENY_MASK
823/** Mask of valid flags. */
824#define RTFILE_RDALL_VALID_MASK RTFILE_RDALL_O_DENY_MASK
825/** @} */
826
827
828/** @page pg_rt_asyncio RT File async I/O API
829 *
830 * File operations are usually blocking the calling thread until
831 * they completed making it impossible to let the thread do anything
832 * else inbetween.
833 * The RT File async I/O API provides an easy and efficient way to
834 * access files asynchronously using the native facilities provided
835 * by each operating system.
836 *
837 * @section sec_rt_asyncio_objects Objects
838 *
839 * There are two objects used in this API.
840 * The first object is the request. A request contains every information
841 * needed two complete the file operation successfully like the start offset
842 * and pointer to the source or destination buffer.
843 * Requests are created with RTFileAioReqCreate() and destroyed with
844 * RTFileAioReqDestroy().
845 * Because creating a request may require allocating various operating
846 * system dependent ressources and may be quite expensive it is possible
847 * to use a request more than once to save CPU cycles.
848 * A request is constructed with either RTFileAioReqPrepareRead()
849 * which will set up a request to read from the given file or
850 * RTFileAioReqPrepareWrite() which will write to a given file.
851 *
852 * The second object is the context. A file is associated with a context
853 * and requests for this file may complete only on the context the file
854 * was associated with and not on the context given in RTFileAioCtxSubmit()
855 * (see below for further information).
856 * RTFileAioCtxWait() is used to wait for completion of requests which were
857 * associated with the context. While waiting for requests the thread can not
858 * respond to global state changes. Thatswhy the API provides a way to let
859 * RTFileAioCtxWait() return immediately no matter how many requests
860 * have finished through RTFileAioCtxWakeup(). The return code is
861 * VERR_INTERRUPTED to let the thread know that he got interrupted.
862 *
863 * @section sec_rt_asyncio_request_states Request states
864 *
865 * Created:
866 * After a request was created with RTFileAioReqCreate() it is in the same state
867 * like it just completed successfully. RTFileAioReqGetRC() will return VINF_SUCCESS
868 * and a transfer size of 0. RTFileAioReqGetUser() will return NULL. The request can be
869 * destroyed RTFileAioReqDestroy(). It is also allowed to prepare a the request
870 * for a data transfer with the RTFileAioReqPrepare* methods.
871 * Calling any other method like RTFileAioCtxSubmit() will return VERR_FILE_AIO_NOT_PREPARED
872 * and RTFileAioReqCancel() returns VERR_FILE_AIO_NOT_SUBMITTED.
873 *
874 * Prepared:
875 * A request will enter this state if one of the RTFileAioReqPrepare* methods
876 * is called. In this state you can still destroy and retrieve the user data
877 * associated with the request but trying to cancel the request or getting
878 * the result of the operation will return VERR_FILE_AIO_NOT_SUBMITTED.
879 *
880 * Submitted:
881 * A prepared request can be submitted with RTFileAioCtxSubmit(). If the operation
882 * succeeds it is not allowed to touch the request or free any ressources until
883 * it completed through RTFileAioCtxWait(). The only allowed method is RTFileAioReqCancel()
884 * which tries to cancel the request. The request will go into the completed state
885 * and RTFileAioReqGetRC() will return VERR_FILE_AIO_CANCELED.
886 * If the request completes not matter if successfully or with an error it will
887 * switch into the completed state. RTFileReqDestroy() fails if the given request
888 * is in this state.
889 *
890 * Completed:
891 * The request will be in this state after it completed and returned through
892 * RTFileAioCtxWait(). RTFileAioReqGetRC() returns the final result code
893 * and the number of bytes transfered.
894 * The request can be used for new data transfers.
895 *
896 * @section sec_rt_asyncio_threading Threading
897 *
898 * The API is a thin wrapper around the specific host OS APIs and therefore
899 * relies on the thread safety of the underlying API.
900 * The interesting functions with regards to thread safety are RTFileAioCtxSubmit()
901 * and RTFileAioCtxWait(). RTFileAioCtxWait() must not be called from different
902 * threads at the same time with the same context handle. The same applies to
903 * RTFileAioCtxSubmit(). However it is possible to submit new requests from a different
904 * thread while waiting for completed requests on another thread with RTFileAioCtxWait().
905 *
906 * @section sec_rt_asyncio_implementations Differences in implementation
907 *
908 * Because the host APIs are quite different on every OS and every API has other limitations
909 * there are some things to consider to make the code as portable as possible.
910 *
911 * The first restriction at the moment is that every buffer has to be aligned to a 512 byte boundary.
912 * This limitation comes from the Linux io_* interface. To use the interface the file
913 * must be opened with O_DIRECT. This flag disables the kernel cache too which may
914 * degrade performance but is unfortunately the only way to make asynchronous
915 * I/O work till today (if O_DIRECT is omitted io_submit will revert to sychronous behavior
916 * and will return when the requests finished and when they are queued).
917 * It is mostly used by DBMS which do theire own caching.
918 * Furthermore there is no filesystem independent way to discover the restrictions at least
919 * for the 2.4 kernel series. Since 2.6 the 512 byte boundary seems to be used by all
920 * file systems. So Linus comment about this flag is comprehensible but Linux
921 * lacks an alternative at the moment.
922 *
923 * The next limitation applies only to Windows. Requests are not associated with the
924 * I/O context they are associated with but with the file the request is for.
925 * The file needs to be associated with exactly one I/O completion port and requests
926 * for this file will only arrive at that context after they completed and not on
927 * the context the request was submitted.
928 * To associate a file with a specific context RTFileAioCtxAssociateWithFile() is
929 * used. It is only implemented on Windows and does nothing on the other platforms.
930 * If the file needs to be associated with different context for some reason
931 * the file must be closed first. After it was opened again the new context
932 * can be associated with the other context.
933 * This can't be done by the API because there is no way to retrieve the flags
934 * the file was opened with.
935 */
936
937/**
938 * Global limits for the AIO API.
939 */
940typedef struct RTFILEAIOLIMITS
941{
942 /** Global number of simultaneous outstanding requests allowed.
943 * RTFILEAIO_UNLIMITED_REQS means no limit. */
944 uint32_t cReqsOutstandingMax;
945 /** The alignment data buffers need to have.
946 * 0 means no alignment restrictions. */
947 uint32_t cbBufferAlignment;
948} RTFILEAIOLIMITS;
949/** A pointer to a AIO limits structure. */
950typedef RTFILEAIOLIMITS *PRTFILEAIOLIMITS;
951
952/**
953 * Returns the global limits for the AIO API.
954 *
955 * @returns IPRT status code.
956 * @retval VERR_NOT_SUPPORTED if the host does not support the async I/O API.
957 *
958 * @param pAioLimits Where to store the global limit information.
959 */
960RTDECL(int) RTFileAioGetLimits(PRTFILEAIOLIMITS pAioLimits);
961
962/**
963 * Creates an async I/O request handle.
964 *
965 * @returns IPRT status code.
966 * @param phReq Where to store the request handle.
967 */
968RTDECL(int) RTFileAioReqCreate(PRTFILEAIOREQ phReq);
969
970/**
971 * Destroys an async I/O request handle.
972 *
973 * @returns IPRT status code.
974 * @retval VERR_FILE_AIO_IN_PROGRESS if the request is still in progress.
975 *
976 * @param hReq The request handle.
977 */
978RTDECL(int) RTFileAioReqDestroy(RTFILEAIOREQ hReq);
979
980/**
981 * Prepares an async read request.
982 *
983 * @returns IPRT status code.
984 * @retval VERR_FILE_AIO_IN_PROGRESS if the request is still in progress.
985 *
986 * @param hReq The request handle.
987 * @param hFile The file to read from.
988 * @param off The offset to start reading at.
989 * @param pvBuf Where to store the read bits.
990 * @param cbRead Number of bytes to read.
991 * @param pvUser Opaque user data associated with this request which
992 * can be retrieved with RTFileAioReqGetUser().
993 */
994RTDECL(int) RTFileAioReqPrepareRead(RTFILEAIOREQ hReq, RTFILE hFile, RTFOFF off,
995 void *pvBuf, size_t cbRead, void *pvUser);
996
997/**
998 * Prepares an async write request.
999 *
1000 * @returns IPRT status code.
1001 * @retval VERR_FILE_AIO_IN_PROGRESS if the request is still in progress.
1002 *
1003 * @param hReq The request handle.
1004 * @param hFile The file to write to.
1005 * @param off The offset to start writing at.
1006 * @param pvBuf Where to store the written bits.
1007 * @param cbRead Number of bytes to write.
1008 * @param pvUser Opaque user data associated with this request which
1009 * can be retrieved with RTFileAioReqGetUser().
1010 */
1011RTDECL(int) RTFileAioReqPrepareWrite(RTFILEAIOREQ hReq, RTFILE hFile, RTFOFF off,
1012 void *pvBuf, size_t cbWrite, void *pvUser);
1013
1014/**
1015 * Prepares an async flush of all cached data associated with a file handle.
1016 *
1017 * @returns IPRT status code.
1018 * @retval VERR_FILE_AIO_IN_PROGRESS if the request is still in progress.
1019 *
1020 * @param hReq The request handle.
1021 * @param hFile The file to flush.
1022 * @param pvUser Opaque user data associated with this request which
1023 * can be retrieved with RTFileAioReqGetUser().
1024 *
1025 * @remarks May also flush other caches on some platforms.
1026 */
1027RTDECL(int) RTFileAioReqPrepareFlush(RTFILEAIOREQ hReq, RTFILE hFile, void *pvUser);
1028
1029/**
1030 * Gets the opaque user data associated with the given request.
1031 *
1032 * @returns Opaque user data.
1033 * @retval NULL if the request hasn't been prepared yet.
1034 *
1035 * @param hReq The request handle.
1036 */
1037RTDECL(void *) RTFileAioReqGetUser(RTFILEAIOREQ hReq);
1038
1039/**
1040 * Cancels a pending request.
1041 *
1042 * @returns IPRT status code.
1043 * @retval VINF_SUCCESS If the request was canceled.
1044 * @retval VERR_FILE_AIO_NOT_SUBMITTED If the request wasn't submitted yet.
1045 * @retval VERR_FILE_AIO_IN_PROGRESS If the request could not be canceled because it is already processed.
1046 * @retval VERR_FILE_AIO_COMPLETED If the request could not be canceled because it already completed.
1047 *
1048 * @param hReq The request to cancel.
1049 */
1050RTDECL(int) RTFileAioReqCancel(RTFILEAIOREQ hReq);
1051
1052/**
1053 * Gets the status of a completed request.
1054 *
1055 * @returns The IPRT status code of the given request.
1056 * @retval VERR_FILE_AIO_NOT_SUBMITTED if the request wasn't submitted yet.
1057 * @retval VERR_FILE_AIO_CANCELED if the request was canceled.
1058 * @retval VERR_FILE_AIO_IN_PROGRESS if the request isn't yet completed.
1059 *
1060 * @param hReq The request handle.
1061 * @param pcbTransferred Where to store the number of bytes transfered.
1062 * Optional since it is not relevant for all kinds of
1063 * requests.
1064 */
1065RTDECL(int) RTFileAioReqGetRC(RTFILEAIOREQ hReq, size_t *pcbTransfered);
1066
1067
1068
1069/**
1070 * Creates an async I/O context.
1071 *
1072 * @todo briefly explain what an async context is here or in the page
1073 * above.
1074 *
1075 * @returns IPRT status code.
1076 * @param phAioCtx Where to store the async I/O context handle.
1077 * @param cAioReqsMax How many async I/O requests the context should be capable
1078 * to handle. Pass RTFILEAIO_UNLIMITED_REQS if the
1079 * context should support an unlimited number of
1080 * requests.
1081 */
1082RTDECL(int) RTFileAioCtxCreate(PRTFILEAIOCTX phAioCtx, uint32_t cAioReqsMax);
1083
1084/** Unlimited number of requests.
1085 * Used with RTFileAioCtxCreate and RTFileAioCtxGetMaxReqCount. */
1086#define RTFILEAIO_UNLIMITED_REQS UINT32_MAX
1087
1088/**
1089 * Destroys an async I/O context.
1090 *
1091 * @returns IPRT status code.
1092 * @param hAioCtx The async I/O context handle.
1093 */
1094RTDECL(int) RTFileAioCtxDestroy(RTFILEAIOCTX hAioCtx);
1095
1096/**
1097 * Get the maximum number of requests one aio context can handle.
1098 *
1099 * @returns Maximum number of tasks the context can handle.
1100 * RTFILEAIO_UNLIMITED_REQS if there is no limit.
1101 *
1102 * @param hAioCtx The async I/O context handle.
1103 * If NIL_RTAIOCONTEXT is passed the maximum value
1104 * which can be passed to RTFileAioCtxCreate()
1105 * is returned.
1106 */
1107RTDECL(uint32_t) RTFileAioCtxGetMaxReqCount(RTFILEAIOCTX hAioCtx);
1108
1109/**
1110 * Associates a file with a async I/O context.
1111 * Requests for this file will arrive at the completion port
1112 * associated with the file.
1113 *
1114 * @returns IPRT status code.
1115 *
1116 * @param hAioCtx The async I/O context handle.
1117 * @param hFile The file handle.
1118 */
1119RTDECL(int) RTFileAioCtxAssociateWithFile(RTFILEAIOCTX hAioCtx, RTFILE hFile);
1120
1121/**
1122 * Submits a set of requests to an async I/O context for processing.
1123 *
1124 * @returns IPRT status code.
1125 * @returns VERR_FILE_AIO_INSUFFICIENT_RESSOURCES if the maximum number of
1126 * simultaneous outstanding requests would be exceeded.
1127 *
1128 * @param hAioCtx The async I/O context handle.
1129 * @param pahReqs Pointer to an array of request handles.
1130 * @param cReqs The number of entries in the array.
1131 *
1132 * @remarks It is possible that some requests could be submitted successfully
1133 * even if the method returns an error code. In that case RTFileAioReqGetRC()
1134 * can be used to determine the status of a request.
1135 * If it returns VERR_FILE_AIO_IN_PROGRESS it was submitted successfully.
1136 * Any other error code may indicate why the request failed.
1137 * VERR_FILE_AIO_NOT_SUBMITTED indicates that a request wasn't submitted
1138 * probably because the previous request encountered an error.
1139 *
1140 * @remarks @a cReqs uses the type size_t while it really is a uint32_t, this is
1141 * to avoid annoying warnings when using RT_ELEMENTS and similar
1142 * macros.
1143 */
1144RTDECL(int) RTFileAioCtxSubmit(RTFILEAIOCTX hAioCtx, PRTFILEAIOREQ pahReqs, size_t cReqs);
1145
1146/**
1147 * Waits for request completion.
1148 *
1149 * Only one thread at a time may call this API on a context.
1150 *
1151 * @returns IPRT status code.
1152 * @retval VERR_INVALID_POINTER If pcReqs or/and pahReqs are invalid.
1153 * @retval VERR_INVALID_HANDLE If hAioCtx is invalid.
1154 * @retval VERR_OUT_OF_RANGE If cMinReqs is larger than cReqs.
1155 * @retval VERR_INVALID_PARAMETER If cReqs is 0.
1156 * @retval VERR_TIMEOUT If cMinReqs didn't complete before the
1157 * timeout expired.
1158 * @retval VERR_INTERRUPTED If the completion context was interrupted
1159 * by RTFileAioCtxWakeup().
1160 * @retval VERR_FILE_AIO_NO_REQUEST If there are no pending request.
1161 *
1162 * @param hAioCtx The async I/O context handle to wait and get
1163 * completed requests from.
1164 * @param cMinReqs The minimum number of requests which have to
1165 * complete before this function returns.
1166 * @param cMillisTimeout The number of milliseconds to wait before returning
1167 * VERR_TIMEOUT. Use RT_INDEFINITE_WAIT to wait
1168 * forever.
1169 * @param pahReqs Pointer to an array where the handles of the
1170 * completed requests will be stored on success.
1171 * @param cReqs The number of entries @a pahReqs can hold.
1172 * @param pcReqs Where to store the number of returned (complete)
1173 * requests. This will always be set.
1174 *
1175 * @remarks The wait will be resume if interrupted by a signal. An
1176 * RTFileAioCtxWaitNoResume variant can be added later if it becomes
1177 * necessary.
1178 *
1179 * @remarks @a cMinReqs and @a cReqs use the type size_t while they really are
1180 * uint32_t's, this is to avoid annoying warnings when using
1181 * RT_ELEMENTS and similar macros.
1182 */
1183RTDECL(int) RTFileAioCtxWait(RTFILEAIOCTX hAioCtx, size_t cMinReqs, unsigned cMillisTimeout,
1184 PRTFILEAIOREQ pahReqs, size_t cReqs, uint32_t *pcReqs);
1185
1186/**
1187 * Forces any RTFileAioCtxWait() call on another thread to return immediately.
1188 *
1189 * @returns IPRT status code.
1190 *
1191 * @param hAioCtx The handle of the async I/O context to wakeup.
1192 */
1193RTDECL(int) RTFileAioCtxWakeup(RTFILEAIOCTX hAioCtx);
1194
1195#endif /* IN_RING3 */
1196
1197/** @} */
1198
1199RT_C_DECLS_END
1200
1201#endif
1202
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette