]> err.no Git - util-linux/log
util-linux
14 years agoblkid: support suffixes for -O <offset> and -S <size>
Karel Zak [Tue, 30 Mar 2010 11:58:16 +0000 (13:58 +0200)]
blkid: support suffixes for -O <offset> and -S <size>

for example:  blkid -p -O 17816085KiB /dev/sda

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolib: add strtosize() function
Karel Zak [Tue, 30 Mar 2010 11:47:33 +0000 (13:47 +0200)]
lib: add strtosize() function

This function

  int strtosize(const char *str, uintmax_t *res)

supports {K,M,G,T,E,P}iB and {K,M,G,T,E,P}B suffixes.

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agohwclock: add --predict for predicting RTC reading at a given time
Timo Juhani Lindfors [Sat, 13 Mar 2010 10:28:50 +0000 (12:28 +0200)]
hwclock: add --predict for predicting RTC reading at a given time

Implement new option --predict that predicts what the RTC will read
at a time given by the --date option. This is useful for example if
you need to setup an RTC wakeup time to distant future and want to
account for the RTC drift.

Signed-off-by: Timo Juhani Lindfors <timo.lindfors@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoblkid: cleanup man page
Karel Zak [Tue, 23 Mar 2010 13:24:02 +0000 (14:24 +0100)]
blkid: cleanup man page

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agodocs: update TODO file
Karel Zak [Tue, 23 Mar 2010 13:12:35 +0000 (14:12 +0100)]
docs: update TODO file

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoblkid: add -n <list> option
Karel Zak [Tue, 23 Mar 2010 13:06:54 +0000 (14:06 +0100)]
blkid: add -n <list> option

This option allows to restrict low-level probing to the defined list
of superbocks (filesystems or RAIDs). For example:

blkid -p -n ext3,ext4,vfat /dev/sda1
or
blkid -p -n novfat /dev/sda1

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoblkid: cleanup -u <list> parsing
Karel Zak [Mon, 22 Mar 2010 14:16:01 +0000 (15:16 +0100)]
blkid: cleanup -u <list> parsing

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: fix -b <sectorsize>
Karel Zak [Fri, 19 Mar 2010 14:56:27 +0000 (15:56 +0100)]
fdisk: fix -b <sectorsize>

The old fdisk (<2.17) does not differentiate between logical and
physical sector size, it uses the <sectorsize> for everything.

Now, we have logical and physical sectors size, but the -b option
changes the logical size only. The second bug is that "fdisk -b <sz>"
does not read topology information (it means that all I/O limits and
physical sector size are 512 (default).

The backwardly compatible bug fix is to override both sizes, logical
and physical if "-b" is used.

In future we can add a special option for physical size only.

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agodocs: update TODO file
Karel Zak [Fri, 19 Mar 2010 14:18:42 +0000 (15:18 +0100)]
docs: update TODO file

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: add microsecond resolution for cache entries
Karel Zak [Wed, 17 Mar 2010 13:49:14 +0000 (14:49 +0100)]
libblkid: add microsecond resolution for cache entries

The libblkid library uses stat.st_mtine to detect changes on the
device. The last update time of of the device in the cache is stored
as TIME= tag in the /etc/blkid.tab file.

Linux since 2.5.48 supports nanosecond resolution and more precise
time is available in the stat.st_mtim timespec struct.

This patch add microsecond precision to TIME= tag in the cache file,
old format:

TIME="<sec>"

the new format:

TIME="<sec>.<usec>"

This change is backwardly compatible.

Now, the blkid_verify() function checks stat.st_mtime and
stat.st_mtim.tv_nsec/1000.

Test:

 # e2label /dev/sdb1 AAAA

old version:

 # blkid -s LABEL /dev/sdb1; e2label /dev/sdb1 BBBB; blkid -s LABEL /dev/sdb1
 /dev/sdb1: LABEL="AAAA"
 /dev/sdb1: LABEL="AAAA"

new version:

 # blkid -s LABEL /dev/sdb1; e2label /dev/sdb1 BBBB; blkid -s LABEL /dev/sdb1
 /dev/sdb1: LABEL="AAAA"
 /dev/sdb1: LABEL="BBBB"

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolib: fix blkdev_find_size()
Karel Zak [Tue, 16 Mar 2010 16:31:39 +0000 (17:31 +0100)]
lib: fix blkdev_find_size()

echo l | fdisk/fdisk /dev/zero

FYI that however now spins forever doing:

offset=3074457345618258603)
    at ../lib/blkdev.c:31
    at ../lib/blkdev.c:151
    at ../lib/blkdev.c:161

