]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fstrim: update man page, reuse libmnt_iter
authorKarel Zak <kzak@redhat.com>
Tue, 11 Jun 2019 09:05:12 +0000 (11:05 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 11 Jun 2019 09:05:12 +0000 (11:05 +0200)
* add info about read-only to the man page
* don't be systemd specific, people aso use crond
* reuse libmnt_iter

Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/fstrim.8
sys-utils/fstrim.c

index 7e04d46be0a5b154c081b1ed3620f77a4c08bd24..7e39b33d759c43d0dd2fdbca049e0409593d325a 100644 (file)
@@ -52,15 +52,14 @@ discard operation.  The root filesystem is determined from kernel command line i
 in the file.
 The other supplied options, like \fB\-\-offset\fR, \fB\-\-length\fR and
 \fB-\-minimum\fR, are applied to all these devices.
-Errors from filesystems that do not support the discard operation are silently
-ignored.
-
+Errors from filesystems that do not support the discard operation,
+read-only devices and read-only filesystems are silently ignored.
 .IP "\fB\-a, \-\-all\fP"
 Trim all mounted filesystems on devices that support the discard operation.
 The other supplied options, like \fB\-\-offset\fR, \fB\-\-length\fR and
 \fB-\-minimum\fR, are applied to all these devices.
-Errors from filesystems that do not support the discard operation are silently
-ignored.
+Errors from filesystems that do not support the discard operation,
+read-only devices and read-only filesystems are silently ignored.
 .IP "\fB\-n, \-\-dry\-run\fP"
 This option does everything apart from actually call FITRIM ioctl.
 .IP "\fB\-o, \-\-offset\fP \fIoffset\fP"
@@ -102,7 +101,8 @@ option).
 .TP
 .B \-\-quiet
 Suppress error messages.  This option is meant to be used in systemd service
-file to hide warnings that are result of known problems, such as NTFS driver
+file or in cron scripts to hide warnings that are result of known problems,
+such as NTFS driver
 reporting
 .I Bad file descriptor
 when device is mounted read-only, or lack of file system support for ioctl
index e0e9e57a984512de0710f8fa7b174eaf856658ba..2c11a317f05bfab73f23c27d13faea20392df3cf 100644 (file)
@@ -278,6 +278,7 @@ static int fstrim_all(struct fstrim_control *ctl)
        if (!itr)
                err(MNT_EX_FAIL, _("failed to initialize libmount iterator"));
 
+       /* Remove useless entries and canonicalize the table */
        while (mnt_table_next_fs(tab, itr, &fs) == 0) {
                const char *src = mnt_fs_get_srcpath(fs),
                           *tgt = mnt_fs_get_target(fs);
@@ -304,15 +305,13 @@ static int fstrim_all(struct fstrim_control *ctl)
                        continue;
                }
        }
-       mnt_free_iter(itr);
 
        /* de-duplicate by source */
        mnt_table_uniq_fs(tab, MNT_UNIQ_FORWARD, uniq_fs_source_cmp);
 
-       itr = mnt_new_iter(MNT_ITER_BACKWARD);
-       if (!itr)
-               err(MNT_EX_FAIL, _("failed to initialize libmount iterator"));
+       mnt_reset_iter(itr, MNT_ITER_BACKWARD);
 
+       /* Do FITRIM */
        while (mnt_table_next_fs(tab, itr, &fs) == 0) {
                const char *src = mnt_fs_get_srcpath(fs),
                           *tgt = mnt_fs_get_target(fs);
@@ -328,7 +327,7 @@ static int fstrim_all(struct fstrim_control *ctl)
                if (rc)
                        continue;       /* overlaying mount */
 
-               /* FSTRIM on read-only filesystem can fail, and it can fail */
+               /* FITRIM on read-only filesystem can fail, and it can fail */
                if (access(path, W_OK) != 0) {
                        if (errno == EROFS)
                                continue;