* Start the ISO format flags at bit 0 instead of bit 1.
* Remove unnecessary _8601 from ISO format flag names to
avoid line wrapping and to ease readability.
* ISO timestamps have date-time-timzone in common, so move
the TIMEZONE flag to bit 2 causing all timestamp masks
to have the first three bits set and the last four bits
as timestamp 'options'.
* Change the 'SPACE' flag to a 'T' flag, because it makes
the code and comments more concise.
* Add common ISO timestamp masks.
* Implement the ISO timestamp masks in all applicable code
using the strxxx_iso() functions.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
This new function returns the GMT offset relative to its
argument. It is used in this patch to fix two bugs:
1) On platforms that the tm struct excludes tm_gmtoff,
hwclock assumes a one hour DST offset. This can cause
an incorrect kernel timezone setting. For example:
Master branch tested with tm_gmtoff illustrates the correct offset:
$ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday
Calling settimeofday(1507494204.192398, -660)
Master branch tested without tm_gmtoff has an incorrect offset:
$ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday
Calling settimeofday(1507494249.193852, -690)
Patched tested without tm_gmtoff has the correct offset:
$ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday
Calling settimeofday(1507494260.194208, -660)
2) ISO 8601 'extended' format requires all time elements
to use a colon (:).
Current invalid ISO 8601:
$ hwclock
2017-10-08 16:25:17.895462-0400
Patched:
$ hwclock
2017-10-08 16:25:34.141895-04:00
Also required by this change:
login-utils/last.c: increase ISO out_len and in_len by one to
accommodate the addition of the timezone colon.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
Although iso-8601 specifies years as 4 digits, it allows
them to be wider.
The current POSIX year width is limited by 'int tm_year'
at 10 digits plus a negative sign.
That, and the possibility of nanosecond time makes the
widest POSIX iso-8601 time 41 characters. Plus the \0
string terminator yields a buffer size of 42.
Before truncated output:
/sbin/hwclock --utc --noadjfile --predict --date '-2147483765 years'
-2147481748-09-25 20:29:45.0000
Patched:
./hwclock --utc --noadjfile --predict --date '-2147483765 years'
-2147481748-09-25 20:17:21.000000-0456
./hwclock --utc --noadjfile --predict --date '-2147483766 years'
hwclock: invalid date '-2147483766 years'
Comparable to coreutils 'date' command:
date -Ins --date '-2147483765 years'
-2147481748-09-25T19:49:31,578899297-0456
date -Ins --date '-2147483766 years'
date: invalid date '-2147483766 years'
The 'date' output illustrates the full 41 character POSIX iso-8601
Signed-off-by: J William Piggott <elseifthen@gmx.com>
FreeBSD since version 10 uses relative offsets for nested partitions.
Based on Richard Narron changes in kernel:block/partitions/msdos.c.
Signed-off-by: Karel Zak <kzak@redhat.com>
The commit c08396c769 replaces
open(O_CREATE) with ecaccess(). Unfortunately, another code depends on
the original behavior.
* let's make utab when really necessary rather than in the try_write() test
* __mnt_new_table_from_file() returns NULL if tab-file does not
exists. This is incorrect for tab_update.c stuff. We need empty table
in this case.
* we can check /run/mount/ directory for write access if
eaccess(filename) return ENOENT (because file does not exist)
Signed-off-by: Karel Zak <kzak@redhat.com>
MNT_FORCE and MNT_DETACH are orthogonal in the Linux kernel, so both may
be specified without any problems. Even if there were a problem with
this combination, it should be up to the kernel to take the correct
action or report an error.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
byteReverse() is an internal function in md5.c, and is not exposed via
any header file, but it is not declared as static. This is a problem
with the md5.c file since it is copied more or less verbatim in other
programs (fontconfig and pjsip among others), causing a link error
when linking two of them together.
Fixes link failures such as:
http://autobuild.buildroot.net/results/419ab2c0e034cc68991281c51caa8271b0fadbab/build-end.log
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
The /etc/issue file has been originally designed to inform users
about the system (version, name, etc.).
In last years is growing number of additional tools (containers,
maintenance tools and interfaces, ...) and many admins and downstream
maintainer want to add some tool specific hints to the issue file, but
it mess to share one file between more packages and/or scripts. The
solution is /etc/issue.d directory.
The directory is extension to the standard system /etc/issue. The
/etc/issue file has to exist, otherwise the directory will be ignored.
It means "rm /etc/issue" (or --onissue) is still the way how keep our
system silent independently on 3rd-party installed files in the
/etc/issue.d directory.
The content of the files in the directory are printed after content of
the /etc/issue. The files are printed in version-sort order and .issue
file extension is required (00-foo.issue 01-bar.issue ...).
The change is backwardly compatible.
Signed-off-by: Karel Zak <kzak@redhat.com>
Using wait() in a library may be problematic as it may reap some
totally unrelated child process instead of the just forked
one. That can result in the library call doing weird things and
returning bad return values, but also in a breakage of an
arbitrary other thing in the program using the library.
[[kzak@redhat.com: - use waitpid() for umount too
- keep the current codding style]
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's keep lsmem backwardly compatible (<=v2.30) and create ranges
according to the output columns by default. This default behavior may
be modified by --split command line option.
Signed-off-by: Karel Zak <kzak@redhat.com>
Without this, 'sfdisk -d' with certain filenames would lead to
reading an 's' from the 'type' field in fdisk_reset_labelitem
and cause a crash due to prematurely freeing the 'data.str' field.
Signed-off-by: Roddy Shuler <roddy@endlessm.com>
The utility fsck.cramfs is prone to a bus error on file systems for
big endian systems with non-standard header sizes. While calculating
the crc32 checksum, it does not properly handle a possible offset
for bootcodes, resulting in out of boundary access of mmap'ed area.
You can trigger the issue with the following commands:
$ mkdir -p cramfs-poc/root/subdir
$ cd cramfs-poc
$ mkfs.cramfs -p -N big root cramfs
$ echo -ne \\00\\x4c | dd of=cramfs bs=1 seek=518 count=2 conv=notrunc
$ fsck.cramfs cramfs
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Let use '-' rather than a partition number to disable the bootable flag
on all partitions:
sfdisk --activate /dev/sdc -
Signed-off-by: Karel Zak <kzak@redhat.com>
sun_add_partition() allowed the 1st sector to be 0 for the 3rd partition
only if that sector was free or if other partitions covered the whole
disk. Now it's always allowed for the 1st sector to be set to 0 for
the 3rd partition.
[kzak@redhat.com: - print info about "wholedisk" before "First sector" dialog for 3rd partition
- default to 0 for 3rd partition start sector]
Signed-off-by: Mikhail Vorobyov <m.vorobyov@cs.msu.ru>
Signed-off-by: Karel Zak <kzak@redhat.com>
The kernel outputs multi-line messages (kernel messages that contain
the end-of-line character '\n'). These message are currently displayed by
dmesg as
[965199.028940] runnable tasks:
task PID tree-key switches prio
wait-time sum-exec sum-sleep
----------------------------------------------------------------------------------------------------------
The kernel timestamps each of these lines with [965199.028940] and the
dmesg utility should do the same.
Add the 'force-prefix'/'-p' dmesg option to add decode & timestamp
information to each line of a multi-line message.
Notes: The new print_record() algorithm stores the decode & timestamp
information in buffers. If the force-prefix option is used, the
message is split into separate lines and each line is prefixed with
the stored decode & timestamp information. The splitting of the
message into separate lines is done using strtok() which requires
write access to the message buffer (ie, the const message buffer is
now copied into a writeable buffer).
Successfully tested by me by looking at sysrq-t and sysrq-w output.
All known good /tests passed with these changes.
[kzak@redhat.com:
- use snprintf()
- cleanup \n usage (don't count line break to the
message text in the parsers and always print \n after the text
- add the option to the man page
- use --force-prefix for kmsg only, old syslog(2) API splits messages itself
- strdup() the message text only on force-prefix]
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
When the bash-completion for fsck runs `find -L /dev/ -type b` it
descends into /dev/fd after opening '.' as file descriptor 3. This
causes find to search through /dev/fd/3/ which includes everything below
the current directory, which can take a very long time.
To avoid this, prune /dev/fd in the find expression.
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Testing image contains only the first 4k sector, so it is not valid,
but for blkid it should be enough.
Signed-off-by: Milan Broz <gmazyland@gmail.com>
This patch adds support for detection of a LUKS2 superblock.
LUKS2 is new version of Linux Unified Key Setup for encrypted
block devices.
LUKS2 contains a binary header and then JSON area for metadata.
Blkid should only parse the binary part, including newly available
optional LABEL and SUBSYSTEM fields.
LABEL is similar to filesystem label. The SUBSYSTEM field is
in principle, just a second label and can be used for specific udev rules
(for example if you have some 3rd party system that activates
volumes automatically, you can mark devices using this attribute).
Both labels are optional.
The magic string and UUID location are intentionally on the same offset
as LUKS v1, so even unpatched blkid now recognizes LUKS2.
Anyway, the code should not parse other versions of the header, so we now
explicitly check for header version and support only version 1 and 2.
Signed-off-by: Milan Broz <gmazyland@gmail.com>
Now the way how lsmem lists memory ranges is affected by used output
columns. It makes it very difficult to use in scripts where you want
to use for example only one column
ranges=$(lsmem -oRANGE)
and in this case all is merged to the one (or two) huge ranges and all
attributes are ignored. The --split allows to control this behavior
ranges=$(lsmem -oRANGE --split=STATE,ZONES)
forces lsmem to list ranges by STATE and ZONES differences.
Signed-off-by: Karel Zak <kzak@redhat.com>