[FASTFAT]
authorPierre Schweitzer <pierre@reactos.org>
Sat, 18 Feb 2017 18:35:48 +0000 (18:35 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Sat, 18 Feb 2017 18:35:48 +0000 (18:35 +0000)
Move ReadVolumeLabel() to fsctl.c close to functions that need it

svn path=/trunk/; revision=73829

reactos/drivers/filesystems/fastfat/create.c
reactos/drivers/filesystems/fastfat/fsctl.c
reactos/drivers/filesystems/fastfat/vfat.h

index 5edb7cc..fdbd46d 100644 (file)
@@ -94,114 +94,6 @@ vfat8Dot3ToString(
     DPRINT("'%wZ'\n", NameU);
 }
 
-/*
- * FUNCTION: Read the volume label
- */
-NTSTATUS
-ReadVolumeLabel(
-    PDEVICE_EXTENSION DeviceExt,
-    PVPB Vpb)
-{
-    PVOID Context = NULL;
-    ULONG DirIndex = 0;
-    PDIR_ENTRY Entry;
-    PVFATFCB pFcb;
-    LARGE_INTEGER FileOffset;
-    UNICODE_STRING NameU;
-    ULONG SizeDirEntry;
-    ULONG EntriesPerPage;
-    OEM_STRING StringO;
-    NTSTATUS Status = STATUS_SUCCESS;
-
-    NameU.Buffer = Vpb->VolumeLabel;
-    NameU.Length = 0;
-    NameU.MaximumLength = sizeof(Vpb->VolumeLabel);
-    *(Vpb->VolumeLabel) = 0;
-    Vpb->VolumeLabelLength = 0;
-
-    if (vfatVolumeIsFatX(DeviceExt))
-    {
-        SizeDirEntry = sizeof(FATX_DIR_ENTRY);
-        EntriesPerPage = FATX_ENTRIES_PER_PAGE;
-    }
-    else
-    {
-        SizeDirEntry = sizeof(FAT_DIR_ENTRY);
-        EntriesPerPage = FAT_ENTRIES_PER_PAGE;
-    }
-
-    ExAcquireResourceExclusiveLite(&DeviceExt->DirResource, TRUE);
-    pFcb = vfatOpenRootFCB(DeviceExt);
-    ExReleaseResourceLite(&DeviceExt->DirResource);
-
-    FileOffset.QuadPart = 0;
-    _SEH2_TRY
-    {
-        CcMapData(pFcb->FileObject, &FileOffset, SizeDirEntry, MAP_WAIT, &Context, (PVOID*)&Entry);
-    }
-    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
-    {
-        Status = _SEH2_GetExceptionCode();
-    }
-    _SEH2_END;
-    if (NT_SUCCESS(Status))
-    {
-        while (TRUE)
-        {
-            if (ENTRY_VOLUME(DeviceExt, Entry))
-            {
-                /* copy volume label */
-                if (vfatVolumeIsFatX(DeviceExt))
-                {
-                    StringO.Buffer = (PCHAR)Entry->FatX.Filename;
-                    StringO.MaximumLength = StringO.Length = Entry->FatX.FilenameLength;
-                    RtlOemStringToUnicodeString(&NameU, &StringO, FALSE);
-                }
-                else
-                {
-                    vfat8Dot3ToString(&Entry->Fat, &NameU);
-                }
-                Vpb->VolumeLabelLength = NameU.Length;
-                break;
-            }
-            if (ENTRY_END(DeviceExt, Entry))
-            {
-                break;
-            }
-            DirIndex++;
-            Entry = (PDIR_ENTRY)((ULONG_PTR)Entry + SizeDirEntry);
-            if ((DirIndex % EntriesPerPage) == 0)
-            {
-                CcUnpinData(Context);
-                FileOffset.u.LowPart += PAGE_SIZE;
-                _SEH2_TRY
-                {
-                    CcMapData(pFcb->FileObject, &FileOffset, SizeDirEntry, MAP_WAIT, &Context, (PVOID*)&Entry);
-                }
-                _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
-                {
-                    Status = _SEH2_GetExceptionCode();
-                }
-                _SEH2_END;
-                if (!NT_SUCCESS(Status))
-                {
-                    Context = NULL;
-                    break;
-                }
-            }
-        }
-        if (Context)
-        {
-            CcUnpinData(Context);
-        }
-    }
-    ExAcquireResourceExclusiveLite(&DeviceExt->DirResource, TRUE);
-    vfatReleaseFCB(DeviceExt, pFcb);
-    ExReleaseResourceLite(&DeviceExt->DirResource);
-
-    return STATUS_SUCCESS;
-}
-
 /*
  * FUNCTION: Find a file
  */
index 5010300..0082953 100644 (file)
@@ -338,6 +338,115 @@ VfatHasFileSystem(
     return Status;
 }
 
+/*
+ * FUNCTION: Read the volume label
+ */
+static
+NTSTATUS
+ReadVolumeLabel(
+    PDEVICE_EXTENSION DeviceExt,
+    PVPB Vpb)
+{
+    PVOID Context = NULL;
+    ULONG DirIndex = 0;
+    PDIR_ENTRY Entry;
+    PVFATFCB pFcb;
+    LARGE_INTEGER FileOffset;
+    UNICODE_STRING NameU;
+    ULONG SizeDirEntry;
+    ULONG EntriesPerPage;
+    OEM_STRING StringO;
+    NTSTATUS Status = STATUS_SUCCESS;
+
+    NameU.Buffer = Vpb->VolumeLabel;
+    NameU.Length = 0;
+    NameU.MaximumLength = sizeof(Vpb->VolumeLabel);
+    *(Vpb->VolumeLabel) = 0;
+    Vpb->VolumeLabelLength = 0;
+
+    if (vfatVolumeIsFatX(DeviceExt))
+    {
+        SizeDirEntry = sizeof(FATX_DIR_ENTRY);
+        EntriesPerPage = FATX_ENTRIES_PER_PAGE;
+    }
+    else
+    {
+        SizeDirEntry = sizeof(FAT_DIR_ENTRY);
+        EntriesPerPage = FAT_ENTRIES_PER_PAGE;
+    }
+
+    ExAcquireResourceExclusiveLite(&DeviceExt->DirResource, TRUE);
+    pFcb = vfatOpenRootFCB(DeviceExt);
+    ExReleaseResourceLite(&DeviceExt->DirResource);
+
+    FileOffset.QuadPart = 0;
+    _SEH2_TRY
+    {
+        CcMapData(pFcb->FileObject, &FileOffset, SizeDirEntry, MAP_WAIT, &Context, (PVOID*)&Entry);
+    }
+    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+    {
+        Status = _SEH2_GetExceptionCode();
+    }
+    _SEH2_END;
+    if (NT_SUCCESS(Status))
+    {
+        while (TRUE)
+        {
+            if (ENTRY_VOLUME(DeviceExt, Entry))
+            {
+                /* copy volume label */
+                if (vfatVolumeIsFatX(DeviceExt))
+                {
+                    StringO.Buffer = (PCHAR)Entry->FatX.Filename;
+                    StringO.MaximumLength = StringO.Length = Entry->FatX.FilenameLength;
+                    RtlOemStringToUnicodeString(&NameU, &StringO, FALSE);
+                }
+                else
+                {
+                    vfat8Dot3ToString(&Entry->Fat, &NameU);
+                }
+                Vpb->VolumeLabelLength = NameU.Length;
+                break;
+            }
+            if (ENTRY_END(DeviceExt, Entry))
+            {
+                break;
+            }
+            DirIndex++;
+            Entry = (PDIR_ENTRY)((ULONG_PTR)Entry + SizeDirEntry);
+            if ((DirIndex % EntriesPerPage) == 0)
+            {
+                CcUnpinData(Context);
+                FileOffset.u.LowPart += PAGE_SIZE;
+                _SEH2_TRY
+                {
+                    CcMapData(pFcb->FileObject, &FileOffset, SizeDirEntry, MAP_WAIT, &Context, (PVOID*)&Entry);
+                }
+                _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+                {
+                    Status = _SEH2_GetExceptionCode();
+                }
+                _SEH2_END;
+                if (!NT_SUCCESS(Status))
+                {
+                    Context = NULL;
+                    break;
+                }
+            }
+        }
+        if (Context)
+        {
+            CcUnpinData(Context);
+        }
+    }
+    ExAcquireResourceExclusiveLite(&DeviceExt->DirResource, TRUE);
+    vfatReleaseFCB(DeviceExt, pFcb);
+    ExReleaseResourceLite(&DeviceExt->DirResource);
+
+    return STATUS_SUCCESS;
+}
+
 
 /*
  * FUNCTION: Mount the filesystem
index b885be4..50a3c53 100644 (file)
@@ -662,11 +662,6 @@ vfat8Dot3ToString(
     PFAT_DIR_ENTRY pEntry,
     PUNICODE_STRING NameU);
 
-NTSTATUS
-ReadVolumeLabel(
-    PDEVICE_EXTENSION DeviceExt,
-    PVPB Vpb);
-
 /* dir.c */
 
 NTSTATUS