From: Francesco Cosoleto <cosoleto@gmail.com>
To: util-linux@vger.kernel.org
Cc: Francesco Cosoleto <cosoleto@gmail.com>
Subject: [PATCH 07/13] fdisk: get rid of get_boot(create_empty_sun) call
Date: Thu, 15 Dec 2011 20:02:43 +0100 [thread overview]
Message-ID: <1323975769-21929-7-git-send-email-cosoleto@gmail.com> (raw)
In-Reply-To: <1323975769-21929-1-git-send-email-cosoleto@gmail.com>
create_sunlabel() should create a new empty SUN disklabel without checking data
itself writes to memory and initialize internal related fdisk variables.
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
---
fdisk/fdisk.c | 7 ++-----
fdisk/fdisk.h | 3 +--
fdisk/fdisksunlabel.c | 17 +++++++++++------
3 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index ab2e68d..aacd73f 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -51,6 +51,7 @@
#include "gpt.h"
+static int get_boot(enum action what);
static void delete_partition(int i);
#define hex_val(c) ({ \
@@ -1090,7 +1091,7 @@ void zeroize_mbr_buffer(void)
* 0: found or created label
* 1: I/O error
*/
-int
+static int
get_boot(enum action what) {
int i;
@@ -1108,9 +1109,6 @@ get_boot(enum action what) {
pe->changed = (what == create_empty_dos);
}
- if (what == create_empty_sun && check_sun_label())
- return 0;
-
memset(MBRbuffer, 0, 512);
if (what == create_empty_dos)
@@ -1175,7 +1173,6 @@ got_dos_table:
case try_only:
return -1;
case create_empty_dos:
- case create_empty_sun:
break;
default:
fprintf(stderr, _("Internal error\n"));
diff --git a/fdisk/fdisk.h b/fdisk/fdisk.h
index 67642cd..6641880 100644
--- a/fdisk/fdisk.h
+++ b/fdisk/fdisk.h
@@ -54,7 +54,7 @@ enum failure {ioctl_error,
unable_to_open, unable_to_read, unable_to_seek,
unable_to_write};
-enum action {fdisk, try_only, create_empty_dos, create_empty_sun};
+enum action {fdisk, try_only, create_empty_dos};
struct geom {
unsigned int heads;
@@ -69,7 +69,6 @@ extern unsigned int display_in_cyl_units, units_per_sector;
extern void change_units(void);
extern void fatal(enum failure why);
extern void get_geometry(int fd, struct geom *);
-extern int get_boot(enum action what);
extern int get_partition(int warn, int max);
extern void list_types(struct systypes *sys);
extern int read_line (int *asked);
diff --git a/fdisk/fdisksunlabel.c b/fdisk/fdisksunlabel.c
index 80408dd..4fd8545 100644
--- a/fdisk/fdisksunlabel.c
+++ b/fdisk/fdisksunlabel.c
@@ -109,6 +109,12 @@ static void set_sun_partition(int i, uint32_t start, uint32_t stop, uint16_t sys
print_partition_size(i + 1, start, stop, sysid);
}
+static void init(void)
+{
+ disklabel = SUN_LABEL;
+ partitions = SUN_NUM_PARTITIONS;
+}
+
void sun_nolabel(void)
{
sunlabel->magic = 0;
@@ -125,6 +131,8 @@ int check_sun_label(void)
other_endian = 0;
return 0;
}
+
+ init();
other_endian = (sunlabel->magic == SUN_LABEL_MAGIC_SWAPPED);
ush = ((unsigned short *) (sunlabel + 1)) - 1;
@@ -176,8 +184,6 @@ int check_sun_label(void)
}
}
update_units();
- disklabel = SUN_LABEL;
- partitions = SUN_NUM_PARTITIONS;
return 1;
}
@@ -195,7 +201,10 @@ void create_sunlabel(void)
#else
other_endian = 0;
#endif
+
+ init();
zeroize_mbr_buffer();
+
sunlabel->magic = SSWAP16(SUN_LABEL_MAGIC);
sunlabel->sanity = SSWAP32(SUN_LABEL_SANE);
sunlabel->version = SSWAP32(SUN_LABEL_VERSION);
@@ -249,9 +258,6 @@ void create_sunlabel(void)
} else
ndiv = cylinders * 2 / 3;
- /* Make sure print_partition_size() uses correct sysid names */
- disklabel = SUN_LABEL;
-
set_sun_partition(0, 0, ndiv * heads * sectors,
SUN_TAG_LINUX_NATIVE);
set_sun_partition(1, ndiv * heads * sectors,
@@ -270,7 +276,6 @@ void create_sunlabel(void)
}
set_all_unchanged();
- get_boot(create_empty_sun);
set_changed(0);
}
--
1.7.7
next prev parent reply other threads:[~2011-12-15 19:03 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-15 19:02 [PATCH 01/13] fdisk: remove unused 'require' member in enum action Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 02/13] fdisk: remove possibly_osf_label variable that is only assigned Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 03/13] fdisk: move code for renaming SGI bootfile to SGI module Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 04/13] fdisk: drop one parameter from try() function Francesco Cosoleto
2011-12-16 13:18 ` Karel Zak
2011-12-22 2:24 ` Guillem Jover
2011-12-22 15:26 ` Francesco Cosoleto
2012-01-04 13:36 ` Karel Zak
2011-12-15 19:02 ` [PATCH 05/13] fdisk: rename try() and tryprocpt() functions Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 06/13] fdisk: get rid of type_open global variable Francesco Cosoleto
2011-12-15 19:02 ` Francesco Cosoleto [this message]
2011-12-15 19:02 ` [PATCH 08/13] fdisk: remove unused guess_device_type() function Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 09/13] fdisk: don't use get_existing_partition() if disk label isn't dos Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 10/13] fdisk: avoid an intermediate variable in command_prompt() Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 11/13] fdisk: Fix bad invalid flag 0x00000 warning message Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 12/13] fdisk: improve some messages Francesco Cosoleto
2011-12-15 19:02 ` [PATCH 13/13] tests: update fdisk tests Francesco Cosoleto
2011-12-16 13:12 ` [PATCH 01/13] fdisk: remove unused 'require' member in enum action 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=1323975769-21929-7-git-send-email-cosoleto@gmail.com \
--to=cosoleto@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).