summaryrefslogtreecommitdiff
path: root/src/fstab-generator
diff options
context:
space:
mode:
Diffstat (limited to 'src/fstab-generator')
-rw-r--r--src/fstab-generator/fstab-generator.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 2c38ab977c..5569325a16 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -73,6 +73,8 @@ static int mount_find_pri(struct mntent *me, int *ret) {
static int add_swap(const char *what, struct mntent *me) {
_cleanup_free_ char *name = NULL, *unit = NULL, *lnk = NULL;
_cleanup_fclose_ FILE *f = NULL;
+ char *discard = NULL;
+
bool noauto;
int r, pri = -1;
@@ -118,6 +120,14 @@ static int add_swap(const char *what, struct mntent *me) {
"What=%s\n",
what);
+ discard = mount_test_option(me->mnt_opts, "discard");
+ if (discard) {
+ discard = strpbrk(discard, "=");
+ fprintf(f,
+ "Discard=%s\n",
+ discard ? discard+1 : "all");
+ }
+
if (pri >= 0)
fprintf(f,
"Priority=%i\n",