ringbuffer: handle user addresses

This commit is contained in:
Matheus
2024-09-18 19:01:01 -03:00
parent a63f8c37cc
commit 7460e8b707
2 changed files with 17 additions and 7 deletions
+3
View File
@@ -19,11 +19,13 @@ int ringbuffer_init(ringbuffer_t *ringbuffer, size_t size);
void ringbuffer_destroy(ringbuffer_t *ringbuffer);
// reads count bytes from ring buffer into buffer
// can accept a buffer in userspace
// returns -1 if it was unable to read (due to EFAULT when copying a user page)
// otherwise returns the number of bytes read
size_t ringbuffer_read(ringbuffer_t* ringbuffer, void *buffer, size_t count);
// writes count bytes from buffer into ring buffer
// can accept a buffer in userspace
// returns -1 if it was unable to write (due to EFAULT when copying a user page)
// otherwise returns the number of bytes read
size_t ringbuffer_write(ringbuffer_t* ringbuffer, void *buffer, size_t count);
@@ -33,6 +35,7 @@ size_t ringbuffer_write(ringbuffer_t* ringbuffer, void *buffer, size_t count);
size_t ringbuffer_truncate(ringbuffer_t *ringbuffer, size_t count);
// same as ringbuffer_read, but accepts an offset and does not update the read pointer
// can accept a buffer in userspace
// returns -1 if it was unable to read (due to EFAULT when copying a user page)
// otherwise returns the number of bytes read
size_t ringbuffer_peek(ringbuffer_t *ringbuffer, void *buffer, uintmax_t offset, size_t count);