Because we run the external fstrim command we don't have access to the
kernel errno when it fails. However in the case where it prints this
specific error message, turn that into errno ENOTSUP.
---
daemon/fstrim.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/daemon/fstrim.c b/daemon/fstrim.c
index 1ad3630..527acfd 100644
--- a/daemon/fstrim.c
+++ b/daemon/fstrim.c
@@ -105,7 +105,13 @@ do_fstrim (const char *path,
r = commandv (&out, &err, argv);
if (r == -1) {
- reply_with_error ("%s", err);
+ /* If the error is about the kernel operation not being supported
+ * for this filesystem type, then return errno ENOTSUP here.
+ */
+ if (strstr (err, "discard operation is not supported"))
+ reply_with_error_errno (ENOTSUP, "%s", err);
+ else
+ reply_with_error ("%s", err);
return -1;
}
--
2.7.4