From: Zebediah Figura Subject: [PATCH v2 2/5] mountmgr: Assign a unique nonzero serial to all volumes. Message-Id: <20200407021034.965424-2-zfigura@codeweavers.com> Date: Mon, 6 Apr 2020 21:10:31 -0500 In-Reply-To: <20200407021034.965424-1-zfigura@codeweavers.com> References: <20200407021034.965424-1-zfigura@codeweavers.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=17823 Signed-off-by: Zebediah Figura --- There might be a better way of deriving a serial from a UUID, but by my understanding, Linux uses version 4 UUIDs, and taking the last 4 bytes is as random as it can be. I don't know about Mac. For folders such as drive_c which are not separate host systems, this returns a serial with the high byte containing the DOS drive letter, and the other three bytes zero, so it would seem to be exactly as unique and stable as the volume GUID itself. dlls/mountmgr.sys/device.c | 3 +++ dlls/ntdll/tests/file.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c index 8fb984579e3..f68ab4de9b4 100644 --- a/dlls/mountmgr.sys/device.c +++ b/dlls/mountmgr.sys/device.c @@ -1123,6 +1123,9 @@ static NTSTATUS set_volume_info( struct volume *volume, struct dos_drive *drive, } } + if (!volume->serial) + memcpy(&volume->serial, &volume->guid.Data4[4], sizeof(DWORD)); + if (!volume->mount) volume->mount = add_volume_mount_point( disk_device->dev_obj, &disk_device->name, &volume->guid ); if (drive && !drive->mount) diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 7b833fc9e86..f2e4ff069fd 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -3874,7 +3874,7 @@ static void test_query_volume_information_file(void) io.Information); todo_wine ok(ffvi->VolumeCreationTime.QuadPart != 0, "Missing VolumeCreationTime\n"); - todo_wine ok(ffvi->VolumeSerialNumber != 0, "Missing VolumeSerialNumber\n"); + ok(ffvi->VolumeSerialNumber != 0, "Missing VolumeSerialNumber\n"); ok(ffvi->SupportsObjects == 1,"expected 1, got %d\n", ffvi->SupportsObjects); ok(ffvi->VolumeLabelLength == lstrlenW(ffvi->VolumeLabel) * sizeof(WCHAR), "got %d\n", ffvi->VolumeLabelLength); -- 2.26.0