/DragonOS/user/apps/test_filemap/ |
H A D | main.c | 12 int fd = open("example.txt", O_RDWR | O_CREAT | O_TRUNC, 0777); in main() local 14 if (fd == -1) in main() 20 write(fd, "HelloWorld!", 11); in main() 23 close(fd); in main() 25 fd = open("example.txt", O_RDWR); in main() 26 read(fd, buf, 11); in main() 30 void *map = mmap(NULL, 11, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); in main() 34 close(fd); in main() 56 fd = open("example.txt", O_RDWR); in main() 57 read(fd, buf, 11); in main()
|
/DragonOS/user/apps/test_uart/ |
H A D | main.c | 8 int fd = open("/dev/char/uart:1088", O_WRONLY | O_NONBLOCK); in main() local 13 n = read(fd, buf, 1); in main() 14 close(fd); in main() 15 fd = open("/dev/char/uart:1088", O_WRONLY | O_NONBLOCK); in main() 23 printf("fd: %d", fd); in main() 26 int len = write(fd, str, strlen(str)); in main() 29 close(fd); in main()
|
/DragonOS/user/apps/test_dup3/ |
H A D | main.c | 6 int fd = open("/history_commands.txt", O_RDONLY); in main() local 7 if (fd < 0) { in main() 13 int rt = dup3(fd, new_fd, O_CLOEXEC); in main() 27 close(fd); in main()
|
/DragonOS/user/apps/test_fstat/ |
H A D | main.c | 9 int fd = open("/bin/about.elf", O_RDONLY); in main() local 10 if (fd == -1) in main() 12 printf("fd = %d\n", fd); in main() 14 fstat(fd, st); in main()
|
/DragonOS/user/apps/test_fstatfs/ |
H A D | main.c | 7 int fd = open("/bin/about.elf", O_RDONLY); in main() local 8 if (fd == -1) in main() 10 printf("fd = %d\n", fd); in main() 14 fstatfs(fd, &diskInfo); in main()
|
/DragonOS/user/apps/test_overlayfs/ |
H A D | main.c | 45 int fd = open(filepath, O_CREAT | O_WRONLY, 0644); in create_lower_file() local 46 if (fd < 0) in create_lower_file() 51 write(fd, "This is a lower layer file.\n", 28); in create_lower_file() 52 close(fd); in create_lower_file()
|
/DragonOS/user/apps/http_server/ |
H A D | main.c | 76 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/kernel/src/net/ |
H A D | syscall.rs | 52 let fd = fd_table_guard.alloc_fd(f, None).map(|x| x as usize); in socket() localVariable 54 return fd; in socket() 106 fd: usize, in setsockopt() 112 .get_socket(fd as i32) in setsockopt() 129 fd: usize, in getsockopt() 138 .get_socket(fd as i32) in getsockopt() 197 pub fn connect(fd: usize, addr: *const SockAddr, addrlen: usize) -> Result<usize, SystemError> { in connect() 200 .get_socket(fd as i32) in connect() 214 pub fn bind(fd: usize, addr: *const SockAddr, addrlen: usize) -> Result<usize, SystemError> { in bind() 217 .get_socket(fd as i32) in bind() [all …]
|
/DragonOS/kernel/src/filesystem/vfs/ |
H A D | syscall.rs | 526 pub fn close(fd: usize) -> Result<usize, SystemError> { in close() 529 let _file = fd_table_guard.drop_fd(fd as i32)?; in close() 541 pub fn ioctl(fd: usize, cmd: u32, data: usize) -> Result<usize, SystemError> { in ioctl() 546 .get_file_by_fd(fd as i32) in ioctl() 562 pub fn read(fd: i32, buf: &mut [u8]) -> Result<usize, SystemError> { in read() 566 let file = fd_table_guard.get_file_by_fd(fd); in read() 584 pub fn write(fd: i32, buf: &[u8]) -> Result<usize, SystemError> { in write() 589 .get_file_by_fd(fd) in write() 604 pub fn lseek(fd: i32, offset: i64, seek: u32) -> Result<usize, SystemError> { in lseek() 616 .get_file_by_fd(fd) in lseek() [all …]
|
H A D | file.rs | 692 for fd in &self.fds { in fd_open_count() 693 if fd.is_some() { in fd_open_count() 706 pub fn validate_fd(fd: i32) -> bool { in validate_fd() 707 return !(fd < 0 || fd as usize > FileDescriptorVec::PROCESS_MAX_FD); in validate_fd() 721 pub fn alloc_fd(&mut self, file: File, fd: Option<i32>) -> Result<i32, SystemError> { in alloc_fd() 722 if let Some(new_fd) = fd { in alloc_fd() 747 pub fn get_file_by_fd(&self, fd: i32) -> Option<Arc<File>> { in get_file_by_fd() 748 if !FileDescriptorVec::validate_fd(fd) { in get_file_by_fd() 751 self.fds[fd as usize].clone() in get_file_by_fd() 759 pub fn drop_fd(&mut self, fd: i32) -> Result<Arc<File>, SystemError> { in drop_fd() [all …]
|
H A D | open.rs | 139 pub fn ksys_fchown(fd: i32, uid: usize, gid: usize) -> Result<usize, SystemError> { in ksys_fchown() 143 let inode = fd_table.get_file_by_fd(fd).unwrap().inode(); in ksys_fchown() 235 .map(|fd| fd as usize); in do_sys_openat2()
|
/DragonOS/kernel/src/net/event_poll/ |
H A D | mod.rs | 84 fd: i32, field 93 fd: i32, in new() 99 fd, in new() 116 pub fn fd(&self) -> i32 { in fd() method 117 self.fd in fd() 209 for fd in fds { in close() 213 .get_file_by_fd(fd); in close() 219 epoll.ep_items.remove(&fd); in close() 266 let fd = fd_table_guard.alloc_fd(ep_file, None)?; in do_create_epoll() localVariable 268 Ok(fd as usize) in do_create_epoll() [all …]
|
H A D | syscall.rs | 66 pub fn epoll_ctl(epfd: i32, op: usize, fd: i32, event: VirtAddr) -> Result<usize, SystemError> { in epoll_ctl() 87 return EventPoll::do_epoll_ctl(epfd, op, fd, &mut epds, false); in epoll_ctl()
|
/DragonOS/kernel/src/syscall/ |
H A D | mod.rs | 140 let fd = args[0]; in handle() localVariable 141 Self::close(fd) in handle() 144 let fd = args[0] as i32; in handle() localVariable 152 Self::read(fd, user_buf) in handle() 155 let fd = args[0] as i32; in handle() localVariable 163 Self::write(fd, user_buf) in handle() 167 let fd = args[0] as i32; in handle() localVariable 171 Self::lseek(fd, offset, whence) in handle() 175 let fd = args[0] as i32; in handle() localVariable 183 Self::pread(fd, buf, len, offset) in handle() [all …]
|
/DragonOS/user/apps/test-chown/src/ |
H A D | main.rs | 52 fn test_fchown(fd: i32, new_uid: uid_t, new_gid: gid_t) -> Result<(), Error> { in test_fchown() 53 let result = unsafe { fchown(fd, new_uid, new_gid) }; in test_fchown() 100 let fd = file.as_raw_fd(); in main() localVariable 106 test_fchown(fd, new_uid, new_gid)?; in main()
|
/DragonOS/kernel/src/perf/ |
H A D | mod.rs | 309 let fd = fd_table.write().alloc_fd(file, None).map(|x| x as usize)?; in perf_event_open() localVariable 310 Ok(fd) in perf_event_open() 313 pub fn perf_event_output(_ctx: *mut c_void, fd: usize, _flags: u32, data: &[u8]) -> Result<()> { in perf_event_output() 314 let file = get_perf_event_file(fd)?; in perf_event_output() 326 fn get_perf_event_file(fd: usize) -> Result<Arc<PerfEventInode>> { in get_perf_event_file() 330 .get_file_by_fd(fd as _) in get_perf_event_file()
|
/DragonOS/kernel/src/bpf/prog/ |
H A D | mod.rs | 121 let fd = fd_table.write().alloc_fd(file, None).map(|x| x as usize)?; in bpf_prog_load() localVariable 122 Ok(fd) in bpf_prog_load()
|
/DragonOS/kernel/src/ipc/ |
H A D | syscall.rs | 51 pub fn pipe2(fd: *mut i32, flags: FileMode) -> Result<usize, SystemError> { in pipe2() 59 let mut user_buffer = UserBufferWriter::new(fd, core::mem::size_of::<[c_int; 2]>(), true)?; in pipe2() 60 let fd = user_buffer.buffer::<i32>(0)?; in pipe2() localVariable 90 fd[0] = read_fd; in pipe2() 91 fd[1] = write_fd; in pipe2()
|
/DragonOS/kernel/src/bpf/map/ |
H A D | mod.rs | 246 let fd = fd_table.write().alloc_fd(file, None).map(|x| x as usize)?; in bpf_map_create() localVariable 247 info!("create map with fd: [{}]", fd); in bpf_map_create() 248 Ok(fd) in bpf_map_create() 405 fn get_map_file(fd: i32) -> Result<Arc<BpfMap>> { in get_map_file() 409 .get_file_by_fd(fd) in get_map_file()
|
/DragonOS/tools/ |
H A D | run-qemu.sh | 198 sudo ${QEMU} -bios arch/x86_64/efi/OVMF-pure-efi.fd ${QEMU_ARGUMENT} 200 sudo ${QEMU} -bios arch/i386/efi/OVMF-pure-efi.fd ${QEMU_ARGUMENT}
|
/DragonOS/kernel/src/virt/kvm/ |
H A D | kvm_dev.rs | 195 .map(|fd| fd as usize); in kvm_dev_ioctl_create_vm()
|
H A D | vm_dev.rs | 231 .map(|fd| fd as usize); in kvm_vm_ioctl_create_vcpu()
|
/DragonOS/kernel/src/bpf/helper/ |
H A D | mod.rs | 81 let fd = binding in perf_event_output() localVariable 84 let fd = u32::from_ne_bytes(fd.try_into().map_err(|_| SystemError::EINVAL)?); in perf_event_output() localVariable 85 crate::perf::perf_event_output(ctx, fd as usize, flags, data)?; in perf_event_output()
|
/DragonOS/kernel/src/filesystem/ |
H A D | eventfd.rs | 278 let fd = fd_table_guard.alloc_fd(file, None).map(|x| x as usize); in sys_eventfd() localVariable 279 return fd; in sys_eventfd()
|
/DragonOS/kernel/src/mm/ |
H A D | syscall.rs | 304 fd: i32, in mmap() 343 fd, in mmap()
|