From: Davidlohr Bueso <dave@gnu.org>
To: Karel Zak <kzak@redhat.com>, Petr Uzel <petr.uzel@suse.cz>
Cc: util-linux <util-linux@vger.kernel.org>
Subject: [PATCH 3/5] fdisk: create DOS specific write table function
Date: Sun, 06 May 2012 14:10:21 +0200 [thread overview]
Message-ID: <1336306221.2685.12.camel@offbook> (raw)
From: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
fdisk/fdisk.c | 27 ++++-----------------------
fdisk/fdiskdoslabel.c | 27 +++++++++++++++++++++++++++
fdisk/fdiskdoslabel.h | 1 +
3 files changed, 32 insertions(+), 23 deletions(-)
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 8c2a162..3044879 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 3f820db..a13a83a 100644
--- a/fdisk/fdiskdoslabel.c
+++ b/fdisk/fdiskdoslabel.c
@@ -657,3 +657,30 @@ void dos_new_partition(void)
printf(_("Invalid partition type `%c'\n"), c);
}
}
+
+void dos_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);
+ }
+ }
+ }
+}
diff --git a/fdisk/fdiskdoslabel.h b/fdisk/fdiskdoslabel.h
index e45a026..8c116f7 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
--
1.7.4.1
next reply other threads:[~2012-05-06 12:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-06 12:10 Davidlohr Bueso [this message]
2012-05-06 18:11 ` [PATCH 3/5] fdisk: create DOS specific write table function Petr Uzel
2012-05-06 19:02 ` Davidlohr Bueso
2012-05-10 9:51 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1336306221.2685.12.camel@offbook \
--to=dave@gnu.org \
--cc=kzak@redhat.com \
--cc=petr.uzel@suse.cz \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.