summaryrefslogtreecommitdiff
path: root/storeio/io.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-11-18 06:23:21 +0000
committerRoland McGrath <roland@gnu.org>1999-11-18 06:23:21 +0000
commita28b7971a74ad65d1d38fc96f0b53283abac15b4 (patch)
tree4345413c279e28e3a8744fbbcdea44f7c76ed048 /storeio/io.c
parent5406e6199f7faa54e96b6cef1ec382be26c2bfe8 (diff)
1999-11-14 Roland McGrath <roland@baalperazim.frob.com>
* io.c (trivfs_S_file_get_storage_info): Fail with EOPNOTSUPP when there is no store open. * 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.
Diffstat (limited to 'storeio/io.c')
-rw-r--r--storeio/io.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/storeio/io.c b/storeio/io.c
index f3a6a732..cffe917a 100644
--- a/storeio/io.c
+++ b/storeio/io.c
@@ -306,12 +306,38 @@ trivfs_S_file_get_storage_info (struct trivfs_protid *cred,
{
*ports_type = MACH_MSG_TYPE_COPY_SEND;
- if (! cred)
+ if (! cred || ! cred->po->hook)
return EOPNOTSUPP;
else
{
error_t err;
- struct store *store = ((struct open *)cred->po->hook)->dev->store;
+ struct dev *dev = ((struct open *)cred->po->hook)->dev;
+ struct store *store = dev->store;
+
+ if (dev->enforced && !(store->flags & STORE_ENFORCED))
+ {
+ /* The --enforced switch tells us not to let anyone
+ get at the device, no matter how trustable they are. */
+ size_t name_len = (store->name ? strlen (store->name) + 1 : 0);
+ int i;
+ *num_ports = 0;
+ i = 0;
+ (*ints)[i++] = STORAGE_OTHER;
+ (*ints)[i++] = store->flags;
+ (*ints)[i++] = store->block_size;
+ (*ints)[i++] = 1; /* num_runs */
+ (*ints)[i++] = name_len;
+ (*ints)[i++] = 0; /* misc_len */
+ *num_ints = i;
+ i = 0;
+ (*offsets)[i++] = 0;
+ (*offsets)[i++] = store->size;
+ *num_offsets = i;
+ if (store->name)
+ memcpy (*data, store->name, name_len);
+ *data_len = name_len;
+ return 0;
+ }
if (!cred->isroot
&& !store_is_securely_returnable (store, cred->po->openmodes))