1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @file
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * IPRT - Virtual Filesystem.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/*
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Copyright (C) 2010-2012 Oracle Corporation
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * available from http://www.virtualbox.org. This file is free software;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * you can redistribute it and/or modify it under the terms of the GNU
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * General Public License (GPL) as published by the Free Software
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * The contents of this file may alternatively be used under the terms
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * of the Common Development and Distribution License Version 1.0
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * VirtualBox OSE distribution, in which case the provisions of the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * CDDL are applicable instead of those of the GPL.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * You may elect to license modified versions of this file under the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * terms and conditions of either the GPL or the CDDL or both.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifndef ___iprt_vfslowlevel_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define ___iprt_vfslowlevel_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#include <iprt/vfs.h>
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#include <iprt/err.h>
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#include <iprt/list.h>
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#include <iprt/param.h>
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
628ddfbd43ad5365d69fddda4007598242956577vboxsyncRT_C_DECLS_BEGIN
628ddfbd43ad5365d69fddda4007598242956577vboxsync
628ddfbd43ad5365d69fddda4007598242956577vboxsync/** @defgroup grp_rt_vfs_lowlevel RTVfs - Low-level Interface.
628ddfbd43ad5365d69fddda4007598242956577vboxsync * @ingroup grp_rt_vfs
628ddfbd43ad5365d69fddda4007598242956577vboxsync * @{
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync/** @name VFS Lock Abstraction
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync * @todo This should be moved somewhere else as it is of general use.
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync * @{ */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * VFS lock types.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef enum RTVFSLOCKTYPE
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync{
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Invalid lock type. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTVFSLOCKTYPE_INVALID = 0,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Read write semaphore. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTVFSLOCKTYPE_RW,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Fast mutex semaphore (critical section in ring-3). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTVFSLOCKTYPE_FASTMUTEX,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Full fledged mutex semaphore. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTVFSLOCKTYPE_MUTEX,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The end of valid lock types. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTVFSLOCKTYPE_END,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The customary 32-bit type hack. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTVFSLOCKTYPE_32BIT_HACK = 0x7fffffff
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync} RTVFSLOCKTYPE;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** VFS lock handle. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef struct RTVFSLOCKINTERNAL *RTVFSLOCK;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Pointer to a VFS lock handle. */
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsynctypedef RTVFSLOCK *PRTVFSLOCK;
ae5379e3e7573369566d4628ef6c597da693cc55vboxsync/** Nil VFS lock handle. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define NIL_RTVFSLOCK ((RTVFSLOCK)~(uintptr_t)0)
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync
ae5379e3e7573369566d4628ef6c597da693cc55vboxsync/** Special handle value for creating a new read/write semaphore based lock. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define RTVFSLOCK_CREATE_RW ((RTVFSLOCK)~(uintptr_t)1)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Special handle value for creating a new fast mutex semaphore based lock. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#define RTVFSLOCK_CREATE_FASTMUTEX ((RTVFSLOCK)~(uintptr_t)2)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/** Special handle value for creating a new mutex semaphore based lock. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#define RTVFSLOCK_CREATE_MUTEX ((RTVFSLOCK)~(uintptr_t)3)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Retains a reference to the VFS lock handle.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync *
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @returns New reference count on success, UINT32_MAX on failure.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param hLock The VFS lock handle.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncRTDECL(uint32_t) RTVfsLockRetain(RTVFSLOCK hLock);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
400d70dc1edb0f6d2a9d3a860b1b43f0b2cdfb39vboxsync/**
b6247ebeef75e5ab689ba845ad8cae8746607bb3vboxsync * Releases a reference to the VFS lock handle.
400d70dc1edb0f6d2a9d3a860b1b43f0b2cdfb39vboxsync *
400d70dc1edb0f6d2a9d3a860b1b43f0b2cdfb39vboxsync * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @param hLock The VFS lock handle.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync */
fd658895339cb48b2ba581b1a1141aea39009ff7vboxsyncRTDECL(uint32_t) RTVfsLockRelease(RTVFSLOCK hLock);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/**
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Gets the lock type.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns The lock type on success, RTVFSLOCKTYPE_INVALID if the handle is
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * not valid.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param hLock The lock handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncRTDECL(RTVFSLOCKTYPE) RTVfsLockGetType(RTVFSLOCK hLock);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
54d3b0107d9bf326fe6e0de92e012c791dbb1587vboxsyncRTDECL(void) RTVfsLockAcquireReadSlow(RTVFSLOCK hLock);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncRTDECL(void) RTVfsLockReleaseReadSlow(RTVFSLOCK hLock);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncRTDECL(void) RTVfsLockAcquireWriteSlow(RTVFSLOCK hLock);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncRTDECL(void) RTVfsLockReleaseWriteSlow(RTVFSLOCK hLock);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * Acquire a read lock.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param hLock The lock handle, can be NIL.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncDECLINLINE(void) RTVfsLockAcquireRead(RTVFSLOCK hLock)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync{
ce5210fe822f74de78c3dddc74f32a2cabcee5fdvboxsync if (hLock != NIL_RTVFSLOCK)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTVfsLockAcquireReadSlow(hLock);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync}
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
ce5210fe822f74de78c3dddc74f32a2cabcee5fdvboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * Release a read lock.
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync *
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * @param hLock The lock handle, can be NIL.
77cce7691847be5aef145f31ba3f9d66fc2cf594vboxsync */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsyncDECLINLINE(void) RTVfsLockReleaseRead(RTVFSLOCK hLock)
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync{
54d3b0107d9bf326fe6e0de92e012c791dbb1587vboxsync if (hLock != NIL_RTVFSLOCK)
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync RTVfsLockReleaseReadSlow(hLock);
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync}
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * Acquire a write lock.
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param hLock The lock handle, can be NIL.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
9e293277b378073ce86910209a246b744b4caa2cvboxsyncDECLINLINE(void) RTVfsLockAcquireWrite(RTVFSLOCK hLock)
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync{
9e293277b378073ce86910209a246b744b4caa2cvboxsync if (hLock != NIL_RTVFSLOCK)
9e293277b378073ce86910209a246b744b4caa2cvboxsync RTVfsLockAcquireWriteSlow(hLock);
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync}
9e293277b378073ce86910209a246b744b4caa2cvboxsync
aabfd650b7e36e2c25a6d48b2a2bfd95fe93b65avboxsync
aabfd650b7e36e2c25a6d48b2a2bfd95fe93b65avboxsync/**
aabfd650b7e36e2c25a6d48b2a2bfd95fe93b65avboxsync * Release a write lock.
9e293277b378073ce86910209a246b744b4caa2cvboxsync *
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * @param hLock The lock handle, can be NIL.
bdd15592ca3578b623ff588055a561f58b7e5586vboxsync */
bdd15592ca3578b623ff588055a561f58b7e5586vboxsyncDECLINLINE(void) RTVfsLockReleaseWrite(RTVFSLOCK hLock)
bdd15592ca3578b623ff588055a561f58b7e5586vboxsync{
9e293277b378073ce86910209a246b744b4caa2cvboxsync if (hLock != NIL_RTVFSLOCK)
7f5e9cb0292dcce87c0a6794c775c14fb9c2a1e7vboxsync RTVfsLockReleaseWriteSlow(hLock);
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync}
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync/** @} */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync
f350b7cf96f1e2f3b0cfd34cfe8726c754f43584vboxsync/**
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * The VFS operations.
f350b7cf96f1e2f3b0cfd34cfe8726c754f43584vboxsync */
f350b7cf96f1e2f3b0cfd34cfe8726c754f43584vboxsynctypedef struct RTVFSOPS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync{
f350b7cf96f1e2f3b0cfd34cfe8726c754f43584vboxsync /** The structure version (RTVFSOPS_VERSION). */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync uint32_t uVersion;
f350b7cf96f1e2f3b0cfd34cfe8726c754f43584vboxsync /** The virtual file system feature mask. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t fFeatures;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The name of the operations. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync const char *pszName;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Destructor.
f350b7cf96f1e2f3b0cfd34cfe8726c754f43584vboxsync *
551d9b8ee3568ad3e11b65ce6ef2867c36375f37vboxsync * @param pvThis The implementation specific data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync DECLCALLBACKMEMBER(void, pfnDestroy)(void *pvThis);
b8908d384db2324f04a2f68a13e67ea32ebf609avboxsync
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Opens the root directory.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * @returns IPRT status code.
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * @param pvThis The implementation specific data.
b603b2af577731f9f825ba3681cd5b728bb1d1d4vboxsync * @param phVfsDir Where to return the handle to the root directory.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnOpenRoot)(void *pvThis, PRTVFSDIR phVfsDir);
8e0c2ca3abd721979958f95b9af73b60665478c8vboxsync
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync /**
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * Checks whether a given range in the underlying medium
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * is in use by the virtual filesystem.
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param off Start offset to check.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param cb Number of bytes to check.
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * @param pfUsed Where to store whether the given range is in use.
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnIsRangeInUse)(void *pvThis, RTFOFF off, size_t cb,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync bool *pfUsed);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync /** @todo There will be more methods here to optimize opening and
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * querying. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#if 0
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Optional entry point for optimizing path traversal within the file system.
39592d8ff3243f6116c4e99be391bcf30a4ad187vboxsync *
39592d8ff3243f6116c4e99be391bcf30a4ad187vboxsync * @returns IPRT status code.
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * @param pvThis The implementation specific data.
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * @param pszPath The path to resolve.
39592d8ff3243f6116c4e99be391bcf30a4ad187vboxsync * @param poffPath The current path offset on input, what we've
6f6e182fde44ac8c4f95d8684e10fbbea937f26evboxsync * traversed to on successful return.
6f6e182fde44ac8c4f95d8684e10fbbea937f26evboxsync * @param phVfs??? Return handle to what we've traversed.
20fc4a350a4a8e56ffaac6cf57dcd677a7ac36c5vboxsync * @param p??? Return other stuff...
20fc4a350a4a8e56ffaac6cf57dcd677a7ac36c5vboxsync */
6f6e182fde44ac8c4f95d8684e10fbbea937f26evboxsync DECLCALLBACKMEMBER(int, pfnTraverse)(void *pvThis, const char *pszPath, size_t *poffPath, PRTVFS??? phVfs?, ???* p???);
678e65f634668c9f9a0f45094277cd6b375484cavboxsync#endif
678e65f634668c9f9a0f45094277cd6b375484cavboxsync
678e65f634668c9f9a0f45094277cd6b375484cavboxsync /** Marks the end of the structure (RTVFSOPS_VERSION). */
678e65f634668c9f9a0f45094277cd6b375484cavboxsync uintptr_t uEndMarker;
678e65f634668c9f9a0f45094277cd6b375484cavboxsync} RTVFSOPS;
678e65f634668c9f9a0f45094277cd6b375484cavboxsync/** Pointer to constant VFS operations. */
678e65f634668c9f9a0f45094277cd6b375484cavboxsynctypedef RTVFSOPS const *PCRTVFSOPS;
678e65f634668c9f9a0f45094277cd6b375484cavboxsync
678e65f634668c9f9a0f45094277cd6b375484cavboxsync/** The RTVFSOPS structure version. */
678e65f634668c9f9a0f45094277cd6b375484cavboxsync#define RTVFSOPS_VERSION RT_MAKE_U32_FROM_U8(0xff,0x0f,1,0)
678e65f634668c9f9a0f45094277cd6b375484cavboxsync
678e65f634668c9f9a0f45094277cd6b375484cavboxsync/** @name RTVFSOPS::fFeatures
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * @{ */
678e65f634668c9f9a0f45094277cd6b375484cavboxsync/** The VFS supports attaching other systems. */
678e65f634668c9f9a0f45094277cd6b375484cavboxsync#define RTVFSOPS_FEAT_ATTACH RT_BIT_32(0)
d84e3f7154abd56986d6ce98d9156769c7ae6587vboxsync/** @} */
678e65f634668c9f9a0f45094277cd6b375484cavboxsync
678e65f634668c9f9a0f45094277cd6b375484cavboxsync/**
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * Creates a new VFS handle.
678e65f634668c9f9a0f45094277cd6b375484cavboxsync *
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * @returns IPRT status code
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVfs Ops The VFS operations.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param cbInstance The size of the instance data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param hVfs The VFS handle to associate this VFS with.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * NIL_VFS is ok.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param hLock Handle to a custom lock to be used with the new
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * object. The reference is consumed. NIL and
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * special lock handles are fine.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param phVfs Where to return the new handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param ppvInstance Where to return the pointer to the instance data
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * (size is @a cbInstance).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
ad27e1d5e48ca41245120c331cc88b50464813cevboxsyncRTDECL(int) RTVfsNew(PCRTVFSOPS pVfsOps, size_t cbInstance, RTVFS hVfs, RTVFSLOCK hLock,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync PRTVFS phVfs, void **ppvInstance);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * The basis for all virtual file system objects except RTVFS.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef struct RTVFSOBJOPS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync{
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The structure version (RTVFSOBJOPS_VERSION). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t uVersion;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The object type for type introspection. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTVFSOBJTYPE enmType;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The name of the operations. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync const char *pszName;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Close the object.
c77e7bff89c7639353778366984d51ff165ea0e3vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific file data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnClose)(void *pvThis);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Get information about the file.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code. See RTVfsObjQueryInfo.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific file data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pObjInfo Where to return the object info on success.
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync * @param enmAddAttr Which set of additional attributes to request.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @sa RTVfsObjQueryInfo, RTFileQueryInfo, RTPathQueryInfo
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnQueryInfo)(void *pvThis, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Marks the end of the structure (RTVFSOBJOPS_VERSION). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uintptr_t uEndMarker;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync} RTVFSOBJOPS;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Pointer to constant VFS object operations. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef RTVFSOBJOPS const *PCRTVFSOBJOPS;
678e65f634668c9f9a0f45094277cd6b375484cavboxsync
678e65f634668c9f9a0f45094277cd6b375484cavboxsync/** The RTVFSOBJOPS structure version. */
678e65f634668c9f9a0f45094277cd6b375484cavboxsync#define RTVFSOBJOPS_VERSION RT_MAKE_U32_FROM_U8(0xff,0x1f,1,0)
678e65f634668c9f9a0f45094277cd6b375484cavboxsync
678e65f634668c9f9a0f45094277cd6b375484cavboxsync
678e65f634668c9f9a0f45094277cd6b375484cavboxsync/**
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * Creates a new VFS base object handle.
678e65f634668c9f9a0f45094277cd6b375484cavboxsync *
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * @returns IPRT status code
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * @param pObjOps The base object operations.
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * @param cbInstance The size of the instance data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param hVfs The VFS handle to associate this base object
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * with. NIL_VFS is ok.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param hLock Handle to a custom lock to be used with the new
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * object. The reference is consumed. NIL and
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * special lock handles are fine.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param phVfsFss Where to return the new handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param ppvInstance Where to return the pointer to the instance data
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * (size is @a cbInstance).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncRTDECL(int) RTVfsNewBaseObj(PCRTVFSOBJOPS pObjOps, size_t cbInstance, RTVFS hVfs, RTVFSLOCK hLock,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync PRTVFSOBJ phVfsObj, void **ppvInstance);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Additional operations for setting object attributes.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef struct RTVFSOBJSETOPS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync{
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The structure version (RTVFSOBJSETOPS_VERSION). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t uVersion;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The offset to the RTVFSOBJOPS structure. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync int32_t offObjOps;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Set the unix style owner and group.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific file data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fMode The new mode bits.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fMask The mask indicating which bits we are
f5eadb22976c1f9813300e4042b8255cfaef7e19vboxsync * changing.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @sa RTFileSetMode
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync */
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync DECLCALLBACKMEMBER(int, pfnSetMode)(void *pvThis, RTFMODE fMode, RTFMODE fMask);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Set the timestamps associated with the object.
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific file data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pAccessTime Pointer to the new access time. NULL if not
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * to be changed.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pModificationTime Pointer to the new modifcation time. NULL if
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * not to be changed.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pChangeTime Pointer to the new change time. NULL if not
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * to be changed.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pBirthTime Pointer to the new time of birth. NULL if
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * not to be changed.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @remarks See RTFileSetTimes for restrictions and behavior imposed by the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * host OS or underlying VFS provider.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @sa RTFileSetTimes
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnSetTimes)(void *pvThis, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Set the unix style owner and group.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific file data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param uid The user ID of the new owner. NIL_RTUID if
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * unchanged.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param gid The group ID of the new owner group. NIL_RTGID if
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * unchanged.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @sa RTFileSetOwner
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnSetOwner)(void *pvThis, RTUID uid, RTGID gid);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Marks the end of the structure (RTVFSOBJSETOPS_VERSION). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uintptr_t uEndMarker;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync} RTVFSOBJSETOPS;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Pointer to const object attribute setter operations. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef RTVFSOBJSETOPS const *PCRTVFSOBJSETOPS;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** The RTVFSOBJSETOPS structure version. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define RTVFSOBJSETOPS_VERSION RT_MAKE_U32_FROM_U8(0xff,0x2f,1,0)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * The filesystem stream operations.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @extends RTVFSOBJOPS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef struct RTVFSFSSTREAMOPS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync{
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The basic object operation. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTVFSOBJOPS Obj;
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync /** The structure version (RTVFSFSSTREAMOPS_VERSION). */
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync uint32_t uVersion;
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync /** Reserved field, MBZ. */
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync uint32_t fReserved;
678e65f634668c9f9a0f45094277cd6b375484cavboxsync
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync /**
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync * Gets the next object in the stream.
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync *
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync * @returns IPRT status code.
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync * @retval VINF_SUCCESS if a new object was retrieved.
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync * @retval VERR_EOF when there are no more objects.
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync * @param pvThis The implementation specific directory data.
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync * @param ppszName Where to return the object name. Must be freed by
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync * calling RTStrFree.
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync * @param penmType Where to return the object type.
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync * @param hVfsObj Where to return the object handle (referenced).
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync * This must be cast to the desired type before use.
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync * @sa RTVfsFsStrmNext
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync */
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync DECLCALLBACKMEMBER(int, pfnNext)(void *pvThis, char **ppszName, RTVFSOBJTYPE *penmType, PRTVFSOBJ phVfsObj);
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync /** Marks the end of the structure (RTVFSFSSTREAMOPS_VERSION). */
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync uintptr_t uEndMarker;
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync} RTVFSFSSTREAMOPS;
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync/** Pointer to const object attribute setter operations. */
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsynctypedef RTVFSFSSTREAMOPS const *PCRTVFSFSSTREAMOPS;
30f07af559efcbd967e801903746fc21f81ee533vboxsync
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync/** The RTVFSFSSTREAMOPS structure version. */
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync#define RTVFSFSSTREAMOPS_VERSION RT_MAKE_U32_FROM_U8(0xff,0x3f,1,0)
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync/**
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * Creates a new VFS filesystem stream handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync * @returns IPRT status code
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync * @param pFsStreamOps The filesystem stream operations.
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsync * @param cbInstance The size of the instance data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param hVfs The VFS handle to associate this filesystem
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * stream with. NIL_VFS is ok.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param hLock Handle to a custom lock to be used with the new
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * object. The reference is consumed. NIL and
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * special lock handles are fine.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param phVfsFss Where to return the new handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param ppvInstance Where to return the pointer to the instance data
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * (size is @a cbInstance).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncRTDECL(int) RTVfsNewFsStream(PCRTVFSFSSTREAMOPS pFsStreamOps, size_t cbInstance, RTVFS hVfs, RTVFSLOCK hLock,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync PRTVFSFSSTREAM phVfsFss, void **ppvInstance);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * The directory operations.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @extends RTVFSOBJOPS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @extends RTVFSOBJSETOPS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef struct RTVFSDIROPS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync{
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The basic object operation. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTVFSOBJOPS Obj;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The structure version (RTVFSDIROPS_VERSION). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t uVersion;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Reserved field, MBZ. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t fReserved;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The object setter operations. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTVFSOBJSETOPS ObjSet;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Opens a directory entry for traversal purposes.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Method which sole purpose is helping the path traversal. Only one of
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * the three output variables will be set, the others will left untouched
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * (caller sets them to NIL).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @retval VERR_PATH_NOT_FOUND if @a pszEntry was not found.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific directory data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pszEntry The name of the directory entry to remove.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param phVfsDir If not NULL and it is a directory, open it and
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * return the handle here.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param phVfsSymlink If not NULL and it is a symbolic link, open it
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * and return the handle here.
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * @param phVfsMounted If not NULL and it is a mounted VFS directory,
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * reference it and return the handle here.
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * @todo Should com dir, symlinks and mount points using some common
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * ancestor "class".
678e65f634668c9f9a0f45094277cd6b375484cavboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnTraversalOpen)(void *pvThis, const char *pszEntry, PRTVFSDIR phVfsDir,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync PRTVFSSYMLINK phVfsSymlink, PRTVFS phVfsMounted);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Open or create a file.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific directory data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pszFilename The name of the immediate file to open or create.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fOpen The open flags (RTFILE_O_XXX).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param phVfsFile Where to return the thandle to the opened file.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @sa RTFileOpen.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnOpenFile)(void *pvThis, const char *pszFilename, uint32_t fOpen, PRTVFSFILE phVfsFile);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /**
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * Open an existing subdirectory.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync *
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @returns IPRT status code.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pvThis The implementation specific directory data.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pszSubDir The name of the immediate subdirectory to open.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param phVfsDir Where to return the handle to the opened directory.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @sa RTDirOpen.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync DECLCALLBACKMEMBER(int, pfnOpenDir)(void *pvThis, const char *pszSubDir, PRTVFSDIR phVfsDir);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /**
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * Creates a new subdirectory.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync *
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @returns IPRT status code.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pvThis The implementation specific directory data.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pszSubDir The name of the immediate subdirectory to create.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param fMode The mode mask of the new directory.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param phVfsDir Where to optionally return the handle to the newly
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * create directory.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @sa RTDirCreate.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync DECLCALLBACKMEMBER(int, pfnCreateDir)(void *pvThis, const char *pszSubDir, RTFMODE fMode, PRTVFSDIR phVfsDir);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /**
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * Opens an existing symbolic link.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync *
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @returns IPRT status code.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pvThis The implementation specific directory data.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pszSymlink The name of the immediate symbolic link to open.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param phVfsSymlink Where to optionally return the handle to the
527a205091eb7c018da75b43ebd1588eb0ef2e38vboxsync * newly create symbolic link.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @sa RTSymlinkCreate.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync DECLCALLBACKMEMBER(int, pfnOpenSymlink)(void *pvThis, const char *pszSymlink, PRTVFSSYMLINK phVfsSymlink);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /**
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * Creates a new symbolic link.
30f07af559efcbd967e801903746fc21f81ee533vboxsync *
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @returns IPRT status code.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pvThis The implementation specific directory data.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pszSymlink The name of the immediate symbolic link to create.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pszTarget The symbolic link target.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param enmType The symbolic link type.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param phVfsSymlink Where to optionally return the handle to the
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * newly create symbolic link.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @sa RTSymlinkCreate.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync DECLCALLBACKMEMBER(int, pfnCreateSymlink)(void *pvThis, const char *pszSymlink, const char *pszTarget,
2a076b740155a538ded6407c44aae5eff986a42fvboxsync RTSYMLINKTYPE enmType, PRTVFSSYMLINK phVfsSymlink);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /**
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * Removes a directory entry.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync *
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @returns IPRT status code.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pvThis The implementation specific directory data.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pszEntry The name of the directory entry to remove.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param fType If non-zero, this restricts the type of the entry to
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * the object type indicated by the mask
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * (RTFS_TYPE_XXX).
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @sa RTFileRemove, RTDirRemove, RTSymlinkRemove.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync DECLCALLBACKMEMBER(int, pfnUnlinkEntry)(void *pvThis, const char *pszEntry, RTFMODE fType, PRTVFSDIR phVfsDir);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /**
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * Rewind the directory stream so that the next read returns the first
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * entry.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync *
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @returns IPRT status code.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pvThis The implementation specific directory data.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync DECLCALLBACKMEMBER(int, pfnRewindDir)(void *pvThis);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /**
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * Rewind the directory stream so that the next read returns the first
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * entry.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync *
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @returns IPRT status code.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pvThis The implementation specific directory data.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pDirEntry Output buffer.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pcbDirEntry Complicated, see RTDirReadEx.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param enmAddAttr Which set of additional attributes to request.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @sa RTDirReadEx
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync DECLCALLBACKMEMBER(int, pfnReadDir)(void *pvThis, PRTDIRENTRYEX pDirEntry, size_t *pcbDirEntry, RTFSOBJATTRADD enmAddAttr);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /** Marks the end of the structure (RTVFSDIROPS_VERSION). */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync uintptr_t uEndMarker;
2a076b740155a538ded6407c44aae5eff986a42fvboxsync} RTVFSDIROPS;
2a076b740155a538ded6407c44aae5eff986a42fvboxsync/** Pointer to const directory operations. */
2a076b740155a538ded6407c44aae5eff986a42fvboxsynctypedef RTVFSDIROPS const *PCRTVFSDIROPS;
2a076b740155a538ded6407c44aae5eff986a42fvboxsync/** The RTVFSDIROPS structure version. */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync#define RTVFSDIROPS_VERSION RT_MAKE_U32_FROM_U8(0xff,0x4f,1,0)
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync/**
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * The symbolic link operations.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync *
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @extends RTVFSOBJOPS
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @extends RTVFSOBJSETOPS
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsynctypedef struct RTVFSSYMLINKOPS
2a076b740155a538ded6407c44aae5eff986a42fvboxsync{
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /** The basic object operation. */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync RTVFSOBJOPS Obj;
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /** The structure version (RTVFSSYMLINKOPS_VERSION). */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync uint32_t uVersion;
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /** Reserved field, MBZ. */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync uint32_t fReserved;
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /** The object setter operations. */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync RTVFSOBJSETOPS ObjSet;
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /**
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * Read the symbolic link target.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync *
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @returns IPRT status code.
30f07af559efcbd967e801903746fc21f81ee533vboxsync * @param pvThis The implementation specific symbolic link data.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pszTarget The target buffer.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param cbTarget The size of the target buffer.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @sa RTSymlinkRead
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync DECLCALLBACKMEMBER(int, pfnRead)(void *pvThis, char *pszTarget, size_t cbTarget);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /** Marks the end of the structure (RTVFSSYMLINKOPS_VERSION). */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync uintptr_t uEndMarker;
2a076b740155a538ded6407c44aae5eff986a42fvboxsync} RTVFSSYMLINKOPS;
2a076b740155a538ded6407c44aae5eff986a42fvboxsync/** Pointer to const symbolic link operations. */
2a076b740155a538ded6407c44aae5eff986a42fvboxsynctypedef RTVFSSYMLINKOPS const *PCRTVFSSYMLINKOPS;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** The RTVFSSYMLINKOPS structure version. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define RTVFSSYMLINKOPS_VERSION RT_MAKE_U32_FROM_U8(0xff,0x5f,1,0)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Creates a new VFS symlink handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pSymlinkOps The symlink operations.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param cbInstance The size of the instance data.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param hVfs The VFS handle to associate this symlink object
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * with. NIL_VFS is ok.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param hLock Handle to a custom lock to be used with the new
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * object. The reference is consumed. NIL and
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * special lock handles are fine.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param phVfsSym Where to return the new handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param ppvInstance Where to return the pointer to the instance data
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * (size is @a cbInstance).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsyncRTDECL(int) RTVfsNewSymlink(PCRTVFSSYMLINKOPS pSymlinkOps, size_t cbInstance, RTVFS hVfs, RTVFSLOCK hLock,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync PRTVFSSYMLINK phVfsSym, void **ppvInstance);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync/**
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * The basis for all I/O objects (files, pipes, sockets, devices, ++).
2a076b740155a538ded6407c44aae5eff986a42fvboxsync *
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @extends RTVFSOBJOPS
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsynctypedef struct RTVFSIOSTREAMOPS
2a076b740155a538ded6407c44aae5eff986a42fvboxsync{
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The basic object operation. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTVFSOBJOPS Obj;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The structure version (RTVFSIOSTREAMOPS_VERSION). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t uVersion;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Feature field. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t fFeatures;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Reads from the file/stream.
3c36c06229c460f138561516170abc867297f256vboxsync *
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @returns IPRT status code. See RTVfsIoStrmRead.
3c36c06229c460f138561516170abc867297f256vboxsync * @param pvThis The implementation specific file data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param off Where to read at, -1 for the current position.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pSgBuf Gather buffer describing the bytes that are to be
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * written.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fBlocking If @c true, the call is blocking, if @c false it
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * should not block.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pcbRead Where return the number of bytes actually read.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * This is set it 0 by the caller. If NULL, try read
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * all and fail if incomplete.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @sa RTVfsIoStrmRead, RTVfsIoStrmSgRead, RTVfsFileRead,
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * RTVfsFileReadAt, RTFileRead, RTFileReadAt.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnRead)(void *pvThis, RTFOFF off, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /**
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * Writes to the file/stream.
def2a1cab3e799960903803a9f7cafe1fba684c0vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pvThis The implementation specific file data.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param off Where to start wrinting, -1 for the current
def2a1cab3e799960903803a9f7cafe1fba684c0vboxsync * position.
30f07af559efcbd967e801903746fc21f81ee533vboxsync * @param pSgBuf Gather buffers describing the bytes that are to be
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * written.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @param fBlocking If @c true, the call is blocking, if @c false it
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * should not block.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pcbWritten Where to return the number of bytes actually
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * written. This is set it 0 by the caller. If
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * NULL, try write it all and fail if incomplete.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @sa RTFileWrite, RTFileWriteAt.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync DECLCALLBACKMEMBER(int, pfnWrite)(void *pvThis, RTFOFF off, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Flushes any pending data writes to the stream.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @returns IPRT status code.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific file data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @sa RTFileFlush.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnFlush)(void *pvThis);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Poll for events.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific file data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fEvents The events to poll for (RTPOLL_EVT_XXX).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param cMillies How long to wait for event to eventuate.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fIntr Whether the wait is interruptible and can return
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * VERR_INTERRUPTED (@c true) or if this condition
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * should be hidden from the caller (@c false).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pfRetEvents Where to return the event mask.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @sa RTPollSetAdd, RTPoll, RTPollNoResume.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnPollOne)(void *pvThis, uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t *pfRetEvents);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Tells the current file/stream position.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific file data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param poffActual Where to return the actual offset.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @sa RTFileTell
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnTell)(void *pvThis, PRTFOFF poffActual);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Skips @a cb ahead in the stream.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific file data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param cb The number bytes to skip.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @remarks This is optional and can be NULL.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnSkip)(void *pvThis, RTFOFF cb);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Fills the stream with @a cb zeros.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific file data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param cb The number of zero bytes to insert.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @remarks This is optional and can be NULL.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnZeroFill)(void *pvThis, RTFOFF cb);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /** Marks the end of the structure (RTVFSIOSTREAMOPS_VERSION). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uintptr_t uEndMarker;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync} RTVFSIOSTREAMOPS;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Pointer to const I/O stream operations. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef RTVFSIOSTREAMOPS const *PCRTVFSIOSTREAMOPS;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** The RTVFSIOSTREAMOPS structure version. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define RTVFSIOSTREAMOPS_VERSION RT_MAKE_U32_FROM_U8(0xff,0x6f,1,0)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @name RTVFSIOSTREAMOPS::fFeatures
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @{ */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** No scatter gather lists, thank you. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define RTVFSIOSTREAMOPS_FEAT_NO_SG RT_BIT_32(0)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Mask of the valid I/O stream feature flags. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define RTVFSIOSTREAMOPS_FEAT_VALID_MASK UINT32_C(0x00000001)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @} */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Creates a new VFS I/O stream handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pIoStreamOps The I/O stream operations.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param cbInstance The size of the instance data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fOpen The open flags. The minimum is the access mask.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param hVfs The VFS handle to associate this I/O stream
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * with. NIL_VFS is ok.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param hLock Handle to a custom lock to be used with the new
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * object. The reference is consumed. NIL and
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * special lock handles are fine.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @param phVfsIos Where to return the new handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param ppvInstance Where to return the pointer to the instance data
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * (size is @a cbInstance).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncRTDECL(int) RTVfsNewIoStream(PCRTVFSIOSTREAMOPS pIoStreamOps, size_t cbInstance, uint32_t fOpen, RTVFS hVfs, RTVFSLOCK hLock,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync PRTVFSIOSTREAM phVfsIos, void **ppvInstance);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Gets the private data of an I/O stream.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @returns Pointer to the private data. NULL if the handle is invalid in some
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * way.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param hVfsIos The I/O stream handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pIoStreamOps The I/O stream operations. This servers as a
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * sort of password.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncRTDECL(void *) RTVfsIoStreamToPrivate(RTVFSIOSTREAM hVfsIos, PCRTVFSIOSTREAMOPS pIoStreamOps);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * The file operations.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @extends RTVFSIOSTREAMOPS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @extends RTVFSOBJSETOPS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef struct RTVFSFILEOPS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync{
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The I/O stream and basis object operations. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTVFSIOSTREAMOPS Stream;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The structure version (RTVFSFILEOPS_VERSION). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t uVersion;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Reserved field, MBZ. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t fReserved;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The object setter operations. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTVFSOBJSETOPS ObjSet;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Changes the current file position.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific file data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param offSeek The offset to seek.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param uMethod The seek method, i.e. what the seek is relative to.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param poffActual Where to return the actual offset.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @sa RTFileSeek
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync */
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync DECLCALLBACKMEMBER(int, pfnSeek)(void *pvThis, RTFOFF offSeek, unsigned uMethod, PRTFOFF poffActual);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Get the current file/stream size.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * @param pvThis The implementation specific file data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pcbFile Where to store the current file size.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @sa RTFileGetSize
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync DECLCALLBACKMEMBER(int, pfnQuerySize)(void *pvThis, uint64_t *pcbFile);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** @todo There will be more methods here. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Marks the end of the structure (RTVFSFILEOPS_VERSION). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uintptr_t uEndMarker;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync} RTVFSFILEOPS;
2a076b740155a538ded6407c44aae5eff986a42fvboxsync/** Pointer to const file operations. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef RTVFSFILEOPS const *PCRTVFSFILEOPS;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** The RTVFSFILEOPS structure version. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define RTVFSFILEOPS_VERSION RT_MAKE_U32_FROM_U8(0xff,0x7f,1,0)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Creates a new VFS file handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pFileOps The file operations.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param cbInstance The size of the instance data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fOpen The open flags. The minimum is the access mask.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param hVfs The VFS handle to associate this file with.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * NIL_VFS is ok.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param hLock Handle to a custom lock to be used with the new
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * object. The reference is consumed. NIL and
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * special lock handles are fine.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param phVfsFile Where to return the new handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param ppvInstance Where to return the pointer to the instance data
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * (size is @a cbInstance).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncRTDECL(int) RTVfsNewFile(PCRTVFSFILEOPS pFileOps, size_t cbInstance, uint32_t fOpen, RTVFS hVfs, RTVFSLOCK hLock,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync PRTVFSFILE phVfsFile, void **ppvInstance);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @defgroup grp_rt_vfs_ll_util VFS Utility APIs
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync * @{ */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
678e65f634668c9f9a0f45094277cd6b375484cavboxsync/**
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * Parsed path.
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef struct RTVFSPARSEDPATH
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync{
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The length of the path in szCopy. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint16_t cch;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The number of path components. */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync uint16_t cComponents;
d5e31f0ab4e7c36082f8db5157c2acb6b36ecd97vboxsync /** Set if the path ends with slash, indicating that it's a directory
d5e31f0ab4e7c36082f8db5157c2acb6b36ecd97vboxsync * reference and not a file reference. The slash has been removed from
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * the copy. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync bool fDirSlash;
678e65f634668c9f9a0f45094277cd6b375484cavboxsync /** The offset where each path component starts, i.e. the char after the
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * slash. The array has cComponents + 1 entries, where the final one is
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync * cch + 1 so that one can always terminate the current component by
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * szPath[aoffComponent[i] - 1] = '\0'. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint16_t aoffComponents[RTPATH_MAX / 2 + 1];
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** A normalized copy of the path.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Reserve some extra space so we can be more relaxed about overflow
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * checks and terminator paddings, especially when recursing. */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync char szPath[RTPATH_MAX];
2a076b740155a538ded6407c44aae5eff986a42fvboxsync} RTVFSPARSEDPATH;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Pointer to a parsed path. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef RTVFSPARSEDPATH *PRTVFSPARSEDPATH;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
c77e7bff89c7639353778366984d51ff165ea0e3vboxsync/** The max accepted path length.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This must be a few chars shorter than RTVFSPARSEDPATH::szPath because we
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * use two terminators and wish be a little bit lazy with checking. */
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync#define RTVFSPARSEDPATH_MAX (RTPATH_MAX - 4)
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Appends @a pszPath (relative) to the already parsed path @a pPath.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @retval VINF_SUCCESS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @retval VERR_FILENAME_TOO_LONG
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @retval VERR_INTERNAL_ERROR_4
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pPath The parsed path to append @a pszPath onto.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This is both input and output.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pszPath The path to append. This must be relative.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param piRestartComp The component to restart parsing at. This is
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * input/output. The input does not have to be
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * within the valid range. Optional.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsyncRTDECL(int) RTVfsParsePathAppend(PRTVFSPARSEDPATH pPath, const char *pszPath, uint16_t *piRestartComp);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync/**
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * Parses a path.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync *
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @retval VINF_SUCCESS
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @retval VERR_FILENAME_TOO_LONG
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pPath Where to store the parsed path.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pszPath The path to parse. Absolute or relative to @a
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * pszCwd.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pszCwd The current working directory. Must be
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * absolute.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncRTDECL(int) RTVfsParsePath(PRTVFSPARSEDPATH pPath, const char *pszPath, const char *pszCwd);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Same as RTVfsParsePath except that it allocates a temporary buffer.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * @retval VINF_SUCCESS
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * @retval VERR_NO_TMP_MEMORY
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @retval VERR_FILENAME_TOO_LONG
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pszPath The path to parse. Absolute or relative to @a
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * pszCwd.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pszCwd The current working directory. Must be
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * absolute.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param ppPath Where to store the pointer to the allocated
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * buffer containing the parsed path. This must
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * be freed by calling RTVfsParsePathFree. NULL
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * will be stored on failured.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsyncRTDECL(int) RTVfsParsePathA(const char *pszPath, const char *pszCwd, PRTVFSPARSEDPATH *ppPath);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
2a076b740155a538ded6407c44aae5eff986a42fvboxsync/**
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * Frees a buffer returned by RTVfsParsePathA.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync *
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pPath The parsed path buffer to free. NULL is fine.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsyncRTDECL(void) RTVfsParsePathFree(PRTVFSPARSEDPATH pPath);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Dummy implementation of RTVFSIOSTREAMOPS::pfnPollOne.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This handles the case where there is no chance any events my be raised and
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * all that is required is to wait according to the parameters.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @returns IPRT status code.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pvThis The implementation specific file data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fEvents The events to poll for (RTPOLL_EVT_XXX).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param cMillies How long to wait for event to eventuate.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fIntr Whether the wait is interruptible and can return
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * VERR_INTERRUPTED (@c true) or if this condition
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * should be hidden from the caller (@c false).
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @param pfRetEvents Where to return the event mask.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @sa RTVFSIOSTREAMOPS::pfnPollOne, RTPollSetAdd, RTPoll, RTPollNoResume.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync */
2a076b740155a538ded6407c44aae5eff986a42fvboxsyncRTDECL(int) RTVfsUtilDummyPollOne(uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr, uint32_t *pfRetEvents);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @} */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @defgroup grp_rt_vfs_lowlevel_chain VFS Chains
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @ref grp_rt_vfs_chain
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @{
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/**
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * Chain element input actions.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsynctypedef enum RTVFSCHAINACTION
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync{
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync /** Invalid action. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync RTVFSCHAINACTION_INVALID = 0,
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync /** No action (start of the chain). */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync RTVFSCHAINACTION_NONE,
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync /** Passive filtering (expressed by pipe symbol). */
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync RTVFSCHAINACTION_PASSIVE,
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync /** Push filtering (expressed by redirection-out symbol). */
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync RTVFSCHAINACTION_PUSH,
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync /** The end of the valid actions. */
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync RTVFSCHAINACTION_END,
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync /** Make sure it's a 32-bit type. */
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync RTVFSCHAINACTION_32BIT_HACK = 0x7fffffff
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync} RTVFSCHAINACTION;
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync/**
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * VFS chain element specification.
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync */
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsynctypedef struct RTVFSCHAINELEMSPEC
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync{
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync /** The provider name. */
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync char *pszProvider;
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync /** The input type. */
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync RTVFSOBJTYPE enmTypeIn;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /** The output type. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync RTVFSOBJTYPE enmTypeOut;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /** The action to take (or not). */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync RTVFSCHAINACTION enmAction;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /** The number of arguments. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync uint32_t cArgs;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /** Arguments. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync char **papszArgs;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync} RTVFSCHAINELEMSPEC;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** Pointer to a chain element specification. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsynctypedef RTVFSCHAINELEMSPEC *PRTVFSCHAINELEMSPEC;
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync/** Pointer to a const chain element specification. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsynctypedef RTVFSCHAINELEMSPEC const *PCRTVFSCHAINELEMSPEC;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/**
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * Parsed VFS chain specification.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsynctypedef struct RTVFSCHAINSPEC
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync{
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /** The action element, UINT32_MAX if none.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Currently we only support one action element (RTVFSCHAINACTION_PASSIVE
f7f5cd7b1e530eb5636da51c974b48ae0c1775b3vboxsync * is not considered). */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync uint32_t iActionElement;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /** The number of elements. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync uint32_t cElements;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /** The elements. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync PRTVFSCHAINELEMSPEC paElements;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync} RTVFSCHAINSPEC;
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync/** Pointer to a parsed VFS chain specification. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsynctypedef RTVFSCHAINSPEC *PRTVFSCHAINSPEC;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** Pointer to a const, parsed VFS chain specification. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsynctypedef RTVFSCHAINSPEC const *PCRTVFSCHAINSPEC;
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/**
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * A chain element provider registration record.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsynctypedef struct RTVFSCHAINELEMENTREG
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync{
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync /** The version (RTVFSCHAINELEMENTREG_VERSION). */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync uint32_t uVersion;
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync /** Reserved, MBZ. */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync uint32_t fReserved;
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync /** The provider name (unique). */
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync const char *pszName;
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync /** For chaining the providers. */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync RTLISTNODE ListEntry;
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync /**
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * Create a VFS from the given chain element specficiation.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync *
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * @returns IPRT status code.
f7f5cd7b1e530eb5636da51c974b48ae0c1775b3vboxsync * @param pSpec The chain element specification.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * @param phVfs Where to returned the VFS handle.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync DECLCALLBACKMEMBER(int, pfnOpenVfs)( PCRTVFSCHAINELEMSPEC pSpec, PRTVFS phVfs);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /**
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Open a directory from the given chain element specficiation.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync *
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @returns IPRT status code.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param pSpec The chain element specification.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param phVfsDir Where to returned the directory handle.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync DECLCALLBACKMEMBER(int, pfnOpenDir)( PCRTVFSCHAINELEMSPEC pSpec, PRTVFSDIR phVfsDir);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /**
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Open a file from the given chain element specficiation.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync *
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @returns IPRT status code.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param pSpec The chain element specification.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param fOpen The open flag. Can be zero and the
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * specification may modify it.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param phVfsFile Where to returned the file handle.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync DECLCALLBACKMEMBER(int, pfnOpenFile)( PCRTVFSCHAINELEMSPEC pSpec, uint32_t fOpen, PRTVFSFILE phVfsFile);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /**
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Open a symlink from the given chain element specficiation.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync *
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @returns IPRT status code.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param pSpec The chain element specification.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param phVfsSym Where to returned the symlink handle.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync DECLCALLBACKMEMBER(int, pfnOpenSymlink)( PCRTVFSCHAINELEMSPEC pSpec, PRTVFSSYMLINK phVfsSym);
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /**
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Open a I/O stream from the given chain element specficiation.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync *
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * @returns IPRT status code.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * @param pSpec The chain element specification.
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * @param fOpen The open flag. Can be zero and the
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * specification may modify it.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param phVfsIos Where to returned the I/O stream handle.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync */
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync DECLCALLBACKMEMBER(int, pfnOpenIoStream)(PCRTVFSCHAINELEMSPEC pSpec, uint32_t fOpen, PRTVFSIOSTREAM phVfsIos);
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /**
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Open a filesystem stream from the given chain element specficiation.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync *
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * @returns IPRT status code.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param pSpec The chain element specification.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * @param phVfsFss Where to returned the filesystem stream handle.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync DECLCALLBACKMEMBER(int, pfnOpenFsStream)(PCRTVFSCHAINELEMSPEC pSpec, PRTVFSFSSTREAM phVfsFss);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /** End marker (RTVFSCHAINELEMENTREG_VERSION). */
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync uintptr_t uEndMarker;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync} RTVFSCHAINELEMENTREG;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** Pointer to a VFS chain element registration record. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsynctypedef RTVFSCHAINELEMENTREG *PRTVFSCHAINELEMENTREG;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** Pointer to a const VFS chain element registration record. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsynctypedef RTVFSCHAINELEMENTREG const *PCRTVFSCHAINELEMENTREG;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync/** The VFS chain element registration record version number. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#define RTVFSCHAINELEMENTREG_VERSION RT_MAKE_U32_FROM_U8(0xff, 0x7f, 1, 0)
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/**
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Parses the specification.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync *
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @returns IPRT status code.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param pszSpec The specification string to parse.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param fFlags Flags, see RTVFSCHAIN_PF_XXX.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param enmLeadingAction The only allowed leading action type.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param enmTrailingAction The only allowed trailing action type.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param ppSpec Where to return the pointer to the parsed
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * specification. This must be freed by calling
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * RTVfsChainSpecFree. Will always be set (unless
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * invalid parameters.)
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * @param ppszError On failure, this will point at the error
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * location in @a pszSpec. Optional.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsyncRTDECL(int) RTVfsChainSpecParse(const char *pszSpec, uint32_t fFlags, RTVFSCHAINACTION enmLeadingAction,
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync RTVFSCHAINACTION enmTrailingAction,
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync PRTVFSCHAINSPEC *ppSpec, const char **ppszError);
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** @name RTVfsChainSpecParse
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * @{ */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** No real action is permitted, i.e. only passive filtering (aka pipe). */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#define RTVFSCHAIN_PF_NO_REAL_ACTION RT_BIT_32(0)
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync/** The specified leading action is optional. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#define RTVFSCHAIN_PF_LEADING_ACTION_OPTIONAL RT_BIT_32(1)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** The specified trailing action is optional. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#define RTVFSCHAIN_PF_TRAILING_ACTION_OPTIONAL RT_BIT_32(2)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** Mask of valid flags. */
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync#define RTVFSCHAIN_PF_VALID_MASK UINT32_C(0x00000007)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** @} */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/**
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Frees a parsed chain specification.
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync *
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param pSpec What RTVfsChainSpecParse returned. NULL is
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * quietly ignored.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncRTDECL(void) RTVfsChainSpecFree(PRTVFSCHAINSPEC pSpec);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync/**
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Registers a chain element provider.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync *
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @returns IPRT status code
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param pRegRec The registration record.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param fFromCtor Indicates where we're called from.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncRTDECL(int) RTVfsChainElementRegisterProvider(PRTVFSCHAINELEMENTREG pRegRec, bool fFromCtor);
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync/**
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Deregisters a chain element provider.
79fe674227c3f2b82ab22a6b7d340283b610fb83vboxsync *
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * @returns IPRT status code
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param pRegRec The registration record.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * @param fFromDtor Indicates where we're called from.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsyncRTDECL(int) RTVfsChainElementDeregisterProvider(PRTVFSCHAINELEMENTREG pRegRec, bool fFromDtor);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** @def RTVFSCHAIN_AUTO_REGISTER_ELEMENT_PROVIDER
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Automatically registers a chain element provider using a global constructor
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * and destructor hack.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync *
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param pRegRec Pointer to the registration record.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param name Some unique variable name prefix.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#ifdef __cplusplus
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/**
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Class used for registering a VFS chain element provider.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncclass RTVfsChainElementAutoRegisterHack
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync{
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncprivate:
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /** The registration record, NULL if registration failed. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync PRTVFSCHAINELEMENTREG m_pRegRec;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncpublic:
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync RTVfsChainElementAutoRegisterHack(PRTVFSCHAINELEMENTREG a_pRegRec)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync : m_pRegRec(a_pRegRec)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync {
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync int rc = RTVfsChainElementRegisterProvider(m_pRegRec, true);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync if (RT_FAILURE(rc))
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync m_pRegRec = NULL;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync }
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync ~RTVfsChainElementAutoRegisterHack()
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync {
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync RTVfsChainElementDeregisterProvider(m_pRegRec, true);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync m_pRegRec = NULL;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync }
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync};
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync# define RTVFSCHAIN_AUTO_REGISTER_ELEMENT_PROVIDER(pRegRec, name) \
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync static RTVfsChainElementAutoRegisterHack name ## AutoRegistrationHack(pRegRec)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync#else
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync# define RTVFSCHAIN_AUTO_REGISTER_ELEMENT_PROVIDER(pRegRec, name) \
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync extern void *name ## AutoRegistrationHack = \
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync &Sorry_but_RTVFSCHAIN_AUTO_REGISTER_ELEMENT_PROVIDER_does_not_work_in_c_source_files
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#endif
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** @} */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** @} */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncRT_C_DECLS_END
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#endif /* !___iprt_vfslowlevel_h */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync