Compare commits

...
Sign in to create a new pull request.

53 commits

Author SHA1 Message Date
Karel Zak
960b779cfb build-sys: release++ (v2.31.1)
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-19 15:06:27 +01:00
Karel Zak
babcf965f5 docs: update v2.31.1-ReleaseNotes
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-19 15:04:56 +01:00
Karel Zak
d4e747c29f docs: update AUTHORS file
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-19 15:02:40 +01:00
Karel Zak
fbf9a18675 po: merge changes
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-19 15:01:31 +01:00
Jakub Bogusz
1db76aff7b po: update pl.po (from translationproject.org) 2017-12-19 14:40:08 +01:00
Takeshi Hamasaki
b36e1faf2e po: update ja.po (from translationproject.org) 2017-12-19 14:40:08 +01:00
Petr Písař
129f09b521 po: update cs.po (from translationproject.org) 2017-12-19 14:40:08 +01:00
Karel Zak
58688816c4 tests: don't use mount.<type> helpers in mount-by-pattern tests
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>
2017-12-19 13:46:35 +01:00
Masatake YAMATO
928ff98abb fincore: fix a typo in fincore.1
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-12-14 15:49:39 +01:00
Karel Zak
0984d07c25 tests: update libsmartcols/title
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:49:25 +01:00
Karel Zak
1b4613f757 libsmartcols: don't add blank padding after left aligned title
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>
2017-12-14 15:49:09 +01:00
Karel Zak
2772bb4143 sample-scols-title: add left title without padding
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:48:58 +01:00
Karel Zak
0808127d5d mcookie: properly initialize hash
This stupid mistake has been introduced by commit 46ae163a8e.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:48:31 +01:00
Karel Zak
09a69dfc77 lib/md5: use ul_/UL_ prefix
The symbols names are too generic.

Addresses: https://github.com/karelzak/util-linux/issues/548
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:48:21 +01:00
Karel Zak
549454b8f9 test_sha1: update helper
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:48:07 +01:00
Karel Zak
ff5feb96ec lib/sha1: use ul_/UL_prefix for symbols
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>
2017-12-14 15:47:54 +01:00
Sami Kerola
4b00335873 docs: improve setarch(8) manual page
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>
2017-12-14 15:47:37 +01:00
Sami Kerola
3f921ba8cb vipw: do not let editor to inherit open file descriptors
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-12-14 15:44:29 +01:00
Sami Kerola
b95c50f3aa man: use long options in text and add example to uuidgen
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-12-14 15:43:02 +01:00
Sami Kerola
1788df44ed misc: fix typos
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-12-14 15:42:52 +01:00
Karel Zak
b3fd1d6c69 nsenter: fix compiler warning [-Wuninitialized]
sys-utils/nsenter.c: In function ‘is_same_namespace’:
sys-utils/nsenter.c:170:2: warning: ‘b_ino’ may be used uninitialized in this function [-Wuninitialized]
sys-utils/nsenter.c:170:2: warning: ‘a_ino’ may be used uninitialized in this function [-Wuninitialized]

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:42:15 +01:00
Karel Zak
9feec6c2a0 rtcwake: fix sys vs. rtc time delta usage
srett commented:

 After some head scratching why relative wakeup using -s always works
 while -t didn't seem to work at all I discovered that the adjustment
 for time difference between sys and rtc is actually inverted when
 writing the alarm (code for -m show reading is fine), so if the RTC
 lags 10 minutes behind, the alarm will be shifted into the future by
 10 minutes, resulting in a wakeup that is 20 minutes late.

Addresses: https://github.com/karelzak/util-linux/issues/544
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:40:59 +01:00
Karel Zak
32337d96b1 hwclock: revert ioctl test
This commit reverts 1d5cffa16a.

(I did this revert manually as there was another changes in the code
and git-revert does not work in this case.)

Addresses: https://github.com/karelzak/util-linux/issues/543
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:40:15 +01:00
Karel Zak
0d732c2358 tests: update columns test due to dda229c7b2
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:40:03 +01:00
Karel Zak
3d0a32b2ea column: use \x<hex> for invalid multibyte seq.
Addresses: https://github.com/karelzak/util-linux/issues/542
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:39:50 +01:00
Karel Zak
a2c9f86b77 lib/mbsalign: add mbs_invalid_encode()
Like mbs_safe_encode(), but it does not care about control chars.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:39:40 +01:00
Karel Zak
1d5d658750 mount: add hint about -t and root perms to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:39:00 +01:00
Karel Zak
410078a36c lsblk: add hint about perms to man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:38:49 +01:00
Karel Zak
5996b3a9d2 libmount: add nsfs between pseudo filesystems
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:38:21 +01:00
J William Piggott
103c2b3768 hwclock: fix debug regression
commit f0a0ce7 makes debug mode implicit for the --test option.

Using the previous command syntax of --test and --debug
together invokes the undocumented Level 2 debugging when
setting the RTC. This can cause many thousands of lines of
output like:
1510967983.499968 < 1510967983.500000 (-0.000032)

Fix: bump Level 2 debugging to Level 9, just before the
other undocumented Level 10. This makes it improbable for
the development debug levels to be accessed unintentionally.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-12-14 15:37:26 +01:00
Mikhail Vorobyov
20bce203c8 libfdisk: (sun) enhance searching of free space
Potential partition start should be aligned to cylinders. So fdisk
wouldn't consider partition's last cylinder remains as eligible space
for new partition start.
2017-12-14 15:35:33 +01:00
Mikhail Vorobyov
aa4523d280 libfdisk: (sun) move aligning of the first sector before availability check
So it will check a sector which would be actualy used as the first sector
of the partition.
2017-12-14 15:35:22 +01:00
Karel Zak
1b6cbf5b4f mount: add more details about UUIDs and LABELs to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:34:38 +01:00
Karel Zak
7cba18f3a9 blockdev: be more explicit for BLKSSZ in blockdev.8
Addresses: https://github.com/karelzak/util-linux/issues/535
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:33:36 +01:00
J William Piggott
a62e5dacff lib/timeutils: ISO_8601_BUFSIZ too small
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>
2017-12-14 15:32:24 +01:00
J William Piggott
12378f1bac hwclock: add iso-8601 overflow check
hwclock wasn't testing for strtimeval_iso() truncation:

/sbin/hwclock --utc --noadjfile --predict --date '7982 years'; echo $?
9999-09-25 19:33:01.000000-0400
0

/sbin/hwclock --utc --noadjfile --predict --date '7983 years'; echo $?
10000-09-25 19:33:10.000000-
0

Patched:
./hwclock --utc --noadjfile --predict --date '7982 years'; echo $?
9999-09-25 19:22:15.000000-0400
0

./hwclock --utc --noadjfile --predict --date '7983 years'; echo $?
hwclock: iso-8601 format truncated
1

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-12-14 15:32:13 +01:00
Pali Rohár
8aa44f8dc7 libblkid: vfat: Fix reading labels which starts with byte 0x05
When FAT directory entry has leading byte 0x05 it is interpreted as byte
0xE5. This is how FAT stores file name which starts with byte 0xE5 as
leading byte in 0xE5 in FAT directory entry means that file slot is empty.

Fixes: #533
2017-12-14 15:29:59 +01:00
Joshua Watt
1e79f87eab libmount: Allow MNT_FORCE and MNT_DETACH at umount
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>
2017-12-14 15:29:38 +01:00
Luca Ceresoli
658e03b294 md5: declare byteReverse as static
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>
2017-12-14 15:29:22 +01:00
Karel Zak
478b902760 rtcwake: add note about HW and sleep to the man page
Addresses: https://github.com/karelzak/util-linux/issues/527
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:29:02 +01:00
Dirk Mueller
0d24a937fc lscpu: Treat read failure on Xen Hypervisor properties as non-fatal
At least on the Sydney Amazon EC2 region this file doesn't show up,
and the fatal exit code causes the rest of the useful information
to not show up.
2017-12-14 15:28:12 +01:00
Karel Zak
0ce8df8c84 sfdisk: create empty label on 'write' command
Addresses: https://github.com/karelzak/util-linux/issues/528
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:27:54 +01:00
Karel Zak
abaf0c8e86 lslocks: add note about OFDLCK
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:27:20 +01:00
Roddy Shuler
76f7b55d1d libfdisk: Fix uninitialized structure
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>
2017-12-14 15:27:00 +01:00
Karel Zak
2b785cb144 tests: add fsck.cramfs bad-header test
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:26:46 +01:00
Tobias Stoeckmann
4906ccc4e6 fsck.cramfs: Fix bus error on broken file system.
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>
2017-12-14 15:26:35 +01:00
Mikhail Vorobyov
6b13880f36 libfdisk: (sun) fix creation of whole disk partition
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>
2017-12-14 15:25:39 +01:00
Kevin Locke
39ab4e85da bash-completion: Exclude /dev/fd from fsck find
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>
2017-12-14 15:24:57 +01:00
Karel Zak
398c2e870d dmesg: add note about -F format to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:24:43 +01:00
Karel Zak
b4703e01f9 Revert "dmesg: fragment concatenation"
* introduces regressions
* stupid code; parse_kmsg_record() called more than once for each record

This reverts commit 22eb2f0190.
2017-12-14 15:24:23 +01:00
Milan Broz
95065a1807 tests: add LUKS test images
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>
2017-12-14 15:23:08 +01:00
Milan Broz
90a13e9531 blkid: Add support for LUKS2 and new LABEL attributes.
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>
2017-12-14 15:22:54 +01:00
Karel Zak
a8fb7537ea build-sys: move rfkill to /usr/sbin
The original implementation uses sbin, let's do it too.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:21:09 +01:00
90 changed files with 10931 additions and 10707 deletions

View file

