Menu

#43 GetDriveTypeW GetDriveTypeA should return DRIVE_RAMDISK

open
nobody
None
2021-12-12
2021-12-07
lev
No

Hello!

Thanks for wonderful application toolkit.

I write app that uses disk IO extensively (for temporary raw video files).
So I must ensure that my software does not broke SSD by wearing it out.
My software checks if provided disk drive is a RAM-drive.
To easy check (without heuristics) it uses disk label and return value of GetDriveTypeW function.
I've found that GetDriveTypeW returns DRIVE_FIXED instead DRIVE_RAMDISK.

Please assign default values for a RAM-disk:
1. return value of GetDriveTypeW to DRIVE_RAMDISK
2. return value (lpVolumeNameBuffer) of GetVolumeInformation to "RAMDISK"

Thanks!

Discussion

  • v77

    v77 - 2021-12-07

    The driver produces drives that are not necessarily ramdisks. And it's not always possible to know whether the volume will be a ramdisk or not (in case of a use of a proxy).

    However, it is possible to know whether a volume belongs to Imdisk or not, with something like:

    DWORD version, data_size;
    HANDLE h = CreateFile("\\\\.\\R:", 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    BOOL is_imdisk = DeviceIoControl(h, IOCTL_IMDISK_QUERY_VERSION, NULL, 0, &version, sizeof version, &data_size, NULL);
    CloseHandle(h);
    
     
  • lev

    lev - 2021-12-11

    I think the driver can ask from a disk implementation for the drive type.

     
  • Olof Lagerkvist

    Olof Lagerkvist - 2021-12-12

    In most cases it is better that DRIVE_FIXED is returned so that ImDisk drives can be used to emulate fixed disk volumes. There is also a RAM disk device type in the kernel that would cause DRIVE_RAMDISK to be returned by GetDriveType, but that device type has lots of limitations and is not suitable for lots of use cases. For example, Windows refuse to format such disks, they need to be pre-loaded with a formatted file system. There are also lots of cases where Windows will refuse to use such disks for various purposes where ImDisk is currently frequently used.

    So, effectively, it would break lots of things to change this and there would be very little pros but lots of cons.

     
  • lev

    lev - 2021-12-12

    Thanks for the exhaustive answer!
    Now, I think the ticket can be moved to an archive.

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.