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.
Sami Kerola [Sun, 16 Jun 2013 18:53:42 +0000 (19:53 +0100)]
renice: exit with non-zero value when arguments cause warnings
This commit also fixes potential error counter wrap, which theoretically
could make command to exit with a success when it internally failed just
correct amount of times.
Karel Zak [Tue, 18 Jun 2013 10:24:28 +0000 (12:24 +0200)]
eject: Check host_status and driver_status when using SG_IO.
Based on Suse patch, originally from
Anna Bernathova <anicka@suse.cz>, May 2008
SG_IO completion status is weird but still well defined. You'll need
to check both host_status, driver_status and status to determine that
a command actually succeeded. -- Tejun Heo, May 2008
Note that we also need to check driver_status and sense_buffer to
detect situation when there is no medium. It's valid request to call
eject(8) for device with no medium.
References: https://bugzilla.novell.com/show_bug.cgi?id=358033 Signed-off-by: Anna Bernathova <anicka@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 17 Jun 2013 16:08:01 +0000 (18:08 +0200)]
cal: fix -y output for UTF8
... in the yearly() function is a static buffer where is not space for
multibyte headers. The patch also clean ups function where we
initialize headers.
Karel Zak [Thu, 13 Jun 2013 11:32:02 +0000 (13:32 +0200)]
Merge branch 'master' of https://github.com/eric-s-raymond/util-linux
* 'master' of https://github.com/eric-s-raymond/util-linux:
Fix broken list syntax.
Restore use of correct alternation syntax using { | }.
Re-layout a FILES section in the traditional style.
Remove another .ti for .RS/.RE, and remove a .TP that broke list parsing.
Replace .IP o with .IP \(bu, using the [nt]roff bullet character.
Replace .ti operations with equivalent .RS/.RE pairs.
Aaron Lu [Thu, 6 Jun 2013 08:28:37 +0000 (16:28 +0800)]
eject: unlock door before issuing CDROMEJECT command
If user has inserted a disc into the drive, the drive will normally be
locked. When using eject command to eject the drive, we need to unlock
the door first, or the CDROMEJECT command will fail.
Though the 2nd attmpt to eject the drive with eject_scsi will succeed,
it actually does two things: first to unlock the door and then to eject
the tray, both with the SG_IO ioctl. The problem is, Linux SCSI driver
keeps track of if a device is in locked state or not, if we go with
SG_IO to do the unlocking, the driver will not be aware of the unlocking
and would think the drive is locked while actually it has already been
unlocked by the first SG_IO command.
Fix this by issuing a unlock door command before the CDROMEJECT command
in cdrom_eject. Prior to this fix, the following output is expected when
there is a disc inside:
[aaron@aaronlu util-linux-2.22.2]$ eject -v /dev/sr0
eject: device name is `/dev/sr0'
eject: /dev/sr0: mounted on /run/media/aaron/CD_ROM
eject: /dev/sr0: is whole-disk device
eject: /dev/sr0: is removable device
eject: /run/media/aaron/CD_ROM: unmounting
eject: /dev/sr0: trying to eject using CD-ROM eject command
eject: CD-ROM eject command failed
eject: /dev/sr0: trying to eject using SCSI commands
eject: SCSI eject succeeded
After this fix, the following output is expected:
[aaron@aaronlu util-linux-2.22.2]$ ./eject -v /dev/sr0
lt-eject: device name is `/dev/sr0'
lt-eject: /dev/sr0: mounted on /run/media/aaron/CD_ROM
lt-eject: /dev/sr0: is whole-disk device
lt-eject: /dev/sr0: is removable device
lt-eject: /run/media/aaron/CD_ROM: unmounting
lt-eject: /dev/sr0: trying to eject using CD-ROM eject command
lt-eject: CD-ROM eject command succeeded
And the SCSI device's locked state is correct now.