Reported-by: Pádraig Brady <P@draigBrady.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: correctly truncate and align translated partition names
Pádraig Brady [Tue, 9 Mar 2010 08:21:35 +0000 (08:21 +0000)]
fdisk: correctly truncate and align translated partition names

* fdisk/Makefile.am: Depend on the mbsalign module.
* fdisk/fdisk.c: Align using mbsalign rather than printf.

[kzak@redhat.com: - use size_t for width to fix gcc warning]

Reported-by: Makoto Kato <m_kato@ga2.so-net.ne.jp>
Signed-off-by: Pádraig Brady <P@draigBrady.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolib: add #ifndef around min() max() macros
Karel Zak [Tue, 16 Mar 2010 14:24:04 +0000 (15:24 +0100)]
lib: add #ifndef around min() max() macros

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agocal: factor out and update multibyte alignment code
Pádraig Brady [Mon, 8 Mar 2010 18:29:01 +0000 (18:29 +0000)]
cal: factor out and update multibyte alignment code

* include/mbsalign.h: New module interface
* lib/mbsalign.c: Updated implementation synced from coreutils
* include/Makefile.am: Add mbsalign.h
* misc-utils/Makefile.am: Make cal dependent on mbsalign module
* misc-utils/cal.c: Call mbsalign()

[kzak@redhat.com: - use min() macro from c.h]

Signed-off-by: Pádraig Brady <P@draigBrady.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agodocs: update TODO file
Karel Zak [Tue, 16 Mar 2010 13:52:10 +0000 (14:52 +0100)]
docs: update TODO file

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolib: avoid compilation failure on rawhide
Jim Meyering [Tue, 16 Mar 2010 12:46:58 +0000 (13:46 +0100)]
lib: avoid compilation failure on rawhide

* lib/blkdev.c: Include <sys/stat.h>, for use of S_ISREG.

14 years agomount: automatically detect and loop-mount regular files
Karel Zak [Mon, 15 Mar 2010 16:10:35 +0000 (17:10 +0100)]
mount: automatically detect and loop-mount regular files

This patch allows to automatically create a loop device from a regular
file if a filesystem type is not specified, for example:

   mount /path/disk.img /mnt

If the filesystem type is specified than "-o loop" is required.

Note that there is not a restriction (on kernel side) that prevents
regular file as a mount(2) source argument. A filesystem that is able
to mount regular files could be implemented.

Based on a patch from Adam Jackson <ajax@redhat.com>.

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agomount: more explicitly explain fstab usage in mount.8
Karel Zak [Mon, 15 Mar 2010 13:36:22 +0000 (14:36 +0100)]
mount: more explicitly explain fstab usage in mount.8

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agomount: report ambivalent FS detection, improve brute force detection
Karel Zak [Mon, 15 Mar 2010 12:46:43 +0000 (13:46 +0100)]
mount: report ambivalent FS detection, improve brute force detection

The ambivalent probing result should be properly reported and user
should be informed that the problem is possible to bypass by "-t
<type>" or resolved by wipefs(8).

The mount(8) command uses a brute force stage (calls mount(2) for all
/{proc,etc}/fylesystems) if there is not any other way how to detect
the filesystem type. The brute force stage should not be restricted by
libblkid. It's possible that libblkid is not able to detect slightly
corrupted filesystem, but kernel is able to mount such filesystem.

Note that the brute force stage should not be used if libblkid returns
ambivalent probing result. In this case user's intervention is required
(e.g. mount -t <type>).

Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agowipefs: cleanup usage() and man page
Karel Zak [Mon, 15 Mar 2010 12:45:03 +0000 (13:45 +0100)]
wipefs: cleanup usage() and man page

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agotests: fix whitespaces
Karel Zak [Sun, 14 Mar 2010 22:18:17 +0000 (23:18 +0100)]
tests: fix whitespaces

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoionice: fix typo
Pierre Hauweele [Sat, 13 Mar 2010 23:50:36 +0000 (00:50 +0100)]
ionice: fix typo

Signed-off-by: Pierre Hauweele <antegallya@gmail.com>
14 years agolibblkid: fix infinite loop when probe chain bails out early
Colin Watson [Sat, 13 Mar 2010 00:46:35 +0000 (00:46 +0000)]
libblkid: fix infinite loop when probe chain bails out early

