fileio-posix.cpp revision 4f4877d6f6ea6dbe54cba4595450e5c837d5d419
df717630fe580e7c753ac381f197e901885985b9tavmjong-free * IPRT - File I/O, POSIX, Part 1.
03919b7845e461f72fa5d954b8124d27481c46b0JazzyNico * Copyright (C) 2006-2010 Oracle Corporation
2041edc9e0c8a75ae1ee22aec3d0fb66e1cc16a1Martin Owens * This file is part of VirtualBox Open Source Edition (OSE), as
03919b7845e461f72fa5d954b8124d27481c46b0JazzyNico * available from http://www.virtualbox.org. This file is free software;
03919b7845e461f72fa5d954b8124d27481c46b0JazzyNico * you can redistribute it and/or modify it under the terms of the GNU
03919b7845e461f72fa5d954b8124d27481c46b0JazzyNico * General Public License (GPL) as published by the Free Software
53eed655608a45ab528115d4225ad6e8e2c5641csuv-lp * Foundation, in version 2 as it comes in the "COPYING" file of the
03919b7845e461f72fa5d954b8124d27481c46b0JazzyNico * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
03919b7845e461f72fa5d954b8124d27481c46b0JazzyNico * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
df717630fe580e7c753ac381f197e901885985b9tavmjong-free * The contents of this file may alternatively be used under the terms
#include <errno.h>
#include <fcntl.h>
#ifdef _MSC_VER
# include <io.h>
# include <stdio.h>
# include <unistd.h>
#ifdef RT_OS_LINUX
# include <io.h>
bool fRc = false;
char const *pszNativePath;
struct stat s;
return fRc;
return rc;
#ifndef O_NONBLOCK
return VERR_INVALID_PARAMETER;
int fOpenMode = 0;
#ifdef O_BINARY
#ifdef O_LARGEFILE
#ifdef O_NOINHERIT
#ifdef O_CLOEXEC
#ifdef O_NONBLOCK
#ifdef O_SYNC
case RTFILE_O_OPEN: break;
case RTFILE_O_CREATE_REPLACE: fOpenMode |= O_CREAT | O_TRUNC; break; /** @todo replacing needs fixing, this is *not* a 1:1 mapping! */
case RTFILE_O_READ:
case RTFILE_O_WRITE:
case RTFILE_O_READWRITE:
return VERR_INVALID_PARAMETER;
char const *pszNativeFilename;
return (rc);
#ifdef O_CLOEXEC
&& s_fHave_O_CLOEXEC == 0)
else if (fh >= 0)
if (fh >= 0)
iErr = 0;
#ifdef O_NOINHERIT
#ifdef O_CLOEXEC
&& s_fHave_O_CLOEXEC <= 0
#if defined(RT_OS_DARWIN) \
# if defined(RT_OS_DARWIN)
#if 0 && defined(RT_OS_LINUX)
if (iErr == 0)
int iLockOp;
AssertFailed();
case RTFILE_O_DENY_NONE:
case RTFILE_O_DENY_NOT_DELETE:
case RTFILE_O_DENY_READ:
case RTFILE_O_DENY_WRITE:
if (iErr != 0)
if (iErr == 0)
AssertFailed();
case RTFILE_O_DENY_NONE:
case RTFILE_O_DENY_NOT_DELETE:
case RTFILE_O_DENY_READ:
case RTFILE_O_DENY_WRITE:
if (iErr != 0)
#ifdef RT_OS_SOLARIS
if (iErr == 0)
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
if ( uNative < 0
return VERR_INVALID_HANDLE;
return VINF_SUCCESS;
int fd;
switch (enmStdHandle)
return NIL_RTFILE;
char const *pszNativeFilename;
return rc;
static const unsigned aSeekRecode[] =
return VERR_INVALID_PARAMETER;
return VERR_NOT_SUPPORTED;
if (offCurrent != ~0)
if (poffActual)
return VINF_SUCCESS;
if (cbToRead <= 0)
return VINF_SUCCESS;
if (cbRead >= 0)
if (pcbRead)
if (cbReadPart <= 0)
if (cbReadPart == 0)
return VERR_EOF;
return VINF_SUCCESS;
if (cbToWrite <= 0)
return VINF_SUCCESS;
if (cbWritten >= 0)
if (pcbWritten)
if (cbWrittenPart <= 0)
return VINF_SUCCESS;
return VERR_NOT_SUPPORTED;
#if defined(_MSC_VER) || (defined(RT_OS_OS2) && (!defined(__INNOTEK_LIBC__) || __INNOTEK_LIBC__ < 0x006))
return VINF_SUCCESS;
return VINF_SUCCESS;
return rc;
if (cbInterval == 0)
if (pcbMax)
if (fFlags >= 0)
return VINF_SUCCESS;
RTR3DECL(int) RTFileIoCtl(RTFILE File, unsigned long ulRequest, void *pvData, unsigned cbData, int *piRet)
if (piRet)
return VERR_INVALID_PARAMETER;
return rc;
return VINF_SUCCESS;
AssertMsgReturn(!(fRename & ~RTPATHRENAME_FLAGS_REPLACE), ("%#x\n", fRename), VERR_INVALID_PARAMETER);
return rc;