summaryrefslogtreecommitdiff
path: root/storeio/storeio.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-01-27 20:46:47 +0000
committerRoland McGrath <roland@gnu.org>1999-01-27 20:46:47 +0000
commit8e8f1f026b493aeea075d4f1cbc05bbf0dd6cec6 (patch)
treefe387c55550994e63545bb880b143bc6e2f4661d /storeio/storeio.c
parent917384c096a24625c84ab8901901a45e2f2f055f (diff)
1999-01-27 Roland McGrath <roland@baalperazim.frob.com>
* storeio.c (options): New option -c/--no-cache. (inhibit_cache): New variable. (parse_opt): Make -c set it. (trivfs_append_args): Report --no-cache if set. (check_open_hook): Pass inhibit_cache flag to dev_open. * dev.h (struct dev): New member `inhibit_cache'. (dev_open): Update decl. * dev.c (dev_open): Take new arg inhibit_cache, store in new dev. If set, don't initialize buf_offs, io_lock, pager, pager_lock. (dev_read, dev_write): If DEV->inhibit_cache is set, allow only whole-block i/o: EINVAL for non-whole-block attempts. * pager.c (dev_get_memory_object): If DEV->inhibit_cache is set, don't make our own pager; if store_map returns EOPNOTSUPP, so do we.
Diffstat (limited to 'storeio/storeio.c')
-rw-r--r--storeio/storeio.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/storeio/storeio.c b/storeio/storeio.c
index 20a2b000..3990387c 100644
--- a/storeio/storeio.c
+++ b/storeio/storeio.c
@@ -1,6 +1,6 @@
/* A translator for doing I/O to stores
- Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1995, 96, 97, 98, 99 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -35,8 +35,9 @@
static struct argp_option options[] =
{
- {"readonly", 'r', 0, 0, "Disallow writing"},
- {"writable", 'w', 0, 0, "Allow writing"},
+ {"readonly", 'r', 0, 0,"Disallow writing"},
+ {"writable", 'w', 0, 0,"Allow writing"},
+ {"no-cache", 'c', 0, 0,"Never cache data--user io does direct device io"},
{"rdev", 'n', "ID", 0,
"The stat rdev number for this node; may be either a"
" single integer, or of the form MAJOR,MINOR"},
@@ -53,10 +54,13 @@ static struct mutex device_lock;
/* Desired store parameters specified by the user. */
struct store_parsed *store_name;
-static int readonly = 0;
+static int readonly;
+
+/* Nonzero if user gave --no-cache flag. */
+static int inhibit_cache;
/* A unixy device number to return when the device is stat'd. */
-static int rdev = 0;
+static int rdev;
/* Parse a single option. */
static error_t
@@ -67,6 +71,8 @@ parse_opt (int key, char *arg, struct argp_state *state)
case 'r': readonly = 1; break;
case 'w': readonly = 0; break;
+ case 'c': inhibit_cache = 1; break;
+
case 'n':
{
char *start = arg, *end;
@@ -147,6 +153,9 @@ trivfs_append_args (struct trivfs_control *trivfs_control,
err = argz_add (argz, argz_len, buf);
}
+ if (!err && inhibit_cache)
+ err = argz_add (argz, argz_len, "--no-cache");
+
if (! err)
err = argz_add (argz, argz_len, readonly ? "--readonly" : "--writable");
@@ -173,7 +182,8 @@ check_open_hook (struct trivfs_control *trivfs_control,
if (device == NULL)
/* Try and open the device. */
{
- err = dev_open (store_name, readonly ? STORE_READONLY : 0, &device);
+ err = dev_open (store_name, readonly ? STORE_READONLY : 0, inhibit_cache,
+ &device);
if (err)
device = NULL;
if (err && (flags & (O_READ|O_WRITE)) == 0)