Commit Graph

5555 Commits

Author SHA1 Message Date
Milan Broz 5eec85708d tests: fix mount move test to work with shared mount
If parent mount for test directory is mounted with shared flag,
move mount test fails because kernel rejects mount move operation.

Use another directory level and explicitly make parent mount private.

(All "modern" systems using system have mounts shared for some reason.)

Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-10-09 12:12:49 +02:00
Milan Broz 53ebc440fc tests: ignore test if kernel doesn't support minix fs
Minix mount test returs failure if kernel have no minix support,
 minix: mkfs ... FAILED (minix/mkfs)
ignore test result instead in this case.

Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-10-09 12:12:49 +02:00
Milan Broz fd22f8dbe8 tests: fix timezone for cramfs
cramfs test need explicitly set timezone otherwise
ls diff fails with
   cramfs: mkfs checksums ... FAILED (cramfs/mkfs)

Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-10-09 12:12:48 +02:00
Mike Frysinger 8323d9fd59 fix bold style of man page references
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-10-09 12:12:48 +02:00
Marcin Juszkiewicz 6d9bbf886a fdisk: add AArch64 support
Attached patch fixed build problem when util-linux is built for AArch64
architecture.
2012-10-09 12:12:48 +02:00
Karel Zak 84600ddc6d mount: add verbose messages
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=864227
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-09 11:56:35 +02:00
Karel Zak dc3ea13356 libmount: fix umount file.img
The umount optimization (commit 9cc03553f7)
has to be disabled if the umount argument is not a directory.

Reported-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-05 20:38:49 +02:00
Karel Zak 98193daa8c login: reuse DEAD_PROCESS utmp entries
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=858009
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-05 12:07:10 +02:00
Karel Zak f7b59bb27f hwclock: fix in usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-03 11:41:52 +02:00
Bjørn Mork 8c8fa302c1 dmesg: fix console-level off-by-one
commit f06ec64f dmesg; support level names (e.g. --console-level=alert)

introduced an off-by-one error.  The kernel will print messages with
a *higher* level than the console-level. The bug made it impossible to
set the level for debugging, like it is documented in e.g
Documentation/networking/netconsole.txt :

 nemi:/tmp# dmesg -n 8
 dmesg: unknown level '8'

And attempting to set the "emerg" level would result in an invalid 0 value:

 nemi:/tmp# dmesg -n emerg
 dmesg: klogctl failed: Invalid argument

Restoring the old behaviour for numeric levels, and mapping the level
names so that "dmesg -n debug" behaves as expected: logging everything
at level "debug" and higher.

[kzak@redhat.com: - add comment to parse_level()]

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-02 11:43:10 +02:00
Sami Kerola 018dfb0fe7 column: describe change of separator behavior in man page bugs section
Add to manual page how to achieve old behavior, just in case someone
relies on buggy behavior of the command.

[kzak@redhat.com: - remove unnecessary info from the man page :-)]

Reported-by:  Padraig Brady <P@draigBrady.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-02 10:43:33 +02:00
Vitezslav Cizek 61cebf7747 su: fixed a typo in pam error message
Signed-off-by: Vitezslav Cizek <vcizek@suse.cz>
2012-10-02 10:25:13 +02:00
Pádraig Brady a38dc987ca column: clarify the --separator option
Indicate that the string is a set,
which also clarifies that it's only
significant when parsing the input.
2012-10-02 10:24:55 +02:00
Sami Kerola 732e3dec7d column: make defined separator to be non-greedy
This patch changes interpretation of subsequent delimeter interpretation.
Earlier version merged columns that had null string as content together,
which lead to output as visualized below.

$ printf "a🅱️c\n1::3\n" | column  -t -s ':'
a  b  c
1  3

The number 3 has wrong column, which this patch takes care of, and alters
the output following way.

$ printf "a🅱️c\n1::3\n" | column  -t -s ':'
a  b  c
1     3

This patch does not alter the default case, e.g., subsequent white spaces
are understood as separator of the same field, and the beginning of line
white spaces are being ignored together.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-02 10:24:48 +02:00
Mike Frysinger f036b4c730 mount: fix a few typos
Nothing of note here.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-10-02 10:24:36 +02:00
Gilles Espinasse 45683be543 textual: typo fixes
Signed-off-by: Gilles Espinasse <g.esp@free.fr>
2012-10-02 10:24:26 +02:00
Peter Rajnoha 8d687180b2 lsblk: fix reporting of 'part' type
Partitions are incorrectly marked with 'disk' type on
lsblk output while it should be marked as 'part' type.

