声明:syscalls.h
asmlinkage long sys_read(unsigned int fd, char __user *buf, size_t count);
定义:
syscalls.h
- C/C++ code
-
#define SYSCALL_DEFINEx(x, name, ...) \ asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__))
fs/read_write.c
- C/C++ code
-
SYSCALL_DEFINE3(read, unsigned int, fd, char __user *, buf, size_t, count) { struct file *file; ssize_t ret = -EBADF; int fput_needed; file = fget_light(fd, &fput_needed); if (file) { loff_t pos = file_pos_read(file); ret = vfs_read(file, buf, count, &pos); file_pos_write(file, pos); fput_light(file, fput_needed); } return ret; }
本文详细介绍了Linux系统中sys_read系统调用的实现原理。通过对syscalls.h中的声明和fs/read_write.c中的定义进行分析,展示了如何通过文件描述符读取数据,并解释了错误处理过程。
2万+

被折叠的 条评论
为什么被折叠?



