/* This is the create() entry in the inode_operations structure for regular HFS directories. The purpose is to create a new file in a directory and return a corresponding inode, given the inode for the directory and the name (and its length) of the new file.  */
static int hfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd)
/* This is the create() entry in the inode_operations structure for regular HFS directories. The purpose is to create a new file in a directory and return a corresponding inode, given the inode for the directory and the name (and its length) of the new file.  */
static int hfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd)
{
	struct inode *inode;
	int res;
	inode = hfs_new_inode(dir, &dentry->d_name, mode);
	if (!inode)
		return -ENOSPC;
	res = hfs_cat_create(inode->i_ino, dir, &dentry->d_name, inode);
	if (res) {
		inode->i_nlink = 0;
		hfs_delete_inode(inode);
		iput(inode);
		return res;
	}
	d_instantiate(dentry, inode);
	mark_inode_dirty(inode);
	return 0;
}