Deleted Added
sdiff udiff text old ( 202107 ) new ( 202109 )
full compact
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

--- 19 unchanged lines hidden (view full) ---

28 */
29
30#if 0
31#ifndef lint
32static const char sccsid[] = "@(#)pass2.c 8.9 (Berkeley) 4/28/95";
33#endif /* not lint */
34#endif
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sbin/fsck_ffs/pass2.c 202107 2010-01-11 19:52:40Z mckusick $");
37
38#include <sys/param.h>
39
40#include <ufs/ufs/dinode.h>
41#include <ufs/ufs/dir.h>
42#include <ufs/ffs/fs.h>
43
44#include <err.h>
45#include <stdint.h>
46#include <string.h>
47
48#include "fsck.h"
49
50#define MINDIRSIZE (sizeof (struct dirtemplate))
51
52static int fix_extraneous(struct inoinfo *, struct inodesc *);

--- 156 unchanged lines hidden (view full) ---

209 inp->i_dotdot = inp->i_parent;
210 fileerror(inp->i_parent, inp->i_number, "MISSING '..'");
211 if (reply("FIX") == 0)
212 continue;
213 (void)makeentry(inp->i_number, inp->i_parent, "..");
214 inoinfo(inp->i_parent)->ino_linkcnt--;
215 continue;
216 }
217 fileerror(inp->i_parent, inp->i_number,
218 "BAD INODE NUMBER FOR '..'");
219 if (reply("FIX") == 0)
220 continue;
221 inoinfo(inp->i_dotdot)->ino_linkcnt++;
222 inoinfo(inp->i_parent)->ino_linkcnt--;
223 inp->i_dotdot = inp->i_parent;
224 (void)changeino(inp->i_number, "..", inp->i_parent);
225 }
226 /*
227 * Mark all the directories that can be found from the root.
228 */

--- 216 unchanged lines hidden (view full) ---

445 return (ret|KEEPON);
446 dirp->d_ino = 0;
447 return (ret|KEEPON|ALTERED);
448}
449
450static int
451fix_extraneous(struct inoinfo *inp, struct inodesc *idesc)
452{
453 struct inodesc dotdesc;
454 char oldname[MAXPATHLEN + 1];
455 char newname[MAXPATHLEN + 1];
456
457 /*
458 * If we have not yet found "..", look it up now so we know
459 * which inode the directory itself believes is its parent.
460 */

--- 25 unchanged lines hidden (view full) ---

486 idesc->id_number == inp->i_parent || /* Case 2 */
487 inp->i_dotdot != idesc->id_number || /* Case 3 */
488 inp->i_dotdot == inp->i_parent) { /* Case 4 */
489 getpathname(newname, idesc->id_number, idesc->id_number);
490 if (strcmp(newname, "/") != 0)
491 strcat (newname, "/");
492 strcat(newname, idesc->id_dirp->d_name);
493 getpathname(oldname, inp->i_number, inp->i_number);
494 pwarn("%s IS AN EXTRANEOUS HARD LINK TO DIRECTORY %s\n",
495 newname, oldname);
496 if (cursnapshot != 0) {
497 /*
498 * We need to
499 * setcwd(idesc->id_number);
500 * unlink(idesc->id_dirp->d_name);
501 */
502 printf(" (IGNORED)\n");
503 return (0);
504 }
505 if (preen) {
506 printf(" (REMOVED)\n");
507 return (1);
508 }
509 return (reply("REMOVE"));
510 }
511 /*
512 * None of the first four cases above, so must be case (5).
513 * Eliminate the old name and make the new the name the parent.
514 */
515 getpathname(oldname, inp->i_parent, inp->i_number);
516 getpathname(newname, inp->i_number, inp->i_number);
517 pwarn("%s IS AN EXTRANEOUS HARD LINK TO DIRECTORY %s\n", oldname,
518 newname);
519 if (cursnapshot != 0) {
520 /*
521 * We need to
522 * setcwd(inp->i_parent);
523 * unlink(last component of oldname pathname);
524 */
525 printf(" (IGNORED)\n");
526 return (0);
527 }
528 if (!preen && !reply("REMOVE"))
529 return (0);
530 memset(&dotdesc, 0, sizeof(struct inodesc));
531 dotdesc.id_type = DATA;
532 dotdesc.id_number = inp->i_parent; /* directory in which name appears */
533 dotdesc.id_parent = inp->i_number; /* inode number in entry to delete */

--- 29 unchanged lines hidden ---