[PATCH] libext2fs: don't flush to device opened in read-only mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Konstantin Chistyakov <Konstantin.Chistyakov@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 19 May 2017 09:23:29 -0600
Subject: [PATCH] libext2fs: don't flush to device opened in read-only mode

From: Konstantin Chistyakov <Konstantin.Chistyakov@xxxxxxxxxxxxxxxxxxxx>

If the e2fsck is called with both -f -n options, the checking completing with a flushing error (retcode 8).

Catch error from the unix_flush() fsync(data->dev) when data->dev is opened in read-only mode:

...
e2fsck -n -f /dev/sdd1
e2fsck 1.43.4 (31-Jan-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Error flushing writes to storage device: Permission denied

---
lib/ext2fs/unix_io.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'lib/ext2fs/unix_io.c')

diff -up lib/ext2fs/unix_io.c{.orig,}
--- lib/ext2fs/unix_io.c.orig        2017-05-19 14:32:12.550414900 +0300
+++ lib/ext2fs/unix_io.c              2017-05-19 14:33:48.520878000 +0300
@@ -1030,7 +1030,7 @@ static errcode_t unix_flush(io_channel channel)
#ifndef NO_IO_CACHE
 	retval = flush_cached_blocks(channel, data, 0);
#endif
-	if (!retval && fsync(data->dev) != 0)
+	if (!retval && (data->flags & IO_FLAG_RW) && fsync(data->dev) != 0)
 		return errno;
 	return retval;
}





[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux