I know this is strongly not recommended. But does is possible to do this in kernel space.
Given the file path, can we remove the corresponding file in kernel space?
I know this is strongly not recommended. But does is possible to do this in kernel space.
Given the file path, can we remove the corresponding file in kernel space?
Maybe it's too late, I'll try to reply. As Tsyvarev said in his comment probably you are looking for the vfs_unlink function that you can find here namei.c. Before the implementation there is a description, but a simple example can be this one /* fcheck's prototype is in linux/fdtable.h and returns a file pointer given a given a file descriptor */
struct file *filp= fcheck(fd);
struct inode *parent_inode = filp->f_path.dentry->d_parent->d_inode;
inode_lock(parent_inode);
vfs_unlink(parent_inode, filp->f_path.dentry, NULL);
inode_unlock(parent_inode);
I hope it's can be useful to someone.