Davidlohr Bueso [Tue, 16 Nov 2010 13:47:35 +0000 (10:47 -0300)]
lib: [strutils] general purpose string handling functions
This patch replaces a few functions used throughout the source:
* Renames getnum (from schedutils) to strtol_or_err
* Moves strtosize (from lib/strtosize.c)
* Moves xstrncpy (from include/xstrncpy.h)
* Adds strnlen, strnchr and strndup if not available (remove it from libmount utils)
A few Makefile.am files were modified to compile accordingly along with trivial renaming
in schedutils source code.
Davidlohr Bueso [Mon, 15 Nov 2010 11:55:16 +0000 (08:55 -0300)]
lib/tt: fix langinfo build break
When HAVE_LANGINFO_H is not defined we break the compilation in tt.c:
CC tt.o
tt.c: In function ‘tt_new_table’:
tt.c:142: warning: implicit declaration of function ‘nl_langinfo’
tt.c:142: error: ‘CODESET’ undeclared (first use in this function)
tt.c:142: error: (Each undeclared identifier is reported only once
tt.c:142: error: for each function it appears in.)
make: *** [tt.o] Error 1
Thorsten Glaser [Sun, 7 Nov 2010 14:00:04 +0000 (14:00 +0000)]
hwclock: [m68k] unbreak FTBFS with recent (>= 2.4.18?) kernels
The old KDGHWCLK ioctl was removed from the Linux kernel quite some
time ago. The kd.c source file of hwclock contains fallback code to
handle this, but the fallback code never could have compiled or was
not fixed along other code changes. The Linux kernel nowadays igno-
res the ioctl entirely so removing it unless provided by the kernel
headers, to keep it working on very old kernels, seems the sensible
thing to do, as the comments say m68k only and deprecated (which is
correct AFAICT).
According to pickaxe on gitweb, it was removed in 2002:
http://git.kernel.org/?p=linux/kernel/git/torvalds/old-2.6-bkcvs.git;a=commit;h=a915e414af5fc541ff62ef0bfec847457ae650bc
Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=578168 Signed-off-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Jeroen Oortwijn [Sun, 31 Oct 2010 20:32:21 +0000 (21:32 +0100)]
libblkid: add signature to FAT32 fsinfo block
Add 0x41645252 to the list of valid signatures of the FAT32 fsinfo
block. It isn't a valid signature, but there are devices that use this
signature in their FAT32 filesystem.
Hugh Dickins [Mon, 25 Oct 2010 00:32:47 +0000 (17:32 -0700)]
swapon: add "discard" support
In kernel 2.6.36 (and in stable kernel 2.6.35.5) I made a tiny change
to the swapon(const char *path, int swapflags) system call interface:
kernel commit 3399446632739fcd05fd8b272b476a69c6e6d14a
swap: discard while swapping only if SWAP_FLAG_DISCARD
As things stand at present, we could just remove the swap discard
support; but since several filesystems (including ext4 and btrfs and
fat) are offering a "discard" mount option, I thought swap should take
the same course, and offer a "--discard" or "-d" option to swapon(8).
[kzak@redhat.com: - update swapon.8 man page
- use for -d the same logic as for -p]
Signed-off-by: Hugh Dickins <hughd@google.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 26 Oct 2010 10:58:32 +0000 (12:58 +0200)]
fsck: add support for whole-disk locking (-l option)
This feature allows to call multiple independent fsck instances rather
than use only one "fsck -A" process.
The lock uses LOCK_EX flock(2). The lock request is ignored if the
whole-disk is non-rotating disk. The verbose mode (-V) provides
information about disk locking.
Note that "fsck -l" does not care if the device is stacked, for
example if you want to call "fsck -l /dev/md0" and "fsck -l /dev/md1"
then the underlying devices will not be locked. The traditional "fsck
-A" does not run in parallel for stacked devices.
Requested-by: Lennart Poettering <lennart@poettering.net> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 25 Oct 2010 21:23:48 +0000 (23:23 +0200)]
libmount: optimize blkid_devno_to_devname()
The brutal force /dev directory scanning should be used as a fallback
solution only. Currently, almost all systems use udev and we can read the
name from /sys/block/<maj>:<min> symlink.
Karel Zak [Mon, 25 Oct 2010 12:03:16 +0000 (14:03 +0200)]
swapon: add support for "nofail" fstab mount option
This option is already supported by mount(8) and fsck(8), there is no
reason to have any exception for swap devices. Note that the --ifexists
command line option applies to all swap devices, the "nofail" setting
is per device.
Karel Zak [Mon, 25 Oct 2010 10:26:28 +0000 (12:26 +0200)]
umount: umount -r segfault
umount(8) segfaults when update incomplete mtab file after remount to
read-only (-r). For example autofs does not store info about
mountpoint to /etc/mtab file.
# mount /dev/sda1 /mnt/test
# sed -i -e 's:/dev/sda1 .*::g' /etc/mtab
# cd /mnt/test
# umount -r /mnt/test
umount: /mnt/test busy - remounted read-only
Segmentation fault
The command "umount -r" should not care about /etc/mtab if the related
mtab entry does not exist.
Reported-by: Paul Crawford <psc@sat.dundee.ac.uk>
Addresses: https://bugs.launchpad.net/bugs/579858 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 14 Oct 2010 23:33:28 +0000 (01:33 +0200)]
libblkid: fix MBR detection on iPod and cleanup vfat code
- move all FAT code to superblocks/vfat.c only
- add a generic function to verify FAT superblock and use it
in FAT prober as well as in MBR parser
- add a more robust FAT cluster_count check
(it seems that iPod contains an "almost valid" FAT superblock before MBR)
Reported-by: Davidlohr Bueso <dave.bueso@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
The example in the man page does not prevent concurrent execution, as it
obtains a shared lock. More useful is taking an exclusive lock, i.e.
remove "-s".
Additionally, IMO most people want the script to exit when the lock
cannot be acquired, so adding "-n".
Forest Bond [Tue, 5 Oct 2010 01:01:30 +0000 (21:01 -0400)]
sfdisk: save errno before calling perror
errno is saved into a local variable to avoid it getting trampled
by perror before it is checked to determine the return value.
This issue seems quite rare, but I have seen it when running sfdisk
via gksudo and using the --quiet command-line option. From what I
can tell, this combination triggers loading of translations in perror,
which (at least on my machine) ends up changing the value of errno.
Signed-off-by: Forest Bond <forest@alittletooquiet.net>
Mike Frysinger [Sun, 3 Oct 2010 20:00:09 +0000 (16:00 -0400)]
fallocate: fix build failure with old linux headers
If linux/falloc.h does not exist, the build system still enables the
fallocate util, but ultimately fails when it tries to include the
header and use a define from it.
Add searching for the be:volume_id attribute in the attributes directory
of the root directory. UUID is now always set when the root directory
contains the be:volume_id attribute.
Sami Kerola [Thu, 30 Sep 2010 22:33:44 +0000 (00:33 +0200)]
namei: parse all path arguments when an optarg path will fail
Old implementation of namei listed path all the way to non-existing
file or directory, something like:
f: /usr/bin/nxdir/file
d /
d usr
d bin
? nxdir - No such file or directory (2)
whiles the current implementation prints:
namei: failed to stat: /usr/bin/nxdir/file: No such file or directory
The new output it's not helpful. I am especially interested see where
the path is broken when a path is symlink to other path with symlink,
and few more like that, and something somewhere is broken.
[kzak@redhat.com: - coding style changes]
Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
Sven Eckelmann [Sun, 26 Sep 2010 19:18:15 +0000 (21:18 +0200)]
mount: Don't call canonicalize_*(SPEC) for 9p
When calling "mount -t 9p -o trans=virtio foobar /mnt/bar" and foobar
exists in the current path, the 9p virtio transport driver will be
called with $CWD/foobar and fail with "9p: no channels available".
Similar problems exist with remote file servers
"mount -t 9p 23.42.08.15 /mnt/bar"
and Plan 9 From User Space applications
"mount -t 9p -o trans=unix,uname=$USER `namespace`/acme /mnt/bar"
A similar exception like for nfs, cifs and smbfs must be added for 9p.
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
Karel Zak [Thu, 30 Sep 2010 20:27:42 +0000 (22:27 +0200)]
ddate: revert man page typo
On Sat, Sep 18, 2010 at 03:10:52AM +0300, Anssi Hannula wrote:
> According to wikipedia [1] 'Holyday' was the correct spelling, I
> guess the first hunk should be reverted.
>
> [1] http://en.wikipedia.org/wiki/Discordian_calendar
Karel Zak [Mon, 6 Sep 2010 11:30:48 +0000 (13:30 +0200)]
cfdisk: don't use size of device based on cylinders
This patch is enough to make cfdisk usable on non-DOS disks where
partitioning is not based on CHS. cfdisk should not print error
messages for such disks.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=630340 Signed-off-by: Karel Zak <kzak@redhat.com>
Miklos Szeredi [Fri, 27 Aug 2010 14:58:44 +0000 (16:58 +0200)]
mount: handle filesystems with subtype
Linux can handle filesystem types with "MAINTYPE.SUBTYPE" format,
where the main type determines the actual filesystem driver while the
subtype can be interpreted by the filesystem itself.
When searching for mount helpers mount(8) and umount(8) should also
interpret such types, falling back to (u)mount.MAINTYPE if
(u)mount.MAINTYPE.SUBTYPE doesn't exist.
This patch implements this, passing the type with "-t TYPE"
to the mount program in this case.
Reported-by: Josef Bacik <josef@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=625064 Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Karel Zak [Fri, 27 Aug 2010 10:22:27 +0000 (12:22 +0200)]
mount: sanity check mount flags for MS_PROPAGATION
mount(8) reuses mount flags from fstab/mtab, the problem is that for
MS_PROPAGATION operations kernel incorrectly evaluates mount flags if
the flags contains any non-propagation stuff (e.g. MS_RDONLY). For
example --make-shared on read-only FS:
# strace -e mount mount --make-shared /mnt/test
mount("/dev/sda1", "/mnt/test", "none", MS_RDONLY|MS_SHARED, NULL) = 0
must be:
# strace -e mount mount --make-shared /mnt/test
mount("/dev/sda1", "/mnt/test", "none", MS_SHARED, NULL) = 0
Reported-by: Valerie Aurora <vaurora@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4, default 1):
Using default value 1
First sector (256-262143, default 256): 257
Last sector, +sectors or +size{K,M,G} (257-262143, default 262143): +100M
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
32 heads, 32 sectors/track, 256 cylinders, total 262144 sectors
Units = sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 262144 bytes
Disk identifier: 0x16db2bb0
Device Boot Start End Blocks Id System
/dev/sdb1 257 25855 102396 83 Linux
Partition 1 does not start on physical sector boundary.
^^^^^^^^
The warning is nonsense. The logical and physical sector size is the
same. It means that every LBA is always aligned to physical sector
boundary.
Note that this bug does not mean that fdisk produces unaligned
partitions. The problem is that fdisk forces to use bigger gaps
between aligned LBAs, for example: