]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
10 years agolibblkid: care about unsafe chars in cache
Karel Zak [Thu, 27 Nov 2014 12:39:35 +0000 (13:39 +0100)] 
libblkid: care about unsafe chars in cache

The high-level libblkid API uses /run/blkid/blkid.tab cache to
store probing results. The cache format is

   <device NAME="value" ...>devname</device>

and unfortunately the cache code does not escape quotation marks:

   # mkfs.ext4 -L 'AAA"BBB'

   # cat /run/blkid/blkid.tab
   ...
   <device ... LABEL="AAA"BBB" ...>/dev/sdb1</device>

such string is later incorrectly parsed and blkid(8) returns
nonsenses. And for use-cases like

   # eval $(blkid -o export /dev/sdb1)

it's also insecure.

Note that mount, udevd and blkid -p are based on low-level libblkid
API, it bypass the cache and directly read data from the devices.

The current udevd upstream does not depend on blkid(8) output at all,
it's directly linked with the library and all unsafe chars are encoded by
\x<hex> notation.

   # mkfs.ext4 -L 'X"`/tmp/foo` "' /dev/sdb1
   # udevadm info --export-db | grep LABEL
   ...
   E: ID_FS_LABEL=X__/tmp/foo___
   E: ID_FS_LABEL_ENC=X\x22\x60\x2ftmp\x2ffoo\x60\x20\x22

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoinclude/carefulputc: encode also ' and $ in fputs_quoted() output
Karel Zak [Thu, 27 Nov 2014 12:36:09 +0000 (13:36 +0100)] 
include/carefulputc: encode also ' and $ in fputs_quoted() output

This change is important for commands linked with libsmartcols (e.g. lsblk(1))
to make it more safe for crazy scenarios like

   eval $(lsblk --fs --pairs /dev/sdb1)

where the command returns NAME="value" from filesystem LABELS (etc.)

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: add API docs
Karel Zak [Wed, 26 Nov 2014 18:13:57 +0000 (19:13 +0100)] 
libfdisk: add API docs

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: rename and move function
Karel Zak [Wed, 26 Nov 2014 16:33:07 +0000 (17:33 +0100)] 
libfdisk: rename and move function

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibsmartcols: fix docs namespace
Karel Zak [Wed, 26 Nov 2014 15:53:48 +0000 (16:53 +0100)] 
libsmartcols: fix docs namespace

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: add fdisk.pc
Karel Zak [Wed, 26 Nov 2014 12:20:16 +0000 (13:20 +0100)] 
build-sys: add fdisk.pc

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: add fdiskP.h to sources
Karel Zak [Wed, 26 Nov 2014 11:51:15 +0000 (12:51 +0100)] 
build-sys: add fdiskP.h to sources

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: create a regular shared libfdisk.so
Karel Zak [Wed, 26 Nov 2014 11:45:24 +0000 (12:45 +0100)] 
build-sys: create a regular shared libfdisk.so

- symbols versioning
- SONAME from configure.ac
- library version to header file
- modify build-sys to compile and install shared lib

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoblkdiscard: fix compiler warning
Karel Zak [Wed, 26 Nov 2014 11:38:53 +0000 (12:38 +0100)] 
blkdiscard: fix compiler warning

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: cleanup in libmount Makemodule
Karel Zak [Wed, 26 Nov 2014 11:14:18 +0000 (12:14 +0100)] 
build-sys: cleanup in libmount Makemodule

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: add comments to header file
Karel Zak [Wed, 26 Nov 2014 10:55:45 +0000 (11:55 +0100)] 
libfdisk: add comments to header file

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: add docs for SGI functions
Karel Zak [Wed, 26 Nov 2014 10:45:00 +0000 (11:45 +0100)] 
libfdisk: add docs for SGI functions

10 years agolibfdisk: add docs for SUN functions
Karel Zak [Wed, 26 Nov 2014 10:34:57 +0000 (11:34 +0100)] 
libfdisk: add docs for SUN functions

