Commit Graph

9 Commits

Author SHA1 Message Date
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