From fcd4d641b9f4ccea6fc0cd13fd2146e44f4bb31b Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 12 Oct 1994 23:52:17 +0000 Subject: Formerly utilities.c.~2~ --- ufs-fsck/utilities.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'ufs-fsck') diff --git a/ufs-fsck/utilities.c b/ufs-fsck/utilities.c index c4846445..aad3429b 100644 --- a/ufs-fsck/utilities.c +++ b/ufs-fsck/utilities.c @@ -38,4 +38,39 @@ writeblock (daddr_t addr, void *buf, size_t size) errexit ("CANNOT SEEK TO BLOCK %d", addr); if (write (writefd, buf, size) != size) errexit ("CANNOT READ BLOCK %d", addr); + fsmodified = 1 } + +/* Read inode number INO into DINODE. */ +void +getinode (ino_t ino, struct dinode *di) +{ + daddr_t iblk; + char buf[sblock->fs_fsize]; + + iblk = ino_to_fsba (sblock, ino); + readblock (fsbtodb (iblk), buf, sblock->fs_fsize); + bcopy (buf + ino_to_fsbo (sblock, ino), di, sizeof (struct dinode)); +} + +/* Write inode number INO from DINODE. */ +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 (iblk), buf, sblock->fs_fsize); + bcopy (di, buf + ino_to_fsbo (sblock, ino), sizeof (struct dinode)); + writeblock (fsbtodb (iblk, buf, sblock->fs_fsize)); +} + +/* Clear inode number INO and zero DI. */ +void +clear_inode (ino_t ino, struct dinode *di) +{ + bzero (di, sizeof (struct dinode)); + write_inote (ino, di); +} + -- cgit v1.2.3