Home
last modified time | relevance | path

Searched refs:fd (Results 1 – 25 of 25) sorted by relevance

/DragonOS-0.1.8/user/libs/libc/src/
Ddirent.c18 int fd = open(path, O_DIRECTORY); in opendir() local
19 if (fd < 0) // 目录打开失败 in opendir()
30 dirp->fd = fd; in opendir()
52 int retval = close(dirp->fd); in closedir()
57 int64_t getdents(int fd, struct dirent *dirent, long count) in getdents() argument
59 return syscall_invoke(SYS_GET_DENTS, fd, (uint64_t)dirent, count, 0, 0, 0, 0, 0); in getdents()
72 int len = getdents(dir->fd, (struct dirent *)dir->buf, DIR_BUF_SIZE); in readdir()
Dunistd.c15 int close(int fd) in close() argument
17 return syscall_invoke(SYS_CLOSE, fd, 0, 0, 0, 0, 0, 0, 0); in close()
28 ssize_t read(int fd, void *buf, size_t count) in read() argument
30 return (ssize_t)syscall_invoke(SYS_READ, fd, (uint64_t)buf, count, 0, 0, 0, 0, 0); in read()
41 ssize_t write(int fd, void const *buf, size_t count) in write() argument
43 return (ssize_t)syscall_invoke(SYS_WRITE, fd, (uint64_t)buf, count, 0, 0, 0, 0, 0); in write()
54 off_t lseek(int fd, off_t offset, int whence) in lseek() argument
56 return (off_t)syscall_invoke(SYS_LSEEK, fd, offset, whence, 0, 0, 0, 0, 0); in lseek()
73 int pipe(int fd[2]) in pipe()
75 return (int)syscall_invoke(SYS_PIPE, fd, 0, 0, 0, 0, 0, 0, 0); in pipe()
[all …]
Dstdio.c24 write(stream->fd, buf, len); in fprintf()
57 int retval = close(stream->fd); in fclose()
60 if (stream->fd >= 3) in fclose()
87 int fd = open(pathname, o_flags); in fopen() local
88 if (fd >= 0) in fopen()
89 stream->fd = fd; in fopen()
Dlibc_init.c15 stdin->fd = 0; in _libc_init()
16 stdout->fd = 1; in _libc_init()
17 stderr->fd = 2; in _libc_init()
/DragonOS-0.1.8/user/apps/shell/
Dcmd_test.c12 int fd[2], i, n; in shell_pipe_test() local
15 int ret = pipe(fd); // 创建一个管道 in shell_pipe_test()
29 close(fd[1]); // 关闭管道的写端 in shell_pipe_test()
33 n = read(fd[0], buf, buf_SIZE); // 从管道的读端读取一条消息 in shell_pipe_test()
50 close(fd[0]); // 关闭管道的读端 in shell_pipe_test()
55 close(fd[0]); // 关闭管道的读端 in shell_pipe_test()
72 write(fd[1], msg, n); // 向管道的写端写入一条消息 in shell_pipe_test()
79 close(fd[1]); // 关闭管道的写端 in shell_pipe_test()
Dcmd.c322 int fd = open(file_path, 0); in shell_cmd_cat() local
323 if (fd <= 0) in shell_cmd_cat()
325 printf("ERROR: Cannot open file: %s, fd=%d\n", file_path, fd); in shell_cmd_cat()
329 int file_size = lseek(fd, 0, SEEK_END); in shell_cmd_cat()
331 lseek(fd, 0, SEEK_SET); in shell_cmd_cat()
338 int l = read(fd, buf, 511); in shell_cmd_cat()
349 close(fd); in shell_cmd_cat()
378 int fd = open(file_path, O_CREAT); in shell_cmd_touch() local
379 switch (fd) in shell_cmd_touch()
388 close(fd); in shell_cmd_touch()
Dshell.c22 int shell_readline(int fd, char *buf);
152 int shell_readline(int fd, char *buf) in shell_readline() argument
/DragonOS-0.1.8/user/libs/libc/src/include/export/
Dunistd.h15 int close(int fd);
25 ssize_t read(int fd, void *buf, size_t count);
35 ssize_t write(int fd, void const *buf, size_t count);
45 off_t lseek(int fd, off_t offset, int whence);
131 int dup(int fd);
Ddirent.h67 int fd; member
Dstdio.h32 int fd; // 文件描述符 member
/DragonOS-0.1.8/user/libs/libKeyboard/
Dkeyboard.c291 int keyboard_analyze_keycode(int fd) in keyboard_analyze_keycode() argument
295 int c = keyboard_get_scancode(fd); in keyboard_analyze_keycode()
308 if (keyboard_get_scancode(fd) != pause_break_scan_code[i]) in keyboard_analyze_keycode()
317 scancode = keyboard_get_scancode(fd); in keyboard_analyze_keycode()
321 if (keyboard_get_scancode(fd) == 0xe0) in keyboard_analyze_keycode()
322 if (keyboard_get_scancode(fd) == 0x37) in keyboard_analyze_keycode()
329 if (keyboard_get_scancode(fd) == 0xe0) in keyboard_analyze_keycode()
330 if (keyboard_get_scancode(fd) == 0xaa) in keyboard_analyze_keycode()
528 int keyboard_get_scancode(int fd) in keyboard_get_scancode() argument
531 read(fd, &ret, 1); in keyboard_get_scancode()
Dkeyboard.h16 int keyboard_get_scancode(int fd);
22 int keyboard_analyze_keycode(int fd);
/DragonOS-0.1.8/docs/userland/libc/apis/api-list/
Dunistd.md9 ``int close(int fd)`` : 关闭文件
11 ``ssize_t read(int fd,void *buf,size_t count)`` : 从文件读取
17 ``ssize_t write(int fd,void const *buf,size_t count)`` : 写入文件
23 ``off_t lseek(int fd,off_t offset,int whence)`` : 调整文件访问位置
31 ``pid_t vfork(void)`` : fork 当前进程,与父进程共享 VM,flags,fd
Ddirent.md11 ``int fd`` : 文件夹id(不推荐修改)
/DragonOS-0.1.8/user/apps/test_fstat/
Dmain.c10 int fd = open("/bin/about.elf", O_RDONLY); in main() local
11 if (fd == -1) in main()
13 printf("fd = %d\n", fd); in main()
15 fstat(fd, st); in main()
/DragonOS-0.1.8/kernel/src/filesystem/vfs/
Dsyscall.rs184 let r = current_pcb().alloc_fd(file, None).map(|fd| fd as usize); in open()
194 pub fn close(fd: usize) -> Result<usize, SystemError> { in close()
196 return current_pcb().drop_fd(fd as i32).map(|_| 0); in close()
206 pub fn read(fd: i32, buf: &mut [u8]) -> Result<usize, SystemError> { in read()
208 let file: Option<&mut File> = current_pcb().get_file_mut_by_fd(fd); in read()
224 pub fn write(fd: i32, buf: &[u8]) -> Result<usize, SystemError> { in write()
226 let file: Option<&mut File> = current_pcb().get_file_mut_by_fd(fd); in write()
242 pub fn lseek(fd: i32, seek: SeekFrom) -> Result<usize, SystemError> { in lseek()
244 let file: Option<&mut File> = current_pcb().get_file_mut_by_fd(fd); in lseek()
308 pub fn getdents(fd: i32, buf: &mut [u8]) -> Result<usize, SystemError> { in getdents()
[all …]
Dfile.rs434 pub fn validate_fd(fd: i32) -> bool { in validate_fd()
435 if fd < 0 || fd as usize > FileDescriptorVec::PROCESS_MAX_FD { in validate_fd()
/DragonOS-0.1.8/kernel/src/process/
Dprocess.rs189 pub fn alloc_fd(&mut self, file: File, fd: Option<i32>) -> Result<i32, SystemError> { in alloc_fd()
206 if fd.is_some() { in alloc_fd()
208 let new_fd = fd.unwrap(); in alloc_fd()
235 pub fn get_file_mut_by_fd(&self, fd: i32) -> Option<&mut File> { in get_file_mut_by_fd()
236 if !FileDescriptorVec::validate_fd(fd) { in get_file_mut_by_fd()
240 return r.fds[fd as usize].as_deref_mut(); in get_file_mut_by_fd()
249 pub fn get_file_ref_by_fd(&self, fd: i32) -> Option<&File> { in get_file_ref_by_fd()
250 if !FileDescriptorVec::validate_fd(fd) { in get_file_ref_by_fd()
254 return r.fds[fd as usize].as_deref(); in get_file_ref_by_fd()
260 pub fn drop_fd(&self, fd: i32) -> Result<(), SystemError> { in drop_fd()
[all …]
Dprocess.c148 int fd = enter_syscall_int(SYS_OPEN, (uint64_t)path, O_RDONLY, 0, 0, 0, 0, 0, 0); in process_open_exec_file() local
149 return fd; in process_open_exec_file()
/DragonOS-0.1.8/user/apps/http_server/
Dmain.c76 int fd = open(path, 0); in send_file() local
77 if (fd == -1) in send_file()
85 int content_length = lseek(fd, 0, SEEK_END); in send_file()
88 lseek(fd, 0, SEEK_SET); in send_file()
97 readSize = read(fd, &buffer, to_read); in send_file()
107 close(fd); in send_file()
115 close(fd); in send_file()
/DragonOS-0.1.8/kernel/src/net/
Dsyscall.rs62 let fd = current_pcb().alloc_fd(f, None).map(|x| x as usize); in socket() localVariable
64 return fd; in socket()
75 fd: usize, in setsockopt()
81 .get_socket(fd as i32) in setsockopt()
98 fd: usize, in getsockopt()
107 .get_socket(fd as i32) in getsockopt()
167 pub fn connect(fd: usize, addr: *const SockAddr, addrlen: usize) -> Result<usize, SystemError> { in connect()
170 .get_socket(fd as i32) in connect()
185 pub fn bind(fd: usize, addr: *const SockAddr, addrlen: usize) -> Result<usize, SystemError> { in bind()
188 .get_socket(fd as i32) in bind()
[all …]
/DragonOS-0.1.8/user/libs/libc/src/include/export/sys/
Dstat.h28 int pipe(int *fd);
/DragonOS-0.1.8/tools/
Drun-qemu.sh97 sudo ${QEMU} -bios arch/x86_64/efi/OVMF-pure-efi.fd ${QEMU_ARGUMENT}
99 sudo ${QEMU} -bios arch/i386/efi/OVMF-pure-efi.fd ${QEMU_ARGUMENT}
/DragonOS-0.1.8/kernel/src/syscall/
Dmod.rs429 let fd = args[0]; in handle() localVariable
430 Self::close(fd) in handle()
433 let fd = args[0] as i32; in handle() localVariable
446 Self::read(fd, buf) in handle()
452 let fd = args[0] as i32; in handle() localVariable
465 Self::write(fd, buf) in handle()
474 let fd = args[0] as i32; in handle() localVariable
490 Self::lseek(fd, w) in handle()
543 let fd = args[0] as i32; in handle() localVariable
557 Self::getdents(fd, buf) in handle()
[all …]
/DragonOS-0.1.8/kernel/src/ipc/
Dsyscall.rs30 pub fn pipe(fd: &mut [i32]) -> Result<usize, SystemError> { in pipe()
38 fd[0] = read_fd; in pipe()
39 fd[1] = write_fd; in pipe()