VirtualBox

Changeset 27133 in vbox for trunk/src


Ignore:
Timestamp:
Mar 6, 2010 5:01:36 PM (15 years ago)
Author:
vboxsync
Message:

FE/VBoxManage: Make raw disk support work for FreeBSD, contributed by Juergen Lock

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp

    r26288 r27133  
    5555# include <windows.h>
    5656# include <winioctl.h>
    57 #elif defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS)
     57#elif defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) \
     58    || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
    5859# include <errno.h>
    5960# include <sys/ioctl.h>
     
    7778# include <sys/vtoc.h>
    7879#endif /* RT_OS_SOLARIS */
     80#ifdef RT_OS_FREEBSD
     81# include <sys/disk.h>
     82#endif /* RT_OS_FREEBSD */
    7983
    8084using namespace com;
     
    10841088        goto out;
    10851089    }
     1090#elif defined(RT_OS_FREEBSD)
     1091    struct stat DevStat;
     1092    if (!fstat(RawFile, &DevStat) && S_ISCHR(DevStat.st_mode))
     1093    {
     1094        off_t cbMedia = 0;
     1095        if (!ioctl(RawFile, DIOCGMEDIASIZE, &cbMedia))
     1096        {
     1097            cbSize = cbMedia;
     1098        }
     1099        else
     1100        {
     1101            vrc = RTErrConvertFromErrno(errno);
     1102            RTPrintf("Cannot get the block count for file '%s': %Rrc", rawdisk.raw(), vrc);
     1103            goto out;
     1104        }
     1105    }
     1106    else
     1107    {
     1108        RTPrintf("File '%s' is no character device\n", rawdisk.raw());
     1109        vrc = VERR_INVALID_PARAMETER;
     1110        goto out;
     1111    }
    10861112#else /* all unrecognized OSes */
    10871113    /* Hopefully this works on all other hosts. If it doesn't, it'll just fail
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