VirtualBox

Changeset 41549 in vbox for trunk/src/VBox/Runtime/include


Ignore:
Timestamp:
Jun 1, 2012 5:29:05 PM (13 years ago)
Author:
vboxsync
Message:

VFS/Filesystem: Convert the filesystem specific code to the VFS framework and make it work

Location:
trunk/src/VBox/Runtime/include/internal
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/include/internal/dvm.h

    r40137 r41549  
    122122
    123123    /**
     124     * Returns whether the given range is in use by the volume manager.
     125     *
     126     * @returns IPRT status code.
     127     * @param   hVolMgrFmt      The format specific volume manager handle.
     128     * @param   offStart        Start offset of the range.
     129     * @param   cbRange         Size of the range to check in bytes.
     130     * @param   pfUsed          Where to store whether the range is in use by the
     131     *                          volume manager.
     132     */
     133    DECLCALLBACKMEMBER(int, pfnQueryRangeUse)(RTDVMFMT hVolMgrFmt,
     134                                              uint64_t off, uint64_t cbRange,
     135                                              bool *pfUsed);
     136
     137    /**
    124138     * Gets the number of valid volumes in the map.
    125139     *
  • trunk/src/VBox/Runtime/include/internal/filesystem.h

    r40029 r41549  
    3131#include <iprt/err.h>
    3232#include <iprt/assert.h>
     33#include <iprt/vfslowlevel.h>
    3334#include "internal/magics.h"
    3435
    3536RT_C_DECLS_BEGIN
    3637
    37 /** A filesystem format handle. */
    38 typedef struct RTFILESYSTEMFMTINT   *RTFILESYSTEMFMT;
    39 /** Pointer to a filesystem format handle. */
    40 typedef RTFILESYSTEMFMT             *PRTFILESYSTEMFMT;
    41 /** NIL filesystem format handle. */
    42 #define NIL_RTFILESYSTEMFMT         ((RTFILESYSTEMFMT)~0)
     38/*******************************************************************************
     39*   Structures and Typedefs                                                    *
     40*******************************************************************************/
    4341
    44 /** A medium handle. */
    45 typedef struct RTFILESYSTEMMEDIUMINT *RTFILESYSTEMMEDIUM;
    46 /** Pointer to a medium handle. */
    47 typedef RTFILESYSTEMMEDIUM *PRTFILESYSTEMMEDIUM;
     42/** Filesystem format specific initialization structure. */
     43typedef DECLCALLBACK(int) FNRTFILESYSTEMINIT(void *pvThis, RTVFSFILE hVfsFile);
     44/** Pointer to a format specific initialization structure. */
     45typedef FNRTFILESYSTEMINIT *PFNRTFILESYSTEMINIT;
    4846
    49 /** Score to indicate that the backend can't handle the format at all */
    5047#define RTFILESYSTEM_MATCH_SCORE_UNSUPPORTED 0
    51 /** Score to indicate that a backend supports the format
    52  * but there can be other backends. */
    53 #define RTFILESYSTEM_MATCH_SCORE_SUPPORTED   (UINT32_MAX/2)
    54 /** Score to indicate a perfect match. */
    55 #define RTFILESYSTEM_MATCH_SCORE_PERFECT     UINT32_MAX
     48#define RTFILESYSTEM_MATCH_SCORE_SUPPORTED UINT32_MAX
    5649
    5750/**
    58  * Filesystem format operations.
     51 * Filesystem descriptor.
    5952 */
    60 typedef struct RTFILESYSTEMFMTOPS
     53typedef struct RTFILESYSTEMDESC
    6154{
    62     /** Name of the format. */
    63     const char *pcszFmt;
     55    /** Size of the filesystem specific state in bytes. */
     56    size_t        cbFs;
     57    /** Pointer to the VFS vtable. */
     58    RTVFSOPS      VfsOps;
    6459
    6560    /**
    66      * Probes the given disk for known structures.
     61     * Probes the underlying for a known filesystem.
    6762     *
    6863     * @returns IPRT status code.
    69      * @param   hMedium          Medium handle.
    70      * @param   puScore          Where to store the match score on success.
     64     * @param   hVfsFile    VFS file handle of the underlying medium.
     65     * @param   puScore     Where to store the match score on success.
    7166     */
    72     DECLCALLBACKMEMBER(int, pfnProbe)(RTFILESYSTEMMEDIUM hMedium, uint32_t *puScore);
     67    DECLCALLBACKMEMBER(int, pfnProbe) (RTVFSFILE hVfsFile, uint32_t *puScore);
    7368
    7469    /**
    75      * Opens the format to set up all structures.
     70     * Initializes the given filesystem state.
    7671     *
    7772     * @returns IPRT status code.
    78      * @param   hMedium          Medium handle.
    79      * @param   phFileSysFmt     Where to store the filesystem format instance on success.
     73     * @param   pvThis      Uninitialized filesystem state.
     74     * @param   hVfsFile    VFS file handle of the underlying medium.
    8075     */
    81     DECLCALLBACKMEMBER(int, pfnOpen)(RTFILESYSTEMMEDIUM hMedium, PRTFILESYSTEMFMT phFsFmt);
     76    DECLCALLBACKMEMBER(int, pfnInit) (void *pvThis, RTVFSFILE hVfsFile);
    8277
    83     /**
    84      * Closes the filesystem format.
    85      *
    86      * @returns IPRT status code.
    87      * @param   hFsFmt           The format specific filesystem handle.
    88      */
    89     DECLCALLBACKMEMBER(int, pfnClose)(RTFILESYSTEMFMT hFsFmt);
     78} RTFILESYSTEMDESC;
     79/** Pointer to a filesystem descriptor. */
     80typedef RTFILESYSTEMDESC *PRTFILESYSTEMDESC;
     81typedef const RTFILESYSTEMDESC *PCRTFILESYSTEMDESC;
    9082
    91     /**
    92      * Returns block size of the given filesystem.
    93      *
    94      * @returns Block size of filesystem.
    95      * @param   hFsFmt           The format specific filesystem handle.
    96      */
    97     DECLCALLBACKMEMBER(uint64_t, pfnGetBlockSize)(RTFILESYSTEMFMT hFsFmt);
    98 
    99     /**
    100      * Query the use of the given range in the filesystem.
    101      *
    102      * @returns IPRT status code.
    103      * @param   hFsFmt           The format specific filesystem handle.
    104      * @param   offStart         Start offset to check.
    105      * @param   cb               Size of the range to check.
    106      * @param   pfUsed           Where to store whether the range is in use
    107      *                           by the filesystem.
    108      */
    109     DECLCALLBACKMEMBER(int, pfnQueryRangeUse)(RTFILESYSTEMFMT hFsFmt, uint64_t offStart,
    110                                               size_t cb, bool *pfUsed);
    111 
    112 } RTFILESYSTEMFMTOPS;
    113 /** Pointer to a filesystem format ops table. */
    114 typedef RTFILESYSTEMFMTOPS *PRTFILESYSTEMFMTOPS;
    115 /** Pointer to a const filesystem format ops table. */
    116 typedef const RTFILESYSTEMFMTOPS *PCRTFILESYSTEMFMTOPS;
    117 
    118 /** Converts a LBA number to the byte offset. */
    119 #define RTFILESYSTEM_LBA2BYTE(lba, disk) ((lba) * (disk)->cbSector)
    120 /** Converts a Byte offset to the LBA number. */
    121 #define RTFILESYSTEM_BYTE2LBA(off, disk) ((off) / (disk)->cbSector)
    122 
    123 /**
    124  * Return size of the medium in bytes.
    125  *
    126  * @returns Size of the medium in bytes.
    127  * @param   hMedium    The medium handle.
    128  */
    129 DECLHIDDEN(uint64_t) rtFilesystemMediumGetSize(RTFILESYSTEMMEDIUM hMedium);
    130 
    131 /**
    132  * Read from the medium at the given offset.
    133  *
    134  * @returns IPRT status code.
    135  * @param   hMedium  The medium handle to read from.
    136  * @param   off      Start offset.
    137  * @param   pvBuf    Destination buffer.
    138  * @param   cbRead   How much to read.
    139  */
    140 DECLHIDDEN(int) rtFilesystemMediumRead(RTFILESYSTEMMEDIUM hMedium, uint64_t off,
    141                                        void *pvBuf, size_t cbRead);
    142 
    143 /**
    144  * Write to the disk at the given offset.
    145  *
    146  * @returns IPRT status code.
    147  * @param   hMedium  The medium handle to write to.
    148  * @param   off      Start offset.
    149  * @param   pvBuf    Source buffer.
    150  * @param   cbWrite  How much to write.
    151  */
    152 DECLHIDDEN(int) rtFilesystemMediumWrite(RTFILESYSTEMMEDIUM hMedium, uint64_t off,
    153                                         const void *pvBuf, size_t cbWrite);
     83extern DECLHIDDEN(RTFILESYSTEMDESC const) g_rtFsExt;
    15484
    15585RT_C_DECLS_END
  • trunk/src/VBox/Runtime/include/internal/magics.h

    r40855 r41549  
    5959/** The value of RTFILEAIOREQINT::u32Magic. (Stephen Edwin King)  */
    6060#define RTFILEAIOREQ_MAGIC              UINT32_C(0x19470921)
    61 /** The value of RTFILESYSTEMINT::u32Magic. (John Scalzi) */
    62 #define RTFILESYSTEM_MAGIC              UINT32_C(0x19690510)
    63 /** The value of RTFILESYSTEMINT::u32Magic after close. */
    64 #define RTFILESYSTEM_MAGIC_DEAD         (~RTFILESYSTEM_MAGIC)
    6561/** The value of RTENVINTERNAL::u32Magic. (Rumiko Takahashi) */
    6662#define RTENV_MAGIC                     UINT32_C(0x19571010)
Note: See TracChangeset for help on using the changeset viewer.

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