

---

 fs/ecryptfs/inode.c            |    0 
 lxc-dave/fs/namei.c            |   13 +++++++++----
 lxc-dave/fs/namespace.c        |    1 +
 lxc-dave/include/linux/mount.h |   21 +++++++++++++++++++++
 4 files changed, 31 insertions(+), 4 deletions(-)

diff -puN fs/hpfs/namei.c~convert-permission-to-file-and-vfs fs/hpfs/namei.c
diff -puN fs/namei.c~convert-permission-to-file-and-vfs fs/namei.c
--- lxc/fs/namei.c~convert-permission-to-file-and-vfs	2006-06-01 14:26:40.000000000 -0700
+++ lxc-dave/fs/namei.c	2006-06-01 15:55:35.000000000 -0700
@@ -2010,10 +2010,15 @@ static long do_rmdir(int dfd, const char
 	mutex_lock(&nd.dentry->d_inode->i_mutex);
 	dentry = lookup_hash(&nd);
 	error = PTR_ERR(dentry);
-	if (!IS_ERR(dentry)) {
-		error = vfs_rmdir(nd.dentry->d_inode, dentry);
-		dput(dentry);
-	}
+	if (IS_ERR(dentry))
+		goto exit2;
+	if (!mnt_want_write(nd.mnt))
+		goto exit3;
+	error = vfs_rmdir(nd.dentry->d_inode, dentry);
+	mnt_drop_write(nd.mnt);
+exit3:
+	dput(dentry);
+exit2:
 	mutex_unlock(&nd.dentry->d_inode->i_mutex);
 exit1:
 	path_release(&nd);
diff -puN security/selinux/hooks.c~convert-permission-to-file-and-vfs security/selinux/hooks.c
diff -puN include/linux/mount.h~convert-permission-to-file-and-vfs include/linux/mount.h
--- lxc/include/linux/mount.h~convert-permission-to-file-and-vfs	2006-06-01 14:26:40.000000000 -0700
+++ lxc-dave/include/linux/mount.h	2006-06-01 15:55:50.000000000 -0700
@@ -38,6 +38,7 @@ struct vfsmount {
 	struct list_head mnt_mounts;	/* list of children, anchored here */
 	struct list_head mnt_child;	/* and going through their mnt_child */
 	atomic_t mnt_count;
+	atomic_t writer_count;
 	int mnt_flags;
 	int mnt_expiry_mark;		/* true if marked for expiry */
 	char *mnt_devname;		/* Name of device e.g. /dev/dsk/hda1 */
@@ -58,6 +59,26 @@ static inline struct vfsmount *mntget(st
 	return mnt;
 }
 
+static inline int mnt_readonly(struct vfsmount *mnt)
+{
+	if (mnt->mnt_sb->s_flags & MS_RDONLY)
+		return -EROFS;
+	return 0;
+}
+
+static inline int mnt_want_write(struct vfsmount *mnt)
+{
+	if (mnt_readonly(mnt))
+		return -EROFS;
+	atomic_inc(&mnt->mnt_writers);
+	return 0;
+}
+
+static inline int mnt_drop_write(struct vfsmount *mnt)
+{
+	atomic_dec(&mnt->mnt_writers);
+}
+
 extern void mntput_no_expire(struct vfsmount *mnt);
 extern void mnt_pin(struct vfsmount *mnt);
 extern void mnt_unpin(struct vfsmount *mnt);
diff -puN fs/namespace.c~convert-permission-to-file-and-vfs fs/namespace.c
--- lxc/fs/namespace.c~convert-permission-to-file-and-vfs	2006-06-01 14:26:40.000000000 -0700
+++ lxc-dave/fs/namespace.c	2006-06-01 14:26:40.000000000 -0700
@@ -66,6 +66,7 @@ struct vfsmount *alloc_vfsmnt(const char
 	if (mnt) {
 		memset(mnt, 0, sizeof(struct vfsmount));
 		atomic_set(&mnt->mnt_count, 1);
+		/* atomic_set(&mnt->writer_count, 0); */
 		INIT_LIST_HEAD(&mnt->mnt_hash);
 		INIT_LIST_HEAD(&mnt->mnt_child);
 		INIT_LIST_HEAD(&mnt->mnt_mounts);
diff -puN fs/ecryptfs/inode.c~convert-permission-to-file-and-vfs fs/ecryptfs/inode.c
_
