Commit Graph

1913 Commits

Author SHA1 Message Date
Karel Zak 86af3b700a swaplabel: fix typo in man page
Reported-by: Marcos Felipe Rasia de Mello <marcosfrm@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-07 16:37:59 +02:00
Karel Zak dad504d97c libblkid: add ultrix PT support
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-07 11:31:37 +02:00
Karel Zak 9f4664ee40 libblkid: fix 'partno' usage
Linux kernel ignores empty partitions, but partition number is always
allocated for the partition. (This rule is used for primary partitions
only.)

For example:

  part 1.  size=12345
  part 2.  size=0
  part 3.  size=24567

the final list of partitions:

  sda1 sda3

'sda2' is not defined and partno=2 is not used for any other
partitions.

The libblkid library has to be compatible with this rule.

Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-07 09:39:05 +02:00
Karel Zak 4720bb19c1 libblkid: fix blkid_partlist_devno_to_partition() for extended partitions
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-06 17:57:49 +02:00
Jason Borden 4dddc2d4aa swaplabel: new command
Print or change the label / UUID of a swap area.

[kzak@redhat.com: - code refactoring
                  - add long options
                  - clean up Makefile.am]

Signed-off-by: Jason Borden <jborden@bluehost.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-02 16:16:59 +02:00
Karel Zak 1f7a33f135 mkswap: zap bootbits on regular files
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-02 12:49:07 +02:00
Karel Zak 865deca224 swapon: move DELETED_SUFFIX to include/pathnames.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-02 11:43:36 +02:00
Karel Zak 7771431278 mkswap: move write_all() to include/writeall.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-01 16:17:17 +02:00
M.S.Colclough 55113b15af libblkid: avoid probing CDs for RAID
RAID probing of CD/DVD can yield errors because of well-known problem
in reading the end of the disk with some disk/drive combinations.
Borrow CD detection method from udev and skip the RAID tests for
these devices.

[kzak@redhat.com: - check for linux/cdrom.h in ./configure
                  - add #ifdef around the ioctl call
                  - call the ioctl for block devices only]

Signed-off-by: Mark Colclough <m.s.colclough@bham.ac.uk>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-31 18:12:47 +02:00
Francesco Cosoleto eaa7716fae blockdev: reduce usage text width
Use spaces in usage text instead of tabs and reduce the distance between
option names and descriptions.

This helps to minimize problems due to limited number of columns and
translated texts which take up more space than English.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2010-03-31 17:27:09 +02:00
Jon Ringle 56054a79fa fdisk: replace bzero with memset
Work on this was done in commit c0f19ccff7,
however a couple of bzero call sites were missed

Signed-off-by: Jon Ringle <jon@ringle.org>
2010-03-31 17:23:32 +02:00
Karel Zak e349c4f84c docs: update tests/README
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-31 17:19:13 +02:00
Yann Droneaud a609340ed2 tests: added tests against strtosize
- test empty string, white spaces
- test hexadecimal

Signed-off-by: Yann Droneaud <yann@droneaud.fr>
2010-03-31 17:15:01 +02:00
Yann Droneaud b832c2fe34 build-sys: improved check for fallocate()
With glibc 2.10 on a 32bits system, fallocate64() function is not
exported. This a problem, since _FILE_OFFSET_BITS is set to 64 and
fallocate() is redirected to fallocate64().
Sadly, AC_CHECK_FUNC() doesn't catch such problem, since it's overriding
the function prototype.

See this for references:
http://sources.redhat.com/ml/libc-hacker/2009-05/msg00003.html

Signed-off-by: Yann Droneaud <yann@droneaud.fr>
2010-03-31 17:04:37 +02:00
Yann Droneaud 08b825dbea tests: use POSIX locale
Since not everyone have en_US.UTF-8 locale, default to POSIX locale.
This changes default sort order, so some expected results were updated.

Signed-off-by: Yann Droneaud <yann@droneaud.fr>
2010-03-31 17:02:28 +02:00
Karel Zak c86dda7b36 partx: fix infinite loop
On Wed, Mar 24, 2010 at 04:39:35PM -0400, Phillip Susi wrote:
> I noticed that running partx -d /dev/sda hangs so I looked into it
> and it seems that it keeps trying to delete partitions forever.

