Commit Graph

7543 Commits

Author SHA1 Message Date
Karel Zak 82ebc7dea7 libfdisk: improve conversion to string
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 8c0a7f9136 libfdisk: add struct fdisk_partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 7358229637 lib/tt: add reduce term width functionality
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak b839bd4fa1 lib/tt: add TT_FL_MAX to fill screen
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 575a1de03a lib/tt: add tb_get_nlines()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 0cd73f41e8 lib/tt: don't hardcode stdout as output
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 6941952e8d libfdisk: (gpt) use fdisk_column
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 8152753d58 libfdisk: implement generic functions for FDISK_COL_ stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 21a44c9b84 libfdisk: extend API definition to list info about partitions
This change adds a struct fdisk_column to provide generic description
for information about partitions. The struct is used for tt tables as
well as lists of possible columns for specified label driver.

We use the same concept in all applications linked with tt.c (lsblk,
findmnt, partx, ...) where is possible to dynamically change columns,
order of the columns etc. Now it will be possible to do the same with
fdisk.

And it's also possible to use FDISK_COL_* Ids to address data, for
example:

   fdisk_partition_get_data(cxt, FDISK_COL_SIZE, 1, &data);

returns a string with human readable size (<num>{MGT}) of the second
partition.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 11fd5edb9d include/tt: add tt_is_empty()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:11 +01:00
Karel Zak 873e7a59d7 ipcs: fix size_t overflow
Addresses: https://github.com/karelzak/util-linux/issues/51
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:22:07 +01:00
Karel Zak 329b0ee753 lib/colors: support <name>.enable too
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 10:38:15 +01:00
Karel Zak 60ec67ff4e lib/colors: add info to man pages, add terminal-colors.d.5
Co-Author: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 10:05:32 +01:00
Ondrej Oprala d0c9ddc3cc lib/colors: check for /etc/terminal-colors.d/[util].disable
[kzak@redhat.com: - move paths to pathnames.h,
                  - use static path buffer]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 09:38:09 +01:00
Sami Kerola 2f79154639 tests: check commands needed for running a test exist
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-07 11:52:57 +01:00
Sami Kerola 22c3c4f936 tools: make config-gen to require build target argument
When argument is not supplied help user by telling what arguments can be
used.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-03-07 11:45:54 +01:00
Karel Zak 5a2fd9329e lsblk: add PARTFLAGS column
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-07 11:14:46 +01:00
Karel Zak df019e9be7 libmount: add statfs_magic.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-06 13:09:16 +01:00
Karel Zak 65acdc8734 build-sys: remove deprecated-mount/
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-05 13:19:19 +01:00
Chris MacGregor 4a44a54b3c hwclock: fix possible hang and other set_hardware_clock_exact() issues
In sys-utils/hwclock.c, set_hardware_clock_exact() has some problems when the
process gets pre-empted (for more than 100ms) before reaching the time for
which it waits:

1. The "continue" statement causes execution to skip the final tdiff
assignment at the end of the do...while loop, leading to the while condition
using the wrong value of tdiff, and thus always exiting the loop once
newhwtime != sethwtime (e.g., after 1 second).  This masks bug # 2, below.

2. The previously-existing bug is that because it starts over waiting for the
desired time whenever two successive calls to gettimeofday() return values >
100ms apart, the loop will never terminate unless the process holds the CPU
(without losing it for more than 100ms) for at least 500ms.  This can happen
on a heavily loaded machine or on a virtual machine (or on a heavily loaded
virtual machine).  This has been observed to occur, preventing a machine from
completing the shutdown or reboot process due to a "hwclock --systohc" call in
a shutdown script.

The new implementation presented in this patch takes a somewhat different
approach, intended to accomplish the same goals:

It computes the desired target system time (at which the requested hardware
clock time will be applied to the hardware clock), and waits for that time to
arrive.  If it misses the time (such as due to being pre-empted for too long),
it recalculates the target time, and increases the tolerance (how late it can
be relative to the target time, and still be "close enough".  Thus, if all is
well, the time will be set *very* precisely.  On a machine where the hwclock
process is repeatedly pre-empted, it will set the time as precisely as is
possible under the conditions present on that particular machine.  In any
case, it will always terminate eventually (and pretty quickly); it will never
hang forever.

[kzak@redhat.com: - tiny coding style changes]

Signed-off-by: Chris MacGregor <chrismacgregor@google.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-05 12:42:00 +01:00
Bernhard Voelker 260412b19f libmount: define BTRFS_TEST_MAGIC if missing
* libmount/src/utils.c (BTRFS_TEST_MAGIC): Conditionally add define
which is used since commit v2.24-243-g6a52473.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2014-03-05 12:14:54 +01:00
Karel Zak 9a7d05fedb chcpu: cleanup stdout/stderr usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-05 11:23:16 +01:00
Karel Zak 48fc00c1c7 chcpu: cleanup return codes
The code currently always return EXIT_SUCCESS, that's strange. It
seems better to return 0 on success, 1 on complete failure and 64 on
partial success.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-05 11:06:59 +01:00
Karel Zak dbf7043ea1 build-sys: don't connect _DEPENDENCIES and _LIBADD
The _DEPENDENCIES has to be used for dependencies on another in-tree
files, but _LIBADD is to specify additional libs (including external
libs).

Reported-by: oleid <notifications@github.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-05 10:20:10 +01:00
Karel Zak 013efbfad4 Merge branch 'master' of https://github.com/rudimeier/util-linux
* 'master' of https://github.com/rudimeier/util-linux:
  travis-ci: import travis yaml controller
2014-03-05 09:25:43 +01:00
Benno Schulenberg 01cc21f5b6 docs: fix two command representations in the man page of more
The previous-file command is not :P but :p, and the back-to-where
command is not an acute accent but an apostrophe.  Also condense
some of the descriptions and remove some useless comments.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-03-04 13:52:14 +01:00
Sami Kerola 4b670c01df logger: allow user to send structured journald messages
This feature is hopefully mostly used to give MESSAGE_ID labels for
messages coming from scripts, making search of messages easy.  The
logger(1) manual page update should give enough information how to use
--journald option.

[kzak@redhat.com: - add missing #ifdefs
                  - use xalloc.h]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-04 13:44:21 +01:00
Ondrej Oprala 3bf7ede997 hexdump: color unit may now be longer than the corresponding format unit
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-03-04 12:48:59 +01:00
Stewart Smith 6f7234f68a lscpu: read_hypervisor_dmi: only fallback to memory scan on x86/x86_64
As the comment in the code says, this method is really only valid
on x86 and x86_64, so add a #ifdef for those architectures around
that code block.

This was causing "Program lscpu tried to access /dev/mem between f0000->100000."
warnings on some ppc64 machines.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-03-04 11:47:27 +01:00
Stewart Smith c0cf4ae9b0 lscpu: don't assume filesystem supports d_type when searching for NUMA nodes
Not all file systems support the d_type field and simply checking for
d_type == DT_DIR in is_node_dirent would cause the test suite to fail
if run on (for example) XFS.

The simple fix is to check for DT_DIR or DT_UNKNOWN in is_node_dirent.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-03-04 11:47:23 +01:00
Karel Zak 7ad19a3feb switch_root: make dirent d_type usage more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-04 11:45:44 +01:00
Karel Zak ea7f012b7c lib/sysfs: make dirent d_type usage more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-04 11:30:03 +01:00
Karel Zak a7c60528f9 partx: make dirent d_type usage more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-04 11:27:46 +01:00
Karel Zak 870c616d60 libmount: cgroup magic already defined
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-03 12:10:08 +01:00
Karel Zak 6a52473ecd umount: don't use mountinfo if possible
The umount(8) always parses /proc/self/mountinfo to get fstype and to
merge kernel mount options with userspace mount options from
/run/mount/utab. This behavior is overkill in many cases and it's
pretty expensive as kernel has to always compose *whole* mountinfo.
This performance disadvantage is visible for crazy use-cases with huge
number of mountpoints and frequently called umount(8).

It seems that we can bypass /proc/self/mountinfo by statfs() to get
filesystem type (statfs.f_type magic) and analyze /run/mount/utab
before we parse mountinfo.

This optimization is not used when:

 * umount(8) executed by non-root (as user= in utab is expected)
 * umount --lazy / --force (target is probably unreachable NFS, then
   use statfs() is pretty bad idea)
 * target is not a directory (e.g. umount /dev/sda1)
 * there is (deprecated) writeable mtab

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-03 10:36:15 +01:00
Karel Zak 53e227cc8d docs: refresh TODO
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-27 13:34:36 +01:00
Ruediger Meier dac87e44a2 travis-ci: import travis yaml controller
.travis.yml is used for automatic builds on travis build farm
(https://travis-ci.org/) if the travis service hook is enabled for the
repo on github.

This inital yaml controller will run 2 different compilers (gcc, clang).
The test suite currently fails, that's why we don't abort yet.
2014-02-26 18:04:13 +01:00
Sami Kerola 5fdd35070c more: fix double free crash
Commit b9579f1f44 moved fclose() to
checkf(), but missed removing file closure in magic().  Ironically the
cause of regression is in previous commit message.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-02-21 13:45:32 +01:00
Karel Zak 4368e3e687 script: clean up files usage
* don't initialize timingfd (to stderr) when -t not specified

 * care about timingfd dooutput() rather in main()

 * make timingdf gloval like fscript FILE

 * close all in done()

 * close irrelevant things in subshell and input processes

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-21 13:39:14 +01:00
Jesper Dahl Nyerup 5d0ce5e84f script: Also flush writes to timing file.
If both -f and -t are given, flush the timing fd on each write, similar
to the behavior on the script fd. This allows playback of still-running
sessions, and reduces the risk of ending up with empty timing files when
script(1) exits abnormally.

Signed-off-by: Jesper Dahl Nyerup <nyerup@one.com>
2014-02-21 13:16:20 +01:00
Karel Zak 2b6759df0c findmnt: add --bytes to print sizes in bytes
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-21 12:27:58 +01:00
Karel Zak 4459245fa3 mkfs: mark this wrapper as DEPRECATED
Theodore Ts'o:

 I'll add that I've never been convinced that the mkfs front end is all
 that useful.  It's probably better for people to explicitly run
 /sbin/mkfs.xfs, /sbin/mkfs.ext4, etc.., so you don't have to worry
 about which options get passed down to the file system specific mkfs
 program, and which ones are interpreted by /sbin/mkfs --- and I don't
 believe /sbin/mkfs adds enough (err, any?) value that using
 "/sbin/mkfs -t xxx" vs "/sbin/mkfs.xxx" makes any sense whatsoever.

... and I absolutely agree.

Reported-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-21 12:04:18 +01:00
Benno Schulenberg 4c5a6f3d39 more: improve formatting and wording of man page and help text
Also, slice up the usage text for ease of translation.

Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-02-21 11:57:05 +01:00
Karel Zak 6c373810f5 libmount: FS id and parent ID could be zero
It seems that linux 3.14 is able to produce things like:

  19 0 8:3 / / rw,relatime - ext4 /dev/sda3 rw,data=ordered
     ^

Reported-by: Mantas Mikulėnas <grawity@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-20 16:59:11 +01:00
Karel Zak 4b01c5a142 fallocate: fix missing sentinel for is_nul()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-19 14:26:52 +01:00
Karel Zak 53e6896ab8 libblkid: add extra checks to XFS prober
The current code rely on XFS magic string only. It seems too fragile.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-19 13:27:56 +01:00
Karel Zak c4172cc3bb fallocate: code optimalizations
Based on Pádraig Brady review:

 * use is_nul() from coreutils rather then memcmp()

 * always call skip_hole() (SEEK_DATA)

 * fix possible overflows

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-19 10:48:16 +01:00
Karel Zak c12eff4ce0 fallocate: use POSIX_FADV_DONTNEED to discard cached data
The patch discard cached data in 1MiB (or bigger) steps.

Thanks to Pádraig Brady.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-18 13:01:52 +01:00
Karel Zak db5f00bc88 fallocate: use SEEK_DATA on already sparse files
It's more efficient to skip already known holes by SEEK_DATA (seek to
the next area with data).

Thanks to Pádraig Brady.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-18 11:38:47 +01:00
Karel Zak 9b1b6ed187 fallocate: fix man page synopsis
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-17 15:34:08 +01:00