int fs_rm (fs_t *fs, char *pathname) { // assert (fs != NULL); // assert (pathname != NULL); // parent not exists int parent = inode_lookup_parent (fs->super_block, pathname); if (parent < 0) return -1; // child not exists int child = inode_lookup_full (fs->super_block, pathname); if (child < 0) return -1; // child is non-empty dir if (inode_isdir (fs->super_block, child) && !inode_isdir_isempty (fs->super_block, child)) return -1; // child is empty-dir or child is reg file return inode_rm (fs->super_block, pathname); }
bool file_is_dir(struct file *file) { return inode_isdir(file->inode); }
int inode_isdir_isempty (super_block_t *sb, int index) { return sb->inodes[index].size == 0 && inode_isdir (sb, index); }