summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1994-10-15 01:09:10 +0000
committerMichael I. Bushnell <mib@gnu.org>1994-10-15 01:09:10 +0000
commitd90715f3cf771633a2adb0faae6f75418c6dd53b (patch)
tree591aca551ccd55ef33ca6b77277a27ffd59a70f1
parent477fc11b468c89d1d3acf2874f445805eccd2ca5 (diff)
Formerly utilities.c.~6~
-rw-r--r--ufs-fsck/utilities.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c
index 4780ac8a..db603831 100644
--- a/ufs-fsck/utilities.c
+++ b/ufs-fsck/utilities.c
@@ -46,16 +46,24 @@ writeblock (daddr_t addr, void *buf, size_t size)
fsmodified = 1;
}
+/* Last filesystem fragment that we read an inode from */
+static char *lastifrag;
+static daddr_t lastifragaddr;
+
/* Read inode number INO into DINODE. */
void
getinode (ino_t ino, struct dinode *di)
{
daddr_t iblk;
- char buf[sblock->fs_fsize];
+ if (!lastifrag)
+ lastifrag = malloc (sblock->fs_fsize);
+
iblk = ino_to_fsba (sblock, ino);
- readblock (fsbtodb (sblock, iblk), buf, sblock->fs_fsize);
- bcopy (buf + ino_to_fsbo (sblock, ino), di, sizeof (struct dinode));
+ if (iblk != lastifragaddr)
+ readblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_fsize);
+ lastifragaddr = iblk;
+ bcopy (lastifrag + ino_to_fsbo (sblock, ino), di, sizeof (struct dinode));
}
/* Write inode number INO from DINODE. */
@@ -63,12 +71,13 @@ void
write_inode (ino_t ino, struct dinode *di)
{
daddr_t iblk;
- char buf[sblock->fs_fsize];
iblk = ino_to_fsba (sblock, ino);
- readblock (fsbtodb (sblock, iblk), buf, sblock->fs_fsize);
- bcopy (di, buf + ino_to_fsbo (sblock, ino), sizeof (struct dinode));
- writeblock (fsbtodb (sblock, iblk), buf, sblock->fs_fsize);
+ if (iblk != lastifragaddr)
+ readblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_fsize);
+ lastifragaddr = iblk;
+ bcopy (di, lastifrag + ino_to_fsbo (sblock, ino), sizeof (struct dinode));
+ writeblock (fsbtodb (sblock, iblk), lastifrag, sblock->fs_fsize);
}
/* Clear inode number INO and zero DI. */