10 years agolibfdisk: cleanup fdisk_partition_to_string() comment
Karel Zak [Wed, 26 Nov 2014 10:26:31 +0000 (11:26 +0100)] 
libfdisk: cleanup fdisk_partition_to_string() comment

10 years agolibfdisk: fix typo
Karel Zak [Wed, 26 Nov 2014 10:23:27 +0000 (11:23 +0100)] 
libfdisk: fix typo

10 years agolibfdisk: add docs for iterator
Karel Zak [Wed, 26 Nov 2014 10:21:16 +0000 (11:21 +0100)] 
libfdisk: add docs for iterator

10 years agolibfdisk: add docs for init functions
Karel Zak [Wed, 26 Nov 2014 10:13:11 +0000 (11:13 +0100)] 
libfdisk: add docs for init functions

10 years agolibfdisk: add docs for GPT functions
Karel Zak [Wed, 26 Nov 2014 10:11:19 +0000 (11:11 +0100)] 
libfdisk: add docs for GPT functions

10 years agolibfdisk: add docs for DOS functions
Karel Zak [Wed, 26 Nov 2014 10:00:43 +0000 (11:00 +0100)] 
libfdisk: add docs for DOS functions

10 years agolibfdisk: add docs for BSD functions
Karel Zak [Wed, 26 Nov 2014 09:28:37 +0000 (10:28 +0100)] 
libfdisk: add docs for BSD functions

10 years agolibfdisk: cleanup ask API, add comments
Karel Zak [Tue, 25 Nov 2014 13:36:50 +0000 (14:36 +0100)] 
libfdisk: cleanup ask API, add comments

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: remove flags from fdisk_ask API
Karel Zak [Fri, 21 Nov 2014 14:31:55 +0000 (15:31 +0100)] 
libfdisk: remove flags from fdisk_ask API

We don't use it for anything usable, lets kill this over-engineering.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoldattach: add fallback for N_GSM0710
Karel Zak [Fri, 21 Nov 2014 12:57:14 +0000 (13:57 +0100)] 
ldattach: add fallback for N_GSM0710

Addresses: https://github.com/karelzak/util-linux/issues/133
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolib/colors: use static buffers when parse scheme
Karel Zak [Fri, 21 Nov 2014 11:23:47 +0000 (12:23 +0100)] 
lib/colors: use static buffers when parse scheme

* use static buffers when parse scheme colors
* cleanup deallocation on error in sequence parser

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoagetty: use futimens, check for all in configure.ac
Karel Zak [Fri, 21 Nov 2014 10:38:11 +0000 (11:38 +0100)] 
agetty: use futimens, check for all in configure.ac

It seems better to warn about --reload in ./configure if futimens or
inotify_init1 are missing.

The patch also replaces futimes() with futimens() to make the code
compatible with Uclibc.

Addresses: https://github.com/karelzak/util-linux/issues/133
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: add ref.counting to ask API
Karel Zak [Fri, 21 Nov 2014 10:03:08 +0000 (11:03 +0100)] 
libfdisk: add ref.counting to ask API

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoagetty: fix typo
Karel Zak [Fri, 21 Nov 2014 08:42:23 +0000 (09:42 +0100)] 
agetty: fix typo

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoagetty: keep the current baud before try 9600 on serial lines
Karel Zak [Fri, 21 Nov 2014 08:03:00 +0000 (09:03 +0100)] 
agetty: keep the current baud before try 9600 on serial lines

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoagetty: don't ignore TERM
Karel Zak [Fri, 21 Nov 2014 07:43:14 +0000 (08:43 +0100)] 
agetty: don't ignore TERM

Fix command line parsing to not ignore term setting if no baud
specified, for example:

  /sbin/agetty ttyS0 vt100

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: cleanup library symbol files
Karel Zak [Thu, 20 Nov 2014 13:01:03 +0000 (14:01 +0100)] 
build-sys: cleanup library symbol files

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoibfdisk: (gpt) allow to maximize partition
Karel Zak [Thu, 20 Nov 2014 12:28:41 +0000 (13:28 +0100)] 
ibfdisk: (gpt) allow to maximize partition

enlarge second partition:

# echo ',+' | ./sfdisk -N2 /dev/sdb
...
Disk /dev/sdb: 100 MiB, 104857600 bytes, 204800 sectors

Old situation:
Device     Start   End Sectors Size Type
/dev/sdb1   2048 22527   20480  10M Linux filesystem
/dev/sdb2  22528 43007   20480  10M Linux filesystem

New situation:
Device     Start    End Sectors Size Type
/dev/sdb1   2048  22527   20480  10M Linux filesystem
/dev/sdb2  22528 204766  182239  89M Linux filesystem

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: (dos) allow to maximize partition
Karel Zak [Thu, 20 Nov 2014 12:11:38 +0000 (13:11 +0100)] 
libfdisk: (dos) allow to maximize partition

The struct fdisk_partition has special flag "end_follow_default" to
make the partition large as much as possible. This patch makes this
flag usable for fdisk_set_partition() function.

Command line example (enlarge the first partition):

# echo ',+' | ./sfdisk -N1 /dev/sdb
...
Disk /dev/sdb: 100 MiB, 104857600 bytes, 204800 sectors
...
Old situation:
Device     Boot Start   End Sectors Size Id Type
/dev/sdb1        2048 22527   20480  10M 83 Linux
      ^^^^^
New situation:
Device     Boot Start    End Sectors Size Id Type
/dev/sdb1        2048 204799  202752  99M 83 Linux
      ^^^^^^

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoaggety: always set default serial line speed
Karel Zak [Thu, 20 Nov 2014 09:56:03 +0000 (10:56 +0100)] 
aggety: always set default serial line speed

* makes speeds table usage more robust
* don't call next_speed() for empty speeds table to avoid division by zero
* default to 9600 when port baud unspecified

Addresses: https://github.com/karelzak/util-linux/pull/131
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: fix lock test to use real time to sync
Karel Zak [Wed, 19 Nov 2014 15:50:08 +0000 (16:50 +0100)] 
libmount: fix lock test to use real time to sync

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agologin: ignore SIGXFSZ when write to lastlog
Karel Zak [Wed, 19 Nov 2014 14:45:42 +0000 (15:45 +0100)] 
login: ignore SIGXFSZ when write to lastlog

the lastlog file is huge and on systems with large UIDs, it's so huge that
it generates SIGXFSZ when the FSIZE limit is too small.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1165702
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoblkid: add hint about lsblk to the man page
Karel Zak [Wed, 19 Nov 2014 13:43:38 +0000 (14:43 +0100)] 
blkid: add hint about lsblk to the man page

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolib/colors: fix double free on error path
Andreas Henriksson [Wed, 19 Nov 2014 11:03:35 +0000 (12:03 +0100)] 
lib/colors: fix double free on error path

The error path was a bit unclear on the semantics. The seq argument
would get freed but not the name argument. Then the caller frees
them both when the function returns an error.
This fixes the problem my making the function not touch the arguments
unless we're going to return success. Also improve the description
for this function to make it more obvious what the callers should expect.

Addresses: CID#77487 (on scan.coverity.com for JIghtuse/util-linux)
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
10 years agobuild-sys: move all around clock_gettime() to monotonic.c
Karel Zak [Wed, 19 Nov 2014 10:54:47 +0000 (11:54 +0100)] 
build-sys: move all around clock_gettime() to monotonic.c

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: use CLOCKGETTIME_LIBS
Karel Zak [Wed, 19 Nov 2014 10:23:05 +0000 (11:23 +0100)] 
build-sys: use CLOCKGETTIME_LIBS

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: fix utab entry on remount
Karel Zak [Wed, 19 Nov 2014 10:10:55 +0000 (11:10 +0100)] 
libmount: fix utab entry on remount

mount(8) command does not set ROOT= field to utab entry on remount,
for example:

mount -oremount,_netdev /mnt

