Commit Graph

1890 Commits

Author SHA1 Message Date
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
Miklos Szeredi 97a3cef4f1 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>
2010-03-11 14:32:36 +01:00
Mike Frysinger 96aad067ca 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>
2010-03-11 10:23:00 +01:00
Karel Zak c686bd6c55 tests: update fdisk tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-11 01:08:45 +01:00
Karel Zak 6f3c7f5cfd mkswap: don't call blkdev_find_size()
.. it's already called by blkdev_get_size().

Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-11 01:08:45 +01:00
Karel Zak abe3923fd9 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>
2010-03-11 01:08:25 +01:00
Karel Zak 530381d2d5 lib: use fstat() as fallback in blkdev_get_size()
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-11 00:59:04 +01:00
Karel Zak d0f2bb89f0 mount: use unmangle/mangle() from lib
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-11 00:27:35 +01:00
Karel Zak bf71ef0797 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>
2010-03-10 23:59:33 +01:00
Karel Zak 21169393e3 lib: add mangle.c for mtab (fstab or swaps) encoding
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-10 23:54:11 +01:00
Karel Zak dac4cc1dd6 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>
2010-03-10 23:08:26 +01:00
Karel Zak 56e961e270 libblkid: add blkid_probe_get_{offset,fd} functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-10 15:50:45 +01:00
Karel Zak 3069624180 liblkid: move getsize.c code to lib/
.. and cleanup blkdev_get_size() usage in libblkid.

Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-10 15:41:40 +01:00
Pascal Terjan 2b923637a4 libblkid: reset BLKID_TINY_DEV flag in blkid_probe_set_device
Signed-off-by: Pascal Terjan <pterjan@mandriva.com>
2010-03-10 11:55:29 +01:00
Karel Zak eb84ba7c05 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>
2010-03-10 11:53:46 +01:00
Karel Zak 74b1659dda 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>
2010-03-08 13:05:09 +01:00
Karel Zak eeaeb7540b libblkid: cleanup usage of empty topology values
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-03 15:01:44 +01:00
Karel Zak 25d1e630f6 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>
2010-03-03 14:00:34 +01:00
Yoshihiro Takahashi 376306795f 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>
2010-03-01 11:43:02 +01:00
Henne Vogelsang bc54770d9e lscpu: fix cpuid opcode detection
Fixes commit c9239f23ac. 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>
2010-03-01 11:35:54 +01:00
Karel Zak b5b28b435e ldattach: prints help to stdout
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-01 10:51:12 +01:00
Tilman Schmidt b091b880f9 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>
2010-03-01 10:45:47 +01:00
Karel Zak 7b549aff71 ldattach: create a generic functions for name=value tables
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-01 10:25:55 +01:00
Karel Zak 4d6cb48808 fdisk: fix 'p' output for sun label
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-26 16:06:18 +01:00