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:
Dima Kogan [Sat, 14 Aug 2010 09:15:47 +0000 (02:15 -0700)]
tailf: fixed timing issue that could cause duplicate data output
The issue is that in roll_file() we fstat() to find the file size, then read()
as much data as we can and then use the previously saved file size to mark our
position. The bug occurs if we read past the file size reported by fstat()
because more data has arrived while we were reading it. The attached patch uses
the current file position as the location marker instead, with some extra logic
to handle tailing truncated files.
[kzak@redhat.com: - fix coding style]
Signed-off-by: Dima Kogan <dkogan@cds.caltech.edu> Signed-off-by: Karel Zak <kzak@redhat.com>
Davidlohr Bueso [Sun, 8 Aug 2010 21:03:56 +0000 (17:03 -0400)]
rev: coding style, various fixes
* Change indentation to 8 characters and coding style, for better reading the code.
* Add some memory allocation error handling.
* Fix memory leaks. In cases when Ctrl-C is used to exit the program,
'p' cannot be freed, so made it a global var, to share between main()
and sig_handler(). Signal handing is necessary to fix some leaks, so
added a very basic, non invasive, mechanism.
Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
The current heuristic for conversion from partition to whole-disk
is based on device names. It's pretty poor. This patch replaces this
code with blkid_devno_to_wholedisk(). This solution is based on
/sys FS and it works for arbitrary partitioned devices.
The another problem is the way how fsck determines stacked devices.
The current code checks device name for "md" prefix only. It does not
care about DM, dm-ccypt, and so on. This patch uses
/sys/block/.../slaves/, but it does not fully resolves dependencies
between all devices. The method is simple -- fsck does not check
stacked devices in parallel with any other device.
Karel Zak [Wed, 18 Aug 2010 07:02:03 +0000 (09:02 +0200)]
agetty: add -s to reuse existing baud rate
For example:
/sbin/agetty -s /dev/ttyS0 9600
will reuse the speed the kernel configured on the port. If the setting
from kernel is useless (tty returns BREAK character) then the baud
rate from command line (9600) is used.
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=623685 Signed-off-by: Karel Zak <kzak@redhat.com>