summaryrefslogtreecommitdiffstats
path: root/sys-utils/blkdiscard.c
Commit message (Collapse)AuthorAgeFilesLines
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-7/+6Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: never use usage(stderr)Ruediger Meier2017-06-261-4/+5
| | | | | | | Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-9/+9
| | | | | | | | | | text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* Use --help suggestion on invalid optionKarel Zak2016-12-191-2/+1Star
| | | | | | | | 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>
* blkdiscard: slice up the recently changed usage textBenno Schulenberg2016-03-091-7/+8
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* blkdiscard: add --zeroout (BLKZEROOUT ioctl)Karel Zak2016-02-241-12/+47
| | | | | Requested-by: Yaniv Kaul <ykaul@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* blkdiscard: don't report "zero range" at the endRuediger Meier2015-12-091-1/+1
| | | | | | | | | | | | | | | 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>
* blkdiscard: fix stats reporting (off by one)Ruediger Meier2015-12-091-3/+3
| | | | | CC: Federico Simoncelli <fsimonce@redhat.com> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* blkdiscard: fix timeval comparison inclusive usecsRuediger Meier2015-12-091-2/+3
| | | | | | | 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>
* misc: fix redundant assignment and reassignments before use [cppcheck]Sami Kerola2015-08-081-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: grammarize and harmonize the stat error messageBenno Schulenberg2015-02-021-1/+1
| | | | | | | | | 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>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+4
| | | | | | | | | 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>
* blkdiscard: fix compiler warningKarel Zak2014-11-261-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: use monotonic time rater than gettimeofdayKarel Zak2014-11-181-3/+4
| | | | | | Based on patch Alexander Samilovskih <alexsamilovskih@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* blkdiscard: fix includesKarel Zak2014-10-271-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* blkdiscard: add support for steps and progressFederico Simoncelli2014-10-271-13/+44
| | | | Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
* blkdiscard: fail on sector misalignmentFederico Simoncelli2014-10-271-3/+9
|
* blkdiscard: fix err->errx()Karel Zak2014-10-141-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* blkdiscard: fix underflow when offset is greater than device sizeRaphael S. Carvalho2014-10-141-0/+2
| | | | | | | | | | | | | 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>
* blkdiscard: BLKSSZGET fills in an int, not a uint64Theodore Ts'o2013-11-041-2/+2
| | | | | Reported-by: Jason Cipriani <jason.cipriani@gmail.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
* blkdiscard: use fstat() rather than stat() [coverity scan]Karel Zak2013-08-061-6/+5Star
| | | | | | | | | | 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>
* textual: fix several typos and angular brackets in messagesBenno Schulenberg2013-06-071-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* blkdiscard: add new commandLukas Czerner2012-09-281-0/+173
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>