Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQUEST] fio 3.31 Windows #87

Open
dsm opened this issue Aug 24, 2022 · 2 comments
Open

[REQUEST] fio 3.31 Windows #87

dsm opened this issue Aug 24, 2022 · 2 comments

Comments

@dsm
Copy link
Contributor

dsm commented Aug 24, 2022

Beginning with fio 3.31 Windows installers are available on GitHub at https://github.com/axboe/fio/releases can we support Windows OS ?

@dsm
Copy link
Contributor Author

dsm commented Oct 11, 2022

any progress ? latest appimage with fio 3.32 and i think fio support windows and why we can't support ?

@MeowKatee
Copy link

MeowKatee commented Feb 4, 2024

To support windows, we need:

  • set windowsaio as default ioengine for windows, libaio for linux, (posixaio for android)
  • path helper function, if any, should accept '/', '\' or even mixed path

List storage devices

Logical Devices

GetLogicalDrives returns a bit mask presents drive letters in use as bit_1_pos + 'A'

from win32api import GetLogicalDrives

# for example, `0b_1100` means there are C:/ and D:/.
def logical_drives():
   bit_mask = GetLogicalDrives()
   for offset in range(26):
      alphabet = chr(ord('A') + offset)
      if (1 << offset) & bit_mask:
          yield alphabet

Volumes

With Powershell1:

Get-Volume

With mountvol.exe

mountvol /L

With FindFirstVolumeW and FindNextVolumeW

from winsys._kernel32 import FindFirstVolume, FindNextVolume
handle, first = FindFirstVolume()
volumes = [first]

while (volume := FindNextVolume(handle)) and isinstance(volume, str):
    volumes.append(volume)

print(volumes)

Get device model

drive letter -> Model

With Powershell2

Get-Disk (Get-Partition -DriveLetter 'C').DiskNumber | select -Prop FriendlyName

drive letter or any volume path -> DeviceId

With Powershell2 (drive letters only)

(Get-Partition -DriveLetter 'C').DiskNumber

With IOCTL_STORAGE_GET_DEVICE_NUMBER

#include <stdio.h>
#include <Windows.h>
#include <fileapi.h>
#include <winioctl.h>

int get_disk_number_by_drive_letter(char letter) {
    char logical_drive_path[7];
    sprintf(logical_drive_path, "\\\\.\\%c:", letter);
    // '\\?\Volume{<GUID>}' is also applicable to this
    HANDLE hDevice = CreateFileA(logical_drive_path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
    if (hDevice == INVALID_HANDLE_VALUE) {
        fprintf(stderr, "Failed to open device. Error code: %lu\n", GetLastError());
        return -1;
    }

    STORAGE_DEVICE_NUMBER device_number;
    DWORD bytes_returned;
    if (!DeviceIoControl(hDevice, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0, &device_number, sizeof(device_number), &bytes_returned, NULL)) {
        fprintf(stderr, "IOCTL_STORAGE_GET_DEVICE_NUMBER failed. Error code: %lu\n", GetLastError());
        CloseHandle(hDevice);
        return -1;
    }

    CloseHandle(hDevice);
    return device_number.DeviceNumber;
}

DeviceId -> Model

With Powershell

Get-Disk | select -Prop Number,FriendlyName

With wmic

wmic diskdrive get index,model

With wmi

from win32com.client import GetObject

def get_diskdrive_info():
    wmi = GetObject(r"winmgmts:\\.\root\cimv2")
    disks = wmi.ExecQuery("SELECT * FROM Win32_DiskDrive")

    disk_info = {disk.Index: disk.Model for disk in disks}
    return disk_info

disk_info = sorted(get_diskdrive_info().items())

for index, model in disk_info:
    print(f"{index}: {model}")

Anyway, the most accurate way is to call smartctl ... X:

Additional (maybe) useful syscalls

QueryDosDeviceW should be the proper way to match logical device with \Device\HarddiskVolumeX.

GetDiskFreeSpaceExA gives free space avaliable for the caller user, total disk size, and total free space.

from win32file import GetDiskFreeSpaceEx
list(map(lambda size: size / (1024**3), GetDiskFreeSpaceEx("C:")))
# [58.516212463378906, 117.97948837280273, 58.516212463378906]

Thanks 3 for cleaning up my confusion to Win32 Paths.

Footnotes

  1. https://winreg-kb.readthedocs.io/en/latest/sources/system-keys/Mounted-devices.html#notes)

  2. https://superuser.com/a/1147305 2

  3. https://chrisdenton.github.io/omnipath/Overview.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants