aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/root-tree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-11-17 21:14:24 -0500
committerChris Mason <chris.mason@oracle.com>2008-11-17 21:14:24 -0500
commitea9e8b11bd1252dcbc23afefcf1a52ec6aa3c113 (patch)
tree3573c8d79e1936e8c921a3be77abda35124e0d78 /fs/btrfs/root-tree.c
parent0660b5af3f7ac0fac69de975914e1f4a3a586fb3 (diff)
Btrfs: prevent loops in the directory tree when creating snapshots
For a directory tree: /mnt/subvolA/subvolB btrfsctl -s /mnt/subvolA/subvolB /mnt Will create a directory loop with subvolA under subvolB. This commit uses the forward refs for each subvol and snapshot to error out before creating the loop. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/root-tree.c')
-rw-r--r--fs/btrfs/root-tree.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index e9be3abcb368..dbe20d4c6ea4 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -300,6 +300,22 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans,
300 return ret; 300 return ret;
301} 301}
302 302
303int btrfs_find_root_ref(struct btrfs_root *tree_root,
304 struct btrfs_path *path,
305 u64 root_id, u64 ref_id)
306{
307 struct btrfs_key key;
308 int ret;
309
310 key.objectid = root_id;
311 key.type = BTRFS_ROOT_REF_KEY;
312 key.offset = ref_id;
313
314 ret = btrfs_search_slot(NULL, tree_root, &key, path, 0, 0);
315 return ret;
316}
317
318
303/* 319/*
304 * add a btrfs_root_ref item. type is either BTRFS_ROOT_REF_KEY 320 * add a btrfs_root_ref item. type is either BTRFS_ROOT_REF_KEY
305 * or BTRFS_ROOT_BACKREF_KEY. 321 * or BTRFS_ROOT_BACKREF_KEY.