The superblocks probe bails out early with no results in some cases.  If
this happens, blkid_do_probe needs to go to the next chain, rather than
entering an infinite loop calling superblocks_probe over and over again.

[kzak@redhat.com: - print debug message always when leaving
                    superblocks_probe()]

Addresses: https://bugs.launchpad.net/bugs/528073
Signed-off-by: Colin Watson <cjwatson@canonical.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: remove "0x" prefix from DRBD UUID
Karel Zak [Thu, 11 Mar 2010 14:52:54 +0000 (15:52 +0100)]
libblkid: remove "0x" prefix from DRBD UUID

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: improve ZFS detection and add LABEL and UUID extraction
Andreas Dilger [Thu, 11 Mar 2010 14:16:46 +0000 (15:16 +0100)]
libblkid: improve ZFS detection and add LABEL and UUID extraction

Improve ZFS uberblock detection to loop over multiple uberblocks,
and detect at least 4 magic values, to avoid random collisions.
It doesn't yet probe the VDEV LABEL at the end of the device, though
it wouldn't be too hard to add it at this point if needed.

Add extraction of the pool name (as LABEL), the VDEV (block device)
guid as UUID_SUB, and pool_guid (volume) as UUID from the nvlist in
the VDEV LABEL.  Do simple sanity checking on the nvlist data values
to avoid overflowing the buffer if they are corrupt in any way.

[kzak@redhat.com: - use %PRIu64 instead %llu]

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: prevent overflow in BeFS
Jeroen Oortwijn [Tue, 9 Mar 2010 22:15:30 +0000 (23:15 +0100)]
libblkid: prevent overflow in BeFS

Prevent overflow by casting values to blkid_loff_t before applying
block shift.

Signed-off-by: Jeroen Oortwijn <oortwijn@gmail.com>
14 years agoumount: add --fake option to umount(8)
Miklos Szeredi [Mon, 8 Mar 2010 18:01:13 +0000 (19:01 +0100)]
umount: add --fake option to umount(8)

Add --fake option to umount(8), which omits calling the actual umount
syscall (and the loop device deletion) but modifies /etc/mtab.  This
is similar to the -f or --fake option to mount(8).

This would allow some simplifications in fuse by allowing it to call
the umount syscall and letting umount(8) just update mtab.

[kzak@redhat.com: - initialize 'res' variable in umount_one() ]

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agomount: properly ignore comments in /etc/filesystems
Mike Frysinger [Sun, 7 Mar 2010 05:16:41 +0000 (00:16 -0500)]
mount: properly ignore comments in /etc/filesystems

The POSIX spec for sscanf() says that whitespace may be matched against 0
bytes which means doing sscanf(" %s") against "#foo" will result in a
match. You can see this behavior by using the verbose options on a garbage
file:

...
mount: you didn't specify a filesystem type for /dev/null
       I will try all types mentioned in /etc/filesystems or /proc/filesystems
Trying #
mount: mount(2) syscall: source: "/dev/null", target: "/", filesystemtype: "#", mountflags: -1058209792, data: (null)
Trying #vfat
mount: mount(2) syscall: source: "/dev/null", target: "/", filesystemtype: "#vfat", mountflags: -1058209792, data: (null)
...

Reported-by: Dave Barton <dave.barton@comodo.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
14 years agotests: update fdisk tests
Karel Zak [Thu, 11 Mar 2010 00:06:45 +0000 (01:06 +0100)]
tests: update fdisk tests

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agomkswap: don't call blkdev_find_size()
Karel Zak [Thu, 11 Mar 2010 00:04:50 +0000 (01:04 +0100)]
mkswap: don't call blkdev_find_size()

.. it's already called by blkdev_get_size().

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: don't use fstat() in blkid_get_dev_size()
Karel Zak [Wed, 10 Mar 2010 23:59:47 +0000 (00:59 +0100)]
libblkid: don't use fstat() in blkid_get_dev_size()

We already use fstat() in blkdev_get_size().

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolib: use fstat() as fallback in blkdev_get_size()
Karel Zak [Wed, 10 Mar 2010 23:59:04 +0000 (00:59 +0100)]
lib: use fstat() as fallback in blkdev_get_size()

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agomount: use unmangle/mangle() from lib
Karel Zak [Wed, 10 Mar 2010 23:27:35 +0000 (00:27 +0100)]
mount: use unmangle/mangle() from lib

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoswapon: use unmangle() for filenames from /proc/swaps
Karel Zak [Wed, 10 Mar 2010 22:59:33 +0000 (23:59 +0100)]
swapon: use unmangle() for filenames from /proc/swaps

