Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Christian Parpart <trapni@gentoo.org>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] deny sys_{rename,link} across subvolumes of same disk
Date: Thu, 9 Oct 2008 03:40:50 +0200	[thread overview]
Message-ID: <200810090340.50462.trapni@gentoo.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]

This patch denies renames and linking of inodes across subvolumes, as it 
causes disk format corruption.

I guess a long-term goal *might* be to just handle these special cases with 
care, to allow them by properly handling this case in the implementation, 
however, I wasn't unable to do that with my limited knowledge.

Best regards,
Christian Parpart.



[-- Attachment #2: cross-subvol-change-fix.diff --]
[-- Type: text/x-patch, Size: 842 bytes --]

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ff0c359..20a3772 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2748,6 +2748,10 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
 	if (inode->i_nlink == 0)
 		return -ENOENT;
 
+	/* do not allow sys_link's with other subvols of the same device */
+	if (root->objectid != BTRFS_I(inode)->root->objectid)
+		return -EPERM;
+
 	btrfs_inc_nlink(inode);
 	err = btrfs_check_free_space(root, 1, 0);
 	if (err)
@@ -3577,6 +3581,10 @@ static int btrfs_rename(struct inode * old_dir, struct dentry *old_dentry,
 		return -ENOTEMPTY;
 	}
 
+	/* do not allow sys_rename's with other subvols of the same device */
+	if (root->objectid != BTRFS_I(new_dir)->root->objectid)
+		return -EPERM;
+
 	ret = btrfs_check_free_space(root, 1, 0);
 	if (ret)
 		goto out_unlock;

             reply	other threads:[~2008-10-09  1:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-09  1:40 Christian Parpart [this message]
2008-10-09  5:55 ` [PATCH] deny sys_{rename,link} across subvolumes of same disk Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200810090340.50462.trapni@gentoo.org \
    --to=trapni@gentoo.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox