Update the on-disk partition tables immediately after modifying the in-memory tables. 

svn path=/trunk/; revision=65855
This commit is contained in:
Eric Kohl 2014-12-28 09:16:41 +00:00
parent 9bf8864501
commit cdc15f3bc5
3 changed files with 55 additions and 11 deletions

View file

@ -1834,6 +1834,7 @@ CreatePrimaryPartitionPage(PINPUT_RECORD Ir)
ULONGLONG DiskSize; ULONGLONG DiskSize;
ULONGLONG SectorCount; ULONGLONG SectorCount;
PCHAR Unit; PCHAR Unit;
NTSTATUS Status;
if (PartitionList == NULL || if (PartitionList == NULL ||
PartitionList->CurrentDisk == NULL || PartitionList->CurrentDisk == NULL ||
@ -1960,6 +1961,14 @@ CreatePrimaryPartitionPage(PINPUT_RECORD Ir)
SectorCount, SectorCount,
FALSE); FALSE);
Status = WriteDirtyPartitions(PartitionList);
if (!NT_SUCCESS(Status))
{
DPRINT("WriteDirtyPartitions() failed\n");
MUIDisplayError(ERROR_WRITE_PTABLE, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
return SELECT_PARTITION_PAGE; return SELECT_PARTITION_PAGE;
} }
} }
@ -1981,6 +1990,7 @@ CreateExtendedPartitionPage(PINPUT_RECORD Ir)
ULONGLONG DiskSize; ULONGLONG DiskSize;
ULONGLONG SectorCount; ULONGLONG SectorCount;
PCHAR Unit; PCHAR Unit;
NTSTATUS Status;
if (PartitionList == NULL || if (PartitionList == NULL ||
PartitionList->CurrentDisk == NULL || PartitionList->CurrentDisk == NULL ||
@ -2106,6 +2116,14 @@ CreateExtendedPartitionPage(PINPUT_RECORD Ir)
CreateExtendedPartition(PartitionList, CreateExtendedPartition(PartitionList,
SectorCount); SectorCount);
Status = WriteDirtyPartitions(PartitionList);
if (!NT_SUCCESS(Status))
{
DPRINT("WriteDirtyPartitions() failed\n");
MUIDisplayError(ERROR_WRITE_PTABLE, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
return SELECT_PARTITION_PAGE; return SELECT_PARTITION_PAGE;
} }
} }
@ -2127,6 +2145,7 @@ CreateLogicalPartitionPage(PINPUT_RECORD Ir)
ULONGLONG DiskSize; ULONGLONG DiskSize;
ULONGLONG SectorCount; ULONGLONG SectorCount;
PCHAR Unit; PCHAR Unit;
NTSTATUS Status;
if (PartitionList == NULL || if (PartitionList == NULL ||
PartitionList->CurrentDisk == NULL || PartitionList->CurrentDisk == NULL ||
@ -2252,6 +2271,14 @@ CreateLogicalPartitionPage(PINPUT_RECORD Ir)
CreateLogicalPartition(PartitionList, CreateLogicalPartition(PartitionList,
SectorCount); SectorCount);
Status = WriteDirtyPartitions(PartitionList);
if (!NT_SUCCESS(Status))
{
DPRINT("WriteDirtyPartitions() failed\n");
MUIDisplayError(ERROR_WRITE_PTABLE, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
return SELECT_PARTITION_PAGE; return SELECT_PARTITION_PAGE;
} }
} }
@ -2269,6 +2296,7 @@ DeletePartitionPage(PINPUT_RECORD Ir)
ULONGLONG PartSize; ULONGLONG PartSize;
PCHAR Unit; PCHAR Unit;
PCHAR PartType; PCHAR PartType;
NTSTATUS Status;
if (PartitionList == NULL || if (PartitionList == NULL ||
PartitionList->CurrentDisk == NULL || PartitionList->CurrentDisk == NULL ||
@ -2421,6 +2449,14 @@ DeletePartitionPage(PINPUT_RECORD Ir)
{ {
DeleteCurrentPartition(PartitionList); DeleteCurrentPartition(PartitionList);
Status = WriteDirtyPartitions(PartitionList);
if (!NT_SUCCESS(Status))
{
DPRINT("WriteDirtyPartitions() failed\n");
MUIDisplayError(ERROR_WRITE_PTABLE, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
return SELECT_PARTITION_PAGE; return SELECT_PARTITION_PAGE;
} }
} }
@ -2792,9 +2828,10 @@ FormatPartitionPage(PINPUT_RECORD Ir)
CheckActiveBootPartition(PartitionList); CheckActiveBootPartition(PartitionList);
if (WritePartitionsToDisk(PartitionList) == FALSE) Status = WriteDirtyPartitions(PartitionList);
if (!NT_SUCCESS(Status))
{ {
DPRINT("WritePartitionsToDisk() failed\n"); DPRINT("WriteDirtyPartitions() failed\n");
MUIDisplayError(ERROR_WRITE_PTABLE, Ir, POPUP_WAIT_ENTER); MUIDisplayError(ERROR_WRITE_PTABLE, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE; return QUIT_PAGE;
} }
@ -3706,6 +3743,7 @@ BootLoaderPage(PINPUT_RECORD Ir)
BOOLEAN InstallOnFloppy; BOOLEAN InstallOnFloppy;
USHORT Line = 12; USHORT Line = 12;
WCHAR PathBuffer[MAX_PATH]; WCHAR PathBuffer[MAX_PATH];
NTSTATUS Status;
CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT)); CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
@ -3713,9 +3751,10 @@ BootLoaderPage(PINPUT_RECORD Ir)
CheckActiveBootPartition(PartitionList); CheckActiveBootPartition(PartitionList);
/* Update the partition table because we may have changed the active partition */ /* Update the partition table because we may have changed the active partition */
if (WritePartitionsToDisk(PartitionList) == FALSE) Status = WriteDirtyPartitions(PartitionList);
if (!NT_SUCCESS(Status))
{ {
DPRINT("WritePartitionsToDisk() failed\n"); DPRINT("WriteDirtyPartitions() failed\n");
MUIDisplayError(ERROR_WRITE_PTABLE, Ir, POPUP_WAIT_ENTER); MUIDisplayError(ERROR_WRITE_PTABLE, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE; return QUIT_PAGE;
} }

View file

@ -2931,15 +2931,16 @@ WritePartitons(
} }
BOOLEAN NTSTATUS
WritePartitionsToDisk( WriteDirtyPartitions(
PPARTLIST List) PPARTLIST List)
{ {
PLIST_ENTRY Entry; PLIST_ENTRY Entry;
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
NTSTATUS Status;
if (List == NULL) if (List == NULL)
return TRUE; return STATUS_SUCCESS;
Entry = List->DiskListHead.Flink; Entry = List->DiskListHead.Flink;
while (Entry != &List->DiskListHead) while (Entry != &List->DiskListHead)
@ -2948,13 +2949,17 @@ WritePartitionsToDisk(
if (DiskEntry->Dirty == TRUE) if (DiskEntry->Dirty == TRUE)
{ {
WritePartitons(List, DiskEntry); Status = WritePartitons(List, DiskEntry);
if (!NT_SUCCESS(Status))
return Status;
DiskEntry->Dirty = FALSE;
} }
Entry = Entry->Flink; Entry = Entry->Flink;
} }
return TRUE; return STATUS_SUCCESS;
} }

View file

@ -247,8 +247,8 @@ BOOLEAN
CheckForLinuxFdiskPartitions( CheckForLinuxFdiskPartitions(
PPARTLIST List); PPARTLIST List);
BOOLEAN NTSTATUS
WritePartitionsToDisk( WriteDirtyPartitions(
PPARTLIST List); PPARTLIST List);
ULONG ULONG