<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">

---

 include/linux/namei.h |    0 
 lxc-dave/fs/namei.c   |   29 +++++++++++++++++++++--------
 2 files changed, 21 insertions(+), 8 deletions(-)

diff -puN fs/namei.c~elevate-writers0 fs/namei.c
--- lxc/fs/namei.c~elevate-writers0	2006-06-01 14:26:43.000000000 -0700
+++ lxc-dave/fs/namei.c	2006-06-01 14:26:43.000000000 -0700
@@ -2007,6 +2007,9 @@ static long do_rmdir(int dfd, const char
 			error = -EBUSY;
 			goto exit1;
 	}
+	error = -EROFS;
+	if (nd_is_readonly(&amp;nd))
+		goto exit1;
 	mutex_lock(&amp;nd.dentry-&gt;d_inode-&gt;i_mutex);
 	dentry = lookup_hash(&amp;nd);
 	error = PTR_ERR(dentry);
@@ -2081,6 +2084,8 @@ static long do_unlinkat(int dfd, const c
 	error = -EISDIR;
 	if (nd.last_type != LAST_NORM)
 		goto exit1;
+	if (nd_is_readonly(&amp;nd))
+		goto exit1;
 	mutex_lock(&amp;nd.dentry-&gt;d_inode-&gt;i_mutex);
 	dentry = lookup_hash(&amp;nd);
 	error = PTR_ERR(dentry);
@@ -2456,16 +2461,21 @@ static int do_rename(int olddfd, const c
 	if (newnd.last_type != LAST_NORM)
 		goto exit2;
 
+	if (!mnt_want_write(oldnd.mnt))
+		goto exit2;
+	if (!mnt_want_write(newnd.mnt))
+		goto exit3;
+
 	trap = lock_rename(new_dir, old_dir);
 
 	old_dentry = lookup_hash(&amp;oldnd);
 	error = PTR_ERR(old_dentry);
 	if (IS_ERR(old_dentry))
-		goto exit3;
+		goto exit4;
 	/* source must exist */
 	error = -ENOENT;
 	if (!old_dentry-&gt;d_inode)
-		goto exit4;
+		goto exit5;
 	/* unless the source is a directory trailing slashes give -ENOTDIR */
 	if (!S_ISDIR(old_dentry-&gt;d_inode-&gt;i_mode)) {
 		error = -ENOTDIR;
@@ -2477,24 +2487,27 @@ static int do_rename(int olddfd, const c
 	/* source should not be ancestor of target */
 	error = -EINVAL;
 	if (old_dentry == trap)
-		goto exit4;
+		goto exit5;
 	new_dentry = lookup_hash(&amp;newnd);
 	error = PTR_ERR(new_dentry);
 	if (IS_ERR(new_dentry))
-		goto exit4;
+		goto exit5;
 	/* target should not be an ancestor of source */
 	error = -ENOTEMPTY;
 	if (new_dentry == trap)
-		goto exit5;
+		goto exit6;
 
 	error = vfs_rename(old_dir-&gt;d_inode, old_dentry,
 				   new_dir-&gt;d_inode, new_dentry);
-exit5:
+exit6:
 	dput(new_dentry);
-exit4:
+exit5:
 	dput(old_dentry);
-exit3:
+exit4:
+	mnt_drop_write(newnd.mnt);
 	unlock_rename(new_dir, old_dir);
+exit3:
+	mnt_drop_write(oldnd.mnt);
 exit2:
 	path_release(&amp;newnd);
 exit1:
diff -puN include/linux/namei.h~elevate-writers0 include/linux/namei.h
_
</pre></body></html>