int remove_file(char *filename)
{
char *filename = NULL;
int ret = 0;
struct nameidata nd;
struct dentry *dentry;
ret = path_lookup(filename, LOOKUP_PARENT, &nd);
if (ret != 0)
{
return -ENOENT;
}
dentry = lookup_one_len(nd.last.name, nd.path.dentry, strlen(nd.last.name));
if (IS_ERR(dentry))
{
path_release(&nd);
return -EACCES;
}
vfs_unlink(nd.path.dentry->d_inode, dentry);
dput(dentry);
//path_release(&nd);
return 0;
}
同理可调用vfs_rmdir删除空目录
阅读(5050) | 评论(1) | 转发(0) |