Commit Graph

843 Commits

Author SHA1 Message Date
Karel Zak b5ef65a931 cfdisk: force main menu to default to Quit/New menu items
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-03 10:37:33 +01:00
Karel Zak 635a81513a cfdisk: disable some KEY_* in ui_get_wqstring()
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-02 13:05:48 +01:00
Karel Zak 316bce9dd4 cfdisk: default to Quit menu item
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-02 12:47:50 +01:00
Benno Schulenberg fc14ceba5e textual: grammarize and harmonize the stat error message
The message "stat failed %s" seems to say that stat() failed to
do something, or failed to pass a test, but of course it means
that the statting of something failed.  So say so.  Also make
two very similar messages equal to this one.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02 11:27:10 +01:00
Benno Schulenberg 9ac1fcf6c5 sfdisk: actually translate the table headers by calling gettext()
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02 10:57:07 +01:00
Benno Schulenberg c7b1fbb4c5 docs: add the Sort command to the man page of cfdisk
Also sort T into its proper position, improve the wording of U,
and add the Left and Right arrow keys.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02 10:57:07 +01:00
Benno Schulenberg 2a0ffa311c cfdisk: make '?' an alias of 'h', to also show the help screen
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02 10:57:07 +01:00
Benno Schulenberg d4640320df cfdisk: punctuate the bottombar messages consistently
Also adjust the style of two comments and add another.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02 10:57:07 +01:00
Benno Schulenberg 143d9e3e52 cfdisk: improve wording and consistency of the size warnings
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02 10:57:07 +01:00
Benno Schulenberg a4fbbbd491 cfdisk: remove the mistaken B from the explanation of size suffixes
Also reword the explanation to be clearer.  It is not necessary to
be complete -- that is what the man page is for.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02 10:57:07 +01:00
Karel Zak 54efd37875 sfdisk: fix --id fallthrough [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-28 14:50:38 +01:00
Karel Zak 52c56476ae fsck: deallocate when no cache [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-28 14:45:15 +01:00
Karel Zak 68ddb13662 fdisk: check return and robust label usage [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-28 14:40:10 +01:00
Karel Zak 9eaa7292e4 blockdev: check return when read from sysfs [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-28 14:33:36 +01:00
Karel Zak ec8a728ae0 cfdisk: fix mem leak and main_menu_action() logic [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-28 14:30:20 +01:00
Karel Zak bf031d89ea libfdisk: support unknown partition types in sfdisk scripts
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1183234
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-28 09:57:03 +01:00
Karel Zak 9bbcf43f88 libfdisk: don't use off_t in public API
It's better to use exact and explicitly defined types (e.g. uint64_t)
rather than something like off_t to make code more portable.

[reported with gcc (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3)]

The patch also fixes one debug message.

Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-26 12:26:00 +01:00
Benno Schulenberg b6e3c61464 cfdisk: actually translate the table headers and the bottom line
The printout of the table headers and the bottomline descriptions
were lacking calls to gettext().

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-26 11:53:51 +01:00
Benno Schulenberg e993b9c8e5 cfdisk: shorten the help screen to make it fit within 25 lines
When the terminal has less than 32 lines, the new cfdisk ignored the
fact that the help-screen text was longer and just skipped printing
the remaining lines.  Instead of introducing a minipager for the help
screen, just condense its text and remove unneeded lines.  Now the
text occupies just 25 lines, which should fit on most terminals.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-26 11:53:49 +01:00
Benno Schulenberg fd4484a712 cfdisk: don't mess up the help screen by printing the PO file header
Asking for the translation of the empty string ("") produces the header
of the PO file corresponding to the current locale, which messes up the
help screen.  So, don't use empty strings in the array of help strings
but (arbitrary) double spaces.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-26 11:53:48 +01:00
Yuri Chornoivan 6e834d67ee textual: fix various minor typos 2015-01-26 11:38:38 +01:00
Karel Zak 3d0b57d62c Merge branch 'opts' of https://github.com/jwpi/util-linux 2015-01-26 11:31:05 +01:00
Benno Schulenberg 54fefa078e textual: fix spellos and inconsistencies in several program messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-26 11:17:55 +01:00
J William Piggott b06c1ca6f8 docs: restore minus symbols in long opts
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2015-01-20 18:15:30 -05:00
Karel Zak ce9f568c25 libfdisk: accept Start offset in {B,M,G..}iB in sfdisk scripts
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-20 14:20:47 +01:00
Karel Zak 8de07279bb sfdisk: fix --bytes
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-19 12:26:37 +01:00
Karel Zak 354f8cc8cf libfdiskL add API to print SIZE field in bytes
The patch also add --bytes to fdisk and fdisk.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-19 11:24:48 +01:00
Karel Zak 2d7dffebac fdisk: add --output to usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-14 12:07:52 +01:00
J William Piggott 973252578d docs: fix-up man-pages flaged by checkmans.sh
disk-utils/sfdisk.8	Fix font escape
login-utils/vipw.8	Delete bogus macro
misc-utils/look.1	Delete bogus macro
sys-utils/prlimit.1	Delete bogus macro

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2015-01-13 11:43:46 -05:00
Karel Zak 2e5bf10e32 build-sys: add sfdisk.static
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-13 16:59:03 +01:00
Karel Zak a434e2398a raw: fix raw query
Bug introduced by commit cd121363.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1181444
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-13 09:53:46 +01:00
Karel Zak 4926bc3683 partx: don't use "hard drive" in man pages
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-12 11:15:55 +01:00
Benno Schulenberg e04b812407 docs: make the wording of the partx man page a bit more precise
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-12 11:04:35 +01:00
Benno Schulenberg 4b8dfcc8a4 partx: simplify a --verbose progress message
Reported-by: Antonio Ceballos <aceballos@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-12 11:03:27 +01:00
Benno Schulenberg 3a60b1c26b docs: remove obsolete and unneeded comments from man-page files
Transform some of them into copyright lines.
Also fix three header lines and snip some trailing whitespace.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-12 11:03:26 +01:00
Benno Schulenberg 4f8d6551d6 docs: sync the docstring of addpart, delpart and resizepart to the man page
Also tweak the wording of those man pages a bit.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-12 11:03:26 +01:00
Karel Zak 08ec8a6fad partx: add --update to ul_excl_twq list
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-12 10:58:00 +01:00
Karel Zak 4bb82a4554 libfdisk: (gpt) cleanup header size usage
Kay reported that Windows 8.1 installed does not recognize GPT created
by libfdisk, but parted works as expected.

It seems (according to the header hexdump) that the problem is
HeaderSize GPT field where libfdisk uses 512 (header + reserved area),
but parted uses 92. The both is pretty valid according to the current
EFI standard, but 92 is probably more backwardly compatible.

I also found places in code where libfdisk gpt driver is inconsistent
and uses sometimes all sector and simetimes sizeof(gpt_header) only.
The right solution is to read all sector (into zeroized memory) and
later write again all sector to the device.

Reported-by: Kay Sievers <kay@vrfy.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-09 13:05:49 +01:00
Sami Kerola 730ae9c899 fsck.minix: fix segmentation fault
Return from check_file() and check_file2() functions when maximum name
depth is reached.  The use unsafe strncpy() is also removed just to be on
safe side.

Addresses: https://bugs.debian.org/773892
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-07 10:14:13 +01:00
Sami Kerola 7ee26cbf02 maint: fix shadow declaration
This change fixes all shadow declarations.  The worth while to mention
fix is with libfdisk sun geometry.  It comes from bitops.h cpu_to_be16
macro that further expands from include/bits/byteswap.h that has the
shadowing.

libfdisk/src/sun.c:961:173: warning: declaration of '__v' shadows a previous local [-Wshadow]
libfdisk/src/sun.c:961:69: warning: shadowed declaration is here [-Wshadow]
libfdisk/src/sun.c:961:178: warning: declaration of '__x' shadows a previous local [-Wshadow]
libfdisk/src/sun.c:961:74: warning: shadowed declaration is here [-Wshadow]

That could have caused earlier some unexpected results.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-07 10:08:21 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Karel Zak 8c9615a99b cfdisk: improve Dump dialog
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-05 12:53:50 +01:00
Karel Zak 702d0e1cef cfdisk: improve menu clean function
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-05 12:42:24 +01:00
Karel Zak 7509020126 cfdisk: detect too small partition sizes
References: https://github.com/karelzak/util-linux/issues/136
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-05 12:13:25 +01:00
Benno Schulenberg edac3e2c2e sfdisk: in the usage text show -v for --version instead of -V
In sfdisk -V is taken by --verify.  Use for the description of --version
the same indentation as for --help, not that of the other options.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-12-19 09:57:28 +01:00
Benno Schulenberg 689d83de5a docs: fix the grammar and formatting in the man page of sfdisk
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-12-19 09:57:26 +01:00
Benno Schulenberg 7ab7109972 docs: adjust some formatting and wordings in a handful of man pages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-12-19 09:57:25 +01:00
Benno Schulenberg f49ccec212 docs: don't use bold or italics for "[option]" in synopsis of man pages
As per the convention shown in Documentation/howto-man-page.txt.
Also make a few other tiny adjustments along the way.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-12-19 09:57:23 +01:00
Sami Kerola 338a6bc55b textual: improve error messages
Use error printing facilities that add command name in front of the error
message, and add explanation that is part of existing translations.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-09 09:19:22 +01:00
Karel Zak 0073a4cff2 libfdisk: rename sector_t to fdisk_sector_t
.. just to avoid too generic names for public API.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-04 11:41:51 +01:00
Karel Zak a1ef792fda libfdisk: rename and move function
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-26 17:33:07 +01:00
Karel Zak 0477369af4 libfdisk: remove flags from fdisk_ask API
We don't use it for anything usable, lets kill this over-engineering.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-21 15:31:55 +01:00
Karel Zak 333c376138 libfdisk: (dos) allow to maximize partition
The struct fdisk_partition has special flag "end_follow_default" to
make the partition large as much as possible. This patch makes this
flag usable for fdisk_set_partition() function.

Command line example (enlarge the first partition):

	# echo ',+' | ./sfdisk -N1 /dev/sdb
	...
	Disk /dev/sdb: 100 MiB, 104857600 bytes, 204800 sectors
	...
	Old situation:
	Device     Boot Start   End Sectors Size Id Type
	/dev/sdb1        2048 22527   20480  10M 83 Linux
			      ^^^^^
	New situation:
	Device     Boot Start    End Sectors Size Id Type
	/dev/sdb1        2048 204799  202752  99M 83 Linux
			      ^^^^^^

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-20 13:11:38 +01:00
Sami Kerola acec6eec4e mkswap: remove memory leaks [LeakSanitizer] [valgrind]
==18922==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x49d12b in __interceptor_malloc (/home/src/util-linux/.libs/lt-mkswap+0x49d12b)
    #1 0x7faf2a5069c9 in __GI___strdup (/usr/lib/libc.so.6+0x819c9)
    #2 0xffff96e7e33 (<unknown module>)

SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s).

And another one that valgrind found.

==6316== 8 bytes in 1 blocks are definitely lost in loss record 1 of 1
==6316==    at 0x4C29F90: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==6316==    by 0x5E3F9C9: strdup (in /usr/lib/libc-2.20.so)
==6316==    by 0x43A25F: size_to_human_string (strutils.c:495)
==6316==    by 0x42B35C: main (mkswap.c:488)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-18 12:56:46 +01:00
Boris Egorov 1ce1a112c4 fdisk: missing break in switch
Signed-off-by: Boris Egorov <egorov@linux.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-13 15:10:58 +01:00
Karel Zak 5c04b40850 cfdisk: cleanup menuitem draw functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-13 12:52:03 +01:00
Karel Zak 5cb9918d59 cfdisk: remove [Load] from menu
This functionality will be rarely used, so it does not make sense to
waste screen space with this menu item. It's enough to provide this
functionality in "Select label type" dialog (cfdisk --zero and then
'L' command).

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-13 11:19:58 +01:00
Karel Zak a89eafed85 cfdisk: add support for sfdisk scripts
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-12 16:12:39 +01:00
Karel Zak a30e4ef423 fdisk: add support for sfdisk scripts
New commands 'I' and 'O' allows to read and write sfdisk compatible
scripts by fdisk. It means that you can save your work (partition
table) and later use it (in fdisk, sfdisk or cfdisk) to create a new
partition table.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-12 11:15:06 +01:00
Karel Zak 9a83b03c73 mkswap: make final report more human readable
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-07 14:03:35 +01:00
Karel Zak 3ba01c145c mkswap: device write code refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-07 13:55:37 +01:00
Karel Zak fabf29f4fe mkswap: device open code refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-07 13:46:42 +01:00
Karel Zak 99f78758aa mkswap: always use header from control struct
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-07 13:35:50 +01:00
Karel Zak 8591859cd7 mkswap: coding style improvements
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-07 13:25:11 +01:00
Benno Schulenberg 24930e7088 docs: fix some wording, grammar and formatting in man page of swapon
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-11-07 13:21:06 +01:00
Sami Kerola d68f402c54 mkswap: various minor improvement
Use correct data type in page_bad(), and add information to error message
how many bad pages were seen.

In check_blocks() move initialization to variable introduction, fix typo,
and avoid memset() when array initializer can do the job.

In main() use correct initializer for pointer.  Move swap file specific
actions to same location, and add warning when request too --check is
dismissed by command.  At the end remove momory leak.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-07 13:21:06 +01:00
Sami Kerola 076ba5a696 mkswap: set variable only when it's value is known
Avoid updating ctl->pagesize twice when user does specify page size.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-07 13:21:06 +01:00
Sami Kerola 6af1822752 mkswap: make remaining functions to take control structure as argument
The wipe_device() and new_prober().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-07 13:21:06 +01:00
Sami Kerola de3822c39c mkswap: add struct mkswap_control to remove global variables
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-07 13:21:06 +01:00
Sami Kerola 3d5c8ba1c9 mkswap: use err() rather than perror() && exit()
The messsages in err() are verified from po/util-linux.pot to be already
part of translations.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-07 13:21:05 +01:00
Sami Kerola c181617cfb mkswap: remove unnecessary size check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-07 13:21:05 +01:00
Sami Kerola a1466ab2b2 mkswap: remove system architecture specific max swap size checks
Since kernel version 2.3.4 (June 1999) all architectures has used
uint32_t as maximum number or pages in a swap device or file, there is no
longer need to support systems earlier than that.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-07 13:21:05 +01:00
Karel Zak c747564764 fdisk: fix and improve -l warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-07 10:42:49 +01:00
Karel Zak d5206b9667 sfdisk: fix version typos in man page
Reported-by: JWP <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-07 09:33:57 +01:00
Karel Zak 68e422ecae docs: update info about env debug variables
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-03 13:13:54 +01:00
Sami Kerola 5d36513976 sfdisk: return deterministic value from sfdisk_deinit()
disk-utils/sfdisk.c:222:9: warning: variable 'rc' is uninitialized when
used here [-Wuninitialized]
        return rc;
disk-utils/sfdisk.c:208:8: note: initialize the variable 'rc' to silence
this warning
        int rc;

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-31 10:38:55 +01:00
Karel Zak 819d9a2975 include/debug: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-24 11:19:23 +02:00
Karel Zak fd211531e8 fdisk: add section about sizes to the man page
Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=594005
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-23 12:11:50 +02:00
Sami Kerola f0f2be20ed sfdisk: fix compiler warnings about uninitialized variables
warning: 'str' may be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-20 14:07:21 +02:00
Karel Zak dfc6db2a35 libfdisk: cleanup parttype API
* add reference counting
 * add functions to set allocated types

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-15 14:10:25 +02:00
Karel Zak ecf40cda76 libfdisk: make it possible to use zero for size and start
The zero may be valid size and start of the partition. This patch
introduces:

	fdisk_partition_has_start()
	fdisk_partition_has_size()
	fdisk_partition_unset_size()
	fdisk_partition_unset_start()

to make it possible to work with zero. The feature is internally
implemented by magic constant ((type) -1) for undefined sizes and
offsets.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-15 12:17:40 +02:00
Karel Zak 3692c28d06 tests: add PMBR sfdisk test
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-13 13:30:28 +02:00
Karel Zak 90dc69e40a sfdisk: leave on error
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-10 12:52:24 +02:00
Karel Zak 05af8bd4f0 sfdisk: ask on EOF
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-09 12:23:59 +02:00
Karel Zak 9b0b9fb1bf libfdisk: follow explicitly specified partition size
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-09 12:09:07 +02:00
Karel Zak 6d812a4859 fdisk: reset cached output fields when change disk label
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-09 12:03:32 +02:00
Karel Zak 8be199ea2b sfdisk: cleanup isatty() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-08 13:00:56 +02:00
Karel Zak e1422de3d8 sfdisk: add --label-nested for hybrid GPT
regular disk label:
	# sfdisk --list /dev/sdb
	..
	Disklabel type: gpt
	Disk identifier: 9DF9A9F1-0654-4E7A-9A5E-36E66D60FD79

	Device     Start    End Sectors Size Type
	/dev/sdb1   2048  22527   20480  10M Linux filesystem
	/dev/sdb2  22528  43007   20480  10M Linux swap
	/dev/sdb3  43008 204766  161759  79M Linux filesystem

nested (PMBR):
	# sfdisk --list --label-nested dos /dev/sdb
	...
	Disklabel type: dos
	Disk identifier: 0x00000000

	Device     Boot Start    End Sectors  Size Id Type
	/dev/sdb1           1 204799  204799  100M ee GPT

and for example:
        # sfdisk --label-nested dos /dev/sdb <<EOF
        1, 2047, ee
        , 10M, L
        , 10M, S
        ,,

creates hybrid GPT (PMBR partitions point to the same location as GPT)

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:33 +02:00
Karel Zak a8a4887bcd libfdisk: fix sun and sgi to be usable from sfdisk
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:33 +02:00
Karel Zak f5aa7b613d fdisk: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 01f9286cb1 sfdisk: add --output <list> for print command(s)
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak fff8ad5882 fdisk: add --output <list> for print command(s)
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak bc9e854709 sfdisk: add --part-attrs
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak e36fb07af6 sfdisk: cleanup option names
Rename options to --part-{label,uuid,type} to be compatible with
another tools (like lsblk, parts, etc).

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 351fad5069 sfdisk: add --name
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 3a5bdedf6a sfdisk: add --uuid command
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 9a79aa6e7a sfdisk: more update to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 5aac742940 sfdisk: update man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 347a7f7756 sfdisk: add --append
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak e54b1c6fcb sfdisk: be sensitive to PT limits
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak ab02d87e4f sfdisk: add --backup and --backup-file
The option --backup force sfdisk to store *all* fragments of the
partition table (including MBR partition tables store in the
extended partitions) to

	$HOME/sfdisk-<devname>-<offset>.bak

The options -O, -backup-file <path> allows to override the default
path, but sfdisk still appends <devname>-<offset>.bak to the <path>.
The backup files always contain only raw data from the device, so it's
possible to use dd(1) to restore original data on the device.

The original sfdisk also supported -O <file>, but semantic was little
bit different:

   - all was based on 512-byte sectors
   - all sectors was stored to the one file in format
	  <offset>|<sector>|<offset>|...

this original concept makes the backup files specific to sfdisk and with
dependence on sector size.

The new concept is the same we already use for wipefs(8) backup files.

Example (disk with GPT):

   # sfdisk /dev/sda --backup

   Welcome to sfdisk (util-linux 2.25.202-f4deb-dirty).
   Changes will remain in memory only, until you decide to write them.
   Be careful before using the write command.

   Backup files:
          PMBR (offset     0, size   512): /root/sfdisk-sda-0x00000000.bak
    GPT Header (offset   512, size   512): /root/sfdisk-sda-0x00000200.bak
   GPT Entries (offset  1024, size 16384): /root/sfdisk-sda-0x00000400.bak

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak db48b6a189 sfdisk: add --no-reread and --force
and also check if the device is in use.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak f01f252857 sfdisk: add --no-act
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 35ce145f6a sfdisk: add deprecated --Linux
The sfdisk does not care about compatibility with classic DOS
partitioning, and it does not warn about incompatibility with DOS at
all. It means that --Linux is default and it's unnecessary to use
this option.

It's the same situation like with "--unit S", these options are very
probably often used in scripts, and these all is default now. So for
backward compatibility new sfdisk accepts these options on command
line, but prints "option is deprecated" warning message.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak f0edb076ed sfdisk: add --quiet
Note that original sfdisk implementation suppressed warning
messages for --quiet.

Now we keep warning and error messages visible, but suppress
extra info messages only (for example to make it more usable in
scripts). IMHO suppress warnings is bad idea.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak d420a7f9f6 sfdisk: add --unit and --show-geometry, update deprecated.txt
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 21ca986d71 sfdisk: cleanup sync() usage, fix --activate
* use sync() only if we change disk layout
 * don't use sync() when we change details (like partition type)

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 2e73a998f4 sfdisk: use fdisk_set_partition_type()
This is more simple than the generic fdisk_set_partition() API.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:32 +02:00
Karel Zak 43a1ccecda sfdisk: cleanup usage() and long options
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 8eab3194ce sfdisk: add --parttype
The patch also makes --{id,change-id,print-id} deprecated in favour
of --parttype. The original --id is too generic option name and the
--print-id and --change-id are unnecessary and inconsistent with
another sfdisk options (e.g. we don't have --change-bootable)

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak d2c47697e1 sfdisk: add --verify
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 058dd97a1c sfdisk: add --list-types
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 2aa36b7372 sfdisk: add missing stuff to usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 6936c081ab libfdisk: (gpt) use generic API to change UUID and name
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 0ecf3ab504 libfdisk: (dos) implement fdisk_set_partition() backend
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak b4df449f53 sfdisk: support -N for primary partitions
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak e881349460 sfdisk: require confirmation before write to the device
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 2d12903265 libfdisk: make yes/no dialogs more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 3186f4a927 sfdisk: improve UI
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak d5bee4bb59 libfdisk: cleanup script size= code
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak c3bc748352 libfdisk: return partno when add new partition
* improve the way how sfdisk report results
 * the API change simplify applications

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 7324f1bf8c sfdisk: implement command_fdisk()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 254b1dfcc3 sfdisk: cleanup comments and command_activate()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 54b13b0c5c sfdisk: add --activate
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak 148f6e6d1c sfdisk: add comments, remove unnecessary function
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak d2eb145785 sfdisk: add --show-size
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak d464e2f0f9 fdisk: refactor /proc/partitions usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:31 +02:00
Karel Zak e3bb13d96c sfdisk: update usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:30 +02:00
Karel Zak 8a8d204cd1 sfdisk: add --dump functionality
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:30 +02:00
Karel Zak 207de32a97 sfdisk: --list just one device
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:30 +02:00
Karel Zak 9c1f9dd3a0 sfdisk: implement --list
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:30 +02:00
Karel Zak 152788aacb fdisk: improve --list output
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:30 +02:00
Karel Zak fdb006e8b5 fdisk: move --list functionality to separated file
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:30 +02:00
Karel Zak 1881390de2 sfdisk: basic main() and friends
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-07 14:55:30 +02:00
Sami Kerola db433bf737 textual: use usage() text element macros
Translating these text elements should happen only once, which is
more likely when the text macros are used properly.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:26 +02:00
Sami Kerola a587cc5520 textual: use manual tail usage() macro
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:24 +02:00
Sami Kerola f627750083 textual: use version printing macro everywhere
Only mount, umount, and blkid remains not using the macro because they
are print also library references.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:23 +02:00
Sami Kerola 7d2600e2d0 docs: update deprecation banners
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:11 +02:00
Karel Zak eef6397023 cfdisk: don't modify ncurses LINES and COLS
On Sun, Sep 28, 2014 at 01:48:38AM -0700, pv4 wrote:
 If ncurses is build with --enable-reentrant, building
 util-linux-2.25.1 fails with the folllowing error:

     disk-utils/cfdisk.c: In function 'resize':
     disk-utils/cfdisk.c:202:9: error: lvalue required as left operand of assignment
        LINES = ws.ws_row;
              ^
     disk-utils/cfdisk.c:203:8: error: lvalue required as left operand of assignment
        COLS = ws.ws_col;
             ^

 man COLS gives the following:

     Depending on the configuration, these may be actual variables,
     or macros (see curs_threads(3X)) which provide read-only
     access to curses's state.  In either case, applications should
     treat them as read-only to avoid confusing the library.

Addresses: https://github.com/karelzak/util-linux/issues/125
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-01 11:38:49 +02:00
Karel Zak 286f1e229b Merge branch 'misc' of git://github.com/kerolasa/lelux-utiliteetit
* 'misc' of git://github.com/kerolasa/lelux-utiliteetit:
  textual: share crypt() error message in sulogin and newgrp
  newgrp: avoid use of obsolete getpass() function
  newgrp: use libc function to read gshadow if it is available
  setarch: use personality() system call when it is available
  setarch: reindent code
  hwclock: remove referal to deprecated keyboard interface
  eject: make open_device() and select_speed() to use struct eject_control
  eject: add struct eject_control to remove global variables
  mountpoint: simplify if statement
  mkfs.minix: fix couple compiler warnings
  mountpoint: add struct mountpoint_control
  last: improve code readability by renaming variable names
  last: make is_phantom() when kernel config does not include audit support
  lib: remove xgetpass()
  include: simplify fputc_careful() in carefulputc.h
  libuuid: add extern qualifiers to uuid/uuid.h system header
2014-09-22 14:55:37 +02:00
Karel Zak 18b3e5495b swapon: split swapon-common.c
swapon    - requires libmount and libblkid
 swapoff   - requires libmount
 swaplabel - requires libblkid

This patch add lib/swapprober.c with blkid stuff for swap. It allows
to use and link libblkid only when necessary.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-09-22 13:16:25 +02:00
Sami Kerola e9b0ac10f2 mkfs.minix: fix couple compiler warnings
disk-utils/mkfs.minix.c:366:3: warning: ISO C forbids 'return' with
expression, in function returning void [-Wpedantic]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:01 +01:00
Jaromir Capik 0cbdf6e22f fdformat: fixing copy'n'paste issue in the manual
The end track default is media specific, not zero.
2014-09-16 11:14:25 +02:00
Karel Zak c7119037f0 libfdisk: use reference counting for context
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-28 12:49:16 +02:00
Karel Zak 59af21c3f2 cfdisk: fix typo in the previous commit
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-26 22:19:26 +02:00
Karel Zak ce3134dfdd cfdisk: wrong interpretation of yes in non-english language
Reported-by: tnut@nutyx.org
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-26 17:03:11 +02:00
Karel Zak 385810d22a libfdisk: remove debug dump function, cleanup API
The fdisk_dump_* prefix will be used for sfdisk-like functionality.
The patch also add FDISK_ prefix to fdisk_get_unit() options.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-22 10:25:35 +02:00
Karel Zak 6b11aad26b libfdisk: fix fdisk_get_optimal_iosize() and update tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-20 11:43:02 +02:00
Karel Zak e6d0c4c1ac fdisk: add independent debug stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-15 12:38:02 +02:00
Karel Zak 8eccde20dd fdisk: use libfdisk public API only
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-15 12:16:55 +02:00