diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2002-12-03 17:47:06 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2002-12-03 17:47:06 +0000 |
commit | f56926743a89f4aa10302b5837aebaf5817a4e01 (patch) | |
tree | 98dc8f09cd60212c10adc5cb9318416de8bf3403 /libstore | |
parent | 08d35f341d827556553d93d705f78a5319aa0619 (diff) |
doc/
2002-12-03 Marcus Brinkmann <marcus@gnu.org>
* hurd.texi (Store I/O): Add store_set_size.
libstore/
2002-10-01 Ludovic Courtès <ludovic.courtes@utbm.fr>
* store.h: New type store_set_size_meth_t: New type. New
prototype store_set_size.
(struct store_class): Added a set_size () method.
* rdwr.c (store_set_size): New function.
* file.c (file_store_set_size): New function.
(store_file_class): Add file_store_set_size.
* concat.c (concat_set_size): New function.
(store_concat_class): concat_set_size.
* copy.c (copy_set_size): New function.
(store_copy_class): copy_set_size.
* device.c (device_set_size): New function.
(store_device_class): device_set_size.
* memobj.c (memobj_set_size): New function.
(store_memobj_class): memobj_set_size.
* mvol.c (mvol_set_size): New function.
(store_mvol_class): mvol_set_size.
* nbd.c (nbd_set_size): New function.
(store_nbd_class): nbd_set_size.
* remap.c (remap_set_size): New function.
(store_remap_class): remap_set_size.
* stripe.c (stripe_set_size): New function.
(store_stripe_class): stripe_set_size.
* unknown.c (unknown_set_size): New function.
(store_unknown_class): unknown_set_size.
* zero.c (zero_set_size): New function.
(store_zero_class): zero_set_size.
Diffstat (limited to 'libstore')
-rw-r--r-- | libstore/ChangeLog | 29 | ||||
-rw-r--r-- | libstore/copy.c | 11 | ||||
-rw-r--r-- | libstore/device.c | 8 | ||||
-rw-r--r-- | libstore/file.c | 68 | ||||
-rw-r--r-- | libstore/memobj.c | 7 | ||||
-rw-r--r-- | libstore/mvol.c | 8 | ||||
-rw-r--r-- | libstore/nbd.c | 7 | ||||
-rw-r--r-- | libstore/rdwr.c | 13 | ||||
-rw-r--r-- | libstore/remap.c | 8 | ||||
-rw-r--r-- | libstore/store.h | 11 | ||||
-rw-r--r-- | libstore/stripe.c | 10 | ||||
-rw-r--r-- | libstore/task.c | 8 | ||||
-rw-r--r-- | libstore/unknown.c | 7 | ||||
-rw-r--r-- | libstore/zero.c | 8 |
14 files changed, 168 insertions, 35 deletions
diff --git a/libstore/ChangeLog b/libstore/ChangeLog index 955d75b5..bf2fa368 100644 --- a/libstore/ChangeLog +++ b/libstore/ChangeLog @@ -1,3 +1,32 @@ +2002-10-01 Ludovic Courtès <ludovic.courtes@utbm.fr> + + * store.h: New type store_set_size_meth_t: New type. New + prototype store_set_size. + (struct store_class): Added a set_size () method. + * rdwr.c (store_set_size): New function. + * file.c (file_store_set_size): New function. + (store_file_class): Add file_store_set_size. + * concat.c (concat_set_size): New function. + (store_concat_class): concat_set_size. + * copy.c (copy_set_size): New function. + (store_copy_class): copy_set_size. + * device.c (device_set_size): New function. + (store_device_class): device_set_size. + * memobj.c (memobj_set_size): New function. + (store_memobj_class): memobj_set_size. + * mvol.c (mvol_set_size): New function. + (store_mvol_class): mvol_set_size. + * nbd.c (nbd_set_size): New function. + (store_nbd_class): nbd_set_size. + * remap.c (remap_set_size): New function. + (store_remap_class): remap_set_size. + * stripe.c (stripe_set_size): New function. + (store_stripe_class): stripe_set_size. + * unknown.c (unknown_set_size): New function. + (store_unknown_class): unknown_set_size. + * zero.c (zero_set_size): New function. + (store_zero_class): zero_set_size. + 2002-11-03 Neal H. Walfield <neal@cs.uml.edu> * kids.c: Do not include <malloc.h>. diff --git a/libstore/copy.c b/libstore/copy.c index c5232cd3..c670ebf3 100644 --- a/libstore/copy.c +++ b/libstore/copy.c @@ -74,18 +74,22 @@ copy_write (struct store *store, *amount = len; return 0; } + +static error_t +copy_set_size (struct store *store, size_t newsize) +{ + return EOPNOTSUPP; +} error_t copy_allocate_encoding (const struct store *store, struct store_enc *enc) { - /* ... */ return EOPNOTSUPP; } error_t copy_encode (const struct store *store, struct store_enc *enc) { - /* ... */ return EOPNOTSUPP; } @@ -93,7 +97,6 @@ static error_t copy_decode (struct store_enc *enc, const struct store_class *const *classes, struct store **store) { - /* ... */ return EOPNOTSUPP; } @@ -159,7 +162,7 @@ copy_clone (const struct store *from, struct store *to) const struct store_class store_copy_class = { - STORAGE_COPY, "copy", copy_read, copy_write, + STORAGE_COPY, "copy", copy_read, copy_write, copy_set_size, copy_allocate_encoding, copy_encode, copy_decode, copy_set_flags, copy_clear_flags, copy_cleanup, copy_clone, 0, copy_open }; diff --git a/libstore/device.c b/libstore/device.c index ffcf999a..3a72df48 100644 --- a/libstore/device.c +++ b/libstore/device.c @@ -70,6 +70,12 @@ dev_write (struct store *store, } static error_t +dev_set_size (struct store *store, size_t newsize) +{ + return EOPNOTSUPP; +} + +static error_t dev_decode (struct store_enc *enc, const struct store_class *const *classes, struct store **store) { @@ -238,7 +244,7 @@ dev_map (const struct store *store, vm_prot_t prot, mach_port_t *memobj) const struct store_class store_device_class = { - STORAGE_DEVICE, "device", dev_read, dev_write, + STORAGE_DEVICE, "device", dev_read, dev_write, dev_set_size, store_std_leaf_allocate_encoding, store_std_leaf_encode, dev_decode, dev_set_flags, dev_clear_flags, 0, 0, 0, dev_open, 0, dev_map }; diff --git a/libstore/file.c b/libstore/file.c index def0c4c0..49f1c3fb 100644 --- a/libstore/file.c +++ b/libstore/file.c @@ -27,6 +27,29 @@ #include "store.h" +/* Return 0 if STORE's range is enforced by the filesystem, otherwise an + error. */ +static error_t +enforced (struct store *store) +{ + if (store->num_runs != 1 || store->runs[0].start != 0) + /* Can't enforce non-contiguous ranges, or one not starting at 0. */ + return EINVAL; + else + { + /* See if the the current (one) range is that the kernel is enforcing. */ + struct stat st; + error_t err = io_stat (store->port, &st); + + if (!err + && store->runs[0].length != (st.st_size >> store->log2_block_size)) + /* The single run is not the whole file. */ + err = EINVAL; + + return err; + } +} + static error_t file_read (struct store *store, store_offset_t addr, size_t index, size_t amount, void **buf, @@ -46,6 +69,27 @@ file_write (struct store *store, } static error_t +file_store_set_size (struct store *store, size_t newsize) +{ + error_t err; + + if (enforced (store) != 0) + /* Bail out if there is more than a single run. */ + return EOPNOTSUPP; + + err = file_set_size (store->port, newsize); + + if (!err) + { + /* Update STORE's size and run. */ + store->size = newsize; + store->runs[0].length = newsize >> store->log2_block_size; + } + + return err; +} + +static error_t file_decode (struct store_enc *enc, const struct store_class *const *classes, struct store **store) { @@ -88,28 +132,7 @@ ficlose (struct store *store) store->port = MACH_PORT_NULL; } -/* Return 0 if STORE's range is enforced by the filesystem, otherwise an - error. */ -static error_t -enforced (struct store *store) -{ - if (store->num_runs != 1 || store->runs[0].start != 0) - /* Can't enforce non-contiguous ranges, or one not starting at 0. */ - return EINVAL; - else - /* See if the the current (one) range is that the kernel is enforcing. */ - { - struct stat st; - error_t err = io_stat (store->port, &st); - - if (!err - && store->runs[0].length != (st.st_size >> store->log2_block_size)) - /* The single run is not the whole file. */ - err = EINVAL; - return err; - } -} static error_t file_set_flags (struct store *store, int flags) @@ -192,7 +215,7 @@ file_map (const struct store *store, vm_prot_t prot, mach_port_t *memobj) const struct store_class store_file_class = { - STORAGE_HURD_FILE, "file", file_read, file_write, + STORAGE_HURD_FILE, "file", file_read, file_write, file_store_set_size, store_std_leaf_allocate_encoding, store_std_leaf_encode, file_decode, file_set_flags, file_clear_flags, 0, 0, 0, file_open, 0, file_map }; @@ -219,6 +242,7 @@ struct store_class store_file_byte_class = { STORAGE_HURD_FILE, "file", file_byte_read, file_byte_write, + file_store_set_size, store_std_leaf_allocate_encoding, store_std_leaf_encode, file_decode, file_set_flags, file_clear_flags, 0, 0, 0, file_open, 0, file_map }; diff --git a/libstore/memobj.c b/libstore/memobj.c index 9bc75d5d..0d5c816e 100644 --- a/libstore/memobj.c +++ b/libstore/memobj.c @@ -170,6 +170,12 @@ memobj_write (struct store *store, } static error_t +memobj_set_size (struct store *store, size_t newsize) +{ + return EOPNOTSUPP; +} + +static error_t memobj_decode (struct store_enc *enc, const struct store_class *const *classes, struct store **store) { @@ -182,6 +188,7 @@ store_memobj_class = STORAGE_MEMORY, "memobj", map: memobj_map, read: memobj_read, + set_size: memobj_set_size, write: memobj_write, allocate_encoding: store_std_leaf_allocate_encoding, encode: store_std_leaf_encode, diff --git a/libstore/mvol.c b/libstore/mvol.c index 607dd41a..d243cc8a 100644 --- a/libstore/mvol.c +++ b/libstore/mvol.c @@ -70,6 +70,12 @@ mvol_write (struct store *store, return err; } +static error_t +mvol_set_size (struct store *store, size_t newsize) +{ + return EOPNOTSUPP; +} + error_t mvol_remap (struct store *source, const struct store_run *runs, size_t num_runs, @@ -81,7 +87,7 @@ mvol_remap (struct store *source, const struct store_class store_mvol_class = { - -1, "mvol", mvol_read, mvol_write, + -1, "mvol", mvol_read, mvol_write, mvol_set_size, 0, 0, 0, store_set_child_flags, store_clear_child_flags, 0, 0, mvol_remap }; diff --git a/libstore/nbd.c b/libstore/nbd.c index 2eb7ebc9..8bd00c4d 100644 --- a/libstore/nbd.c +++ b/libstore/nbd.c @@ -264,6 +264,12 @@ nbd_read (struct store *store, return err; } +static error_t +nbd_set_size (struct store *store, size_t newsize) +{ + return EOPNOTSUPP; +} + /* Setup hooks. */ @@ -473,6 +479,7 @@ const struct store_class store_nbd_class = validate_name: nbd_validate_name, read: nbd_read, write: nbd_write, + set_size: nbd_set_size, allocate_encoding: store_std_leaf_allocate_encoding, encode: store_std_leaf_encode, decode: nbd_decode, diff --git a/libstore/rdwr.c b/libstore/rdwr.c index ecc604fe..354b193a 100644 --- a/libstore/rdwr.c +++ b/libstore/rdwr.c @@ -285,3 +285,16 @@ store_read (struct store *store, return err; } } + +/* Set STORE's size to NEWSIZE (in bytes). */ +error_t +store_set_size (struct store *store, size_t newsize) +{ + error_t err; + store_set_size_meth_t set_size = store->class->set_size; + + /* Updating the runs list is up to the class set_size method. */ + err = (* set_size) (store, newsize); + + return err; +} diff --git a/libstore/remap.c b/libstore/remap.c index 1ac1351e..55ab51ac 100644 --- a/libstore/remap.c +++ b/libstore/remap.c @@ -41,6 +41,12 @@ remap_write (struct store *store, return store_write (store->children[0], addr, buf, len, amount); } +static error_t +remap_set_size (struct store *store, size_t newsize) +{ + return store_set_size (store->children[0], newsize); +} + error_t remap_allocate_encoding (const struct store *store, struct store_enc *enc) { @@ -200,7 +206,7 @@ remap_validate_name (const char *name, const struct store_class store_remap_class = { - STORAGE_REMAP, "remap", remap_read, remap_write, + STORAGE_REMAP, "remap", remap_read, remap_write, remap_set_size, remap_allocate_encoding, remap_encode, remap_decode, store_set_child_flags, store_clear_child_flags, NULL, NULL, NULL, /* cleanup, clone, remap */ diff --git a/libstore/store.h b/libstore/store.h index ee0a2d21..9d9ee712 100644 --- a/libstore/store.h +++ b/libstore/store.h @@ -132,6 +132,8 @@ typedef error_t (*store_read_meth_t)(struct store *store, store_offset_t addr, size_t index, mach_msg_type_number_t amount, void **buf, mach_msg_type_number_t *len); +typedef error_t (*store_set_size_meth_t)(struct store *store, + size_t newsize); struct store_enc; /* fwd decl */ @@ -144,11 +146,13 @@ struct store_class const char *name; /* Read up to AMOUNT bytes at the underlying address ADDR from the storage - into BUF and LEN. INDEX varies from 0 to the number of runs in STORE. */ + into BUF and LEN. INDEX varies from 0 to the number of runs in STORE. */ store_read_meth_t read; /* Write up to LEN bytes from BUF to the storage at the underlying address - ADDR. INDEX varies from 0 to the number of runs in STORE. */ + ADDR. INDEX varies from 0 to the number of runs in STORE. */ store_write_meth_t write; + /* Set store's size to NEWSIZE (in bytes). */ + store_set_size_meth_t set_size; /* To the lengths of each for the four arrays in ENC, add how much STORE would need to be encoded. */ @@ -305,6 +309,9 @@ error_t store_write (struct store *store, error_t store_read (struct store *store, store_offset_t addr, size_t amount, void **buf, size_t *len); +/* Set STORE's size to NEWSIZE (in bytes). */ +error_t store_set_size (struct store *store, size_t newsize); + /* If STORE was created using store_create, remove the reference to the source from which it was created. */ void store_close_source (struct store *store); diff --git a/libstore/stripe.c b/libstore/stripe.c index eb9bda25..e9c58466 100644 --- a/libstore/stripe.c +++ b/libstore/stripe.c @@ -58,6 +58,12 @@ stripe_write (struct store *store, } error_t +stripe_set_size (struct store *store, size_t newsize) +{ + return EOPNOTSUPP; +} + +error_t stripe_remap (struct store *source, const struct store_run *runs, size_t num_runs, struct store **store) @@ -105,7 +111,7 @@ ileave_decode (struct store_enc *enc, const struct store_class *const *classes, const struct store_class store_ileave_class = { - STORAGE_INTERLEAVE, "interleave", stripe_read, stripe_write, + STORAGE_INTERLEAVE, "interleave", stripe_read, stripe_write, stripe_set_size, ileave_allocate_encoding, ileave_encode, ileave_decode, store_set_child_flags, store_clear_child_flags, 0, 0, stripe_remap }; @@ -149,7 +155,7 @@ concat_decode (struct store_enc *enc, const struct store_class *const *classes, const struct store_class store_concat_class = { - STORAGE_CONCAT, "concat", stripe_read, stripe_write, + STORAGE_CONCAT, "concat", stripe_read, stripe_write, stripe_set_size, concat_allocate_encoding, concat_encode, concat_decode, store_set_child_flags, store_clear_child_flags, 0, 0, stripe_remap, store_concat_open diff --git a/libstore/task.c b/libstore/task.c index 770635a4..ea1475c8 100644 --- a/libstore/task.c +++ b/libstore/task.c @@ -75,6 +75,12 @@ task_write (struct store *store, } static error_t +task_set_size (struct store *store, size_t newsize) +{ + return EOPNOTSUPP; +} + +static error_t task_decode (struct store_enc *enc, const struct store_class *const *classes, struct store **store) { @@ -127,7 +133,7 @@ task_clear_flags (struct store *store, int flags) const struct store_class store_task_class = { - STORAGE_TASK, "task", task_read, task_write, + STORAGE_TASK, "task", task_read, task_write, task_set_size, store_std_leaf_allocate_encoding, store_std_leaf_encode, task_decode, task_set_flags, task_clear_flags, 0, 0, 0, task_open }; diff --git a/libstore/unknown.c b/libstore/unknown.c index f72a0667..8b7f4268 100644 --- a/libstore/unknown.c +++ b/libstore/unknown.c @@ -42,6 +42,12 @@ nowrite (struct store *store, } static error_t +noset_size (struct store *store, size_t newsize) +{ + return EFTYPE; +} + +static error_t noflags (struct store *store, int flags) { return EINVAL; @@ -211,6 +217,7 @@ const struct store_class store_unknown_class = -1, "unknown", read: noread, write: nowrite, + set_size: noset_size, allocate_encoding: unknown_allocate_encoding, encode: unknown_encode, decode: store_unknown_decode, diff --git a/libstore/zero.c b/libstore/zero.c index 13ebb21a..31b8864b 100644 --- a/libstore/zero.c +++ b/libstore/zero.c @@ -55,6 +55,12 @@ zero_write (struct store *store, return 0; } +static error_t +zero_set_size (struct store *store, size_t newsize) +{ + return EOPNOTSUPP; +} + /* Modify SOURCE to reflect those runs in RUNS, and return it in STORE. */ error_t zero_remap (struct store *source, @@ -173,7 +179,7 @@ zero_map (const struct store *store, vm_prot_t prot, mach_port_t *memobj) const struct store_class store_zero_class = { - STORAGE_ZERO, "zero", zero_read, zero_write, + STORAGE_ZERO, "zero", zero_read, zero_write, zero_set_size, zero_allocate_encoding, zero_encode, zero_decode, 0, 0, 0, 0, zero_remap, zero_open, zero_validate_name, zero_map |