summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1998-12-26 20:37:25 +0000
committerRoland McGrath <roland@gnu.org>1998-12-26 20:37:25 +0000
commit21a8a27ca3c6840a5420aa1b6c0ebf9acff07f46 (patch)
treec7ba43a89039d9201d424755fe6f46a1b08ee254
parent25efa8f7dbbc2091db525cc8a0c529220429ef74 (diff)
1998-12-21 Roland McGrath <roland@baalperazim.frob.com>
* open.c (store_open): Like file.c:fiopen, catch EACCES or EROFS and try to open read-only.
-rw-r--r--libstore/open.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libstore/open.c b/libstore/open.c
index ebfe2d5c..ca3eb886 100644
--- a/libstore/open.c
+++ b/libstore/open.c
@@ -1,6 +1,6 @@
/* Store creation from a file name
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1996, 97, 98 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
This file is part of the GNU Hurd.
@@ -37,6 +37,13 @@ store_open (const char *name, int flags,
int open_flags = (flags & STORE_HARD_READONLY) ? O_RDONLY : O_RDWR;
file_t node = file_name_lookup (name, open_flags, 0);
+ if (node == MACH_PORT_NULL && !(flags & STORE_HARD_READONLY)
+ && (errno == EACCES || errno == EROFS))
+ {
+ flags |= STORE_HARD_READONLY;
+ node = file_name_lookup (name, O_RDONLY, 0);
+ }
+
if (node == MACH_PORT_NULL)
return errno;