Karel Zak [Tue, 6 Aug 2013 09:04:35 +0000 (11:04 +0200)]
losetup: use loop-control to explicitly ask for device
Now we use LOOP_CTL_GET_FREE ioctl to ask for free device, for example
losetup -f foo.img
Unfortunately, losetup(8) allows to ask for specified device
losetup /dev/loop100 foo.img
and in this case we assume that the device already exists in the
system. This is incorrect, we should be able to use loop-control
LOOP_CTL_ADD ioctl to ask for the specified device.
Sami Kerola [Sun, 28 Jul 2013 21:11:20 +0000 (22:11 +0100)]
build-sys: use backticks rather than $() for commands in configure
The configure had both backticks and $() in use. These command
susbstitutions are mutually interchangeable, so one should pick only one
form. In this case backticks were favored because they are known with
greater range of shells, making the backticks to be more portable.
References: https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Shell-Substitutions.html#index-g_t_0024_0028_0040var_007bcommands_007d_0029-1632 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Reported-by: "Dr. David Alan Gilbert" <dave@treblig.org>
References: https://bugzilla.novell.com/show_bug.cgi?id=829720 Signed-off-by: Karel Zak <kzak@redhat.com>
This change proposed in util-linux maillist by Damien Wyart in behalf of
Daniel Kahn Gillmor. Sami Kerola changed the patch to use option rather
than makign the default behavior of the command to change.
Reported-by: Damien Wyart <damien.wyart@gmail.com>
Reference: http://markmail.org/message/2z6qh5auk7wjie3l
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=495881 CC: Daniel Kahn Gillmor <dkg@fifthhorseman.net> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Karel Zak [Wed, 3 Jul 2013 10:28:16 +0000 (12:28 +0200)]
unshare: add --mount-proc for pid namespaces
Based on patch from Mike Frysinger <vapier@gentoo.org>.
Mike Frysinger wrote:
When it comes to pid namespaces, it's also useful for /proc to reflect
the current namespace. Again, this is easy to pull off, but annoying
to force everyone to do it themselves. So let's add a --mount-proc to
do the magic for us. The downside is that this also implies creating
a mount namespace as mounting the new pid namespace /proc over top the
system one will quickly break all other processes on the system.
Signed-off-by: Karel Zak <kzak@redhat.com> Acked-by: Mike Frysinger <vapier@gentoo.or>
Mike Frysinger [Fri, 28 Jun 2013 00:04:58 +0000 (20:04 -0400)]
unshare: add --fork options for pid namespaces
The ability of unshare to launch a new pid namespace is a bit limited.
The first process in the namespace is expected to be the "init" for it.
When it's not, you get bad behavior.
For example, trying to launch a shell in a new pid namespace fails very
quickly:
$ sudo unshare -p dash
# uname -r
3.8.3
# uname -m
dash: 2: Cannot fork
# ls -ld /
dash: 3: Cannot fork
# echo $$
1324
For this to work smoothly, we need an init process to actively watch over
things. But forcing people to re-use an existing init or write their own
mini init is a bit overkill. So let's add a --fork option to unshare to
do this common bit of book keeping. Now we can do:
$ sudo unshare -p --fork dash
# uname -r
3.8.3
# uname -m
x86_64
# ls -ld /
drwxr-xr-x 22 root root 4096 May 4 14:01 /
# echo $$
1
Thanks to Michael Kerrisk for his namespace articles on lwn.net
Karel Zak [Mon, 8 Jul 2013 12:21:03 +0000 (14:21 +0200)]
lsblk: use devno to check if the filesystem is mounted
The device (for example LVM logical volume) could be renamed and then
the device name from /proc/self/mountinfo does not match with reality.
So, we also need to check devno. Unfortunately we cannot completely
rely on devno, because for example btrfs uses psudo device numbers.
References: https://bugzilla.redhat.com/show_bug.cgi?id=980463 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 8 Jul 2013 12:21:03 +0000 (14:21 +0200)]
lsblk: use devno to get mountpoint
The device (for example LVM logical volume) could be renamed and then
the device name from /proc/self/mountinfo does not match with reality.
So, we also need to check devno. Unfortunately we cannot completely
rely on devno, because for example btrfs uses psudo device numbers.
References: https://bugzilla.redhat.com/show_bug.cgi?id=980463 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 1 Jul 2013 13:59:16 +0000 (15:59 +0200)]
findmnt: make udev usage more robust
$ findmnt -rn --target /home/kzak/.bashrc -o UUID
uses libudev to ask for UUID, unfortunately /home/kzak is DM device
and libudev expects sysfs-like names (e.g. dm-0). We have to convert
the name to kernel devname.
Sami Kerola [Sun, 30 Jun 2013 18:11:22 +0000 (19:11 +0100)]
dmesg: make time stamps to be printed consistently
Earlier uptime determination, which was done with sysinfo(2), had one
second resolution, which made time stamps to be rounded unstable way
depending on when a dmesg command was executed. In practical terms; the
command below was supposed not to differ but it did.
Sami Kerola [Sun, 16 Jun 2013 18:53:51 +0000 (19:53 +0100)]
dmesg: add iso-8601 time format
The ISO-8601 should be welcomed by anyone who tries to parse dmesg time
stamp, and compare them across servers. Time format tries to imitate
coreutils 'date --iso-8601=ns' output, but instead of having nanoseconds
the dmesg is using microseconds.
Reference: http://www.cs.tut.fi/~jkorpela/iso8601.html
Addresses: http://xkcd.com/1179/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Sun, 16 Jun 2013 18:53:48 +0000 (19:53 +0100)]
sfdisk: replace my_warn() with warnx()
This change adds program name in front of error messages. Often that
helps user to know which command sent message, when the command is
executed as part of script.
Unfortunately the prefixing can break scripts, as someone might have
wrote automation which expects output in the format it has always been.
In programmer terms, the change has an ABI change, which some may find
annoying.
Sami Kerola [Sun, 16 Jun 2013 18:53:46 +0000 (19:53 +0100)]
docs: correct sfdisk --activate instructions
The activate can be enabled by renaming the command to 'activate'. Quite
confusingly the option and command arguments are interchangeable, and
depending on which one is defined as --activate option argument the
command will behave different rather different ways.