You are looking for the filp_open function. From include/linux/fs.h :
struct file *filp_open(const char *filename, int flags, umode_t mode);
Here is a link to the source and function documentation: http://lxr.free-electrons.com/source/fs/open.c#L937
If you really need FD, you can use sys_open (not exported to newer kernels):
long sys_open(const char __user *filename, int flags, int mode);
You can find a very good answer on a similar question: How to read / write files in the Linux kernel module?
Edit (how to get inode ):
You can get the cached inode from the struct file :
struct file *file = ...; struct inode *inode = file->inode;
If you want it with a lock: here is the background: Documentation/filesystems/path-lookup.txt
The starting point for the move is current->fs->root . There are a number of functions in the kernel that already do the work, you can find them in the source file fs/namei.c .
There is a function: kern_path :
int error; struct inode *inode; struct path path; error = kern_path(pathname, LOOKUP_FOLLOW, &path); if (error) ...; inode = path.dentry->d_inode;
source share