Before:
$ lsblk /dev/sda
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  128M  0 disk
`-sda1   8:1    0   64M  0 disk

With this patch applied:
$ lsblk /dev/sda
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  128M  0 disk
`-sda1   8:1    0   64M  0 part

Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
2012-10-02 10:23:51 +02:00
Karel Zak 705ee62ff0 su: don't modify PATH if -l not specified
This patch reverts a6fdd3f812.

su(1) modifies PATH if:
  - option -l specified
  - ALWAYS_SET_PATH login.defs variable set

Reported-by: Thomas Bächler <thomas@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-02 10:14:05 +02:00
Bernhard Voelker b83b9b11c2 ipcrm: avoid 'uninitialized' warning
GCC 4.1.2 on SLES 10.4:
sys-utils/ipcrm.c: In function ‘main’:
sys-utils/ipcrm.c:297: warning: ‘what_all’ may be used uninitialized in this function

* sys-utils/ipcrm.c: Initialize what_all to ALL.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-10-02 10:01:51 +02:00
Lukas Czerner d964b669c8 blkdiscard: add new command
blkdiscard is used to discard device sectors. This is useful for
solid-state drivers (SSDs) and thinly-provisioned storage. Unlike
fstrim this command is used directly on the block device.

blkkdiscard uses BLKDISCARD ioctl or BLKSECDISCARD ioctl for the secure
discard.

All data in the discarded region on the device will be lost!

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
2012-09-28 01:12:09 +02:00
Karel Zak fce05e9617 Revert "blkdiscard: new command"
This was only attempt as alternative implementation, unfortunately
pushed publicly... sorry.

This reverts commit c84ed54cef.
2012-09-28 01:10:08 +02:00
Davidlohr Bueso 766d5156c4 fdisk: add GPT support
This patch allows fdisk to handle GUID partition tables, based on the latest UEFI specifications
version 2.3.1, from June 27th, 2012. The following operations are supported:

  - Probing (detects both protective and hybrid MBRs)
  - Writing to disk
  - Listing used partitions
  - Adding partitions
  - Deleting partitions
  - Data integrity verifications (for both headers and partitions).

A few considerations:
  - Currently we do not fix invalid primary headers -- we just abort!
  - Header checksums are updated upon every change (ie: add/delete partitions), this allows us
    to mathematically verify the changes on-the-fly, and not only when writing to disk, like
    most other related tools do.
  - We are extremly picky when writing to disk, any error aborts the opeartion.
  - When creating a new partition, the following GUIDs are available:
     http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs

For test cases, the gpt.img from libblkid tests, scsi_debug and my own hard drive (/dev/sda) were used.
For the image, all operations were tested successfully, and for /dev/sda all except write, which
was not tested - hey, I'm not suicidal!

[kzak@redhat.com: - add get/set partition type functions
                  - use unified on strings based table for partition types
                  - add partition type to table list function]

Tested-and-reviewed-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:14 +02:00
Karel Zak 2b1a43cf17 fdisk: cleanup debug messages and comments
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak ed470672bb fdisk: use fdisk_parttype in add_partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak 02460b8aae fdisk: add fdisk_set_partition_type()
- remove all label specific partition type stuff from fdisk.c to
   label files
 - add new fdisk_set_partition_type() to API

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak 010186f2a2 fdisk: add fdisk_get_partition_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak 559d921eda fdisk: add new functions for work with fdisk_parttype
- add flags to fdisk_parttype to store more information about the types
 - function for conversion from code to fdisk_parttype
 - function for conversion from string to fdisk_parttype
 - function for conversion from user input to fdisk_parttype
 - support for unknown complex types (e.g. unknown UUIDs)

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak 7b575fcc3b fdisk: improve list partition types
- add fdisk_parttype->typestr for types like GPT UUID or Mac
 - list typestr if specified

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak 749af4b609 fdisk: move partition types to label specific part
- move MBR partition types to dos_part_types.h
 - make dos_part_types.h independent on datetypes to keep it useful in
   all fdisks
 - add struct fdisk_parrtype
 - move label specific partition types to context->label

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 13:38:13 +02:00
Karel Zak c84ed54cef blkdiscard: new command
Add to fstrim(8) code to support new discard BLKDISCARD and
BLKSECDISCARD ioctls for block devices.  The new command is only
symlink to fstrim(8) as the both utils share some code and the basic
ideas.

