]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: create DOS specific write table function
authorDavidlohr Bueso <dave@gnu.org>
Sun, 6 May 2012 19:02:45 +0000 (21:02 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 10 May 2012 09:35:42 +0000 (11:35 +0200)
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
fdisk/fdisk.c
fdisk/fdiskdoslabel.c
fdisk/fdiskdoslabel.h

index 8c2a162cb35f433cb5908ccc7ceeda3c3d712976..3044879aa26ecc7bf8610838e66d9342c2176f6e 100644 (file)
@@ -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++)
index 3f820dbf3579ad60b1f4f1ceb54ed99a6feaf530..a1916fc573837cdfa9ce01f1122146a3f467876a 100644 (file)
@@ -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);
+               }
+       }
+}
index e45a026672c7c6a1b26bc396a0a9a7c07954931c..8c116f7ef82c0e969e9f31bdc00ce6b3ca7686dd 100644 (file)
@@ -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