viofs-svc: use VirtFS device's tag as volume prefix.
@@ -587,25 +587,29 @@ static NTSTATUS GetFileInfoInternal(VIRTFS *VirtFs, uint64_t nodeid,
return Status;
}
-static NTSTATUS GetVolumeInfo(FSP_FILE_SYSTEM *FileSystem,
- FSP_FSCTL_VOLUME_INFO *VolumeInfo)
+static VOID GetVolumeName(HANDLE Device, PWSTR VolumeName,
+ DWORD VolumeNameSize)
{
- VIRTFS *VirtFs = FileSystem->UserContext;
DWORD BytesReturned;
- NTSTATUS Status;
BOOL Result;
- FUSE_STATFS_IN statfs_in;
- FUSE_STATFS_OUT statfs_out;
- Result = DeviceIoControl(VirtFs->Device, IOCTL_VIRTFS_GET_VOLUME_NAME,
- NULL, 0, VolumeInfo->VolumeLabel, sizeof(VolumeInfo->VolumeLabel),
- &BytesReturned, NULL);
+ Result = DeviceIoControl(Device, IOCTL_VIRTFS_GET_VOLUME_NAME, NULL, 0,
+ VolumeName, VolumeNameSize, &BytesReturned, NULL);
if (Result == FALSE)
{
- lstrcpy(VolumeInfo->VolumeLabel, L"VirtFS");
+ lstrcpy(VolumeName, L"Default");
+ }
}
+static NTSTATUS GetVolumeInfo(FSP_FILE_SYSTEM *FileSystem,
+ FSP_FSCTL_VOLUME_INFO *VolumeInfo)
+{
+ VIRTFS *VirtFs = FileSystem->UserContext;
+ NTSTATUS Status;
+ FUSE_STATFS_IN statfs_in;
+ FUSE_STATFS_OUT statfs_out;
+
FUSE_HEADER_INIT(&statfs_in.hdr, FUSE_STATFS, FUSE_ROOT_ID, 0);
Status = VirtFsFuseRequest(VirtFs->Device, &statfs_in, sizeof(statfs_in),
@@ -617,6 +621,10 @@ static NTSTATUS GetVolumeInfo(FSP_FILE_SYSTEM *FileSystem,
VolumeInfo->TotalSize = kstatfs->bsize * kstatfs->blocks;
VolumeInfo->FreeSize = kstatfs->bsize * kstatfs->bavail;
+
+ GetVolumeName(VirtFs->Device, VolumeInfo->VolumeLabel,
+ sizeof(VolumeInfo->VolumeLabel));
+
VolumeInfo->VolumeLabelLength =
(UINT16)(wcslen(VolumeInfo->VolumeLabel) * sizeof(WCHAR));
}
@@ -1624,6 +1632,7 @@ static FSP_FILE_SYSTEM_INTERFACE VirtFsInterface =
static NTSTATUS SvcStart(FSP_SERVICE *Service, ULONG argc, PWSTR *argv)
{
VIRTFS *VirtFs;
+ WCHAR VolumePrefix[MAX_PATH];
FSP_FSCTL_VOLUME_PARAMS VolumeParams;
DWORD SessionId;
// PWSTR MountPoint = L"C:\\Shared Folders\\mytag";
@@ -1664,6 +1673,10 @@ static NTSTATUS SvcStart(FSP_SERVICE *Service, ULONG argc, PWSTR *argv)
return Status;
}
+ lstrcpy(VolumePrefix, L"\\VirtFS\\");
+ GetVolumeName(VirtFs->Device, VolumePrefix + lstrlen(VolumePrefix),
+ sizeof(VolumePrefix) - (lstrlen(VolumePrefix) * sizeof(WCHAR)));
+
FUSE_HEADER_INIT(&init_in.hdr, FUSE_INIT, FUSE_ROOT_ID,
sizeof(init_in.init));