Based on patch from Lukas Czerner <lczerner@redhat.com>.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 11:38:31 +02:00
Karel Zak 1ae3d0d932 libmount: don't setup new loopdev on remount with regular mtab
[chroot-i486] root:/tmp$ mount -oloop /tmp/blob /tmp/mnt
[chroot-i486] root:/tmp$ mount -o remount,loop,ro /tmp/mnt
[chroot-i486] root:/tmp$ mount
/dev/loop0 on /tmp/mnt type ext2 (ro,loop)
[chroot-i486] root:/tmp$ losetup -a
/dev/loop0: [2051]:306957 (/tmp/blob)
/dev/loop1: [0005]:2218 (/dev/loop0)
[chroot-i486] root:/tmp$ umount /tmp/mnt
umount: /tmp/mnt: filesystem umounted, but mount(8) failed: Device or
resource busy
[chroot-i486] root:/tmp$ losetup -d /dev/loop1
[chroot-i486] root:/tmp$ losetup -d /dev/loop0

Reported-by: g.esp@free.fr
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-26 11:25:01 +02:00
Karel Zak ab6c01925c libmount: improve debug message
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-25 17:04:21 +02:00
Karel Zak 4709c9e6a1 libmount: optimize mtab and utab parsing in umount
create 8000 NFS mountpoints:
	#!/bin/bash
	mount=/tmp/mount
	if [ ! -d $mount ]; then
	    mkdir -p $mount
	fi
	for dir in {1..8000}; do
	    if [ ! -d $mount/$dir ]; then
		mkdir -p $mount/$dir
	    fi
	    echo mount $dir
	    mount -t nfs 127.0.0.1:/ $mount/$dir
	done

old version:
	time ./umount /tmp/mount/2255

	real	0m1.254s
	user	0m1.002s
	sys	0m0.238s

new version:
	time ./umount /tmp/mount/2244

	real	0m0.332s
	user	0m0.111s
	sys	0m0.218s

Reported-by: chenditang <chendt.fnst@cn.fujitsu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-25 16:47:18 +02:00
Karel Zak 9af2433419 libmount: user-mounted loopback fs cannot be unmounted by user
Addresses: https://bugs.archlinux.org/task/31624
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-21 17:15:07 +02:00
Milan Broz c1f1b30171 mkswap: wipe old signature if there is no part table by default
Historically mkswap avoids wiping any signature on "whole disk",
until force option is given.

While the idea is that it should not wipe possible boot loader,
in reality it leads to many situations where e.g. LUKS device
is overwritten but still can be detected as LUKS (but unusable).

Patch chnges behaviour that only if partition table is detected,
signatures are not wiped.

Also it removes check for block device - loop device can now
map partitions in-kernel, so using mkswap on disk image in file
should behave the same as on disk.

Also it adds warning that know signature was wiped.

Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-09-21 12:43:33 +02:00
Karel Zak 4082ab2c6f su: fix compiler warning [-Wstrict-prototypes]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-21 12:38:18 +02:00
Ondrej Oprala ea8a10391b su: add segmentation fault reporting of the child process
Child processes that ended with segmentation fault previously
indicated this with return status only. The report is now more
verbose if core dump is allowed.

Improved-by: Pádraig Brady <P@draigBrady.com>
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2012-09-21 12:37:18 +02:00
Peter Rajnoha da30cb2a87 lsblk: fix processing of dm partition mappings
As blkid_devno_to_wholedisk returns parent dm device for
a partition mapping, the condition used in lsblk incorrectly
checked the parent-child relationship.

In this particular case, we need to process the dm partition
mapping like any other non-partition device as dm devices always
use proper holders/slaves sysfs hierarchy instead of
/sys/block/<parent>/<name> that is used for real partitions.

Example (test1 is a partition mapping and sdb1 is a real partition):
$ lsblk
NAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                8:0    0  128M  0 disk
`-test (dm-0)    253:0    0  128M  0 dm
  `-test1 (dm-1) 253:1    0  127M  0 part
sdb                8:16   0  128M  0 disk
`-sdb1             8:17   0  127M  0 disk

Before this patch (test1 skipped!):
$ lsblk -s /dev/mapper/test1
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
test (dm-0) 253:0    0  128M  0 dm
`-sda         8:0    0  128M  0 disk

$ lsblk -s /dev/sdb1
NAME  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb1    8:17   0  127M  0 disk
`-sdb   8:16   0  128M  0 disk

With this patch (test1 processed correctly):
$ lsblk -s /dev/mapper/test1
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
test1 (dm-1)  253:1    0  127M  0 part
`-test (dm-0) 253:0    0  128M  0 dm
  `-sda         8:0    0  128M  0 disk

$ lsblk -s /dev/sdb1
NAME  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb1    8:17   0  127M  0 disk
`-sdb   8:16   0  128M  0 disk
2012-09-21 12:25:32 +02:00
Peter Rajnoha 857db7f53c lib/sysfs: fix sysfs_devname_to_devno for dm partitions
Partitions mapped by device-mapper are not like real partitions where
there's a /sys/block/<parent>/<name>/dev sysfs path. We need to look
at /sys/block/<name>/dev like we do for any other non-partition devices.
The mapped partition is not found otherwise.

For example, this bug shows up in lsblk while specifying a device
on command line while that device is a dm mapping over a partition:
$lsblk
NAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                8:0    0  128M  0 disk
`-test (dm-0)    253:0    0  128M  0 dm
  `-test1 (dm-1) 253:1    0  127M  0 part

Before this patch:
$lsblk /dev/mapper/test1
lsblk: dm-1: unknown device name

With this patch:
$lsblk /dev/mapper/test1
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
test1 (dm-1) 253:1    0  127M  0 part
2012-09-21 12:21:30 +02:00
Petr Uzel 2754ffc5f5 setterm: make error message more informative
If `setterm -dump` fails because of lack of permission to read
/dev/vcsa, it should not report that it couldn't read /dev/vcsa0.
This could be misleading if there is only /dev/vcsa, but not /dev/vcsa0.

Before:
$ ./setterm -dump
setterm: Couldn't read /dev/vcsa0

After:
$ ./setterm -dump
setterm: Couldn't read neither /dev/vcsa0 nor /dev/vcsa

(Note: /dev/vcsa0 does not exist and the user does not have read
permission on /dev/vcsa in this case).

Addresses: https://bugzilla.novell.com/show_bug.cgi?id=780615
Reported-by: Christopher Yeleighton <giecrilj@stegny.2a.pl>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-09-21 12:14:14 +02:00
Thierry Reding 4862db73e8 sfdisk: Fix format specifiers for size_t
The proper specifier for size_t is %zu. %lu will work fine on 64-bit
architectures but not on 32-bit.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
2012-09-21 12:14:04 +02:00
Tom Gundersen 910a090039 hwclock: don't warp the systemtime if the RTC is in UTC
A sideeffect of 839be2ba6b is that we now
warp the systemtime according to the timezone, on the first call of
--systz. This is not always the correct thing to do, and causes a
regression for us in Arch Linux.

The behavior is correct if the RTC, and hence the systemtime, is
in localtime. However, if the systemtime is already in UTC we don't
want to touch it when we set the kernel timezone (which we still need to
do as some filesystems use this information).

An almost identical issue was also fixed in systemd commit
72edcff5db936e54cfc322d9392ec46e2428fd9b.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2012-09-21 12:07:32 +02:00
Karel Zak 72fc8ca062 hwclock: wait time in hwclock is not long enough for some ARM devices
On Sun, Sep 16, 2012 at 02:11:48PM +0800, Queen Adam wrote:
> I'm using Archlinux ARM for my Melo A100 box.
> The hwclock always timeout when using select() in rtc.c.
>
> After I change the timeout from 5 to 10, the problem is solved.
>
> In fact the timeout in my ARM box seems only to be a little larger
> than 5s.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-21 12:05:12 +02:00
Ville Skyttä 9e94f3938d docs: AUTHORS, NEWS: UTF-8 fixes.
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
2012-09-20 11:30:59 +02:00
Ville Skyttä 53859b5f59 docs: umount.8 syntax fix.
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
2012-09-20 11:30:41 +02:00
Karel Zak e8cd181967 libmount: append loop option when automatically create loopdev
The loop option is optional, mount(8) is able to detect that the
source path is regular file (image) with known filesystem -- then a
loop device is automatically created. In this case we have to store
"loop" option to mtab on systems without autoclear loopdev flag.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-18 11:40:44 +02:00
Karel Zak 475c30d061 libmount: detach loopdev on umount if loop option in mtab
[chroot-i486] root:/$ mount --version
mount from util-linux 2.22 (libmount 2.22.0: debug)
[chroot-i486] root:/$ losetup -a
[chroot-i486] root:/$ mount -oloop /tmp/foo_fs /tmp/bar_dir
[chroot-i486] root:/$ umount /tmp/foo_fs
[chroot-i486] root:/$ losetup -a
/dev/loop0: [2051]:387175 (/tmp/foo_fs)

Reported-by: g.esp@free.fr
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-18 11:22:17 +02:00
Giacomo 829eab67e6 rtcwake: doesn't reset wakealarm
Disable an alarm use the same logic used to enable it: first try RTC_WKALM_SET
with the "enabled" flag set to false, if it fails fall back to RTC_AIE_OFF.

Signed-off-by: Giacomo <giacomo.perale@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-13 13:23:11 +02:00
Karel Zak 2b945eda3d agetty: add \4 and \6 issue file sequences to print IP addresses
Based on Andrea Bonomi <a.bonomi@endian.com> ideas.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-13 12:59:46 +02:00
Karel Zak df0bd828b1 build-sys: simplify usrlib_execdir initialization
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-12 18:09:28 +02:00