Commit Graph

35 Commits

Author SHA1 Message Date
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
Karel Zak 289b153340 fstrim: close dir before exit [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-29 16:14:35 +02:00
Karel Zak 8dd51c1833 fstrim: de-duplicate by mount source too
Now fstrim de-duplicates by target (mountpoint). This patch adds
de-duplication according to mount source (device) to avoid bind mounts
or devices mounted more than once. Note that the patch also check FS
root, the different FS roots of the same multi-root FS (e.g. btrfs)
maybe mounted on different places.

  # mount --bind /home/wine /mnt/test

old version:

  # fstrim -av
  /mnt/test: 0 B (0 bytes) trimmed            <---
  /home/wine: 0 B (0 bytes) trimmed           <---
  /boot: 0 B (0 bytes) trimmed
  /home: 0 B (0 bytes) trimmed
  /: 0 B (0 bytes) trimmed

new version:

  # fstrim -av
  /mnt/test: 0 B (0 bytes) trimmed            <---
  /boot: 0 B (0 bytes) trimmed
  /home: 171.8 MiB (180113408 bytes) trimmed
  /: 0 B (0 bytes) trimmed

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1162213
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-10 14:19:45 +02: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
Sami Kerola b35c37274c fstrim: initialize path variable
Reading the code this initialization is not necessary, so the change is
mostly about silencing a compiler warning and ensuring the program keeps
on working if there is a future bug that could make uninitialized 'path'
reachable to use.

sys-utils/fstrim.c:247: warning: 'path' may be used uninitialized in this
function

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-31 10:38:58 +01:00
Benno Schulenberg 1d23119072 textual: remove some inconsistent periods from error messages
While doing so, also improve translatability and some wordings.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-08-11 14:51:54 +02:00
Karel Zak df1a1ca0c9 fstrim: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-17 15:07:49 +02:00
Sami Kerola e612ead96a fstrim: avoid TOCTOU race
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-17 14:01:02 +02:00
Sami Kerola 0e65dcde88 textual: fix some typos
Found with misspell-check version 2.0d.

Reference: https://github.com/lyda/misspell-check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 17:21:02 +01:00
Benno Schulenberg d6bbe8044b textual: small inprovements to usage and man page of fstrim
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-12-12 11:10:53 +01:00
Karel Zak e05a3400e7 fstrim: de-duplicate list of filesystems
Reported-by: Pádraig Brady <P@draigBrady.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-12-11 17:01:23 +01:00
Karel Zak 36c370cbf1 fstrim: add --all to discard all filesystem
* read /proc/self/mountinfo to get filesystems
 * ignore net and pseudo filesystems
 * ignore unaccessible filesystems (over mounted by another FS)
 * read disk sysfs queue/discard_granularity to detect is discard support
 * call FITRIM ioctl
 * silently ignore EOPNOTSUPP (for example LUKS without discard) and ENOTTY
   (for example vfat) errors

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-12-10 16:40:31 +01:00
Karel Zak a60fa93cb7 fstrim: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-12-10 11:36:50 +01:00
Karel Zak 2be4015b4d fstrim: remove unnecessary "were" from verbose message
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-30 15:59:58 +01:00
Karel Zak fe98b1805f fstrim: use human readable sizes in verbose output
# fstrim -v /home
  /home: 513.9 MiB (538828800 bytes) were trimmed

Reported-by: member graysky <graysky@archlinux.us>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-28 09:25:08 +01:00
Benno Schulenberg 48899b9eae textual: remove inconsistent periods from two error messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-01-25 11:47:27 +01:00
Karel Zak fce05e9617 Revert "blkdiscard: new command"
This was only attempt as alternative implementation, unfortunately
pushed publicly... sorry.

This reverts commit c84ed54cef.
2012-09-28 01:10:08 +02:00
Karel Zak c84ed54cef blkdiscard: new command
Add to fstrim(8) code to support new discard BLKDISCARD and
BLKSECDISCARD ioctls for block devices.  The new command is only
symlink to fstrim(8) as the both utils share some code and the basic
ideas.

Based on patch from Lukas Czerner <lczerner@redhat.com>.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-27 11:38:31 +02:00
Sami Kerola 289dcc9023 translation: unify file open error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Sami Kerola add1b8afd0 translation: unify stat error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Sami Kerola efb8854f4c sys-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:49:40 +02:00
Sami Kerola 47a9edbd6d fstrim: add --version and align with howto-usage-function.txt
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-30 16:48:12 +02:00
Karel Zak 28c710217c fstrim: use strtosize_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-30 16:18:18 +02:00
Petr Uzel cf48ee22d1 fstrim: fix section number in referral to manpage
Reported-by: Roeland Jansen <roeland@linux-it.nl>
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=723877

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-10-17 11:06:36 +02:00
Karel Zak 2daae86205 fstrim: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 13:14:02 +02:00
Benno Schulenberg f14f02f581 textual: add some guiding comments for translators
These are picked up by xgettext and put in the POT file.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-02 14:13:44 +02:00
Benno Schulenberg 79d5a3b47f fstrim: correct mistaken grammar in one message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-02 14:13:44 +02:00
Francesco Cosoleto c60103a9f3 fstrim, setarch: replace error() with err()
This should improve a bit the portability as error() is a GNU extension and
util-linux provides fallbacks for err.h functions.

Fix compilation with icc, broken due to a reference to `__builtin_va_arg_pack'
in error.h using the -gcc default option.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-06-08 13:09:18 +02:00
Karel Zak fa41c101ef fstrim: cast from __u64 to standard C types
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-08 12:44:14 +02:00
Karel Zak 6c7d5ae9a2 move struct option to .rodata
It does not make sense to have writable large arrays of "struct
option" on the stack.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-03 15:00:30 +01:00
Benno Schulenberg e22d8b9519 textual: fix three typos in message strings and improve consistency
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-02-16 15:30:13 +01:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
Solaris lacks err, errx, warn and warnx.  This also means the err.h header
doesn't exist.  Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-02-14 17:45:24 +01:00
Karel Zak e3d61a4579 fstrim: fix typo
Reported-by: Jeroen Oortwijn <oortwijn@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-29 13:09:16 +01:00
Lukas Czerner d9e2d0dd14 fstrim: add new command
fstrim is used on a mounted filesystem to discard (or "trim") blocks
which are not in use by the filesystem.  This is useful for
solid-state drives (SSDs) and thinly-provisioned storage

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-26 14:59:01 +01:00