def rmdir(self, parent_inode, name, ctx):
assert self._initialized
assert_or_errno(self.access(parent_inode, WX_OK, ctx),
EPERM, 'no wx perm to parent inode')
pn = self.forest.inodes.get_by_value(parent_inode)
n = self._lookup(pn, name, ctx)
assert_or_errno(n, ENOENT, 'no entry in tree')
try:
assert_or_errno(n.leaf_node.is_dir, ENOENT, 'non-directory target')
self._ctx_sticky_mutate_check(ctx, pn, n)
assert_or_errno(not n.node.children, ENOTEMPTY)
n.leaf_node.root.remove_from_tree(n.leaf_node)
pn.change_times()
# TBD: Also check the subdir permission?
finally:
n.deref()
评论列表
文章目录