Commit 3bc19c2a authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] pipe.c: don't write to readonly filesystems

The pipe code's mtime and ctime updates are causing writes to read-only
mounted filesystems.

Fix that up by teaching inode_update_time() to honour readonly mounts, and
call it from the pipe code.
parent 03497495
...@@ -1148,9 +1148,14 @@ void update_atime(struct inode *inode) ...@@ -1148,9 +1148,14 @@ void update_atime(struct inode *inode)
void inode_update_time(struct inode *inode, int ctime_too) void inode_update_time(struct inode *inode, int ctime_too)
{ {
struct timespec now = current_kernel_time(); struct timespec now;
int sync_it = 0; int sync_it = 0;
if (IS_RDONLY(inode))
return;
now = current_kernel_time();
if (inode_times_differ(inode, &inode->i_mtime, &now)) if (inode_times_differ(inode, &inode->i_mtime, &now))
sync_it = 1; sync_it = 1;
inode->i_mtime = now; inode->i_mtime = now;
......
...@@ -208,10 +208,8 @@ pipe_write(struct file *filp, const char __user *buf, size_t count, loff_t *ppos ...@@ -208,10 +208,8 @@ pipe_write(struct file *filp, const char __user *buf, size_t count, loff_t *ppos
wake_up_interruptible(PIPE_WAIT(*inode)); wake_up_interruptible(PIPE_WAIT(*inode));
kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN); kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
} }
if (ret > 0) { if (ret > 0)
inode->i_ctime = inode->i_mtime = CURRENT_TIME; inode_update_time(inode, 1); /* mtime and ctime */
mark_inode_dirty(inode);
}
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment