Skip to contentSkip to conversation

e2fsprogs: open device writable for trim/discard

PATCH Applied Eric Sandeen 2 participants 2 messages Nov 17, 2009 – Nov 25, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 e2fsprogs: open device writable for trim/discard

Sorry about that, the discard ioctl doesn't actually work unless you open the file with write capabilities...

---

misc/mke2fs.c +1 -1
index 94b4c81..0aa31d8 100644
@@ -1877,7 +1877,7 @@ static void mke2fs_discard_blocks(ext2_filsys fs)
 	range[0] = 0;
 	range[1] = blocks * blocksize;
 
-	fd = open64(fs->device_name, O_RDONLY);
+	fd = open64(fs->device_name, O_RDWR);
 
 	/*
 	 * We don't care about whether the ioctl succeeds; it's only an
#1 lore raw
Quoted 2 lines · Eric Sandeen

Sorry about that, the discard ioctl doesn't actually work unless you open the file with write capabilities...

Applied, thanks.

- Ted