Reported-By: Phillip Susi <psusi@cfl.rr.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-31 16:38:51 +02:00
Phillip Susi d6d9cc6ea1 partx: do not add nonexistent partitions
This simple patch fixes partx -a to not add nonexistent zero length
partitions for unused primary partition slots to to the kernel. This
makes partx conform to the usual kernel behavior.

Signed-off-by: Phillip Susi <psusi@cfl.rr.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-31 15:52:08 +02:00
Yann Droneaud 11ba4182e6 mkswap: fixed strtoll() usage
- catch empty string
- check against LLONG_MAX and LLONG_MIN instead of ULLONG_MAX and 0

Signed-off-by: Yann Droneaud <yann@droneaud.fr>
2010-03-30 20:15:24 +02:00
Karel Zak 588c2685f4 mount: support suffixes for offset= and sizelimit=
Note that the offset= and sizelimit= values in /etc/mtab are
always in the final format -- it means without suffix).

Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-30 16:15:44 +02:00
Karel Zak 5d6c8028da mount: more robust offset= and sizelimit= parsing
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-30 15:11:06 +02:00
Karel Zak ca1e1363e7 losetup: support suffixes and hex numbers for --offset and --sizelimit
Reported-By: Liu Aleaxander <aleaxander@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-30 15:09:41 +02:00
Karel Zak 3b6b039ae8 fallocate: support suffixes for --offset and --lenght
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-30 14:45:37 +02:00
Karel Zak 20543e618a mkswap: more robust strtoull() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-30 14:45:37 +02:00
Karel Zak 69cc2ec061 wipefs: support suffixes for --offset
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-30 14:45:29 +02:00
Karel Zak 8ab912cfa6 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>
2010-03-30 14:42:42 +02:00
Karel Zak cf8de26afe 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>
2010-03-30 13:51:58 +02:00
Timo Juhani Lindfors 2e5627fa03 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>
2010-03-29 10:30:01 +02:00
Karel Zak 8ab43e6a67 blkid: cleanup man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-23 14:24:02 +01:00
Karel Zak c9744f0b2f docs: update TODO file
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-23 14:12:35 +01:00
Karel Zak 4f946f530c 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>
2010-03-23 14:06:54 +01:00
Karel Zak 962496d401 blkid: cleanup -u <list> parsing
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-22 15:16:01 +01:00
Karel Zak 7f152745c3 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>
2010-03-19 15:56:27 +01:00
Karel Zak e981b2887f docs: update TODO file
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-19 15:18:42 +01:00
Karel Zak 6c2f2b9d62 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>
2010-03-17 14:49:14 +01:00
Karel Zak abbd79ac35 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>
2010-03-16 17:31:39 +01:00
Pádraig Brady b8d22034f1 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>
2010-03-16 15:29:01 +01:00
Karel Zak 70502c5246 lib: add #ifndef around min() max() macros
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-16 15:24:04 +01:00
Pádraig Brady 104b92f848 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>
2010-03-16 15:16:11 +01:00
Karel Zak 03e062e593 docs: update TODO file
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-16 14:52:10 +01:00
Jim Meyering 1675ed7819 lib: avoid compilation failure on rawhide
* lib/blkdev.c: Include <sys/stat.h>, for use of S_ISREG.
2010-03-16 14:31:23 +01:00
Karel Zak e580266914 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>
2010-03-15 17:10:35 +01:00
Karel Zak c47381d1b3 mount: more explicitly explain fstab usage in mount.8
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-15 14:36:22 +01:00
Karel Zak c6c98f93f5 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>
2010-03-15 13:46:43 +01:00
Karel Zak f5b1bab190 wipefs: cleanup usage() and man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-15 13:45:03 +01:00
Karel Zak af6b2e6574 tests: fix whitespaces
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-14 23:18:17 +01:00
Pierre Hauweele 4880a6f1ed ionice: fix typo
Signed-off-by: Pierre Hauweele <antegallya@gmail.com>
2010-03-14 22:58:56 +01:00
Colin Watson 046959cca1 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>
2010-03-14 22:45:40 +01:00
Karel Zak 594c3d1ba4 libblkid: remove "0x" prefix from DRBD UUID
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-11 15:52:54 +01:00
Andreas Dilger a1fbeb3df3 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>
2010-03-11 15:19:44 +01:00
Jeroen Oortwijn af109b063a 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>
2010-03-11 14:34:00 +01:00