tarvfs.cpp revision 4152e1d3f89dc5e2319a53c242e8e7cfcdf3726e
43af8389304c77c3d4db525de8907cb74207c380vboxsync * IPRT - TAR Virtual Filesystem.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Copyright (C) 2010 Oracle Corporation
43af8389304c77c3d4db525de8907cb74207c380vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
43af8389304c77c3d4db525de8907cb74207c380vboxsync * available from http://www.virtualbox.org. This file is free software;
43af8389304c77c3d4db525de8907cb74207c380vboxsync * you can redistribute it and/or modify it under the terms of the GNU
43af8389304c77c3d4db525de8907cb74207c380vboxsync * General Public License (GPL) as published by the Free Software
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
43af8389304c77c3d4db525de8907cb74207c380vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
43af8389304c77c3d4db525de8907cb74207c380vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * The contents of this file may alternatively be used under the terms
43af8389304c77c3d4db525de8907cb74207c380vboxsync * of the Common Development and Distribution License Version 1.0
43af8389304c77c3d4db525de8907cb74207c380vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
43af8389304c77c3d4db525de8907cb74207c380vboxsync * VirtualBox OSE distribution, in which case the provisions of the
43af8389304c77c3d4db525de8907cb74207c380vboxsync * CDDL are applicable instead of those of the GPL.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * You may elect to license modified versions of this file under the
43af8389304c77c3d4db525de8907cb74207c380vboxsync * terms and conditions of either the GPL or the CDDL or both.
43af8389304c77c3d4db525de8907cb74207c380vboxsync/******************************************************************************
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Header Files *
43af8389304c77c3d4db525de8907cb74207c380vboxsync ******************************************************************************/
43af8389304c77c3d4db525de8907cb74207c380vboxsync/*******************************************************************************
43af8389304c77c3d4db525de8907cb74207c380vboxsync* Structures and Typedefs *
43af8389304c77c3d4db525de8907cb74207c380vboxsync*******************************************************************************/
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Tar directory, character device, block device, fifo socket or symbolic link.
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** The stream offset of the (first) header. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** The tar header. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** The object info with unix attributes. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync/** Pointer to a tar filesystem stream base object. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Tar file represented as a VFS I/O stream.
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** The basic tar object data. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** The number of bytes in the file. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** The current file position. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** The number of padding bytes following the file. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** Set if we've reached the end of the file. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** The input I/O stream. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync/** Pointer to a the private data of a tar file I/O stream. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Tar filesystem stream private data.
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** The input I/O stream. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** The current object (referenced). */
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** Pointer to the private data if hVfsCurObj is representing a file. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** The start offset. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** The offset of the next header. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** Set if we've reached the end of the stream. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** Set if we've encountered a fatal error. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync/** Pointer to a the private data of a tar filesystem stream. */
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * Checks if the TAR header includes a posix user name field.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @returns true / false.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @param pTar The TAR header.
43af8389304c77c3d4db525de8907cb74207c380vboxsyncDECLINLINE(bool) rtZipTarHdrHasPosixUserName(PCRTZIPTARHDR pTar)
43af8389304c77c3d4db525de8907cb74207c380vboxsync return true;
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * Checks if the TAR header includes a posix group name field.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @returns true / false.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @param pTar The TAR header.
43af8389304c77c3d4db525de8907cb74207c380vboxsyncDECLINLINE(bool) rtZipTarHdrHasPosixGroupName(PCRTZIPTARHDR pTar)
43af8389304c77c3d4db525de8907cb74207c380vboxsync return true;
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * Checks if the TAR header includes a posix compatible path prefix field.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @returns true / false.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @param pTar The TAR header.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsyncDECLINLINE(bool) rtZipTarHdrHasPrefix(PCRTZIPTARHDR pTar)
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync return true;
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * Validates the TAR header.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @returns VINF_SUCCESS if valid, appropriate VERR_TAR_XXX if not.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @param pTar The TAR header.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * Translate a TAR header to an IPRT object info structure with additional UNIX
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * attributes.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @returns VINF_SUCCESS if valid, appropriate VERR_TAR_XXX if not.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @param pTar The TAR header (input).
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @param pObjInfo The object info structure (output).
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsyncstatic int rtZipTarHdrToFsObjInfo(PCRTZIPTARHDR pTar, PRTFSOBJINFO pObjInfo)
43af8389304c77c3d4db525de8907cb74207c380vboxsync * T h e V F S F i l e s y s t e m S t r e a m B i t s.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * T h e V F S F i l e s y s t e m S t r e a m B i t s.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * T h e V F S F i l e s y s t e m S t r e a m B i t s.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @interface_method_impl{RTVFSOBJOPS,pfnClose}
43af8389304c77c3d4db525de8907cb74207c380vboxsyncstatic DECLCALLBACK(int) rtZipTarFssBaseObj_Close(void *pvThis)
43af8389304c77c3d4db525de8907cb74207c380vboxsync /* Currently there is nothing we really have to do here. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @interface_method_impl{RTVFSOBJOPS,pfnQueryInfo}
43af8389304c77c3d4db525de8907cb74207c380vboxsyncstatic DECLCALLBACK(int) rtZipTarFssBaseObj_QueryInfo(void *pvThis, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr)
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Copy the desired data.
43af8389304c77c3d4db525de8907cb74207c380vboxsync pObjInfo->Attr.enmAdditional = RTFSOBJATTRADD_UNIX_OWNER;
43af8389304c77c3d4db525de8907cb74207c380vboxsync pObjInfo->Attr.u.UnixOwner.uid = pThis->ObjInfo.Attr.u.Unix.uid;
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync RTStrCopy(pObjInfo->Attr.u.UnixOwner.szName, sizeof(pObjInfo->Attr.u.UnixOwner.szName), pThis->Hdr.Posix.uname);
43af8389304c77c3d4db525de8907cb74207c380vboxsync pObjInfo->Attr.enmAdditional = RTFSOBJATTRADD_UNIX_GROUP;
43af8389304c77c3d4db525de8907cb74207c380vboxsync pObjInfo->Attr.u.UnixGroup.gid = pThis->ObjInfo.Attr.u.Unix.gid;
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync RTStrCopy(pObjInfo->Attr.u.UnixGroup.szName, sizeof(pObjInfo->Attr.u.UnixGroup.szName), pThis->Hdr.Posix.gname);
43af8389304c77c3d4db525de8907cb74207c380vboxsync pObjInfo->Attr.enmAdditional = RTFSOBJATTRADD_EASIZE;
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * Tar filesystem base object operations.
43af8389304c77c3d4db525de8907cb74207c380vboxsync "TarFsStream::Obj",
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @interface_method_impl{RTVFSOBJOPS,pfnClose}
43af8389304c77c3d4db525de8907cb74207c380vboxsyncstatic DECLCALLBACK(int) rtZipTarFssIos_Close(void *pvThis)
43af8389304c77c3d4db525de8907cb74207c380vboxsync PRTZIPTARIOSTREAM pThis = (PRTZIPTARIOSTREAM)pvThis;
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @interface_method_impl{RTVFSOBJOPS,pfnQueryInfo}
43af8389304c77c3d4db525de8907cb74207c380vboxsyncstatic DECLCALLBACK(int) rtZipTarFssIos_QueryInfo(void *pvThis, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr)
43af8389304c77c3d4db525de8907cb74207c380vboxsync PRTZIPTARIOSTREAM pThis = (PRTZIPTARIOSTREAM)pvThis;
43af8389304c77c3d4db525de8907cb74207c380vboxsync return rtZipTarFssBaseObj_QueryInfo(&pThis->BaseObj, pObjInfo, enmAddAttr);
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Reads one segment.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @returns IPRT status code.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param pThis The instance data.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param pvBuf Where to put the read bytes.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param cbToRead The number of bytes to read.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param fBlocking Whether to block or not.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @param pcbRead Where to store the number of bytes actually read.
43af8389304c77c3d4db525de8907cb74207c380vboxsyncstatic int rtZipTarFssIos_ReadOneSeg(PRTZIPTARIOSTREAM pThis, void *pvBuf, size_t cbToRead, bool fBlocking, size_t *pcbRead)
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Fend of reads beyond the end of the stream here.
43af8389304c77c3d4db525de8907cb74207c380vboxsync uint64_t cbLeft = (uint64_t)(pThis->cbFile - pThis->offFile);
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Do the reading.
43af8389304c77c3d4db525de8907cb74207c380vboxsync int rc = RTVfsIoStrmRead(pThis->hVfsIos, pvBuf, cbToRead, fBlocking, pcbRead);
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @interface_method_impl{RTVFSIOSTREAMOPS,pfnRead}
43af8389304c77c3d4db525de8907cb74207c380vboxsyncstatic DECLCALLBACK(int) rtZipTarFssIos_Read(void *pvThis, RTFOFF off, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead)
43af8389304c77c3d4db525de8907cb74207c380vboxsync PRTZIPTARIOSTREAM pThis = (PRTZIPTARIOSTREAM)pvThis;
43af8389304c77c3d4db525de8907cb74207c380vboxsync rc = rtZipTarFssIos_ReadOneSeg(pThis, pSgBuf->paSegs[0].pvSeg, pSgBuf->paSegs[0].cbSeg, fBlocking, pcbRead);
43af8389304c77c3d4db525de8907cb74207c380vboxsync for (uint32_t iSeg = 0; iSeg < pSgBuf->cSegs; iSeg++)
43af8389304c77c3d4db525de8907cb74207c380vboxsync rc = rtZipTarFssIos_ReadOneSeg(pThis, pSgBuf->paSegs[iSeg].pvSeg, pSgBuf->paSegs[iSeg].cbSeg, fBlocking, pcbReadSeg);
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @interface_method_impl{RTVFSIOSTREAMOPS,pfnWrite}
43af8389304c77c3d4db525de8907cb74207c380vboxsyncstatic DECLCALLBACK(int) rtZipTarFssIos_Write(void *pvThis, RTFOFF off, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten)
43af8389304c77c3d4db525de8907cb74207c380vboxsync /* Cannot write to a read-only I/O stream. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync NOREF(pvThis); NOREF(off); NOREF(pSgBuf); NOREF(fBlocking); NOREF(pcbWritten);
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @interface_method_impl{RTVFSIOSTREAMOPS,pfnFlush}
43af8389304c77c3d4db525de8907cb74207c380vboxsyncstatic DECLCALLBACK(int) rtZipTarFssIos_Flush(void *pvThis)
43af8389304c77c3d4db525de8907cb74207c380vboxsync /* It's a read only stream, nothing dirty to flush. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @interface_method_impl{RTVFSIOSTREAMOPS,pfnPollOne}
43af8389304c77c3d4db525de8907cb74207c380vboxsyncstatic DECLCALLBACK(int) rtZipTarFssIos_PollOne(void *pvThis, uint32_t fEvents, RTMSINTERVAL cMillies, bool fIntr,
43af8389304c77c3d4db525de8907cb74207c380vboxsync PRTZIPTARIOSTREAM pThis = (PRTZIPTARIOSTREAM)pvThis;
43af8389304c77c3d4db525de8907cb74207c380vboxsync /* When we've reached the end, read will be set to indicate it. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync int rc = RTVfsIoStrmPoll(pThis->hVfsIos, fEvents, 0, fIntr, pfRetEvents);
43af8389304c77c3d4db525de8907cb74207c380vboxsync return RTVfsIoStrmPoll(pThis->hVfsIos, fEvents, cMillies, fIntr, pfRetEvents);
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @interface_method_impl{RTVFSIOSTREAMOPS,pfnTell}
43af8389304c77c3d4db525de8907cb74207c380vboxsyncstatic DECLCALLBACK(int) rtZipTarFssIos_Tell(void *pvThis, PRTFOFF poffActual)
43af8389304c77c3d4db525de8907cb74207c380vboxsync PRTZIPTARIOSTREAM pThis = (PRTZIPTARIOSTREAM)pvThis;
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * Tar I/O stream operations.
43af8389304c77c3d4db525de8907cb74207c380vboxsync { /* Obj */
43af8389304c77c3d4db525de8907cb74207c380vboxsync "TarFsStream::IoStream",
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @interface_method_impl{RTVFSOBJOPS,pfnClose}
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsyncstatic DECLCALLBACK(int) rtZipTarFssSym_Close(void *pvThis)
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @interface_method_impl{RTVFSOBJOPS,pfnQueryInfo}
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsyncstatic DECLCALLBACK(int) rtZipTarFssSym_QueryInfo(void *pvThis, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr)
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync return rtZipTarFssBaseObj_QueryInfo(pThis, pObjInfo, enmAddAttr);
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @interface_method_impl{RTVFSOBJSETOPS,pfnMode}
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsyncstatic DECLCALLBACK(int) rtZipTarFssSym_SetMode(void *pvThis, RTFMODE fMode, RTFMODE fMask)
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @interface_method_impl{RTVFSOBJSETOPS,pfnSetTimes}
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsyncstatic DECLCALLBACK(int) rtZipTarFssSym_SetTimes(void *pvThis, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync NOREF(pvThis); NOREF(pAccessTime); NOREF(pModificationTime); NOREF(pChangeTime); NOREF(pBirthTime);
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @interface_method_impl{RTVFSOBJSETOPS,pfnSetOwner}
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsyncstatic DECLCALLBACK(int) rtZipTarFssSym_SetOwner(void *pvThis, RTUID uid, RTGID gid)
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * @interface_method_impl{RTVFSSYMLINKOPS,pfnRead}
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsyncstatic DECLCALLBACK(int) rtZipTarFssSym_Read(void *pvThis, char *pszTarget, size_t cbTarget)
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync return RTStrCopy(pszTarget, cbTarget, pThis->Hdr.Posix.linkname);
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * Tar symbolic (and hardlink) operations.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync { /* Obj */
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync "TarFsStream::Symlink",
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync { /* ObjSet */
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync RT_OFFSETOF(RTVFSFILEOPS, Stream.Obj) - RT_OFFSETOF(RTVFSFILEOPS, ObjSet),
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @interface_method_impl{RTVFSOBJOPS,pfnClose}
43af8389304c77c3d4db525de8907cb74207c380vboxsyncstatic DECLCALLBACK(int) rtZipTarFss_Close(void *pvThis)
43af8389304c77c3d4db525de8907cb74207c380vboxsync PRTZIPTARFSSTREAM pThis = (PRTZIPTARFSSTREAM)pvThis;
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @interface_method_impl{RTVFSOBJOPS,pfnQueryInfo}
43af8389304c77c3d4db525de8907cb74207c380vboxsyncstatic DECLCALLBACK(int) rtZipTarFss_QueryInfo(void *pvThis, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr)
43af8389304c77c3d4db525de8907cb74207c380vboxsync PRTZIPTARFSSTREAM pThis = (PRTZIPTARFSSTREAM)pvThis;
43af8389304c77c3d4db525de8907cb74207c380vboxsync /* Take the lazy approach here, with the sideffect of providing some info
43af8389304c77c3d4db525de8907cb74207c380vboxsync that is actually kind of useful. */
43af8389304c77c3d4db525de8907cb74207c380vboxsync return RTVfsIoStrmQueryInfo(pThis->hVfsIos, pObjInfo, enmAddAttr);
43af8389304c77c3d4db525de8907cb74207c380vboxsync * @interface_method_impl{RTVFSFSSTREAMOPS,pfnNext}
43af8389304c77c3d4db525de8907cb74207c380vboxsyncstatic DECLCALLBACK(int) rtZipTarFss_Next(void *pvThis, char **ppszName, RTVFSOBJTYPE *penmType, PRTVFSOBJ phVfsObj)
43af8389304c77c3d4db525de8907cb74207c380vboxsync PRTZIPTARFSSTREAM pThis = (PRTZIPTARFSSTREAM)pvThis;
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Dispense with the current object.
43af8389304c77c3d4db525de8907cb74207c380vboxsync pThis->pCurIosData->offFile = pThis->pCurIosData->cbFile;
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Check if we've already reached the end in some way.
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Make sure the input stream is in the right place.
43af8389304c77c3d4db525de8907cb74207c380vboxsync while ( off >= 0
43af8389304c77c3d4db525de8907cb74207c380vboxsync int rc = RTVfsIoStrmSkip(pThis->hVfsIos, off - pThis->offNextHdr);
43af8389304c77c3d4db525de8907cb74207c380vboxsync /** @todo Ignore if we're at the end of the stream? */
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Read the next header.
43af8389304c77c3d4db525de8907cb74207c380vboxsync int rc = RTVfsIoStrmRead(pThis->hVfsIos, &Hdr, sizeof(Hdr), true /*fBlocking*/, &cbRead);
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * Validate the header and convert to binary object info.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync/** @todo look for the two all zero headers terminating the stream... */
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Create an object of the appropriate type.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * Files are represented by a VFS I/O stream.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync RTFILE_O_READ | RTFILE_O_DENY_NONE | RTFILE_O_OPEN,
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync pIosData->cbPadding = 512 - (uint32_t)(Info.cbObject % 512);
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync pThis->offNextHdr += pIosData->cbFile + pIosData->cbPadding;
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * We represent hard links using a symbolic link object. This fits
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * best with the way TAR stores it and there is currently no better
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * fitting VFS type alternative.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * All other objects are repesented using a VFS base object since they
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * carry no data streams (unless some tar extension implements extended
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * attributes / alternative streams).
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync * Set the return data and we're done.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync rc = RTStrAAppendExN(ppszName, 2, Hdr.Posix.prefix, Hdr.Posix.name);
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Tar filesystem stream operations.
43af8389304c77c3d4db525de8907cb74207c380vboxsync { /* Obj */
43af8389304c77c3d4db525de8907cb74207c380vboxsync "TarFsStream",
43af8389304c77c3d4db525de8907cb74207c380vboxsyncRTDECL(int) RTZipTarFsStreamFromIoStream(RTVFSIOSTREAM hVfsIosIn, PRTVFSFSSTREAM phVfsFss)
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Input validation.
43af8389304c77c3d4db525de8907cb74207c380vboxsync RTFOFF const offStart = RTVfsIoStrmTell(hVfsIosIn);
43af8389304c77c3d4db525de8907cb74207c380vboxsync AssertReturn(cRefs != UINT32_MAX, VERR_INVALID_HANDLE);
43af8389304c77c3d4db525de8907cb74207c380vboxsync * Retain the input stream and create a new filesystem stream handle.
4152e1d3f89dc5e2319a53c242e8e7cfcdf3726evboxsync int rc = RTVfsNewFsStream(&rtZipTarFssOps, sizeof(*pThis), NIL_RTVFS, NIL_RTVFSLOCK, &hVfsFss, (void **)&pThis);
43af8389304c77c3d4db525de8907cb74207c380vboxsync /* Don't check if it's a TAR stream here, do that in the
43af8389304c77c3d4db525de8907cb74207c380vboxsync rtZipTarFss_Next. */