Commit Graph

20 Commits

Author SHA1 Message Date
Karel Zak 677ec86cef Use --help suggestion on invalid option
The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 13:13:34 +01:00
Benno Schulenberg b31fd516ff blkdiscard: slice up the recently changed usage text
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-09 12:11:18 +01:00
Karel Zak 7154cc8926 blkdiscard: add --zeroout (BLKZEROOUT ioctl)
Requested-by: Yaniv Kaul <ykaul@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-24 15:21:38 +01:00
Ruediger Meier eeae448805 blkdiscard: don't report "zero range" at the end
We want to address the case that we have printed the last useful
stats line already within the loop. Avoiding an additional line
"Discarded 0 bytes ..." at the end.

Note there is a behavior change now for the edge cases "-v -l 0" and
"-v -o blksize" where we don't print any stats line anymore. But actually
it's correct, we never make any BLKDISCARD syscall with zero range.
Perhaps we should return error in these cases to help people who always
want to parse stats output on success.

CC: Federico Simoncelli <fsimonce@redhat.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-12-09 18:23:29 +01:00
Ruediger Meier a3e91e2646 blkdiscard: fix stats reporting (off by one)
CC: Federico Simoncelli <fsimonce@redhat.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-12-09 18:23:29 +01:00
Ruediger Meier 0e76536579 blkdiscard: fix timeval comparison inclusive usecs
We will see if this makes our "--step" tests reliable.

CC: Federico Simoncelli <fsimonce@redhat.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-12-09 18:23:29 +01:00
Sami Kerola ee24ab6f1e misc: fix redundant assignment and reassignments before use [cppcheck]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-08 07:46:39 +01:00
Benno Schulenberg fc14ceba5e textual: grammarize and harmonize the stat error message
The message "stat failed %s" seems to say that stat() failed to
do something, or failed to pass a test, but of course it means
that the statting of something failed.  So say so.  Also make
two very similar messages equal to this one.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02 11:27:10 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Karel Zak 784467ad2d blkdiscard: fix compiler warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-26 12:38:53 +01:00
Karel Zak 700031ade7 misc: use monotonic time rater than gettimeofday
Based on patch Alexander Samilovskih <alexsamilovskih@gmail.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-18 14:35:21 +01:00
Karel Zak 4f55368cc5 blkdiscard: fix includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-27 10:00:19 +01:00
Federico Simoncelli c472a7e35a blkdiscard: add support for steps and progress
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
2014-10-27 09:16:49 +01:00
Federico Simoncelli d7ce9acb33 blkdiscard: fail on sector misalignment 2014-10-27 09:16:47 +01:00
Karel Zak 0c75b6a470 blkdiscard: fix err->errx()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-14 12:14:05 +02:00
Raphael S. Carvalho 303884a495 blkdiscard: fix underflow when offset is greater than device size
If offset (range[0]) is greater than device size (blksize), the variable 'end'
will be greater than blksize, and range[1] (length) will be recalculated.
The underflow happens when subtracting range[0] (offset) from blksize, thus
range[1] will be the result of an underflow. The bug leads to unwanted behavior
from the program, where range[1] is likely to be a high number and then will
discard a considerable amount of blocks from the device. The fix consists of
exitting the program with an error message when the condition stated above is
true. Spotted while auditing the code.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2014-10-14 12:04:14 +02:00
Theodore Ts'o 8883945957 blkdiscard: BLKSSZGET fills in an int, not a uint64
Reported-by: Jason Cipriani <jason.cipriani@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-11-04 14:58:47 +01:00
Karel Zak 777519226d blkdiscard: use fstat() rather than stat() [coverity scan]
Calling function "open(char const *, int, ...)" that uses "path" after
 a check function. This can cause a time-of-check, time-of-use race
 condition.

.. well, in blkdiscard context it's mostly cosmetic change.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-06 10:29:04 +02:00
Benno Schulenberg 4ce393f4d8 textual: fix several typos and angular brackets in messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-06-07 12:11:14 +02:00
Lukas Czerner d964b669c8 blkdiscard: add new command
blkdiscard is used to discard device sectors. This is useful for
solid-state drivers (SSDs) and thinly-provisioned storage. Unlike
fstrim this command is used directly on the block device.

blkkdiscard uses BLKDISCARD ioctl or BLKSECDISCARD ioctl for the secure
discard.

All data in the discarded region on the device will be lost!

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
2012-09-28 01:12:09 +02:00