inode.c (88413) | inode.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[] = "@(#)inode.c 8.8 (Berkeley) 4/28/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[] = "@(#)inode.c 8.8 (Berkeley) 4/28/95"; 37#endif 38static const char rcsid[] = |
39 "$FreeBSD: head/sbin/fsck_ffs/inode.c 88413 2001-12-22 12:35:03Z alfred $"; | 39 "$FreeBSD: head/sbin/fsck_ffs/inode.c 92806 2002-03-20 17:55:10Z obrien $"; |
40#endif /* not lint */ 41 42#include <sys/param.h> 43#include <sys/time.h> 44#include <sys/sysctl.h> 45 46#include <ufs/ufs/dinode.h> 47#include <ufs/ufs/dir.h> --- 7 unchanged lines hidden (view full) --- 55 56static ino_t startinum; 57 58static int iblock __P((struct inodesc *, long ilevel, quad_t isize)); 59 60int 61ckinode(dp, idesc) 62 struct dinode *dp; | 40#endif /* not lint */ 41 42#include <sys/param.h> 43#include <sys/time.h> 44#include <sys/sysctl.h> 45 46#include <ufs/ufs/dinode.h> 47#include <ufs/ufs/dir.h> --- 7 unchanged lines hidden (view full) --- 55 56static ino_t startinum; 57 58static int iblock __P((struct inodesc *, long ilevel, quad_t isize)); 59 60int 61ckinode(dp, idesc) 62 struct dinode *dp; |
63 register struct inodesc *idesc; | 63 struct inodesc *idesc; |
64{ 65 ufs_daddr_t *ap; 66 int ret; 67 long n, ndb, offset; 68 struct dinode dino; 69 quad_t remsize, sizepb; 70 mode_t mode; 71 char pathbuf[MAXPATHLEN + 1]; --- 169 unchanged lines hidden (view full) --- 241 * Check that a block in a legal block number. 242 * Return 0 if in range, 1 if out of range. 243 */ 244int 245chkrange(blk, cnt) 246 ufs_daddr_t blk; 247 int cnt; 248{ | 64{ 65 ufs_daddr_t *ap; 66 int ret; 67 long n, ndb, offset; 68 struct dinode dino; 69 quad_t remsize, sizepb; 70 mode_t mode; 71 char pathbuf[MAXPATHLEN + 1]; --- 169 unchanged lines hidden (view full) --- 241 * Check that a block in a legal block number. 242 * Return 0 if in range, 1 if out of range. 243 */ 244int 245chkrange(blk, cnt) 246 ufs_daddr_t blk; 247 int cnt; 248{ |
249 register int c; | 249 int c; |
250 251 if (cnt <= 0 || blk <= 0 || blk > maxfsblock || 252 cnt - 1 > maxfsblock - blk) 253 return (1); 254 if (cnt > sblock.fs_frag || 255 fragnum(&sblock, blk) + cnt > sblock.fs_frag) { 256 if (debug) 257 printf("bad size: blk %ld, offset %i, size %d\n", --- 128 unchanged lines hidden (view full) --- 386 * Routines to maintain information about directory inodes. 387 * This is built during the first pass and used during the 388 * second and third passes. 389 * 390 * Enter inodes into the cache. 391 */ 392void 393cacheino(dp, inumber) | 250 251 if (cnt <= 0 || blk <= 0 || blk > maxfsblock || 252 cnt - 1 > maxfsblock - blk) 253 return (1); 254 if (cnt > sblock.fs_frag || 255 fragnum(&sblock, blk) + cnt > sblock.fs_frag) { 256 if (debug) 257 printf("bad size: blk %ld, offset %i, size %d\n", --- 128 unchanged lines hidden (view full) --- 386 * Routines to maintain information about directory inodes. 387 * This is built during the first pass and used during the 388 * second and third passes. 389 * 390 * Enter inodes into the cache. 391 */ 392void 393cacheino(dp, inumber) |
394 register struct dinode *dp; | 394 struct dinode *dp; |
395 ino_t inumber; 396{ | 395 ino_t inumber; 396{ |
397 register struct inoinfo *inp; | 397 struct inoinfo *inp; |
398 struct inoinfo **inpp; 399 int blks; 400 401 blks = howmany(dp->di_size, sblock.fs_bsize); 402 if (blks > NDADDR) 403 blks = NDADDR + NIADDR; 404 inp = (struct inoinfo *) 405 malloc(sizeof(*inp) + (blks - 1) * sizeof(ufs_daddr_t)); --- 20 unchanged lines hidden (view full) --- 426 427/* 428 * Look up an inode cache structure. 429 */ 430struct inoinfo * 431getinoinfo(inumber) 432 ino_t inumber; 433{ | 398 struct inoinfo **inpp; 399 int blks; 400 401 blks = howmany(dp->di_size, sblock.fs_bsize); 402 if (blks > NDADDR) 403 blks = NDADDR + NIADDR; 404 inp = (struct inoinfo *) 405 malloc(sizeof(*inp) + (blks - 1) * sizeof(ufs_daddr_t)); --- 20 unchanged lines hidden (view full) --- 426 427/* 428 * Look up an inode cache structure. 429 */ 430struct inoinfo * 431getinoinfo(inumber) 432 ino_t inumber; 433{ |
434 register struct inoinfo *inp; | 434 struct inoinfo *inp; |
435 436 for (inp = inphead[inumber % dirhash]; inp; inp = inp->i_nexthash) { 437 if (inp->i_number != inumber) 438 continue; 439 return (inp); 440 } 441 errx(EEXIT, "cannot find inode %d", inumber); 442 return ((struct inoinfo *)0); 443} 444 445/* 446 * Clean up all the inode cache structure. 447 */ 448void 449inocleanup() 450{ | 435 436 for (inp = inphead[inumber % dirhash]; inp; inp = inp->i_nexthash) { 437 if (inp->i_number != inumber) 438 continue; 439 return (inp); 440 } 441 errx(EEXIT, "cannot find inode %d", inumber); 442 return ((struct inoinfo *)0); 443} 444 445/* 446 * Clean up all the inode cache structure. 447 */ 448void 449inocleanup() 450{ |
451 register struct inoinfo **inpp; | 451 struct inoinfo **inpp; |
452 453 if (inphead == NULL) 454 return; 455 for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--) 456 free((char *)(*inpp)); 457 free((char *)inphead); 458 free((char *)inpsort); 459 inphead = inpsort = NULL; 460} 461 462void 463inodirty() 464{ 465 466 dirty(pbp); 467} 468 469void 470clri(idesc, type, flag) | 452 453 if (inphead == NULL) 454 return; 455 for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--) 456 free((char *)(*inpp)); 457 free((char *)inphead); 458 free((char *)inpsort); 459 inphead = inpsort = NULL; 460} 461 462void 463inodirty() 464{ 465 466 dirty(pbp); 467} 468 469void 470clri(idesc, type, flag) |
471 register struct inodesc *idesc; | 471 struct inodesc *idesc; |
472 char *type; 473 int flag; 474{ | 472 char *type; 473 int flag; 474{ |
475 register struct dinode *dp; | 475 struct dinode *dp; |
476 477 dp = ginode(idesc->id_number); 478 if (flag == 1) { 479 pwarn("%s %s", type, 480 (dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE"); 481 pinode(idesc->id_number); 482 } 483 if (preen || reply("CLEAR") == 1) { --- 17 unchanged lines hidden (view full) --- 501 } 502 } 503} 504 505int 506findname(idesc) 507 struct inodesc *idesc; 508{ | 476 477 dp = ginode(idesc->id_number); 478 if (flag == 1) { 479 pwarn("%s %s", type, 480 (dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE"); 481 pinode(idesc->id_number); 482 } 483 if (preen || reply("CLEAR") == 1) { --- 17 unchanged lines hidden (view full) --- 501 } 502 } 503} 504 505int 506findname(idesc) 507 struct inodesc *idesc; 508{ |
509 register struct direct *dirp = idesc->id_dirp; | 509 struct direct *dirp = idesc->id_dirp; |
510 511 if (dirp->d_ino != idesc->id_parent || idesc->id_entryno < 2) { 512 idesc->id_entryno++; 513 return (KEEPON); 514 } 515 memmove(idesc->id_name, dirp->d_name, (size_t)dirp->d_namlen + 1); 516 return (STOP|FOUND); 517} 518 519int 520findino(idesc) 521 struct inodesc *idesc; 522{ | 510 511 if (dirp->d_ino != idesc->id_parent || idesc->id_entryno < 2) { 512 idesc->id_entryno++; 513 return (KEEPON); 514 } 515 memmove(idesc->id_name, dirp->d_name, (size_t)dirp->d_namlen + 1); 516 return (STOP|FOUND); 517} 518 519int 520findino(idesc) 521 struct inodesc *idesc; 522{ |
523 register struct direct *dirp = idesc->id_dirp; | 523 struct direct *dirp = idesc->id_dirp; |
524 525 if (dirp->d_ino == 0) 526 return (KEEPON); 527 if (strcmp(dirp->d_name, idesc->id_name) == 0 && 528 dirp->d_ino >= ROOTINO && dirp->d_ino <= maxino) { 529 idesc->id_parent = dirp->d_ino; 530 return (STOP|FOUND); 531 } 532 return (KEEPON); 533} 534 535int 536clearentry(idesc) 537 struct inodesc *idesc; 538{ | 524 525 if (dirp->d_ino == 0) 526 return (KEEPON); 527 if (strcmp(dirp->d_name, idesc->id_name) == 0 && 528 dirp->d_ino >= ROOTINO && dirp->d_ino <= maxino) { 529 idesc->id_parent = dirp->d_ino; 530 return (STOP|FOUND); 531 } 532 return (KEEPON); 533} 534 535int 536clearentry(idesc) 537 struct inodesc *idesc; 538{ |
539 register struct direct *dirp = idesc->id_dirp; | 539 struct direct *dirp = idesc->id_dirp; |
540 541 if (dirp->d_ino != idesc->id_parent || idesc->id_entryno < 2) { 542 idesc->id_entryno++; 543 return (KEEPON); 544 } 545 dirp->d_ino = 0; 546 return (STOP|FOUND|ALTERED); 547} 548 549void 550pinode(ino) 551 ino_t ino; 552{ | 540 541 if (dirp->d_ino != idesc->id_parent || idesc->id_entryno < 2) { 542 idesc->id_entryno++; 543 return (KEEPON); 544 } 545 dirp->d_ino = 0; 546 return (STOP|FOUND|ALTERED); 547} 548 549void 550pinode(ino) 551 ino_t ino; 552{ |
553 register struct dinode *dp; 554 register char *p; | 553 struct dinode *dp; 554 char *p; |
555 struct passwd *pw; 556 time_t t; 557 558 printf(" I=%lu ", (u_long)ino); 559 if (ino < ROOTINO || ino > maxino) 560 return; 561 dp = ginode(ino); 562 printf(" OWNER="); --- 42 unchanged lines hidden (view full) --- 605/* 606 * allocate an unused inode 607 */ 608ino_t 609allocino(request, type) 610 ino_t request; 611 int type; 612{ | 555 struct passwd *pw; 556 time_t t; 557 558 printf(" I=%lu ", (u_long)ino); 559 if (ino < ROOTINO || ino > maxino) 560 return; 561 dp = ginode(ino); 562 printf(" OWNER="); --- 42 unchanged lines hidden (view full) --- 605/* 606 * allocate an unused inode 607 */ 608ino_t 609allocino(request, type) 610 ino_t request; 611 int type; 612{ |
613 register ino_t ino; 614 register struct dinode *dp; | 613 ino_t ino; 614 struct dinode *dp; |
615 struct cg *cgp = &cgrp; 616 int cg; 617 618 if (request == 0) 619 request = ROOTINO; 620 else if (inoinfo(request)->ino_state != USTATE) 621 return (0); 622 for (ino = request; ino < maxino; ino++) --- 64 unchanged lines hidden --- | 615 struct cg *cgp = &cgrp; 616 int cg; 617 618 if (request == 0) 619 request = ROOTINO; 620 else if (inoinfo(request)->ino_state != USTATE) 621 return (0); 622 for (ino = request; ino < maxino; ino++) --- 64 unchanged lines hidden --- |