fsutil.c (86514) | fsutil.c (92806) |
---|---|
1/* 2 * Copyright (c) 1980, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95"; 37#endif 38static const char rcsid[] = | 1/* 2 * Copyright (c) 1980, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95"; 37#endif 38static const char rcsid[] = |
39 "$FreeBSD: head/sbin/fsck_ffs/fsutil.c 86514 2001-11-17 23:48:21Z iedowse $"; | 39 "$FreeBSD: head/sbin/fsck_ffs/fsutil.c 92806 2002-03-20 17:55:10Z obrien $"; |
40#endif /* not lint */ 41 42#include <sys/param.h> 43#include <sys/types.h> 44#include <sys/sysctl.h> 45#include <sys/stat.h> 46 47#include <ufs/ufs/dinode.h> --- 94 unchanged lines hidden (view full) --- 142} 143 144/* 145 * Malloc buffers and set up cache. 146 */ 147void 148bufinit() 149{ | 40#endif /* not lint */ 41 42#include <sys/param.h> 43#include <sys/types.h> 44#include <sys/sysctl.h> 45#include <sys/stat.h> 46 47#include <ufs/ufs/dinode.h> --- 94 unchanged lines hidden (view full) --- 142} 143 144/* 145 * Malloc buffers and set up cache. 146 */ 147void 148bufinit() 149{ |
150 register struct bufarea *bp; | 150 struct bufarea *bp; |
151 long bufcnt, i; 152 char *bufp; 153 154 pbp = pdirbp = (struct bufarea *)0; 155 bufp = malloc((unsigned int)sblock.fs_bsize); 156 if (bufp == 0) 157 errx(EEXIT, "cannot allocate buffer pool"); 158 cgblk.b_un.b_buf = bufp; --- 23 unchanged lines hidden (view full) --- 182/* 183 * Manage a cache of directory blocks. 184 */ 185struct bufarea * 186getdatablk(blkno, size) 187 ufs_daddr_t blkno; 188 long size; 189{ | 151 long bufcnt, i; 152 char *bufp; 153 154 pbp = pdirbp = (struct bufarea *)0; 155 bufp = malloc((unsigned int)sblock.fs_bsize); 156 if (bufp == 0) 157 errx(EEXIT, "cannot allocate buffer pool"); 158 cgblk.b_un.b_buf = bufp; --- 23 unchanged lines hidden (view full) --- 182/* 183 * Manage a cache of directory blocks. 184 */ 185struct bufarea * 186getdatablk(blkno, size) 187 ufs_daddr_t blkno; 188 long size; 189{ |
190 register struct bufarea *bp; | 190 struct bufarea *bp; |
191 192 for (bp = bufhead.b_next; bp != &bufhead; bp = bp->b_next) 193 if (bp->b_bno == fsbtodb(&sblock, blkno)) 194 goto foundit; 195 for (bp = bufhead.b_prev; bp != &bufhead; bp = bp->b_prev) 196 if ((bp->b_flags & B_INUSE) == 0) 197 break; 198 if (bp == &bufhead) --- 9 unchanged lines hidden (view full) --- 208 bufhead.b_next->b_prev = bp; 209 bufhead.b_next = bp; 210 bp->b_flags |= B_INUSE; 211 return (bp); 212} 213 214void 215getblk(bp, blk, size) | 191 192 for (bp = bufhead.b_next; bp != &bufhead; bp = bp->b_next) 193 if (bp->b_bno == fsbtodb(&sblock, blkno)) 194 goto foundit; 195 for (bp = bufhead.b_prev; bp != &bufhead; bp = bp->b_prev) 196 if ((bp->b_flags & B_INUSE) == 0) 197 break; 198 if (bp == &bufhead) --- 9 unchanged lines hidden (view full) --- 208 bufhead.b_next->b_prev = bp; 209 bufhead.b_next = bp; 210 bp->b_flags |= B_INUSE; 211 return (bp); 212} 213 214void 215getblk(bp, blk, size) |
216 register struct bufarea *bp; | 216 struct bufarea *bp; |
217 ufs_daddr_t blk; 218 long size; 219{ 220 ufs_daddr_t dblk; 221 222 dblk = fsbtodb(&sblock, blk); 223 if (bp->b_bno != dblk) { 224 flush(fswritefd, bp); 225 diskreads++; 226 bp->b_errs = bread(fsreadfd, bp->b_un.b_buf, dblk, size); 227 bp->b_bno = dblk; 228 bp->b_size = size; 229 } 230} 231 232void 233flush(fd, bp) 234 int fd; | 217 ufs_daddr_t blk; 218 long size; 219{ 220 ufs_daddr_t dblk; 221 222 dblk = fsbtodb(&sblock, blk); 223 if (bp->b_bno != dblk) { 224 flush(fswritefd, bp); 225 diskreads++; 226 bp->b_errs = bread(fsreadfd, bp->b_un.b_buf, dblk, size); 227 bp->b_bno = dblk; 228 bp->b_size = size; 229 } 230} 231 232void 233flush(fd, bp) 234 int fd; |
235 register struct bufarea *bp; | 235 struct bufarea *bp; |
236{ | 236{ |
237 register int i, j; | 237 int i, j; |
238 239 if (!bp->b_dirty) 240 return; 241 bp->b_dirty = 0; 242 if (fswritefd < 0) { 243 pfatal("WRITING IN READ_ONLY MODE.\n"); 244 return; 245 } --- 27 unchanged lines hidden (view full) --- 273 if (reply("CONTINUE") == 0) 274 exit(EEXIT); 275} 276 277void 278ckfini(markclean) 279 int markclean; 280{ | 238 239 if (!bp->b_dirty) 240 return; 241 bp->b_dirty = 0; 242 if (fswritefd < 0) { 243 pfatal("WRITING IN READ_ONLY MODE.\n"); 244 return; 245 } --- 27 unchanged lines hidden (view full) --- 273 if (reply("CONTINUE") == 0) 274 exit(EEXIT); 275} 276 277void 278ckfini(markclean) 279 int markclean; 280{ |
281 register struct bufarea *bp, *nbp; | 281 struct bufarea *bp, *nbp; |
282 int ofsmodified, cnt = 0; 283 284 if (bkgrdflag) { 285 unlink(snapname); 286 if ((!(sblock.fs_flags & FS_UNCLEAN)) != markclean) { 287 cmd.value = FS_UNCLEAN; 288 cmd.size = markclean ? -1 : 1; 289 if (sysctlbyname("vfs.ffs.setflags", 0, 0, --- 196 unchanged lines hidden (view full) --- 486 * Find a pathname 487 */ 488void 489getpathname(namebuf, curdir, ino) 490 char *namebuf; 491 ino_t curdir, ino; 492{ 493 int len; | 282 int ofsmodified, cnt = 0; 283 284 if (bkgrdflag) { 285 unlink(snapname); 286 if ((!(sblock.fs_flags & FS_UNCLEAN)) != markclean) { 287 cmd.value = FS_UNCLEAN; 288 cmd.size = markclean ? -1 : 1; 289 if (sysctlbyname("vfs.ffs.setflags", 0, 0, --- 196 unchanged lines hidden (view full) --- 486 * Find a pathname 487 */ 488void 489getpathname(namebuf, curdir, ino) 490 char *namebuf; 491 ino_t curdir, ino; 492{ 493 int len; |
494 register char *cp; | 494 char *cp; |
495 struct inodesc idesc; 496 static int busy = 0; 497 498 if (curdir == ino && ino == ROOTINO) { 499 (void)strcpy(namebuf, "/"); 500 return; 501 } 502 if (busy || --- 62 unchanged lines hidden (view full) --- 565 (void)signal(SIGQUIT, SIG_DFL); 566} 567 568/* 569 * determine whether an inode should be fixed. 570 */ 571int 572dofix(idesc, msg) | 495 struct inodesc idesc; 496 static int busy = 0; 497 498 if (curdir == ino && ino == ROOTINO) { 499 (void)strcpy(namebuf, "/"); 500 return; 501 } 502 if (busy || --- 62 unchanged lines hidden (view full) --- 565 (void)signal(SIGQUIT, SIG_DFL); 566} 567 568/* 569 * determine whether an inode should be fixed. 570 */ 571int 572dofix(idesc, msg) |
573 register struct inodesc *idesc; | 573 struct inodesc *idesc; |
574 char *msg; 575{ 576 577 switch (idesc->id_fix) { 578 579 case DONTKNOW: 580 if (idesc->id_type == DATA) 581 direrror(idesc->id_number, msg); --- 144 unchanged lines hidden --- | 574 char *msg; 575{ 576 577 switch (idesc->id_fix) { 578 579 case DONTKNOW: 580 if (idesc->id_type == DATA) 581 direrror(idesc->id_number, msg); --- 144 unchanged lines hidden --- |