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.
Sami Kerola [Sun, 2 Jun 2013 17:51:17 +0000 (18:51 +0100)]
rev: simplify new line detection and impossible test
The new line detection is earlier using only '\n' so there should not be
need to search for '\r' later.
The detection whether allocated address is pointing to null seems to be
unnecessary. Assuming xmalloc() returned valid address space the address
should never be 0.
Sami Kerola [Sun, 2 Jun 2013 17:51:16 +0000 (18:51 +0100)]
rev: stop adding new line at the end when input does not have it
When the rev(1) is executed twice outcome is expected to be exactly what
it was originally. That includes not adding new line at the end of the
output. The oneliner below demonstrates earlier issue.
Sami Kerola [Sun, 2 Jun 2013 17:51:08 +0000 (18:51 +0100)]
lscpu: add max MHz value to make cpu governor effects more visible
The existing 'CPU MHz' is usually dynamic value, which CPU governor
changes up on needs of CPU demand. Assuming lscpu is used to gather
information to a hardware inventory the dynamic value is misleading. For
inventing the maximum MHz value is more sensible.
Dennis H Jensen [Wed, 22 May 2013 11:12:08 +0000 (13:12 +0200)]
logger: add support for --prio-prefix when logging stdin
This patch adds a new option to logger that will make it look for a
priority prefix <n> at the beginning of every line. The priority is
a single decimal number formed as explained in syslog(3).
If a prefix is found logger will log the message using the found
facility and level in that prefix, if the prefix doesn't contain a
facility the default facility specified by the -p option will be used.
If no prefix is found, logger will use the priority specified by -p.
[kzak@redhat.com: - add --prio-prefix to usage() output]
Signed-off-by: Dennis H Jensen <dennis.h.jensen@siemens.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 28 May 2013 13:23:59 +0000 (15:23 +0200)]
Merge branch 'cal-fourth' of git://github.com/kerolasa/lelux-utiliteetit
* 'cal-fourth' of git://github.com/kerolasa/lelux-utiliteetit:
docs: cal: stop telling year 9999 is upper limit
tests: check cal works when year is far in future
cal: remove arbitrary limit of maxium year being 9999
cal: use Claus Tøndering's day of the week algorithm
cal: simplify day_in_week() calculation
cal: mark all functions static
cal: stop trimming whitespaces
tests: add cal day color corner cases
docs: cal: add --color option description to manual page
cal: add --color to usage()
cal: support --color[={auto,always,never}]
cal: de-duplicate julian specific functions
cal: remove unnecessary initializations
cal: simplify calendar reformat calculations
tests: add calendar reformation check
cal: clean up use of constants
cal: convert function like definitions to functions
cal: fix preprocessor directive indendation
Sami Kerola [Mon, 29 Apr 2013 21:30:51 +0000 (22:30 +0100)]
cal: simplify day_in_week() calculation
The day_in_week() can be made easier to read, and should return invalid
weekday at the time of missing 11 days at September 1752.
Reported-by: Thomas Bächler <thomas@archlinux.org>
References: http://www.spinics.net/lists/util-linux-ng/msg07910.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Sun, 28 Apr 2013 20:11:12 +0000 (21:11 +0100)]
cal: mark all functions static
Proposed-by: Dave Reisner <dreisner@archlinux.org>
Reference: http://marc.info/?l=util-linux-ng&m=136717012419551&w=2 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Sun, 28 Apr 2013 08:06:40 +0000 (09:06 +0100)]
cal: clean up use of constants
The commit also adds few new symbolic names, such as DAYS_IN_WEEK. While
these definitions may look a little too trivial to have I am sure they
ease understanding what is going on in code where they are used.
Reviewed-by: Thomas Bächler <thomas@archlinux.org> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Karel Zak [Thu, 23 May 2013 07:25:06 +0000 (09:25 +0200)]
agetty: allow full control on CLOCAL flag
Now the -L option allows to explicitly enable CLOCAL flag.
Unfortunately sometimes it's necessary to clear the flag. This patch
add optional argument =<mode> to specify 'auto', 'always' and 'never'
to control CLOCAL flag.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=816342 Signed-off-by: Karel Zak <kzak@redhat.com>
Gilles Espinasse [Mon, 13 May 2013 14:52:28 +0000 (16:52 +0200)]
tests: new warning fix
2.23 added -Wstrict-prototypes check. Fix make check showing
CC tests/helpers/test_md5.o
tests/helpers/test_md5.c:8: warning: function declaration isn't a prototype
Karel Zak [Tue, 21 May 2013 09:32:29 +0000 (11:32 +0200)]
build-sys: always check for setns() and unshare() libs functions
$ ./configure --disable-unshare
$ make nsenter
CC sys-utils/nsenter.o
In file included from sys-utils/nsenter.c:36:0:
./include/namespace.h:31:19: error: static declaration of ‘unshare’ follows non-static declaration
In file included from /usr/include/sched.h:42:0,
from sys-utils/nsenter.c:23:
/usr/include/bits/sched.h:86:12: note: previous declaration of ‘unshare’ was here
make: *** [sys-utils/nsenter.o] Error 1
We have to always check for the libc function independently on
--disable-{unshare,nsenter} to avoid collision between local and libc
declarations.
Reported-by: "Gabor Z. Papp" <gzp@papp.hu> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 14 May 2013 08:32:56 +0000 (10:32 +0200)]
libmount: don't ignore root fs on umount -a
The release v2.22 (the new umount) introduces a regression when root
fs is excluded from umount --all. There is not reason for this
exception. The libmount should be smart enough to disable mtab update
after rootfs umount.
Reported-by: Bruce Dubbs <bruce.dubbs@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Mike Frysinger [Wed, 8 May 2013 22:12:04 +0000 (18:12 -0400)]
standard SEE ALSO section of man pages
The standard format is to seperate each entry with a comma, and
for each one to be on a line by itself. Most util-linux pages
follow this, but a few do not.
The function sets loopdev size according to backing file size. The
problem is that the backing file could be a block device where
stat.st_size is zero, so we have to use blkdev_get_size() for block
devices.
Addresses: https://bugs.archlinux.org/task/35193 Reported-by: Dave Reisner <d@falconindy.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 6 May 2013 15:20:03 +0000 (17:20 +0200)]
libblkid: fix blkid_parse_tag_string() to ignore incomplete tags
fstab entry:
FOO= / btrfs defaults 1 1
Program received signal SIGABRT, Aborted.
0x00007f016ccd8819 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(gdb) bt
at ../sysdeps/unix/sysv/linux/libc_fatal.c:196
Reported-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Karel Zak <kzak@redhat.com>