VirtualBox

Changeset 34029 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Nov 12, 2010 2:21:59 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
67708
Message:

iprt/vfs/tar: more code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/vfslowlevel.h

    r34002 r34029  
    4040 */
    4141
     42
     43/** @name VFS Lock Abstraction
     44 * @todo This should be moved somewhere else as it is of general use.
     45 * @{ */
     46
     47/**
     48 * VFS lock types.
     49 */
     50typedef enum RTVFSLOCKTYPE
     51{
     52    /** Invalid lock type. */
     53    RTVFSLOCKTYPE_INVALID = 0,
     54    /** Read write semaphore. */
     55    RTVFSLOCKTYPE_RW,
     56    /** Fast mutex semaphore (critical section in ring-3). */
     57    RTVFSLOCKTYPE_FASTMUTEX,
     58    /** Full fledged mutex semaphore. */
     59    RTVFSLOCKTYPE_MUTEX,
     60    /** The end of valid lock types. */
     61    RTVFSLOCKTYPE_END,
     62    /** The customary 32-bit type hack. */
     63    RTVFSLOCKTYPE_32BIT_HACK = 0x7fffffff
     64} RTVFSLOCKTYPE;
     65
     66/** VFS lock handle. */
     67typedef struct RTVFSLOCKINTERNAL   *RTVFSLOCK;
     68/** Pointer to a VFS lock handle. */
     69typedef RTVFSLOCK                  *PRTVFSLOCK;
     70/** Nil VFS lock handle. */
     71#define NIL_RTVFSLOCK               ((RTVFSLOCK)~(uintptr_t)0)
     72
     73/** Special handle value for creating a new read/write semaphore based lock. */
     74#define RTVFSLOCK_CREATE_RW         ((RTVFSLOCK)~(uintptr_t)1)
     75/** Special handle value for creating a new fast mutex semaphore based lock. */
     76#define RTVFSLOCK_CREATE_FASTMUTEX  ((RTVFSLOCK)~(uintptr_t)2)
     77/** Special handle value for creating a new mutex semaphore based lock. */
     78#define RTVFSLOCK_CREATE_MUTEX      ((RTVFSLOCK)~(uintptr_t)3)
     79
     80/**
     81 * Retains a reference to the VFS lock handle.
     82 *
     83 * @returns New reference count on success, UINT32_MAX on failure.
     84 * @param   hLock           The VFS lock handle.
     85 */
     86RTDECL(uint32_t) RTVfsLockRetain(RTVFSLOCK hLock);
     87
     88/**
     89 * Releases a reference to the VFS lock handle.
     90 *
     91 * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
     92 * @param   hLock           The VFS lock handle.
     93 */
     94RTDECL(uint32_t) RTVfsLockRelease(RTVFSLOCK hLock);
     95
     96/**
     97 * Gets the lock type.
     98 *
     99 * @returns The lock type on success, RTVFSLOCKTYPE_INVALID if the handle is
     100 *          not valid.
     101 * @param   hLock               The lock handle.
     102 */
     103RTDECL(RTVFSLOCKTYPE) RTVfsLockGetType(RTVFSLOCK hLock);
     104
     105
     106
     107RTDECL(void) RTVfsLockAcquireReadSlow(RTVFSLOCK hLock);
     108RTDECL(void) RTVfsLockReleaseReadSlow(RTVFSLOCK hLock);
     109RTDECL(void) RTVfsLockAcquireWriteSlow(RTVFSLOCK hLock);
     110RTDECL(void) RTVfsLockReleaseWriteSlow(RTVFSLOCK hLock);
     111/** @}  */
     112
     113/**
     114 * Acquire a read lock.
     115 *
     116 * @param   hLock               The lock handle, can be NIL.
     117 */
     118DECLINLINE(void) RTVfsLockAcquireRead(RTVFSLOCK hLock)
     119{
     120    if (hLock != NIL_RTVFSLOCK)
     121        RTVfsLockAcquireReadSlow(hLock);
     122}
     123
     124
     125/**
     126 * Release a read lock.
     127 *
     128 * @param   hLock               The lock handle, can be NIL.
     129 */
     130DECLINLINE(void) RTVfsLockReleaseRead(RTVFSLOCK hLock)
     131{
     132    if (hLock != NIL_RTVFSLOCK)
     133        RTVfsLockReleaseReadSlow(hLock);
     134}
     135
     136
     137/**
     138 * Acquire a write lock.
     139 *
     140 * @param   hLock               The lock handle, can be NIL.
     141 */
     142DECLINLINE(void) RTVfsLockAcquireWrite(RTVFSLOCK hLock)
     143{
     144    if (hLock != NIL_RTVFSLOCK)
     145        RTVfsLockAcquireWriteSlow(hLock);
     146}
     147
     148
     149/**
     150 * Release a write lock.
     151 *
     152 * @param   hLock               The lock handle, can be NIL.
     153 */
     154DECLINLINE(void) RTVfsLockReleaseWrite(RTVFSLOCK hLock)
     155{
     156    if (hLock != NIL_RTVFSLOCK)
     157        RTVfsLockReleaseWriteSlow(hLock);
     158}
     159
     160/** @}  */
     161
    42162/**
    43163 * The VFS operations.
     
    141261/** The RTVFSOBJOPS structure version. */
    142262#define RTVFSOBJOPS_VERSION         RT_MAKE_U32_FROM_U8(0xff,0x1f,1,0)
     263
     264
     265/**
     266 * Creates a new VFS base object handle.
     267 *
     268 * @returns IPRT status code
     269 * @param   pObjOps             The base object operations.
     270 * @param   cbInstance          The size of the instance data.
     271 * @param   hVfs                The VFS handle to associate this base object
     272 *                              with.  NIL_VFS is ok.
     273 * @param   hLock               Handle to a custom lock to be used with the new
     274 *                              object.  The reference is consumed.  NIL and
     275 *                              special lock handles are fine.
     276 * @param   phVfsFss            Where to return the new handle.
     277 * @param   ppvInstance         Where to return the pointer to the instance data
     278 *                              (size is @a cbInstance).
     279 */
     280RTDECL(int) RTVfsNewBaseObj(PCRTVFSOBJOPS pObjOps, size_t cbInstance, RTVFS hVfs, RTVFSLOCK hLock,
     281                            PRTVFSOBJ phVfsObj, void **ppvInstance);
    143282
    144283
     
    255394 * @param   cbInstance          The size of the instance data.
    256395 * @param   hVfs                The VFS handle to associate this filesystem
    257  *                              steram with.  NIL_VFS is ok.
    258  * @param   hSemRW              The read-write semaphore to use to protect the
    259  *                              handle if this differs from the one the VFS
    260  *                              uses.  NIL_RTSEMRW is ok if no locking is
    261  *                              desired.
     396 *                              stream with.  NIL_VFS is ok.
     397 * @param   hLock               Handle to a custom lock to be used with the new
     398 *                              object.  The reference is consumed.  NIL and
     399 *                              special lock handles are fine.
    262400 * @param   phVfsFss            Where to return the new handle.
    263401 * @param   ppvInstance         Where to return the pointer to the instance data
    264402 *                              (size is @a cbInstance).
    265403 */
    266 RTDECL(int) RTVfsNewFsStream(PCRTVFSFSSTREAMOPS pFsStreamOps, size_t cbInstance, RTVFS hVfs, RTSEMRW hSemRW,
     404RTDECL(int) RTVfsNewFsStream(PCRTVFSFSSTREAMOPS pFsStreamOps, size_t cbInstance, RTVFS hVfs, RTVFSLOCK hLock,
    267405                             PRTVFSFSSTREAM phVfsFss, void **ppvInstance);
    268406
     
    450588/** The RTVFSSYMLINKOPS structure version. */
    451589#define RTVFSSYMLINKOPS_VERSION     RT_MAKE_U32_FROM_U8(0xff,0x5f,1,0)
     590
     591
     592/**
     593 * Creates a new VFS symlink handle.
     594 *
     595 * @returns IPRT status code
     596 * @param   pSymlinkOps         The symlink operations.
     597 * @param   cbInstance          The size of the instance data.
     598 * @param   hVfs                The VFS handle to associate this symlink object
     599 *                              with.  NIL_VFS is ok.
     600 * @param   hLock               Handle to a custom lock to be used with the new
     601 *                              object.  The reference is consumed.  NIL and
     602 *                              special lock handles are fine.
     603 * @param   phVfsSym            Where to return the new handle.
     604 * @param   ppvInstance         Where to return the pointer to the instance data
     605 *                              (size is @a cbInstance).
     606 */
     607RTDECL(int) RTVfsNewSymlink(PCRTVFSSYMLINKOPS pSymlinkOps, size_t cbInstance, RTVFS hVfs, RTVFSLOCK hLock,
     608                            PRTVFSSYMLINK phVfsSym, void **ppvInstance);
    452609
    453610
     
    576733 * @param   hVfs                The VFS handle to associate this I/O stream
    577734 *                              with.  NIL_VFS is ok.
    578  * @param   hSemRW              The read-write semaphore to use to protect the
    579  *                              handle if this differs from the one the VFS
    580  *                              uses.  NIL_RTSEMRW is ok if no locking is
    581  *                              desired.
     735 * @param   hLock               Handle to a custom lock to be used with the new
     736 *                              object.  The reference is consumed.  NIL and
     737 *                              special lock handles are fine.
    582738 * @param   phVfsIos            Where to return the new handle.
    583739 * @param   ppvInstance         Where to return the pointer to the instance data
    584740 *                              (size is @a cbInstance).
    585741 */
    586 RTDECL(int) RTVfsNewIoStream(PCRTVFSIOSTREAMOPS pIoStreamOps, size_t cbInstance, uint32_t fOpen, RTVFS hVfs, RTSEMRW hSemRW,
     742RTDECL(int) RTVfsNewIoStream(PCRTVFSIOSTREAMOPS pIoStreamOps, size_t cbInstance, uint32_t fOpen, RTVFS hVfs, RTVFSLOCK hLock,
    587743                             PRTVFSIOSTREAM phVfsIos, void **ppvInstance);
    588744
     
    647803 * @param   hVfs                The VFS handle to associate this file with.
    648804 *                              NIL_VFS is ok.
     805 * @param   hLock               Handle to a custom lock to be used with the new
     806 *                              object.  The reference is consumed.  NIL and
     807 *                              special lock handles are fine.
    649808 * @param   phVfsFile           Where to return the new handle.
    650809 * @param   ppvInstance         Where to return the pointer to the instance data
    651810 *                              (size is @a cbInstance).
    652811 */
    653 RTDECL(int) RTVfsNewFile(PCRTVFSFILEOPS pFileOps, size_t cbInstance, uint32_t fOpen, RTVFS hVfs,
     812RTDECL(int) RTVfsNewFile(PCRTVFSFILEOPS pFileOps, size_t cbInstance, uint32_t fOpen, RTVFS hVfs, RTVFSLOCK hLock,
    654813                         PRTVFSFILE phVfsFile, void **ppvInstance);
    655814
Note: See TracChangeset for help on using the changeset viewer.

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