aboutsummaryrefslogtreecommitdiff
path: root/ufs/hyper.c
diff options
context:
space:
mode:
Diffstat (limited to 'ufs/hyper.c')
-rw-r--r--ufs/hyper.c85
1 files changed, 51 insertions, 34 deletions
diff --git a/ufs/hyper.c b/ufs/hyper.c
index e4f58249..ece327a2 100644
--- a/ufs/hyper.c
+++ b/ufs/hyper.c
@@ -1,5 +1,5 @@
/* Fetching and storing the hypermetadata (superblock and cg summary info).
- Copyright (C) 1994, 1995, 1996 Free Software Foundation
+ Copyright (C) 1994, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -19,12 +19,13 @@
#include <string.h>
#include <stdio.h>
#include <error.h>
+#include <hurd/store.h>
static int ufs_clean; /* fs clean before we started writing? */
static int oldformat;
-vm_address_t zeroblock;
+void *zeroblock;
struct fs *sblock;
struct csum *csum;
@@ -33,7 +34,7 @@ void
swab_sblock (struct fs *sblock)
{
int i, j;
-
+
sblock->fs_sblkno = swab_long (sblock->fs_sblkno);
sblock->fs_cblkno = swab_long (sblock->fs_cblkno);
sblock->fs_iblkno = swab_long (sblock->fs_iblkno);
@@ -107,24 +108,24 @@ swab_sblock (struct fs *sblock)
else
for (i = 0; i < sblock->fs_cpc; i++)
for (j = 0; j < sblock->fs_nrpos; j++)
- fs_postbl(sblock, j)[i]
+ fs_postbl(sblock, j)[i]
= swab_short (fs_postbl (sblock, j)[i]);
/* The rot table is all chars */
}
-
+
void
swab_csums (struct csum *csum)
{
int i;
-
+
for (i = 0; i < sblock->fs_ncg; i++)
{
csum[i].cs_ndir = swab_long (csum[i].cs_ndir);
csum[i].cs_nbfree = swab_long (csum[i].cs_nbfree);
csum[i].cs_nifree = swab_long (csum[i].cs_nifree);
csum[i].cs_nffree = swab_long (csum[i].cs_nffree);
- }
+ }
}
void
@@ -137,7 +138,7 @@ get_hypermetadata (void)
/* Free previous values. */
if (zeroblock)
- vm_deallocate (mach_task_self (), zeroblock, sblock->fs_bsize);
+ munmap ((caddr_t) zeroblock, sblock->fs_bsize);
if (csum)
free (csum);
@@ -190,13 +191,13 @@ get_hypermetadata (void)
{
error (0, 0,
"%s: warning: FILESYSTEM NOT UNMOUNTED CLEANLY; PLEASE fsck",
- diskfs_device_arg);
+ diskfs_disk_name);
if (! diskfs_readonly)
{
diskfs_readonly = 1;
error (0, 0,
"%s: MOUNTED READ-ONLY; MUST USE `fsysopts --writable'",
- diskfs_device_arg);
+ diskfs_disk_name);
}
}
@@ -247,18 +248,16 @@ get_hypermetadata (void)
if (swab_disk)
swab_csums (csum);
- if ((diskfs_device_size << diskfs_log2_device_block_size)
- < sblock->fs_size * sblock->fs_fsize)
+ if (store->size < sblock->fs_size * sblock->fs_fsize)
{
fprintf (stderr,
- "Disk size (%ld) less than necessary "
+ "Disk size (%Ld) less than necessary "
"(superblock says we need %ld)\n",
- diskfs_device_size << diskfs_log2_device_block_size,
- sblock->fs_size * sblock->fs_fsize);
+ store->size, sblock->fs_size * sblock->fs_fsize);
exit (1);
}
- vm_allocate (mach_task_self (), &zeroblock, sblock->fs_bsize, 1);
+ zeroblock = mmap (0, sblock->fs_bsize, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
/* If the filesystem has new features in it, don't pay attention to
the user's request not to use them. */
@@ -276,11 +275,9 @@ get_hypermetadata (void)
taken from ordinary data blocks and might not be an even number
of pages; in that case writing it through the pager would nuke whatever
pages came after it on the disk and were backed by file pagers. */
-void
+error_t
diskfs_set_hypermetadata (int wait, int clean)
{
- vm_address_t buf;
- vm_size_t bufsize;
error_t err;
spin_lock (&alloclock);
@@ -289,21 +286,41 @@ diskfs_set_hypermetadata (int wait, int clean)
{
/* Copy into a page-aligned buffer to avoid bugs in kernel device
code. */
-
- bufsize = round_page (fragroundup (sblock, sblock->fs_cssize));
-
- err = diskfs_device_read_sync (fsbtodb (sblock, sblock->fs_csaddr),
- &buf, bufsize);
- if (!err)
+ void *buf = 0;
+ size_t read = 0;
+ size_t bufsize = round_page (fragroundup (sblock, sblock->fs_cssize));
+
+ err = store_read (store,
+ fsbtodb (sblock, sblock->fs_csaddr)
+ << log2_dev_blocks_per_dev_bsize,
+ bufsize, &buf, &read);
+ if (err)
+ return err;
+ else if (read != bufsize)
+ err = EIO;
+ else
{
- bcopy (csum, (void *) buf, sblock->fs_cssize);
+ size_t wrote;
+ bcopy (csum, buf, sblock->fs_cssize);
if (swab_disk)
swab_csums ((struct csum *)buf);
- diskfs_device_write_sync (fsbtodb (sblock, sblock->fs_csaddr),
- buf, bufsize);
- csum_dirty = 0;
- vm_deallocate (mach_task_self (), buf, bufsize);
+ err = store_write (store,
+ fsbtodb (sblock, sblock->fs_csaddr)
+ << log2_dev_blocks_per_dev_bsize,
+ buf, bufsize, &wrote);
+ if (!err && wrote != bufsize)
+ err = EIO;
}
+
+ munmap (buf, read);
+
+ if (err)
+ {
+ spin_unlock (&alloclock);
+ return err;
+ }
+
+ csum_dirty = 0;
}
if (clean && ufs_clean && !sblock->fs_clean)
@@ -326,6 +343,7 @@ diskfs_set_hypermetadata (int wait, int clean)
copy_sblock ();
sync_disk (wait);
+ return 0;
}
/* Copy the sblock into the disk */
@@ -376,10 +394,9 @@ copy_sblock ()
void
diskfs_readonly_changed (int readonly)
{
- vm_protect (mach_task_self (),
- (vm_address_t)disk_image,
- diskfs_device_size << diskfs_log2_device_block_size,
- 0, VM_PROT_READ | (readonly ? 0 : VM_PROT_WRITE));
+ (*(readonly ? store_set_flags : store_clear_flags)) (store, STORE_READONLY);
+
+ mprotect (disk_image, store->size, PROT_READ | (readonly ? 0 : PROT_WRITE));
if (readonly)
{