return ret;
}
-/* copy of may_delete in fs/namei.c()
- * Check whether we can remove a link victim from directory dir, check
- * whether the type of victim is right.
- * 1. We can't do it if dir is read-only (done in permission())
- * 2. We should have write and exec permissions on dir
- * 3. We can't remove anything from append-only dir
- * 4. We can't do anything with immutable dir (done in permission())
- * 5. If the sticky bit on dir is set we should either
- * a. be owner of dir, or
- * b. be owner of victim, or
- * c. have CAP_FOWNER capability
- * 6. If the victim is append-only or immutable we can't do anything with
- * links pointing to it.
- * 7. If we were asked to remove a directory and victim isn't one - ENOTDIR.
- * 8. If we were asked to remove a non-directory and victim isn't one - EISDIR.
- * 9. We can't remove a root or mountpoint.
- * 10. We don't allow removal of NFS sillyrenamed files; it's handled by
- * nfs_async_unlink().
- */
-
-static int btrfs_may_delete(struct mnt_idmap *idmap,
- struct inode *dir, struct dentry *victim, int isdir)
-{
- int ret;
-
- if (d_really_is_negative(victim))
- return -ENOENT;
-
- /* The @victim is not inside @dir. */
- if (d_inode(victim->d_parent) != dir)
- return -EINVAL;
- audit_inode_child(dir, victim, AUDIT_TYPE_CHILD_DELETE);
-
- ret = inode_permission(idmap, dir, MAY_WRITE | MAY_EXEC);
- if (ret)
- return ret;
- if (IS_APPEND(dir))
- return -EPERM;
- if (check_sticky(idmap, dir, d_inode(victim)) ||
- IS_APPEND(d_inode(victim)) || IS_IMMUTABLE(d_inode(victim)) ||
- IS_SWAPFILE(d_inode(victim)))
- return -EPERM;
- if (isdir) {
- if (!d_is_dir(victim))
- return -ENOTDIR;
- if (IS_ROOT(victim))
- return -EBUSY;
- } else if (d_is_dir(victim))
- return -EISDIR;
- if (IS_DEADDIR(dir))
- return -ENOENT;
- if (victim->d_flags & DCACHE_NFSFS_RENAMED)
- return -EBUSY;
- return 0;
-}
-
/* copy of may_create in fs/namei.c() */
static inline int btrfs_may_create(struct mnt_idmap *idmap,
struct inode *dir, const struct dentry *child)
}
/* check if subvolume may be deleted by a user */
- ret = btrfs_may_delete(idmap, dir, dentry, 1);
+ ret = may_delete_dentry(idmap, dir, dentry, true);
if (ret)
goto out_end_removing;