From 0e224593fa805f84729abf366db3910dc0b28bfa Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 18 Nov 1999 06:23:27 +0000 Subject: 1999-11-14 Roland McGrath * storeio.c (check_open_hook): Don't check for D_NO_SUCH_DEVICE here. Translation to ENXIO now done in libstore. * dev.h (struct dev): New member `enforced'. * storeio.c (enforce_store): New variable. (options, parse_opt, trivfs_append_args): Grok new option --enforced/-e to set enforce_store. (check_open_hook): Set DEVICE->enforced from enforce_store. * io.c (trivfs_S_file_get_storage_info): If DEV->enforced is set and the store flags lack STORE_ENFORCED, then return STORAGE_OTHER. --- storeio/storeio.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'storeio') diff --git a/storeio/storeio.c b/storeio/storeio.c index 0224aa11..29b8dd6a 100644 --- a/storeio/storeio.c +++ b/storeio/storeio.c @@ -38,6 +38,7 @@ static struct argp_option options[] = {"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"}, + {"enforced", 'e', 0, 0,"Never reveal underlying devices, even to root"}, {"rdev", 'n', "ID", 0, "The stat rdev number for this node; may be either a" " single integer, or of the form MAJOR,MINOR"}, @@ -59,6 +60,9 @@ static int readonly; /* Nonzero if user gave --no-cache flag. */ static int inhibit_cache; +/* Nonzero if user gave --enforced flag. */ +static int enforce_store; + /* A unixy device number to return when the device is stat'd. */ static int rdev; @@ -72,6 +76,7 @@ parse_opt (int key, char *arg, struct argp_state *state) case 'w': readonly = 0; break; case 'c': inhibit_cache = 1; break; + case 'e': enforce_store = 1; break; case 'n': { @@ -156,6 +161,9 @@ trivfs_append_args (struct trivfs_control *trivfs_control, if (!err && inhibit_cache) err = argz_add (argz, argz_len, "--no-cache"); + if (!err && enforce_store) + err = argz_add (argz, argz_len, "--enforced"); + if (! err) err = argz_add (argz, argz_len, readonly ? "--readonly" : "--writable"); @@ -186,14 +194,12 @@ check_open_hook (struct trivfs_control *trivfs_control, &device); if (err) device = NULL; + else + device->enforced = enforce_store; if (err && (flags & (O_READ|O_WRITE)) == 0) /* If we're not opening for read or write, then just ignore the error, as this allows stat to word correctly. XXX */ err = 0; - if (err == D_NO_SUCH_DEVICE) - /* Give the canonical POSIX error code for an absent device, - rather than letting the Mach code propagate up. */ - err = ENXIO; } mutex_unlock (&device_lock); -- cgit v1.2.3