Skip to contentSkip to conversation

don't rename file into dummy directory

PATCH New Yan, Zheng 1 participant 1 message Sep 24, 2009 Btrfs file system

lore
Share & tools
lore

Yan, Zheng

author
#0 lore raw

PATCH 1/1 don't rename file into dummy directory

A recently change enforces there is only one access point to each subvolume. The first directory entry (the one added when the subvolume/snapshot was created) is treated as valid access point, all other subvolume links are linked to dummy empty directories. The dummy directories are temporary inodes that only in memory, so we can not rename file into them.

---

fs/btrfs/inode.c +3 -0
diff -urp 1/fs/btrfs/inode.c 2/fs/btrfs/inode.c
@@ -5057,6 +5057,9 @@ static int btrfs_rename(struct inode *ol
 	u64 root_objectid;
 	int ret;
 
+	if (new_dir->i_ino == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)
+		return -EPERM;
+
 	/* we only allow rename subvolume link between subvolumes */
 	if (old_inode->i_ino != BTRFS_FIRST_FREE_OBJECTID && root != dest)
 		return -EXDEV;