From 4382c9902f28a99e2163c9fe583d3f4861e6043e Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Wed, 13 Feb 2013 21:53:46 -0500 Subject: [PATCH 1/1] Windows: Add Cell to FS Volume Information Label Add the Cell name to the VolumeLabel field of the FILE_FS_VOLUME_INFORMATION structure. This permits "cell#volume" to be displayed by cmd.exe's DIR command and other applications that call the GetVolumeInformation() or GetVolumeInformationByHandle() Win32 APIs. Change-Id: I6cc7a7c2b79cb7d0d96cbddcf34dce68e52bf987 Reviewed-on: http://gerrit.openafs.org/9106 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSVolumeInfo.cpp | 38 +++++++++++++++++++-------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSVolumeInfo.cpp b/src/WINNT/afsrdr/kernel/lib/AFSVolumeInfo.cpp index 2f1ae40..6e57fdb 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSVolumeInfo.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSVolumeInfo.cpp @@ -287,7 +287,7 @@ AFSQueryFsVolumeInfo( IN AFSVolumeInfoCB *VolumeInfo, { NTSTATUS ntStatus = STATUS_BUFFER_TOO_SMALL; - ULONG ulCopyLength; + ULONG ulLabelLength; RtlZeroMemory( Buffer, *Length); @@ -295,18 +295,17 @@ AFSQueryFsVolumeInfo( IN AFSVolumeInfoCB *VolumeInfo, if( *Length >= (ULONG)sizeof( FILE_FS_VOLUME_INFORMATION)) { - if( *Length >= (ULONG)(FIELD_OFFSET( FILE_FS_VOLUME_INFORMATION, VolumeLabel) + (LONG)VolumeInfo->VolumeLabelLength)) - { + ulLabelLength = VolumeInfo->VolumeLabelLength + + VolumeInfo->CellLength + sizeof( WCHAR); - ulCopyLength = (LONG)VolumeInfo->VolumeLabelLength; + if( *Length >= (ULONG)(FIELD_OFFSET( FILE_FS_VOLUME_INFORMATION, VolumeLabel) + ulLabelLength)) + { ntStatus = STATUS_SUCCESS; } else { - ulCopyLength = *Length - FIELD_OFFSET( FILE_FS_VOLUME_INFORMATION, VolumeLabel); - ntStatus = STATUS_BUFFER_OVERFLOW; } @@ -314,20 +313,37 @@ AFSQueryFsVolumeInfo( IN AFSVolumeInfoCB *VolumeInfo, Buffer->VolumeSerialNumber = VolumeInfo->VolumeID; - Buffer->VolumeLabelLength = VolumeInfo->VolumeLabelLength; + Buffer->VolumeLabelLength = ulLabelLength; Buffer->SupportsObjects = FALSE; *Length -= FIELD_OFFSET( FILE_FS_VOLUME_INFORMATION, VolumeLabel); - if( ulCopyLength > 0) + if( *Length > 0) { RtlCopyMemory( Buffer->VolumeLabel, - VolumeInfo->VolumeLabel, - ulCopyLength); + VolumeInfo->Cell, + min( *Length, VolumeInfo->CellLength)); + + *Length -= min( *Length, VolumeInfo->CellLength); + + if ( *Length >= sizeof( WCHAR)) + { - *Length -= ulCopyLength; + Buffer->VolumeLabel[ VolumeInfo->CellLength / sizeof( WCHAR)] = L'#'; + + *Length -= sizeof( WCHAR); + + if ( *Length > 0) { + + RtlCopyMemory( &Buffer->VolumeLabel[ (VolumeInfo->CellLength + sizeof( WCHAR)) / sizeof( WCHAR)], + VolumeInfo->VolumeLabel, + min( *Length, VolumeInfo->VolumeLabelLength)); + + *Length -= min( *Length, VolumeInfo->VolumeLabelLength); + } + } } } -- 1.9.4