Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int unlink_file(const char * req_path)
- {
- int length;
- char file_path[256];
- char file_dir[256];
- struct file * target;
- struct file * path;
- struct inode *delegated_inode;
- int i;
- length = strlen(req_path);
- memcpy(file_path, req_path, length + 1);
- memcpy(file_dir, req_path, length + 1);
- target = filp_open(file_path, O_RDONLY, 0600);
- if (!target)
- return 0; /* file not found */
- for (i = length; i > 0; i--)
- {
- if (file_dir[i] == '/')
- {
- *(char **)(&(file_dir[i + 1])) = (char *)0x00;
- break;
- }
- }
- if (!i) return -1; /* dir err */
- path = filp_open(file_dir, O_RDONLY, 0600);
- if (!path) return -2;
- vfs_unlink(path->f_path.dentry->d_inode, target->f_path.dentry, &delegated_inode); //TODO: check response
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement