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>
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>
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>
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>
The printout of the table headers and the bottomline descriptions
were lacking calls to gettext().
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
==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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
* '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
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>
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>
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>