VirtualBox

Changeset 30365 in vbox


Ignore:
Timestamp:
Jun 22, 2010 12:08:20 PM (14 years ago)
Author:
vboxsync
Message:

RTFsQueryType: Use an enum. Added RTFsTypeName() for translating a enum value into a string. Added more file system types.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/fs.h

    r30281 r30365  
    180180
    181181
    182 /** @name Filesystem type IDs. Used by RTFsQueryType. */
    183 #define RTFS_FS_TYPE_UNKNOWN            0
    184 #define RTFS_FS_TYPE_EXT                1
    185 #define RTFS_FS_TYPE_EXT2               2
    186 #define RTFS_FS_TYPE_EXT3               3
    187 #define RTFS_FS_TYPE_EXT4               4
    188 #define RTFS_FS_TYPE_TMPFS              5
    189 #define RTFS_FS_TYPE_JFS                6
    190 #define RTFS_FS_TYPE_NFS                7
    191 #define RTFS_FS_TYPE_HFS                8
    192 #define RTFS_FS_TYPE_CIFS               9
    193 #define RTFS_FS_TYPE_FAT               10
    194 #define RTFS_FS_TYPE_NTFS              11
    195 #define RTFS_FS_TYPE_ZFS               12
    196 #define RTFS_FS_TYPE_XFS               13
    197 #define RTFS_FS_TYPE_AUTOFS            14
    198 #define RTFS_FS_TYPE_DEVFS             15
     182/**
     183 * Filesystem type IDs returned by RTFsQueryType.
     184 *
     185 * This enum is subject to changes and must not be used as part of any ABI or
     186 * binary format (file, network, etc).
     187 *
     188 * @remarks When adding new entries, please update RTFsTypeName().  Also, try
     189 *          add them to the most natural group.
     190 */
     191typedef enum RTFSTYPE
     192{
     193    /** Unknown file system. */
     194    RTFSTYPE_UNKNOWN = 0,
     195
     196    /** Universal Disk Format. */
     197    RTFSTYPE_UDF,
     198    /** ISO 9660, aka Compact Disc File System (CDFS). */
     199    RTFSTYPE_ISO9660,
     200    /** Filesystem in Userspace. */
     201    RTFSTYPE_FUSE,
     202    /** VirtualBox shared folders.  */
     203    RTFSTYPE_VBOXSHF,
     204
     205    /* Linux: */
     206    RTFSTYPE_EXT,
     207    RTFSTYPE_EXT2,
     208    RTFSTYPE_EXT3,
     209    RTFSTYPE_EXT4,
     210    RTFSTYPE_XFS,
     211    RTFSTYPE_CIFS,
     212    RTFSTYPE_SMBFS,
     213    RTFSTYPE_TMPFS,
     214    RTFSTYPE_SYSFS,
     215    RTFSTYPE_PROC,
     216
     217    /* Windows: */
     218    /** New Technology File System. */
     219    RTFSTYPE_NTFS,
     220    /** FAT12, FAT16 and FAT32 lumped into one basket.
     221     * The partition size limit of FAT12 and FAT16 will be the factor
     222     * limiting the file size (except, perhaps for the 64KB cluster case on
     223     * non-Windows hosts). */
     224    RTFSTYPE_FAT,
     225
     226    /* Solaris: */
     227    /** Zettabyte File System.  */
     228    RTFSTYPE_ZFS,
     229    /** Unix File System. */
     230    RTFSTYPE_UFS,
     231    /** Network File System. */
     232    RTFSTYPE_NFS,
     233
     234    /* Mac OS X: */
     235    /** Hierarchical File System. */
     236    RTFSTYPE_HFS,
     237    /** @todo RTFSTYPE_HFS_PLUS? */
     238    RTFSTYPE_AUTOFS,
     239    RTFSTYPE_DEVFS,
     240
     241    /* *BSD: */
     242
     243    /* OS/2: */
     244    /** High Performance File System. */
     245    RTFSTYPE_HPFS,
     246    /** Journaled File System (v2).  */
     247    RTFSTYPE_JFS,
     248
     249    /** The end of valid Filesystem types IDs. */
     250    RTFSTYPE_END,
     251    /** The usual 32-bit type blow up. */
     252    RTFSTYPE_32BIT_HACK = 0x7fffffff
     253} RTFSTYPE;
     254/** Pointer to a Filesystem type ID. */
     255typedef RTFSTYPE *PRTFSTYPE;
    199256
    200257
     
    408465 *
    409466 * @returns iprt status code.
    410  * @param   pszFsPath       Path within the mounted filesystem.
    411  *                          In case this is a symlink, the file it refers to
    412  *                          is evaluated.
    413  * @param   pu32Type        Where to store the filesystem type.
    414  *                          See RTFS_FS_TYPE_xxx constants.
    415  */
    416 RTR3DECL(int) RTFsQueryType(const char *pszFsPath, uint32_t *pu32Type);
     467 * @param   pszFsPath       Path within the mounted filesystem.  It must exist.
     468 *                          In case this is a symlink, the file it refers to is
     469 *                          evaluated.
     470 * @param   penmType        Where to store the filesystem type, this is always
     471 *                          set.  See RTFSTYPE for the values.
     472 */
     473RTR3DECL(int) RTFsQueryType(const char *pszFsPath, PRTFSTYPE penmType);
    417474
    418475#endif /* IN_RING3 */
     476
     477/**
     478 * Gets the name of a filesystem type.
     479 *
     480 * @returns Pointer to a read-only string containing the name.
     481 * @param   enmType         A valid filesystem ID.  If outside the valid range,
     482 *                          the returned string will be pointing to a static
     483 *                          memory buffer which will be changed on subsequent
     484 *                          calls to this function by any thread.
     485 */
     486RTDECL(const char *) RTFsTypeName(RTFSTYPE enmType);
    419487
    420488/**
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r30324 r30365  
    24212421            hrc = pMachine->COMGETTER(SnapshotFolder)(strSnap.asOutParam());            H();
    24222422            Utf8Str utfSnap = Utf8Str(strSnap);
    2423             uint32_t typeFile, typeSnap;
    2424             rc = RTFsQueryType(utfFile.c_str(), &typeFile);
     2423            RTFSTYPE enmFsTypeFile;
     2424            RTFSTYPE enmFsTypeSnap;
     2425            rc = RTFsQueryType(utfFile.c_str(), &enmFsTypeFile);
    24252426            if (RT_SUCCESS(rc))
    2426                 rc = RTFsQueryType(utfSnap.c_str(), &typeSnap);
     2427                rc = RTFsQueryType(utfSnap.c_str(), &enmFsTypeSnap);
    24272428            ULONG64 u64Size;
    24282429            hrc = pMedium->COMGETTER(LogicalSize)(&u64Size);                            H();
     
    24312432            {
    24322433#ifdef RT_OS_WINDOWS
    2433                 if (   typeFile == RTFS_FS_TYPE_FAT
     2434                if (   enmFsTypeFile == RTFSTYPE_FAT
    24342435                    && u64Size >= _4G)
    24352436                {
     
    24462447                }
    24472448#else /* !RT_OS_WINDOWS */
    2448                 if (   typeFile == RTFS_FS_TYPE_FAT
    2449                     || typeFile == RTFS_FS_TYPE_EXT
    2450                     || typeFile == RTFS_FS_TYPE_EXT2
    2451                     || typeFile == RTFS_FS_TYPE_EXT3
    2452                     || typeFile == RTFS_FS_TYPE_EXT4)
     2449                if (   enmFsTypeFile == RTFSTYPE_FAT
     2450                    || enmFsTypeFile == RTFSTYPE_EXT
     2451                    || enmFsTypeFile == RTFSTYPE_EXT2
     2452                    || enmFsTypeFile == RTFSTYPE_EXT3
     2453                    || enmFsTypeFile == RTFSTYPE_EXT4)
    24532454                {
    24542455                    RTFILE file;
     
    24862487                 * Here we test only for a FAT partition as we had to create a dummy file otherwise
    24872488                 */
    2488                 if (   typeSnap == RTFS_FS_TYPE_FAT
     2489                if (   enmFsTypeSnap == RTFSTYPE_FAT
    24892490                    && u64Size >= _4G
    24902491                    && !mfSnapshotFolderSizeWarningShown)
     
    25222523                if (   (uCaps & MediumFormatCapabilities_Asynchronous)
    25232524                    && !fUseHostIOCache
    2524                     && (   typeFile == RTFS_FS_TYPE_EXT4
    2525                         || typeFile == RTFS_FS_TYPE_XFS))
     2525                    && (   enmFsTypeFile == RTFSTYPE_EXT4
     2526                        || enmFsTypeFile == RTFSTYPE_XFS))
    25262527                {
    25272528                    setVMRuntimeErrorCallbackF(pVM, this, 0,
     
    25362537                               "onto a different file system.\n"
    25372538                               "The host I/O cache will now be enabled for this medium"),
    2538                             strFile.raw(), typeFile == RTFS_FS_TYPE_EXT4 ? "ext4" : "xfs");
     2539                            strFile.raw(), enmFsTypeFile == RTFSTYPE_EXT4 ? "ext4" : "xfs");
    25392540                    fUseHostIOCache = true;
    25402541                }
    25412542                else if (   (uCaps & MediumFormatCapabilities_Asynchronous)
    25422543                         && !fUseHostIOCache
    2543                          && (   typeSnap == RTFS_FS_TYPE_EXT4
    2544                              || typeSnap == RTFS_FS_TYPE_XFS)
     2544                         && (   enmFsTypeSnap == RTFSTYPE_EXT4
     2545                             || enmFsTypeSnap == RTFSTYPE_XFS)
    25452546                         && !mfSnapshotFolderExt4WarningShown)
    25462547                {
     
    25562557                               "onto a different file system.\n"
    25572558                               "The host I/O cache will now be enabled for this medium"),
    2558                             typeSnap == RTFS_FS_TYPE_EXT4 ? "ext4" : "xfs");
     2559                            enmFsTypeSnap == RTFSTYPE_EXT4 ? "ext4" : "xfs");
    25592560                    fUseHostIOCache = true;
    25602561                    mfSnapshotFolderExt4WarningShown = true;
  • trunk/src/VBox/Runtime/r3/fs.cpp

    r28800 r30365  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4040
    4141#include <iprt/fs.h>
     42#include "internal/iprt.h"
     43
     44#include <iprt/asm.h>
    4245#include <iprt/assert.h>
     46#include <iprt/ctype.h>
     47#include <iprt/path.h>
     48#include <iprt/string.h>
    4349#include <iprt/time.h>
    44 #include <iprt/string.h>
    45 #include <iprt/path.h>
    46 #include <iprt/ctype.h>
    4750#include "internal/fs.h"
    4851
     
    292295    pObjInfo->Attr.u.Unix.Device          = pStat->st_rdev;
    293296}
    294 
    295297#endif /* !RT_OS_WINDOWS */
     298
     299
     300RTDECL(const char *) RTFsTypeName(RTFSTYPE enmType)
     301{
     302    switch (enmType)
     303    {
     304        case RTFSTYPE_UNKNOWN:      return "unknown";
     305        case RTFSTYPE_UDF:          return "udf";
     306        case RTFSTYPE_ISO9660:      return "iso9660";
     307        case RTFSTYPE_FUSE:         return "fuse";
     308        case RTFSTYPE_VBOXSHF:      return "vboxshf";
     309
     310        case RTFSTYPE_EXT:          return "ext";
     311        case RTFSTYPE_EXT2:         return "ext2";
     312        case RTFSTYPE_EXT3:         return "ext3";
     313        case RTFSTYPE_EXT4:         return "ext4";
     314        case RTFSTYPE_XFS:          return "xfs";
     315        case RTFSTYPE_CIFS:         return "cifs";
     316        case RTFSTYPE_SMBFS:        return "smbfs";
     317        case RTFSTYPE_TMPFS:        return "tmpfs";
     318        case RTFSTYPE_SYSFS:        return "sysfs";
     319        case RTFSTYPE_PROC:         return "proc";
     320
     321        case RTFSTYPE_NTFS:         return "ntfs";
     322        case RTFSTYPE_FAT:          return "fat";
     323
     324        case RTFSTYPE_ZFS:          return "zfs";
     325        case RTFSTYPE_UFS:          return "ufs";
     326        case RTFSTYPE_NFS:          return "nfs";
     327
     328        case RTFSTYPE_HFS:          return "hfs";
     329        case RTFSTYPE_AUTOFS:       return "autofs";
     330        case RTFSTYPE_DEVFS:        return "devfs";
     331
     332        case RTFSTYPE_HPFS:         return "hpfs";
     333        case RTFSTYPE_JFS:          return "jfs";
     334
     335        case RTFSTYPE_END:          return "end";
     336        case RTFSTYPE_32BIT_HACK:   break;
     337    }
     338
     339    /* Don't put this in as 'default:', we wish GCC to warn about missing cases. */
     340    static char                 s_asz[4][64];
     341    static uint32_t volatile    s_i = 0;
     342    uint32_t i = ASMAtomicIncU32(&s_i) % RT_ELEMENTS(s_asz);
     343    RTStrPrintf(s_asz[i], sizeof(s_asz[i]), "type=%d", enmType);
     344    return s_asz[i];
     345}
     346
  • trunk/src/VBox/Runtime/r3/posix/fs-posix.cpp

    r30324 r30365  
    171171
    172172
    173 RTR3DECL(int) RTFsQueryType(const char *pszFsPath, uint32_t *pu32Type)
    174 {
     173RTR3DECL(int) RTFsQueryType(const char *pszFsPath, PRTFSTYPE penmType)
     174{
     175    *penmType = RTFSTYPE_UNKNOWN;
     176
    175177    /*
    176178     * Validate input.
    177179     */
    178     AssertMsgReturn(VALID_PTR(pszFsPath) && *pszFsPath, ("%p", pszFsPath), VERR_INVALID_PARAMETER);
     180    AssertPtrReturn(pszFsPath, VERR_INVALID_POINTER);
     181    AssertReturn(*pszFsPath, VERR_INVALID_PARAMETER);
    179182
    180183    /*
     
    186189    if (RT_SUCCESS(rc))
    187190    {
    188         *pu32Type = RTFS_FS_TYPE_UNKNOWN;
    189 
    190191        struct stat Stat;
    191192        if (!stat(pszNativeFsPath, &Stat))
     
    197198            if (mounted)
    198199            {
    199                 char szBuf[1024];
    200                 struct stat mntStat;
    201                 struct mntent mntEnt;
     200                char            szBuf[1024];
     201                struct stat     mntStat;
     202                struct mntent   mntEnt;
    202203                while (getmntent_r(mounted, &mntEnt, szBuf, sizeof(szBuf)))
    203204                {
     
    207208                        {
    208209                            if (!strcmp("ext4", mntEnt.mnt_type))
    209                                 *pu32Type = RTFS_FS_TYPE_EXT4;
     210                                *penmType = RTFSTYPE_EXT4;
    210211                            else if (!strcmp("ext3", mntEnt.mnt_type))
    211                                 *pu32Type = RTFS_FS_TYPE_EXT3;
     212                                *penmType = RTFSTYPE_EXT3;
    212213                            else if (!strcmp("ext2", mntEnt.mnt_type))
    213                                 *pu32Type = RTFS_FS_TYPE_EXT2;
     214                                *penmType = RTFSTYPE_EXT2;
     215                            else if (!strcmp("jfs", mntEnt.mnt_type))
     216                                *penmType = RTFSTYPE_JFS;
    214217                            else if (!strcmp("xfs", mntEnt.mnt_type))
    215                                 *pu32Type = RTFS_FS_TYPE_XFS;
     218                                *penmType = RTFSTYPE_XFS;
    216219                            else if (   !strcmp("vfat", mntEnt.mnt_type)
    217220                                     || !strcmp("msdos", mntEnt.mnt_type))
    218                                 *pu32Type = RTFS_FS_TYPE_FAT;
     221                                *penmType = RTFSTYPE_FAT;
     222                            else if (!strcmp("ntfs", mntEnt.mnt_type))
     223                                *penmType = RTFSTYPE_NTFS;
     224                            else if (!strcmp("hpfs", mntEnt.mnt_type))
     225                                *penmType = RTFSTYPE_HPFS;
     226                            else if (!strcmp("ufs", mntEnt.mnt_type))
     227                                *penmType = RTFSTYPE_UFS;
    219228                            else if (!strcmp("tmpfs", mntEnt.mnt_type))
    220                                 *pu32Type = RTFS_FS_TYPE_TMPFS;
     229                                *penmType = RTFSTYPE_TMPFS;
    221230                            else if (!strcmp("hfsplus", mntEnt.mnt_type))
    222                                 *pu32Type = RTFS_FS_TYPE_HFS;
     231                                *penmType = RTFSTYPE_HFS;
     232                            else if (!strcmp("udf", mntEnt.mnt_type))
     233                                *penmType = RTFSTYPE_UDF;
     234                            else if (!strcmp("iso9660", mntEnt.mnt_type))
     235                                *penmType = RTFSTYPE_ISO9660;
     236                            else if (!strcmp("smbfs", mntEnt.mnt_type))
     237                                *penmType = RTFSTYPE_SMBFS;
     238                            else if (!strcmp("cifs", mntEnt.mnt_type))
     239                                *penmType = RTFSTYPE_CIFS;
     240                            else if (!strcmp("nfs", mntEnt.mnt_type))
     241                                *penmType = RTFSTYPE_NFS;
     242                            else if (!strcmp("nfs4", mntEnt.mnt_type))
     243                                *penmType = RTFSTYPE_NFS;
     244                            else if (!strcmp("sysfs", mntEnt.mnt_type))
     245                                *penmType = RTFSTYPE_SYSFS;
     246                            else if (!strcmp("proc", mntEnt.mnt_type))
     247                                *penmType = RTFSTYPE_PROC;
     248                            else if (   !strcmp("fuse", mntEnt.mnt_type)
     249                                     || !strncmp("fuse.", mntEnt.mnt_type, 5))
     250                                *penmType = RTFSTYPE_FUSE;
    223251                            else
    224252                            {
     
    232260                endmntent(mounted);
    233261            }
     262
    234263#elif defined(RT_OS_SOLARIS)
    235264            if (!strcmp("zfs", Stat.st_fstype))
    236                 *pu32Type = RTFS_FS_TYPE_ZFS;
     265                *penmType = RTFSTYPE_ZFS;
     266            else if (!strcmp("ufs", Stat.st_fstype))
     267                *penmType = RTFSTYPE_UFS;
     268            else if (!strcmp("nfs", Stat.st_fstype))
     269                *penmType = RTFSTYPE_NFS;
     270
    237271#elif defined(RT_OS_DARWIN)
    238272            struct statfs statfsBuf;
     
    240274            {
    241275                if (!strcmp("hfs", statfsBuf.f_fstypename))
    242                     *pu32Type = RTFS_FS_TYPE_HFS;
     276                    *penmType = RTFSTYPE_HFS;
    243277                else if (   !strcmp("fat", statfsBuf.f_fstypename)
    244278                         || !strcmp("msdos", statfsBuf.f_fstypename))
    245                     *pu32Type = RTFS_FS_TYPE_FAT;
     279                    *penmType = RTFSTYPE_FAT;
    246280                else if (!strcmp("ntfs", statfsBuf.f_fstypename))
    247                     *pu32Type = RTFS_FS_TYPE_NTFS;
     281                    *penmType = RTFSTYPE_NTFS;
    248282                else if (!strcmp("autofs", statfsBuf.f_fstypename))
    249                     *pu32Type = RTFS_FS_TYPE_AUTOFS;
     283                    *penmType = RTFSTYPE_AUTOFS;
    250284                else if (!strcmp("devfs", statfsBuf.f_fstypename))
    251                     *pu32Type = RTFS_FS_TYPE_DEVFS;
     285                    *penmType = RTFSTYPE_DEVFS;
    252286                else if (!strcmp("nfs", statfsBuf.f_fstypename))
    253                     *pu32Type = RTFS_FS_TYPE_NFS;
     287                    *penmType = RTFSTYPE_NFS;
    254288            }
    255289            else
  • trunk/src/VBox/Runtime/r3/win/fs-win.cpp

    r30279 r30365  
    334334}
    335335
    336 RTR3DECL(int) RTFsQueryType(const char *pszFsPath, uint32_t *pu32Type)
    337 {
    338     int rc = VINF_SUCCESS;
    339 
    340     *pu32Type = RTFS_FS_TYPE_UNKNOWN;
    341 
    342     HANDLE hFile = CreateFile(pszFsPath,
    343                               GENERIC_READ,
    344                               FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
    345                               NULL,
    346                               OPEN_EXISTING,
    347                               FILE_FLAG_BACKUP_SEMANTICS,
    348                               NULL);
    349     if (hFile != INVALID_HANDLE_VALUE)
    350     {
    351         char abBuf[8192];
    352         IO_STATUS_BLOCK Ios;
    353         NTSTATUS rcNt = NtQueryVolumeInformationFile(hFile, &Ios,
    354                                                      abBuf, sizeof(abBuf),
    355                                                      FileFsAttributeInformation);
    356         if (rcNt >= 0)
    357         {
    358             PFILE_FS_ATTRIBUTE_INFORMATION pFsAttrInfo = (PFILE_FS_ATTRIBUTE_INFORMATION)abBuf;
    359             if (   pFsAttrInfo->FileSystemName[0] == 'N'
    360                 && pFsAttrInfo->FileSystemName[1] == 'T'
    361                 && pFsAttrInfo->FileSystemName[2] == 'F'
    362                 && pFsAttrInfo->FileSystemName[3] == 'S'
    363                 && pFsAttrInfo->FileSystemName[4] == '\0')
    364                 *pu32Type = RTFS_FS_TYPE_NTFS;
    365             else if (   pFsAttrInfo->FileSystemName[0] == 'F'
    366                      && pFsAttrInfo->FileSystemName[1] == 'A'
    367                      && pFsAttrInfo->FileSystemName[2] == 'T'
    368                      && (   (   pFsAttrInfo->FileSystemName[3] == '3'
    369                              && pFsAttrInfo->FileSystemName[4] == '2'
    370                              && pFsAttrInfo->FileSystemName[5] == '\0')
    371                          || pFsAttrInfo->FileSystemName[3] == '\0'))
    372                 /* This is either FAT32 or FAT12/16. IMO it doesn't make
    373                  * sense to distinguish more detailed because we cannot
    374                  * easily distinguish between these FAT types on Linux
    375                  * and users who put some image file on an FAT16 partition
    376                  * should know what they are doing. */
    377                 *pu32Type = RTFS_FS_TYPE_FAT;
     336
     337/**
     338 * Internal helper for comparing a WCHAR string with a char string.
     339 *
     340 * @returns 0 if equal, -1 if @a psz1 < @a psz2, 1 if @a psz1 < @a psz2.
     341 * @param   pwsz1               The first string.
     342 * @param   psz2                The second string.
     343 */
     344static int rtFsWinCmpUtf16(WCHAR const *pwsz1, const char *psz2)
     345{
     346    for (;;)
     347    {
     348        unsigned ch1 = *pwsz1++;
     349        unsigned ch2 = (unsigned char)*psz2++;
     350        if (ch1 != ch2)
     351            return ch1 < ch2 ? -1 : 1;
     352        if (!ch1)
     353            return 0;
     354    }
     355}
     356
     357
     358RTR3DECL(int) RTFsQueryType(const char *pszFsPath, PRTFSTYPE penmType)
     359{
     360    *penmType = RTFSTYPE_UNKNOWN;
     361
     362    AssertPtrReturn(pszFsPath, VERR_INVALID_POINTER);
     363    AssertReturn(*pszFsPath, VERR_INVALID_PARAMETER);
     364
     365    /*
     366     * Convert the path and try open it.
     367     */
     368    PRTUTF16 pwszFsPath;
     369    int rc = RTStrToUtf16(pszFsPath, &pwszFsPath);
     370    if (RT_SUCCESS(rc))
     371    {
     372        HANDLE hFile = CreateFileW(pwszFsPath,
     373                                   GENERIC_READ,
     374                                   FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
     375                                   NULL,
     376                                   OPEN_EXISTING,
     377                                   FILE_FLAG_BACKUP_SEMANTICS,
     378                                   NULL);
     379        if (hFile != INVALID_HANDLE_VALUE)
     380        {
     381            /*
     382             * Use the NT api directly to get the file system name.
     383             */
     384            char            abBuf[8192];
     385            IO_STATUS_BLOCK Ios;
     386            NTSTATUS        rcNt = NtQueryVolumeInformationFile(hFile, &Ios,
     387                                                                abBuf, sizeof(abBuf),
     388                                                                FileFsAttributeInformation);
     389            if (rcNt >= 0)
     390            {
     391                PFILE_FS_ATTRIBUTE_INFORMATION pFsAttrInfo = (PFILE_FS_ATTRIBUTE_INFORMATION)abBuf;
     392
     393                if (!rtFsWinCmpUtf16(pFsAttrInfo->FileSystemName, "NTFS"))
     394                    *penmType = RTFSTYPE_NTFS;
     395                else if (!rtFsWinCmpUtf16(pFsAttrInfo->FileSystemName, "FAT"))
     396                    *penmType = RTFSTYPE_FAT;
     397                else if (!rtFsWinCmpUtf16(pFsAttrInfo->FileSystemName, "FAT32"))
     398                    *penmType = RTFSTYPE_FAT;
     399                else if (!rtFsWinCmpUtf16(pFsAttrInfo->FileSystemName, "VBoxSharedFolderFS"))
     400                    *penmType = RTFSTYPE_VBOXSHF;
     401            }
     402            else
     403                rc = RTErrConvertFromNtStatus(rcNt);
     404            CloseHandle(hFile);
    378405        }
    379         /* else: Is RTFS_FS_UNKNOWN suffient or should we return an error? */
    380         CloseHandle(hFile);
    381     }
    382 
     406        else
     407            rc = RTErrConvertFromWin32(GetLastError());
     408        RTUtf16Free(pwszFsPath);
     409    }
    383410    return rc;
    384411}
  • trunk/src/VBox/Runtime/testcase/tstRTFsQueries.cpp

    r30281 r30365  
    7777        }
    7878
    79         uint32_t u32Type;
    80         rc = RTFsQueryType(argv[i], &u32Type);
    81         if (RT_FAILURE(rc))
     79        RTFSTYPE enmType;
     80        rc = RTFsQueryType(argv[i], &enmType);
     81        if (RT_SUCCESS(rc))
     82            RTPrintf("tstRTFsQueries: file system type is '%s'\n", RTFsTypeName(enmType));
     83        else
    8284        {
    8385            RTPrintf("tstRTFsQueries: RTFsQueryType failed, rc=%Rrc\n", rc);
    8486            cErrors++;
    85         }
    86         else
    87         {
    88             static const char *s_apszType[] =
    89             {
    90                 "unknown",
    91                 "ext",
    92                 "ext2",
    93                 "ext3",
    94                 "ext4",
    95                 "tmpfs",
    96                 "jfs",
    97                 "nfs",
    98                 "hfs",
    99                 "cifs",
    100                 "fat",
    101                 "ntfs",
    102                 "zfs",
    103                 "xfs",
    104                 "autofs",
    105                 "devfs"
    106             };
    107 
    108             if (u32Type < RT_ELEMENTS(s_apszType))
    109                 RTPrintf("tstRTFsQueries: file system type is '%s'\n", s_apszType[u32Type]);
    110             else
    111                 RTPrintf("tstRTFsQueries: unknown file system type %d\n", u32Type);
    11287        }
    11388
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