linux kernel encodes all garbage in filenames by mangle() function. We
need to unmagle() to get the real filenames.

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolib: add mangle.c for mtab (fstab or swaps) encoding
Karel Zak [Wed, 10 Mar 2010 22:54:11 +0000 (23:54 +0100)]
lib: add mangle.c for mtab (fstab or swaps) encoding

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoswapon: remove " (deleted)" from filenames from /proc/swaps
Karel Zak [Wed, 10 Mar 2010 22:08:26 +0000 (23:08 +0100)]
swapon: remove " (deleted)" from filenames from /proc/swaps

The filenames in /proc/swaps are generated by seq_path() and this
function uses __d_path() from fs/dcache.c. The filename could
generated with " (deleted)" suffix. We need real filenames without
the suffix.

Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=562403
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: add blkid_probe_get_{offset,fd} functions
Karel Zak [Wed, 10 Mar 2010 14:50:45 +0000 (15:50 +0100)]
libblkid: add blkid_probe_get_{offset,fd} functions

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoliblkid: move getsize.c code to lib/
Karel Zak [Wed, 10 Mar 2010 14:41:40 +0000 (15:41 +0100)]
liblkid: move getsize.c code to lib/

.. and cleanup blkdev_get_size() usage in libblkid.

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: reset BLKID_TINY_DEV flag in blkid_probe_set_device
Pascal Terjan [Wed, 10 Mar 2010 10:08:02 +0000 (11:08 +0100)]
libblkid: reset BLKID_TINY_DEV flag in blkid_probe_set_device

Signed-off-by: Pascal Terjan <pterjan@mandriva.com>
14 years agolibblkid: fix display of device size
Karel Zak [Wed, 10 Mar 2010 10:08:01 +0000 (11:08 +0100)]
libblkid: fix display of device size

blkid_loff_t is int64 so use %jd not %zd in debug

Reported-by: Pascal Terjan <pterjan@mandriva.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: more robust minix probing
Karel Zak [Mon, 8 Mar 2010 12:05:09 +0000 (13:05 +0100)]
libblkid: more robust minix probing

