Hi i am having some trouble using sys_open.At this point i am starting to think that i am doing something wrong with the arguments of the functions. An example of how i use it:
fd = sys_open("file.txt" , O_WRONLY | O_CREAT, 0);
sys_write(fd, "test\n", strlen("test\n"));
sys_fsync(fd);
sys_fdatasync(fd);
sys_close(fd);
fd value is a non negative integer (0). Every single one of the functions returns 0 so i guess they are executed corectly.Except sys_write. Every time that i go to find the file after i write on it i can never find it any idea maybe something on my code is wrong?
The sys_
family of functions for Linux are considered deprecated now . However, for the purposes of this question, sys_open
is a user-level function that calls the open
syscall, which then calls the kernel level do_sys_open()
, the latter two defined in fs/open.c
. So to open files from within the kernel you should stick to kernel level functions and not user-level functions.
Here are some answers about opening files at the kernel level, some of which are deprecated as well, so be aware.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.