@ -215,6 +215,7 @@ CONTRIBUTORS:
Dennis Jensen <dennis.h.jensen@siemens.com>
Diego Elio 'Flameeyes' Pettenò <flameeyes@gmail.com>
Dima Kogan <dkogan@cds.caltech.edu>
Dirk Mueller <dmueller@suse.com>
Dmitry V. Levin <ldv@altlinux.org>
Dong Hao <haodong@linux.vnet.ibm.com>
Dongli Zhang <dongli.zhang@oracle.com>
@ -344,6 +345,7 @@ CONTRIBUTORS:
Josep Puigdemont <josep.puigdemont@gmail.com>
Josh Triplett <josh@joshtriplett.org>
Joshua Hudson <joshudson@gmail.com>
Joshua Watt <jpewhacker@gmail.com>
Josiah Worcester <josiahw@gmail.com>
Juha Laiho <jlaiho@ichaos.nullnet.fi>
Jun Hamano <junio@shadow.twinsun.com>
@ -359,6 +361,7 @@ CONTRIBUTORS:
kernc <kerncece@gmail.com>
Kevin E. Martin <martin@cs.unc.edu>
kevin.granade@gmail.com <kevin.granade@gmail.com>
Kevin Locke <kevin@kevinlocke.name>
Kirill Elagin <kirelagin@gmail.com>
Kir Kolyshkin <kir@openvz.org>
Kunihiko IMAI <kimai@iodata.jp>
@ -373,6 +376,7 @@ CONTRIBUTORS:
Li Zefan <lizf@cn.fujitsu.com>
Lubomir Kundrak <lkundrak@redhat.com>
Lubomir Rintel <lkundrak@v3.sk>
Luca Ceresoli <luca@lucaceresoli.net>
Luciano Chavez <lnx1138@us.ibm.com>
Ludwig Nussel <ludwig.nussel@suse.de>
Lukas Czerner <lczerner@redhat.com>
@ -424,6 +428,7 @@ CONTRIBUTORS:
Mikel Olasagasti Uranga <hey_neken@mundurat.net>
Mike Place <mp@saltstack.com>
Mikhail Gusarov <dottedmag@dottedmag.net>
Mikhail Vorobyov <m.vorobyov@cs.msu.ru>
Miklos Szeredi <mszeredi@suse.cz>
Milan Bouchet-Valat <nalimilan@club.fr>
Milan Broz <mbroz@redhat.com>
@ -515,6 +520,7 @@ CONTRIBUTORS:
Robert Förster <Dessa@gmake.de>
Robert Millan <rmh@debian.org>
Robert Schiele <rschiele@gmail.com>
Roddy Shuler <roddy@endlessm.com>
Rodrigo Campos <rodrigo@sdfg.com.ar>
Rodrigo Stulzer Lopes <rodrigo@conectiva.com.br>
Rolf Fokkens <rolf@rolffokkens.nl>

View file

@ -0,0 +1,87 @@
util-linux 2.31.1 Release Notes
===============================
bash-completion:
- Exclude /dev/fd from fsck find [Kevin Locke]
blkid:
- Add support for LUKS2 and new LABEL attributes. [Milan Broz]
blockdev:
- be more explicit for BLKSSZ in blockdev.8 [Karel Zak]
build-sys:
- move rfkill to /usr/sbin [Karel Zak]
column:
- use \x<hex> for invalid multibyte seq. [Karel Zak]
dmesg:
- add note about -F format to the man page [Karel Zak]
docs:
- improve setarch(8) manual page [Sami Kerola]
- update AUTHORS file [Karel Zak]
fincore:
- fix a typo in fincore.1 [Masatake YAMATO]
fsck.cramfs:
- Fix bus error on broken file system. [Tobias Stoeckmann]
hwclock:
- add iso-8601 overflow check [J William Piggott]
- fix debug regression [J William Piggott]
- revert ioctl test [Karel Zak]
lib/mbsalign:
- add mbs_invalid_encode() [Karel Zak]
lib/md5:
- use ul_/UL_ prefix [Karel Zak]
lib/sha1:
- use ul_/UL_prefix for symbols [Karel Zak]
lib/timeutils:
- ISO_8601_BUFSIZ too small [J William Piggott]
libblkid:
- vfat Fix reading labels which starts with byte 0x05 [Pali Rohár]
libfdisk:
- (sun) enhance searching of free space [Mikhail Vorobyov]
- (sun) fix creation of whole disk partition [Mikhail Vorobyov]
- (sun) move aligning of the first sector before availability check [Mikhail Vorobyov]
- Fix uninitialized structure [Roddy Shuler]
libmount:
- Allow MNT_FORCE and MNT_DETACH at umount [Joshua Watt]
- add nsfs between pseudo filesystems [Karel Zak]
libsmartcols:
- don't add blank padding after left aligned title [Karel Zak]
lsblk:
- add hint about perms to man page [Karel Zak]
lscpu:
- Treat read failure on Xen Hypervisor properties as non-fatal [Dirk Mueller]
lslocks:
- add note about OFDLCK [Karel Zak]
man:
- use long options in text and add example to uuidgen [Sami Kerola]
mcookie:
- properly initialize hash [Karel Zak]
md5:
- declare byteReverse as static [Luca Ceresoli]
misc:
- fix typos [Sami Kerola]
mount:
- add hint about -t and root perms to the man page [Karel Zak]
- add more details about UUIDs and LABELs to the man page [Karel Zak]
nsenter:
- fix compiler warning [-Wuninitialized] [Karel Zak]
po:
- merge changes [Karel Zak]
- update cs.po (from translationproject.org) [Petr Písař]
- update ja.po (from translationproject.org) [Takeshi Hamasaki]
- update pl.po (from translationproject.org) [Jakub Bogusz]
rtcwake:
- add note about HW and sleep to the man page [Karel Zak]
- fix sys vs. rtc time delta usage [Karel Zak]
sample-scols-title:
- add left title without padding [Karel Zak]
sfdisk:
- create empty label on 'write' command [Karel Zak]
test_sha1:
- update helper [Karel Zak]
tests:
- add LUKS test images [Milan Broz]
- add fsck.cramfs bad-header test [Karel Zak]
- don't use mount.<type> helpers in mount-by-pattern tests [Karel Zak]
- update columns test due to dda229c7b2b16a31fae8e99079ab4f4ae5bc8eac [Karel Zak]
- update libsmartcols/title [Karel Zak]
vipw:
- do not let editor to inherit open file descriptors [Sami Kerola]

4
NEWS
View file

@ -1,3 +1,7 @@
util-linux 2.31.1: Dec 19 2017
* see Documentation/releases/v2.31.1-ReleaseNotes or the complete changelog at
https://www.kernel.org/pub/linux/utils/util-linux/v2.31/v2.31.1-ChangeLog
util-linux 2.31: Oct 19 2017
* see Documentation/releases/v2.31-ReleaseNotes or the complete changelog at
https://www.kernel.org/pub/linux/utils/util-linux/v2.31/v2.31-ChangeLog

View file

@ -32,7 +32,8 @@ _fsck_module()
return 0
;;
esac
COMPREPLY=( $(compgen -W "$(find -L /dev/ -type b 2>/dev/null)" -- $cur) )
COMPREPLY=( $(compgen -W "$(find -L /dev/ -path /dev/fd -prune \
-o -type b -print 2>/dev/null)" -- $cur) )
return 0
}
complete -F _fsck_module fsck

View file