Unfortunately, it's still possible to interpret some parts of ext3
filesystem as minix superblock ;-(

So, the most robust is to check for the extN magic string in minix
probing function.

Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=570606
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: cleanup usage of empty topology values
Karel Zak [Wed, 3 Mar 2010 14:01:44 +0000 (15:01 +0100)]
libblkid: cleanup usage of empty topology values

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: support alignment_offset=-1
Karel Zak [Wed, 3 Mar 2010 12:12:02 +0000 (13:12 +0100)]
libblkid: support alignment_offset=-1

Unfortunately, Linux kernel uses "signed int" for alignment_offset and
the offset could be -1 for devices with undefined alignment (if no
compatible sizes and alignments exist for stacked devices).

There is no way how libblkid caller can respond to the value -1, so
we are going to hide this corner case...

TODO: maybe we can export an extra boolean value 'misaligned' rather
      then complete hide this problem. We will see...

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agomount: posix option of vfat is obsolete
Yoshihiro Takahashi [Mon, 1 Mar 2010 10:43:02 +0000 (11:43 +0100)]
mount: posix option of vfat is obsolete

Summary of changes from v2.5.42 to v2.5.43
[PATCH] removes posix option of fat (3/5)
  This removes the posix option of vfat. The current posix options works
  only as an alias of name_check=s.

Signed-off-by: Yoshihiro Takahashi <ytakahashi@miraclelinux.com>
14 years agolscpu: fix cpuid opcode detection
Henne Vogelsang [Mon, 1 Mar 2010 10:35:54 +0000 (11:35 +0100)]
lscpu: fix cpuid opcode detection

Fixes commit c9239f23acdc8b50f8bcbfadf967c6a490fd4693. The author
didn't care for matching constraints when resorting the register
constraints.  The eax register (with the cpuid opcode) is now in
operand 1, not zero anymore.

Signed-off-by: Henne Vogelsang <hvogel@opensuse.org>
14 years agoldattach: prints help to stdout
Karel Zak [Mon, 1 Mar 2010 09:51:12 +0000 (10:51 +0100)]
ldattach: prints help to stdout

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoldattach: add --iflag command line option
Tilman Schmidt [Mon, 1 Mar 2010 09:45:47 +0000 (10:45 +0100)]
ldattach: add --iflag command line option

Add a command line option '-i' / '--iflag' for setting or clearing
input flags on the serial device before attaching the line discipline.

[kzak@redhat.com: - use generic functions for work with iflags table
                  - add list of iflags to usage/help output
                  - move iflags parsing to separate function]

Impact: added functionality
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoldattach: create a generic functions for name=value tables
Karel Zak [Mon, 1 Mar 2010 09:25:55 +0000 (10:25 +0100)]
ldattach: create a generic functions for name=value tables

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: fix 'p' output for sun label
Karel Zak [Fri, 26 Feb 2010 15:06:18 +0000 (16:06 +0100)]
fdisk: fix 'p' output for sun label

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agowipefs: fix license (GPL -> GPLv2+)
Karel Zak [Tue, 23 Feb 2010 13:13:28 +0000 (14:13 +0100)]
wipefs: fix license (GPL -> GPLv2+)

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: swap VTOC values for warning messages
Karel Zak [Fri, 19 Feb 2010 15:11:49 +0000 (16:11 +0100)]
fdisk: swap VTOC values for warning messages

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: improve Sun VTOC
Karel Zak [Fri, 19 Feb 2010 13:54:25 +0000 (14:54 +0100)]
libblkid: improve Sun VTOC

It seems that for example GNU Parted is able to generate Sun VTOC with
empty sanity, version and nparts fields. But there is still useful
info about partition flags in such VTOC.

This change makes libblkid Sun PT parser compatible with Sun PT
parser in Linux kernel.

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoblkid: fix blkid_probe_lookup_value() usage
Karel Zak [Fri, 19 Feb 2010 09:15:11 +0000 (10:15 +0100)]
blkid: fix blkid_probe_lookup_value() usage

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoblkid: encode PART_ENTRY_TYPE
Karel Zak [Thu, 18 Feb 2010 22:04:22 +0000 (23:04 +0100)]
blkid: encode PART_ENTRY_TYPE

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: add PART_ENTRY_{SCHEME,NUMBER}
Karel Zak [Thu, 18 Feb 2010 22:01:38 +0000 (23:01 +0100)]
libblkid: add PART_ENTRY_{SCHEME,NUMBER}

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: add support for partition flags/attributes
Karel Zak [Thu, 18 Feb 2010 21:53:44 +0000 (22:53 +0100)]
libblkid: add support for partition flags/attributes

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: add blkid_partition_set_type()
Karel Zak [Thu, 18 Feb 2010 21:28:41 +0000 (22:28 +0100)]
libblkid: add blkid_partition_set_type()

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agosfdisk: make sure writes make it to disk in write_partitions()
Bryn M. Reeves [Thu, 18 Feb 2010 20:39:22 +0000 (21:39 +0100)]
sfdisk: make sure writes make it to disk in write_partitions()

Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=565946
Signed-off-by: Bryn M. Reeves <bmr@errorists.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoblkid: export ID_PART_ENTRY_* variables for udev
Karel Zak [Thu, 18 Feb 2010 15:46:56 +0000 (16:46 +0100)]
blkid: export ID_PART_ENTRY_* variables for udev

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: add support for PART_ENTRY_* values
Karel Zak [Thu, 18 Feb 2010 15:38:59 +0000 (16:38 +0100)]
libblkid: add support for PART_ENTRY_* values

blkid(8) will be replacement for devkit-disks-part-id, so we have to
be able to found entry in partition table for requested partition.

This functionality is enabled by BLKID_PARTS_ENTRY_DETAILS flag
(see blkid_probe_set_partitions_flags() for more details).

This patch also add a new public function blkid_partlist_devno_to_partition().

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: don't probe for nested PT on tiny disks (<=1.44MiB)
Karel Zak [Thu, 18 Feb 2010 15:19:31 +0000 (16:19 +0100)]
libblkid: don't probe for nested PT on tiny disks (<=1.44MiB)

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: add generic functions for sysfs attributes
Karel Zak [Thu, 18 Feb 2010 10:09:46 +0000 (11:09 +0100)]
libblkid: add generic functions for sysfs attributes

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: fix ZSF detection
Andreas Dilger [Wed, 17 Feb 2010 09:21:27 +0000 (10:21 +0100)]
libblkid: fix ZSF detection

Fix the ZFS device detection by looking at multiple uberblocks to see
if any are present, rather than looking for the ZFS boot block which
is not always present.

There may be up to 128 uberblocks, but the first 4 are not written to
disk on a newly-formatted filesystem so check several of them at
different offsets within the uberblock array.

[kzak@redhat.com: - port e2fsprogs patch to util-linux-ng]

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoswapon: fix swapsize calculation
Karel Zak [Tue, 16 Feb 2010 12:48:09 +0000 (13:48 +0100)]
swapon: fix swapsize calculation

Reported-by: Peter Breitenlohner <peb@mppmu.mpg.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoblkid: report open() errors in low-level probing
Karel Zak [Tue, 16 Feb 2010 08:43:26 +0000 (09:43 +0100)]
blkid: report open() errors in low-level probing

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: don't use 1MiB grain on small devices
Karel Zak [Mon, 15 Feb 2010 15:46:05 +0000 (16:46 +0100)]
fdisk: don't use 1MiB grain on small devices

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agotests: update fdisk tests
Karel Zak [Mon, 15 Feb 2010 15:07:44 +0000 (16:07 +0100)]
tests: update fdisk tests

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: use 1MiB offset and grain always when possible
Karel Zak [Mon, 15 Feb 2010 14:55:22 +0000 (15:55 +0100)]
fdisk: use 1MiB offset and grain always when possible

It would be nice to minimize dependence between the disk layout and
disk topology. We have to follow disk topology for alignment_offset
and huge (> 1MiB) I/O sizes only. For all others disks we can use 1MiB
grain and 1MiB offset.

Reported-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: add -c option (switch off DOS mode)
Karel Zak [Mon, 15 Feb 2010 13:39:30 +0000 (14:39 +0100)]
fdisk: add -c option (switch off DOS mode)

 * add -c to allows to switch off DOS mode from command line

 * recommend sectors (command 'u' or option -u)

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: fix ALIGN_UP
Karel Zak [Mon, 15 Feb 2010 13:06:56 +0000 (14:06 +0100)]
fdisk: fix ALIGN_UP

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: fallback for topology values
Karel Zak [Mon, 15 Feb 2010 12:29:04 +0000 (13:29 +0100)]
fdisk: fallback for topology values

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: cleanup help, add -h option
Karel Zak [Mon, 15 Feb 2010 09:08:03 +0000 (10:08 +0100)]
fdisk: cleanup help, add -h option

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agotests: update fdisk tests
Karel Zak [Fri, 12 Feb 2010 21:10:52 +0000 (22:10 +0100)]
tests: update fdisk tests

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: use more elegant way to count and check alignment
Karel Zak [Fri, 12 Feb 2010 20:43:03 +0000 (21:43 +0100)]
fdisk: use more elegant way to count and check alignment

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoinclude: add min/max macros
Karel Zak [Fri, 12 Feb 2010 20:42:46 +0000 (21:42 +0100)]
include: add min/max macros

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agomount: advise users to use "modprobe", not "insmod"
Karel Zak [Fri, 12 Feb 2010 18:58:45 +0000 (19:58 +0100)]
mount: advise users to use "modprobe", not "insmod"

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=562394
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agocfdisk: set '[New]' as default item on menu for non allocated space instead of '...
Francesco Cosoleto [Fri, 12 Feb 2010 17:51:29 +0000 (18:51 +0100)]
cfdisk: set '[New]' as default item on menu for non allocated space instead of '[Help]'.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
14 years agobuild-sys: add missing tests for libuuid and libblkid
Karel Zak [Fri, 12 Feb 2010 11:43:07 +0000 (12:43 +0100)]
build-sys: add missing tests for libuuid and libblkid

$ make checkconfig
misc-utils/blkid.c : HAVE_TERMIO_H
misc-utils/blkid.c : HAVE_TERMIOS_H
shlibs/blkid/src/getsize.c : HAVE_FSTAT64
shlibs/blkid/src/llseek.c : HAVE_LLSEEK_PROTOTYPE
shlibs/blkid/src/llseek.c : HAVE_LSEEK64_PROTOTYPE
shlibs/uuid/src/gen_uuid.c : HAVE_SA_LEN*/
shlibs/uuid/src/gen_uuid.c : HAVE_SYS_SOCKET_H
shlibs/uuid/src/gen_uuid.c : HAVE_SYS_SYSCALL_H

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agoblkid: fix #ifdef HAVE_TERMIO[S]_H
Karel Zak [Fri, 12 Feb 2010 09:32:34 +0000 (10:32 +0100)]
blkid: fix #ifdef HAVE_TERMIO[S]_H

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agobuild-sys: remove duplicate #includes
Karel Zak [Fri, 12 Feb 2010 09:21:05 +0000 (10:21 +0100)]
build-sys: remove duplicate #includes

$ make checkincludes
fsck/fsck.c: errno.h is included more than once.
lib/canonicalize.c: string.h is included more than once.
shlibs/blkid/src/blkidP.h: stdio.h is included more than once.
shlibs/blkid/src/devname.c: string.h is included more than once.
shlibs/blkid/src/devno.c: string.h is included more than once.

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agodocs: update TODO file
Karel Zak [Thu, 11 Feb 2010 16:25:06 +0000 (17:25 +0100)]
docs: update TODO file

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agocal: fix first day of the week calculation on BE systems
Karel Zak [Thu, 11 Feb 2010 15:29:05 +0000 (16:29 +0100)]
cal: fix first day of the week calculation on BE systems

This reverts commit dcb54fafb128ab41772ae217afc6a7612e2cc446,
"cal: remove gcc-ism from nl_langinfo() call".

The code:

int wfd = (int)(intptr_t) nl_langinfo(_NL_TIME_WEEK_1STDAY);

does not work on big-endian machines. The original solution based on
union is better.

Note that the "type punning" is not gcc-ism any more, it's allowed
by C99 (6.5.2.3).

Reported-by: Joseph Jezak <josejx@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agocfdisk: set '[Quit]' as default menu item on first run instead of '[Bootable]'.
Francesco Cosoleto [Wed, 10 Feb 2010 11:42:26 +0000 (12:42 +0100)]
cfdisk: set '[Quit]' as default menu item on first run instead of '[Bootable]'.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
14 years agomount: warn users that mtab is read-only
Karel Zak [Thu, 11 Feb 2010 12:54:06 +0000 (13:54 +0100)]
mount: warn users that mtab is read-only

In repair mode the root filesystem is read-only and mtab file is not
up to date.

Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=427183
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agotests: fix and update old fdisk tests
Karel Zak [Tue, 9 Feb 2010 15:24:51 +0000 (16:24 +0100)]
tests: fix and update old fdisk tests

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agotests: add fdisk alignment tests
Karel Zak [Tue, 9 Feb 2010 14:47:32 +0000 (15:47 +0100)]
tests: add fdisk alignment tests

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: cleanup warnings
Karel Zak [Thu, 4 Feb 2010 14:02:16 +0000 (15:02 +0100)]
fdisk: cleanup warnings

* don't print:

The number of cylinders for this disk is set to 12161.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

  we really don't care about MS-DOS or extremely old LILO.

* inform users that DOS-compatible mode is bad and deprecated thing
  (It's difficult to use 2048 sectors grain or 4KiB sectors or
   alignment_offset in DOS mode where all is based on cylinders...)

* don't check for cylinders boundary in non-DOS mode

* inform about sector and I/O sizes

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: fix default first sector
Karel Zak [Tue, 9 Feb 2010 10:06:42 +0000 (11:06 +0100)]
fdisk: fix default first sector

The previous release 2.17 introduces aligned defaults for the first
and last sectors on the partition. Unfortunately, there is endless
loop when the code looks for first unused aligned sector.

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: cleanup alignment, default to 1MiB offset
Karel Zak [Thu, 4 Feb 2010 12:43:37 +0000 (13:43 +0100)]
fdisk: cleanup alignment, default to 1MiB offset

* add heuristic to detect that the device does not provide
  topology information. We can use topology if:

- alignment_offset is not 0
- or optimal_io_size is not 0
- or minimal_io_size is not power of 2

* default to 1MiB offset for the start of the first partition
  if topology is unknown. This (2048 512-byte sectors)
  is Windows Vista default.

* use optimal_io_size, minimal_io_size or 1MiB as a grain for
  partitions alignment

Note that this all is used when DOS-compatible mode is disabled.

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: fix check_alignment()
Karel Zak [Tue, 9 Feb 2010 09:32:29 +0000 (10:32 +0100)]
fdisk: fix check_alignment()

The old version of check_alignment() does not work with extended
partitions.

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agofdisk: don't check alignment_offset against geometry
Karel Zak [Mon, 8 Feb 2010 16:45:42 +0000 (17:45 +0100)]
fdisk: don't check alignment_offset against geometry

The alignment_offset is compensation for DOS compatible partitioning.

It usually matches with disk geometry (e.g. 63 sectors), but the
offset is also exported from phy.disks to RAIDs there the geometry
don't match with the offset. So.. don't print unnecessary warning.

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: don't return error on empty files
Karel Zak [Thu, 4 Feb 2010 21:19:38 +0000 (22:19 +0100)]
libblkid: don't return error on empty files

Currently, the library does not allow to initialize blkid_probe if the
file (or block device) is empty. The empty file is reported as an
error. That's wrong. The empty file should be interpreted as a file
without any FS or PT. It means that

blkid_do_{probe,safeprobe,fullprobe}()

have to return 1 ("nothing").

Reported-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agodocs: update TODO file
Karel Zak [Thu, 4 Feb 2010 20:47:47 +0000 (21:47 +0100)]
docs: update TODO file

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agowipefs: ignore devices with partition table
Karel Zak [Thu, 4 Feb 2010 20:18:34 +0000 (21:18 +0100)]
wipefs: ignore devices with partition table

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agochrt: add --reset-on-fork
Karel Zak [Tue, 2 Feb 2010 20:24:52 +0000 (21:24 +0100)]
chrt: add --reset-on-fork

This new option allows to set SCHED_RESET_ON_FORK flag for FIFO and RR
policies.

Example:

$ chrt --fifo --reset-on-fork 1 /bin/bash

$ schedutils/chrt --pid $$
pid 31579's current scheduling policy: SCHED_FIFO|SCHED_RESET_ON_FORK
pid 31579's current scheduling priority: 1

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agochrt: add support for SCHED_RESET_ON_FORK
Adrian Knoth [Tue, 2 Feb 2010 16:18:29 +0000 (17:18 +0100)]
chrt: add support for SCHED_RESET_ON_FORK

From 9262c9832134f8a33ac2ea2854dc6d20acc712d1 Mon Sep 17 00:00:00 2001
From: Adrian Knoth <adi@drcomp.erfurt.thur.de>
Date: Tue, 2 Feb 2010 16:57:23 +0100
Subject: [PATCH] Add support for SCHED_RESET_ON_FORK to chrt

SCHED_RESET_ON_FORK has been added in 2.6.31. If a thread has this flag
set, chrt reports "unknown" policy, which is confusing.

The patch adds support for this new flag. It will (can) only be applied
to SCHED_FIFO or SCHED_RR, so there's no need to catch the other
scheduling policies.

Signed-off-by: Adrian Knoth <adi@drcomp.erfurt.thur.de>
14 years agolibblkid: minor fixes in befs.c
Karel Zak [Tue, 2 Feb 2010 15:01:28 +0000 (16:01 +0100)]
libblkid: minor fixes in befs.c

The library does not reset the probing result (e.g. LABEL, VERSION)
when the probing function failed (return value != 0). We have to be
absolutely sure that the FS has been properly detected before we set
LABEL or VERSION or so.

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agotests: add BeFS test image
Karel Zak [Tue, 2 Feb 2010 14:49:35 +0000 (15:49 +0100)]
tests: add BeFS test image

Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: Add probing function for BeFS
Jeroen Oortwijn [Fri, 29 Jan 2010 22:20:49 +0000 (23:20 +0100)]
libblkid: Add probing function for BeFS

Add probing function for the Be File System to libblkid. It sets LABEL,
VERSION and UUID. But UUID is only set if the be:volume_id attribute is
found in the small_data area of the i-node of the root directory.

[kzak@redhat.com: - add .minsz = 1024*1440 to avoid BeFS probing on
                    very small devices]

Signed-off-by: Jeroen Oortwijn <oortwijn@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
14 years agolibblkid: Add initial support for BeFS detection
Jeroen Oortwijn [Thu, 14 Jan 2010 18:01:36 +0000 (19:01 +0100)]
libblkid: Add initial support for BeFS detection

Add initial support for detection of the Be File System
<http://en.wikipedia.org/wiki/Be_File_System> to libblkid.

Signed-off-by: Jeroen Oortwijn <oortwijn@gmail.com>