Commit Graph

266 Commits

Author SHA1 Message Date
Francesco Cosoleto e97a991aff fdisk: rename bselect, xselect functions
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-11-14 14:23:32 +01:00
Karel Zak 8176a34404 fdisk: don't shorten long path to disk device
Reported-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-12 10:25:01 +02:00
Petr Uzel 960cf5737e misc: use %m in format string instead of %s and strerror(errno)
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-27 15:46:07 +02:00
Petr Uzel 4310e47adc sfdisk: warn if partition exceeds partition table limits
Warn the user if the partition to be created exceeds limits
imposed by the DOS partition table, which is:
* partition has to start on sector < 2^32
* partition size has to be < 2^32 sectors

For 512-byte logical sector size, these limits are ~2.2 TiB.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-27 15:24:06 +02:00
Petr Uzel 6c709b57a3 sfdisk: use unsigned long long to internally represent sector number
Unsigned long is only 4 bytes long on i586, which is not enough to
represent sector number on todays large disks. Use unsigned long long,
which is 8 bytes long, to store the sector numbers internally, so that
we could later make some sanity checks and warn the user if the sector
numbers exceed the limits imposed by DOS partition table format.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-27 15:24:04 +02:00
Petr Uzel b7767afc63 sfdisk: introduce get_ull() function
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-27 15:24:02 +02:00
Petr Uzel c4730f108e sfdisk: get_disksize() returns long long
unsigned long is 4 bytes long on i586, which is not enough for big
HDD's with 512B sectors. Use unsigned long long, which is 8 bytes.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-27 15:24:01 +02:00
Petr Uzel 26f0feac99 sfdisk: make the cylinder boundary check less fatal
If the specified format is not cylinders, make the cylinder boundary
check only print a warning and proceed anyways.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-27 15:24:00 +02:00
Petr Uzel bb92c8ea2d sfdisk: fix weird indentation in msdos_partition()
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-27 15:23:58 +02:00
Petr Uzel 8c4c0268a6 sfdisk: file descriptor is of int type
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-27 15:23:53 +02:00
Karel Zak fa25f2289c Merge branch 'docs-dir' of https://github.com/kerolasa/lelux-utiliteetit
* 'docs-dir' of https://github.com/kerolasa/lelux-utiliteetit:
  docs: remove duplicated text
  docs: require kernel support before accepting use of it
  docs: note about independent super block structs
  docs: add libmount & libblkid debug instructions
  Documentation: add debugging doc
  arch: start using arch as a usage() example
  docs: new file Documentation/release-schedule.txt
  docs: move setuid information from reame to hwclock.8
  docs: clean up old readme files
  docs: copy contributors from legacy files to AUTHORS
  docs: new file Documentation/howto-man-page.txt
  docs: new file Documentation/source-code-management.txt
  docs: new file Documentation/howto-contribute.txt
  docs: new file Documentation/howto-compilation.txt
  docs: tell what the Documentation/ is about
  docs: add usage() howto for contributors
  docs: Documentation directory added
  docs: remove README.clear
2011-08-31 11:04:15 +02:00
Petr Uzel 84895878d0 sfdisk.8: fix formatting
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-08-30 11:53:31 +02:00
Francesco Cosoleto 9777759ad6 fdisk: print welcome message
This adds a welcome message with util-linux version number, information
about fdisk behaviour that doesn't write to disk after a command (unlike
gparted) and a warning about possible data loss.

The message appears just before the first command prompt.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-08-30 10:54:37 +02:00
Francesco Cosoleto a75ba1319e fdisk: print partition deleted message
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-08-30 10:53:39 +02: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
Giulio Orsero cc393e381d sfdisk: make some tests conditional to !Linux
This patch makes the following tests/actions conditional to "!Linux":

- Force cylinders as format instead of MB, even if user asked for MB.
  This solves a bug where if you use "-L -uM", set 1 as starting MB
  and the disk is larger than a certain size (about 1GB) the partition
  would start at sector 1 instead of 1MB due to cyl rounding.

- Warn about partitions not starting/ending on cyl boundaries.

- Check if CHS is ok.

I used the "!Linux" notation since it was already used elsewhere in
the code.

Signed-off-by: Giulio Orsero <giulioo@pobox.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-23 12:19:38 +02:00
Benno Schulenberg 232dc924c4 docs: uniformize the header and footer lines in man pages
Use dates without the day, use the full month name, put "util-linux" in
the lower left corner, and "User Commands" or "System Administration"
at the top center.

Also improve here and there the one-line program description.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-22 10:39:21 +02:00
Karel Zak e871457382 sfdisk: fix typo in man page
Reported-by: markus reichelt <ml@mareichelt.com>
Signed-off-by: Karel Zak <kzak@redhat.com>

