summaryrefslogtreecommitdiff
path: root/libstore
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-03-16 04:35:20 +0000
committerMiles Bader <miles@gnu.org>1996-03-16 04:35:20 +0000
commitac63f6ce3d9b411dd2d22b6361f7c69c16e5bdd8 (patch)
treeb60423cd6978c3768090b4085cb2fb1e735530e7 /libstore
parentde7e48f40992b58eb8900298c720e8dd66910dc4 (diff)
Formerly device.c.~4~
Diffstat (limited to 'libstore')
-rw-r--r--libstore/device.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/libstore/device.c b/libstore/device.c
index 71c89dad..82a85745 100644
--- a/libstore/device.c
+++ b/libstore/device.c
@@ -21,19 +21,34 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include "store.h"
static error_t
-dev_read (struct store *store, off_t addr, mach_msg_type_number_t amount,
+dev_read (struct store *store,
+ off_t addr, size_t index, 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);
+ error_t err = device_read (store->port, 0, addr, amount, (io_buf_ptr_t *)buf, len);
+ char rep_buf[20];
+ 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;
}
static error_t
dev_write (struct store *store,
- off_t addr, char *buf, mach_msg_type_number_t len,
+ off_t addr, size_t index, 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);
@@ -71,6 +86,6 @@ _store_device_create (device_t device, size_t block_size,
struct store **store)
{
*store = _make_store (STORAGE_DEVICE, &device_meths, device, block_size,
- runs, runs_len);
+ runs, runs_len, 0);
return *store ? 0 : ENOMEM;
}