From da2495949dfd41675ac36a62ad9034d6bed8b618 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Mon, 8 Jan 2001 22:33:11 +0000 Subject: doc/ 2001-01-08 Marcus Brinkmann * hurd.texi (Store Management): Replace off_t with store_offset_t. (Store I/O): Likewise. (Store Classes): Likewise. ext2fs/ 2001-01-08 Marcus Brinkmann * ext2fs.c (main): Use %Ld instead %ld to print store->size. * hyper.c (get_hypermetadata): Likewise. libstore/ 2001-01-08 Marcus Brinkmann * zero.c (zero_remap): Change type of variables length, old_length to store_offset_t. (zero_decode): Change type of variable size to store_offset_t. (zero_open): Likewise. Use strtoull instead strtoul to parse size argument from name. Use store_offset_t for max_offs and its calculation. (store_zero_create): Use store_offset_t type for size argument. * derive.c (_store_derive): Use store_offset_t as type for variable last_part_base. * stripe.c (addr_adj): Change types of addr argument and return value to store_offset_t. (store_ileave_create): Change type of interleave argument and variables min_end and end to store_offset_t, but type of variable block_size to size_t. (store_concat_create): Change type of variable block_size to size_t. * make.c (_store_create): Change end argument type to store_offset_t. * store.h: New type store_offset_t, define to off64_t. (struct store_run): Change type of start and length to store_offset_t. (struct store): Change type of end, wrap_src, wrap_dst, blocks, size to store_offset_t. Change type of addr arg in store_read_meth_t and store_write_meth_t to store_offset_t, as well as in declarations for store_read and store_write. Change type of argument end in _store_create declaration to store_offset_t. Change type of argument size in store_zero_create to store_offset_t. Change type of argument interleace in store_ileace_create to store_offset_t. * rdwr.c (store_find_first_run): Change type of return value, addr and *base arguments, and variables wrap_src and run_blocks to store_offset_t. (store_next_run): Change type of *base argument to store_offset_t. (store_write): Change type of addr argument and variable base to store_offset_t. (store_read): Likewise, also for addr argument of local function seg_read. Change type of len argument to size_t. * copy.c (copy_read): Change type of addr argument to store_offset_t. (copy_write): Likewise. * device.c (dev_read): Likewise. (dev_write): Likewise. * file.c (file_read): Likewise. (file_write): Likewise. (file_byte_read): Likewise. (file_byte_write): Likewise. * mvol.c (mvol_read): Likewise. (mvol_write): Likewise. * remap.c (remap_read): Likewise. (remap_write): Likewise. * stripe.c (stripe_read): Likewise. (stripe_write): Likewise. * task.c (task_read): Likewise. (task_write): Likewise. * zero.c (zero_read): Likewise. (zero_write): Likewise. * remap.c (store_remap_runs): Change type of addr and len arguments of local function add_run and of local variables addr, length, baddr, blen and len to store_offset_t. (remap_open): Cast -1 to store_offset_t, not off_t. * argp.c (struct store_parsed): Change type of interleave from off_t to store_offset_t. (store_parsed_append_args): Use %Ld instead %ld to print interleave value. (store_parsed_name): Likewise. ufs/ 2001-01-08 Marcus Brinkmann * main.c (main): Use %Ld instead %ld to print store->size. * hyper.c (get_hypermetadata): Likewise. * inode.c (diskfs_S_file_get_storage_info): Change type of variables start and length from off_t to store_offset_t. utils/ 2001-01-08 Marcus Brinkmann * storeread.c (main): Change type of addr to store_offset_t, also for first argument of local function dump. Add comment about store->size as len parameter for store_read. Use atoll instead atoi for addr argument. * storeinfo.c (print_store): Remove local function pint, add two similar functions psiz and poff, accepting and printing a size_t or store_offset_t respectively. Use psiz to print block_size, poff to print blocks and size of store. Use %Ld instead %ld to print runs. * storecat.c (main): Change type of addr and left to store_offset_t. --- doc/ChangeLog | 6 +++++ doc/hurd.texi | 10 +++---- ext2fs/ChangeLog | 5 ++++ ext2fs/ext2fs.c | 2 +- ext2fs/hyper.c | 2 +- libstore/ChangeLog | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ libstore/argp.c | 6 ++--- libstore/copy.c | 4 +-- libstore/derive.c | 2 +- libstore/device.c | 4 +-- libstore/file.c | 10 ++++--- libstore/make.c | 4 +-- libstore/mvol.c | 4 +-- libstore/rdwr.c | 22 ++++++++-------- libstore/remap.c | 18 ++++++------- libstore/store.h | 30 +++++++++++---------- libstore/stripe.c | 18 +++++++------ libstore/task.c | 4 +-- libstore/zero.c | 17 +++++++----- ufs/ChangeLog | 7 +++++ ufs/hyper.c | 2 +- ufs/inode.c | 4 +-- ufs/main.c | 2 +- utils/ChangeLog | 16 ++++++++++++ utils/storecat.c | 4 +-- utils/storeinfo.c | 22 +++++++++++----- utils/storeread.c | 8 +++--- 27 files changed, 220 insertions(+), 89 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 188ad440..e0f6405c 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2001-01-08 Marcus Brinkmann + + * hurd.texi (Store Management): Replace off_t with store_offset_t. + (Store I/O): Likewise. + (Store Classes): Likewise. + 2001-01-07 Marcus Brinkmann * hurd.texi (Diskfs Callbacks): Make diskfs_dirstat_size const. diff --git a/doc/hurd.texi b/doc/hurd.texi index 9097163c..26adffb9 100644 --- a/doc/hurd.texi +++ b/doc/hurd.texi @@ -3032,7 +3032,7 @@ reference to the source from which it was created. Clean up and deallocate @var{store}'s underlying stores. @end deftypefun -@deftypefn {Structure} struct store_run @{ @w{off_t @var{start}}, @var{length}; @} +@deftypefn {Structure} struct store_run @{ @w{store_offset_t @var{start}}, @var{length}; @} A @code{struct store_run} represents a contiguous region in a store's address range. These are used to designate active portions of a store. If @var{start} is -1, then the region is a @dfn{hole} (it is zero-filled @@ -3113,7 +3113,7 @@ the routines below to get a pager. @end ignore @end deftypefun -@deftypefun error_t store_read (@w{struct store *@var{store}}, @w{off_t @var{addr}}, @w{size_t @var{amount}}, @w{void **@var{buf}}, @w{size_t *@var{len}}) +@deftypefun error_t store_read (@w{struct store *@var{store}}, @w{store_offset_t @var{addr}}, @w{size_t @var{amount}}, @w{void **@var{buf}}, @w{size_t *@var{len}}) Read @var{amount} bytes from @var{store} at @var{addr} into @var{buf} and @var{len} (which follows the usual Mach buffer-return semantics) to @var{store} at @var{addr}. @var{addr} is in @var{blocks} (as defined by @@ -3124,7 +3124,7 @@ and @var{len} (which follows the usual Mach buffer-return semantics) to @c `microkernel'? @c tb: nope, Mach-specific semantics. -@deftypefun error_t store_write (@w{struct store *@var{store}}, @w{off_t @var{addr}}, @w{void *@var{buf}}, @w{size_t @var{len}}, @w{size_t *@var{amount}}) +@deftypefun error_t store_write (@w{struct store *@var{store}}, @w{store_offset_t @var{addr}}, @w{void *@var{buf}}, @w{size_t @var{len}}, @w{size_t *@var{amount}}) Write @var{len} bytes from @var{buf} to @var{store} at @var{addr}. Returns the amount written in @var{amount} (in bytes). @var{addr} is in @var{blocks} (as defined by @code{@var{store}->block_size}). @@ -3264,7 +3264,7 @@ has been written into it. This store corresponds to the Unix @file{/dev/zero} device node. @end deftypevar -@deftypefun error_t store_zero_create (@w{off_t @var{size}}, @w{int @var{flags}}, @w{struct store **@var{store}}) +@deftypefun error_t store_zero_create (@w{store_offset_t @var{size}}, @w{int @var{flags}}, @w{struct store **@var{store}}) Return a new zero store @var{size} bytes long in @var{store}. @end deftypefun @@ -3378,7 +3378,7 @@ are not as reliable as others, failures will wipe out every @var{n}th storage block, where @var{n} is the number of substores. @end deftypevar -@deftypefun error_t store_ileave_create (@w{struct store * const *@var{stripes}}, @w{size_t @w{num_stripes}}, @w{off_t @var{interleave}}, @w{int @var{flags}}, @w{struct store **@var{store}}) +@deftypefun error_t store_ileave_create (@w{struct store * const *@var{stripes}}, @w{size_t @w{num_stripes}}, @w{store_offset_t @var{interleave}}, @w{int @var{flags}}, @w{struct store **@var{store}}) Return a new store in @var{store} that interleaves all the stores in @var{stripes} (@var{num_stripes} of them) every @var{interleave} bytes; @var{interleave} must be an integer multiple of each stripe's block diff --git a/ext2fs/ChangeLog b/ext2fs/ChangeLog index b20901a1..279362e0 100644 --- a/ext2fs/ChangeLog +++ b/ext2fs/ChangeLog @@ -1,3 +1,8 @@ +2001-01-08 Marcus Brinkmann + + * ext2fs.c (main): Use %Ld instead %ld to print store->size. + * hyper.c (get_hypermetadata): Likewise. + 2001-01-07 Marcus Brinkmann * dir.c: Make diskfs_dirstat_size const. diff --git a/ext2fs/ext2fs.c b/ext2fs/ext2fs.c index ef22a940..c34ec4d4 100644 --- a/ext2fs/ext2fs.c +++ b/ext2fs/ext2fs.c @@ -173,7 +173,7 @@ main (int argc, char **argv) &store_parsed, &bootstrap); if (store->size < SBLOCK_OFFS + SBLOCK_SIZE) - ext2_panic ("device too small for superblock (%ld bytes)", store->size); + ext2_panic ("device too small for superblock (%Ld bytes)", store->size); if (store->log2_blocks_per_page < 0) ext2_panic ("device block size (%u) greater than page size (%d)", store->block_size, vm_page_size); diff --git a/ext2fs/hyper.c b/ext2fs/hyper.c index 4012f9f7..5460f0e9 100644 --- a/ext2fs/hyper.c +++ b/ext2fs/hyper.c @@ -102,7 +102,7 @@ get_hypermetadata (void) (long long int) sblock->s_blocks_count << log2_block_size); if (log2_dev_blocks_per_fs_block != 0 && (store->size & ((1 << log2_dev_blocks_per_fs_block) - 1)) != 0) - ext2_warning ("%ld (%d byte) device blocks " + ext2_warning ("%Ld (%d byte) device blocks " " unused after last filesystem (%d byte) block", (store->size & ((1 << log2_dev_blocks_per_fs_block) - 1)), store->block_size, block_size); diff --git a/libstore/ChangeLog b/libstore/ChangeLog index fe1405fc..4b1fd92b 100644 --- a/libstore/ChangeLog +++ b/libstore/ChangeLog @@ -1,3 +1,79 @@ +2001-01-08 Marcus Brinkmann + + * zero.c (zero_remap): Change type of variables length, old_length + to store_offset_t. + (zero_decode): Change type of variable size to store_offset_t. + (zero_open): Likewise. Use strtoull instead strtoul to parse + size argument from name. Use store_offset_t for max_offs and + its calculation. + (store_zero_create): Use store_offset_t type for size argument. + + * derive.c (_store_derive): Use store_offset_t as type for + variable last_part_base. + + * stripe.c (addr_adj): Change types of addr argument and return + value to store_offset_t. + (store_ileave_create): Change type of interleave argument and + variables min_end and end to store_offset_t, but type of variable + block_size to size_t. + (store_concat_create): Change type of variable block_size to + size_t. + + * make.c (_store_create): Change end argument type to store_offset_t. + + * store.h: New type store_offset_t, define to off64_t. + (struct store_run): Change type of start and length to + store_offset_t. + (struct store): Change type of end, wrap_src, wrap_dst, blocks, + size to store_offset_t. + Change type of addr arg in store_read_meth_t and + store_write_meth_t to store_offset_t, as well as in declarations + for store_read and store_write. + Change type of argument end in _store_create declaration to + store_offset_t. + Change type of argument size in store_zero_create to + store_offset_t. Change type of argument interleace in + store_ileace_create to store_offset_t. + + * rdwr.c (store_find_first_run): Change type of return value, addr + and *base arguments, and variables wrap_src and run_blocks to + store_offset_t. + (store_next_run): Change type of *base argument to store_offset_t. + (store_write): Change type of addr argument and variable base to + store_offset_t. + (store_read): Likewise, also for addr argument of local function seg_read. + Change type of len argument to size_t. + + * copy.c (copy_read): Change type of addr argument to store_offset_t. + (copy_write): Likewise. + * device.c (dev_read): Likewise. + (dev_write): Likewise. + * file.c (file_read): Likewise. + (file_write): Likewise. + (file_byte_read): Likewise. + (file_byte_write): Likewise. + * mvol.c (mvol_read): Likewise. + (mvol_write): Likewise. + * remap.c (remap_read): Likewise. + (remap_write): Likewise. + * stripe.c (stripe_read): Likewise. + (stripe_write): Likewise. + * task.c (task_read): Likewise. + (task_write): Likewise. + * zero.c (zero_read): Likewise. + (zero_write): Likewise. + + * remap.c (store_remap_runs): Change type of addr and len + arguments of local function add_run and of local variables addr, + length, baddr, blen and len to store_offset_t. + (remap_open): Cast -1 to store_offset_t, not off_t. + + * argp.c (struct store_parsed): Change type of interleave from + off_t to store_offset_t. + (store_parsed_append_args): Use %Ld instead %ld to print + interleave value. + (store_parsed_name): Likewise. + 2001-01-07 Marcus Brinkmann * copy.c: Include . New macro page_aligned. diff --git a/libstore/argp.c b/libstore/argp.c index 97640e19..1ebd32a2 100644 --- a/libstore/argp.c +++ b/libstore/argp.c @@ -59,7 +59,7 @@ struct store_parsed /* DEFAULT_TYPE field passed to parser. */ const struct store_class *default_type; - off_t interleave; /* --interleave value */ + store_offset_t interleave; /* --interleave value */ int layer : 1; /* --layer specified */ }; @@ -85,7 +85,7 @@ store_parsed_append_args (const struct store_parsed *parsed, if (!err && num_names > 1 && (parsed->interleave || parsed->layer)) { if (parsed->interleave) - snprintf (buf, sizeof buf, "--interleave=%ld", parsed->interleave); + snprintf (buf, sizeof buf, "--interleave=%Ld", parsed->interleave); else snprintf (buf, sizeof buf, "--layer=%d", parsed->layer); err = argz_add (args, args_len, buf); @@ -128,7 +128,7 @@ store_parsed_name (const struct store_parsed *parsed, char **name) { if (parsed->interleave) { - snprintf (buf, sizeof buf, "interleave(%ld,", parsed->interleave); + snprintf (buf, sizeof buf, "interleave(%Ld,", parsed->interleave); pfx = buf; } else if (parsed->layer) diff --git a/libstore/copy.c b/libstore/copy.c index 6a4d0d5a..25ea1259 100644 --- a/libstore/copy.c +++ b/libstore/copy.c @@ -32,7 +32,7 @@ static error_t copy_read (struct store *store, - off_t addr, size_t index, size_t amount, void **buf, size_t *len) + store_offset_t addr, size_t index, size_t amount, void **buf, size_t *len) { char *data = store->hook + (addr * store->block_size); @@ -59,7 +59,7 @@ copy_read (struct store *store, static error_t copy_write (struct store *store, - off_t addr, size_t index, void *buf, size_t len, size_t *amount) + store_offset_t addr, size_t index, void *buf, size_t len, size_t *amount) { char *data = store->hook + (addr * store->block_size); diff --git a/libstore/derive.c b/libstore/derive.c index 8c0b2790..41bcbaca 100644 --- a/libstore/derive.c +++ b/libstore/derive.c @@ -50,7 +50,7 @@ _store_derive (struct store *store) to include all iterations. */ { size_t num_iters = store->end / store->wrap_src; - off_t last_part_base = num_iters * store->wrap_src; + store_offset_t last_part_base = num_iters * store->wrap_src; store->blocks *= num_iters; diff --git a/libstore/device.c b/libstore/device.c index 986ca25b..ac7555f6 100644 --- a/libstore/device.c +++ b/libstore/device.c @@ -48,7 +48,7 @@ dev_error (error_t err) static error_t dev_read (struct store *store, - off_t addr, size_t index, mach_msg_type_number_t amount, + store_offset_t addr, size_t index, mach_msg_type_number_t amount, void **buf, mach_msg_type_number_t *len) { return dev_error (device_read (store->port, 0, addr, amount, @@ -57,7 +57,7 @@ dev_read (struct store *store, static error_t dev_write (struct store *store, - off_t addr, size_t index, void *buf, mach_msg_type_number_t len, + store_offset_t addr, size_t index, void *buf, mach_msg_type_number_t len, mach_msg_type_number_t *amount) { return dev_error (device_write (store->port, 0, addr, diff --git a/libstore/file.c b/libstore/file.c index e952a91e..4f9a1b6e 100644 --- a/libstore/file.c +++ b/libstore/file.c @@ -29,7 +29,8 @@ static error_t file_read (struct store *store, - off_t addr, size_t index, size_t amount, void **buf, size_t *len) + store_offset_t addr, size_t index, size_t amount, void **buf, + size_t *len) { size_t bsize = store->block_size; return io_read (store->port, (char **)buf, len, addr * bsize, amount); @@ -37,7 +38,8 @@ file_read (struct store *store, static error_t file_write (struct store *store, - off_t addr, size_t index, void *buf, size_t len, size_t *amount) + store_offset_t addr, size_t index, void *buf, size_t len, + size_t *amount) { size_t bsize = store->block_size; return io_write (store->port, buf, len, addr * bsize, amount); @@ -197,7 +199,7 @@ store_file_class = static error_t file_byte_read (struct store *store, - off_t addr, size_t index, size_t amount, + store_offset_t addr, size_t index, size_t amount, void **buf, size_t *len) { return io_read (store->port, (char **)buf, len, addr, amount); @@ -205,7 +207,7 @@ file_byte_read (struct store *store, static error_t file_byte_write (struct store *store, - off_t addr, size_t index, void *buf, size_t len, + store_offset_t addr, size_t index, void *buf, size_t len, size_t *amount) { return io_write (store->port, buf, len, addr, amount); diff --git a/libstore/make.c b/libstore/make.c index ed476ba4..8f289533 100644 --- a/libstore/make.c +++ b/libstore/make.c @@ -27,8 +27,8 @@ error_t _store_create (const struct store_class *class, mach_port_t port, int flags, size_t block_size, - const struct store_run *runs, size_t num_runs, off_t end, - struct store **store) + const struct store_run *runs, size_t num_runs, + store_offset_t end, struct store **store) { if ((block_size & (block_size - 1)) || (block_size == 0 && num_runs > 0)) return EINVAL; /* block size not a power of two. */ diff --git a/libstore/mvol.c b/libstore/mvol.c index b0753dac..18eacf40 100644 --- a/libstore/mvol.c +++ b/libstore/mvol.c @@ -50,7 +50,7 @@ ensure_vol (struct store *store, size_t vol) static error_t mvol_read (struct store *store, - off_t addr, size_t index, size_t amount, + store_offset_t addr, size_t index, size_t amount, void **buf, size_t *len) { error_t err = ensure_vol (store, index); @@ -61,7 +61,7 @@ mvol_read (struct store *store, static error_t mvol_write (struct store *store, - off_t addr, size_t index, void *buf, size_t len, + store_offset_t addr, size_t index, void *buf, size_t len, size_t *amount) { error_t err = ensure_vol (store, index); diff --git a/libstore/rdwr.c b/libstore/rdwr.c index 85d2ba2b..e79f56a2 100644 --- a/libstore/rdwr.c +++ b/libstore/rdwr.c @@ -27,13 +27,13 @@ ADDR, and is not a hole, and in RUNS_END a pointer pointing at the end of the run list. Returns the offset within it at which ADDR occurs. Also returns BASE, which should be added to offsets from RUNS. */ -static inline off_t -store_find_first_run (struct store *store, off_t addr, +static inline store_offset_t +store_find_first_run (struct store *store, store_offset_t addr, struct store_run **run, struct store_run **runs_end, - off_t *base, size_t *index) + store_offset_t *base, size_t *index) { struct store_run *tail = store->runs, *tail_end = tail + store->num_runs; - off_t wrap_src = store->wrap_src; + store_offset_t wrap_src = store->wrap_src; if (addr >= wrap_src && addr < store->end) /* Locate the correct position within a repeating pattern of runs. */ @@ -49,7 +49,7 @@ store_find_first_run (struct store *store, off_t addr, binary search or something. */ while (tail < tail_end) { - off_t run_blocks = tail->length; + store_offset_t run_blocks = tail->length; if (run_blocks > addr) { @@ -72,7 +72,7 @@ store_find_first_run (struct store *store, off_t addr, things are still kosher. */ static inline int store_next_run (struct store *store, struct store_run *runs_end, - struct store_run **run, off_t *base, size_t *index) + struct store_run **run, store_offset_t *base, size_t *index) { (*run)++; (*index)++; @@ -95,11 +95,11 @@ store_next_run (struct store *store, struct store_run *runs_end, in AMOUNT. ADDR is in BLOCKS (as defined by STORE->block_size). */ error_t store_write (struct store *store, - off_t addr, void *buf, size_t len, size_t *amount) + store_offset_t addr, void *buf, size_t len, size_t *amount) { error_t err; size_t index; - off_t base; + store_offset_t base; struct store_run *run, *runs_end; int block_shift = store->log2_block_size; store_write_meth_t write = store->class->write; @@ -172,10 +172,10 @@ store_write (struct store *store, (as defined by STORE->block_size). */ error_t store_read (struct store *store, - off_t addr, size_t amount, void **buf, size_t *len) + store_offset_t addr, size_t amount, void **buf, size_t *len) { size_t index; - off_t base; + store_offset_t base; struct store_run *run, *runs_end; int block_shift = store->log2_block_size; store_read_meth_t read = store->class->read; @@ -204,7 +204,7 @@ store_read (struct store *store, /* Read LEN bytes from the store address ADDR into BUF_END. BUF_END and AMOUNT are adjusted by the amount actually read. Whether or not the amount read is the same as what was request is returned in ALL. */ - inline error_t seg_read (off_t addr, off_t len, int *all) + inline error_t seg_read (store_offset_t addr, size_t len, int *all) { /* SEG_BUF and SEG_LEN are the buffer for a particular bit of the whole (within one run). */ diff --git a/libstore/remap.c b/libstore/remap.c index e1965ea5..6dd104e8 100644 --- a/libstore/remap.c +++ b/libstore/remap.c @@ -27,7 +27,7 @@ static error_t remap_read (struct store *store, - off_t addr, size_t index, size_t amount, + store_offset_t addr, size_t index, size_t amount, void **buf, size_t *len) { return store_read (store->children[0], addr, amount, buf, len); @@ -35,7 +35,7 @@ remap_read (struct store *store, static error_t remap_write (struct store *store, - off_t addr, size_t index, void *buf, size_t len, + store_offset_t addr, size_t index, void *buf, size_t len, size_t *amount) { return store_write (store->children[0], addr, buf, len, amount); @@ -120,7 +120,7 @@ remap_open (const char *name, int flags, /* Syntax "100+" means block 100 to the end of the store. Since we don't know the size yet, we use -1 as a marker for the code below. */ - runs[nruns++].length = (off_t) -1; + runs[nruns++].length = (store_offset_t) -1; break; } runs[nruns].length = strtoul (p, &endp, 0); @@ -144,7 +144,7 @@ remap_open (const char *name, int flags, and update them to use the actual size of the store. */ size_t i; for (i = 0; i < nruns; ++i) - if (runs[i].length == (off_t) -1) + if (runs[i].length == (store_offset_t) -1) runs[i].length = from->blocks - runs[i].start; /* Now do the remapping according to RUNS. */ @@ -241,7 +241,7 @@ store_remap_runs (const struct store_run *runs, size_t num_runs, size_t xruns_alloced = num_runs + num_base_runs; /* Add the single run [ADDR, LEN) to *XRUNS, returning true if successful. */ - int add_run (off_t addr, off_t len) + int add_run (store_offset_t addr, store_offset_t len) { if (*num_xruns == xruns_alloced) /* Make some more space in *XRUNS. */ @@ -266,13 +266,13 @@ store_remap_runs (const struct store_run *runs, size_t num_runs, for (i = 0; i < num_runs; i++) { - off_t addr = runs[i].start, left = runs[i].length; + store_offset_t addr = runs[i].start, left = runs[i].length; if (addr >= 0) for (j = 0; j < num_base_runs && left > 0; j++) { - off_t baddr = base_runs[j].start; - off_t blen = base_runs[j].length; + store_offset_t baddr = base_runs[j].start; + store_offset_t blen = base_runs[j].length; if (addr >= blen) addr -= blen; @@ -282,7 +282,7 @@ store_remap_runs (const struct store_run *runs, size_t num_runs, else /* Add another output run. */ { - off_t len = blen - addr; /* Size of next output run. */ + store_offset_t len = blen - addr; /* Size of next output run. */ if (! add_run (baddr + addr, len > left ? left : len)) ERR (ENOMEM); addr = 0; diff --git a/libstore/store.h b/libstore/store.h index c7789373..9c5e5bfd 100644 --- a/libstore/store.h +++ b/libstore/store.h @@ -39,10 +39,13 @@ #endif +/* Type for addresses inside the store. */ +typedef off64_t store_offset_t; + /* A portion of a store. If START == -1, it's a hole. */ struct store_run { - off_t start, length; + store_offset_t start, length; }; struct store @@ -57,13 +60,13 @@ struct store size_t num_runs; /* Length of RUNS. */ /* Maximum valid offset. This is the same as SIZE, but in blocks. */ - off_t end; + store_offset_t end; /* WRAP_SRC is the sum of the run lengths in RUNS. If this is less than END, then RUNS describes a repeating pattern, of length WRAP_SRC -- each successive iteration having an additional offset of WRAP_DST. */ - off_t wrap_src; - off_t wrap_dst; /* Only meaningful if WRAP_SRC < END */ + store_offset_t wrap_src; + store_offset_t wrap_dst; /* Only meaningful if WRAP_SRC < END */ /* Handles for the underlying storage. */ char *name; /* Malloced */ @@ -73,9 +76,9 @@ struct store size_t block_size; /* The number of blocks (of size BLOCK_SIZE) in this storage. */ - off_t blocks; + store_offset_t blocks; /* The number of bytes in this storage, including holes. */ - off_t size; + store_offset_t size; /* Log_2 (BLOCK_SIZE) or 0 if not a power of 2. */ unsigned log2_block_size; @@ -121,11 +124,11 @@ struct store | ~(STORE_BACKEND_SPEC_BASE - 1)) typedef error_t (*store_write_meth_t)(struct store *store, - off_t addr, size_t index, + store_offset_t addr, size_t index, void *buf, mach_msg_type_number_t len, mach_msg_type_number_t *amount); typedef error_t (*store_read_meth_t)(struct store *store, - off_t addr, size_t index, + store_offset_t addr, size_t index, mach_msg_type_number_t amount, void **buf, mach_msg_type_number_t *len); @@ -229,7 +232,7 @@ error_t _store_create (const struct store_class *class, mach_port_t port, int flags, size_t block_size, const struct store_run *runs, size_t num_runs, - off_t end, struct store **store); + store_offset_t end, struct store **store); /* Set STORE's current runs list to (a copy of) RUNS and NUM_RUNS. */ error_t store_set_runs (struct store *store, @@ -293,13 +296,13 @@ error_t store_remap (struct store *source, /* Write LEN bytes from BUF to STORE at ADDR. Returns the amount written in AMOUNT (in bytes). ADDR is in BLOCKS (as defined by STORE->block_size). */ error_t store_write (struct store *store, - off_t addr, void *buf, size_t len, size_t *amount); + store_offset_t addr, void *buf, size_t len, size_t *amount); /* Read AMOUNT bytes from STORE at ADDR into BUF & LEN (which following the usual mach buffer-return semantics) to STORE at ADDR. ADDR is in BLOCKS (as defined by STORE->block_size). Note that LEN is in bytes. */ error_t store_read (struct store *store, - off_t addr, size_t amount, void **buf, size_t *len); + store_offset_t addr, size_t amount, void **buf, size_t *len); /* If STORE was created using store_create, remove the reference to the source from which it was created. */ @@ -322,7 +325,7 @@ error_t store_create_pager (struct store *store, vm_prot_t prot, ..., /* Creating specific types of stores. */ /* Return a new zero store SIZE bytes long in STORE. */ -error_t store_zero_create (off_t size, int flags, struct store **store); +error_t store_zero_create (store_offset_t size, int flags, struct store **store); /* Return a new store in STORE referring to the mach device DEVICE. Consumes the send right DEVICE. */ @@ -388,7 +391,8 @@ error_t store_typed_open (const char *name, int flags, consumed -- that is, will be freed when this store is (however, the *array* STRIPES is copied, and so should be freed by the caller). */ error_t store_ileave_create (struct store * const *stripes, size_t num_stripes, - off_t interleave, int flags, struct store **store); + store_offset_t interleave, int flags, + struct store **store); /* Return a new store in STORE that concatenates all the stores in STORES (NUM_STORES of them). The stores in STRIPES are consumed -- that is, will diff --git a/libstore/stripe.c b/libstore/stripe.c index 59fb504e..52a596df 100644 --- a/libstore/stripe.c +++ b/libstore/stripe.c @@ -27,8 +27,8 @@ extern long lcm (long p, long q); /* Return ADDR adjust for any block size difference between STORE and STRIPE. We assume that STORE's block size is no less than STRIPE's. */ -static inline off_t -addr_adj (off_t addr, struct store *store, struct store *stripe) +static inline store_offset_t +addr_adj (store_offset_t addr, struct store *store, struct store *stripe) { unsigned common_bs = store->log2_block_size; unsigned stripe_bs = stripe->log2_block_size; @@ -40,7 +40,7 @@ addr_adj (off_t addr, struct store *store, struct store *stripe) static error_t stripe_read (struct store *store, - off_t addr, size_t index, size_t amount, + store_offset_t addr, size_t index, size_t amount, void **buf, size_t *len) { struct store *stripe = store->children[index]; @@ -49,7 +49,7 @@ stripe_read (struct store *store, static error_t stripe_write (struct store *store, - off_t addr, size_t index, void *buf, size_t len, + store_offset_t addr, size_t index, void *buf, size_t len, size_t *amount) { struct store *stripe = store->children[index]; @@ -160,11 +160,13 @@ store_concat_class = *array* STRIPES is copied, and so should be freed by the caller). */ error_t store_ileave_create (struct store *const *stripes, size_t num_stripes, - off_t interleave, int flags, struct store **store) + store_offset_t interleave, int flags, + struct store **store) { size_t i; error_t err; - off_t block_size = 1, min_end = 0; + size_t block_size = 1; + store_offset_t min_end = 0; struct store_run runs[num_stripes]; int common_flags = STORE_BACKEND_FLAGS; @@ -180,7 +182,7 @@ store_ileave_create (struct store *const *stripes, size_t num_stripes, for (i = 0; i < num_stripes; i++) { /* The stripe's end adjusted to the common block size. */ - off_t end = stripes[i]->end; + store_offset_t end = stripes[i]->end; runs[i].start = 0; runs[i].length = interleave; @@ -222,7 +224,7 @@ store_concat_create (struct store * const *stores, size_t num_stores, { size_t i; error_t err; - off_t block_size = 1; + size_t block_size = 1; int common_flags = STORE_BACKEND_FLAGS; struct store_run runs[num_stores]; diff --git a/libstore/task.c b/libstore/task.c index d2cce5f3..aad91c2c 100644 --- a/libstore/task.c +++ b/libstore/task.c @@ -56,7 +56,7 @@ tclose (struct store *store) static error_t task_read (struct store *store, - off_t addr, size_t index, size_t amount, void **buf, size_t *len) + store_offset_t addr, size_t index, size_t amount, void **buf, size_t *len) { size_t bsize = store->block_size; return vm_read (store->port, addr * bsize, amount, (vm_address_t *)buf, len); @@ -64,7 +64,7 @@ task_read (struct store *store, static error_t task_write (struct store *store, - off_t addr, size_t index, void *buf, size_t len, size_t *amount) + store_offset_t addr, size_t index, void *buf, size_t len, size_t *amount) { size_t bsize = store->block_size; error_t err = vm_write (store->port, addr * bsize, (vm_address_t)buf, len); diff --git a/libstore/zero.c b/libstore/zero.c index f0a23276..4452179b 100644 --- a/libstore/zero.c +++ b/libstore/zero.c @@ -29,7 +29,8 @@ static error_t zero_read (struct store *store, - off_t addr, size_t index, size_t amount, void **buf, size_t *len) + store_offset_t addr, size_t index, size_t amount, void **buf, + size_t *len) { if (*len < amount) { @@ -48,7 +49,8 @@ zero_read (struct store *store, static error_t zero_write (struct store *store, - off_t addr, size_t index, void *buf, size_t len, size_t *amount) + store_offset_t addr, size_t index, void *buf, size_t len, + size_t *amount) { return 0; } @@ -63,7 +65,7 @@ zero_remap (struct store *source, run; here we simply count up the number of blocks specified by RUNS, and modify SOURCE's one run to reflect that. */ int i; - off_t length = 0, old_length = source->runs[0].length; + store_offset_t length = 0, old_length = source->runs[0].length; for (i = 0; i < num_runs; i++) if (runs[i].start < 0 || runs[i].start + runs[i].length >= old_length) return EINVAL; @@ -95,7 +97,7 @@ error_t zero_decode (struct store_enc *enc, const struct store_class *const *classes, struct store **store) { - off_t size; + store_offset_t size; int type, flags; if (enc->cur_int + 2 > enc->num_ints @@ -117,7 +119,7 @@ zero_open (const char *name, int flags, if (name) { char *end; - off_t size = strtoul (name, &end, 0); + store_offset_t size = strtoull (name, &end, 0); if (end == name || end == NULL) return EINVAL; switch (*end) @@ -142,7 +144,8 @@ zero_open (const char *name, int flags, } else { - off_t max_offs = ~((off_t)1 << (CHAR_BIT * sizeof (off_t) - 1)); + store_offset_t max_offs = ~((store_offset_t)1 + << (CHAR_BIT * sizeof (store_offset_t) - 1)); return store_zero_create (max_offs, flags, store); } } @@ -178,7 +181,7 @@ store_zero_class = /* Return a new zero store SIZE bytes long in STORE. */ error_t -store_zero_create (off_t size, int flags, struct store **store) +store_zero_create (store_offset_t size, int flags, struct store **store) { struct store_run run = { 0, size }; return diff --git a/ufs/ChangeLog b/ufs/ChangeLog index 14aed9dd..d8e04a0e 100644 --- a/ufs/ChangeLog +++ b/ufs/ChangeLog @@ -1,3 +1,10 @@ +2001-01-08 Marcus Brinkmann + + * main.c (main): Use %Ld instead %ld to print store->size. + * hyper.c (get_hypermetadata): Likewise. + * inode.c (diskfs_S_file_get_storage_info): Change type of variables + start and length from off_t to store_offset_t. + 2001-01-07 Marcus Brinkmann * dir.c: Make diskfs_dirstat_size const. diff --git a/ufs/hyper.c b/ufs/hyper.c index c907d274..ece327a2 100644 --- a/ufs/hyper.c +++ b/ufs/hyper.c @@ -251,7 +251,7 @@ get_hypermetadata (void) if (store->size < sblock->fs_size * sblock->fs_fsize) { fprintf (stderr, - "Disk size (%ld) less than necessary " + "Disk size (%Ld) less than necessary " "(superblock says we need %ld)\n", store->size, sblock->fs_size * sblock->fs_fsize); exit (1); diff --git a/ufs/inode.c b/ufs/inode.c index 099609ab..72467e1a 100644 --- a/ufs/inode.c +++ b/ufs/inode.c @@ -679,8 +679,8 @@ diskfs_S_file_get_storage_info (struct protid *cred, for (i = 0; i < NDADDR; i++) { - off_t start = fsbtodb (sblock, read_disk_entry (di->di_db[i])); - off_t length = + store_offset_t start = fsbtodb (sblock, read_disk_entry (di->di_db[i])); + store_offset_t length = (((i + 1) * sblock->fs_bsize > np->allocsize) ? np->allocsize - i * sblock->fs_bsize : sblock->fs_bsize); diff --git a/ufs/main.c b/ufs/main.c index cc39019d..8c79d707 100644 --- a/ufs/main.c +++ b/ufs/main.c @@ -169,7 +169,7 @@ main (int argc, char **argv) error (4, 0, "%s: Bad device block size %d (should be <= %d)", diskfs_disk_name, store->block_size, DEV_BSIZE); if (store->size < SBSIZE + SBOFF) - error (5, 0, "%s: Disk too small (%ld bytes)", diskfs_disk_name, + error (5, 0, "%s: Disk too small (%Ld bytes)", diskfs_disk_name, store->size); log2_dev_blocks_per_dev_bsize = 0; diff --git a/utils/ChangeLog b/utils/ChangeLog index 2eb8f4eb..5a56b1c9 100644 --- a/utils/ChangeLog +++ b/utils/ChangeLog @@ -1,3 +1,19 @@ +2001-01-08 Marcus Brinkmann + + * storeread.c (main): Change type of addr to store_offset_t, + also for first argument of local function dump. + Add comment about store->size as len parameter for store_read. + Use atoll instead atoi for addr argument. + + * storeinfo.c (print_store): Remove local function pint, add two + similar functions psiz and poff, accepting and printing a size_t + or store_offset_t respectively. + Use psiz to print block_size, poff to print blocks and size of + store. + Use %Ld instead %ld to print runs. + + * storecat.c (main): Change type of addr and left to store_offset_t. + 2000-10-18 Marcus Brinkmann * devprobe.c (main): Call device_close before freeing the device diff --git a/utils/storecat.c b/utils/storecat.c index be65b63a..f01c12c1 100644 --- a/utils/storecat.c +++ b/utils/storecat.c @@ -30,8 +30,8 @@ main (int argc, char **argv) error_t err; struct store *s; char *name; - off_t addr; - size_t left; + store_offset_t addr; + store_offset_t left; const struct argp_child kids[] = { { &store_argp }, { 0 }}; struct argp argp = { 0, 0, 0, "Write the contents of a store to stdout", kids }; diff --git a/utils/storeinfo.c b/utils/storeinfo.c index 638cebc7..d088a9fd 100644 --- a/utils/storeinfo.c +++ b/utils/storeinfo.c @@ -99,12 +99,20 @@ print_store (struct store *store, int level, unsigned what) fputs (str ?: "-", stdout); } } - void pint (off_t val, unsigned mask) + void psiz (size_t val, unsigned mask) { if ((what & mask) == mask) { psep (); - printf ("%ld", val); + printf ("%u", val); + } + } + void poff (store_offset_t val, unsigned mask) + { + if ((what & mask) == mask) + { + psep (); + printf ("%Ld", val); } } @@ -155,9 +163,9 @@ print_store (struct store *store, int level, unsigned what) } pstr (store->name, W_NAME); - pint (store->block_size, W_BLOCK_SIZE); - pint (store->blocks, W_BLOCKS); - pint (store->size, W_SIZE); + psiz (store->block_size, W_BLOCK_SIZE); + poff (store->blocks, W_BLOCKS); + poff (store->size, W_SIZE); if (what & W_RUNS) { @@ -168,9 +176,9 @@ print_store (struct store *store, int level, unsigned what) putchar (','); if (store->runs[i].start < 0) /* A hole */ - printf ("@+%ld", store->runs[i].length); + printf ("@+%Ld", store->runs[i].length); else - printf ("%ld+%ld", store->runs[i].start, store->runs[i].length); + printf ("%Ld+%Ld", store->runs[i].start, store->runs[i].length); } } diff --git a/utils/storeread.c b/utils/storeread.c index 80c36466..52da3fc2 100644 --- a/utils/storeread.c +++ b/utils/storeread.c @@ -39,14 +39,16 @@ int main (int argc, char **argv) { struct store *store = 0; - off_t addr = -1; + store_offset_t addr = -1; int dumped = 0, use_file_io = 0, block_size = 0; - void dump (off_t addr, ssize_t len) + void dump (store_offset_t addr, ssize_t len) { char buf[4096]; void *data = buf; size_t data_len = sizeof (buf); + + /* XXX: store->size can be too big for len. */ error_t err = store_read (store, addr, len < 0 ? store->size : len, &data, &data_len); @@ -92,7 +94,7 @@ main (int argc, char **argv) error (err, 3, "%s", arg); } else if (addr < 0) - addr = atoi (arg); + addr = atoll (arg); else { dump (addr, atoi (arg)); -- cgit v1.2.3