From 781b7dc197eaa45129fcdee410609387e63217a9 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Mon, 13 Nov 1995 21:52:59 +0000 Subject: Formerly device.c.~2~ --- libstore/device.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/libstore/device.c b/libstore/device.c index 65a714b9..520482cd 100644 --- a/libstore/device.c +++ b/libstore/device.c @@ -20,8 +20,28 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include + #include "store.h" + +static error_t +dev_read (struct store *store, off_t addr, mach_msg_type_number_t amount, + char **buf, mach_msg_type_number_t *len) +{ + return device_read (store->port, 0, addr, amount, (io_buf_ptr_t *)buf, len); +} +static error_t +dev_write (struct store *store, + off_t addr, char *buf, mach_msg_type_number_t len, + mach_msg_type_number_t *amount) +{ + return device_write (store->port, 0, addr, (io_buf_ptr_t)buf, len, amount); +} + +static struct store_meths +device_meths = {dev_read, dev_write}; + /* Return a new store in STORE referring to the mach device DEVICE. Consumes the send right DEVICE. */ error_t @@ -30,7 +50,10 @@ store_device_create (device_t device, struct store **store) off_t runs[2]; size_t sizes[DEV_GET_SIZE_COUNT], block_size; unsigned sizes_len = DEV_GET_SIZE_COUNT; - error_t err = device_get_status (*port, DEV_GET_SIZE, sizes, &sizes_len); + error_t err = device_get_status (device, DEV_GET_SIZE, sizes, &sizes_len); + + if (err) + return err; assert (sizes_len == DEV_GET_SIZE_COUNT); @@ -47,14 +70,14 @@ _store_device_create (device_t device, off_t *runs, unsigned runs_len, size_t block_size, struct store **store) { - *store = _alloc_store (); + *store = _make_store (STORAGE_DEVICE, &device_meths); if (!*store) return ENOMEM; (*store)->block_size = block_size; store_set_runs (*store, runs, runs_len); - store_derive (*store); + _store_derive (*store); return 0; } -- cgit v1.2.3