/* Note that this function destroys the original nameidata  */
struct file* nameidata_to_filp(struct nameidata *nd)
/* Note that this function destroys the original nameidata  */
struct file* nameidata_to_filp(struct nameidata *nd)
{
	const struct cred *cred = current_cred();
	struct file *filp;
	filp = nd->intent.open.file;
	if (filp->f_path.dentry == NULL)
		filp = __dentry_open(nd->path.dentry, nd->path.mnt, filp,
				     NULL, cred);
	else
		path_put(&nd->path);
	return filp;
}