VirtualBox

Changeset 1532 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 16, 2007 2:54:40 PM (18 years ago)
Author:
vboxsync
Message:

Handle EFBIG on Linux correctly (and try to detect the same situation on
Windows). Provide separate runtime error message, because disk full
doesn't describe the problem (file size limit exceeded). Happens mostly
if people store VDIs on FAT32 partitions.

Location:
trunk/src/VBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevATA.cpp

    r1021 r1532  
    13751375
    13761376
     1377static void ataWarningFileTooBig(PPDMDEVINS pDevIns)
     1378{
     1379    int rc;
     1380    LogRel(("PIIX3 ATA: File too big\n"));
     1381    rc = VMSetRuntimeError(PDMDevHlpGetVM(pDevIns),
     1382                           false, "DevATA_FILETOOBIG",
     1383                           N_("Host system reported that the file size limit has been exceeded. VM execution is suspended. You need to move the file to a filesystem which allows bigger files"));
     1384    AssertRC(rc);
     1385}
     1386
     1387
    13771388static void ataWarningISCSI(PPDMDEVINS pDevIns)
    13781389{
     
    14111422            return true;
    14121423        }
     1424        if (rc == VERR_FILE_TOO_BIG)
     1425        {
     1426            ataWarningFileTooBig(ATADEVSTATE_2_DEVINS(s));
     1427            return true;
     1428        }
    14131429        if (rc == VERR_BROKEN_PIPE || rc == VERR_NET_CONNECTION_REFUSED)
    14141430        {
     
    14511467        {
    14521468            ataWarningDiskFull(ATADEVSTATE_2_DEVINS(s));
     1469            return true;
     1470        }
     1471        if (rc == VERR_FILE_TOO_BIG)
     1472        {
     1473            ataWarningFileTooBig(ATADEVSTATE_2_DEVINS(s));
    14531474            return true;
    14541475        }
  • trunk/src/VBox/Runtime/RTErrConvertFromErrno.cpp

    r1 r1532  
    130130#endif
    131131#ifdef EFBIG
    132         //case EFBIG:
     132        case EFBIG:             return VERR_FILE_TOO_BIG;
    133133#endif
    134134#ifdef ENOSPC
  • trunk/src/VBox/Runtime/r3/win32/fileio-win32.cpp

    r1 r1532  
    7474    return fRc;
    7575}
     76
     77
     78/**
     79 * This is a helper to check if an attempt is made to grow a file beyond the
     80 * limit of the filesystem.
     81 *
     82 * @returns true for file size limit exceeded.
     83 * @param   File        Filehandle.
     84 * @param   offSeek     Offset to seek.
     85 */
     86inline bool IsBeyondLimit(RTFILE File, uint64_t offSeek, unsigned uMethod)
     87{
     88    bool fIsBeyondLimit = false;
     89    /*
     90     * Get current file pointer.
     91     */
     92    uint64_t    offCurrent;
     93    if (MySetFilePointer(File, 0, &offCurrent, FILE_CURRENT))
     94    {
     95        /*
     96         * Set new file pointer.
     97         */
     98        if (!MySetFilePointer(File, offSeek, NULL, uMethod))
     99        {
     100            /*
     101             * Failed to set new file pointer.
     102             */
     103            fIsBeyondLimit = (GetLastError() == ERROR_SEEK);
     104        }
     105        else
     106        {
     107            /*
     108             * Restore file pointer.
     109             */
     110            MySetFilePointer(File, offCurrent, NULL, FILE_BEGIN);
     111        }
     112    }
     113
     114    return fIsBeyondLimit;
     115}
     116
     117
    76118
    77119
     
    307349                ULONG cbWrittenPart = 0;
    308350                if (!WriteFile((HANDLE)File, (char*)pvBuf + cbWritten, cbToWrite - cbWritten, &cbWrittenPart, NULL))
    309                     return RTErrConvertFromWin32(GetLastError());
     351                {
     352                    int rc = RTErrConvertFromWin32(GetLastError());
     353                    if (   rc == VERR_DISK_FULL
     354                        && IsBeyondLimit(File, cbToWrite - cbWritten, FILE_CURRENT)
     355                       )
     356                        rc = VERR_FILE_TOO_BIG;
     357                    return rc;
     358                }
    310359                if (cbWrittenPart == 0)
    311360                    return VERR_WRITE_ERROR;
     
    315364        return VINF_SUCCESS;
    316365    }
    317     return RTErrConvertFromWin32(GetLastError());
     366    int rc = RTErrConvertFromWin32(GetLastError());
     367    if (   rc == VERR_DISK_FULL
     368        && IsBeyondLimit(File, cbToWrite - cbWritten, FILE_CURRENT)
     369       )
     370        rc = VERR_FILE_TOO_BIG;
     371    return rc;
    318372}
    319373
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