Karel Zak [Wed, 6 Jan 2010 10:12:43 +0000 (11:12 +0100)]
fdisk: sleep-after-sync and fsync usage
It seems that sleep() after sync() is unnecessary legacy. It's very
probably unnecessary since kernel 1.3.20. For example the libparted
does not to use sleep() at all.
It seems that more important is fsync() usage in fdisks. For more
details see
DRBD is the Distributed Replicated Block Device, a replication service for low
level block devices.
The attached patch provides libblkid detection for v08 type drbd devices
(v08 is the current one).
[kzak@redhat.com: - port to libblkid 2.17
- use BLKID_USAGE_RAID flag
- remove BLKID_IDINFO_TOLERANT flag
- note that DRBD is supported since kernel v2.6.33-rc1]
Signed-off-by: Bastian Friedrich <bastian.friedrich@collax.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 4 Jan 2010 10:34:13 +0000 (11:34 +0100)]
sfdisk: confused about disk size
The size of disk in the sfdisk command is based on number of cylinders
(this is probably legacy from CHS epoch). That's wrong because
partitions are addressed in sectors (LBA), so cylinders don't provide
necessary resolution (granularity).
On Sat, Jan 02, 2010 at 01:01:16PM +0100, Giulio wrote:
> $ cat /sys/block/sda/size
> 184549376
>
> $ sfdisk -d /dev/sda > part.dump
> $ cat part.dump
> # partition table of /dev/sda
> unit: sectors
>
> /dev/sda1 : start= 2048, size= 2097152, Id=83
> /dev/sda2 : start= 2099200, size= 12582912, Id=83
> /dev/sda3 : start= 14682112, size= 84934656, Id=83
> /dev/sda4 : start= 99616768, size= 84932608, Id=83
>
>
> $ sfdisk -L /dev/sda < part.dump
> Checking that no-one is using this disk right now ...
> OK
>
> Disk /dev/sda: 11487 cylinders, 255 heads, 63 sectors/track
> Old situation:
> Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
>
> Device Boot Start End #cyls #blocks Id System
> /dev/sda1 0+ 130- 131- 1048576 83 Linux
> /dev/sda2 130+ 913- 784- 6291456 83 Linux
> /dev/sda3 913+ 6200- 5287- 42467328 83 Linux
> /dev/sda4 6200+ 11487- 5287- 42466304 83 Linux
> Warning: given size (84932608) exceeds max allowable size (84921887)
Mike Frysinger [Sat, 26 Dec 2009 19:56:54 +0000 (14:56 -0500)]
pg: command enters infinite loop
In a multibyte locale such as en_GB.UTF-8, the pg command cannot handle files
containing a form feed character (ASCII 0x0c) at the start of a line. The
program enters an infinite loop.
I've traced the problem to the function endline_for_mb in file pg.c. The code
assumes that the libc function wcwidth will return a nonnegative value, which
is not true for a form feed character. wcwidth returns -1 and the unsigned
variable "pos" goes into underflow.
I'll attach a patch which tests whether the character is printable before
calling wcwidth. If not, it uses instead the width of the constant L'?' which
is later used to replace nonprintable characters. I trust that we can assume
printability of this constant :-)
Steps to Reproduce:
1. Select a multibyte locale (tested with en_GB.UTF-8)
2. Create a file with a form feed character (0x0c) at the start of a line.
3. Try to display this file using the pg command.
Reported-by: Mark Calderbank <m.calderbank@iname.com> Reported-by: Mike Frysinger <vapier@gentoo.org>
Addresses: https://bugs.gentoo.org/297717 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 10 Dec 2009 10:59:46 +0000 (11:59 +0100)]
lib: bug (typo) in function MD5Final()
On Wed, Dec 09, 2009 at 10:08:38PM +0000, Jochen Voss wrote:
> while experimenting with coccinelle, I accidentally found what I
> believe is a bug in util-linux-ng release 2.17-rc2 (downloaded
> today). The problem is the following code in lib/md5.c (around line
> 153):
>
> void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
> {
> [...]
> memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
> }
>
> The third argument of memset should probably be the size of 'struct
> MD5Context' instead of the size of the pointer. So my guess is
> that the memset line should be
>
> memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
>
> instead. I don't know whether this actually causes a problem,
> but the comment makes it seem possible that it does.
Note, this typo does not have any impact on the utils in the
util-linux-ng project, because we don't use MD5 for any security
sensitive data or cryptographic stuff. The typo also does not have any
impact to the final MD5 hashes.
Reported-by: Jochen Voss <voss@seehuhn.de> Signed-off-by: Karel Zak <kzak@redhat.com>
Mike Frysinger [Mon, 7 Dec 2009 14:18:17 +0000 (15:18 +0100)]
flock: fix hang when parent ignores SIGCHLD
If flock is executed from a process which has set SIGCHLD to SIG_IGN, then
flock will eat cpu and hang indefinitely if given a command to execute.
So before we fork(), make sure to set SIGCHLD handling back to the default
so that the later waitpid() doesn't freak out on us.
[kzak@redhat.com: - add a check for waitpid() return value]
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 4 Dec 2009 14:45:19 +0000 (15:45 +0100)]
build-sys: rewrite TLS detection
* use more robust tls.m4 from gcc project
The old version (from util-linux-ng) used AC_TRY_COMPILE. That's
wrong. We need to use AC_RUN_IFELSE to check that the result is
link-able and executable.
The new version also test it TLS really works in multi-thread
applications.
* we need to detect TLS usability for cross-compiling
* this new version supports __thread keyword only, it seems that we
needn't to care about anything other
Ludwig Nussel [Fri, 27 Nov 2009 09:15:53 +0000 (10:15 +0100)]
fsck: honor nofail option in fsck
analog to mount gracefully ignoring non existing devices if the "nofail"
option is specified in fstab, also have fsck -A skip them. This way it's
possible to have devices optionally not available during boot but still
have them fsck'd if they are there.
Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
Even though --systz doesn't need to change the system clock when the
hardware clock is in UTC time (--systz --utc), it does need to set
the kernel timezone so that FAT timestamps, etc. will be correct.
Signed-off-by: Scott James Remnant <scott@ubuntu.com>
hwclock: do not access hardware clock when using --systz
When using --systz we do not read from the hardware clock, so there
is no need to search for a hardware clock. Indeed, we may be running
hwclock --systz before /dev is mounted.
Signed-off-by: Scott James Remnant <scott@ubuntu.com>
Mike Frysinger [Tue, 13 Oct 2009 10:05:19 +0000 (06:05 -0400)]
swapon: handle <=linux-2.6.19 bug in /proc/swaps
Linux <=2.6.19 contained a bug in the /proc/swaps code where the header
would not be displayed (the first line). Most people report the issue as
a sequence of swapon/swapoff calls to trigger, but for some lucky people,
it triggers all the time at initial boot. Since this throws up an error,
init systems don't actually activate any swap files.
First, swapon shouldn't whine about unexpected format if the file is empty
(the default at boot). This is easy to do by putting the warning behind a
check to ferror().
Second, we can detect that the first line isn't actually the header but
instead is a valid swap line and so need to be processed. This assumes
that the first line will always be the same format. Looking quickly at
older versions shows that this header has retained its exact format since
at least Linux 2.2.0 and considering the concern that goes along with proc
files and the ABI, it's highly unlikely it will ever change.
Karel Zak [Tue, 29 Sep 2009 09:08:32 +0000 (11:08 +0200)]
libblkid: fix the default cache file path
The blkid_get_cache_filename() can returns BLKID_CONFIG_FILE instead
BLKID_CACHE_FILE. Yeah, pretty stupid typo.
Fortunately, this brown-paper-bag bug is invisible in almost all cases,
because the default path is returned by blkid_read_config(). The bug
can be visible only when blkid_read_config() returns NULL -- it means
on parses or malloc error.
mount: document changed semantics of tmpfs size option in mount.8
Linux kernel commit 818db35992c249dc32c1d86daf7d533fb0952f5d fixed a
problem where invoking mount -t tmpfs with a size argument smaler than the
size of one page caused the limits on the size of a tmpfs to not operate.
The commit also caused the number supplied by the size option to be
rounded up to the nearest page size instead of down. This alters the man
page to match the behavior of the kernel in this instance.
Signed-off-by: Kevin Granade <kevin.granade@gmail.com>
Karel Zak [Fri, 11 Sep 2009 12:00:50 +0000 (14:00 +0200)]
sfdisk: dump has to be $LANG insensitive
This stupid bug has been introduced by:
commit add5133f4ad5136aac3ce7627e615d14893d0aeb
Author: Pedro Ribeiro <p.m42.ribeiro@gmail.com>
Date: Fri Oct 3 08:52:35 2008 +0200
fdisk: several strings without gettext calls
... so it shows that we need to improve our review process... :-(
Address-Red-Hat-Bug: #522718 Signed-off-by: Karel Zak <kzak@redhat.com>