Commit Graph

1228 Commits

Author SHA1 Message Date
Karel Zak 9cd88771ef fdisk: add --lock and LOCK_BLOCK_DEVICE
Addresses: https://github.com/karelzak/util-linux/issues/921
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-27 17:00:41 +02:00
Karel Zak c3ef1268a0 sfdisk: add --lock and LOCK_BLOCK_DEVICE
Addresses: https://github.com/karelzak/util-linux/issues/921
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-27 16:59:46 +02:00
Karel Zak b8671fe763 mkswap: add --lock and LOCK_BLOCK_DEVICE
Addresses: https://github.com/karelzak/util-linux/issues/921
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-27 16:59:16 +02:00
Karel Zak ec8f712157 cfdisk: add --lock and LOCK_BLOCK_DEVICE
Addresses: https://github.com/karelzak/util-linux/issues/921
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-27 16:58:08 +02:00
Michael Kerrisk (man-pages) 380fd9aa95 Manual pages: order ENVIRONMENT / FILES / CONFORMING TO consistently
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.

In this patch, we ensure that the ENVIRONMENT, FILES, and CONFORMING TO
sections are always placed toward the end of the page, just above NOTES.

One page is not fixed by this patch: term-utils/agetty.8. This page
is a mess of unusual section names, and probably requires an individual
edit.

Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:

    $ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
    [Apply patch]
    $ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
    $ diff a b
    $ echo $?
    0

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-22 10:25:52 +02:00
Michael Kerrisk (man-pages) 67e63c1263 Manual pages: order NOTES / HISTORY / BUGS / EXAMPLE consistently
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.

In this patch, we ensure that the NOTES, HISTORY, BUGS, and EXAMPLE
sections are always placed near the end of the page, just above
AUTHORS, COPYRIGHT, SEE ALSO, and AVAILABILITY.

One page is not fixed by this patch: term-utils/agetty.8. This page
is a mess of unusual section names, and probably requires an individual
edit.

Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:

    $ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
    [Apply patch]
    $ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
    $ diff a b
    $ echo $?
    0

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-22 10:25:50 +02:00
Michael Kerrisk (man-pages) ade04bb89c Manual pages: order AUTHORS / COPYRIGHT / SEE ALSO / AVAILABILITY consistently
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.

In this patch, we ensure that the AUTHORS, COPYRIGHT, SEE ALSO, and
AVAILABILITY sections are always placed at the end of the page.

Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:

    $ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
    [Apply patch]
    $ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
    $ diff a b
    $ echo $?
    0

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-22 10:25:49 +02:00
Michael Kerrisk (man-pages) a87f49f662 Manual pages: use the term "exit status"
The manual pages currently use a multitude of terms--"exit code",
"error code", "return code", "exit code", and so on--when what
is always meant is "exit status" (the POSIX term). This patch fixes
as many of these erroneous terms as I could find.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-20 12:56:52 +02:00
Michael Kerrisk (man-pages) 7e765c93dc Manual pages: Standardize on EXIT STATUS as section title
There is quite some value (in terms of readability and user
expectations) if consistent names are used for the sections
within manual pages. This patch is one of a series to bring
about this consistency.

Currently we have EXIT STATUS (18), EXIT CODES (3), RETURN CODE (7),
RETURN CODES (1), or RETURN VALUE (4 instances in pages that document
commands, rather than functions).

Let's standardize on the EXIT STATUS (which is also what is
suggested in man-pages(7), and is the POSIX terminology).

A subsequent patch will clean up corresponding miswordings in
manual page text.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-20 12:56:12 +02:00
Michael Kerrisk (man-pages) 4259cff22e Manual pages: Standardize on ENVIRONMENT as section title
There is quite some value (in terms of readability and user
expectations) if consistent names are used for the sections
within manual pages. This patch is one of a series to bring
about this consistency.

But, let's make sure that the section is consistently titled
across pages. Currently we have ENVIRONMENT (many) or ENVIRONMENT
VARIABLES (3).  Let's standardize on ENVIRONMENT (which is also
what is suggested in man-pages(7)).

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-20 12:56:12 +02:00
Michael Kerrisk (man-pages) bc281b0991 Manual pages: Standardize on EXAMPLE as section title
There is quite some value (in terms of readability and user
expectations) if consistent names are used for the sections
within manual pages. This patch is one of a series to bring
about this consistency.

