diff options
author | Miles Bader <miles@gnu.org> | 1996-03-16 02:08:44 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1996-03-16 02:08:44 +0000 |
commit | 9654dbe0a3569c9a991b6eb37a61b858e7d2df6e (patch) | |
tree | eca27444bc59f8b6ac42979fdfa646de93fb0a42 /libstore | |
parent | 2c873f17bf4130b8f2ab31517627753a13502fca (diff) |
Formerly storeread.c.~4~
Diffstat (limited to 'libstore')
-rw-r--r-- | libstore/storeread.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/libstore/storeread.c b/libstore/storeread.c index 0514aca7..2558a86b 100644 --- a/libstore/storeread.c +++ b/libstore/storeread.c @@ -7,7 +7,9 @@ #include "store.h" struct argp_option options[] = { - {0} + {"file", 'f', 0, 0, "Use file IO instead of the raw device"}, + {"block-size", 'b', "BYTES", 0, "Set the file block size"}, + {0, 0} }; char *arg_doc = "FILE [ADDR [LENGTH]]..."; char *doc = "ADDR is in blocks, and defaults to 0; LENGTH is in bytes, and defaults to the remainder of FILE."; @@ -17,7 +19,7 @@ main (int argc, char **argv) { struct store *store = 0; off_t addr = -1; - int dumped = 0; + int dumped = 0, use_file_io = 0, block_size = 0; void dump (off_t addr, ssize_t len) { @@ -38,6 +40,9 @@ main (int argc, char **argv) { switch (key) { + case 'f': use_file_io = 1; break; + case 'b': block_size = atoi (arg); break; + case ARGP_KEY_ARG: if (! store) { @@ -45,10 +50,27 @@ main (int argc, char **argv) file_t source = file_name_lookup (arg, O_READ, 0); if (errno) error (2, errno, "%s", arg); - err = store_create (source, &store); + if (use_file_io) + if (block_size) + { + off_t runs[2]; + struct stat stat; + + err = io_stat (source, &stat); + if (! err) + { + runs[0] = 0; + runs[1] = stat.st_size / block_size; + err = _store_file_create (source, + block_size, runs, 2, &store); + } + } + else + err = store_file_create (source, &store); + else + err = store_create (source, &store); if (err) error (err, 3, "%s", arg); - mach_port_deallocate (mach_task_self (), source); } else if (addr < 0) addr = atoi (arg); |