summaryrefslogtreecommitdiff
path: root/ext2fs
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-04-17 15:06:27 +0000
committerMiles Bader <miles@gnu.org>1995-04-17 15:06:27 +0000
commitb1f8e7ca010567d51cd98cc4e6c3210711868e9d (patch)
tree0b987d9b34d0941d073fcbf49fc454b396d27902 /ext2fs
parent2c848001b36c5c04cd8b117795e8c6fcb28b89c3 (diff)
Formerly hyper.c.~7~
Diffstat (limited to 'ext2fs')
-rw-r--r--ext2fs/hyper.c78
1 files changed, 12 insertions, 66 deletions
diff --git a/ext2fs/hyper.c b/ext2fs/hyper.c
index b2ec88a4..d60b5c34 100644
--- a/ext2fs/hyper.c
+++ b/ext2fs/hyper.c
@@ -23,11 +23,9 @@
void
get_hypermetadata (void)
{
- sblock = malloc (SBLOCK_SIZE);
-
assert (!diskfs_catch_exception ());
- bcopy (disk_image + SBLOCK_OFFS, sblock, SBLOCK_SIZE);
- diskfs_end_catch_exception ();
+
+ sblock = boffs_ptr(SBLOCK_OFFS);
if (sblock->s_magic != EXT2_SUPER_MAGIC
#ifdef EXT2FS_PRE_02B_COMPAT
@@ -82,74 +80,22 @@ get_hypermetadata (void)
desc_per_block = block_size / sizeof (struct ext2_group_desc);
addr_per_block = block_size / sizeof (u32);
db_per_group = (groups_count + desc_per_block - 1) / desc_per_block;
-}
-
-/* Write the csum data. This isn't backed by a pager because it is
- 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
-diskfs_set_hypermetadata (int wait, int clean)
-{
-#if 0
- vm_address_t buf;
- vm_size_t bufsize;
- error_t err;
- spin_lock (&alloclock);
-
- if (!csum_dirty)
- {
- spin_unlock (&alloclock);
- return;
- }
-
- /* Copy into a page-aligned buffer to avoid bugs in kernel device code. */
-
- bufsize = round_page (fragroundup (sblock, sblock->fs_cssize));
-
- err = dev_read_sync (fsbtodb (sblock, sblock->fs_csaddr), &buf, bufsize);
- if (!err)
- {
- bcopy (csum, (void *) buf, sblock->fs_cssize);
- dev_write_sync (fsbtodb (sblock, sblock->fs_csaddr), buf, bufsize);
- csum_dirty = 0;
- vm_deallocate (mach_task_self (), buf, bufsize);
- }
-
- spin_unlock (&alloclock);
-#endif
+ diskfs_end_catch_exception ();
}
-/* Copy the sblock into the disk */
void
-copy_sblock ()
+diskfs_set_hypermetadata (int wait, int clean)
{
- int clean = 1; /* XXX wrong... */
-
- assert (!diskfs_catch_exception ());
-
- spin_lock (&sblock_lock);
-
- if (clean && !diskfs_readonly)
+ if (clean && !(sblock->s_state & EXT2_VALID_FS))
+ /* The filesystem is clean, so we need to set the clean flag. We
+ just write the superblock directly, without using the paged copy. */
{
- sblock->s_state |= EXT2_VALID_FS;
- sblock_dirty = 1;
- }
+ struct ext2_super_block clean_sblock;
- if (sblock_dirty)
- {
- bcopy (sblock, disk_image + SBLOCK_OFFS, SBLOCK_SIZE);
- pokel_add (&sblock_pokel, disk_image + SBLOCK_OFFS, SBLOCK_SIZE);
- sblock_dirty = 0;
+ bcopy (sblock, clean_sblock, SBLOCK_SIZE);
+ clean_sblock->s_state |= EXT2_VALID_FS;
+ dev_write_sync (SBLOCK_OFFS / device_block_size,
+ (vm_address_t)clean_sblock, SBLOCK_SIZE);
}
-
- if (clean && !diskfs_readonly)
- {
- sblock->s_state &= ~EXT2_VALID_FS;
- sblock_dirty = 1;
- }
-
- spin_unlock (&sblock_lock);
- diskfs_end_catch_exception ();
}