Commit Graph

31 Commits

Author SHA1 Message Date
Davidlohr Bueso 3457420178 fdisk: rework fatal errors
When the device cannot be opened, there's no point calling fatal() when we can
just use err(3). When any other kind of fatal error occurs it's Ok, in addition
we can also go ahead and close the descriptor before exiting the program as
it's currently leaking.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-05-02 09:33:46 +02:00
Davidlohr Bueso f45121dd46 fdisk: remove action enum
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-23 13:00:00 +02:00
Sami Kerola 521349a127 fdisk: remove redundant declaration [cppcheck]
fdisk.h:116:12: warning: redundant redeclaration of 'valid_part_table_flag' [-Wredundant-decls]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-08 13:28:43 +01:00
Karel Zak 67aa2fc795 fdisk: remove PACKED macro
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-05 17:01:19 +01:00
Francesco Cosoleto 8db8295d82 fdisk: Fix bad invalid flag 0x00000 warning message
This splits check_dos_label() and dos_init() off from get_boot() and gets
rid of the invalid flag 0x00000 warning message due to a check for MBR
signs in zeroized buffer:

	memset(MBRbuffer, 0, 512);

	if (what == create_empty_dos)
		goto got_dos_table;
[...]
got_dos_table:
	if (!valid_part_table_flag(MBRbuffer)) {
[...]
	if (!valid_part_table_flag(pe->sectorbuffer))
		fprintf(stderr, _("Warning: invalid flag 0x%04x of partition "
[...]

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-12-16 14:04:09 +01:00
Francesco Cosoleto ad30333e1d fdisk: get rid of get_boot(create_empty_sun) call
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>
2011-12-16 14:04:04 +01:00
Francesco Cosoleto 1025b5ab08 fdisk: remove unused 'require' member in enum action
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-12-16 14:03:58 +01:00
Francesco Cosoleto c482303ef7 fdisk: rewrite print menu system
DOS and SGI label menus are unchanged. BSD label command
descriptions change slightly to use a common form.

This also removes an useless menu entry in SUN label menu to
edit bsd disklabel.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-11-14 14:27:18 +01:00
Francesco Cosoleto e97a991aff fdisk: rename bselect, xselect functions
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-11-14 14:23:32 +01:00
Francesco Cosoleto 20aa2570e8 fdisk: print a message with size and type of created partition
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-08-30 10:53:22 +02:00
Francesco Cosoleto 365acc9765 fdisk: use a single variable for the current disklabel
Using a variable for each supported partition table type doesn't seem necessary.

This fixes also a minor bug in switching from SGI label to SUN label: the expert
menu isn't available as sgi_label variable remains set to true.

Code a bit more clear as *_label names have similarity with names such as
"sgilabel", "struct sun_label".

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-07-11 12:01:42 +02:00
Francesco Cosoleto 52b38677e2 fdisk: use xalloc lib
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-01-23 23:05:08 +01:00
Francesco Cosoleto 7c1db6b47a fdisk: replace fatal(usage) with a separate usage() function
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-23 23:04:06 +01:00
Karel Zak 8feb31e532 fdisk: re-print prompt after maybe_exit()
after
	Do you really want to quit? n

the read_chars() has to re-print the original prompt and ask again
for new input. For example:

Partition number (1-4, default 3):               <-- CTRL-D
Do you really want to quit? n
Partition number (1-4, default 3): 3             <-- ask again
First sector (411648-1023999, default 411648):

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-05 16:50:47 +01:00
Karel Zak 6bec87105c fdisk: use canonicalized names for -l (and sfdisk -d)
.. no more /dev/dm-X in "fdisk -l" and "sfdisk -d" output, always use
/dev/mapper/<name>.

Signed-off-by: Karel Zak <kzak@redhat.com>
2010-12-17 01:28:59 +01:00
Karel Zak 3b19e88dab fdisk: cleanup help, add -h option
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-15 10:08:03 +01:00
Karel Zak b2f15782a7 fdisk: fix strict-aliasing bugs
gcc 4.4 produces tons of

  "dereferencing type-punned pointer will break strict-aliasing rules"

warnings for fdisk code where is

  char buffer[BUFSIZ];

  ((struct disklabel *) MBRBuffer)->foo

There are two ways how fix the problem:

  1/ union {
          char buffer[BUFSIZ], struct disklabel label
     } MBRBuffer;

  2/ use allocated buffer, this way seems less invasive.

This patch implements 2/.

Old version:
  $ make -C fdisk | grep -c warning
  236

New version:
  $ make -C fdisk | grep -c warning
  0

About aliasing:
 - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40665
 - http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html
 - C99

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-17 00:18:46 +02:00
Karel Zak 17d0d058fc fdisk: use c.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-16 01:26:46 +02:00
Karel Zak e7fa917a33 fdisk: add MAC label detection
This patch is based on the old Suse util-linux-2.11q-fs_mac.diff patch.

Signed-off-by: Karel Zak <kzak@redhat.com>
2007-06-27 23:49:56 +02:00
Karel Zak 024353c9ea fdisk: move duplicate stuff from fdisk*label.h to fdisk.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-06-27 23:36:08 +02:00
Karel Zak bf8df99191 fdisk: fix "type qualifiers ignored on function return type"
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-05-31 15:02:13 +02:00
Karel Zak be97c5f361 fdisk: use unsigned long long instead int for sectors
The patch is originally based on an old Suse patch.

Signed-off-by: Karel Zak <kzak@redhat.com>
2007-05-31 15:00:50 +02:00
Karel Zak cf6d7faebb Imported from util-linux-2.13-pre6 tarball. 2006-12-07 00:27:13 +01:00
Karel Zak 5213517f54 Imported from util-linux-2.12l tarball. 2006-12-07 00:26:28 +01:00
Karel Zak df1dddf9ff Imported from util-linux-2.12 tarball. 2006-12-07 00:26:12 +01:00
Karel Zak e8f2641919 Imported from util-linux-2.11m tarball. 2006-12-07 00:25:49 +01:00
Karel Zak c07ebfa1e0 Imported from util-linux-2.11b tarball. 2006-12-07 00:25:46 +01:00
Karel Zak 22853e4a82 Imported from util-linux-2.10m tarball. 2006-12-07 00:25:43 +01:00
Karel Zak eb63b9b8f4 Imported from util-linux-2.10f tarball. 2006-12-07 00:25:41 +01:00
Karel Zak 7eda085c41 Imported from util-linux-2.9v tarball. 2006-12-07 00:25:39 +01:00
Karel Zak 5c36a0eb7c Imported from util-linux-2.9i tarball. 2006-12-07 00:25:37 +01:00