summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libstore/clone.c2
-rw-r--r--libstore/create.c11
-rw-r--r--libstore/decode.c8
-rw-r--r--libstore/derive.c6
-rw-r--r--libstore/device.c4
-rw-r--r--libstore/enc.c26
-rw-r--r--libstore/encode.c34
-rw-r--r--libstore/file.c6
-rw-r--r--libstore/make.c6
-rw-r--r--libstore/rdwr.c2
-rw-r--r--libstore/set.c8
11 files changed, 62 insertions, 51 deletions
diff --git a/libstore/clone.c b/libstore/clone.c
index 2550f859..3030bae3 100644
--- a/libstore/clone.c
+++ b/libstore/clone.c
@@ -32,7 +32,7 @@ store_clone (struct store *from, struct store **to)
error_t err = 0;
struct store *c =
_make_store (from->class, from->meths, from->port, from->block_size,
- from->runs, from->runs_len, from->end);
+ from->runs, from->num_runs, from->end);
if (! c)
return ENOMEM;
diff --git a/libstore/create.c b/libstore/create.c
index 8c288bc9..5e681859 100644
--- a/libstore/create.c
+++ b/libstore/create.c
@@ -24,6 +24,16 @@
#include "store.h"
+static error_t
+fgsi (file_t source,
+ mach_port_t **ports, mach_msg_type_number_t *num_ports,
+ int **ints, mach_msg_type_number_t *num_ints,
+ off_t **offsets, mach_msg_type_number_t *num_offsets,
+ char **data, mach_msg_type_number_t *num_data)
+{
+ return EOPNOTSUPP;
+}
+
/* Return a new store in STORE, which refers to the storage underlying
SOURCE. A reference to SOURCE is created (but may be destroyed with
store_close_source). */
@@ -39,6 +49,7 @@ error_t store_create (file_t source, struct store **store)
store_enc_init (&enc, inline_ports, 10, inline_ints, 60,
inline_offsets, 60, inline_data, 100);
+#define file_get_storage_info fgsi /* XXX */
err = file_get_storage_info (source,
&enc.ports, &enc.num_ports,
&enc.ints, &enc.num_ints,
diff --git a/libstore/decode.c b/libstore/decode.c
index 08c80831..d3cc0d45 100644
--- a/libstore/decode.c
+++ b/libstore/decode.c
@@ -32,7 +32,7 @@ store_default_leaf_decode (struct store_enc *enc,
error_t (*create)(mach_port_t port,
size_t block_size,
const off_t *runs,
- size_t runs_len,
+ size_t num_runs,
struct store **store),
struct store **store)
{
@@ -43,7 +43,7 @@ store_default_leaf_decode (struct store_enc *enc,
size_t block_size, num_runs, name_len, misc_len;
/* Make sure there are enough encoded ints and ports. */
- if (enc->cur_int + 6 > enc->ints_len || enc->cur_port + 1 > enc->ports_len)
+ if (enc->cur_int + 6 > enc->num_ints || enc->cur_port + 1 > enc->num_ports)
return EINVAL;
/* Read encoded ints. */
@@ -55,7 +55,7 @@ store_default_leaf_decode (struct store_enc *enc,
misc_len = enc->ints[enc->cur_int++];
/* Make sure there are enough encoded offsets and data. */
- if (enc->cur_offset + num_runs * 2 > enc->offsets_len
+ if (enc->cur_offset + num_runs * 2 > enc->num_offsets
|| enc->cur_data + name_len + misc_len > enc->data_len)
return EINVAL;
@@ -94,7 +94,7 @@ store_default_leaf_decode (struct store_enc *enc,
error_t
store_decode (struct store_enc *enc, struct store **store)
{
- if (enc->cur_int >= enc->ints_len)
+ if (enc->cur_int >= enc->num_ints)
/* The first int should always be the type. */
return EINVAL;
diff --git a/libstore/derive.c b/libstore/derive.c
index b840e033..5a7e0173 100644
--- a/libstore/derive.c
+++ b/libstore/derive.c
@@ -29,13 +29,13 @@ _store_derive (struct store *store)
{
unsigned i;
off_t *runs = store->runs;
- unsigned runs_len = store->runs_len;
+ unsigned num_runs = store->num_runs;
size_t bsize = store->block_size;
/* BLOCK & SIZE */
store->blocks = 0;
- for (i = 0; i < runs_len; i += 2)
+ for (i = 0; i < num_runs; i += 2)
{
store->wrap_src += runs[i + 1];
if (runs[i] >= 0)
@@ -54,7 +54,7 @@ _store_derive (struct store *store)
store->blocks *= num_iters;
- for (i = 0; i < runs_len; i += 2)
+ for (i = 0; i < num_runs; i += 2)
if (last_part_base + runs[i + 1] < store->end)
{
store->blocks += store->end - (last_part_base + runs[i + 1]);
diff --git a/libstore/device.c b/libstore/device.c
index 2655fbd4..ce15d3a4 100644
--- a/libstore/device.c
+++ b/libstore/device.c
@@ -82,10 +82,10 @@ store_device_create (device_t device, struct store **store)
/* Like store_device_create, but doesn't query the device for information. */
error_t
_store_device_create (device_t device, size_t block_size,
- const off_t *runs, size_t runs_len,
+ const off_t *runs, size_t num_runs,
struct store **store)
{
*store = _make_store (STORAGE_DEVICE, &device_meths, device, block_size,
- runs, runs_len, 0);
+ runs, num_runs, 0);
return *store ? 0 : ENOMEM;
}
diff --git a/libstore/enc.c b/libstore/enc.c
index 8091eb89..9706dfc9 100644
--- a/libstore/enc.c
+++ b/libstore/enc.c
@@ -29,19 +29,19 @@
allocated). */
void
store_enc_init (struct store_enc *enc,
- mach_port_t *ports, mach_msg_type_number_t ports_len,
- int *ints, mach_msg_type_number_t ints_len,
- off_t *offsets, mach_msg_type_number_t offsets_len,
+ mach_port_t *ports, mach_msg_type_number_t num_ports,
+ int *ints, mach_msg_type_number_t num_ints,
+ off_t *offsets, mach_msg_type_number_t num_offsets,
char *data, mach_msg_type_number_t data_len)
{
bzero (enc, sizeof (*enc));
enc->ports = enc->init_ports = ports;
- enc->ports_len = ports_len;
+ enc->num_ports = num_ports;
enc->ints = enc->init_ints = ints;
- enc->ints_len = ints_len;
+ enc->num_ints = num_ints;
enc->offsets = enc->init_offsets = offsets;
- enc->offsets_len = offsets_len;
+ enc->num_offsets = num_offsets;
enc->data = enc->init_data = data;
enc->data_len = data_len;
}
@@ -51,10 +51,10 @@ store_enc_init (struct store_enc *enc,
void
store_enc_dealloc (struct store_enc *enc)
{
- if (enc->ports && enc->ports_len > 0)
+ if (enc->ports && enc->num_ports > 0)
/* For ports, we must deallocate each port as well. */
{
- while (enc->cur_port < enc->ports_len)
+ while (enc->cur_port < enc->num_ports)
{
mach_port_t port = enc->ports[enc->cur_port++];
if (port != MACH_PORT_NULL)
@@ -64,19 +64,19 @@ store_enc_dealloc (struct store_enc *enc)
if (enc->ports != enc->init_ports)
vm_deallocate (mach_task_self (),
(vm_address_t)enc->ports,
- enc->ports_len * sizeof (*enc->ports));
+ enc->num_ports * sizeof (*enc->ports));
}
- if (enc->ints && enc->ints_len > 0 && enc->ints != enc->init_ints)
+ if (enc->ints && enc->num_ints > 0 && enc->ints != enc->init_ints)
vm_deallocate (mach_task_self (),
(vm_address_t)enc->ints,
- enc->ints_len * sizeof (*enc->ints));
+ enc->num_ints * sizeof (*enc->ints));
- if (enc->offsets && enc->offsets_len > 0
+ if (enc->offsets && enc->num_offsets > 0
&& enc->offsets != enc->init_offsets)
vm_deallocate (mach_task_self (),
(vm_address_t)enc->offsets,
- enc->offsets_len * sizeof (*enc->offsets));
+ enc->num_offsets * sizeof (*enc->offsets));
if (enc->data && enc->data_len > 0 && enc->data != enc->init_data)
vm_deallocate (mach_task_self (),
diff --git a/libstore/encode.c b/libstore/encode.c
index 9a54d502..bf9ab398 100644
--- a/libstore/encode.c
+++ b/libstore/encode.c
@@ -30,9 +30,9 @@ error_t
store_default_leaf_allocate_encoding (struct store *store,
struct store_enc *enc)
{
- enc->ports_len++;
- enc->ints_len += 6;
- enc->offsets_len += store->runs_len;
+ enc->num_ports++;
+ enc->num_ints += 6;
+ enc->num_offsets += store->num_runs;
if (store->name)
enc->data_len += strlen (store->name) + 1;
enc->data_len += store->misc_len;
@@ -50,11 +50,11 @@ store_default_leaf_encode (struct store *store, struct store_enc *enc)
enc->ints[enc->cur_int++] = store->class;
enc->ints[enc->cur_int++] = store->flags;
enc->ints[enc->cur_int++] = store->block_size;
- enc->ints[enc->cur_int++] = store->runs_len;
+ enc->ints[enc->cur_int++] = store->num_runs;
enc->ints[enc->cur_int++] = name_len;
enc->ints[enc->cur_int++] = store->misc_len;
- for (i = 0; i < store->runs_len; i++)
+ for (i = 0; i < store->num_runs; i++)
enc->offsets[enc->cur_offset++] = store->runs[i];
if (store->name)
@@ -83,31 +83,31 @@ store_encode (const struct store *store, struct store_enc *enc)
struct store_meths *meths = store->meths;
/* We zero each vector length for the allocate_encoding method to work, so
save the old values. */
- mach_msg_type_number_t init_ports_len = enc->ports_len;
- mach_msg_type_number_t init_ints_len = enc->ints_len;
- mach_msg_type_number_t init_offsets_len = enc->offsets_len;
+ mach_msg_type_number_t init_num_ports = enc->num_ports;
+ mach_msg_type_number_t init_num_ints = enc->num_ints;
+ mach_msg_type_number_t init_num_offsets = enc->num_offsets;
mach_msg_type_number_t init_data_len = enc->data_len;
if (!meths->allocate_encoding || !meths->encode)
return EOPNOTSUPP;
- enc->ports_len = 0;
- enc->ints_len = 0;
- enc->offsets_len = 0;
+ enc->num_ports = 0;
+ enc->num_ints = 0;
+ enc->num_offsets = 0;
enc->data_len = 0;
err = (*meths->allocate_encoding) (store, enc);
if (err)
return err;
- if (enc->ports_len > init_ports_len)
+ if (enc->num_ports > init_num_ports)
err = vm_allocate (mach_task_self (),
- (vm_address_t *)&enc->ports, enc->ports_len, 1);
- if (!err && enc->ints_len > init_ints_len)
+ (vm_address_t *)&enc->ports, enc->num_ports, 1);
+ if (!err && enc->num_ints > init_num_ints)
err = vm_allocate (mach_task_self (),
- (vm_address_t *)&enc->ints, enc->ints_len, 1);
- if (!err && enc->offsets_len > init_offsets_len)
+ (vm_address_t *)&enc->ints, enc->num_ints, 1);
+ if (!err && enc->num_offsets > init_num_offsets)
err = vm_allocate (mach_task_self (),
- (vm_address_t *)&enc->offsets, enc->offsets_len, 1);
+ (vm_address_t *)&enc->offsets, enc->num_offsets, 1);
if (!err && enc->data_len > init_data_len)
err = vm_allocate (mach_task_self (),
(vm_address_t *)&enc->data, enc->data_len, 1);
diff --git a/libstore/file.c b/libstore/file.c
index 8760f05c..125394d7 100644
--- a/libstore/file.c
+++ b/libstore/file.c
@@ -125,15 +125,15 @@ store_file_create (file_t file, struct store **store)
/* Like store_file_create, but doesn't query the file for information. */
error_t
_store_file_create (file_t file, size_t block_size,
- const off_t *runs, size_t runs_len,
+ const off_t *runs, size_t num_runs,
struct store **store)
{
if (block_size == 1)
*store = _make_store (STORAGE_HURD_FILE, &file_byte_meths, file, 1,
- runs, runs_len, 0);
+ runs, num_runs, 0);
else if ((block_size & (block_size - 1)) == 0)
*store = _make_store (STORAGE_HURD_FILE, &file_meths, file, block_size,
- runs, runs_len, 0);
+ runs, num_runs, 0);
else
return EINVAL; /* block size not a power of two */
return *store ? 0 : ENOMEM;
diff --git a/libstore/make.c b/libstore/make.c
index 340d583c..7ce320d5 100644
--- a/libstore/make.c
+++ b/libstore/make.c
@@ -29,7 +29,7 @@
struct store *
_make_store (enum file_storage_class class, struct store_meths *meths,
mach_port_t port, size_t block_size,
- const off_t *runs, size_t runs_len, off_t end)
+ const off_t *runs, size_t num_runs, off_t end)
{
if (block_size & (block_size - 1))
return 0; /* block size not a power of two. */
@@ -41,7 +41,7 @@ _make_store (enum file_storage_class class, struct store_meths *meths,
store->name = 0;
store->port = port;
store->runs = 0;
- store->runs_len = 0;
+ store->num_runs = 0;
store->wrap_src = 0;
store->wrap_dst = 0;
store->end = end;
@@ -57,7 +57,7 @@ _make_store (enum file_storage_class class, struct store_meths *meths,
store->class = class;
store->meths = meths;
- store_set_runs (store, runs, runs_len); /* Calls _store_derive() */
+ store_set_runs (store, runs, num_runs); /* Calls _store_derive() */
}
return store;
}
diff --git a/libstore/rdwr.c b/libstore/rdwr.c
index b6622a70..e33b46dc 100644
--- a/libstore/rdwr.c
+++ b/libstore/rdwr.c
@@ -33,7 +33,7 @@ store_find_first_run (struct store *store, off_t addr,
off_t **runs, off_t **runs_end,
off_t *base, size_t *index)
{
- off_t *tail = store->runs, *tail_end = tail + store->runs_len;
+ off_t *tail = store->runs, *tail_end = tail + store->num_runs;
off_t wrap_src = store->wrap_src;
if (addr >= wrap_src && addr < store->end)
diff --git a/libstore/set.c b/libstore/set.c
index 60701f64..d59538e1 100644
--- a/libstore/set.c
+++ b/libstore/set.c
@@ -25,11 +25,11 @@
#include "store.h"
-/* Set STORE's current runs list to (a copy of) RUNS and RUNS_LEN. */
+/* Set STORE's current runs list to (a copy of) RUNS and NUM_RUNS. */
error_t
-store_set_runs (struct store *store, const off_t *runs, unsigned runs_len)
+store_set_runs (struct store *store, const off_t *runs, unsigned num_runs)
{
- unsigned size = runs_len * sizeof (off_t);
+ unsigned size = num_runs * sizeof (off_t);
off_t *copy = malloc (size);
if (!copy)
@@ -40,7 +40,7 @@ store_set_runs (struct store *store, const off_t *runs, unsigned runs_len)
bcopy (runs, copy, size);
store->runs = copy;
- store->runs_len = runs_len;
+ store->num_runs = num_runs;
if (store->block_size > 0)
_store_derive (store);