Reported-by: Chris Leech <cleech@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: add private mnt_context_get_mtab_for_target()
Karel Zak [Wed, 19 Nov 2014 10:07:40 +0000 (11:07 +0100)] 
libmount: add private mnt_context_get_mtab_for_target()

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: reuse allocated fs in parser
Karel Zak [Wed, 19 Nov 2014 10:07:11 +0000 (11:07 +0100)] 
libmount: reuse allocated fs in parser

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: improve mnt_reset_fs()
Karel Zak [Wed, 19 Nov 2014 10:06:24 +0000 (11:06 +0100)] 
libmount: improve mnt_reset_fs()

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomisc: use monotonic time rater than gettimeofday
Karel Zak [Tue, 18 Nov 2014 13:35:21 +0000 (14:35 +0100)] 
misc: use monotonic time rater than gettimeofday

Based on patch Alexander Samilovskih <alexsamilovskih@gmail.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agouuidd: Fixed a typo in daemon logging message
Nikolay Sivov [Tue, 18 Nov 2014 13:14:47 +0000 (14:14 +0100)] 
uuidd: Fixed a typo in daemon logging message

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
10 years agodocs: Spelling fixes
Ville Skyttä [Sat, 15 Nov 2014 20:41:43 +0000 (22:41 +0200)] 
docs: Spelling fixes

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobash-completion: Invoke actual commands to be completed, not basenames
Ville Skyttä [Sat, 15 Nov 2014 20:36:04 +0000 (22:36 +0200)] 
bash-completion: Invoke actual commands to be completed, not basenames

Addresses partially: http://bugs.debian.org/769462
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
10 years agoldattach: GSM0710 support, add intro modem command
Karel Zak [Tue, 18 Nov 2014 12:48:34 +0000 (13:48 +0100)] 
ldattach: GSM0710 support, add intro modem command

Patch add:
 --intro-command string  : send command to modem
 --pause value           : define delay between intro command and ldattach

Based on patch from Martin Schmid <scm@aps-systems.ch>

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomkswap: remove memory leaks [LeakSanitizer] [valgrind]
Sami Kerola [Tue, 11 Nov 2014 21:34:30 +0000 (21:34 +0000)] 
mkswap: remove memory leaks [LeakSanitizer] [valgrind]

==18922==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x49d12b in __interceptor_malloc (/home/src/util-linux/.libs/lt-mkswap+0x49d12b)
    #1 0x7faf2a5069c9 in __GI___strdup (/usr/lib/libc.so.6+0x819c9)
    #2 0xffff96e7e33 (<unknown module>)

SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s).

And another one that valgrind found.

==6316== 8 bytes in 1 blocks are definitely lost in loss record 1 of 1
==6316==    at 0x4C29F90: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==6316==    by 0x5E3F9C9: strdup (in /usr/lib/libc-2.20.so)
==6316==    by 0x43A25F: size_to_human_string (strutils.c:495)
==6316==    by 0x42B35C: main (mkswap.c:488)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agotests: mark python libmount tests known to fail with AddressSanitizer
Sami Kerola [Sun, 9 Nov 2014 21:54:27 +0000 (21:54 +0000)] 
tests: mark python libmount tests known to fail with AddressSanitizer

The tests fail with an error similar to this.

Traceback (most recent call last):
  File "/home/src/util-linux/libmount/python/test_mount_tab_update.py", line 7, in <module>
    import pylibmount as mnt
ImportError: /home/src/util-linux/.libs/libuuid.so.1: undefined symbol: __asan_option_detect_stack_use_after_return

It might be possible to build ASAN-DSO and set LD_PRELOAD, but this
solution is not officially supported.  See the reference for details.

Reference: https://code.google.com/p/address-sanitizer/wiki/AsanAsDso
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agotests: skip kill -SEGV test when running AddressSanitizer
Sami Kerola [Sun, 9 Nov 2014 21:22:52 +0000 (21:22 +0000)] 
tests: skip kill -SEGV test when running AddressSanitizer

Sending signal indicating invalid memory reference makes AddressSanitizer
to report false positive test failure.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolibmount: fix memory overflow [AddressSanitizer]
Sami Kerola [Sun, 9 Nov 2014 15:26:05 +0000 (15:26 +0000)] 
libmount: fix memory overflow [AddressSanitizer]

==10918==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffd795b680 at pc 0x0000004447c6 bp 0x7fffd795b3e0 sp 0x7fffd795ab78
WRITE of size 129 at 0x7fffd795b680 thread T0
    #0 0x4447c5 in scanf_common(void*, int, bool, char const*, __va_list_tag*) (/home/src/util-linux/.libs/lt-mount+0x4447c5)
    #1 0x445892 in sscanf (/home/src/util-linux/.libs/lt-mount+0x445892)
    #2 0x7fe78709a3d3 in get_filesystems /home/src/util-linux/libmount/src/utils.c:581:7
    #3 0x7fe78709a1ba in mnt_get_filesystems /home/src/util-linux/libmount/src/utils.c:622:7
    #4 0x7fe7870aa78f in do_mount_by_pattern /home/src/util-linux/libmount/src/context_mount.c:833:7
    #5 0x7fe7870a9534 in mnt_context_do_mount /home/src/util-linux/libmount/src/context_mount.c:951:9
    #6 0x7fe7870aab2b in mnt_context_mount /home/src/util-linux/libmount/src/context_mount.c:1051:8
    #7 0x4ba9f5 in main /home/src/util-linux/sys-utils/mount.c:1107:7
    #8 0x7fe785caa03f in __libc_start_main (/usr/lib/libc.so.6+0x2003f)
    #9 0x4b9f9c in _start (/home/src/util-linux/.libs/lt-mount+0x4b9f9c)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: fix memory leak [AddressSanitizer]
