summaryrefslogtreecommitdiff
path: root/libstore/device.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1997-07-17 20:12:33 +0000
committerMiles Bader <miles@gnu.org>1997-07-17 20:12:33 +0000
commitc46c23b595fd03c2e5d5aed2dbc2a4831dbf6b62 (patch)
tree68934499ba5c0226ef20ac2657453922e9ad1663 /libstore/device.c
parentf138cc2729afb71517581ea1072fc06543edd41c (diff)
(dev_map):
New function. (store_device_class): Use dev_map. (dev_read, dev_write): Remove debugging grot.
Diffstat (limited to 'libstore/device.c')
-rw-r--r--libstore/device.c48
1 files changed, 18 insertions, 30 deletions
diff --git a/libstore/device.c b/libstore/device.c
index a34aed86..4ca29c3f 100644
--- a/libstore/device.c
+++ b/libstore/device.c
@@ -31,22 +31,7 @@ dev_read (struct store *store,
off_t addr, size_t index, mach_msg_type_number_t amount,
void **buf, mach_msg_type_number_t *len)
{
-#if 1
return device_read (store->port, 0, addr, amount, (io_buf_ptr_t *)buf, len);
-#else
- char rep_buf[20];
- error_t err = device_read (store->port, 0, addr, amount, (io_buf_ptr_t *)buf, len);
- if (err)
- strcpy (rep_buf, "-");
- else if (*len > sizeof rep_buf - 3)
- sprintf (rep_buf, "\"%.*s\"...", (int)(sizeof rep_buf - 6), *buf);
- else
- sprintf (rep_buf, "\"%.*s\"", (int)(sizeof rep_buf - 3), *buf);
- fprintf (stderr, "; dev_read (%ld, %d, %d) [%d] => %s, %s, %d\n",
- addr, index, amount, store->block_size, err ? strerror (err) : "-",
- rep_buf, err ? 0 : *len);
- return err;
-#endif
}
static error_t
@@ -54,21 +39,7 @@ dev_write (struct store *store,
off_t addr, size_t index, void *buf, mach_msg_type_number_t len,
mach_msg_type_number_t *amount)
{
-#if 1
return device_write (store->port, 0, addr, (io_buf_ptr_t)buf, len, amount);
-#else
- error_t err;
- char rep_buf[20];
- if (len > sizeof rep_buf - 3)
- sprintf (rep_buf, "\"%.*s\"...", (int)(sizeof rep_buf - 6), buf);
- else
- sprintf (rep_buf, "\"%.*s\"", (int)(sizeof rep_buf - 3), buf);
- err = device_write (store->port, 0, addr, (io_buf_ptr_t)buf, len, amount);
- fprintf (stderr, "; dev_write (%ld, %d, %s, %d) [%d] => %s, %d\n",
- addr, index, rep_buf, len, store->block_size,
- err ? strerror (err) : "-", *amount);
- return err;
-#endif
}
static error_t
@@ -185,12 +156,29 @@ dev_clear_flags (struct store *store, int flags)
return err;
}
+static error_t
+dev_map (const struct store *store, vm_prot_t prot, mach_port_t *memobj)
+{
+ if (store->num_runs != 1)
+ return EOPNOTSUPP;
+ else
+ {
+ error_t err =
+ device_map (store->port, prot,
+ store->runs[0].start, store->runs[0].length,
+ memobj, 0);
+ if (err == ED_INVALID_OPERATION)
+ err = EOPNOTSUPP; /* This device doesn't support paging. */
+ return err;
+ }
+}
+
struct store_class
store_device_class =
{
STORAGE_DEVICE, "device", dev_read, dev_write,
store_std_leaf_allocate_encoding, store_std_leaf_encode, dev_decode,
- dev_set_flags, dev_clear_flags, 0, 0, 0, dev_open
+ dev_set_flags, dev_clear_flags, 0, 0, 0, dev_open, 0, dev_map
};
/* Return a new store in STORE referring to the mach device DEVICE. Consumes