Currently we have EXAMPLE (10) or EXAMPLES (23).
Let's standardize on the EXAMPLE (which is also what is
suggested in man-pages(7)) and used consistently across
a large number of pages in the Linux man-pages project.

(I realize the choice to go EXAMPLE, rather than EXAMPLES,
may be debatable. If necessary, I'd write a patch that instead
goes the other way, but I'd prefer to follow man-pages(7).)

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-20 12:56:12 +02:00
Michael Kerrisk (man-pages) a8d0d330cf Manual pages: Standardize on AUTHORS as section title
There is quite some value (in terms of readability and user
expectations) if consistent names are used for the sections
within manual pages. This patch is one of a series to bring
about this consistency.

In the Linux man-pages project, I long ago did away with the
AUTHOR(S) section, but I realize some projects like to keep this.

But, let's make sure that the section is consistently titled
across pages. Currently we have AUTHOR (47) or AUTHORS (41).
Let's standardize on the latter (which is also what is
suggested in man-pages(7)).

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-20 12:56:12 +02:00
Michael Kerrisk (man-pages) 5a82980632 docs: (man) remove double quotes (") in .SH lines
Using double quotes in .SH lines containing multiple words is unneeded,
and in any case is not consistently done in the util-linux manual pages,
where double quotes are used in only around half of the cases.
(This usage was long ago elminated in the man-pages project, with
no ill effects reported to date.)

Remove these quotes, so that .SH lines are more uniform, in preparation
for some (more easily) scripted doiscovery of consistency problems in
(and possibly global fixes to) the manual pages.

Other than stripping the double quotes, this patch makes no changes to
the content of the manual pages.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-19 12:15:34 +02:00
Yannick Le Pennec 5fdb086696 docs: Fix dead references to kernel documentation
Most date back to reorganisation of the Documentation/ tree in 2016,
new paths based on v5.7-rc5:

fdisk.8:   Documentation/{,admin-guide/}devices.txt
eject.c:   Documentation/{,userspace-api/}ioctl/cdrom.rst
mount.8:   Documentation/filesystems/adfs.{txt,rst}
rfkill.8:  Documentation/{rfkill.txt,driver-api/rfkill.rst}
tunelp.8:  Documentation/{parport.txt,admin-guide/parport.rst}
zramctl.8: Documentation/{blockdev/zram.txt,admin-guide/blockdev/zram.rst}

Signed-off-by: Yannick Le Pennec <yannick.lepennec@live.fr>
2020-05-18 10:35:31 +02:00
Gaël PORTAY 366e163961 sfdisk: (man) fix typo 2020-05-15 12:48:31 -04:00
Wolfram Sang 9bf7517162 sfdisk: avoid unneeded empty lines with '--list-free'
Similar to commit 4a52959d1 ("(s)fdisk: avoid unneeded empty lines with
'--list'"), there were also two superfluous empty lines when /dev/sr0
didn't contain a medium. Refactor the '--list-free' code the same way as
in the mentioned commit.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
2020-05-12 10:09:46 +02:00
Wolfram Sang 4a52959d18 (s)fdisk: avoid unneeded empty lines with '--list'
On my system, I got two superfluous empty lines because /dev/sr0 didn't
contain a medium. Refactor the code to handle the seperator within
print_device_pt() and print it only when assigning the device worked.
This unifies handling between print_all_devices_pt and (s)fdisk because
the latter did not consider the return code for the seperator while the
former did. Also, it saves some lines of code.

Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=814184 (first part)
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2020-05-11 11:28:49 +02:00
Wolfram Sang f708d71aef fdisk: better wording for '-B' in the man page
Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=814184 (second part)
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2020-05-06 15:14:55 +02:00
Wolfram Sang 7eeb2c827c fdisk: specify in '--help' that we can have multiple devices with '-l'
Matches it with the man-page.

Adresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=756187
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2020-05-06 15:14:52 +02:00
Karel Zak 79ef974a68 sfdisk: only report I/O errors on --move-data
Now sfdisk stops everything on I/O error when moving data. It seems
better to report the error to user and continue as it's better to have
one bad sector in the partition than inconsistent all partition.

Addresses: https://github.com/karelzak/util-linux/issues/984
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-22 15:03:26 +02:00
Rosen Penev ad52498014
[clang-tidy] fix misleading identation
Found with readability-misleading-indentation

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:21:00 -07:00
Rosen Penev ad296391f9
[clang-tidy] fix wrong *cmp usage
Found with bugprone-suspicious-string-compare

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:21:00 -07:00
Rosen Penev 042f62dfc5
[clang-tidy] do not use else after return
Found with readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:20:59 -07:00
Rosen Penev bd89499e07
[clang-tidy] do not return in void functions
Found with readability-redundant-control-flow

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-19 14:03:21 -07:00
Karel Zak 53a808562d fdisk: make sure label defined for some menu entries
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-24 12:00:28 +01:00
Karel Zak f2229320a9 fdisk: add --noauto-pt
The default partition table depends on system arch, for example on
Sparc it's SUN and on x86_64 it's MBR. This option forces fdisk to
keep the device empty and allow user to create non-default PT in more
elegant way.

Addresses: https://github.com/karelzak/util-linux/pull/994
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-24 11:17:34 +01:00
Zbigniew Jędrzejewski-Szmek d52786aab7 fsck.cramfs: fix macro usage
Autotoolz does not define HAVE_LCHOWN when the condition is false,
so it is appropriate to use #ifdef/#ifndef as everywhere else.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-10 10:55:01 +01:00
Karel Zak e441601563 Merge branch 'topic/fdisk' 2020-03-03 16:22:10 +01:00
Karel Zak 006607abb5 fdisk: add support for parttype aliases
* add list of supported aliases to 'l' and 'L' output
* support aliases in 't' dialog

For example (use 'swap' to set 0x82 partition type):

 Command (m for help): t
 Selected partition 1
 Hex code or alias (type L to list all): swap
 Changed type of partition 'Linux' to 'Linux swap / Solaris'.

Note that the aliases are evaluated as the last possibility if user's
input dues not match up with any partition type. This is necessary for
backward compatibility.

This patch does NOT introduce shortcuts (.e.g. 'S' for swap) to
fdisk(8) due to collisions with already used dialog keys.

Addresses: https://github.com/karelzak/util-linux/issues/958
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-03 16:20:05 +01:00
Karel Zak 5839a4ea03 sfdisk: extend --part-type, support aliases
* add support for aliases to sfdisk scripts
* add shortcuts and aliases to --part-type command

Note that --part-type evaluates shortcuts and aliases as the last
possibility (so after regular type string). This is necessary for
backward compatibility.

Example ('raid' type alias):
 # sfdisk --part-type /dev/sdc 1 raid

 # fdisk -l /dev/sdc
 ...
 Device     Boot Start    End Sectors Size Id Type
 /dev/sdc1        2048 204799  202752  99M fd Linux raid autodetect

Example ('L' type shortcut):

 # sfdisk --part-type /dev/sdc 1 L

 # fdisk -l /dev/sdc
 ...
 Device     Boot Start    End Sectors Size Id Type
 /dev/sdc1        2048 204799  202752  99M 83 Linux

Addresses: https://github.com/karelzak/util-linux/issues/958
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-03 16:15:39 +01:00
Karel Zak ac762ed71f sfdisk: fix previous --append patch, improve man page
- fix stupid typo (!has_container_or_unused(sf))
- use fdisk_is_partition_used() as fdisk_get_partition() returns
  nothing for unused partition
- update tests
- add more hints to the man page

Addresses: https://github.com/calamares/calamares/issues/1332
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-02 14:41:39 +01:00
Karel Zak fa3fface0f sfdisk: fix --append to PT with gaps
sfdisk trying to be more smart than libfdisk when analyze if we can
append to the current PT. libfdisk is able to use unused partition
to create a new one (if partno not strictly specified), but sfdisk
assumes that we can add partition to extended partition only.

Addresses: https://github.com/calamares/calamares/issues/1332
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-02 12:27:36 +01:00
Karel Zak 5d271cefad fdisk: improve list-types readability
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-20 15:27:05 +01:00
Karel Zak 4d755765b4 sfdisk: (man) add note about type and shortcuts collision
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-20 15:26:28 +01:00
Karel Zak ee5a160250 sfdisk: add --relocate command
This command allows to relocate GPT backup header behind last
partition (--relocate gpt-bak-mini) or to standard position
(--relocate gpt-bak-std).

Hint: use "fdisk --list-details" to see "Alternative LBA".

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-05 14:40:45 +01:00
Karel Zak 99d78b2fef fdisk: add --list-details
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-05 14:31:00 +01:00
Karel Zak f1970cc557 docs: improve size arguments description in --help output
Let's add "Arguments:" section to the --help output and describe
{K,M,G...}iB suffixes there.

Addresses: https://github.com/karelzak/util-linux/pull/917
Co-Author: ed <ed@s5h.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-05 11:01:36 +01:00
Karel Zak da0debad53 sfdisk: fix ref-counting for the script
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-04 15:54:53 +01:00
Karel Zak d8c68b52cc libfdisk: (script) accept sector-size, ignore unknown headers
- add sector-size between supported headers (already in --dump output)

- report unknown headers by -ENOTSUP

- ignore ENOTSUP in sfdisk (but print warning) and in fdisk_script_read_file()

Addresses: https://github.com/karelzak/util-linux/issues/949
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-04 15:11:19 +01:00
Karel Zak 65e27d545c sfdisk: add --disk-id to change disk UUID/ID
Addresses: https://github.com/karelzak/util-linux/issues/916
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-23 15:50:28 +01:00
Karel Zak 9fabc6d5fa sfdisk: remove broken step alignment for --move
* remove unnecessary and broken step alignment
* improve reported information in move log
* improve final progress bar update

Addresses: https://github.com/karelzak/util-linux/issues/938
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-23 15:07:32 +01:00
Karel Zak 2b26438c4b sfdisk: make sure we do not overlap on --move
The area we need to move does not have to be aligned to optimal I/O
size (step size) -- we need to be sure we do not move data
after/before the area.

Addresses: https://github.com/karelzak/util-linux/issues/938
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-23 12:44:58 +01:00
Karel Zak 319029e8b4 sfdisk: remove never read value [clang scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-15 12:38:19 +01:00
Karel Zak e1d7c65a5c sfdisk: check fdisk_script_set_header() return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-15 12:35:38 +01:00
Karel Zak a8955bf07a cfdisk: check mnt_table_parse_fstab() return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-15 11:56:00 +01:00
Karel Zak bb607cb3b2 docs: fix typos [fossies codespell scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-09 10:18:16 +01:00
Karel Zak 63f8c66af8 Merge branch 'master' of https://github.com/dsd/util-linux
* 'master' of https://github.com/dsd/util-linux:
  libblkid: improve identification of ISO9660 partition
  isosize: move ISO size functions into a shared header
2019-12-20 12:55:49 +01:00
Bjarni Ingi Gislason 1c4c602427 man pages: Change a HYPHEN-MINUS (-) to a minus (\-) for options and numbers
Change a HYPHEN-MINUS (code 0x55, 2D) to a minus (\-), if in front of

1) a name of an option

2) a negative number to be printed.

  See man-pages(7) [Debian package "manpages"].

  The output from "nroff" is unchanged.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2019-12-17 12:32:43 +01:00
Bjarni Ingi Gislason eb02489380 man pages: Add a comma after "e.g." and "i.e."
Add a comma (,) after "e.g." and "i.e.", or use English words
(man-pages(7) [package "manpages"]).

  Abbreviation points should be protected (usually with the
non-printing, zero width character '\&') from being interpreted as an
end of sentence, if they are not, and that independent of their current
place on the line.

  This is important when typing, as one does not usually know in
advance when the editor jumps to a new line.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2019-12-17 12:32:43 +01:00
Bjarni Ingi Gislason 2fb684f004 man pages: Fix misuse of two-fonts macros
Two-fonts macros are made for two or more arguments.

  Remove space at end of lines in the files "term-utils/{script.1,
scriptlive.1, scriptreplay.1}".

  Put "\-\-summary" to the correct indent in the file
"term-utils/script.1"

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2019-12-17 12:32:43 +01:00
Daniel Drake 1f10f4afec isosize: move ISO size functions into a shared header
Move the helper functions that parse ISO data & sector size info into
a separate, shared header.

These will addtionally be used by libblkid's iso9660 parser.

Signed-off-by: Daniel Drake <drake@endlessm.com>
2019-12-16 14:29:24 +08:00
Elliott Mitchell 2bb3aa36b2 cleanup: Remove some spurious spaces
Sorry detail-oriented people tend to wipe these out if they notice them.
Add in automated tools and lots of excess end-of-line spaces get wiped
out.

Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-01 13:01:43 +02:00
Karel Zak 1d84470388 libfdisk: (gpt) fix hybrid MBR detection, fix 'w'
* current code overwrites hybrid MBR because EE partition
  is expected from fist sector, this is not true for hybrid MBR

* print "The partition table has been altered." message also for
  nested contexts

* remove "You have to sync the MBR manually" message

Addresses: https://github.com/karelzak/util-linux/issues/851
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-01 12:51:04 +02:00
Karel Zak 5c1c594ee5 fdisk: use 'r' to return from MBR to GPT
The current code uses 'M' to switch between MBR and GPT, but it's not
intuitive to "go back" by 'M'. It seems more user-friendly to use 'r'
as in another places (for example when go from expert menu or from BRD
menu).

The 'M' to return to GPT is still supported for backward compatibility.

Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-30 13:11:17 +02:00
Karel Zak 980a25f9c4 sfdisk: (move-data) improve MiB/s progress bar
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-30 12:25:17 +02:00
Karel Zak 135e03892b sfdisk: (man) add note about interactive mode)
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-26 15:20:47 +02:00
Karel Zak a6a24f18e6 mkswap: cast before lseek [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 15:47:55 +02:00
Karel Zak c135625734 fdformat: cast before lseek [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 15:45:15 +02:00
Karel Zak e56ca06815 libfdisk: add sector-size to dump
We do not use sector-size from dumps to create partition tables,
because it's always necessary to use real device specific settings.

The new sector-size value is usable when you use the dump as
a description of the device or disk image.

Addresses: https://github.com/karelzak/util-linux/issues/869
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-16 10:29:41 +02:00
Matthew Krupcale c7a3455c12 disk-utils: docs: fix sfdisk(8) man page typo
* disk-utils/sfdisk.8: fix typo: "ir" -> "it"
2019-09-10 17:05:22 -04:00
Karel Zak 925f2d4f4f sfdisk: (--move-data) add speed to progress bar, don't use POSIX_FADV_DONTNEED
posix_fadvise() in the loop is pretty expensive.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-06 16:57:40 +02:00
Karel Zak 4bf424188d sfdisk: (--move-data) add simple progress bar
Addresses: https://github.com/karelzak/util-linux/issues/848
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-06 15:07:59 +02:00
Karel Zak 7942ba8a79 sfdisk: add --move-use-fsync, disable fsync() by default
It's slow, so slooow...

Addresses: https://github.com/karelzak/util-linux/issues/848
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-06 15:07:43 +02:00
Karel Zak 69f30c3126 sfdisk: (--move-data) make log optional
The log may be pretty huge and very probably not used by many users.
Let's make it optional.

The patch also clean up move-data output messages.

Addresses: https://github.com/karelzak/util-linux/issues/848
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-06 15:07:30 +02:00
Karel Zak 4ce4675cce sfdisk: (--move-data) keep step size based on optimal I/O
The current implementation is too paranoid and tries to keep in
memory only data which are on disk too. It means very small step size
when move partition only a few sectors left/right.

This patch enlarge the buffer to at least 1MiB and aligned to optimal
I/O.

Addresses: https://github.com/karelzak/util-linux/issues/848
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-06 15:05:59 +02:00
Karel Zak 45aaa8f3db sfdisk: make --no-act usable for --move-data too
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-06 12:37:26 +02:00
Karel Zak 91099dea35 tests: update sfdisk wipe output
- stderr is used for the warning (like in fdisk)

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-05 16:46:14 +02:00
Karel Zak 40af0db4cd fdisk: fix quit dialog for non-libreadline version
We need to clear stdin errors otherwise it returns EOF forever after
CTRL+D.

Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-05 12:34:01 +02:00
Karel Zak fff85eb577 fdisk: make quit question more usable
Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-05 12:06:27 +02:00
Karel Zak 6cd671d427 fdisk: cleanup wipe warning
Let's remove 'old' from the sentence, add man page reference to
sfdisk.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-04 14:54:54 +02:00
Karel Zak 03154d2cf2 sfdisk: add -J between mutually exclusive options
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-03 16:22:21 +02:00
Karel Zak ce16f04efa fdisk: add hint about --wipe to warning
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1748020
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-03 11:57:23 +02:00
Karel Zak eabcbfc449 sfdisk: mark --dump and --list-free as mutually exclusive
Reported-by: Bertrand Jacquin <bertrand@jacquin.bzh>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-02 13:10:44 +02:00
Karel Zak 7837cd491a sfdisk: write all message to stdout
The code writes message to stdout and \n to stderr.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-30 15:40:06 +02:00
Sami Kerola dbeb1d733e
docs: try to find broken man references and fix them
Unfortunately methods I used to find and fix were based on quite manual
process that cannot be easily repeated so I do not see how this fix could be
turned into a tools/checkmans.sh addition.  Well, lets hope doing this
manually twice every decade is good enough.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-26 19:43:40 +01:00
Sami Kerola a7466bdcbe
po: remove possibility to translate static option arguments
These strings are expected to be wrote exactly as they are parsed, so make
translating them impossible.  Since mkfs.cramfs -N option arguments need
this treatment use opportunity to slice usage() output to multiple lines.

Addresses: https://bugs.debian.org/907568
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-24 09:29:52 +01:00
Karel Zak 5200aa99d2 partx: document -d vs. --nr and fix test
The commit ab025087f9 has disabled error
message, but unfortunately it keeps wrong return code. This has been fixed
by commit 53ae7d60cf.

This commit add hit about it to docs and fix regression test too.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-21 13:42:22 +02:00
Karel Zak 53ae7d60cf partx: don't report ENXIO as error on -d
The errno ENXIO should be ignored, unfortunately the current code uses
variable 'rc' for ioctl return code as well as for final del_parts()
return value. So, failed ioctl (which should be ignored) affects all
del_parts() status.

  # modprobe scsi_debug dev_size_mb=100
  # partx  -d --nr 1-1024 /dev/sdc; echo $?
  1

The device dos not contains any partitions, so 0 return code is
expected in this case.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1739179
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-21 10:51:18 +02:00
Rosen Penev 050def0f35
Remove unused utime.h header
It is sometimes unavailable and errors on inclusion. For example, when
disabled in uClibc-ng.
2019-08-08 12:14:39 -07:00
Karel Zak 08474fde66 libfdisk: (script) support shortcuts in the type= field
The unnamed-field format supports partition type shortcuts:

	",1MiB,L'

but for named-field format it requires full type:

 (mbr)	"size=1MiB,type=83"
 (gpt)  "size=1MiB,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4"

This patch implements type shortcuts also for named-field format:

	"size=1MiB,type=L"

to make it more user-friendly and unified.

Addresses: https://github.com/karelzak/util-linux/issues/837
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-08 10:34:27 +02:00
Karel Zak 41994e0097 cfdisk: free libfdisk items
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-11 11:22:39 +02:00
Karel Zak 49e1a33346 cfdisk: simplify code
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-11 10:54:22 +02:00
Karel Zak b0eca21a5c fdisk: add note about -S and -H
It's seems people still follow old advices for SSD/4K devices. Let's
make CHS deprecation more visible at the begin of the man page...

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-28 15:12:31 +02:00
Karel Zak 9f34182d53 sfdisk: use xstrcpy()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-20 12:42:43 +02:00
Sami Kerola 84f46d1f67
sfdisk: remove unnecessary size check [cppcheck]
Following warning is false positive.  Size of the buffer is defined using
BUFSIZ, and so the strncpy() will never overwrite the last byte that is
initialized to zero in get_user_reply().

[disk-utils/sfdisk.c:137] -> [disk-utils/sfdisk.c:136]: (warning) Either the
condition 'bufsz!=0' is redundant or strncpy() argument nr 3 can have
invalid value.  The value is -1 but the valid values are '0:'.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-18 22:07:20 +01:00
Karel Zak 89770db4ef fdisk: initialize buffers for get_user_reply() [coverity scan]
It's probably unnecessary, but better be safe than sorry.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-14 15:00:01 +02:00
Karel Zak 2c308875a7 misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 15:14:13 +02:00
Karel Zak 68224d108d include/c: add print_version() macro
Let's consolidate the version printing code. It also seems better to
use exit() after --version, because it's handled in different way by
ASAN.

It's strange, but ASAN reports leaks after return in main(). Note that
we do not use free-before-exit.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 13:47:17 +02:00
Karel Zak 4534e4f2fb fsck: (man) labels are available for all filesystems
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-03-28 15:29:09 +01:00
Karel Zak f91c21cc7e mkswap: be more explicit about maximal number of pages
Addresses: https://github.com/karelzak/util-linux/pull/766
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-03-08 12:14:19 +01:00
Karel Zak c9fbfcfc49 blockdev: make –-getbsz less confusing for end-users
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1684078
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-28 14:08:23 +01:00
Sami Kerola 4813a5210f various: fix 'uninitialized when used' warnings [clang]
This change fixes "warning: variable 'var' may be uninitialized when used
here [-Wconditional-uninitialized]" warnings reported in various files.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-02-18 13:19:24 +01:00
Tobias Stoeckmann a6fb1ce79d sfdisk: Avoid out of boundary read with readline
It is not guaranteed that the returned string of readline() actually
contains as many bytes as buf can contain.

If bufsz is larger than the allocated memory by readline, an out of
boundary read occurs and leads to undefined behaviour. Most likely
that will be a crash.

This can be reproduced when readline-support is compiled in and when
you directly enter "quit" and "n" (to not write changes back to disk)
when sfdisk was called with any given device.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2019-02-18 13:05:14 +01:00
Karel Zak 39f37044b3 fdisk: use 2 decimal places for size in disk summary
In the disk summary it seems nice, but I'm not sure about lists (SIZE
 columns). It seems more readable to keep the lists with one decimal
 place only. New output:

  # sfdisk --list /dev/sda

 Old output:
  Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors

 New output:
  Disk /dev/sda: 223.58 GiB, 240057409536 bytes, 468862128 sectors

 The rest is unchanged:
  ...
  Device         Start       End   Sectors   Size Type
  /dev/sda1       2048    411647    409600   200M EFI System
  /dev/sda2     411648    821247    409600   200M Linux filesystem
  /dev/sda3     821248 274087935 273266688 130.3G Linux filesystem
  /dev/sda4  274087936 378945535 104857600    50G Linux filesystem
  /dev/sda5  378945536 468862094  89916559  42.9G Linux filesystem

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1673452
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-12 14:21:54 +01:00
Karel Zak 1895c76f74 swapon: rewrite section about swapfiles
* don't duplicate info on two places -- let's keep only small note
  in mkswap(8) man page, suggest to read swapon(8) man page

* add info about kernel versions for XFS and Btrfs swapfiles support

* use subsection in the NOTES

Addresses: https://github.com/karelzak/util-linux/issues/633
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-22 10:02:17 +01:00
Karel Zak 77983e4a21 swapon: (man) iomap for swapfile is already supported by kernel
... since commit 67482129cdabf7cede1301d2415ef4f0156d35cd (Linus'
tree).

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-21 17:01:25 +01:00
Karel Zak eebfa469fc swapon: (man) cleanup note about holes
Addresses: https://github.com/karelzak/util-linux/issues/633
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-21 12:54:20 +01:00
Karel Zak 12d12102d6 fsck.cramfs: fix utimes() usage
The bug has been introduced by untested commit ad7ac3d598 ;-(

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-15 11:44:25 +01:00
Sami Kerola ad7ac3d598
fsck.cramfs: use utimes() instead of utime() that is obsolete
Reference: http://man7.org/linux/man-pages/man3/utime.3p.html#APPLICATION_USAGE
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-01-12 08:46:54 +00:00
Karel Zak e6effcac61 fdisk: make partition types uses more robust
* report failed partition type parsing
* make sure partition types code (from user reply) for MBR is hex

Reported-by: Jonny Grant <jg@jguk.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-10 12:17:19 +01:00