summaryrefslogtreecommitdiffstats
path: root/fdisk
diff options
context:
space:
mode:
authorDavidlohr Bueso2012-05-06 21:02:45 +0200
committerKarel Zak2012-05-10 11:35:42 +0200
commit0dc13a38631361394a098c5e9b39ca05a0cb36a7 (patch)
treef5a0d056adef75d092558036db7ac9ac135d01c4 /fdisk
parentfdisk: move DOS new/add partition code (diff)
downloadkernel-qcow2-util-linux-0dc13a38631361394a098c5e9b39ca05a0cb36a7.tar.gz
kernel-qcow2-util-linux-0dc13a38631361394a098c5e9b39ca05a0cb36a7.tar.xz
kernel-qcow2-util-linux-0dc13a38631361394a098c5e9b39ca05a0cb36a7.zip
fdisk: create DOS specific write table function
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Diffstat (limited to 'fdisk')
-rw-r--r--fdisk/fdisk.c27
-rw-r--r--fdisk/fdiskdoslabel.c25
-rw-r--r--fdisk/fdiskdoslabel.h1
3 files changed, 30 insertions, 23 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 8c2a162cb..3044879aa 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -1672,31 +1672,12 @@ static void
write_table(void) {
int i;
- if (disklabel == DOS_LABEL) {
- /* MBR (primary partitions) */
- if (!MBRbuffer_changed) {
- for (i = 0; i < 4; i++)
- if (ptes[i].changed)
- MBRbuffer_changed = 1;
- }
- if (MBRbuffer_changed) {
- write_part_table_flag(MBRbuffer);
- write_sector(fd, 0, MBRbuffer);
- }
- /* EBR (logical partitions) */
- for (i = 4; i < partitions; i++) {
- struct pte *pe = &ptes[i];
-
- if (pe->changed) {
- write_part_table_flag(pe->sectorbuffer);
- write_sector(fd, pe->offset, pe->sectorbuffer);
- }
- }
- }
- else if (disklabel == SGI_LABEL) {
+ if (disklabel == DOS_LABEL)
+ dos_write_table();
+ else if (disklabel == SGI_LABEL)
/* no test on change? the printf below might be mistaken */
sgi_write_table();
- } else if (disklabel == SUN_LABEL) {
+ else if (disklabel == SUN_LABEL) {
int needw = 0;
for (i=0; i<8; i++)
diff --git a/fdisk/fdiskdoslabel.c b/fdisk/fdiskdoslabel.c
index 3f820dbf3..a1916fc57 100644
--- a/fdisk/fdiskdoslabel.c
+++ b/fdisk/fdiskdoslabel.c
@@ -657,3 +657,28 @@ void dos_new_partition(void)
printf(_("Invalid partition type `%c'\n"), c);
}
}
+
+void dos_write_table(void)
+{
+ int i;
+
+ /* MBR (primary partitions) */
+ if (!MBRbuffer_changed) {
+ for (i = 0; i < 4; i++)
+ if (ptes[i].changed)
+ MBRbuffer_changed = 1;
+ }
+ if (MBRbuffer_changed) {
+ write_part_table_flag(MBRbuffer);
+ write_sector(fd, 0, MBRbuffer);
+ }
+ /* EBR (logical partitions) */
+ for (i = 4; i < partitions; i++) {
+ struct pte *pe = &ptes[i];
+
+ if (pe->changed) {
+ write_part_table_flag(pe->sectorbuffer);
+ write_sector(fd, pe->offset, pe->sectorbuffer);
+ }
+ }
+}
diff --git a/fdisk/fdiskdoslabel.h b/fdisk/fdiskdoslabel.h
index e45a02667..8c116f7ef 100644
--- a/fdisk/fdiskdoslabel.h
+++ b/fdisk/fdiskdoslabel.h
@@ -52,5 +52,6 @@ extern int is_dos_partition(int t);
extern void dos_init(void);
extern void dos_add_partition(int n, int sys);
extern void dos_new_partition(void);
+extern void dos_write_table(void);
#endif