@ -28,7 +28,7 @@ PACKAGE_VERSION_RELEASE=$(echo $PACKAGE_VERSION | awk -F. '{
dnl libblkid version
LIBBLKID_VERSION="$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR.$PACKAGE_VERSION_RELEASE"
LIBBLKID_DATE="19-Oct-2017"
LIBBLKID_DATE="19-Dec-2017"
LIBBLKID_LT_MAJOR=1
LIBBLKID_LT_MINOR=1
LIBBLKID_LT_MICRO=0

View file

@ -66,7 +66,7 @@ Print device size in bytes.
.IP "\fB\-\-getsize\fP"
Print device size (32-bit!) in sectors. Deprecated in favor of the \-\-getsz option.
.IP "\fB\-\-getss\fP"
Print sector size in bytes \(en usually 512.
Print logical sector size in bytes \(en usually 512.
.IP "\fB\-\-getsz\fP"
Get size in 512-byte sectors.
.IP "\fB\-\-rereadpt\fP"

View file

@ -220,23 +220,24 @@ static void test_crc(int start)
crc = crc32(0L, NULL, 0);
buf =
mmap(NULL, super.size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
mmap(NULL, start + super.size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
if (buf == MAP_FAILED) {
buf =
mmap(NULL, super.size, PROT_READ | PROT_WRITE,
mmap(NULL, start + super.size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (buf != MAP_FAILED) {
if (lseek(fd, 0, SEEK_SET) == (off_t) -1)
if (lseek(fd, start, SEEK_SET) == (off_t) -1)
err(FSCK_EX_ERROR, _("seek on %s failed"), filename);
if (read(fd, buf, super.size) != (ssize_t) super.size)
if (read(fd, (unsigned char *) buf + start, super.size) !=
(ssize_t) super.size)
err(FSCK_EX_ERROR, _("cannot read %s"), filename);
}
}
if (buf != MAP_FAILED) {
((struct cramfs_super *)((unsigned char *) buf + start))->fsid.crc =
crc32(0L, NULL, 0);
crc = crc32(crc, (unsigned char *) buf + start, super.size - start);
munmap(buf, super.size);
crc = crc32(crc, (unsigned char *) buf + start, super.size);
munmap(buf, start + super.size);
} else {
int retval;
size_t length = 0;

View file

@ -98,7 +98,7 @@ struct entry {
/* stats */
unsigned char *name;
unsigned int mode, size, uid, gid;
unsigned char md5sum[MD5LENGTH];
unsigned char md5sum[UL_MD5LENGTH];
unsigned char flags; /* CRAMFS_EFLAG_* */
/* FS data */
@ -194,16 +194,17 @@ do_munmap(char *start, unsigned int size, unsigned int mode){
/* compute md5sums, so that we do not have to compare every pair of files */
static void
mdfile(struct entry *e) {
MD5_CTX ctx;
char *start;
start = do_mmap(e->path, e->size, e->mode);
if (start == NULL) {
e->flags |= CRAMFS_EFLAG_INVALID;
} else {
MD5Init(&ctx);
MD5Update(&ctx, (unsigned char *) start, e->size);
MD5Final(e->md5sum, &ctx);
UL_MD5_CTX ctx;
ul_MD5Init(&ctx);
ul_MD5Update(&ctx, (unsigned char *) start, e->size);
ul_MD5Final(e->md5sum, &ctx);
do_munmap(start, e->size, e->mode);
@ -255,7 +256,7 @@ static int find_identical_file(struct entry *orig, struct entry *new, loff_t *fs
if ((orig->flags & CRAMFS_EFLAG_MD5) &&
(new->flags & CRAMFS_EFLAG_MD5) &&
!memcmp(orig->md5sum, new->md5sum, MD5LENGTH) &&
!memcmp(orig->md5sum, new->md5sum, UL_MD5LENGTH) &&
identical_file(orig, new)) {
new->same = orig;
*fslen_ub -= new->size;

View file

@ -1766,7 +1766,7 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
} while (1);
/* create empty disk label if label, but no partition specified */
if (rc == SFDISK_DONE_EOF && created == 0
if ((rc == SFDISK_DONE_EOF || rc == SFDISK_DONE_WRITE) && created == 0
&& fdisk_script_has_force_label(dp) == 1
&& fdisk_table_get_nents(tb) == 0
&& fdisk_script_get_header(dp, "label")) {

View file

@ -57,4 +57,7 @@ extern char *mbs_safe_encode(const char *s, size_t *width);
extern char *mbs_safe_encode_to_buffer(const char *s, size_t *width, char *buf, const char *safechars);
extern size_t mbs_safe_encode_size(size_t bytes);
extern char *mbs_invalid_encode(const char *s, size_t *width);
extern char *mbs_invalid_encode_to_buffer(const char *s, size_t *width, char *buf);
#endif /* UTIL_LINUX_MBSALIGN_H */

View file

@ -1,29 +1,24 @@
#ifndef MD5_H
#define MD5_H
#ifndef UTIL_LINUX_MD5_H
#define UTIL_LINUX_MD5_H
#ifdef HAVE_STDINT_H
#include <stdint.h>
#else
typedef unsigned int uint32_t;
#endif
#define MD5LENGTH 16
#define UL_MD5LENGTH 16
struct MD5Context {
struct UL_MD5Context {
uint32_t buf[4];
uint32_t bits[2];
unsigned char in[64];
};
void MD5Init(struct MD5Context *context);
void MD5Update(struct MD5Context *context, unsigned char const *buf,
unsigned len);
void MD5Final(unsigned char digest[MD5LENGTH], struct MD5Context *context);
void MD5Transform(uint32_t buf[4], uint32_t const in[16]);
void ul_MD5Init(struct UL_MD5Context *context);
void ul_MD5Update(struct UL_MD5Context *context, unsigned char const *buf, unsigned len);
void ul_MD5Final(unsigned char digest[UL_MD5LENGTH], struct UL_MD5Context *context);
void ul_MD5Transform(uint32_t buf[4], uint32_t const in[16]);
/*
* This is needed to make RSAREF happy on some MS-DOS compilers.
*/
typedef struct MD5Context MD5_CTX;
typedef struct UL_MD5Context UL_MD5_CTX;
#endif /* !MD5_H */
#endif /* !UTIL_LINUX_MD5_H */

View file

@ -1,5 +1,5 @@
#ifndef SHA1_H
#define SHA1_H
#ifndef UTIL_LINUX_SHA1_H
#define UTIL_LINUX_SHA1_H
/*
SHA-1 in C
@ -9,38 +9,19 @@
#include "stdint.h"
#define SHA1LENGTH 20
#define UL_SHA1LENGTH 20
typedef struct
{
uint32_t state[5];
uint32_t count[2];
unsigned char buffer[64];
} SHA1_CTX;
uint32_t state[5];
uint32_t count[2];
unsigned char buffer[64];
} UL_SHA1_CTX;
void SHA1Transform(
uint32_t state[5],
const unsigned char buffer[64]
);
void ul_SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
void ul_SHA1Init(UL_SHA1_CTX *context);
void ul_SHA1Update(UL_SHA1_CTX *context, const unsigned char *data, uint32_t len);
void ul_SHA1Final(unsigned char digest[UL_SHA1LENGTH], UL_SHA1_CTX *context);
void ul_SHA1(char *hash_out, const char *str, unsigned len);
void SHA1Init(
SHA1_CTX * context
);
void SHA1Update(
SHA1_CTX * context,
const unsigned char *data,
uint32_t len
);
void SHA1Final(
unsigned char digest[SHA1LENGTH],
SHA1_CTX * context
);
void SHA1(
char *hash_out,
const char *str,
unsigned len);
#endif /* SHA1_H */
#endif /* UTIL_LINUX_SHA1_H */

View file

@ -65,7 +65,7 @@ enum {
ISO_8601_GMTIME = (1 << 7)
};
#define ISO_8601_BUFSIZ 32
#define ISO_8601_BUFSIZ 42
int strtimeval_iso(struct timeval *tv, int flags, char *buf, size_t bufsz);
int strtm_iso(struct tm *tm, int flags, char *buf, size_t bufsz);

View file

@ -194,6 +194,67 @@ char *mbs_safe_encode_to_buffer(const char *s, size_t *width, char *buf, const c
return buf;
}
/*
* Copy @s to @buf and replace broken sequences to \x?? hex sequence. The
* @width returns number of cells. The @safechars are not encoded.
*
* The @buf has to be big enough to store mbs_safe_encode_size(strlen(s)))
* bytes.
*/
char *mbs_invalid_encode_to_buffer(const char *s, size_t *width, char *buf)
{
const char *p = s;
char *r;
size_t sz = s ? strlen(s) : 0;
#ifdef HAVE_WIDECHAR
mbstate_t st;
memset(&st, 0, sizeof(st));
#endif
if (!sz || !buf)
return NULL;
r = buf;
*width = 0;
while (p && *p) {
#ifdef HAVE_WIDECHAR
wchar_t wc;
size_t len = mbrtowc(&wc, p, MB_CUR_MAX, &st);
if (len == 0)
break; /* end of string */
if (len == (size_t) -1 || len == (size_t) -2) {
len = 1;
/*
* Not valid multibyte sequence -- maybe it's
* printable char according to the current locales.
*/
if (!isprint((unsigned char) *p)) {
sprintf(r, "\\x%02x", (unsigned char) *p);
r += 4;
*width += 4;
} else {
(*width)++;
*r++ = *p;
}
} else {
memcpy(r, p, len);
r += len;
*width += wcwidth(wc);
}
p += len;
#else
*r++ = *p++;
(*width)++;
#endif
}
*r = '\0';
return buf;
}
size_t mbs_safe_encode_size(size_t bytes)
{
return (bytes * 4) + 1;
@ -218,6 +279,25 @@ char *mbs_safe_encode(const char *s, size_t *width)
return ret;
}
/*
* Returns allocated string where all broken widechars chars are
* replaced with \x?? hex sequence.
*/
char *mbs_invalid_encode(const char *s, size_t *width)
{
size_t sz = s ? strlen(s) : 0;
char *buf, *ret = NULL;
if (!sz)
return NULL;
buf = malloc(mbs_safe_encode_size(sz));
if (buf)
ret = mbs_invalid_encode_to_buffer(s, width, buf);
if (!ret)
free(buf);
return ret;
}
#ifdef HAVE_WIDECHAR
static bool

View file

@ -19,15 +19,15 @@
#include "md5.h"
#if !defined(WORDS_BIGENDIAN)
#define byteReverse(buf, len) /* Nothing */
# define byteReverse(buf, len) /* Nothing */
#else
void byteReverse(unsigned char *buf, unsigned longs);
static void byteReverse(unsigned char *buf, unsigned longs);
#ifndef ASM_MD5
/*
* Note: this code is harmless on little-endian machines.
*/
void byteReverse(unsigned char *buf, unsigned longs)
static void byteReverse(unsigned char *buf, unsigned longs)
{
uint32_t t;
do {
@ -37,14 +37,14 @@ void byteReverse(unsigned char *buf, unsigned longs)
buf += 4;
} while (--longs);
}
#endif
#endif
#endif /* !ASM_MD5 */
#endif /* !WORDS_BIGENDIAN */
/*
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
* initialization constants.
*/
void MD5Init(struct MD5Context *ctx)
void ul_MD5Init(struct UL_MD5Context *ctx)
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
@ -59,7 +59,7 @@ void MD5Init(struct MD5Context *ctx)
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
void ul_MD5Update(struct UL_MD5Context *ctx, unsigned char const *buf, unsigned len)
{
uint32_t t;
@ -84,7 +84,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
}
memcpy(p, buf, t);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32_t *) ctx->in);
ul_MD5Transform(ctx->buf, (uint32_t *) ctx->in);
buf += t;
len -= t;
}
@ -93,7 +93,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32_t *) ctx->in);
ul_MD5Transform(ctx->buf, (uint32_t *) ctx->in);
buf += 64;
len -= 64;
}
@ -104,10 +104,10 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
}
/*
* Final wrapup - pad to 64-byte boundary with the bit pattern
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void MD5Final(unsigned char digest[MD5LENGTH], struct MD5Context *ctx)
void ul_MD5Final(unsigned char digest[UL_MD5LENGTH], struct UL_MD5Context *ctx)
{
unsigned count;
unsigned char *p;
@ -128,7 +128,7 @@ void MD5Final(unsigned char digest[MD5LENGTH], struct MD5Context *ctx)
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32_t *) ctx->in);
ul_MD5Transform(ctx->buf, (uint32_t *) ctx->in);
/* Now fill the next block with 56 bytes */
memset(ctx->in, 0, 56);
@ -145,9 +145,9 @@ void MD5Final(unsigned char digest[MD5LENGTH], struct MD5Context *ctx)
memcpy(&ctx->in[14 * sizeof(uint32_t)], &ctx->bits[0], 4);
memcpy(&ctx->in[15 * sizeof(uint32_t)], &ctx->bits[1], 4);
MD5Transform(ctx->buf, (uint32_t *) ctx->in);
ul_MD5Transform(ctx->buf, (uint32_t *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4);
memcpy(digest, ctx->buf, MD5LENGTH);
memcpy(digest, ctx->buf, UL_MD5LENGTH);
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
}
@ -170,7 +170,7 @@ void MD5Final(unsigned char digest[MD5LENGTH], struct MD5Context *ctx)
* reflect the addition of 16 longwords of new data. MD5Update blocks
* the data and converts bytes into longwords for this routine.
*/
void MD5Transform(uint32_t buf[4], uint32_t const in[16])
void ul_MD5Transform(uint32_t buf[4], uint32_t const in[16])
{
register uint32_t a, b, c, d;

View file

@ -51,7 +51,7 @@ A million repetitions of "a"
/* Hash a single 512-bit block. This is the core of the algorithm. */
void SHA1Transform(
void ul_SHA1Transform(
uint32_t state[5],
const unsigned char buffer[64]
)
@ -179,8 +179,8 @@ void SHA1Transform(
/* SHA1Init - Initialize new context */
void SHA1Init(
SHA1_CTX * context
void ul_SHA1Init(
UL_SHA1_CTX * context
)
{
/* SHA1 initialization constants */
@ -195,8 +195,8 @@ void SHA1Init(
/* Run your data through this. */
void SHA1Update(
SHA1_CTX * context,
void ul_SHA1Update(
UL_SHA1_CTX * context,
const unsigned char *data,
uint32_t len
)
@ -213,10 +213,10 @@ void SHA1Update(
if ((j + len) > 63)
{
memcpy(&context->buffer[j], data, (i = 64 - j));
SHA1Transform(context->state, context->buffer);
ul_SHA1Transform(context->state, context->buffer);
for (; i + 63 < len; i += 64)
{
SHA1Transform(context->state, &data[i]);
ul_SHA1Transform(context->state, &data[i]);
}
j = 0;
}
@ -228,9 +228,9 @@ void SHA1Update(
/* Add padding and return the message digest. */
void SHA1Final(
void ul_SHA1Final(
unsigned char digest[20],
SHA1_CTX * context
UL_SHA1_CTX * context
)
{
unsigned i;
@ -262,13 +262,13 @@ void SHA1Final(
}
#endif
c = 0200;
SHA1Update(context, &c, 1);
ul_SHA1Update(context, &c, 1);
while ((context->count[0] & 504) != 448)
{
c = 0000;
SHA1Update(context, &c, 1);
ul_SHA1Update(context, &c, 1);
}
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
ul_SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
for (i = 0; i < 20; i++)
{
digest[i] = (unsigned char)
@ -279,18 +279,18 @@ void SHA1Final(
memset(&finalcount, '\0', sizeof(finalcount));
}
void SHA1(
void ul_SHA1(
char *hash_out,
const char *str,
unsigned len)
{
SHA1_CTX ctx;
UL_SHA1_CTX ctx;
unsigned int ii;
SHA1Init(&ctx);
ul_SHA1Init(&ctx);
for (ii=0; ii<len; ii+=1)
SHA1Update(&ctx, (const unsigned char*)str + ii, 1);
SHA1Final((unsigned char *)hash_out, &ctx);
ul_SHA1Update(&ctx, (const unsigned char*)str + ii, 1);
ul_SHA1Final((unsigned char *)hash_out, &ctx);
hash_out[20] = '\0';
}

View file

@ -130,19 +130,21 @@ struct hfsplus_vol_header {
static int hfs_set_uuid(blkid_probe pr, unsigned char const *hfs_info, size_t len)
{
static unsigned char const hash_init[MD5LENGTH] = {
static unsigned char const hash_init[UL_MD5LENGTH] = {
0xb3, 0xe2, 0x0f, 0x39, 0xf2, 0x92, 0x11, 0xd6,
0x97, 0xa4, 0x00, 0x30, 0x65, 0x43, 0xec, 0xac
};
unsigned char uuid[MD5LENGTH];
struct MD5Context md5c;
unsigned char uuid[UL_MD5LENGTH];
struct UL_MD5Context md5c;
if (memcmp(hfs_info, "\0\0\0\0\0\0\0\0", len) == 0)
return -1;
MD5Init(&md5c);
MD5Update(&md5c, hash_init, MD5LENGTH);
MD5Update(&md5c, hfs_info, len);
MD5Final(uuid, &md5c);
ul_MD5Init(&md5c);
ul_MD5Update(&md5c, hash_init, UL_MD5LENGTH);
ul_MD5Update(&md5c, hfs_info, len);
ul_MD5Final(uuid, &md5c);
uuid[6] = 0x30 | (uuid[6] & 0x0f);
uuid[8] = 0x80 | (uuid[8] & 0x3f);
return blkid_probe_set_uuid(pr, uuid);

View file

@ -24,6 +24,10 @@
#define LUKS_SALTSIZE 32
#define LUKS_MAGIC_L 6
#define UUID_STRING_L 40
#define LUKS2_LABEL_L 48
#define LUKS2_SALT_L 64
#define LUKS2_CHECKSUM_ALG_L 32
#define LUKS2_CHECKSUM_L 64
struct luks_phdr {
uint8_t magic[LUKS_MAGIC_L];
@ -39,17 +43,47 @@ struct luks_phdr {
uint8_t uuid[UUID_STRING_L];
} __attribute__((packed));
struct luks2_phdr {
char magic[LUKS_MAGIC_L];
uint16_t version;
uint64_t hdr_size; /* in bytes, including JSON area */
uint64_t seqid; /* increased on every update */
char label[LUKS2_LABEL_L];
char checksum_alg[LUKS2_CHECKSUM_ALG_L];
uint8_t salt[LUKS2_SALT_L]; /* unique for every header/offset */
char uuid[UUID_STRING_L];
char subsystem[LUKS2_LABEL_L]; /* owner subsystem label */
uint64_t hdr_offset; /* offset from device start in bytes */
char _padding[184];
uint8_t csum[LUKS2_CHECKSUM_L];
/* Padding to 4k, then JSON area */
} __attribute__ ((packed));
static int probe_luks(blkid_probe pr, const struct blkid_idmag *mag)
{
struct luks_phdr *header;
struct luks_phdr *header_v1;
struct luks2_phdr *header;
int version;
header = blkid_probe_get_sb(pr, mag, struct luks_phdr);
header = blkid_probe_get_sb(pr, mag, struct luks2_phdr);
if (header == NULL)
return errno ? -errno : 1;
blkid_probe_strncpy_uuid(pr, (unsigned char *) header->uuid,
sizeof(header->uuid));
version = be16_to_cpu(header->version);
blkid_probe_sprintf_version(pr, "%u", be16_to_cpu(header->version));
if (version == 1) {
header_v1 = (struct luks_phdr *)header;
blkid_probe_strncpy_uuid(pr,
(unsigned char *) header_v1->uuid, UUID_STRING_L);
} else if (version == 2) {
blkid_probe_strncpy_uuid(pr,
(unsigned char *) header->uuid, UUID_STRING_L);
blkid_probe_set_label(pr,
(unsigned char *) header->label, LUKS2_LABEL_L);
blkid_probe_set_id_label(pr, "SUBSYSTEM",
(unsigned char *) header->subsystem, LUKS2_LABEL_L);
}
return 0;
}

View file

@ -165,6 +165,8 @@ static unsigned char *search_fat_label(blkid_probe pr,
if ((ent->attr & (FAT_ATTR_VOLUME_ID | FAT_ATTR_DIR)) ==
FAT_ATTR_VOLUME_ID) {
DBG(LOWPROBE, ul_debug("\tfound fs LABEL at entry %d", i));
if (ent->name[0] == 0x05)
ent->name[0] = 0xE5;
return ent->name;
}
}

View file

@ -433,7 +433,7 @@ const char *fdisk_get_collision(struct fdisk_context *cxt)
* fdisk_is_ptcollision:
* @cxt: fdisk context
*
* The collision detected by libblkid (usally another partition table). Note
* The collision detected by libblkid (usually another partition table). Note
* that libfdisk does not support all partitions tables, so fdisk_has_label()
* may return false, but fdisk_is_ptcollision() may return true.
*

View file

@ -418,7 +418,7 @@ int fdisk_script_read_context(struct fdisk_script *dp, struct fdisk_context *cxt
rc = fdisk_script_set_header(dp, "unit", "sectors");
if (!rc && fdisk_is_label(cxt, GPT)) {
struct fdisk_labelitem item;
struct fdisk_labelitem item = FDISK_LABELITEM_INIT;
char buf[64];
/* first-lba */

View file

@ -326,6 +326,7 @@ static void fetch_sun(struct fdisk_context *cxt,
struct sun_disklabel *sunlabel;
int continuous = 1;
size_t i;
int sectors_per_cylinder = cxt->geom.heads * cxt->geom.sectors;
assert(cxt);
assert(cxt);
@ -335,7 +336,7 @@ static void fetch_sun(struct fdisk_context *cxt,
sunlabel = self_disklabel(cxt);
*start = 0;
*stop = cxt->geom.cylinders * cxt->geom.heads * cxt->geom.sectors;
*stop = cxt->geom.cylinders * sectors_per_cylinder;
for (i = 0; i < cxt->label->nparts_max; i++) {
struct sun_partition *part = &sunlabel->partitions[i];
@ -345,12 +346,16 @@ static void fetch_sun(struct fdisk_context *cxt,
be16_to_cpu(info->id) != SUN_TAG_UNASSIGNED &&
be16_to_cpu(info->id) != SUN_TAG_WHOLEDISK) {
starts[i] = be32_to_cpu(part->start_cylinder) *
cxt->geom.heads * cxt->geom.sectors;
sectors_per_cylinder;
lens[i] = be32_to_cpu(part->num_sectors);
if (continuous) {
if (starts[i] == *start)
if (starts[i] == *start) {
*start += lens[i];
else if (starts[i] + lens[i] >= *stop)
int remained_sectors = *start % sectors_per_cylinder;
if (remained_sectors) {
*start += sectors_per_cylinder - remained_sectors;
}
} else if (starts[i] + lens[i] >= *stop)
*stop = starts[i];
else
continuous = 0;
@ -529,6 +534,11 @@ static int sun_add_partition(
} else {
struct fdisk_ask *ask;
if (n == 2)
fdisk_info(cxt, _("It is highly recommended that the "
"third partition covers the whole disk "
"and is of type `Whole disk'"));
snprintf(mesg, sizeof(mesg), _("First %s"),
fdisk_get_unit(cxt, FDISK_SINGULAR));
for (;;) {
@ -543,6 +553,10 @@ static int sun_add_partition(
fdisk_ask_number_set_low(ask, 0); /* minimal */
fdisk_ask_number_set_default(ask, 0); /* default */
fdisk_ask_number_set_high(ask, 0); /* maximal */
} else if (n == 2) {
fdisk_ask_number_set_low(ask, 0); /* minimal */
fdisk_ask_number_set_default(ask, 0); /* default */
fdisk_ask_number_set_high(ask, fdisk_scround(cxt, stop)); /* maximal */
} else {
fdisk_ask_number_set_low(ask, fdisk_scround(cxt, start)); /* minimal */
fdisk_ask_number_set_default(ask, fdisk_scround(cxt, start)); /* default */
@ -557,6 +571,19 @@ static int sun_add_partition(
if (fdisk_use_cylinders(cxt))
first *= fdisk_get_units_per_sector(cxt);
if (!fdisk_use_cylinders(cxt)) {
/* Starting sector has to be properly aligned */
int cs = cxt->geom.heads * cxt->geom.sectors;
int x = first % cs;
if (x) {
fdisk_info(cxt, _("Aligning the first sector from %u to %u "
"to be on cylinder boundary."),
first, first + cs - x);
first += cs - x;
}
}
/* ewt asks to add: "don't start a partition at cyl 0"
However, edmundo@rano.demon.co.uk writes:
"In addition to having a Sun partition table, to be able to
@ -584,24 +611,6 @@ static int sun_add_partition(
}
}
if (n == 2 && first != 0)
fdisk_warnx(cxt, _("It is highly recommended that the "
"third partition covers the whole disk "
"and is of type `Whole disk'"));
if (!fdisk_use_cylinders(cxt)) {
/* Starting sector has to be properly aligned */
int cs = cxt->geom.heads * cxt->geom.sectors;
int x = first % cs;
if (x) {
fdisk_info(cxt, _("Aligning the first sector from %u to %u "
"to be on cylinder boundary."),
first, first + cs - x);
first += cs - x;
}
}
stop = cxt->geom.cylinders * cxt->geom.heads * cxt->geom.sectors; /* ancient */
stop2 = stop;
for (i = 0; i < cxt->label->nparts_max; i++) {

View file

@ -696,7 +696,7 @@ static int do_umount(struct libmnt_context *cxt)
if (mnt_context_is_lazy(cxt))
flags |= MNT_DETACH;
else if (mnt_context_is_force(cxt))
if (mnt_context_is_force(cxt))
flags |= MNT_FORCE;
DBG(CXT, ul_debugobj(cxt, "umount(2) [target='%s', flags=0x%08x]%s",

View file

@ -282,6 +282,7 @@ int mnt_fstype_is_pseudofs(const char *type)
"mqueue",
"nfsd",
"none",
"nsfs",
"overlay",
"pipefs",
"proc",

View file

@ -62,6 +62,8 @@ int main(int argc, char *argv[])
static const struct option longopts[] = {
{ "maxout", 0, NULL, 'm' },
{ "width", 1, NULL, 'w' },
{ "help", 1, NULL, 'h' },
{ NULL, 0, NULL, 0 },
};
@ -73,8 +75,11 @@ int main(int argc, char *argv[])
if (!tb)
err(EXIT_FAILURE, "failed to create output table");
while((c = getopt_long(argc, argv, "mw:", longopts, NULL)) != -1) {
while((c = getopt_long(argc, argv, "hmw:", longopts, NULL)) != -1) {
switch(c) {
case 'h':
printf("%s [--help | --maxout | --width <num>]\n", program_invocation_short_name);
break;
case 'm':
scols_table_enable_maxout(tb, TRUE);
break;
@ -98,6 +103,12 @@ int main(int argc, char *argv[])
scols_cell_set_flags(title, SCOLS_CELL_FL_RIGHT);
scols_print_table(tb);
/* left without padding */
scols_cell_set_data(title, "This is left title (without padding)");
scols_cell_set_color(title, "yellow");
scols_cell_set_flags(title, SCOLS_CELL_FL_LEFT);
scols_print_table(tb);
/* center */
sy = scols_new_symbols();
if (!sy)
@ -110,13 +121,14 @@ int main(int argc, char *argv[])
scols_cell_set_flags(title, SCOLS_CELL_FL_CENTER);
scols_print_table(tb);
/* left */
/* left with padding */
scols_symbols_set_title_padding(sy, "-");
scols_cell_set_data(title, "This is left title (with padding)");
scols_cell_set_color(title, "blue");
scols_cell_set_flags(title, SCOLS_CELL_FL_LEFT);
scols_print_table(tb);
scols_unref_table(tb);
return EXIT_SUCCESS;
}

View file

@ -160,7 +160,7 @@ int scols_line_move_cells(struct libscols_line *ln, size_t newn, size_t oldn)
/* remember data from old position */
memcpy(&ce, &ln->cells[oldn], sizeof(struct libscols_cell));
/* remove old possition (move data behind oldn to oldn) */
/* remove old position (move data behind oldn to oldn) */
if (oldn + 1 < ln->ncells)
memmove(ln->cells + oldn, ln->cells + oldn + 1,
(ln->ncells - oldn - 1) * sizeof(struct libscols_cell));

View file

@ -761,7 +761,7 @@ static int print_title(struct libscols_table *tb)
{
int rc, color = 0;
mbs_align_t align;
size_t width, bufsz, titlesz;
size_t width, len = 0, bufsz, titlesz;
char *title = NULL, *buf = NULL;
assert(tb);
@ -773,7 +773,7 @@ static int print_title(struct libscols_table *tb)
/* encode data */
if (tb->no_encode) {
bufsz = strlen(tb->title.data) + 1;
len = bufsz = strlen(tb->title.data) + 1;
buf = strdup(tb->title.data);
if (!buf) {
rc = -ENOMEM;
@ -791,8 +791,8 @@ static int print_title(struct libscols_table *tb)
goto done;
}
if (!mbs_safe_encode_to_buffer(tb->title.data, &bufsz, buf, NULL) ||
!bufsz || bufsz == (size_t) -1) {
if (!mbs_safe_encode_to_buffer(tb->title.data, &len, buf, NULL) ||
!len || len == (size_t) -1) {
rc = -EINVAL;
goto done;
}
@ -818,6 +818,14 @@ static int print_title(struct libscols_table *tb)
case SCOLS_CELL_FL_LEFT:
default:
align = MBS_ALIGN_LEFT;
/*
* Don't print extra blank chars after the title if on left
* (that's same as we use for the last column in the table).
*/
if (len < width
&& !scols_table_is_maxout(tb)
&& isblank(*titlepadding_symbol(tb)))
width = len;
break;
}

View file

@ -564,15 +564,15 @@ void uuid_generate(uuid_t out)
*/
void uuid_generate_md5(uuid_t out, const uuid_t ns, const char *name, size_t len)
{
MD5_CTX ctx;
char hash[MD5LENGTH];
UL_MD5_CTX ctx;
char hash[UL_MD5LENGTH];
MD5Init(&ctx);
ul_MD5Init(&ctx);
/* hash concatenation of well-known UUID with name */
MD5Update(&ctx, ns, sizeof(uuid_t));
MD5Update(&ctx, (const unsigned char *)name, len);
ul_MD5Update(&ctx, ns, sizeof(uuid_t));
ul_MD5Update(&ctx, (const unsigned char *)name, len);
MD5Final((unsigned char *)hash, &ctx);
ul_MD5Final((unsigned char *)hash, &ctx);
memcpy(out, hash, sizeof(uuid_t));
@ -589,15 +589,15 @@ void uuid_generate_md5(uuid_t out, const uuid_t ns, const char *name, size_t len
*/
void uuid_generate_sha1(uuid_t out, const uuid_t ns, const char *name, size_t len)
{
SHA1_CTX ctx;
char hash[SHA1LENGTH];
UL_SHA1_CTX ctx;
char hash[UL_SHA1LENGTH];
SHA1Init(&ctx);
ul_SHA1Init(&ctx);
/* hash concatenation of well-known UUID with name */
SHA1Update(&ctx, ns, sizeof(uuid_t));
SHA1Update(&ctx, (const unsigned char *)name, len);
ul_SHA1Update(&ctx, ns, sizeof(uuid_t));
ul_SHA1Update(&ctx, (const unsigned char *)name, len);
SHA1Final((unsigned char *)hash, &ctx);
ul_SHA1Final((unsigned char *)hash, &ctx);
memcpy(out, hash, sizeof(uuid_t));

View file

@ -130,7 +130,7 @@ struct su_context {
const char *tty_number; /* end of the tty_path */
char *new_user; /* wanted user */
char *old_user; /* orginal user */
char *old_user; /* original user */
pid_t child; /* fork() baby */
int childstatus; /* wait() status */

View file

@ -257,7 +257,7 @@ static void edit_file(int is_shadow)
if (lckpwdf() < 0)
err(EXIT_FAILURE, _("cannot get lock"));
passwd_file = open(orig_file, O_RDONLY, 0);
passwd_file = open(orig_file, O_RDONLY | O_CLOEXEC, 0);
if (passwd_file < 0)
err(EXIT_FAILURE, _("cannot open %s"), orig_file);
tmp_fd = pw_tmpfile(passwd_file);
@ -275,7 +275,7 @@ static void edit_file(int is_shadow)
if (end.st_nlink == 0) {
if (close_stream(tmp_fd) != 0)
err(EXIT_FAILURE, _("write error"));
tmp_fd = fopen(tmp_file, "r");
tmp_fd = fopen(tmp_file, "r" UL_CLOEXECSTR);
if (!tmp_fd)
err(EXIT_FAILURE, _("cannot open %s"), tmp_file);
if (fstat(fileno(tmp_fd), &end))

View file

@ -56,7 +56,7 @@ Masatake YAMATO
.BR getpagesize (2),
.BR getconf (1)
.SH AVAILABILITY
The example command is part of the util-linux package and is available from
The fincore command is part of the util-linux package and is available from
.UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
Linux Kernel Archive
.UE .

View file

@ -13,7 +13,9 @@ command reads the
.B sysfs
filesystem and
.B udev db
to gather information.
to gather information. If the udev db is not available or lsblk is compiled without udev support than it
tries to read LABELs, UUIDs and filesystem types from the block device. In this case root permissions
are necessary.
.PP
The command prints all block devices (except RAM disks) in a tree-like format
by default. Use

View file

@ -53,8 +53,8 @@ The command name of the process holding the lock.
.IP "PID"
The process ID of the process which holds the lock.
.IP "TYPE"
The type of lock; can be FLOCK (created with \fBflock\fR(2)) or POSIX
(created with \fBfcntl\fR(2) and \fBlockf\fR(3)).
The type of lock; can be FLOCK (created with \fBflock\fR(2)), POSIX
(created with \fBfcntl\fR(2) and \fBlockf\fR(3)) or OFDLCK (created with fcntl(2).
.IP "SIZE"
Size of the locked file.
.IP "MODE"

View file

@ -72,7 +72,7 @@ struct colinfo {
static struct colinfo infos[] = {
[COL_SRC] = { "COMMAND",15, 0, N_("command of the process holding the lock") },
[COL_PID] = { "PID", 5, SCOLS_FL_RIGHT, N_("PID of the process holding the lock") },
[COL_TYPE] = { "TYPE", 5, SCOLS_FL_RIGHT, N_("kind of lock: FL_FLOCK or FL_POSIX.") },
[COL_TYPE] = { "TYPE", 5, SCOLS_FL_RIGHT, N_("kind of lock") },
[COL_SIZE] = { "SIZE", 4, SCOLS_FL_RIGHT, N_("size of the lock") },
[COL_MODE] = { "MODE", 5, 0, N_("lock access mode") },
[COL_M] = { "M", 1, 0, N_("mandatory state of the lock: 0 (none), 1 (set)")},

View file

@ -41,7 +41,7 @@ enum {
};
struct mcookie_control {
struct MD5Context ctx;
struct UL_MD5Context ctx;
char **files;
size_t nfiles;
uint64_t maxsz;
@ -67,12 +67,12 @@ static uint64_t hash_file(struct mcookie_control *ctl, int fd)
r = read_all(fd, (char *) buf, rdsz);
if (r < 0)
break;
MD5Update(&ctl->ctx, buf, r);
ul_MD5Update(&ctl->ctx, buf, r);
count += r;
}
/* Separate files with a null byte */
buf[0] = '\0';
MD5Update(&ctl->ctx, buf, 1);
ul_MD5Update(&ctl->ctx, buf, 1);
return count;
}
@ -131,7 +131,7 @@ int main(int argc, char **argv)
{
struct mcookie_control ctl = { .verbose = 0 };
size_t i;
unsigned char digest[MD5LENGTH];
unsigned char digest[UL_MD5LENGTH];
unsigned char buf[RAND_BYTES];
int c;
@ -176,18 +176,19 @@ int main(int argc, char **argv)
if (ctl.maxsz && ctl.nfiles == 0)
warnx(_("--max-size ignored when used without --file"));
ul_MD5Init(&ctl.ctx);
randomness_from_files(&ctl);
free(ctl.files);
random_get_bytes(&buf, RAND_BYTES);
MD5Update(&ctl.ctx, buf, RAND_BYTES);
ul_MD5Update(&ctl.ctx, buf, RAND_BYTES);
if (ctl.verbose)
fprintf(stderr, P_("Got %d byte from %s\n",
"Got %d bytes from %s\n", RAND_BYTES),
RAND_BYTES, random_tell_source());
MD5Final(digest, &ctl.ctx);
for (i = 0; i < MD5LENGTH; i++)
ul_MD5Final(digest, &ctl.ctx);
for (i = 0; i < UL_MD5LENGTH; i++)
printf("%02x", digest[i]);
putchar('\n');

View file

@ -27,19 +27,19 @@ will generate a random-based UUID if a high-quality random number
generator is present. Otherwise, it will choose a time-based UUID.
It is possible to force the generation of one of these first two
UUID types by using the
.B \-r
.B \-\-random
or
.B \-t
.B \-\-time
options.
.PP
The third type of UUID is generated with the
.B \-m
.B \-\-md5
or
.B \-s
options (MD5 or SHA1, respectively), followed by
.BR "\-n " \fInamespace
.B \-\-sha1
options, followed by
\fB\-\-namespace\fR \fInamespace\fR
and
.BR "\-N " \fIname\fR.
\fB\-\-name\fR \fIname\fR.
The \fInamespace\fR may either be a well-known UUID, or else
an alias to one of the well-known UUIDs defined in RFC 4122, that is
.BR @dns ,
@ -89,6 +89,8 @@ Generate the hash of the \fIname\fR.
Interpret name \fIname\fR as a hexidecimal string.
.SH "CONFORMING TO"
OSF DCE 1.1
.SH EXAMPLES
uuidgen \-\-sha1 \-\-namespace @dns \-\-name "www.example.com"
.SH AUTHOR
.B uuidgen
was written by Andreas Dilger for libuuid.

View file

@ -114,7 +114,7 @@ Display version information and exit.
.SH EXAMPLES
.TP
.BR "wipefs /dev/sda*"
Prints infomation about sda and all partitions on sda.
Prints information about sda and all partitions on sda.
.TP
.BR "wipefs --all --backup /dev/sdb"
Erases all signatures from the device /dev/sdb and creates a signature backup

754
po/ca.po

File diff suppressed because it is too large Load diff

1491
po/cs.po

File diff suppressed because it is too large Load diff

708
po/da.po

File diff suppressed because it is too large Load diff

708
po/de.po

File diff suppressed because it is too large Load diff

708
po/es.po

File diff suppressed because it is too large Load diff

756
po/et.po

File diff suppressed because it is too large Load diff

754
po/eu.po

File diff suppressed because it is too large Load diff

754
po/fi.po

File diff suppressed because it is too large Load diff

708
po/fr.po

File diff suppressed because it is too large Load diff

754
po/gl.po

File diff suppressed because it is too large Load diff

754
po/hr.po

File diff suppressed because it is too large Load diff

754
po/hu.po

File diff suppressed because it is too large Load diff

754
po/id.po

File diff suppressed because it is too large Load diff

754
po/it.po

File diff suppressed because it is too large Load diff

946
po/ja.po

File diff suppressed because it is too large Load diff

708
po/nl.po

File diff suppressed because it is too large Load diff

712
po/pl.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

756
po/ru.po

File diff suppressed because it is too large Load diff

754
po/sl.po

File diff suppressed because it is too large Load diff

708
po/sv.po

File diff suppressed because it is too large Load diff

708
po/tr.po

File diff suppressed because it is too large Load diff

708
po/uk.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

709
po/vi.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -60,7 +60,7 @@ renice_SOURCES = sys-utils/renice.c
endif
if BUILD_RFKILL
usrbin_exec_PROGRAMS += rfkill
usrsbin_exec_PROGRAMS += rfkill
dist_man_MANS += sys-utils/rfkill.8
rfkill_SOURCES = sys-utils/rfkill.c
rfkill_LDADD = $(LDADD) libcommon.la libsmartcols.la

View file

@ -49,8 +49,9 @@ Display the local time and the delta in human-readable format. Be aware that
conversion to the local time could be inaccurate (see \fB\-T\fR for more
details).
.IP "\fB\-F\fR, \fB\-\-file \fIfile\fR"
Read the messages from the given
Read the syslog messages from the given
.IR file .
Note that \fB\-F\fR does not support messages in kmsg format. The old syslog format is supported only.
.IP "\fB\-f\fR, \fB\-\-facility \fIlist\fR"
Restrict output to the given (comma-separated)
.I list

View file

@ -20,7 +20,6 @@
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <poll.h>
#include "c.h"
#include "colors.h"
@ -179,8 +178,6 @@ struct dmesg_control {
int kmsg; /* /dev/kmsg file descriptor */
ssize_t kmsg_first_read;/* initial read() return code */
char kmsg_buf[BUFSIZ];/* buffer to read kmsg data */
char kmsg_saved[BUFSIZ];/* buffer to save line after fragment */
ssize_t kmsg_saved_size; /* if nonzero, read from kmsg_saved */
/*
* For the --file option we mmap whole file. The unnecessary (already
@ -209,7 +206,6 @@ struct dmesg_record {
int level;
int facility;
struct timeval tv;
char flags;
const char *next; /* buffer with next unparsed record */
size_t next_size; /* size of the next buffer */
@ -226,13 +222,6 @@ struct dmesg_record {
static int read_kmsg(struct dmesg_control *ctl);
static int parse_kmsg_record(struct dmesg_control *ctl,
struct dmesg_record *rec,
char *buf,
size_t sz);
static int set_level_color(int log_level, const char *mesg, size_t mesgsz)
{
int id = -1;
@ -1024,101 +1013,15 @@ static void print_buffer(struct dmesg_control *ctl,
print_record(ctl, &rec);
}
/*
* Read one record from kmsg, automatically concatenating message fragments
*/
static ssize_t read_kmsg_one(struct dmesg_control *ctl)
{
ssize_t size;
struct dmesg_record rec = { .flags = 0 };
char fragment_buf[BUFSIZ] = { 0 };
ssize_t fragment_offset = 0;
if (ctl->kmsg_saved_size != 0) {
size = ctl->kmsg_saved_size;
memcpy(ctl->kmsg_buf, ctl->kmsg_saved, size);
ctl->kmsg_saved_size = 0;
return size;
}
/*
* kmsg returns EPIPE if record was modified while reading.
* Read records until there is one with a flag different from 'c'/'+',
* which indicates that a fragment (if it exists) is complete.
*/
/* kmsg returns EPIPE if record was modified while reading */
do {
/*
* If there is a fragment in progress, and we're in follow mode,
* read with a timeout so that if no line is read in 100ms, we can
* assume that the fragment is the last line in /dev/kmsg and it
* is completed.
*/
if (ctl->follow && fragment_offset) {
struct pollfd pfd = {.fd = ctl->kmsg, .events = POLLIN};
poll(&pfd, 1, 100);
/* If 100ms has passed and kmsg has no data to read() */
if (!(pfd.revents & POLLIN)) {
memcpy(ctl->kmsg_buf, fragment_buf, fragment_offset);
return fragment_offset + 1;
}
}
size = read(ctl->kmsg, ctl->kmsg_buf, sizeof(ctl->kmsg_buf) - 1);
/*
* If read() would have blocked and we have a fragment in
* progress, assume that it's completed (ie. it was the last line
* in the ring buffer) otherwise it won't be displayed until
* another non-fragment message is logged.
*/
if (errno == EAGAIN && fragment_offset) {
memcpy(ctl->kmsg_buf, fragment_buf, fragment_offset);
return fragment_offset + 1;
}
if (parse_kmsg_record(ctl, &rec, ctl->kmsg_buf,
(size_t) size) == 0) {
/*
* 'c' can indicate a start of a fragment or a
* continuation, '+' is used in older kernels to
* indicate a continuation.
*/
if (rec.flags == 'c' || rec.flags == '+') {
if (!fragment_offset) {
memcpy(fragment_buf, ctl->kmsg_buf, size);
fragment_offset = size - 1;
} else {
/*
* In case of a buffer overflow, just
* truncate the fragment - no one should
* be logging this much anyway
*/
ssize_t truncate_size = min(
fragment_offset + rec.mesg_size,
sizeof(fragment_buf));
memcpy(fragment_buf + fragment_offset,
rec.mesg, truncate_size);
fragment_offset += rec.mesg_size;
}
} else if (rec.flags == '-') {
/*
* If there was a fragment being built, move it
* into kmsg_buf, but first save a copy of the
* current message so that it doesn't get lost.
*/
if (fragment_offset) {
memcpy(ctl->kmsg_saved,
ctl->kmsg_buf, size);
ctl->kmsg_saved_size = size;
memcpy(ctl->kmsg_buf,
fragment_buf, fragment_offset);
return fragment_offset + 1;
}
}
}
} while ((size < 0 && errno == EPIPE) ||
(rec.flags == 'c' || rec.flags == '+'));
size = read(ctl->kmsg, ctl->kmsg_buf,
sizeof(ctl->kmsg_buf) - 1);
} while (size < 0 && errno == EPIPE);
return size;
}
@ -1212,17 +1115,11 @@ static int parse_kmsg_record(struct dmesg_control *ctl,
if (LAST_KMSG_FIELD(p))
goto mesg;
/* D) flags */
rec->flags = *p; // flag is one char
p = p + 1;
if (LAST_KMSG_FIELD(p))
goto mesg;
/* E) optional fields (ignore) */
/* D) optional fields (ignore) */
p = skip_item(p, end, ";");
mesg:
/* F) message text */
/* E) message text */
rec->mesg = p;
p = skip_item(p, end, "\n");
@ -1238,7 +1135,7 @@ mesg:
*/
unhexmangle_to_buffer(rec->mesg, (char *) rec->mesg, rec->mesg_size + 1);
/* G) message tags (ignore) */
/* F) message tags (ignore) */
return 0;
}

View file

@ -261,7 +261,7 @@ static int synchronize_to_clock_tick_rtc(const struct hwclock_control *ctl)
* they should.
*/
rc = -1;
errno = ENOTTY;
errno = EINVAL;
#else
rc = ioctl(rtc_fd, RTC_UIE_ON, 0);
#endif
@ -296,7 +296,7 @@ static int synchronize_to_clock_tick_rtc(const struct hwclock_control *ctl)
if (rc == -1)
warn(_("ioctl() to %s to turn off update interrupts failed"),
rtc_dev_name);
} else if (errno == ENOTTY) {
} else if (errno == ENOTTY || errno == EINVAL) {
/* rtc ioctl interrupts are unimplemented */
ret = busywait_for_rtc_clock_tick(ctl, rtc_fd);
} else

View file

@ -494,7 +494,7 @@ set_hardware_clock_exact(const struct hwclock_control *ctl,
/* The retarget is handled at the end of the loop. */
} else if (deltavstarget < 0) {
/* deltavstarget < 0 if current time < target time */
if (ctl->debug >= 2)
if (ctl->debug >= 9)
printf(_("%ld.%06ld < %ld.%06ld (%.6f)\n"),
nowsystime.tv_sec,
nowsystime.tv_usec,
@ -551,15 +551,19 @@ set_hardware_clock_exact(const struct hwclock_control *ctl,
set_hardware_clock(ctl, newhwtime);
}
static void
static int
display_time(struct timeval hwctime)
{
char buf[ISO_8601_BUFSIZ];
strtimeval_iso(&hwctime, ISO_8601_DATE|ISO_8601_TIME|ISO_8601_DOTUSEC|
if (strtimeval_iso(&hwctime, ISO_8601_DATE|ISO_8601_TIME|ISO_8601_DOTUSEC|
ISO_8601_TIMEZONE|ISO_8601_SPACE,
buf, sizeof(buf));
buf, sizeof(buf))) {
warnx(_("iso-8601 format overflow"));
return EXIT_FAILURE;
}
printf("%s\n", buf);
return EXIT_SUCCESS;
}
/*
@ -931,8 +935,7 @@ manipulate_clock(const struct hwclock_control *ctl, const time_t set_time,
printf(_ ("Target date: %ld\n"), set_time);
printf(_ ("Predicted RTC: %ld\n"), hclocktime.tv_sec);
}
display_time(hclocktime);
return EXIT_SUCCESS;
return display_time(hclocktime);
}
if (ctl->systz)
@ -978,7 +981,7 @@ manipulate_clock(const struct hwclock_control *ctl, const time_t set_time,
time_inc(hclocktime, time_diff(startup_time, read_time));
}
if (ctl->show || ctl->get) {
display_time(startup_hclocktime);
return display_time(startup_hclocktime);
} else if (ctl->set) {
set_hardware_clock_exact(ctl, set_time, startup_time);
if (!ctl->noadjfile)

View file

@ -954,9 +954,6 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod)
== XEN_FEATURES_PVH_MASK)
desc->virtype = VIRT_PARA;
fclose(fd);
} else {
err(EXIT_FAILURE, _("failed to read from: %s"),
_PATH_SYS_HYP_FEATURES);
}
}
} else if (read_hypervisor_powerpc(desc) > 0) {}

View file

@ -63,7 +63,8 @@ These files can be spread out over several devices. The
command serves to attach the filesystem found on some device
to the big file tree. Conversely, the
.BR umount (8)
command will detach it again.
command will detach it again. The filesystem is used to control how data is
stored on the device or provided in a virtual way by network or another services.
The standard form of the
.B mount
@ -81,6 +82,10 @@ This tells the kernel to attach the filesystem found on
.IR type )
at the directory
.IR dir .
The option \fB\-t \fItype\fR is optional. The
.B mount
command is usually able to detect a filesystem. The root permissions are necessary
to mount a filesystem by default. See section "Non-superuser mounts" below for more details.
The previous contents (if any) and owner and mode of
.I dir
become invisible, and as long as this filesystem remains mounted,
@ -125,7 +130,7 @@ The following command lists all mounted filesystems (of type
.RE
The option \fB\-l\fR adds labels to this listing. See below.
.SS Indicating the device
.SS Indicating the device and filesystem
Most devices are indicated by a filename (of a block special device), like
.IR /dev/sda1 ,
but there are other possibilities. For example, in the case of an NFS mount,
@ -134,15 +139,24 @@ may look like
.IR knuth.cwi.nl:/dir .
It is also possible to indicate a block special device using its filesystem label
or UUID (see the \fB\-L\fR and \fB\-U\fR options below), or its partition label
or UUID. (Partition identifiers are supported for example for GUID Partition
Tables (GPT).)
or UUID. Partition identifiers are supported for example for GUID Partition
Tables (GPT).
The device name of disk partitions are unstable; hardware reconfiguration,
adding or removing a device can cause change in names. This is reason why it's
strongly recommended to use filesystem or partition identificators like UUID or
LABEL.
The command \fBlsblk --fs\fR provides overview of filesystems, LABELs and UUIDs
on available block devices. The command \fBblkid -p <device>\fR provides details about
a filesystem on the specified device.
Don't forget that there is no guarantee that UUIDs and labels are really
unique, especially if you move, share or copy the device. Use
.B "lsblk \-o +UUID,PARTUUID"
to verify that the UUIDs are really unique in your system.
The recommended setup is to use tags (e.g.\& \fBLABEL=\fIlabel\fR) rather than
The recommended setup is to use tags (e.g.\& \fBUUID=\fIuuid\fR) rather than
.I /dev/disk/by-{label,uuid,partuuid,partlabel}
udev symlinks in the
.I /etc/fstab

View file

@ -157,7 +157,7 @@ static int get_ns_ino(const char *path, ino_t *ino)
static int is_same_namespace(pid_t a, pid_t b, const char *type)
{
char path[PATH_MAX];
ino_t a_ino, b_ino;
ino_t a_ino = 0, b_ino = 0;
snprintf(path, sizeof(path), "/proc/%u/%s", a, type);
if (get_ns_ino(path, &a_ino) != 0)

View file

@ -45,6 +45,11 @@ appropriate for such suspend modes.
.PP
Note that alarm functionality depends on hardware; not every RTC is able to setup
an alarm up to 24 hours in the future.
.PP
The suspend setup maybe be interrupted by active hardware; for example wireless USB
input devices that continue to send events for some fraction of a second after the
return key is pressed. In this case is better to use sleep command before invoking
suspend by rtcwake.
.SH OPTIONS
.TP
.BR \-A , " \-\-adjfile " \fIfile

View file

@ -532,7 +532,7 @@ int main(int argc, char **argv)
if (alarm < ctl.sys_time)
errx(EXIT_FAILURE, _("time doesn't go backward to %s"),
ctime(&alarm));
alarm += ctl.sys_time - ctl.rtc_time;
alarm -= ctl.sys_time - ctl.rtc_time;
} else
alarm = ctl.rtc_time + seconds + 1;

View file

@ -1,4 +1,4 @@
.TH SETARCH 8 "December 2014" "util-linux" "System Administration"
.TH SETARCH 8 "December 2017" "util-linux" "System Administration"
.SH NAME
setarch \- change reported architecture in new program environment and set personality flags
.SH SYNOPSIS
@ -30,41 +30,73 @@ can actually set each of these architectures depends on the running kernel.
.TP
.B \-\-uname\-2.6
Causes the \fIprogram\fR to see a kernel version number beginning with 2.6.
Turns on UNAME26.
.TP
.BR \-v , " \-\-verbose"
Be verbose.
.TP
\fB\-3\fR, \fB\-\-3gb\fR
Specifies that processes should use a maximum of 3GB of address space on systems where it is supported (ADDR_LIMIT_3GB).
Specifies
.I program
should use a maximum of 3GB of address space. Supported on x86. Turns on
ADDR_LIMIT_3GB.
.TP
\fB\-\-4gb\fR
Ignored (for backward compatibility only).
This option has no effect. It is retained for backward compatibility only,
and may be removed in future releases.
.TP
\fB\-B\fR, \fB\-\-32bit\fR
Turns on ADDR_LIMIT_32BIT.
Limit the address space to 32 bits to emulate hardware. Supported on ARM
and Alpha. Turns on ADDR_LIMIT_32BIT.
.TP
\fB\-F\fR, \fB\-\-fdpic\-funcptrs\fR
Userspace function pointers point to descriptors (turns on FDPIC_FUNCPTRS).
Treat user-space function pointers to signal handlers as pointers to address
descriptors. This option has no effect on architectures that do not support
FDPIC ELF binaries. In kernel v4.14 support is limited to ARM, Blackfin,
Fujitsu FR-V, and SuperH CPU architectures.
.TP
\fB\-I\fR, \fB\-\-short\-inode\fR
Turns on SHORT_INODE.
Obsolete bug emulation flag. Turns on SHORT_INODE.
.TP
\fB\-L\fR, \fB\-\-addr\-compat\-layout\fR
Changes the way virtual memory is allocated (turns on the ADDR_COMPAT_LAYOUT).
Provide legacy virtual address space layout. Use when the
.I program
binary does not have PT_GNU_STACK ELF header. Turns on
ADDR_COMPAT_LAYOUT.
.TP
\fB\-R\fR, \fB\-\-addr\-no\-randomize\fR
Disables randomization of the virtual address space (turns on ADDR_NO_RANDOMIZE).
Disables randomization of the virtual address space. Turns on
ADDR_NO_RANDOMIZE.
.TP
\fB\-S\fR, \fB\-\-whole\-seconds\fR
Turns on WHOLE_SECONDS.
Obsolete bug emulation flag. Turns on WHOLE_SECONDS.
.TP
\fB\-T\fR, \fB\-\-sticky\-timeouts\fR
Turns on STICKY_TIMEOUTS.
This makes
.BR select (2),
.BR pselect (2),
and
.BR ppoll (2)
system calls preserve the timeout value instead of modifying it to reflect
the amount of time not slept when interrupted by a signal handler. Use when
.I program
depends on this behavior. For more details see the timeout description in
.BR select (2)
manual page. Turns on STICKY_TIMEOUTS.
.TP
\fB\-X\fR, \fB\-\-read\-implies\-exec\fR
Turns on READ_IMPLIES_EXEC.
If this is set then
.BR mmap (3)
PROT_READ will also add the PROT_EXEC bit - as expected by legacy x86
binaries. Notice that the ELF loader will automatically set this bit when
it encounters a legacy binary. Turns on READ_IMPLIES_EXEC.
.TP
\fB\-Z\fR, \fB\-\-mmap\-page\-zero\fR
SVr4 bug emulation that will set
.BR mmap (3)
page zero as read-only. Use when
.I program
depends on this behavior, and the source code is not available to be fixed.
Turns on MMAP_PAGE_ZERO.
.TP
.BR \-V , " \-\-version"
@ -86,6 +118,9 @@ Elliot Lee
.MT jnovy@redhat.com
Jindrich Novy
.ME
.SH "SEE ALSO"
.BR personality (2),
.BR select (2)
.SH AVAILABILITY
The setarch command is part of the util-linux package and is available from
.UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/

View file

@ -0,0 +1,7 @@
ID_FS_LABEL=___
ID_FS_LABEL_ENC=\xe5\xe5\xe5
ID_FS_TYPE=vfat
ID_FS_USAGE=filesystem
ID_FS_UUID=2826-F9B3
ID_FS_UUID_ENC=2826-F9B3
ID_FS_VERSION=FAT32

View file

@ -0,0 +1,5 @@
ID_FS_TYPE=crypto_LUKS
ID_FS_USAGE=crypto
ID_FS_UUID=e5f398d9-39da-4b6a-9ac3-e085a9394e7c
ID_FS_UUID_ENC=e5f398d9-39da-4b6a-9ac3-e085a9394e7c
ID_FS_VERSION=1

View file

@ -0,0 +1,8 @@
ID_FS_LABEL=tst_label
ID_FS_LABEL_ENC=tst_label
ID_FS_SUBSYSTEM=tst_subsys
ID_FS_TYPE=crypto_LUKS
ID_FS_USAGE=crypto
ID_FS_UUID=202265fe-9842-4c2d-ac9b-aba1b05deb63
ID_FS_UUID_ENC=202265fe-9842-4c2d-ac9b-aba1b05deb63
ID_FS_VERSION=2

View file

@ -1 +1 @@
column: read failed: Invalid or incomplete multibyte or wide character
\xa3

View file

@ -0,0 +1,2 @@
fsck.cramfs: file extends past end of filesystem
fsck.cramfs: crc error

View file

@ -2,6 +2,10 @@
NAME DATA
foo bla bla bla
bar alb alb alb
This is left title (without padding)
NAME DATA
foo bla bla bla
bar alb alb alb
=======================This is center title (with padding)======================
NAME DATA
foo bla bla bla

View file

@ -7,22 +7,22 @@
int main(void)
{
int i, ret;
struct MD5Context ctx;
unsigned char digest[MD5LENGTH];
struct UL_MD5Context ctx;
unsigned char digest[UL_MD5LENGTH];
unsigned char buf[BUFSIZ];
MD5Init( &ctx );
ul_MD5Init( &ctx );
while(!feof(stdin) && !ferror(stdin)) {
ret = fread(buf, 1, sizeof(buf), stdin);
if (ret)
MD5Update( &ctx, buf, ret );
ul_MD5Update( &ctx, buf, ret );
}
fclose(stdin);
MD5Final( digest, &ctx );
ul_MD5Final( digest, &ctx );
for (i = 0; i < MD5LENGTH; i++)
for (i = 0; i < UL_MD5LENGTH; i++)
printf( "%02x", digest[i] );
printf("\n");
return 0;

View file

@ -7,22 +7,22 @@
int main(void)
{
int i, ret;
SHA1_CTX ctx;
unsigned char digest[SHA1LENGTH];
UL_SHA1_CTX ctx;
unsigned char digest[UL_SHA1LENGTH];
unsigned char buf[BUFSIZ];
SHA1Init( &ctx );
ul_SHA1Init( &ctx );
while(!feof(stdin) && !ferror(stdin)) {
ret = fread(buf, 1, sizeof(buf), stdin);
if (ret)
SHA1Update( &ctx, buf, ret );
ul_SHA1Update( &ctx, buf, ret );
}
fclose(stdin);
SHA1Final( digest, &ctx );
ul_SHA1Final( digest, &ctx );
for (i = 0; i < SHA1LENGTH; i++)
for (i = 0; i < UL_SHA1LENGTH; i++)
printf( "%02x", digest[i] );
printf("\n");
return 0;

Binary file not shown.

Binary file not shown.

Binary file not shown.

38
tests/ts/cramfs/fsck-bad-header Executable file
View file

@ -0,0 +1,38 @@
#!/bin/bash
#
# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
#
# This file is part of util-linux.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
TS_TOPDIR="${0%/*}/../.."
TS_DESC="fsck endianness"
. $TS_TOPDIR/functions.sh
ts_init "$*"
ts_check_test_command "$TS_CMD_MKCRAMFS"
ts_check_test_command "$TS_CMD_FSCKCRAMFS"
ts_check_prog "dd"
IMAGE_SOURCE="$TS_OUTDIR/${TS_TESTNAME}-data/root"
IMAGE_FILE="$TS_OUTDIR/${TS_TESTNAME}-cramfs.img"
mkdir -p "${IMAGE_SOURCE}/subdir" &> /dev/null
$TS_CMD_MKCRAMFS -p -N big $IMAGE_SOURCE $IMAGE_FILE &> /dev/null
echo -ne \\00\\x4c |
dd of=$IMAGE_FILE bs=1 seek=518 count=2 conv=notrunc &> /dev/null
$TS_CMD_FSCKCRAMFS $IMAGE_FILE >> $TS_OUTPUT 2>&1
ts_finalize

View file

@ -71,7 +71,7 @@ ts_finalize_subtest
ts_init_subtest "type-pattern"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
$TS_CMD_MOUNT -t nofoo,bar $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1
$TS_CMD_MOUNT -i -t nofoo,bar $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1
ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
$TS_CMD_UMOUNT $TS_MOUNTPOINT
ts_log "Success"
@ -80,7 +80,7 @@ ts_finalize_subtest
ts_init_subtest "type-pattern-neg"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
$TS_CMD_MOUNT -t nofoo,bar,ext3,ext2,ext4 $DEVICE $TS_MOUNTPOINT &> /dev/null
$TS_CMD_MOUNT -i -t nofoo,bar,ext3,ext2,ext4 $DEVICE $TS_MOUNTPOINT &> /dev/null
ts_is_mounted $DEVICE && ts_die "$DEVICE unexpectedly mounted"
ts_log "Success"
ts_finalize_subtest

View file

@ -54,7 +54,7 @@ mode is enabled by option \fB-t, \-\-table\fP and columns formatting is
possible to modify by \fB\-\-table-*\fP options. Use this mode if not sure.
.PP
Input is taken from \fIfile\fR, or otherwise from standard input. Empty lines
are ignored.
are ignored and all invalid multibyte sequences are encoded by \\x<hex> convention.
.PP
.SH OPTIONS
The argument \fIcolumns\fP for \fB\-\-table-*\fP options is comma separated
@ -79,7 +79,7 @@ supplied using the \fB\-\-output\-separator\fP option.
Table output is useful for pretty-printing.
.IP "\fB\-N, \-\-table-columns\fP \fInames\fP"
Specify the columns names by comma separated list of names. The names are used
for the table header or to addres column in option arguments.
for the table header or to address column in option arguments.
.IP "\fB\-R, \-\-table-right\fP \fIcolumns\fP"
Right align text in the specified columns.
.IP "\fB\-T, \-\-table-truncate\fP \fIcolumns\fP"

View file

@ -52,6 +52,7 @@
#include "ttyutils.h"
#include "strv.h"
#include "optutils.h"
#include "mbsalign.h"
#include "libsmartcols.h"
@ -458,8 +459,18 @@ static int read_input(struct column_control *ctl, FILE *fp)
continue;
wcs = mbs_to_wcs(str);
if (!wcs)
err(EXIT_FAILURE, _("read failed"));
if (!wcs) {
/*
* Convert broken sequences to \x<hex> and continue.
*/
size_t tmpsz = 0;
char *tmp = mbs_invalid_encode(str, &tmpsz);
if (!tmp)
err(EXIT_FAILURE, _("read failed"));
wcs = mbs_to_wcs(tmp);
free(tmp);
}
switch (ctl->mode) {
case COLUMN_MODE_TABLE:
@ -590,6 +601,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -s, --separator <string> possible table delimiters\n"), out);
fputs(_(" -x, --fillrows fill rows before columns\n"), out);
fputs(USAGE_SEPARATOR, out);
printf(USAGE_HELP_OPTIONS(34));
printf(USAGE_MAN_TAIL("column(1)"));