- Update to r53061
[reactos.git] / drivers / filesystems / cdfs / fsctl.c
index 897c081..a8543db 100644 (file)
@@ -46,7 +46,7 @@ CdfsGetPVDData(PUCHAR Buffer,
                PCDINFO CdInfo)
 {
     PPVD Pvd;
-    ULONG i;
+    USHORT i;
     PUCHAR pc;
     PWCHAR pw;
 
@@ -63,21 +63,34 @@ CdfsGetPVDData(PUCHAR Buffer,
     for (i = 0; i < 2048; i += 4)
     {
         /* DON'T optimize this to ULONG!!! (breaks overflow) */
-        Serial.Part[0] += Buffer[i+3];
-        Serial.Part[1] += Buffer[i+2];
-        Serial.Part[2] += Buffer[i+1];
         Serial.Part[3] += Buffer[i+0];
+        Serial.Part[2] += Buffer[i+1];
+        Serial.Part[1] += Buffer[i+2];
+        Serial.Part[0] += Buffer[i+3];
     }
     CdInfo->SerialNumber = Serial.Value;
 
     /* Extract the volume label */
     pc = Pvd->VolumeId;
     pw = CdInfo->VolumeLabel;
-    for (i = 0; i < MAXIMUM_VOLUME_LABEL_LENGTH && *pc != ' '; i++)
+    for (i = 0; i < (MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)) - 1; i++)
     {
         *pw++ = (WCHAR)*pc++;
     }
     *pw = 0;
+
+    /* Trim trailing spaces */
+    while (pw > CdInfo->VolumeLabel)
+    {
+        if (*--pw != ' ') break;
+
+        /* Remove the space */
+        *pw = '\0';
+
+        /* Decrease size */
+        i--;
+    }
+
     CdInfo->VolumeLabelLength = i * sizeof(WCHAR);
 
     CdInfo->VolumeSpaceSize = Pvd->VolumeSpaceSizeL;
@@ -346,7 +359,7 @@ CdfsMountVolume(PDEVICE_OBJECT DeviceObject,
 
     Vpb->SerialNumber = CdInfo.SerialNumber;
     Vpb->VolumeLabelLength = CdInfo.VolumeLabelLength;
-    RtlCopyMemory(Vpb->VolumeLabel, CdInfo.VolumeLabel, CdInfo.VolumeLabelLength * sizeof(WCHAR));
+    RtlCopyMemory(Vpb->VolumeLabel, CdInfo.VolumeLabel, CdInfo.VolumeLabelLength);
     RtlCopyMemory(&DeviceExt->CdInfo, &CdInfo, sizeof(CDINFO));
 
     NewDeviceObject->Vpb = DeviceToMount->Vpb;
@@ -553,6 +566,7 @@ CdfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
 
     switch (Stack->MinorFunction)
     {
+    case IRP_MN_KERNEL_CALL:
     case IRP_MN_USER_FS_REQUEST:
         switch (Stack->Parameters.DeviceIoControl.IoControlCode)
         {