MCPcopy Create free account
hub / github.com/Starry-OS/StarryOS / get_event_bits

Method get_event_bits

api/src/vfs/dev/event.rs:95–112  ·  view source on GitHub ↗
(&self, arg: usize, size: usize, ty: u8)

Source from the content-addressed store, hash-verified

93 }
94
95 fn get_event_bits(&self, arg: usize, size: usize, ty: u8) -> AxResult<usize> {
96 let bits = UserPtr::<u8>::from(arg).get_as_mut_slice(size)?;
97 if ty == 0 {
98 Ok(copy_bytes(self.ev_bits.as_bytes(), bits))
99 } else {
100 let ty = EventType::from_repr(ty).ok_or(AxError::InvalidInput)?;
101 match self.inner.lock().device.get_event_bits(ty, bits) {
102 Ok(true) => {}
103 Ok(false) => {
104 debug!("No events for {ty:?}");
105 }
106 Err(err) => {
107 warn!("Failed to get event bits: {err:?}");
108 }
109 }
110 Ok(bits.len().min(ty.bits_count().div_ceil(8)))
111 }
112 }
113}
114
115fn copy_bytes(src: &[u8], dst: &mut [u8]) -> usize {

Callers 2

newMethod · 0.80
ioctlMethod · 0.80

Calls 3

copy_bytesFunction · 0.85
get_as_mut_sliceMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected