VirtualBox

Changeset 34002 in vbox for trunk


Ignore:
Timestamp:
Nov 11, 2010 5:16:37 PM (14 years ago)
Author:
vboxsync
Message:

iprt: Working on tar vfs.

Location:
trunk
Files:
2 added
16 edited

Legend:

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

    r33945 r34002  
    12941294/** The tar end of file record was read. */
    12951295#define VERR_TAR_END_OF_FILE                    (-926)
     1296/** The tar file ended unexpectedly. */
     1297#define VERR_TAR_UNEXPECTED_EOS                 (-927)
    12961298/** @} */
    12971299
  • trunk/include/iprt/fs.h

    r33993 r34002  
    263263    /** No additional information is available / requested. */
    264264    RTFSOBJATTRADD_NOTHING = 1,
    265     /** The additional unix attributes (RTFSOBJATTR::u::Unix) are available / requested. */
     265    /** The additional unix attributes (RTFSOBJATTR::u::Unix) are available /
     266     *  requested. */
    266267    RTFSOBJATTRADD_UNIX,
     268    /** The additional unix attributes (RTFSOBJATTR::u::UnixOwner) are
     269     * available / requested. */
     270    RTFSOBJATTRADD_UNIX_OWNER,
     271    /** The additional unix attributes (RTFSOBJATTR::u::UnixGroup) are
     272     * available / requested. */
     273    RTFSOBJATTRADD_UNIX_GROUP,
    267274    /** The additional extended attribute size (RTFSOBJATTR::u::EASize) is available / requested. */
    268275    RTFSOBJATTRADD_EASIZE,
     
    275282} RTFSOBJATTRADD;
    276283
     284/** The number of bytes reserved for the additional attribute union. */
     285#define RTFSOBJATTRUNION_MAX_SIZE       128
     286
     287/**
     288 * Additional Unix Attributes (RTFSOBJATTRADD_UNIX).
     289 */
     290typedef struct RTFSOBJATTRUNIX
     291{
     292    /** The user owning the filesystem object (st_uid).
     293     * This field is NIL_UID if not supported. */
     294    RTUID           uid;
     295
     296    /** The group the filesystem object is assigned (st_gid).
     297     * This field is NIL_GID if not supported. */
     298    RTGID           gid;
     299
     300    /** Number of hard links to this filesystem object (st_nlink).
     301     * This field is 1 if the filesystem doesn't support hardlinking or
     302     * the information isn't available.
     303     */
     304    uint32_t        cHardlinks;
     305
     306    /** The device number of the device which this filesystem object resides on (st_dev).
     307     * This field is 0 if this information is not available. */
     308    RTDEV           INodeIdDevice;
     309
     310    /** The unique identifier (within the filesystem) of this filesystem object (st_ino).
     311     * Together with INodeIdDevice, this field can be used as a OS wide unique id
     312     * when both their values are not 0.
     313     * This field is 0 if the information is not available. */
     314    RTINODE         INodeId;
     315
     316    /** User flags (st_flags).
     317     * This field is 0 if this information is not available. */
     318    uint32_t        fFlags;
     319
     320    /** The current generation number (st_gen).
     321     * This field is 0 if this information is not available. */
     322    uint32_t        GenerationId;
     323
     324    /** The device number of a character or block device type object (st_rdev).
     325     * This field is 0 if the file isn't of a character or block device type and
     326     * when the OS doesn't subscribe to the major+minor device idenfication scheme. */
     327    RTDEV           Device;
     328} RTFSOBJATTRUNIX;
     329
     330
     331/**
     332 * Additional Unix Attributes (RTFSOBJATTRADD_UNIX_OWNER).
     333 *
     334 * @remarks This interface is mainly for TAR.
     335 */
     336typedef struct RTFSOBJATTRUNIXOWNER
     337{
     338    /** The user owning the filesystem object (st_uid).
     339     * This field is NIL_UID if not supported. */
     340    RTUID           uid;
     341    /** The user name.
     342     * Empty if not available or not supported, truncated if too long. */
     343    char            szName[RTFSOBJATTRUNION_MAX_SIZE - sizeof(RTUID)];
     344} RTFSOBJATTRUNIXOWNER;
     345
     346
     347/**
     348 * Additional Unix Attributes (RTFSOBJATTRADD_UNIX_GROUP).
     349 *
     350 * @remarks This interface is mainly for TAR.
     351 */
     352typedef struct RTFSOBJATTRUNIXGROUP
     353{
     354    /** The user owning the filesystem object (st_uid).
     355     * This field is NIL_GID if not supported. */
     356    RTGID           gid;
     357    /** The group name.
     358     * Empty if not available or not supported, truncated if too long. */
     359    char            szName[RTFSOBJATTRUNION_MAX_SIZE - sizeof(RTGID)];
     360} RTFSOBJATTRUNIXGROUP;
     361
    277362
    278363/**
    279364 * Filesystem object attributes.
    280365 */
    281 #pragma pack(1)
    282366typedef struct RTFSOBJATTR
    283367{
     
    296380    union RTFSOBJATTRUNION
    297381    {
    298         /** Additional Unix Attributes
    299          * These are available when RTFSOBJATTRADD is set in fUnix.
    300          */
    301          struct RTFSOBJATTRUNIX
    302          {
    303             /** The user owning the filesystem object (st_uid).
    304              * This field is ~0U if not supported. */
    305             RTUID           uid;
    306 
    307             /** The group the filesystem object is assigned (st_gid).
    308              * This field is ~0U if not supported. */
    309             RTGID           gid;
    310 
    311             /** Number of hard links to this filesystem object (st_nlink).
    312              * This field is 1 if the filesystem doesn't support hardlinking or
    313              * the information isn't available.
    314              */
    315             uint32_t        cHardlinks;
    316 
    317             /** The device number of the device which this filesystem object resides on (st_dev).
    318              * This field is 0 if this information is not available. */
    319             RTDEV           INodeIdDevice;
    320 
    321             /** The unique identifier (within the filesystem) of this filesystem object (st_ino).
    322              * Together with INodeIdDevice, this field can be used as a OS wide unique id
    323              * when both their values are not 0.
    324              * This field is 0 if the information is not available. */
    325             RTINODE         INodeId;
    326 
    327             /** User flags (st_flags).
    328              * This field is 0 if this information is not available. */
    329             uint32_t        fFlags;
    330 
    331             /** The current generation number (st_gen).
    332              * This field is 0 if this information is not available. */
    333             uint32_t        GenerationId;
    334 
    335             /** The device number of a character or block device type object (st_rdev).
    336              * This field is 0 if the file isn't of a character or block device type and
    337              * when the OS doesn't subscribe to the major+minor device idenfication scheme. */
    338             RTDEV           Device;
    339         } Unix;
     382        /** Additional Unix Attributes - RTFSOBJATTRADD_UNIX. */
     383        RTFSOBJATTRUNIX         Unix;
     384        /** Additional Unix Owner Attributes - RTFSOBJATTRADD_UNIX_OWNER. */
     385        RTFSOBJATTRUNIXOWNER    UnixOwner;
     386        /** Additional Unix Group Attributes - RTFSOBJATTRADD_UNIX_GROUP. */
     387        RTFSOBJATTRUNIXGROUP    UnixGroup;
    340388
    341389        /**
     
    347395            RTFOFF          cb;
    348396        } EASize;
     397        /** Reserved space. */
     398        uint8_t         abReserveSpace[128];
    349399    } u;
    350400} RTFSOBJATTR;
    351 #pragma pack()
    352401/** Pointer to a filesystem object attributes structure. */
    353402typedef RTFSOBJATTR *PRTFSOBJATTR;
     
    361410 * This is returned by the RTPathQueryInfo(), RTFileQueryInfo() and RTDirRead() APIs.
    362411 */
    363 #pragma pack(1)
    364412typedef struct RTFSOBJINFO
    365413{
     
    395443
    396444} RTFSOBJINFO;
    397 #pragma pack()
    398445/** Pointer to a filesystem object information structure. */
    399446typedef RTFSOBJINFO *PRTFSOBJINFO;
  • trunk/include/iprt/path.h

    r33802 r34002  
    628628 *
    629629 * @param   pszPath     Path to the file system object.
    630  * @param   pObjInfo    Object information structure to be filled on successful return.
     630 * @param   pObjInfo    Object information structure to be filled on successful
     631 *                      return.
    631632 * @param   enmAdditionalAttribs
    632633 *                      Which set of additional attributes to request.
  • trunk/include/iprt/vfs.h

    r33973 r34002  
    119119
    120120
    121 /** @defgroup grp_vfs_dir           VFS Directory API
     121/** @defgroup grp_vfs_dir           VFS Base Object API
    122122 * @{
    123123 */
    124124
    125 RTDECL(RTVFS)           RTVfsObjToVfs(RTVFSOBJ hVfsObj);
    126 RTDECL(RTVFSFSSTREAM)   RTVfsObjToFsStream(RTVFSOBJ hVfsObj);
    127 RTDECL(RTVFSDIR)        RTVfsObjToDir(RTVFSOBJ hVfsObj);
    128 RTDECL(RTVFSIOSTREAM)   RTVfsObjToIoStream(RTVFSOBJ hVfsObj);
    129 RTDECL(RTVFSFILE)       RTVfsObjToFile(RTVFSOBJ hVfsObj);
    130 RTDECL(RTVFSSYMLINK)    RTVfsObjToSymlink(RTVFSOBJ hVfsObj);
    131 
    132 RTDECL(RTVFSOBJ)        RTVfsObjFromVfs(RTVFS hVfs);
    133 RTDECL(RTVFSOBJ)        RTVfsObjFromFsStream(RTVFSFSSTREAM hVfsFss);
    134 RTDECL(RTVFSOBJ)        RTVfsObjFromDir(RTVFSDIR hVfsDir);
    135 RTDECL(RTVFSOBJ)        RTVfsObjFromIoStream(RTVFSIOSTREAM hVfsIos);
    136 RTDECL(RTVFSOBJ)        RTVfsObjFromFile(RTVFSFILE hVfsFile);
    137 RTDECL(RTVFSOBJ)        RTVfsObjFromSymlink(RTVFSSYMLINK hVfsSym);
     125/**
     126 * Retains a reference to the VFS base object handle.
     127 *
     128 * @returns New reference count on success, UINT32_MAX on failure.
     129 * @param   hVfsObj         The VFS base object handle.
     130 */
     131RTDECL(uint32_t)        RTVfsObjRetain(RTVFSOBJ hVfsObj);
     132
     133/**
     134 * Releases a reference to the VFS base handle.
     135 *
     136 * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
     137 * @param   hVfsObj         The VFS base object handle.
     138 */
     139RTDECL(uint32_t)        RTVfsObjRelease(RTVFSOBJ hVfsObj);
    138140
    139141/**
     
    141143 *
    142144 * @returns IPRT status code.
     145 * @retval  VERR_NOT_SUPPORTED if the @a enmAddAttr value is not handled by the
     146 *          implementation.
     147 *
    143148 * @param   hVfsObj         The VFS object handle.
    144149 * @param   pObjInfo        Where to return the info.
     
    146151 * @sa      RTFileQueryInfo, RTPathQueryInfo
    147152 */
    148 RTDECL(int)         RTVfsObjQueryInfo(RTVFSOBJ hVfsObj, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
     153RTDECL(int)             RTVfsObjQueryInfo(RTVFSOBJ hVfsObj, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
     154
     155
     156/**
     157 * Converts a VFS base object handle to a VFS handle.
     158 *
     159 * @returns Referenced handle on success, NIL on failure.
     160 * @param   hVfsObj         The VFS base object handle.
     161 */
     162RTDECL(RTVFS)           RTVfsObjToVfs(RTVFSOBJ hVfsObj);
     163
     164/**
     165 * Converts a VFS base object handle to a VFS filesystem stream handle.
     166 *
     167 * @returns Referenced handle on success, NIL on failure.
     168 * @param   hVfsObj         The VFS base object handle.
     169 */
     170RTDECL(RTVFSFSSTREAM)   RTVfsObjToFsStream(RTVFSOBJ hVfsObj);
     171
     172/**
     173 * Converts a VFS base object handle to a VFS directory handle.
     174 *
     175 * @returns Referenced handle on success, NIL on failure.
     176 * @param   hVfsObj         The VFS base object handle.
     177 */
     178RTDECL(RTVFSDIR)        RTVfsObjToDir(RTVFSOBJ hVfsObj);
     179
     180/**
     181 * Converts a VFS base object handle to a VFS I/O stream handle.
     182 *
     183 * @returns Referenced handle on success, NIL on failure.
     184 * @param   hVfsObj         The VFS base object handle.
     185 */
     186RTDECL(RTVFSIOSTREAM)   RTVfsObjToIoStream(RTVFSOBJ hVfsObj);
     187
     188/**
     189 * Converts a VFS base object handle to a VFS file handle.
     190 *
     191 * @returns Referenced handle on success, NIL on failure.
     192 * @param   hVfsObj         The VFS base object handle.
     193 */
     194RTDECL(RTVFSFILE)       RTVfsObjToFile(RTVFSOBJ hVfsObj);
     195
     196/**
     197 * Converts a VFS base object handle to a VFS symbolic link handle.
     198 *
     199 * @returns Referenced handle on success, NIL on failure.
     200 * @param   hVfsObj         The VFS base object handle.
     201 */
     202RTDECL(RTVFSSYMLINK)    RTVfsObjToSymlink(RTVFSOBJ hVfsObj);
     203
     204
     205/**
     206 * Converts a VFS handle to a VFS base object handle.
     207 *
     208 * @returns Referenced handle on success, NIL if the input handle was invalid.
     209 * @param   hVfs            The VFS handle.
     210 */
     211RTDECL(RTVFSOBJ)        RTVfsObjFromVfs(RTVFS hVfs);
     212
     213/**
     214 * Converts a VFS filesystem stream handle to a VFS base object handle.
     215 *
     216 * @returns Referenced handle on success, NIL if the input handle was invalid.
     217 * @param   hVfsFSs         The VFS filesystem stream handle.
     218 */
     219RTDECL(RTVFSOBJ)        RTVfsObjFromFsStream(RTVFSFSSTREAM hVfsFss);
     220
     221/**
     222 * Converts a VFS directory handle to a VFS base object handle.
     223 *
     224 * @returns Referenced handle on success, NIL if the input handle was invalid.
     225 * @param   hVfsDir          The VFS directory handle.
     226 */
     227RTDECL(RTVFSOBJ)        RTVfsObjFromDir(RTVFSDIR hVfsDir);
     228
     229/**
     230 * Converts a VFS I/O stream handle to a VFS base object handle.
     231 *
     232 * @returns Referenced handle on success, NIL if the input handle was invalid.
     233 * @param   hVfsIos          The VFS I/O stream handle.
     234 */
     235RTDECL(RTVFSOBJ)        RTVfsObjFromIoStream(RTVFSIOSTREAM hVfsIos);
     236
     237/**
     238 * Converts a VFS file handle to a VFS base object handle.
     239 *
     240 * @returns Referenced handle on success, NIL if the input handle was invalid.
     241 * @param   hVfsFile         The VFS file handle.
     242 */
     243RTDECL(RTVFSOBJ)        RTVfsObjFromFile(RTVFSFILE hVfsFile);
     244
     245/**
     246 * Converts a VFS symbolic link handle to a VFS base object handle.
     247 *
     248 * @returns Referenced handle on success, NIL if the input handle was invalid.
     249 * @param   hVfsSym            The VFS symbolic link handle.
     250 */
     251RTDECL(RTVFSOBJ)        RTVfsObjFromSymlink(RTVFSSYMLINK hVfsSym);
    149252
    150253/** @} */
     
    182285 * @retval  VINF_SUCCESS if a new object was retrieved.
    183286 * @retval  VERR_EOF when there are no more objects.
     287 *
    184288 * @param   pvThis      The implementation specific directory data.
    185289 * @param   ppszName    Where to return the object name.  Must be freed by
     
    323427 * @retval  VERR_EOF when trying to read __beyond__ the end of the stream and
    324428 *          @a pcbRead is NULL.
     429 * @retval  VERR_ACCESS_DENIED if the stream is not readable.
    325430 *
    326431 * @param   hVfsIos         The VFS I/O stream handle.
     
    339444 *
    340445 * @returns IPRT status code.
     446 * @retval  VERR_ACCESS_DENIED if the stream is not writable.
     447 *
    341448 * @param   hVfsIos         The VFS I/O stream handle.
    342449 * @param   pvBuf           The bytes to write.
     
    366473 * @retval  VERR_EOF when trying to read __beyond__ the end of the stream and
    367474 *          @a pcbRead is NULL.
     475 * @retval  VERR_ACCESS_DENIED if the stream is not readable.
    368476 *
    369477 * @param   hVfsIos         The VFS I/O stream handle.
     
    383491 *
    384492 * @returns IPRT status code.
     493 * @retval  VERR_ACCESS_DENIED if the stream is not writable.
     494 *
    385495 * @param   hVfsIos         The VFS I/O stream handle.
    386496 * @param   pSgBuf          Pointer to a gather buffer descriptor.  The number
  • trunk/include/iprt/vfslowlevel.h

    r33973 r34002  
    125125     * Get information about the file.
    126126     *
    127      * @returns IPRT status code.
     127     * @returns IPRT status code. See RTVfsObjQueryInfo.
    128128     * @param   pvThis      The implementation specific file data.
    129129     * @param   pObjInfo    Where to return the object info on success.
    130130     * @param   enmAddAttr  Which set of additional attributes to request.
    131      * @sa      RTFileQueryInfo
     131     * @sa      RTVfsObjQueryInfo, RTFileQueryInfo, RTPathQueryInfo
    132132     */
    133133    DECLCALLBACKMEMBER(int, pfnQueryInfo)(void *pvThis, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr);
     
    234234     * @param   hVfsObj     Where to return the object handle (referenced).
    235235     *                      This must be cast to the desired type before use.
     236     * @sa      RTVfsFsStrmNext
    236237     */
    237238    DECLCALLBACKMEMBER(int, pfnNext)(void *pvThis, char **ppszName, RTVFSOBJTYPE *penmType, PRTVFSOBJ phVfsObj);
     
    245246/** The RTVFSFSSTREAMOPS structure version. */
    246247#define RTVFSFSSTREAMOPS_VERSION    RT_MAKE_U32_FROM_U8(0xff,0x3f,1,0)
     248
     249
     250/**
     251 * Creates a new VFS filesystem stream handle.
     252 *
     253 * @returns IPRT status code
     254 * @param   pFsStreamOps        The filesystem stream operations.
     255 * @param   cbInstance          The size of the instance data.
     256 * @param   hVfs                The VFS handle to associate this filesystem
     257 *                              steram with.  NIL_VFS is ok.
     258 * @param   hSemRW              The read-write semaphore to use to protect the
     259 *                              handle if this differs from the one the VFS
     260 *                              uses.  NIL_RTSEMRW is ok if no locking is
     261 *                              desired.
     262 * @param   phVfsFss            Where to return the new handle.
     263 * @param   ppvInstance         Where to return the pointer to the instance data
     264 *                              (size is @a cbInstance).
     265 */
     266RTDECL(int) RTVfsNewFsStream(PCRTVFSFSSTREAMOPS pFsStreamOps, size_t cbInstance, RTVFS hVfs, RTSEMRW hSemRW,
     267                             PRTVFSFSSTREAM phVfsFss, void **ppvInstance);
    247268
    248269
     
    553574 * @param   cbInstance          The size of the instance data.
    554575 * @param   fOpen               The open flags.  The minimum is the access mask.
    555  * @param   hVfs                The VFS handle to associate this file with.
    556  *                              NIL_VFS is ok.
     576 * @param   hVfs                The VFS handle to associate this I/O stream
     577 *                              with.  NIL_VFS is ok.
    557578 * @param   hSemRW              The read-write semaphore to use to protect the
    558579 *                              handle if this differs from the one the VFS
  • trunk/src/VBox/Runtime/Makefile.kmk

    r33982 r34002  
    372372        common/vfs/vfsstdfile.cpp \
    373373        common/zip/tar.cpp \
     374        common/zip/tarvfs.cpp \
    374375        common/zip/zip.cpp \
    375376        common/zip/zipgzip.cpp \
  • trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp

    r33979 r34002  
    6868/** The max number of symbolic links to resolve in a path. */
    6969#define RTVFS_MAX_LINKS             20U
     70
     71
     72/** Asserts that the VFS base object vtable is valid. */
     73#define RTVFSOBJ_ASSERT_OPS(pObj, enmTypeArg) \
     74    do \
     75    { \
     76        Assert((pObj)->uVersion == RTVFSOBJOPS_VERSION); \
     77        Assert((pObj)->enmType == (enmTypeArg) || (enmTypeArg) == RTVFSOBJTYPE_INVALID); \
     78        AssertPtr((pObj)->pszName); \
     79        Assert(*(pObj)->pszName); \
     80        AssertPtr((pObj)->pfnClose); \
     81        AssertPtr((pObj)->pfnQueryInfo); \
     82        Assert((pObj)->uEndMarker == RTVFSOBJOPS_VERSION); \
     83    } while (0)
     84
     85/** Asserts that the VFS I/O stream vtable is valid. */
     86#define RTVFSIOSTREAM_ASSERT_OPS(pIoStreamOps, enmTypeArg) \
     87    do { \
     88        RTVFSOBJ_ASSERT_OPS(&(pIoStreamOps)->Obj, enmTypeArg); \
     89        Assert((pIoStreamOps)->uVersion == RTVFSIOSTREAMOPS_VERSION); \
     90        Assert(!(pIoStreamOps)->fReserved); \
     91        AssertPtr((pIoStreamOps)->pfnRead); \
     92        AssertPtr((pIoStreamOps)->pfnWrite); \
     93        AssertPtr((pIoStreamOps)->pfnFlush); \
     94        AssertPtr((pIoStreamOps)->pfnPollOne); \
     95        AssertPtr((pIoStreamOps)->pfnTell); \
     96        AssertPtrNull((pIoStreamOps)->pfnSkip); \
     97        AssertPtrNull((pIoStreamOps)->pfnZeroFill); \
     98        Assert((pIoStreamOps)->uEndMarker == RTVFSIOSTREAMOPS_VERSION); \
     99    } while (0)
    70100
    71101
     
    10951125                             PRTVFSFSSTREAM phVfsFss, void **ppvInstance)
    10961126{
    1097     return VERR_NOT_IMPLEMENTED;
     1127    /*
     1128     * Validate the input, be extra strict in strict builds.
     1129     */
     1130    AssertPtr(pFsStreamOps);
     1131    AssertReturn(pFsStreamOps->uVersion   == RTVFSFSSTREAMOPS_VERSION, VERR_VERSION_MISMATCH);
     1132    AssertReturn(pFsStreamOps->uEndMarker == RTVFSFSSTREAMOPS_VERSION, VERR_VERSION_MISMATCH);
     1133    Assert(!pFsStreamOps->fReserved);
     1134    RTVFSOBJ_ASSERT_OPS(&pFsStreamOps->Obj, RTVFSOBJTYPE_FS_STREAM);
     1135    AssertPtr(pFsStreamOps->pfnNext);
     1136    Assert(cbInstance > 0);
     1137    AssertPtr(ppvInstance);
     1138    AssertPtr(phVfsFss);
     1139
     1140    RTVFSINTERNAL *pVfs = NULL;
     1141    if (hVfs != NIL_RTVFS)
     1142    {
     1143        pVfs = hVfs;
     1144        AssertPtrReturn(pVfs, VERR_INVALID_HANDLE);
     1145        AssertReturn(pVfs->uMagic == RTVFS_MAGIC, VERR_INVALID_HANDLE);
     1146    }
     1147
     1148    /*
     1149     * Allocate the handle + instance data.
     1150     */
     1151    size_t const cbThis = RT_ALIGN_Z(sizeof(RTVFSFSSTREAMINTERNAL), RTVFS_INST_ALIGNMENT)
     1152                        + RT_ALIGN_Z(cbInstance, RTVFS_INST_ALIGNMENT);
     1153    RTVFSFSSTREAMINTERNAL *pThis = (RTVFSFSSTREAMINTERNAL *)RTMemAllocZ(cbThis);
     1154    if (!pThis)
     1155        return VERR_NO_MEMORY;
     1156
     1157    pThis->uMagic       = RTVFSFSSTREAM_MAGIC;
     1158    pThis->fFlags       = RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE;
     1159    pThis->pOps         = pFsStreamOps;
     1160    pThis->Base.uMagic  = RTVFSOBJ_MAGIC;
     1161    pThis->Base.pvThis  = (char *)pThis + RT_ALIGN_Z(sizeof(*pThis), RTVFS_INST_ALIGNMENT);
     1162    pThis->Base.pOps    = &pFsStreamOps->Obj;
     1163    pThis->Base.hSemRW  = hSemRW != NIL_RTSEMRW ? hSemRW : pVfs ? pVfs->Base.hSemRW : NIL_RTSEMRW;
     1164    pThis->Base.hVfs    = hVfs;
     1165    pThis->Base.cRefs   = 1;
     1166    if (hVfs != NIL_RTVFS)
     1167        rtVfsObjRetainVoid(&pVfs->Base);
     1168
     1169    *phVfsFss    = pThis;
     1170    *ppvInstance = pThis->Base.pvThis;
     1171    return VINF_SUCCESS;
    10981172}
    10991173
     
    12331307    AssertReturn(pIoStreamOps->uEndMarker == RTVFSIOSTREAMOPS_VERSION, VERR_VERSION_MISMATCH);
    12341308    Assert(!pIoStreamOps->fReserved);
     1309    RTVFSIOSTREAM_ASSERT_OPS(pIoStreamOps, RTVFSOBJTYPE_IO_STREAM);
    12351310    Assert(cbInstance > 0);
    12361311    Assert(fOpen & RTFILE_O_ACCESS_MASK);
     
    15391614    AssertReturn(pFileOps->uEndMarker == RTVFSFILEOPS_VERSION, VERR_VERSION_MISMATCH);
    15401615    Assert(!pFileOps->fReserved);
     1616    RTVFSIOSTREAM_ASSERT_OPS(&pFileOps->Stream, RTVFSOBJTYPE_FILE);
    15411617    Assert(cbInstance > 0);
    15421618    Assert(fOpen & RTFILE_O_ACCESS_MASK);
  • trunk/src/VBox/Runtime/common/zip/tar.cpp

    r33982 r34002  
    3030 ******************************************************************************/
    3131#include "internal/iprt.h"
    32 #include "internal/magics.h"
    3332#include <iprt/tar.h>
    3433
     
    4039#include <iprt/path.h>
    4140#include <iprt/string.h>
     41
     42#include "internal/magics.h"
    4243
    4344
  • trunk/src/VBox/Runtime/common/zip/zipgzip.cpp

    r33973 r34002  
    341341    int              rc;
    342342
    343     NOREF(fBlocking);
    344343    if (!pThis->fDecompress)
    345344        return VERR_ACCESS_DENIED;
  • trunk/src/VBox/Runtime/include/internal/fs.h

    r28800 r34002  
    4343#ifndef RT_OS_WINDOWS
    4444void    rtFsConvertStatToObjInfo(PRTFSOBJINFO pObjInfo, const struct stat *pStat, const char *pszName, unsigned cbName);
     45void    rtFsObjInfoAttrSetUnixOwner(PRTFSOBJINFO pObjInfo, RTUID uid);
     46void    rtFsObjInfoAttrSetUnixGroup(PRTFSOBJINFO pObjInfo, RTUID gid);
    4547#endif
    4648
  • trunk/src/VBox/Runtime/r3/fs.cpp

    r33540 r34002  
    3737#  define DEV_BSIZE S_BLKSIZE /** @todo bird: add DEV_BSIZE to sys/param.h on OS/2. */
    3838# endif
     39# include <grp.h>
     40# include <pwd.h>
    3941#endif
    4042
     
    192194}
    193195
    194 
    195196#ifndef RT_OS_WINDOWS
     197
    196198/**
    197199 * Internal worker function which setups RTFSOBJINFO based on a UNIX stat struct.
     
    300302    pObjInfo->Attr.u.Unix.Device          = pStat->st_rdev;
    301303}
     304
     305
     306/**
     307 * Set user-owner additional attributes.
     308 *
     309 * @param   pObjInfo            The object info to fill add attrs for.
     310 * @param   uid                 The user id.
     311 */
     312void    rtFsObjInfoAttrSetUnixOwner(PRTFSOBJINFO pObjInfo, RTUID uid)
     313{
     314    pObjInfo->Attr.enmAdditional   = RTFSOBJATTRADD_UNIX_OWNER;
     315    pObjInfo->Attr.u.UnixOwner.uid = uid;
     316    pObjInfo->Attr.u.UnixOwner.szName[0] = '\0';
     317
     318    char            achBuf[_4K];
     319    struct passwd   Pwd;
     320    struct passwd  *pPwd;
     321    int rc = getpwuid_r(uid, &Pwd, achBuf, sizeof(achBuf), &pPwd);
     322    if (!rc && pPwd)
     323        RTStrCopy(pObjInfo->Attr.u.UnixOwner.szName, sizeof(pObjInfo->Attr.u.UnixOwner.szName), pPwd->pw_name);
     324}
     325
     326
     327/**
     328 * Set user-group additional attributes.
     329 *
     330 * @param   pObjInfo            The object info to fill add attrs for.
     331 * @param   gid                 The group id.
     332 */
     333void rtFsObjInfoAttrSetUnixGroup(PRTFSOBJINFO pObjInfo, RTUID gid)
     334{
     335    pObjInfo->Attr.enmAdditional   = RTFSOBJATTRADD_UNIX_GROUP;
     336    pObjInfo->Attr.u.UnixGroup.gid = gid;
     337    pObjInfo->Attr.u.UnixGroup.szName[0] = '\0';
     338
     339    char            achBuf[_4K];
     340    struct group    Grp;
     341    struct group   *pGrp;
     342
     343    int rc = getgrgid_r(gid, &Grp, achBuf, sizeof(achBuf), &pGrp);
     344    if (!rc && pGrp)
     345        RTStrCopy(pObjInfo->Attr.u.UnixGroup.szName, sizeof(pObjInfo->Attr.u.UnixGroup.szName), pGrp->gr_name);
     346}
     347
    302348#endif /* !RT_OS_WINDOWS */
    303349
  • trunk/src/VBox/Runtime/r3/posix/fileio-posix.cpp

    r33103 r34002  
    658658    switch (enmAdditionalAttribs)
    659659    {
     660        case RTFSOBJATTRADD_NOTHING:
     661        case RTFSOBJATTRADD_UNIX:
     662            /* done */
     663            break;
     664
     665        case RTFSOBJATTRADD_UNIX_OWNER:
     666            rtFsObjInfoAttrSetUnixOwner(pObjInfo, Stat.st_uid);
     667            break;
     668
     669        case RTFSOBJATTRADD_UNIX_GROUP:
     670            rtFsObjInfoAttrSetUnixGroup(pObjInfo, Stat.st_gid);
     671            break;
     672
    660673        case RTFSOBJATTRADD_EASIZE:
    661674            pObjInfo->Attr.enmAdditional          = RTFSOBJATTRADD_EASIZE;
    662675            pObjInfo->Attr.u.EASize.cb            = 0;
    663             break;
    664 
    665         case RTFSOBJATTRADD_NOTHING:
    666         case RTFSOBJATTRADD_UNIX:
    667             /* done */
    668676            break;
    669677
  • trunk/src/VBox/Runtime/r3/posix/path-posix.cpp

    r33602 r34002  
    3939#include <sys/types.h>
    4040#include <pwd.h>
     41#include <grp.h>
    4142
    4243#include <iprt/path.h>
     
    340341            switch (enmAdditionalAttribs)
    341342            {
     343                case RTFSOBJATTRADD_NOTHING:
     344                case RTFSOBJATTRADD_UNIX:
     345                    Assert(pObjInfo->Attr.enmAdditional == RTFSOBJATTRADD_UNIX);
     346                    break;
     347
     348                case RTFSOBJATTRADD_UNIX_OWNER:
     349                    rtFsObjInfoAttrSetUnixOwner(pObjInfo, Stat.st_uid);
     350                    break;
     351
     352                case RTFSOBJATTRADD_UNIX_GROUP:
     353                    rtFsObjInfoAttrSetUnixGroup(pObjInfo, Stat.st_gid);
     354                    break;
     355
    342356                case RTFSOBJATTRADD_EASIZE:
    343357                    /** @todo Use SGI extended attribute interface to query EA info. */
    344358                    pObjInfo->Attr.enmAdditional          = RTFSOBJATTRADD_EASIZE;
    345359                    pObjInfo->Attr.u.EASize.cb            = 0;
    346                     break;
    347 
    348                 case RTFSOBJATTRADD_NOTHING:
    349                 case RTFSOBJATTRADD_UNIX:
    350                     Assert(pObjInfo->Attr.enmAdditional == RTFSOBJATTRADD_UNIX);
    351360                    break;
    352361
  • trunk/src/VBox/Runtime/r3/win/dir-win.cpp

    r28918 r34002  
    437437            break;
    438438
     439        case RTFSOBJATTRADD_UNIX_OWNER:
     440            pDirEntry->Info.Attr.enmAdditional          = RTFSOBJATTRADD_UNIX_OWNER;
     441            pDirEntry->Info.Attr.u.UnixOwner.uid        = ~0U;
     442            pDirEntry->Info.Attr.u.UnixOwner.szName[0]  = '\0'; /** @todo return something sensible here. */
     443            break;
     444
     445        case RTFSOBJATTRADD_UNIX_GROUP:
     446            pDirEntry->Info.Attr.enmAdditional          = RTFSOBJATTRADD_UNIX_GROUP;
     447            pDirEntry->Info.Attr.u.UnixGroup.gid        = ~0U;
     448            pDirEntry->Info.Attr.u.UnixGroup.szName[0]  = '\0';
     449            break;
     450
    439451        default:
    440452            AssertMsgFailed(("Impossible!\n"));
  • trunk/src/VBox/Runtime/r3/win/fileio-win.cpp

    r33540 r34002  
    680680    switch (enmAdditionalAttribs)
    681681    {
    682         case RTFSOBJATTRADD_EASIZE:
    683             pObjInfo->Attr.enmAdditional          = RTFSOBJATTRADD_EASIZE;
    684             pObjInfo->Attr.u.EASize.cb            = 0;
     682        case RTFSOBJATTRADD_NOTHING:
     683            pObjInfo->Attr.enmAdditional          = RTFSOBJATTRADD_NOTHING;
    685684            break;
    686685
     
    697696            break;
    698697
    699         case RTFSOBJATTRADD_NOTHING:
    700             pObjInfo->Attr.enmAdditional          = RTFSOBJATTRADD_NOTHING;
     698        case RTFSOBJATTRADD_UNIX_OWNER:
     699            pObjInfo->Info.Attr.enmAdditional     = RTFSOBJATTRADD_UNIX_OWNER;
     700            pObjInfo->Info.Attr.u.UnixOwner.uid   = ~0U;
     701            pObjInfo->Info.Attr.u.UnixOwner.szName[0] = '\0'; /** @todo return something sensible here. */
     702            break;
     703
     704        case RTFSOBJATTRADD_UNIX_GROUP:
     705            pObjInfo->Info.Attr.enmAdditional     = RTFSOBJATTRADD_UNIX_GROUP;
     706            pObjInfo->Info.Attr.u.UnixGroup.gid   = ~0U;
     707            pObjInfo->Info.Attr.u.UnixGroup.szName[0] = '\0';
     708            break;
     709
     710        case RTFSOBJATTRADD_EASIZE:
     711            pObjInfo->Attr.enmAdditional          = RTFSOBJATTRADD_EASIZE;
     712            pObjInfo->Attr.u.EASize.cb            = 0;
    701713            break;
    702714
  • trunk/src/VBox/Runtime/r3/win/path-win.cpp

    r33439 r34002  
    300300    switch (enmAdditionalAttribs)
    301301    {
    302         case RTFSOBJATTRADD_EASIZE:
    303             pObjInfo->Attr.enmAdditional          = RTFSOBJATTRADD_EASIZE;
    304             pObjInfo->Attr.u.EASize.cb            = 0;
     302        case RTFSOBJATTRADD_NOTHING:
     303            pObjInfo->Attr.enmAdditional          = RTFSOBJATTRADD_NOTHING;
    305304            break;
    306305
     
    317316            break;
    318317
    319         case RTFSOBJATTRADD_NOTHING:
    320             pObjInfo->Attr.enmAdditional          = RTFSOBJATTRADD_NOTHING;
     318        case RTFSOBJATTRADD_UNIX_OWNER:
     319            pObjInfo->Info.Attr.enmAdditional     = RTFSOBJATTRADD_UNIX_OWNER;
     320            pObjInfo->Info.Attr.u.UnixOwner.uid   = ~0U;
     321            pObjInfo->Info.Attr.u.UnixOwner.szName[0] = '\0'; /** @todo return something sensible here. */
     322            break;
     323
     324        case RTFSOBJATTRADD_UNIX_GROUP:
     325            pObjInfo->Info.Attr.enmAdditional     = RTFSOBJATTRADD_UNIX_GROUP;
     326            pObjInfo->Info.Attr.u.UnixGroup.gid   = ~0U;
     327            pObjInfo->Info.Attr.u.UnixGroup.szName[0] = '\0';
     328            break;
     329
     330        case RTFSOBJATTRADD_EASIZE:
     331            pObjInfo->Attr.enmAdditional          = RTFSOBJATTRADD_EASIZE;
     332            pObjInfo->Attr.u.EASize.cb            = 0;
    321333            break;
    322334
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