File util-linux-fstrim-A-4.patch of Package util-linux

From 6466959d9af04a2f720374839c6ecf89de02f4b6 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 11 Jun 2019 11:05:12 +0200
Subject: [PATCH 4/4] fstrim: update man page, reuse libmnt_iter

* 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.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Index: util-linux-2.33.1/sys-utils/fstrim.c
===================================================================
--- util-linux-2.33.1.orig/sys-utils/fstrim.c
+++ util-linux-2.33.1/sys-utils/fstrim.c
@@ -244,6 +244,7 @@ static int fstrim_all(struct fstrim_cont
 	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);
@@ -270,15 +271,13 @@ static int fstrim_all(struct fstrim_cont
 			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);
@@ -294,7 +293,7 @@ static int fstrim_all(struct fstrim_cont
 		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;
openSUSE Build Service is sponsored by