Sami Kerola [Wed, 15 Jan 2014 20:15:51 +0000 (20:15 +0000)]
cal: limit year to 32 bit value
This is done to keep things simple, when considering tests, for both 64
and 32 bit architectures. Setting the upper limit of a year value to to
2^31-1 (2147483646) should be enough for anyone.
Reported-by: Mike Frysinger <vapier@gentoo.org>
Reference: http://www.spinics.net/lists/util-linux-ng/msg08662.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Karel Zak [Fri, 24 Jan 2014 12:58:40 +0000 (13:58 +0100)]
losetup: wait for udev
On system with /dev/lop-control the udevd creates /dev/loopN nodes.
It seems better to wait a moment after unsuccessful open(/dev/loopN)
and try it to open again.
The problem is pretty visible on systems where udevd also modifies
permission for loopN devices, then open() fails with EACCES when
losetup executed by non-root user (but user who is in "disk" group).
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1045432 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 24 Jan 2014 12:04:14 +0000 (13:04 +0100)]
include/c.h: prefer nanosleep() over usleep()
Let's use nanosleep() although if usleep() exists. The nanosleep
function does no interact with signals and other timers.
The patch introduces xusleep() as replacement to libc (or our fallback)
usleep(). Yes, we don't want to use struct timespec + nanosleep()
everywhere in code as nano-time resolution is useless for us.
The patch also enlarges delays in some busy wait loops. It seems
enough to try read/write 4x per second.
Karel Zak [Mon, 20 Jan 2014 11:07:35 +0000 (12:07 +0100)]
wipefs: call BLKRRPART when erase partition table
It's better to be smart than make things inconsistent (without
BLKRRPART kernel still uses the erased PT and udev-db still contains
obsolete information).
Karel Zak [Thu, 16 Jan 2014 15:38:30 +0000 (16:38 +0100)]
libblkid: no more probe for btrfs backup superblock
* Linux kernel cares about the first superblock only
* backup superblock are FS specific stuff and there is no reason to
care about it in generic tools
* the problem with broken btrfs utils has been already fixed (it was
possible to use the utils on filesystem with erased primary
superblok without any warning message).
Karel Zak [Thu, 16 Jan 2014 11:22:13 +0000 (12:22 +0100)]
script: don't wait for empty descriptors if child is dead
The current code waits for empty file master and slave descriptors,
but it makes sense only if there is child process that cares (read)
about data in the descriptors.
Scott Moser [Mon, 13 Jan 2014 20:32:49 +0000 (15:32 -0500)]
partx: fix --update ranges and out of order tables
partx --update DEVICE NUMBER
was broken in 2 cases:
* if NUMBER != 1
* if the partition table was "out of order".
Ie, where sda2 came after sda3.
References: https://bugs.launchpad.net/ubuntu/+source/cloud-utils/+bug/1244662 Signed-off-by: Scott Moser <smoser@ubuntu.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Lubomir Rintel [Fri, 27 Dec 2013 21:14:48 +0000 (22:14 +0100)]
unshare: Add possibility to add mapping into root user in user namespace
This makes it very convenient to use make use of privileged actions
on CONFIG_USER_NS enabled kernels, without having to manually tinker
with uid_map and gid_map to obtain required credentials (as those
given upon unshare() vanish with call to execve() and lot of userspace
checks for euid==0 anyway).
Usage example:
$ unshare --uts
unshare: unshare failed: Operation not permitted
$ unshare --user --uts
[nfsnobody@odvarok ~]$ hostname swag
hostname: you must be root to change the host name
Karel Zak [Mon, 6 Jan 2014 15:48:44 +0000 (16:48 +0100)]
lscpu: support discontinuous NUMA nodes
lscpu fails to print proper NUMA node values in a system with
discontinuous nodes. This patch adds support by creating a nodeidx
array to map node numbers.
Based on patch from Madhavan Srinivasan <maddy@linux.vnet.ibm.com>.
Reported-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Sami Kerola [Sun, 22 Dec 2013 18:06:04 +0000 (18:06 +0000)]
cal: mention where Gregorian reformation happen in September 1752
In September 1752 the Gregorian reformation happen in Great Britain and
Dominions (including what is now the USA). One could argue the cal(1)
should consider locale when determining the reformation, but such is
nearly impossible implement correctly.
The dates when reformation happen are split by areas that cannot be
expressed with current locales, for example the Netherlands is split to
two and Germany three categories depending on where in the modern country
one is. Secondly the track when reformation happen is lost for some
countries, Lithuania or Japan are good examples of such.
One of the worst for a programmer is Sweden. They got gradual calendar
change which made Swedish calendar to be completely out of sync. Later
the Swedish calendar jumped in 1753 to be in sync with everyone else.
Notice that some countries, including Saudi Arabia, Ethiopia, Nepal, Iran
and Afghanistan, still have not adopted the Gregorian calendar. Hence
the output of the cal(1) cannot be considered to be correct for everyone.
Lukas Czerner [Tue, 3 Dec 2013 15:24:44 +0000 (16:24 +0100)]
libblkid: Identify extN file system properly
Currently when trying to identify extN file system we're playing games
with searching for kernel modules and parsing /proc/filesystem. All of
this just because ext4 module can be used to mount ext3 and ext2 file
systems on recent kernel and also because of ext4dev.
However all of this is not necessary. Ext4 module which does support
mounting ext2 and ext3 file system is able to recognize and mount ext2
and ext3 type so there is no need to disguise it and ext4dev should only
be ever used for testing and not as fallback when other modules are
missing (use -t instead).
This also introduces a bug when in situation that we only have ext4
modules with ext2/ext3 support which is not loaded and we try to mount
ext2 file system we will mount it incorrectly as ext4. This will not
happen if the ext4 module is already loaded.
With this patch we remove all the unnecessary checks and return the real
type of the file system which is on the device. This fixes the issue.
However on the kernel which was not compiled with EXT4_USE_FOR_EXT23
support one would have to provide file system type (-t) to be able to
mount the file system with ext4 driver.
Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 10 Dec 2013 14:49:49 +0000 (15:49 +0100)]
fstrim: add --all to discard all filesystem
* read /proc/self/mountinfo to get filesystems
* ignore net and pseudo filesystems
* ignore unaccessible filesystems (over mounted by another FS)
* read disk sysfs queue/discard_granularity to detect is discard support
* call FITRIM ioctl
* silently ignore EOPNOTSUPP (for example LUKS without discard) and ENOTTY
(for example vfat) errors
Rik van Riel [Fri, 6 Dec 2013 21:07:54 +0000 (16:07 -0500)]
taskset: fix PERMISSIONS section of taskset man page
A user is always allowed to change the CPU affinity of his or her
own processes. CAP_SYS_NICE is only required to change the affinity
of another user's process.
Signed-off-by: Rik van Riel <riel@redhat.com> Reported-by: Joe Mario <jmario@redhat.com>
Sami Kerola [Sun, 10 Nov 2013 18:23:36 +0000 (18:23 +0000)]
tests: cal: do not let --week=<num> to adjust requested month
The previous commit made --week=<number> to have smaller weight value
than a month supplied by user. The commit started to print the month
that has more days at the week when a week is split to two months, and
only one month output is requested.
Sami Kerola [Sun, 10 Nov 2013 18:23:30 +0000 (18:23 +0000)]
cal: add input variable names to function prototypes
While prototypes such as 'function(int, int, char, int);' are legal they
do not help when trying to understand how the function is expected to be
used. Adding variable names gives at least a hint when looking the
prototypes.
Sami Kerola [Sun, 10 Nov 2013 18:23:28 +0000 (18:23 +0000)]
cal: use control structure for run time configuration
Runtime configuration is set at the time of command line option parsing,
and other initialization. Later the configuration is read-only. This
should make code a little bit more understandable.
Karel Zak [Tue, 3 Dec 2013 12:32:55 +0000 (13:32 +0100)]
script: script input redirection / eof handling
echo "ps uf" | script
does not work because script assume that stdin is terminal and
it does not forward EOF to the pty.
This patch:
* make non-tty use-case more robust (don't call tty ioclts to
non-tty file descriptors.
* send EOF (CTL('D') control char) to the master channel when
detected eof by read() on stdin
* wait for empty master and slave file descriptors to be sure that
we don't miss date for typescript. This is also necessary to be
sure that slave channel (shell) is completely initialized otherwise
EOF is ignored.
Reported-by: Phillip Susi <psusi@ubuntu.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Werner Fink [Fri, 29 Nov 2013 15:44:25 +0000 (16:44 +0100)]
agetty: support the special terminal on first serial line on a S/390
which is due legacy reasons a block terminal of type 3270 or higher.
Whereas the second serial line on a S/390(x) is a real character
terminal which is compatible with VT220.
Dave Reisner [Thu, 21 Nov 2013 17:25:27 +0000 (12:25 -0500)]
pylibmount: correctly import from pylibmount.so
Without this, python is unable to find the module:
$ python -c 'import libmount'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.3/site-packages/libmount/__init__.py", line 1, in <module>
from pylibmount import *
ImportError: No module named 'pylibmount'
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Karel Zak [Mon, 25 Nov 2013 11:00:55 +0000 (12:00 +0100)]
fdisk: don't care about partition type
fdisk allows to overwrite existing partition if the partition has
partition type set to zero (very unusual, but possible).
This is incorrect because such partition is pretty valid (and Linux
kernel does not care about the type at all). For example:
Device Boot Start End Blocks Id System
/dev/sdb1 2048 22527 10240 83 Linux
/dev/sdb2 22528 227327 102400 0 Empty
^^^^^ ^^^^^^^^
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p):
Using default response p
Partition number (3,4, default 3):
First sector (22528-1228799, default 22528):
^^^^^^^
.. if user follows the default then the result are overlapping
partitions:
Device Boot Start End Blocks Id System
/dev/sdb1 2048 22527 10240 83 Linux
/dev/sdb2 22528 227327 102400 0 Empty
/dev/sdb3 22528 1228799 603136 83 Linux
^^^^^
... and if you call "mkfs /dev/sdb3" then you lost data on sdb2. Sad
thing.
Reported-by: Marc MERLIN <marc@merlins.org> Signed-off-by: Karel Zak <kzak@redhat.com>