Hi, > This is basically ok. We will need copyright assignments from you before we > can put it in, though. Can you work out the details with [EMAIL PROTECTED]? > You have the options of just assigning the copyright for this change (or > even disclaim only) or also for future changes.
Since I have no experience with how to deal with this, could you provide me with further details? The copyrights are already assigned to the FSF so should I ask them to explicitely keep it this way? I took into account your comments regarding the patch itself. As for the ellipsis (/* ... */ in copy.c), not that they were actually already there. ;) Thanks, Ludovic.
diff -u /src/hurd/libstore.20020912/ChangeLog /src/hurd/libstore/ChangeLog --- /src/hurd/libstore.20020912/ChangeLog Thu Sep 12 23:00:02 2002 +++ /src/hurd/libstore/ChangeLog Tue Oct 1 11:31:23 2002 @@ -1,3 +1,14 @@ +2002-10-01 Ludovic Courtès <[EMAIL PROTECTED]> + + * store.h (struct store_class): Added a set_size () method. + * rdwr.c (store_set_size): New function. + * file.c (store_file_class): New function file_store_set_size () added. + * concat.c (store_concat_class): Likewise. + * copy.c (store_copy_class): Likewise. + * device.c (store_device_class): Likewise. + * stripe.c (store_ileave_class): Likewise. + * zero.c (store_zero_class): Likewise. + 2002-06-07 Roland McGrath <[EMAIL PROTECTED]> * store.h (struct store_enc): Use loff_t instead of off_t. diff -u /src/hurd/libstore.20020912/copy.c /src/hurd/libstore/copy.c --- /src/hurd/libstore.20020912/copy.c Thu Sep 12 23:00:02 2002 +++ /src/hurd/libstore/copy.c Tue Oct 1 11:42:03 2002 @@ -74,18 +74,22 @@ *amount = len; return 0; } + +static error_t +copy_set_size (struct store *store, store_offset_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 @@ copy_decode (struct store_enc *enc, const struct store_class *const *classes, struct store **store) { - /* ... */ return EOPNOTSUPP; } @@ -159,7 +162,7 @@ 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 -u /src/hurd/libstore.20020912/device.c /src/hurd/libstore/device.c --- /src/hurd/libstore.20020912/device.c Thu Sep 12 23:00:02 2002 +++ /src/hurd/libstore/device.c Thu Sep 12 23:01:02 2002 @@ -70,6 +70,12 @@ } static error_t +dev_set_size (struct store *store, store_offset_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 @@ 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 -u /src/hurd/libstore.20020912/file.c /src/hurd/libstore/file.c --- /src/hurd/libstore.20020912/file.c Thu Sep 12 23:00:02 2002 +++ /src/hurd/libstore/file.c Tue Oct 1 11:40:24 2002 @@ -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 @@ } static error_t +file_store_set_size (struct store *store, store_offset_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 @@ 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 @@ 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 @@ 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 -u /src/hurd/libstore.20020912/rdwr.c /src/hurd/libstore/rdwr.c --- /src/hurd/libstore.20020912/rdwr.c Thu Sep 12 23:00:02 2002 +++ /src/hurd/libstore/rdwr.c Sat Sep 14 21:21:20 2002 @@ -285,3 +285,16 @@ return err; } } + +/* Set STORE's size to NEWSIZE (in bytes). */ +error_t +store_set_size (struct store *store, off_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 -u /src/hurd/libstore.20020912/store.h /src/hurd/libstore/store.h --- /src/hurd/libstore.20020912/store.h Thu Sep 12 23:00:02 2002 +++ /src/hurd/libstore/store.h Sat Sep 14 21:20:42 2002 @@ -132,6 +132,8 @@ 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, + store_offset_t newsize); struct store_enc; /* fwd decl */ @@ -144,11 +146,13 @@ 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. */ @@ -304,6 +308,9 @@ (as defined by STORE->block_size). Note that LEN is in bytes. */ 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, off_t newsize); /* If STORE was created using store_create, remove the reference to the source from which it was created. */ diff -u /src/hurd/libstore.20020912/stripe.c /src/hurd/libstore/stripe.c --- /src/hurd/libstore.20020912/stripe.c Thu Sep 12 23:00:02 2002 +++ /src/hurd/libstore/stripe.c Thu Sep 12 23:06:24 2002 @@ -58,6 +58,12 @@ } error_t +stripe_set_size (struct store *store, store_offset_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 @@ 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 @@ 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 -u /src/hurd/libstore.20020912/zero.c /src/hurd/libstore/zero.c --- /src/hurd/libstore.20020912/zero.c Thu Sep 12 23:00:02 2002 +++ /src/hurd/libstore/zero.c Tue Oct 1 13:18:36 2002 @@ -55,6 +55,12 @@ return 0; } +static error_t +zero_set_size (struct store *store, store_offset_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 @@ 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