Davidlohr Bueso [Mon, 12 Dec 2011 22:52:26 +0000 (23:52 +0100)]
lists: add list sorting routine
We need a list sorting function, just to mention one example user that could
benefit is the lib/tt code to sort columns.
This patch adds list_sort() which uses the Merge Sort algorithm, behaving
nicely in O(nlog(n)), heavily based on the kernel's implementation[1]. The
private data (void *priv) passed to the comparison function as been removed to
adopt a qsort(3)-like syntax, and IMHO we don't really need it anyways.
Karel Zak [Thu, 8 Dec 2011 13:22:04 +0000 (14:22 +0100)]
partx: don't treat empty partition table as error
Phillip wrote:
If a partition table was detected, but it had no partitions
in it, a poorly worded error message was printed and further
action halted. For partx -a, this gave an unnecessary error.
Reported-by: Phillip Susi <psusi@cfl.rr.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Phillip Susi [Mon, 5 Dec 2011 20:02:51 +0000 (15:02 -0500)]
partx: don't print error when partition already doesn't exist
If you run partx -d to delete partitions, and there are gaps
in the sequence ( partition 2 exists, but 1 doesn't ), then it
would complain that it had errors trying to remove the partitions
that already don't exist. Changed to ignore the error when
errno == ENXIO.
Karel Zak [Thu, 8 Dec 2011 10:39:05 +0000 (11:39 +0100)]
agetty: don't use log_err() for non-fatal errors
The TIOCSCTTY ioctl requires that caller is session leader -- so it
depends on initd (or we have to add setsid() to aggety). It seems that the
traditional way is to setup tty in agetty and session in login(1).
It means that all session related things (TIOCSCTTY, vhangup, ...) in the
command agetty should be optional. (Note that vhangup() is called when
--hangup is explicitly specified on command line, so log_err() makes
sense there.)
Reported-by: Andrew Walrond <andrew@walrond.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 28 Nov 2011 09:23:04 +0000 (10:23 +0100)]
Merge branch 'master' of https://github.com/maurizio-lombardi/util-linux
* 'master' of https://github.com/maurizio-lombardi/util-linux:
mkfs.minix: The total number of zones is limited to 65536 only on V1 filesystems
mkfs.minix: Some bug fixes:
mkfs.minix: The s_blocksize field of the MinixV3 superblock must be initialized with a valid block size, not the total number of blocks of the device!
mkfs.minix: inode numbers are 32-bit wide in V3 filesystems
mkfs.minix: In Minix V3 filesystems the maximum filename lenght is 60 chars and the dirsize is 64 bytes.
mkfs.minix: Fix super_set_nzones()
mkfs.minix: remove redundant code
Arnaud Mouiche [Thu, 17 Nov 2011 17:03:04 +0000 (18:03 +0100)]
small bug in mkfs.cramfs + patch
mkfs.cramfs on version v2.17.2 has a small bug when dealing with very small
filesystems. look at upstream code on git, and the issue is still here.
ex:
$ cd /tmp
$ mkdir content
$ echo hello > content/a
$ echo hello > content/b
$ mkfs.cramfs content content.cramfs
not enough space allocated for ROM image (4090 allocated, 4096 used)
Here is a patch for fixing (simply rounding to page size AFTER eleminating
doubles).
Signed-off-by: Arnaud Mouiche <arnaud.mouiche@invoxia.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Cong Wang [Fri, 18 Nov 2011 08:51:37 +0000 (16:51 +0800)]
fallocate: add FALLOC_FL_PUNCH_HOLE support
Recent Linux kernel supports FALLOC_FL_PUNCH_HOLE in fallocate(2).
This patch adds FALLOC_FL_PUNCH_HOLE support to fallocate utility,
by introducing a new option -p|--punch-hole.
[kzak@redhat.com: - fix merge conflict in fallocate.1]
Cc: Karel Zak <kzak@redhat.com> Cc: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Bernhard Voelker [Wed, 16 Nov 2011 16:57:27 +0000 (17:57 +0100)]
prlimit: add support for executing a command
prlimit.c: Alternatively to applying the limits to an existing process via the
--pid option, allow a command to be executed. Adapted usage() accordingly.
prlimit.1: mention new syntax.
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
The lock file cannot be opened in read-write mode by default, because
then we cannot use flock(1) to lock executable files.
The read-write mode for lock files is necessary on NFSv4 where
flock(2) is emulated by by fcntl() -- this situation is possible to
detect by flock(2) EIO error.
This patch reverts the default to O_RDONLY and use O_RDWR only if EIO
error is detected.
Reported-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Bernhard Voelker [Wed, 16 Nov 2011 10:55:43 +0000 (11:55 +0100)]
prlimit: fix case when PID is given later
# prlimit --nofile=:4000 --pid $$
When the PID is given later than a partially given limit, then prlimit
used the current PID for getting the missing part (hard, soft) of the
limit.
Factored out the retrieval of the unknown limit from parse_prlim() to
new get_unknown_hardsoft() which is to be called by do_prlimit() based
on the struct prlimit member 'modify' set by add_prlim().
[kzak@redhat.com: - use prlimit->mofify as mask
- add soft vs. hard limit check from another
Bernhard's patch]
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 16 Nov 2011 09:54:07 +0000 (10:54 +0100)]
prlimit: fix error message
- differentiate between set and get operations
- add limit name to the error message
- remove PID from the message (whole util works always with only one
PID, so this info is superfluous)
Reported-by: Bernhard Voelker <mail@bernhard-voelker.de> Signed-off-by: Karel Zak <kzak@redhat.com>
Bernhard Voelker [Mon, 14 Nov 2011 01:47:57 +0000 (02:47 +0100)]
prlimit: show all limits if called without options
Fix option parsing: prlimit ran into usage() if called
without arguments which should only be done for surplus
arguments. Instead, it should display all limits.
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
fdisk: split delete_partition() off from dos_delete_partition()
This accidentally fixes a mistake printing the "Partition n is deleted"
message as the 'i' variable get decremented or incremented in case of
logical partitions.
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
This allows the creation of a new label if the disk already has an existing
SGI disklabel without working around this problem such as creating a DOS
disklabel or overwriting with zero the partition table (problem reported in
'Gentoo Linux/MIPS Handbook').
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>