Sami Kerola [Sun, 2 Nov 2014 22:26:48 +0000 (22:26 +0000)] 
tests: fix memory leak [AddressSanitizer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agobuild-sys: make scanf_cv_alloc_modifier to work [LeakSanitizer]
Sami Kerola [Sun, 2 Nov 2014 22:06:15 +0000 (22:06 +0000)] 
build-sys: make scanf_cv_alloc_modifier to work [LeakSanitizer]

The tests failed with following message in config.log

ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2 byte(s) in 1 object(s) allocated from:
    #0 0x49a40e in realloc (/home/src/util-linux/conftest+0x49a40e)
    #1 0x7fbe48633e69 in __GI__IO_vfscanf (/usr/lib/libc.so.6+0x56e69)
    #2 0x7fbe48649786 in _IO_vsscanf (/usr/lib/libc.so.6+0x6c786)

which knocked out libmount from build, and commands depending on it.

The reason this change makes sense is that AddressSanitizer seems like a
good addition to set of tools that util-linux package can use, when and
if needed.

Reference: https://code.google.com/p/address-sanitizer/wiki/AddressSanitizer
Reviewed-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolscpu: theoretical buffer overflow
Tobias Stoeckmann [Sun, 26 Oct 2014 17:41:24 +0000 (18:41 +0100)] 
lscpu: theoretical buffer overflow

there is a theoretical buffer overflow possible in the hypervisor
parsing code of lscpu.  It would require a proc entry to return way more
than expected so it's no high priority.  But better be safe than sorry.

At first I thought about switching to fgets but there is another
code file that adds a format specifier.  The diff is less intrusive
that way, too.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: fix partition names on GNU Hurd.
Gabriele Giacone [Tue, 18 Nov 2014 01:13:22 +0000 (02:13 +0100)] 
libfdisk: fix partition names on GNU Hurd.

10 years agolibfdisk: fix get_partition_unused_primary()
Boris Egorov [Fri, 14 Nov 2014 05:27:16 +0000 (11:27 +0600)] 
libfdisk: fix get_partition_unused_primary()

Was:
Mentioned function returns -1 if adding of primary partition is
impossible. Caller treats this value as size_t (res variable) and then
compares it for negative values, totally ignoring errors.

Becomes:
Now function takes address to variable and fills it with partition
number. Caller treats return value as int and use it appropriately.

[kzak@redhat.com: - don't mix return code and partno at all]

Signed-off-by: Boris Egorov <egorov@linux.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofdisk: missing break in switch
Boris Egorov [Wed, 12 Nov 2014 15:49:01 +0000 (21:49 +0600)] 
fdisk: missing break in switch

Signed-off-by: Boris Egorov <egorov@linux.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibblkid: (nilfs) fix typo
Boris Egorov [Wed, 12 Nov 2014 15:49:01 +0000 (21:49 +0600)] 
libblkid: (nilfs) fix typo

Signed-off-by: Boris Egorov <egorov@linux.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agohwclock: improve wording and formatting of man page
Benno Schulenberg [Sun, 9 Nov 2014 19:29:26 +0000 (20:29 +0100)] 
hwclock: improve wording and formatting of man page

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agolibfdisk: (dos) be sure that sorted EBR list is terminated
Karel Zak [Thu, 13 Nov 2014 13:37:05 +0000 (14:37 +0100)] 
libfdisk: (dos) be sure that sorted EBR list is terminated

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: fix table_add_freespace(), add debug messages
Karel Zak [Thu, 13 Nov 2014 13:17:47 +0000 (14:17 +0100)] 
libfdisk: fix table_add_freespace(), add debug messages

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agocfdisk: cleanup menuitem draw functions
Karel Zak [Thu, 13 Nov 2014 11:52:03 +0000 (12:52 +0100)] 
cfdisk: cleanup menuitem draw functions

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agocfdisk: remove [Load] from menu
Karel Zak [Thu, 13 Nov 2014 10:19:58 +0000 (11:19 +0100)] 
cfdisk: remove [Load] from menu

This functionality will be rarely used, so it does not make sense to
waste screen space with this menu item. It's enough to provide this
functionality in "Select label type" dialog (cfdisk --zero and then
'L' command).

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agocfdisk: add support for sfdisk scripts
Karel Zak [Wed, 12 Nov 2014 15:12:39 +0000 (16:12 +0100)] 
cfdisk: add support for sfdisk scripts

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofdisk: add support for sfdisk scripts
Karel Zak [Wed, 12 Nov 2014 10:15:06 +0000 (11:15 +0100)] 
fdisk: add support for sfdisk scripts

New commands 'I' and 'O' allows to read and write sfdisk compatible
scripts by fdisk. It means that you can save your work (partition
table) and later use it (in fdisk, sfdisk or cfdisk) to create a new
partition table.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: fix script parser, add debug messages
Karel Zak [Wed, 12 Nov 2014 09:34:13 +0000 (10:34 +0100)] 
libfdisk: fix script parser, add debug messages

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: (gpt) don't offer first sector before the first partion
Karel Zak [Mon, 10 Nov 2014 13:01:09 +0000 (14:01 +0100)] 
libfdisk: (gpt) don't offer first sector before the first partion

The GPT first usable LBA is usually aligned to grain (1MiB), but for small
(<=4MiB) devices we strictly follow sector sizes.

In this case there is a small space in front of the aligned begin of
the first partition. This useless space should not be offered for the
next partitions.

Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 32768 bytes
Disklabel type: gpt
Disk identifier: 041E2D54-AD0C-4C7E-A50D-363D23058D47

Device    Start          End Size Type
/dev/sdb1    40         2087   1M Linux filesystem

Command (m for help): n
Partition number (2-128, default 2):
First sector (34-8158, default 2088):
                      ^^

first usable LBA is 34, but first aligned (recommended) LBA is 40, we
use it for the first partition. All this is correct, but the space
before the first partition should be ignored. Fixed version:

        Command (m for help): n
Partition number (2-128, default 2):
First sector (2088-8158, default 2088):
                      ^^^^

Note this problem does not exist for "normal" (large) devices where
first usable LBA is aligned to grain.

Reported-by: Boaz Harrosh <boaz@plexistor.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: (gpt) make mode more readable
Karel Zak [Mon, 10 Nov 2014 11:22:55 +0000 (12:22 +0100)] 
libfdisk: (gpt) make mode more readable

* use check_ prefix for checking functions
* use plural in function names where we work with more partitions than one
* always use "ents" when when we work with gpt entries array

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: fdisk_read_firstsector should seek to offset 0
Samuel Thibault [Sun, 9 Nov 2014 02:19:01 +0000 (03:19 +0100)] 
libfdisk: fdisk_read_firstsector should seek to offset 0

The current offset of cxt->dev_fd may not be still 0, notably when
blkdev_get_size has to resort to using blkdev_find_size

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org
10 years agotests: simplify and update swaplabel test
Karel Zak [Mon, 10 Nov 2014 10:46:46 +0000 (11:46 +0100)] 
tests: simplify and update swaplabel test

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoinclude/statfs_magic: use macro rather than type for f_type
Karel Zak [Mon, 10 Nov 2014 10:29:42 +0000 (11:29 +0100)] 
include/statfs_magic: use macro rather than type for f_type

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomkswap: make final report more human readable
Karel Zak [Fri, 7 Nov 2014 13:03:35 +0000 (14:03 +0100)] 
mkswap: make final report more human readable

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomkswap: device write code refactoring
Karel Zak [Fri, 7 Nov 2014 12:55:37 +0000 (13:55 +0100)] 
mkswap: device write code refactoring

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomkswap: device open code refactoring
Karel Zak [Fri, 7 Nov 2014 12:46:42 +0000 (13:46 +0100)] 
mkswap: device open code refactoring

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomkswap: always use header from control struct
Karel Zak [Fri, 7 Nov 2014 12:35:50 +0000 (13:35 +0100)] 
mkswap: always use header from control struct

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomkswap: coding style improvements
Karel Zak [Fri, 7 Nov 2014 12:25:11 +0000 (13:25 +0100)] 
mkswap: coding style improvements

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoswapon: reword some usage strings
Benno Schulenberg [Mon, 3 Nov 2014 21:17:17 +0000 (22:17 +0100)] 
swapon: reword some usage strings

Also remove some inconsistent periods and properly punctuate
the closing sentence.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agodocs: fix some wording, grammar and formatting in man page of swapon
Benno Schulenberg [Mon, 3 Nov 2014 21:17:16 +0000 (22:17 +0100)] 
docs: fix some wording, grammar and formatting in man page of swapon

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
10 years agomkswap: various minor improvement
Sami Kerola [Sun, 2 Nov 2014 20:26:31 +0000 (20:26 +0000)] 
mkswap: various minor improvement

Use correct data type in page_bad(), and add information to error message
how many bad pages were seen.

In check_blocks() move initialization to variable introduction, fix typo,
and avoid memset() when array initializer can do the job.

In main() use correct initializer for pointer.  Move swap file specific
actions to same location, and add warning when request too --check is
dismissed by command.  At the end remove momory leak.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agomkswap: set variable only when it's value is known
Sami Kerola [Sun, 2 Nov 2014 20:26:30 +0000 (20:26 +0000)] 
mkswap: set variable only when it's value is known

Avoid updating ctl->pagesize twice when user does specify page size.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agomkswap: make remaining functions to take control structure as argument
Sami Kerola [Sun, 2 Nov 2014 20:26:29 +0000 (20:26 +0000)] 
mkswap: make remaining functions to take control structure as argument

The wipe_device() and new_prober().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agomkswap: add struct mkswap_control to remove global variables
Sami Kerola [Sun, 2 Nov 2014 20:26:28 +0000 (20:26 +0000)] 
mkswap: add struct mkswap_control to remove global variables

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agomkswap: use err() rather than perror() && exit()
Sami Kerola [Sun, 2 Nov 2014 20:26:27 +0000 (20:26 +0000)] 
mkswap: use err() rather than perror() && exit()

The messsages in err() are verified from po/util-linux.pot to be already
part of translations.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agomkswap: remove unnecessary size check
Sami Kerola [Sun, 2 Nov 2014 20:26:26 +0000 (20:26 +0000)] 
mkswap: remove unnecessary size check

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agomkswap: remove system architecture specific max swap size checks
Sami Kerola [Sun, 2 Nov 2014 20:26:25 +0000 (20:26 +0000)] 
mkswap: remove system architecture specific max swap size checks

Since kernel version 2.3.4 (June 1999) all architectures has used
uint32_t as maximum number or pages in a swap device or file, there is no
longer need to support systems earlier than that.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agotests: update fdisk tests
Karel Zak [Fri, 7 Nov 2014 11:29:17 +0000 (12:29 +0100)] 
tests: update fdisk tests

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoswapoff: swapoff swap files by LABEL and UUID
Karel Zak [Fri, 7 Nov 2014 11:08:11 +0000 (12:08 +0100)] 
swapoff: swapoff swap files by LABEL and UUID

 # swapon --show=NAME,UUID
 NAME                   UUID
 /dev/sda3              8d52fca3-bf48-41d6-b826-2315e518a305
 /home/fs-images/2g.img 6fa72b96-b802-441f-a31c-091d65c0212c

 # swapoff UUID=6fa72b96-b802-441f-a31c-091d65c0212c
 swapoff: cannot find the device for UUID=6fa72b96-b802-441f-a31c-091d65c0212c

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofdisk: fix and improve -l warnings
Karel Zak [Fri, 7 Nov 2014 09:42:49 +0000 (10:42 +0100)] 
fdisk: fix and improve -l warnings

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agosfdisk: fix version typos in man page
Karel Zak [Fri, 7 Nov 2014 08:33:57 +0000 (09:33 +0100)] 
sfdisk: fix version typos in man page

Reported-by: JWP <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoswitch_root: improve statfs->f_type portability
Karel Zak [Thu, 6 Nov 2014 11:50:27 +0000 (12:50 +0100)] 
switch_root: improve statfs->f_type portability

__SWORD_TYPE is not available everywhere, for example it's not defined
by musl libc. It also seems that __SWORD_TYPE is not used for f_type
on some architectures (s390x).

Reported-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolib/loopdev: remove test program
Karel Zak [Tue, 4 Nov 2014 14:36:05 +0000 (15:36 +0100)] 
lib/loopdev: remove test program

All is already covered by losetup and mount. The test program has
never been used in our regression tests.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolib/loopdev: replace custom DBG() with include/debug.h
Karel Zak [Tue, 4 Nov 2014 13:08:45 +0000 (14:08 +0100)] 
lib/loopdev: replace custom DBG() with include/debug.h

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: cleanup libmount debug test
Karel Zak [Mon, 3 Nov 2014 12:54:40 +0000 (13:54 +0100)] 
tests: cleanup libmount debug test

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agodocs: update info about env debug variables
Karel Zak [Mon, 3 Nov 2014 12:13:54 +0000 (13:13 +0100)] 
docs: update info about env debug variables

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: clean up debug, add help debug mask
Karel Zak [Mon, 3 Nov 2014 12:13:32 +0000 (13:13 +0100)] 
libfdisk: clean up debug, add help debug mask

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibsmartcols: clean up debug, add help debug mask
Karel Zak [Mon, 3 Nov 2014 12:13:22 +0000 (13:13 +0100)] 
libsmartcols: clean up debug, add help debug mask

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: clean up debug, add help debug mask
Karel Zak [Mon, 3 Nov 2014 12:13:12 +0000 (13:13 +0100)] 
libmount: clean up debug, add help debug mask

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibblkid: clean up debug, add "help" debug mask
Karel Zak [Mon, 3 Nov 2014 12:12:20 +0000 (13:12 +0100)] 
libblkid: clean up debug, add "help" debug mask

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agoinclude/debug: improve and cleanup
Karel Zak [Mon, 3 Nov 2014 11:51:17 +0000 (12:51 +0100)] 
include/debug: improve and cleanup

* use ul_debug_ prefix for all routines
* support <NAME>_DEBUG=all also for programs without debug mask names
  (so we can avoid 0xffff mask in man pages)
* add function to print debug help

Signed-off-by: Karel Zak <kzak@redhat.com>