/DragonOS/user/apps/dmesg/ |
H A D | main.c | 10 char *buf = NULL; in main() local 15 len = klogctl(10, buf, len); in main() 22 buf = malloc(len); in main() 23 if (buf == NULL) in main() 32 len = klogctl(2, buf, len); in main() 55 len = klogctl(opt, buf, len); in main() 76 klogctl(8, buf, level); in main() 77 len = klogctl(2, buf, len); in main() 90 c[0] = buf[i]; in main() 93 if (content == 0 && buf[i] == '>') in main() [all …]
|
/DragonOS/kernel/crates/crc/src/ |
H A D | crc64.rs | 41 pub fn crc64_be(mut crc: u64, buf: &[u8]) -> u64 { in crc64_be() 42 for &byte in buf { in crc64_be() 57 pub fn crc64_rocksoft_generic(mut crc: u64, buf: &[u8]) -> u64 { in crc64_rocksoft_generic() 60 for &byte in buf { in crc64_rocksoft_generic() 73 let mut buf = [0u8; 1]; in crc64_be_single() localVariable 74 buf[0] = 0xaa; in crc64_be_single() 75 let crc = crc64_be(0, &buf); in crc64_be_single() 81 let buf = b"0123456789"; in crc64_be_multibytes() localVariable 82 let crc = crc64_be(0, buf); in crc64_be_multibytes()
|
/DragonOS/kernel/src/driver/base/block/ |
H A D | gendisk.rs | 53 buf: &mut [u8], in read_at() 56 if (buf.len() & (LBA_SIZE - 1)) > 0 { in read_at() 60 let blocks = buf.len() / (1 << self.block_size_log2 as usize); in read_at() 63 return self.block_device().read_at(lba, blocks, buf); in read_at() 74 pub fn read_at_bytes(&self, buf: &mut [u8], bytes_offset: usize) -> Result<usize, SystemError> { in read_at_bytes() 79 .read_at_bytes(bytes_offset, buf.len(), buf); in read_at_bytes() 96 pub fn write_at_bytes(&self, buf: &[u8], bytes_offset: usize) -> Result<usize, SystemError> { in write_at_bytes() 101 .write_at_bytes(bytes_offset, buf.len(), buf); in write_at_bytes() 112 pub fn write_at(&self, buf: &[u8], start_block_offset: BlockId) -> Result<usize, SystemError> { in write_at() 113 if (buf.len() & (LBA_SIZE - 1)) > 0 { in write_at() [all …]
|
H A D | block_device.rs | 310 buf: &mut [u8], in read_at_sync() 324 buf: &[u8], in write_at_sync() 357 buf: &mut [u8], in read_at() 359 self.cache_read(lba_id_start, count, buf) in read_at() 368 buf: &[u8], in write_at() 370 self.cache_write(lba_id_start, count, buf) in write_at() 379 buf: &mut [u8], in cache_read() 381 let cache_response = BlockCache::read(lba_id_start, count, buf); in cache_read() 386 let ans = self.read_at_sync(lba_id_start, count, buf)?; in cache_read() 390 let ans = self.read_at_sync(lba_id_start, count, buf)?; in cache_read() [all …]
|
/DragonOS/user/apps/test_filemap/ |
H A D | main.c | 21 char buf[12]; in main() local 22 buf[11] = '\0'; in main() 26 read(fd, buf, 11); in main() 27 printf("File content: %s\n", buf); in main() 57 read(fd, buf, 11); in main() 58 printf("File content: %s\n", buf); in main()
|
/DragonOS/user/apps/test_uart/ |
H A D | main.c | 9 char buf[1] = {0}; in main() local 11 memset(buf, 0, 1); in main() 13 n = read(fd, buf, 1); in main() 17 printf("Received: %s\n", buf); // 打印接收到的数据 in main() 18 if (buf[0] == 'g') { in main()
|
/DragonOS/kernel/src/filesystem/kernfs/ |
H A D | callback.rs | 20 buf: &mut [u8], in read() 27 buf: &[u8], in write() 68 pub fn callback_read(&self, buf: &mut [u8], offset: usize) -> Result<usize, SystemError> { in callback_read() 71 return private_data.callback_read(buf, offset); in callback_read() 76 pub fn callback_write(&self, buf: &[u8], offset: usize) -> Result<usize, SystemError> { in callback_write() 79 return private_data.callback_write(buf, offset); in callback_write() 93 pub fn callback_read(&self, buf: &mut [u8], offset: usize) -> Result<usize, SystemError> { in callback_read() 96 return private_data.callback_read(buf, offset); in callback_read() 102 pub fn callback_write(&self, buf: &[u8], offset: usize) -> Result<usize, SystemError> { in callback_write() 105 return private_data.callback_write(buf, offset); in callback_write()
|
/DragonOS/kernel/src/filesystem/procfs/ |
H A D | kmsg.rs | 60 pub fn read(&mut self, buf: &mut [u8]) -> Result<usize, SystemError> { in read() 64 LogLevel::DEFAULT => self.read_all(buf), in read() 65 _ => self.read_level(buf), in read() 70 fn read_all(&mut self, buf: &mut [u8]) -> Result<usize, SystemError> { in read_all() 71 let len = self.data.len().min(buf.len()); in read_all() 75 buf[0..len].copy_from_slice(src); in read_all() 81 fn read_level(&mut self, buf: &mut [u8]) -> Result<usize, SystemError> { in read_level() 90 let len = data_level.len().min(buf.len()); in read_level() 94 buf[0..len].copy_from_slice(src); in read_level() 103 pub fn read_clear(&mut self, buf: &mut [u8]) -> Result<usize, SystemError> { in read_clear() [all …]
|
H A D | syscall.rs | 57 buf: &mut [u8], in do_syslog() 67 SyslogAction::Read => kmsg_guard.read(buf), in do_syslog() 68 SyslogAction::ReadClear => kmsg_guard.read_clear(buf), in do_syslog()
|
/DragonOS/kernel/src/libs/ |
H A D | vec_cursor.rs | 102 pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), SystemError> { in read_exact() 103 if self.pos + buf.len() > self.data.len() { in read_exact() 106 buf.copy_from_slice(&self.data[self.pos..self.pos + buf.len()]); in read_exact() 107 self.pos += buf.len(); in read_exact() 114 pub fn read_u16_into(&mut self, buf: &mut [u16]) -> Result<(), SystemError> { in read_u16_into() 115 if self.pos + size_of_val(buf) > self.data.len() * size_of::<u16>() { in read_u16_into() 119 for item in buf.iter_mut() { in read_u16_into() 210 pub fn write_exact(&mut self, buf: &[u8]) -> Result<(), SystemError> { in write_exact() 211 if self.pos + buf.len() > self.data.len() { in write_exact() 215 self.data[self.pos..self.pos + buf.len()].copy_from_slice(buf); in write_exact() [all …]
|
H A D | printk.c | 54 static int __do_vsprintf(char *buf, const char *fmt, int buf_size, va_list args) in __do_vsprintf() argument 62 str = buf; in __do_vsprintf() 72 end = buf + buf_size; in __do_vsprintf() 310 *ip = str - buf; in __do_vsprintf() 354 return str - buf; in __do_vsprintf() 364 int vsprintf(char *buf, const char *fmt, va_list args) in vsprintf() argument 366 return __do_vsprintf(buf, fmt, -1, args); in vsprintf() 378 int vsnprintf(char *buf, const char *fmt, int buf_size, va_list args) in vsnprintf() argument 380 return __do_vsprintf(buf, fmt, buf_size, args); in vsnprintf() 602 static char buf[4096]; // vsprintf()的缓冲区 in printk_color() local [all …]
|
/DragonOS/kernel/src/net/socket/ |
H A D | unix.rs | 63 fn read(&self, buf: &mut [u8]) -> (Result<usize, SystemError>, Endpoint) { in read() 66 let len = core::cmp::min(buf.len(), buffer.len()); in read() 67 buf[..len].copy_from_slice(&buffer[..len]); in read() 74 fn write(&self, buf: &[u8], _to: Option<Endpoint>) -> Result<usize, SystemError> { in write() 80 let len = peer_inode.inner().write_buffer(buf)?; in write() 97 fn write_buffer(&self, buf: &[u8]) -> Result<usize, SystemError> { in write_buffer() 100 let len = buf.len(); in write_buffer() 104 buffer.extend_from_slice(buf); in write_buffer() 174 fn read(&self, buf: &mut [u8]) -> (Result<usize, SystemError>, Endpoint) { in read() 177 let len = core::cmp::min(buf.len(), buffer.len()); in read() [all …]
|
/DragonOS/kernel/src/exception/ |
H A D | sysfs.rs | 151 fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> { in show() 159 let len = core::cmp::min(name.len() + 1, buf.len()); in show() 161 buf[..len].copy_from_slice(name.as_bytes()); in show() 182 fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> { in show() 188 return sysfs_emit_str(buf, &format!("{}\n", hwirq.data())); in show() 208 fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> { in show() 219 return sysfs_emit_str(buf, &format!("{}\n", irq_type)); in show() 239 fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> { in show() 245 return sysfs_emit_str(buf, &format!("{}\n", wakeup)); in show() 265 fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> { in show() [all …]
|
/DragonOS/kernel/src/filesystem/sysfs/ |
H A D | file.rs | 60 pub fn callback_read(&self, buf: &mut [u8], offset: usize) -> Result<usize, SystemError> { in callback_read() 64 let len = attribute.show(kobj, buf)?; in callback_read() 70 buf.copy_within(offset..offset + len, 0); in callback_read() 71 buf[len] = 0; in callback_read() 77 return bin_attribute.read(kobj, buf, offset); in callback_read() 83 pub fn callback_write(&self, buf: &[u8], offset: usize) -> Result<usize, SystemError> { in callback_write() 87 return attribute.store(kobj, buf); in callback_write() 91 return bin_attribute.write(kobj, buf, offset); in callback_write() 297 buf: &mut [u8], in read() 300 return data.callback_read(buf, offset); in read() [all …]
|
/DragonOS/kernel/src/arch/riscv64/ |
H A D | rand.rs | 3 let mut buf = [0u8; size_of::<usize>()]; in rand() localVariable 4 for x in buf.iter_mut() { in rand() 11 let x: usize = unsafe { core::mem::transmute(buf) }; in rand()
|
/DragonOS/user/apps/test_pty/ |
H A D | test_pty.c | 31 char buf[256]; in main() local 32 ssize_t n = read(ptm, buf, sizeof(buf)); in main() 34 printf("read %ld bytes from slave: %.*s", n, (int)n, buf); in main()
|
/DragonOS/tools/debugging/logmonitor/src/backend/monitor/ |
H A D | mod.rs | 15 pub fn new(buf: &[u8]) -> Option<Self> { in new() 16 if buf.len() != std::mem::size_of::<T>() { in new() 19 buf.len(), in new() 24 let x = unsafe { std::ptr::read(buf.as_ptr() as *const T) }; in new()
|
/DragonOS/user/apps/test_lo/src/ |
H A D | main.rs | 11 let mut buf = [0; 1024]; in main() localVariable 12 let (amt, _src) = socket.recv_from(&mut buf)?; in main() 14 let received_msg = str::from_utf8(&buf[..amt]).expect("Could not read buffer as UTF-8"); in main()
|
/DragonOS/kernel/src/driver/video/fbdev/base/ |
H A D | fbsysfs.rs | 64 fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> { in show() 68 return sysfs_emit_str(buf, &format!("{}\n", name)); in show() 93 fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> { in show() 97 return sysfs_emit_str(buf, &format!("{}\n", bits_per_pixel)); in show() 195 fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> { in show() 199 return sysfs_emit_str(buf, &format!("{},{}\n", var_info.xoffset, var_info.yoffset)); in show() 224 fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> { in show() 229 buf, in show() 256 fn show(&self, kobj: Arc<dyn KObject>, buf: &mut [u8]) -> Result<usize, SystemError> { in show() 260 return sysfs_emit_str(buf, &format!("{}\n", fix_info.line_length)); in show() [all …]
|
/DragonOS/kernel/src/common/ |
H A D | printk.h | 45 int vsprintf(char *buf, const char *fmt, va_list args); 56 int vsnprintf(char *buf, const char *fmt, int buf_size, va_list args); 78 int sprintk(char *buf, const char *fmt, ...);
|
H A D | stdio.h | 11 extern int vsprintf(char *buf, const char *fmt, va_list args); 13 extern int sprintk(char *buf, const char *fmt, ...);
|
/DragonOS/kernel/src/driver/block/cache/ |
H A D | cache_block.rs | 43 pub fn data(&self, buf: &mut [u8]) -> Result<usize, BlockCacheError> { in data() 44 if buf.len() != BLOCK_SIZE { in data() 47 buf.copy_from_slice(&self.data); in data()
|
/DragonOS/kernel/src/driver/disk/ahci/ |
H A D | ahcidisk.rs | 74 buf: &mut [u8], in read_at() 76 assert!((buf.len() & 511) == 0); in read_at() 79 if count * 512 > buf.len() || check_length > 8_usize { in read_at() 113 let mut buf_ptr = buf as *mut [u8] as *mut usize as usize; in read_at() 118 let user_buf = verify_area(VirtAddr::new(buf_ptr), buf.len()).is_ok(); in read_at() 120 let x: Vec<u8> = vec![0; buf.len()]; in read_at() 218 buf.copy_from_slice(kbuf); in read_at() 230 buf: &[u8], in write_at() 232 assert!((buf.len() & 511) == 0); in write_at() 235 if count * 512 > buf.len() || check_length > 8 { in write_at() [all …]
|
H A D | ahci_inode.rs | 121 buf: &mut [u8], in read_at() 124 if buf.len() < len { in read_at() 129 return self.0.lock().disk.read_at_bytes(offset, len, buf); in read_at() 140 buf: &[u8], in write_at() 143 if buf.len() < len { in write_at() 148 return self.0.lock().disk.write_at_bytes(offset, len, buf); in write_at()
|
/DragonOS/kernel/crates/intertrait/macros/src/ |
H A D | gen_caster.rs | 58 fn new_fn_name(buf: &mut [u8]) -> &str { in new_fn_name() 59 buf[..FN_PREFIX.len()].copy_from_slice(FN_PREFIX); in new_fn_name() 62 .encode_lower(&mut buf[FN_PREFIX.len()..]); in new_fn_name() 63 unsafe { from_utf8_unchecked(&buf[..FN_BUF_LEN]) } in new_fn_name()
|