VirtualBox

Changeset 21493 in vbox for trunk/src/VBox/Runtime/r3


Ignore:
Timestamp:
Jul 10, 2009 7:58:31 PM (16 years ago)
Author:
vboxsync
Message:

Runtime/File: Add flag to disable the file cache

Location:
trunk/src/VBox/Runtime/r3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/fileio-posix.cpp

    r19346 r21493  
    148148        fOpenMode |= O_DIRECT;
    149149#endif
     150#if defined(O_DIRECT) && (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD))
     151    /* Disable the kernel cache. */
     152    if (fOpen & RTFILE_O_NO_CACHE)
     153        fOpenMode |= O_DIRECT;
     154#endif
    150155
    151156    /* create/truncate file */
     
    204209            ||  fcntl(fh, F_SETFD, FD_CLOEXEC) >= 0)
    205210        {
    206             *pFile = (RTFILE)fh;
    207             Assert((int)*pFile == fh);
    208             LogFlow(("RTFileOpen(%p:{%RTfile}, %p:{%s}, %#x): returns %Rrc\n",
    209                      pFile, *pFile, pszFilename, pszFilename, fOpen, rc));
    210             return VINF_SUCCESS;
     211#if defined(RT_OS_SOLARIS) || defined(RT_OS_DARWIN)
     212            iErr = 0;
     213            /* Switch direct I/O on now if requested */
     214            if (fOpen & RTFILE_O_NO_CACHE)
     215# if defined(RT_OS_SOLARIS)
     216                iErr = directio(fh, DIRECTIO_ON);
     217# elif defined(RT_OS_DARWIN)
     218                iErr = fcntl(fh, F_NOCACHE);
     219# endif
     220            if (iErr < 0)
     221                iErr = errno;
     222            else
     223#endif
     224            {
     225                *pFile = (RTFILE)fh;
     226                Assert((int)*pFile == fh);
     227                LogFlow(("RTFileOpen(%p:{%RTfile}, %p:{%s}, %#x): returns %Rrc\n",
     228                         pFile, *pFile, pszFilename, pszFilename, fOpen, rc));
     229                return VINF_SUCCESS;
     230            }
    211231        }
    212232        iErr = errno;
  • trunk/src/VBox/Runtime/r3/win/fileio-win.cpp

    r19186 r21493  
    263263    if (fOpen & RTFILE_O_ASYNC_IO)
    264264        dwFlagsAndAttributes |= FILE_FLAG_OVERLAPPED;
     265    if (fOpen & RTFILE_O_NO_CACHE)
     266        dwFlagsAndAttributes |= FILE_FLAG_NO_BUFFERING;
    265267
    266268    /*
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