summaryrefslogtreecommitdiff
path: root/storeio/dev.h
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2000-03-19 20:55:45 +0000
committerRoland McGrath <roland@gnu.org>2000-03-19 20:55:45 +0000
commit402d7b0b9e63a112cf827482a41b3a9c18afbb0f (patch)
treeb551e7f36e6d30cdd1694890c400d566854e5458 /storeio/dev.h
parent85f3e87e0238f89ae9a4fa9c57bad675814107fd (diff)
2000-03-19 Roland McGrath <roland@baalperazim.frob.com>
* dev.h (struct dev): New members store_name, readonly, rdev. (dev_is_readonly): New inline function. * dev.c (dev_open): Take just one arg, a struct dev whose store==0. (dev_close): Shut down the store, but leave DEV intact with store==0. * storeio.c (struct storeio_argp_params): New type. (device, device_lock, store_name): Variables removed. (readonly, inhibit_cache, enforce_store, rdev): Likewise. These are all now members in struct storeio_argp_params or struct dev; rdev now uses dev_t instead of int. (parse_opt): Find a struct storeio_argp_params in STATE->input and fill it in accordingly. Use makedev macro to construct rdev. (trivfs_append_args): Find options in struct dev off control hook. Use major, minor macros. (main): Make DEVICE a local here, and point FSYS->hook at it. Don't modify trivfs_allow_open. (getroot_hook): New static function. (trivfs_getroot_hook): New variable, initialized to that. (check_open_hook): Find struct dev in CNTL->hook and use new dev_open interface. Use dev_is_readonly. (open_hook): Find struct dev in PEROPEN->cntl->hook and check DEV->store. (trivfs_modify_stat): Find struct dev in CRED->po->cntl->hook. Use dev_is_readonly. (trivfs_goaway): Find struct dev in FSYS->hook and use its lock. (trivfs_S_fsys_syncfs): Find struct dev in CNTL->hook.
Diffstat (limited to 'storeio/dev.h')
-rw-r--r--storeio/dev.h39
1 files changed, 26 insertions, 13 deletions
diff --git a/storeio/dev.h b/storeio/dev.h
index d6e50102..b223fe7e 100644
--- a/storeio/dev.h
+++ b/storeio/dev.h
@@ -1,8 +1,7 @@
/* store `device' I/O
- Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
-
- Written by Miles Bader <miles@gnu.ai.mit.edu>
+ Copyright (C) 1995,96,97,99,2000 Free Software Foundation, Inc.
+ Written by Miles Bader <miles@gnu.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -26,12 +25,20 @@
#include <rwlock.h>
#include <hurd/store.h>
-/* Information about a kernel device. */
+/* Information about backend store, which we presumptively call a "device". */
struct dev
{
- /* The device to which we're doing io. */
+ /* The argument specification that we use to open the store. */
+ struct store_parsed *store_name;
+
+ /* The device to which we're doing io. This is null when the
+ device is closed, in which case we will open from `store_name'. */
struct store *store;
+ int readonly; /* Nonzero if user gave --readonly flag. */
+ int enforced; /* Nonzero if user gave --enforced flag. */
+ dev_t rdev; /* A unixy device number for st_rdev. */
+
/* The current owner of the open device. For terminals, this affects
controlling terminal behavior (see term_become_ctty). For all objects
this affects old-style async IO. Negative values represent pgrps. This
@@ -40,7 +47,9 @@ struct dev
indicates that there is no owner. */
pid_t owner;
- int enforced; /* Nonzero iff --enforced flag was given. */
+ /* This lock protects `store' and `owner'. The other members never
+ change after creation, except for those locked by io_lock (below). */
+ struct mutex lock;
/* Nonzero iff the --no-cache flag was given.
If this is set, the remaining members are not used at all
@@ -68,14 +77,18 @@ struct dev
struct mutex pager_lock;
};
-/* Returns a pointer to a new device structure in DEV for the device
- NAME, with the given FLAGS. If BLOCK_SIZE is non-zero, it should be the
- desired block size, and must be a multiple of the device block size.
- If an error occurs, the error code is returned, otherwise 0. */
-error_t dev_open (struct store_parsed *name, int flags, int inhibit_cache,
- struct dev **dev);
+static inline int
+dev_is_readonly (const struct dev *dev)
+{
+ return dev->readonly || (dev->store && (dev->store->flags & STORE_READONLY));
+}
+
+/* Called with DEV->lock held. Try to open the store underlying DEV. */
+error_t dev_open (struct dev *dev);
-/* Free DEV and any resources it consumes. */
+/* Shut down the store underlying DEV and free any resources it consumes.
+ DEV itself remains intact so that dev_open can be called again.
+ This should be called with DEV->lock held. */
void dev_close (struct dev *dev);
/* Returns in MEMOBJ the port for a memory object backed by the storage on