jDiskMark / jdm-java

1 stars 0 forks source link

micro SD over USB reports 0/0 (usage/available) #21

Closed jamesmarkchan closed 6 months ago

jamesmarkchan commented 6 months ago

usb-micro-sd-usage-bug Tyler found this issue with his USB micro SD drive.

jamesmarkchan commented 6 months ago

Looks like this is also with USB stick storage devices image

*** starting new worker thread
os: Windows 11

DiskModel                        DriveLetter
---------                        -----------
WD_BLACK SN850X 1000GB           E:
MSI M450 1TB                     C:
Samsung SSD 990 PRO 1TB          D:
 USB  SanDisk 3.2Gen1 USB Device F:
model is: USB  SanDisk 3.2Gen1 USB Device
deviceModel=USB  SanDisk 3.2Gen1 USB Device
Mar 10, 2024 9:07:23 AM jdiskmark.BenchmarkWorker doInBackground
SEVERE: null
java.io.IOException: Command execution failed with exit code: 1
        at jdiskmark.Util.getDiskUsage(Util.java:198)
        at jdiskmark.BenchmarkWorker.doInBackground(BenchmarkWorker.java:72)
        at jdiskmark.BenchmarkWorker.doInBackground(BenchmarkWorker.java:28)
        at java.desktop/javax.swing.SwingWorker$1.call(Unknown Source)
        at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
        at java.desktop/javax.swing.SwingWorker.run(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)

Sample(WRITE): 1 bwMBs=24.247 avg=24.247 accessTimeMs=20.621261596679688
jamesmarkchan commented 6 months ago

Here is how the fsutil output differs on a FAT32 partition

C:\Users\james>fsutil volume diskfree F:\jDiskMarkData
A local NTFS volume is required for this operation.
Total free bytes        : 20,601,946,112 (19.2 GB)
Total bytes             : 30,769,037,312 (28.7 GB)
Total quota free bytes  : 20,601,946,112 (19.2 GB)

vs our expected NTFS

PS C:\Users\james> fsutil volume diskfree c:\
Total free bytes                : 548,036,538,368 (510.4 GB)
Total bytes                     : 999,137,734,656 (930.5 GB)
Total quota free bytes          : 548,036,538,368 (510.4 GB)
Unavailable pool bytes          :               0 (  0.0 KB)
Quota unavailable pool bytes    :               0 (  0.0 KB)
Used bytes                      : 445,687,042,048 (415.1 GB)
Total Reserved bytes            :   5,414,154,240 (  5.0 GB)
Volume storage reserved bytes   :   5,370,494,976 (  5.0 GB)
Available committed bytes       :               0 (  0.0 KB)
Pool available bytes            :               0 (  0.0 KB)
jamesmarkchan commented 6 months ago

The good thing is we parse the common fields for both FAT32 and NTFS drives so this code will add support for windows USB drives:

        int exitCode = process.waitFor();
        if (exitCode != 0) {
            if (App.os.startsWith("Windows")) {
                /* GH-21 windows parsing handles non NTFS partitions like
                 * FAT32 used for USB sticks
                 */
                System.out.println("exit code: " + exitCode);
            } else if (App.os.contains("Mac OS")) {
                throw new IOException("Command execution failed with exit code: " + exitCode);
            } else if (App.os.contains("Linux")) {
                throw new IOException("Command execution failed with exit code: " + exitCode);
            }
        }
jamesmarkchan commented 6 months ago

jdm-sandisk-3 2g1-32GB-usb-drive just pushed fix to master. next release should support FAT32 usb drives on windows!