dev: implement reading from block devices
reading from block devices is done using the block cache (bcache). This cache stores sectors from a block device in pages of memory marked as 'cached', which will allow them to be reclaimed when memory pressure is high (TODO). while block device drivers implement callbacks allowing reading/writing at block-granularity, the device subsystem uses the block cache to implement reading/writing at byte-granularity in a driver-agnostic way. block drivers can disable the block cache for their devices, but this will require that any clients communicate with the devices at block-granularity. also added an offset parameter to device and object read/write functions/callbacks.
This commit is contained in:
@@ -73,7 +73,7 @@ static void putchar(struct device *tty, int c)
|
||||
}
|
||||
}
|
||||
|
||||
kern_status_t tty_read(struct device *tty, void *buf, size_t max, size_t *nr_read, socks_flags_t flags)
|
||||
kern_status_t tty_read(struct device *tty, void *buf, size_t offset, size_t max, size_t *nr_read, socks_flags_t flags)
|
||||
{
|
||||
kern_status_t status = KERN_UNSUPPORTED;
|
||||
struct tty_device *ttydev = TTY_DEVICE(tty);
|
||||
@@ -85,7 +85,7 @@ kern_status_t tty_read(struct device *tty, void *buf, size_t max, size_t *nr_rea
|
||||
return status;
|
||||
}
|
||||
|
||||
kern_status_t tty_write(struct device *tty, const void *buf, size_t len, size_t *nr_written, socks_flags_t flags)
|
||||
kern_status_t tty_write(struct device *tty, const void *buf, size_t offset, size_t len, size_t *nr_written, socks_flags_t flags)
|
||||
{
|
||||
size_t r = 0;
|
||||
const char *s = buf;
|
||||
|
||||
Reference in New Issue
Block a user