Commit Graph

4781 Commits

Author SHA1 Message Date
Petr Uzel e12c9866b5 include: rename writeall.h to all-io.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:27 +02:00
Dave Reisner ea178007eb lib/mangle: check for end of string on every iteration
Checking for the null byte at the end of the string only conditionally
leads to segfaults, evidenced by mount helpers crashing on writes to
/run/mount/utab. Simply check for the null on each iteration, and append
a null byte to the mangled string before breaking.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-05-15 11:32:24 +02:00
Petr Uzel 5821dbe328 rev: mention tac(1) in 'SEE ALSO' man page section
Cc: James R. Van Zandt <jrv@debian.org>
From: James R. Van Zandt <jrv@debian.org>
Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=568709
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:19:53 +02:00
Petr Uzel dceb1f220c mkswap: improve diagnostics message if the device is mounted
Currently, attempt to create swap on mounted partition results
with "/dev/sdXy: Device or resource busy" message being printed.
Change this to explicitly telling the user that the device is mounted.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:19:53 +02:00
Petr Uzel 95e1d8f3ba mkswap: allow creating swap on /dev/hd[ab]
Currently, mkswap does not allow swap to be created on /dev/hda and
/dev/hdb. There is no reason why /dev/hda and /dev/hdb should be treated
differently.

Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=491021
Cc: Russell Coker <russell@coker.com.au>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:19:53 +02:00
Petr Uzel def478cf72 mkswap: use is_mounted() instead of check_mount()
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:19:52 +02:00
Petr Uzel 68eebd5354 lsblk: improve man page wording
Cc: Regid Ichira <regid23@yahoo.com>
From: Regid Ichira <regid23@yahoo.com>
Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672702
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:19:44 +02:00
Karel Zak 5dd9472117 tests: update fdisk test
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-10 11:58:32 +02:00
Petr Uzel c544aa2c25 libuuid: avoid double open and leaking fd (reworked)
This reverts commit 6126f7a53c
and fixes the double open and leaking descriptor in a different way,
that is by using newly introduced function 'have_random_source()'
to check whether good random source is available while deciding
which uuid type to generate (random/time).

This is better than calling random_get_fd() twice, passing the file
descriptor down the stack and reusing it in next call to
random_get_fd().

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-10 11:43:49 +02:00
Davidlohr Bueso fbf9034e48 lslocks: fix bracket indentation
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-05-10 11:41:15 +02:00
Davidlohr Bueso 50f6100a96 fdisk: sgi: abort on HDIO_GETGEO failure
When the HDIO_GETGEO ioctl fails on non IRIX/MIPS platforms (ie: inappropriate
ioctl for device) the variables that describe the geometry are compromissed.
One clear example is a division by 0 bug because the cylinder size is 0 is
verify_sgi():

$> fdisk sgi.img
Welcome to fdisk (util-linux 2.21.392-4b1c).

...

Command (m for help): x

Expert command (m for help): g
Building a new SGI disklabel.
Partition 11 of type SGI volume and of size 7.9 MiB is set
Floating point exception

Fix this by simply exiting the program instead of leaving it in a vulnerable
state.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-10 11:40:21 +02:00
Davidlohr Bueso 8335c780ee fdisk: remove unused function declaration
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-05-10 11:38:14 +02:00
Davidlohr Bueso 0dc13a3863 fdisk: create DOS specific write table function
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-05-10 11:35:42 +02:00
Davidlohr Bueso 9dea2923c8 fdisk: move DOS new/add partition code
Since this is DOS specific logic, it belongs in its own label file.
Additionally, a dos_new_partition() function is created that asks the user for
partition type and then calls the actual dos_add_partition().

This patch passed fdisk regression tests, builds without problems and it was
locally tested against adding and removing DOS partitions.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-05-10 11:34:43 +02:00
Davidlohr Bueso a2a7d18e62 fdisk: remove unused hsc2sector macro
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-05-10 11:33:12 +02:00
Davidlohr Bueso 44d2fc8198 fdisk: fix segfault on bsd label
Commit 8db8295d82 added a regression that causes the program to crash when
touching the partition structure (pte) for BSD/OSF labels. Since DOS has its own initialization function,
allow BSD labels to use it as well.

Steps to reproduce:

$> fdisk bsd.img (obtained from blkid regression test files)
Command (m for help): p
...
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Segmentation fault

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-05-10 11:32:04 +02:00
Karel Zak 4b1cf29d23 uuidd: remove unnecessary variables
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-04 16:20:37 +02:00
Petr Uzel 6126f7a53c libuuid: avoid double open and leaking descriptor
We are opening /dev/urandom twice in uuid_generate(): first to check if
the file is available and then later __uuid_generate_random() again to
actually get the random data. Moreover, descriptor from the first open
is leaking.

Fix by passign the descriptor down the stack and reusing it there.

References: http://marc.info/?l=util-linux-ng&m=133406051131131&w=2

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:24 +02:00
Petr Uzel 881a0f6b28 uuidd: introduce uuidd_cxt to pass arguments to server loop
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:21 +02:00
Petr Uzel ea4f8845f0 libuuid: don't exec uuidd
Executing the daemon from the shared library is not quite elegant
solution. Drop this functionality and require uuidd (should it be
needed) to be started from the initscript or by socket-activation.

References: http://www.spinics.net/lists/util-linux-ng/msg05967.html

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:18 +02:00
Petr Uzel 1b68c37927 uuidd: add systemd unit files
Add systemd unit files which use the socket activation mechanism
of systemd. The uuidd deamon is started upon first request on the
socket and quits after 1 minute of inactivity.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:16 +02:00
Petr Uzel 7ec85b5b71 libuuid: use EXIT_FAILURE
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:14 +02:00
Petr Uzel cb20279fb0 uuidd: do not drop privileges
libuuid can (for now) spawn uuidd on-demand. To support this scenario,
uuidd should be installed setuid/setgid to have access to
/var/lib/libuuid/clock.txt. Therefore, dropping the privileges is
not functional, so removing this ability.

Moreover, the ability to spawn uuidd on-demand will be removed anyway.

References: http://www.spinics.net/lists/util-linux-ng/msg05934.html

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:11 +02:00
Petr Uzel 18c68d70ee uuidd: print all debugging information to stderr
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:07 +02:00
Petr Uzel bbe289c489 uuidd: implement --socket-activation option
Implement --socket-activation option, which is supposed to be used
with systemd (or equivalent init system) socket activation mechanism.
With this option, the UUID daemon does not create the socket on its own,
but instead expect the connection fd to be provided by the calling
process.

This option is only available if util-linux is configured with
--enable-socket-activation option. With this configure
option, the uuidd is compiled with sd-daemon.c.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:04 +02:00
Petr Uzel 75a94e8b36 uuidd: factor out socket creation into separate function
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:13:46 +02:00
Petr Uzel e1cf3ebed5 uuidd: implement --no-fork option
With this option, uuidd does not daemonize itself but stays
in the foreground.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:13:45 +02:00
Petr Uzel f6f3dc7811 uuidd: use ignore_result helper
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:13:43 +02:00
Petr Uzel 0abfbd9ce6 uuidd: implement --no-pid option
With this option, uuidd does not create the PID file.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:13:40 +02:00
Petr Uzel c453635572 uuidd: factor out pidfile creation into separate function
Introduce create_pidfile() function.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:13:34 +02:00
Petr Uzel fcb09bf211 uuidd: remove useless initialization of cleanup_socket
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:13:28 +02:00
Petr Uzel 2e9b39eff3 uuidd: use UUIDD_OP_GETPID instead of magic number
Make parameters passed to call_daemon() more descriptive:
- use UUIDD_OP_GETPID instead of magic number 0
- call_daemon() takes pointer as a last argument, so pass NULL instead
  of 0

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:13:20 +02:00
Vladimir 'φ-coder/phcoder' Serbinenko a767169feb libblkid: support UFS UUID
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-04 11:49:16 +02:00
Vladimir 'φ-coder/phcoder' Serbinenko fd688b6cf3 libblkid: accept small blocks for NTFS and Reiserfs in blkid
libblkid is restrictive as to what it accepts as valid reiserfs or
valid NTFS.  One can mkfs an NTFS with 256B sectors and it's supported
by ntfs-3g Reiserfs can have 512B blocks and it works both with
mkfs.ntfs and Linux.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-04 11:48:07 +02:00
Karel Zak 5b0289b9cf build-sys: add BUILD_WDCTL, check for linux/watchdog.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-04 11:45:35 +02:00
Karel Zak 013a48910e wdctl: add man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-04 11:04:35 +02:00
Karel Zak 3dd00e0773 wdctl: make timeouts output more parsable
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-04 11:02:47 +02:00
Karel Zak 09f9a393a4 wdctl: rewrite to use lib/tt
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-03 17:29:31 +02:00
Karel Zak 5ef167714e lib/strutils: add string_to_bitmask()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-03 17:28:44 +02:00
Karel Zak 1ea962b208 lsblk: fix /sys/.../ro usage
Reported-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-03 16:24:12 +02:00
Karel Zak 0bda832322 lslock: remove duplicate variable
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-03 16:01:04 +02:00
Karel Zak 4a695b1a8b include/tt: remove obsolete stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-03 15:25:23 +02:00
Sami Kerola 33a0de92e9 wdctl: align with other util-linux commands
* Add watchdog device path to pathnames.h
* Check output stream status at exit.
* Adjust usage() notation to follow howto file.
* Retire numeric return value.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-05-03 15:00:07 +02:00
Karel Zak 96f817fb16 fdisk: fix fdiskdoslabel.c global variables
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-02 14:05:51 +02:00
Davidlohr Bueso e2ee917804 fdisk: isolate dos label logic
DOS specific logic is currently embedded in the heart of fdisk code. This patch
separates DOS label specific code into its own file, just like the rest of the
labels, leaving a more generic fdisk.c file. Most changes are just moving code
from fdisk.c to fdisk.h and fdiskdoslabel.[c/h].

The only logical modification is calling dos_delete_partition() from
read_extended(), instead of the generic delete_partition.  This is ok since
read extended is only called from a DOS context.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-05-02 10:35:57 +02:00
Karel Zak 1f13d6fcd0 Merge branch '2012wk17' of https://github.com/kerolasa/lelux-utiliteetit
* '2012wk17' of https://github.com/kerolasa/lelux-utiliteetit:
  build-sys: determine availability of __fpending()
2012-05-02 09:34:39 +02:00
Davidlohr Bueso 64115eed34 fdisk: remove dummy function
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-05-02 09:33:56 +02:00
Davidlohr Bueso 3457420178 fdisk: rework fatal errors
When the device cannot be opened, there's no point calling fatal() when we can
just use err(3). When any other kind of fatal error occurs it's Ok, in addition
we can also go ahead and close the descriptor before exiting the program as
it's currently leaking.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-05-02 09:33:46 +02:00
Davidlohr Bueso 337643ad0f fdisk: remove listing variable
useless global variable.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-05-02 09:33:32 +02:00
Davidlohr Bueso 9f6c866f65 fdisk: remove stack jumping
This patch eliminates the long/setjmp code. The current logic does not do
anything with stack jumps as it only exits from
print_partition_table_from_option() when a fatal error occurs.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-05-02 09:33:24 +02:00