vfsbase.cpp revision 4e38f78b4916ef128a3902ed2a8d7e8d7f947d8d
/* $Id$ */
/** @file
* IPRT - Virtual File System, Base.
*/
/*
* Copyright (C) 2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/vfslowlevel.h>
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
#define RTVFS_MAGIC_DEAD (~RTVFS_MAGIC)
#define RTVFSIOSTREAM_MAGIC_DEAD (~RTVFSIOSTREAM_MAGIC)
#define RTVFSFILE_MAGIC_DEAD (~RTVFSFILE_MAGIC)
/** The instance data alignment. */
#define RTVFS_INST_ALIGNMENT 16U
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* The VFS handle data.
*/
typedef struct RTVFSINTERNAL
{
/** The VFS magic (RTVFS_MAGIC). */
/** Creation flags (RTVFS_C_XXX). */
/** Pointer to the instance data. */
void *pvThis;
/** The vtable. */
/** Read-write semaphore protecting all access to the VFS
* Only valid RTVFS_C_THREAD_SAFE is set, otherwise it is NIL_RTSEMRW. */
/** The number of references to this VFS.
* This count includes objects within the file system, so that the VFS
* won't be destroyed before all objects are closed. */
/**
* The VFS directory handle data.
*/
typedef struct RTVFSDIRINTERNAL
{
/** The VFS magic (RTVFSDIR_MAGIC). */
/** Reserved for flags or something. */
/** Pointer to the instance data. */
void *pvThis;
/** The vtable. */
/** The VFS RW sem if serialized. */
/** Reference back to the VFS containing this directory. */
/** The number of references to this directory handle. This does not
* include files or anything. */
/**
* The VFS I/O stream handle data.
*
* This is normally part of a type specific handle, like a file or pipe.
*/
typedef struct RTVFSIOSTREAMINTERNAL
{
/** The VFS magic (RTVFSIOSTREAM_MAGIC). */
/** File open flags, at a minimum the access mask. */
/** Pointer to the instance data. */
void *pvThis;
/** The vtable. */
/** The VFS RW sem if serialized. */
/** Reference back to the VFS containing this directory. */
/** The number of references to this file VFS. */
/**
* The VFS file handle data.
*
* @extends RTVFSIOSTREAMINTERNAL
*/
typedef struct RTVFSFILEINTERNAL
{
/** The VFS magic (RTVFSFILE_MAGIC). */
/** Reserved for flags or something. */
/** The vtable. */
/** The stream handle data. */
/**
* Internal object retainer that asserts sanity in strict builds.
*
* @returns The new reference count.
* @param pcRefs The reference counter.
*/
{
return cRefs;
}
/**
* Internal object retainer that asserts sanity in strict builds.
*
* @param pcRefs The reference counter.
*/
{
(void)rtVfsRetain(pcRefs);
}
/**
* Internal object releaser that asserts sanity in strict builds.
*
* @returns The new reference count.
* @param pcRefs The reference counter.
*/
{
return cRefs;
}
{
/*
* Validate the input, be extra strict in strict builds.
*/
Assert(cbInstance > 0);
{
}
/*
* Allocate the handle + instance data.
*/
if (!pThis)
return VERR_NO_MEMORY;
return VINF_SUCCESS;
}
{
}
{
if (!cRefs)
{
}
return cRefs;
}
{
}