/* * hfs_remove() * * This serves as both unlink() and rmdir() in the inode_operations * structure for regular HFS directories. The purpose is to delete * an existing child, given the inode for the parent directory and * the name (and its length) of the existing directory. * * HFS does not have hardlinks, so both rmdir and unlink set the * link count to 0. The only difference is the emptiness check. */ static int hfs_remove(struct inode *dir, struct dentry *dentry) { struct inode *inode = dentry->d_inode; int res; if (S_ISDIR(inode->i_mode) && inode->i_size != 2) return -ENOTEMPTY; res = hfs_cat_delete(inode->i_ino, dir, &dentry->d_name); if (res) return res; clear_nlink(inode); inode->i_ctime = CURRENT_TIME_SEC; hfs_delete_inode(inode); mark_inode_dirty(inode); return 0; }
/* * hfs_rmdir() * * This is the rmdir() entry in the inode_operations structure for * regular HFS directories. The purpose is to delete an existing * directory, given the inode for the parent directory and the name * (and its length) of the existing directory. */ int hfs_rmdir(struct inode *dir, struct dentry *dentry) { struct inode *inode; int res; inode = dentry->d_inode; if (inode->i_size != 2) return -ENOTEMPTY; res = hfs_cat_delete(inode->i_ino, dir, &dentry->d_name); if (res) return res; inode->i_nlink = 0; inode->i_ctime = CURRENT_TIME; hfs_delete_inode(inode); mark_inode_dirty(inode); return 0; }
/* * hfs_unlink() * * This is the unlink() entry in the inode_operations structure for * regular HFS directories. The purpose is to delete an existing * file, given the inode for the parent directory and the name * (and its length) of the existing file. */ int hfs_unlink(struct inode *dir, struct dentry *dentry) { struct inode *inode; int res; inode = dentry->d_inode; res = hfs_cat_delete(inode->i_ino, dir, &dentry->d_name); if (res) return res; inode->i_nlink--; hfs_delete_inode(inode); inode->i_ctime = CURRENT_TIME; mark_inode_dirty(inode); return res; }