* 'gpt-part-name' of https://github.com/yontalcar/util-linux:
libfdisk: return bytes processed from gpt_entry_set_name(), process rc
libfdisk: allocate enough bytes for ucs2 to utf8 encoding
libfdisk: gpt: properly encode string on rename
lib/mbsalign: encode backslash to prevent ambiguity
The test behavior is fragile if depends on external helpers. Let's
keep it based on mount(2) only. The test will be faster too.
Note that "mount -t <pattern>" does not behaviour as expected with
helpers. We need to try another helper if the current one ends with
status=1 (waitpid()). Now it returns status from the first helper.
Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
Made gpt_entry_set_name() return number of utf8 bytes processed on
success, so info message about change can be accurate.
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Allocate 3*number_of_ucs2_characters bytes for utf8 output.
Also as we are using calloc there's no need to write terminating null
byte.
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
GPT partition name entry should be recorded as little endian UCS2, so I have
written proper conversion (assuming UTF8 input).
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
The syscall swapon() with two arguments is supported since Linux 1.3.2
and it's really long time ago... Let's assume that all libc header files
have been already fixed.
Signed-off-by: Karel Zak <kzak@redhat.com>
On Sun, Dec 17, 2017 at 07:47:49PM -0500, J William Piggott wrote
> * it contains multi-byte characters (which is what drew me to reading it).
> * it truncates one very important piece of the formula: ". . . (mod 7)."
> * it explains the values for 'e', but there is no 'e' in the code.
> * it doesn't include a row resolving 'e' in the table, so it is not
> obvious what it relates to in the code.
> * without citing it as an external reference, the comment language is confusing.
Co-Author: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's use the same semantic for the title as for the last column in
the table. If aligned on left, table is not "maxout" and title padding
symbol is undefined (or blank) then keep title as short as possible.
Addresses: https://github.com/karelzak/util-linux/issues/549
Signed-off-by: Karel Zak <kzak@redhat.com>
Unfortunately, the symbols are visible in statically compiled libuuid
and the names are too generic.
Addresses: https://github.com/karelzak/util-linux/issues/548
Signed-off-by: Karel Zak <kzak@redhat.com>
Add more information when and why one might want to use various options.
Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Print a message when the format_iso_time() buffer is exceeded, because
there is more than one type of failure that returns -1.
Also remove the corresponding message from hwclock.c.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
Year can wrap when adding the tm struct epoch during iso formatting:
hwclock --utc --noadjfile --predict --date '67768034678844900 seconds'
-2147481749-12-31 23:59:59.000000-05:00
Patched:
hwclock --utc --noadjfile --predict --date '67768034678844900 seconds'
2147485547-12-31 23:59:59.000000-05:00
Comparable to date(1):
date -Ins --date '67768034678844900 seconds'
2147485547-12-31T23:59:59,547886165-0500
Note: the 'seconds' argument is relative to the current time, so
reaching this max year output is a moving target. The values shown
above were invalid one second later. They then overflow tm_year
upon conversion with localtime(3) and friends, which causes them
to return NULL indicating that an error occurred.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
Test for libc time conversion errors in ISO time format functions.
hwclock --utc --noadjfile --predict --date '67768034678846520 seconds'
Segmentation fault
Patched:
hwclock --utc --noadjfile --predict --date '67768034678846520 seconds'
hwclock: time 67768036191695381 is out of range.
Comparable to date(1):
date --date '67768034678846520 seconds'
date: time 67768036191695384 is out of range
Signed-off-by: J William Piggott <elseifthen@gmx.com>
Use reentrant time functions to avoid sending a NULL pointer to
format_iso_time() (and to be reentrant ;). Followup commits test for
errors and tm_year wrapping (illustrated below).
hwclock --utc --noadjfile --predict --date '67768034678849400 seconds'
Segmentation fault
Patched
hwclock --utc --noadjfile --predict --date '67768034678849400 seconds'
-2147481748-01-00 00:10:46.000000-05:00
Signed-off-by: J William Piggott <elseifthen@gmx.com>
The patch enables flock for scsi_debug to avoid collision between
tests. The patch also adds ./run.sh --nolocks to disable this feature.
Signed-off-by: Karel Zak <kzak@redhat.com>
Remove global variable, skip unnecessary comparison, and remove version
printing function when a simple printf() can do the job. In same go fix
compiler warning.
sys-utils/setarch.c:296:4: warning: null argument where non-null required
(argument 2) [-Wnonnull]
execl("/bin/bash", NULL);
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This is more lightweight than calling stat(3). In same go add a regression
test to ensure changes like this will not break --no-overwrite option.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
We have command line option -H to disable hostname in login prompt.
Unfortunately, in same cases (e.g. telnetd) it's impossible to specify
login(1) command line options due to hardcoded execl()...
This patch introduces LOGIN_PLAIN_PROMPT boolean for /etc/login.defs
to suppress hostname in the prompt.
Signed-off-by: Karel Zak <kzak@redhat.com>
Based on patch from Vaclav Dolezal <vdolezal@redhat.com>, this
implementation is less invasive.
The patch adds a new while() for pread() call (so diff is mostly code
indention). The pread() is called for a real data only (addressed by
'off' and 'end') and we use SEEK_{DATA,HOLE} before the pread() to
skip already existing holes. The variables 'file_off' and 'file_end'
addresses area in the file as specified on fallocate command line.
Test:
$ truncate -s 10G testfile
$ dd if=/dev/zero of=testfile count=10 bs=1M conv=notrunc
old version:
$ time /usr/bin/fallocate --dig-holes --verbose testfile
testfile: 10 GiB (10737418240 bytes) converted to sparse holes.
real 0m3.013s
user 0m0.700s
sys 0m2.304s
new version:
$ time ./fallocate --dig-holes --verbose testfile
testfile: 10 MiB (10485760 bytes) converted to sparse holes.
real 0m0.026s
user 0m0.002s
sys 0m0.004s
The old version scans all file.
The change has minimal overhead for files without holes.
Addresses: https://github.com/karelzak/util-linux/issues/421
Co-Author: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
It seems better to deallocate logindefs.conf stuff in long time
running (=waiting) processes like login(1) and su(1).
Signed-off-by: Karel Zak <kzak@redhat.com>
The CDROM_SELECT_SPEED should be available practically everywhere. Where
the define is missing an error message about path /proc/sys/dev/cdrom/info
cannot be opened is better error than a warnx() about kernel support.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>