diff options
Diffstat (limited to 'libdiskfs')
-rw-r--r-- | libdiskfs/ChangeLog | 10 | ||||
-rw-r--r-- | libdiskfs/dev-io.c | 13 | ||||
-rw-r--r-- | libdiskfs/diskfs.h | 2 | ||||
-rw-r--r-- | libdiskfs/readonly.c | 13 |
4 files changed, 32 insertions, 6 deletions
diff --git a/libdiskfs/ChangeLog b/libdiskfs/ChangeLog index 531ad50b..d5ea48a4 100644 --- a/libdiskfs/ChangeLog +++ b/libdiskfs/ChangeLog @@ -1,5 +1,15 @@ +Thu Aug 8 18:18:09 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * readonly.c: Include <error.h>. + Wed Aug 7 13:53:56 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + * readonly.c (diskfs_check_readonly): If we get an error from + diskfs_hypermetadata, then switch to readonly. + * diskfs.h (diskfs_set_hypermetadata): Require an error code return. + * dev-io.c (diskfs_device_write_sync): If we get D_READ_ONLY, then + return EROFS to the caller instead of EIO. + * node-create.c (diskfs_create_node): New files always copy GID from their parent; that's NetBSD's behavior, and it's good enough for me. diff --git a/libdiskfs/dev-io.c b/libdiskfs/dev-io.c index 9d0ed9d0..d3be449f 100644 --- a/libdiskfs/dev-io.c +++ b/libdiskfs/dev-io.c @@ -1,5 +1,5 @@ /* Device input and output - Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU Hurd. @@ -29,10 +29,15 @@ error_t diskfs_device_write_sync (off_t addr, vm_address_t data, size_t len) { int written; + error_t err; + assert (!diskfs_readonly); - if (device_write (diskfs_device, 0, diskfs_device_start + addr, - (io_buf_ptr_t) data, len, &written) - || written != len) + err = device_write (diskfs_device, 0, diskfs_device_start + addr, + (io_buf_ptr_t) data, len, &written); + + if (err == D_READ_ONLY) + return EROFS; + else if (err || written != len) return EIO; return 0; } diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h index 8cada32f..fe8374de 100644 --- a/libdiskfs/diskfs.h +++ b/libdiskfs/diskfs.h @@ -364,7 +364,7 @@ error_t diskfs_grow (struct node *np, off_t size, struct protid *cred); metadata. If CLEAN is nonzero, then after this is written the filesystem will be absolutely clean, and the non-paged metadata can so indicate. */ -void diskfs_set_hypermetadata (int wait, int clean); +error_t diskfs_set_hypermetadata (int wait, int clean); /* The user must define this function. Allocate a new node to be of mode MODE in locked directory DP (don't actually set the mode or diff --git a/libdiskfs/readonly.c b/libdiskfs/readonly.c index 18ade09a..17ed312e 100644 --- a/libdiskfs/readonly.c +++ b/libdiskfs/readonly.c @@ -21,6 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <fcntl.h> +#include <error.h> #include "priv.h" @@ -29,13 +30,23 @@ int _diskfs_diskdirty; int diskfs_check_readonly () { + error_t err; + if (diskfs_readonly) return 1; else { if (!_diskfs_diskdirty) { - diskfs_set_hypermetadata (1, 0); + err = diskfs_set_hypermetadata (1, 0); + if (err) + { + error (0, 0, + "%s: MEDIA NOT WRITABLE; switching to READ-ONLY", + diskfs_device_arg); + diskfs_readonly = 1; + return 1; + } _diskfs_diskdirty = 1; } return 0; |