sk/sfdisk.8
2011-08-16 23:56:26 +02:00
Benno Schulenberg e0c97cdcf8 sfdisk: slice help text into small chunks and improve its wording
[kzak@redhat.com: - use fputs(),
                  - use <var> convention]

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-16 23:52:40 +02:00
Benno Schulenberg 2e9cb1c3d6 sfdisk: (man page) use comma between short and long option instead of "or"
Also fix some erratic formatting, indent the third example too, drop
the trailing % prompt in examples, add a blank line before and after,
and improve the wording here and there.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-16 23:32:50 +02:00
Karel Zak fcbaa9794c sfdisk: indent usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 10:28:59 +02:00
Benno Schulenberg a89dbfee94 sfdisk: correct '--inside-order' to '--inside-outer' in documentation
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-15 15:49:52 +02:00
Benno Schulenberg be350fb952 sfdisk: remove inconsistent and wasteful newlines in the _() calls
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-15 15:49:35 +02:00
Benno Schulenberg ebaba0a906 sfdisk: improve descriptions of options --no-reread and --show-extended
Also keep the two geometry options (-g and -G) together by moving -A.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-15 15:49:31 +02:00
Benno Schulenberg 850ca1a808 sfdisk: gettextize each warning as a whole
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-15 15:49:29 +02:00
Benno Schulenberg 512b057ead fdisksgilabel: correct the grammar of an error message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-15 15:49:26 +02:00
Sami Kerola f98d4f766e docs: Documentation directory added
Move readme, licence, change log, relese notes and other
supplementary files to a Documentation directory. This commit
does not change contents of any other but few Makefile.am files.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-08-12 20:19:52 +02:00
Karel Zak 479f00ebf5 cfdisk: fix compiler warnings [-Wunused-parameter]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01 15:27:45 +02:00
Karel Zak e99da659a9 fdisk: fix compiler warnings [-Wunused-parameter -Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01 15:27:35 +02:00
Karel Zak 15fbd83f3b cfdisk: fix compilation with slang
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-28 13:46: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
Karel Zak 37b94458bd sfdisk: fix coding style.
The style in the file is really horrible and unreadable. This patch
uses:

 indent -linux -i4 -psl -brf sfdisk.c

to fix the style. The ideal solution is to call the indent with only
-linux option, but it's too invasive...

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-29 12:47:38 +02:00
Sami Kerola d5251274a9 Merge branch 'master', remote-tracking branch 'upstream/master' into sfdisk 2011-06-16 21:44:24 +02:00
Sami Kerola bdb8757e91 sfdisk: fix for data type mismatches
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-14 20:49:11 +02:00
Josiah Worcester 95961ee294 fdisk, display, hexdump.h: Use standard C types instead of u_int, u_char, u_long, etc.
Signed-off-by: Josiah Worcester <josiahw@gmail.com>
2011-06-14 13:58:33 +02:00
Karel Zak ddca89be53 cfdisk: fix gcc warning (unused variable)
cfdisk.c: In function ‘fp_printf’:
cfdisk.c:1760:12: warning: variable ‘x’ set but not used [-Wunused-but-set-variable]

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-08 12:57:25 +02:00
Sami Kerola b5ac06704e sfdisk: fix implicit overflow
sfdisk.c:1650:6: warning: overflow in implicit constant conversion [-Woverflow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-05-30 22:19:53 +02:00
Sami Kerola f74478a64d docs: sfdisk manual update
Add to manual page previously unmentioned options and few missing
long options.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-05-30 22:12:53 +02:00
Sami Kerola 4a0f60f62d sfdisk: previously undocumented options to usage
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-05-30 22:12:53 +02:00
Sami Kerola cc80c23477 sfdisk: help screen format
Readability improvement by making the help screen to look like
majority of command line utilities.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-05-30 22:12:53 +02:00
Sami Kerola 4dd3383af2 sfdisk: declare unused function attributes
Add `__attribute__ ((__unused__))' where needed.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-05-30 22:12:46 +02:00
Francesco Cosoleto 7439604895 fdisk: accept digits-space-suffix format
This is for users who are used to separate with a space numbers from units.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-05-10 14:33:33 +02:00
Francesco Cosoleto 11187bfadd fdisk: print logical partition number while adding it
[kzak@redhat.com: - merged two Francesco's patches]

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-05-10 14:13:14 +02:00
Francesco Cosoleto b25c9df7c7 fdisk: quit from partition type dialog after invalid response
This gets rid of the while() loop and fixes indentation.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-05-10 13:50:16 +02:00
Francesco Cosoleto 37b4484fe6 fdisk: add a default response for the partition type dialog
The default response is 'p' until three primary partitions are created,
then 'e'.

The original idea is from Karel Zak.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-05-10 13:50:11 +02:00
Francesco Cosoleto ffde29b2bd fdisk: change primary or extended partition type dialog
Mainly this appends a colon for the prompt, reverses order of the list,
reports the number of primary partitions used and unused.

Old version:
 Command action
    e   extended
    p   primary partition (1-4)
 p

New version:
 Partition type:
    p   primary (0 primary, 0 extended, 4 free)
    e   extended
 Select: p

Old version:
 Command action
    l   logical (5 or over)
    p   primary partition (1-4)
 l

New version:
 Partition type:
    p   primary (0 primary, 1 extended, 3 free)
    l   logical (numbered from 5)
 Select: l

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-05-10 13:50:06 +02:00
Andrea Galbusera e82810c6cf sfdisk: returns non-zero on failed BLKRRPART ioctl
Make sfdisk(8) return non-zero value on failed BLKRRPART ioctl().
This will happen for either partition table re-reads after partition
changes or on explicit use of -R switch.

The function reread_disk_partition() was changed from 'void' to 'int'
and now returns a result to let the calling functions decide to exit(1).

Signed-off-by: Andrea Galbusera <gizero@gmail.com>
2011-05-06 13:03:43 +02:00
Francesco Cosoleto 63c3e98f21 fdisk: improve error message for missing extended partition
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-05-03 12:59:03 +02:00
Francesco Cosoleto f01c41e5ff fdisk: fix "invalid partition number for type" error message
You can't input a partition number here.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-05-03 12:59:01 +02:00
Karel Zak 112b3813d2 fdisk: check index before access to array [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-17 22:58:05 +01:00