Deleted Added
full compact
dir.c (96483) dir.c (98542)
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[] = "@(#)dir.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[] = "@(#)dir.c 8.8 (Berkeley) 4/28/95";
37#endif
38static const char rcsid[] =
39 "$FreeBSD: head/sbin/fsck_ffs/dir.c 96483 2002-05-12 23:44:15Z phk $";
39 "$FreeBSD: head/sbin/fsck_ffs/dir.c 98542 2002-06-21 06:18:05Z mckusick $";
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>

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

64};
65struct odirtemplate odirhead = {
66 0, 12, 1, ".",
67 0, DIRBLKSIZ - 12, 2, ".."
68};
69
70static int chgino(struct inodesc *);
71static int dircheck(struct inodesc *, struct direct *);
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>

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

64};
65struct odirtemplate odirhead = {
66 0, 12, 1, ".",
67 0, DIRBLKSIZ - 12, 2, ".."
68};
69
70static int chgino(struct inodesc *);
71static int dircheck(struct inodesc *, struct direct *);
72static int expanddir(struct dinode *dp, char *name);
72static int expanddir(union dinode *dp, char *name);
73static void freedir(ino_t ino, ino_t parent);
74static struct direct *fsck_readdir(struct inodesc *);
73static void freedir(ino_t ino, ino_t parent);
74static struct direct *fsck_readdir(struct inodesc *);
75static struct bufarea *getdirblk(ufs_daddr_t blkno, long size);
75static struct bufarea *getdirblk(ufs2_daddr_t blkno, long size);
76static int lftempname(char *bufp, ino_t ino);
77static int mkentry(struct inodesc *);
78
79/*
80 * Propagate connected state through the tree.
81 */
82void
83propagate(void)

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

250{
251
252 fileerror(ino, ino, errmesg);
253}
254
255void
256fileerror(ino_t cwd, ino_t ino, char *errmesg)
257{
76static int lftempname(char *bufp, ino_t ino);
77static int mkentry(struct inodesc *);
78
79/*
80 * Propagate connected state through the tree.
81 */
82void
83propagate(void)

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

250{
251
252 fileerror(ino, ino, errmesg);
253}
254
255void
256fileerror(ino_t cwd, ino_t ino, char *errmesg)
257{
258 struct dinode *dp;
258 union dinode *dp;
259 char pathbuf[MAXPATHLEN + 1];
260
261 pwarn("%s ", errmesg);
262 pinode(ino);
263 printf("\n");
264 getpathname(pathbuf, cwd, ino);
265 if (ino < ROOTINO || ino > maxino) {
266 pfatal("NAME=%s\n", pathbuf);
267 return;
268 }
269 dp = ginode(ino);
270 if (ftypeok(dp))
271 pfatal("%s=%s\n",
259 char pathbuf[MAXPATHLEN + 1];
260
261 pwarn("%s ", errmesg);
262 pinode(ino);
263 printf("\n");
264 getpathname(pathbuf, cwd, ino);
265 if (ino < ROOTINO || ino > maxino) {
266 pfatal("NAME=%s\n", pathbuf);
267 return;
268 }
269 dp = ginode(ino);
270 if (ftypeok(dp))
271 pfatal("%s=%s\n",
272 (dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE", pathbuf);
272 (DIP(dp, di_mode) & IFMT) == IFDIR ? "DIR" : "FILE",
273 pathbuf);
273 else
274 pfatal("NAME=%s\n", pathbuf);
275}
276
277void
278adjust(struct inodesc *idesc, int lcnt)
279{
274 else
275 pfatal("NAME=%s\n", pathbuf);
276}
277
278void
279adjust(struct inodesc *idesc, int lcnt)
280{
280 struct dinode *dp;
281 union dinode *dp;
281 int saveresolved;
282
283 dp = ginode(idesc->id_number);
282 int saveresolved;
283
284 dp = ginode(idesc->id_number);
284 if (dp->di_nlink == lcnt) {
285 if (DIP(dp, di_nlink) == lcnt) {
285 /*
286 * If we have not hit any unresolved problems, are running
287 * in preen mode, and are on a filesystem using soft updates,
288 * then just toss any partially allocated files.
289 */
290 if (resolved && (preen || bkgrdflag) && usedsoftdep) {
291 clri(idesc, "UNREF", 1);
292 return;

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

307 * Account for the new reference created by linkup().
308 */
309 dp = ginode(idesc->id_number);
310 lcnt--;
311 }
312 }
313 if (lcnt != 0) {
314 pwarn("LINK COUNT %s", (lfdir == idesc->id_number) ? lfname :
286 /*
287 * If we have not hit any unresolved problems, are running
288 * in preen mode, and are on a filesystem using soft updates,
289 * then just toss any partially allocated files.
290 */
291 if (resolved && (preen || bkgrdflag) && usedsoftdep) {
292 clri(idesc, "UNREF", 1);
293 return;

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

308 * Account for the new reference created by linkup().
309 */
310 dp = ginode(idesc->id_number);
311 lcnt--;
312 }
313 }
314 if (lcnt != 0) {
315 pwarn("LINK COUNT %s", (lfdir == idesc->id_number) ? lfname :
315 ((dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE"));
316 ((DIP(dp, di_mode) & IFMT) == IFDIR ? "DIR" : "FILE"));
316 pinode(idesc->id_number);
317 printf(" COUNT %d SHOULD BE %d",
317 pinode(idesc->id_number);
318 printf(" COUNT %d SHOULD BE %d",
318 dp->di_nlink, dp->di_nlink - lcnt);
319 DIP(dp, di_nlink), DIP(dp, di_nlink) - lcnt);
319 if (preen || usedsoftdep) {
320 if (lcnt < 0) {
321 printf("\n");
322 pfatal("LINK COUNT INCREASING");
323 }
324 if (preen)
325 printf(" (ADJUSTED)\n");
326 }
327 if (preen || reply("ADJUST") == 1) {
328 if (bkgrdflag == 0) {
320 if (preen || usedsoftdep) {
321 if (lcnt < 0) {
322 printf("\n");
323 pfatal("LINK COUNT INCREASING");
324 }
325 if (preen)
326 printf(" (ADJUSTED)\n");
327 }
328 if (preen || reply("ADJUST") == 1) {
329 if (bkgrdflag == 0) {
329 dp->di_nlink -= lcnt;
330 DIP(dp, di_nlink) -= lcnt;
330 inodirty();
331 } else {
332 cmd.value = idesc->id_number;
333 cmd.size = -lcnt;
334 if (debug)
335 printf("adjrefcnt ino %ld amt %ld\n",
336 (long)cmd.value, cmd.size);
337 if (sysctl(adjrefcnt, MIBSIZE, 0, 0,

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

378 dirp->d_ino = idesc->id_parent;
379 dirp->d_type = inoinfo(idesc->id_parent)->ino_type;
380 return (ALTERED|STOP);
381}
382
383int
384linkup(ino_t orphan, ino_t parentdir, char *name)
385{
331 inodirty();
332 } else {
333 cmd.value = idesc->id_number;
334 cmd.size = -lcnt;
335 if (debug)
336 printf("adjrefcnt ino %ld amt %ld\n",
337 (long)cmd.value, cmd.size);
338 if (sysctl(adjrefcnt, MIBSIZE, 0, 0,

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

379 dirp->d_ino = idesc->id_parent;
380 dirp->d_type = inoinfo(idesc->id_parent)->ino_type;
381 return (ALTERED|STOP);
382}
383
384int
385linkup(ino_t orphan, ino_t parentdir, char *name)
386{
386 struct dinode *dp;
387 union dinode *dp;
387 int lostdir;
388 ino_t oldlfdir;
389 struct inodesc idesc;
390 char tempname[BUFSIZ];
391
392 memset(&idesc, 0, sizeof(struct inodesc));
393 dp = ginode(orphan);
388 int lostdir;
389 ino_t oldlfdir;
390 struct inodesc idesc;
391 char tempname[BUFSIZ];
392
393 memset(&idesc, 0, sizeof(struct inodesc));
394 dp = ginode(orphan);
394 lostdir = (dp->di_mode & IFMT) == IFDIR;
395 lostdir = (DIP(dp, di_mode) & IFMT) == IFDIR;
395 pwarn("UNREF %s ", lostdir ? "DIR" : "FILE");
396 pinode(orphan);
396 pwarn("UNREF %s ", lostdir ? "DIR" : "FILE");
397 pinode(orphan);
397 if (preen && dp->di_size == 0)
398 if (preen && DIP(dp, di_size) == 0)
398 return (0);
399 if (cursnapshot != 0) {
400 pfatal("FILE LINKUP IN SNAPSHOT");
401 return (0);
402 }
403 if (preen)
404 printf(" (RECONNECTED)\n");
405 else

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

433 }
434 if (lfdir == 0) {
435 pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY");
436 printf("\n\n");
437 return (0);
438 }
439 }
440 dp = ginode(lfdir);
399 return (0);
400 if (cursnapshot != 0) {
401 pfatal("FILE LINKUP IN SNAPSHOT");
402 return (0);
403 }
404 if (preen)
405 printf(" (RECONNECTED)\n");
406 else

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

434 }
435 if (lfdir == 0) {
436 pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY");
437 printf("\n\n");
438 return (0);
439 }
440 }
441 dp = ginode(lfdir);
441 if ((dp->di_mode & IFMT) != IFDIR) {
442 if ((DIP(dp, di_mode) & IFMT) != IFDIR) {
442 pfatal("lost+found IS NOT A DIRECTORY");
443 if (reply("REALLOCATE") == 0)
444 return (0);
445 oldlfdir = lfdir;
446 if ((lfdir = allocdir(ROOTINO, (ino_t)0, lfmode)) == 0) {
447 pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY\n\n");
448 return (0);
449 }

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

470 return (0);
471 }
472 inoinfo(orphan)->ino_linkcnt--;
473 if (lostdir) {
474 if ((changeino(orphan, "..", lfdir) & ALTERED) == 0 &&
475 parentdir != (ino_t)-1)
476 (void)makeentry(orphan, lfdir, "..");
477 dp = ginode(lfdir);
443 pfatal("lost+found IS NOT A DIRECTORY");
444 if (reply("REALLOCATE") == 0)
445 return (0);
446 oldlfdir = lfdir;
447 if ((lfdir = allocdir(ROOTINO, (ino_t)0, lfmode)) == 0) {
448 pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY\n\n");
449 return (0);
450 }

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

471 return (0);
472 }
473 inoinfo(orphan)->ino_linkcnt--;
474 if (lostdir) {
475 if ((changeino(orphan, "..", lfdir) & ALTERED) == 0 &&
476 parentdir != (ino_t)-1)
477 (void)makeentry(orphan, lfdir, "..");
478 dp = ginode(lfdir);
478 dp->di_nlink++;
479 DIP(dp, di_nlink)++;
479 inodirty();
480 inoinfo(lfdir)->ino_linkcnt++;
481 pwarn("DIR I=%lu CONNECTED. ", (u_long)orphan);
482 if (parentdir != (ino_t)-1) {
483 printf("PARENT WAS I=%lu\n", (u_long)parentdir);
484 /*
485 * The parent directory, because of the ordering
486 * guarantees, has had the link count incremented

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

515}
516
517/*
518 * make an entry in a directory
519 */
520int
521makeentry(ino_t parent, ino_t ino, char *name)
522{
480 inodirty();
481 inoinfo(lfdir)->ino_linkcnt++;
482 pwarn("DIR I=%lu CONNECTED. ", (u_long)orphan);
483 if (parentdir != (ino_t)-1) {
484 printf("PARENT WAS I=%lu\n", (u_long)parentdir);
485 /*
486 * The parent directory, because of the ordering
487 * guarantees, has had the link count incremented

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

516}
517
518/*
519 * make an entry in a directory
520 */
521int
522makeentry(ino_t parent, ino_t ino, char *name)
523{
523 struct dinode *dp;
524 union dinode *dp;
524 struct inodesc idesc;
525 char pathbuf[MAXPATHLEN + 1];
526
527 if (parent < ROOTINO || parent >= maxino ||
528 ino < ROOTINO || ino >= maxino)
529 return (0);
530 memset(&idesc, 0, sizeof(struct inodesc));
531 idesc.id_type = DATA;
532 idesc.id_func = mkentry;
533 idesc.id_number = parent;
534 idesc.id_parent = ino; /* this is the inode to enter */
535 idesc.id_fix = DONTKNOW;
536 idesc.id_name = name;
537 dp = ginode(parent);
525 struct inodesc idesc;
526 char pathbuf[MAXPATHLEN + 1];
527
528 if (parent < ROOTINO || parent >= maxino ||
529 ino < ROOTINO || ino >= maxino)
530 return (0);
531 memset(&idesc, 0, sizeof(struct inodesc));
532 idesc.id_type = DATA;
533 idesc.id_func = mkentry;
534 idesc.id_number = parent;
535 idesc.id_parent = ino; /* this is the inode to enter */
536 idesc.id_fix = DONTKNOW;
537 idesc.id_name = name;
538 dp = ginode(parent);
538 if (dp->di_size % DIRBLKSIZ) {
539 dp->di_size = roundup(dp->di_size, DIRBLKSIZ);
539 if (DIP(dp, di_size) % DIRBLKSIZ) {
540 DIP(dp, di_size) = roundup(DIP(dp, di_size), DIRBLKSIZ);
540 inodirty();
541 }
542 if ((ckinode(dp, &idesc) & ALTERED) != 0)
543 return (1);
544 getpathname(pathbuf, parent, parent);
545 dp = ginode(parent);
546 if (expanddir(dp, pathbuf) == 0)
547 return (0);
548 return (ckinode(dp, &idesc) & ALTERED);
549}
550
551/*
552 * Attempt to expand the size of a directory
553 */
554static int
541 inodirty();
542 }
543 if ((ckinode(dp, &idesc) & ALTERED) != 0)
544 return (1);
545 getpathname(pathbuf, parent, parent);
546 dp = ginode(parent);
547 if (expanddir(dp, pathbuf) == 0)
548 return (0);
549 return (ckinode(dp, &idesc) & ALTERED);
550}
551
552/*
553 * Attempt to expand the size of a directory
554 */
555static int
555expanddir(struct dinode *dp, char *name)
556expanddir(union dinode *dp, char *name)
556{
557{
557 ufs_daddr_t lastbn, newblk;
558 ufs2_daddr_t lastbn, newblk;
558 struct bufarea *bp;
559 char *cp, firstblk[DIRBLKSIZ];
560
559 struct bufarea *bp;
560 char *cp, firstblk[DIRBLKSIZ];
561
561 lastbn = lblkno(&sblock, dp->di_size);
562 if (lastbn >= NDADDR - 1 || dp->di_db[lastbn] == 0 || dp->di_size == 0)
562 lastbn = lblkno(&sblock, DIP(dp, di_size));
563 if (lastbn >= NDADDR - 1 || DIP(dp, di_db[lastbn]) == 0 ||
564 DIP(dp, di_size) == 0)
563 return (0);
564 if ((newblk = allocblk(sblock.fs_frag)) == 0)
565 return (0);
565 return (0);
566 if ((newblk = allocblk(sblock.fs_frag)) == 0)
567 return (0);
566 dp->di_db[lastbn + 1] = dp->di_db[lastbn];
567 dp->di_db[lastbn] = newblk;
568 dp->di_size += sblock.fs_bsize;
569 dp->di_blocks += btodb(sblock.fs_bsize);
570 bp = getdirblk(dp->di_db[lastbn + 1],
571 (long)dblksize(&sblock, dp, lastbn + 1));
568 DIP(dp, di_db[lastbn + 1]) = DIP(dp, di_db[lastbn]);
569 DIP(dp, di_db[lastbn]) = newblk;
570 DIP(dp, di_size) += sblock.fs_bsize;
571 DIP(dp, di_blocks) += btodb(sblock.fs_bsize);
572 bp = getdirblk(DIP(dp, di_db[lastbn + 1]),
573 sblksize(&sblock, DIP(dp, di_size), lastbn + 1));
572 if (bp->b_errs)
573 goto bad;
574 memmove(firstblk, bp->b_un.b_buf, DIRBLKSIZ);
575 bp = getdirblk(newblk, sblock.fs_bsize);
576 if (bp->b_errs)
577 goto bad;
578 memmove(bp->b_un.b_buf, firstblk, DIRBLKSIZ);
579 for (cp = &bp->b_un.b_buf[DIRBLKSIZ];
580 cp < &bp->b_un.b_buf[sblock.fs_bsize];
581 cp += DIRBLKSIZ)
582 memmove(cp, &emptydir, sizeof emptydir);
583 dirty(bp);
574 if (bp->b_errs)
575 goto bad;
576 memmove(firstblk, bp->b_un.b_buf, DIRBLKSIZ);
577 bp = getdirblk(newblk, sblock.fs_bsize);
578 if (bp->b_errs)
579 goto bad;
580 memmove(bp->b_un.b_buf, firstblk, DIRBLKSIZ);
581 for (cp = &bp->b_un.b_buf[DIRBLKSIZ];
582 cp < &bp->b_un.b_buf[sblock.fs_bsize];
583 cp += DIRBLKSIZ)
584 memmove(cp, &emptydir, sizeof emptydir);
585 dirty(bp);
584 bp = getdirblk(dp->di_db[lastbn + 1],
585 (long)dblksize(&sblock, dp, lastbn + 1));
586 bp = getdirblk(DIP(dp, di_db[lastbn + 1]),
587 sblksize(&sblock, DIP(dp, di_size), lastbn + 1));
586 if (bp->b_errs)
587 goto bad;
588 memmove(bp->b_un.b_buf, &emptydir, sizeof emptydir);
589 pwarn("NO SPACE LEFT IN %s", name);
590 if (preen)
591 printf(" (EXPANDED)\n");
592 else if (reply("EXPAND") == 0)
593 goto bad;
594 dirty(bp);
595 inodirty();
596 return (1);
597bad:
588 if (bp->b_errs)
589 goto bad;
590 memmove(bp->b_un.b_buf, &emptydir, sizeof emptydir);
591 pwarn("NO SPACE LEFT IN %s", name);
592 if (preen)
593 printf(" (EXPANDED)\n");
594 else if (reply("EXPAND") == 0)
595 goto bad;
596 dirty(bp);
597 inodirty();
598 return (1);
599bad:
598 dp->di_db[lastbn] = dp->di_db[lastbn + 1];
599 dp->di_db[lastbn + 1] = 0;
600 dp->di_size -= sblock.fs_bsize;
601 dp->di_blocks -= btodb(sblock.fs_bsize);
600 DIP(dp, di_db[lastbn]) = DIP(dp, di_db[lastbn + 1]);
601 DIP(dp, di_db[lastbn + 1]) = 0;
602 DIP(dp, di_size) -= sblock.fs_bsize;
603 DIP(dp, di_blocks) -= btodb(sblock.fs_bsize);
602 freeblk(newblk, sblock.fs_frag);
603 return (0);
604}
605
606/*
607 * allocate a new directory
608 */
609ino_t
610allocdir(ino_t parent, ino_t request, int mode)
611{
612 ino_t ino;
613 char *cp;
604 freeblk(newblk, sblock.fs_frag);
605 return (0);
606}
607
608/*
609 * allocate a new directory
610 */
611ino_t
612allocdir(ino_t parent, ino_t request, int mode)
613{
614 ino_t ino;
615 char *cp;
614 struct dinode *dp;
616 union dinode *dp;
615 struct bufarea *bp;
616 struct inoinfo *inp;
617 struct dirtemplate *dirp;
618
619 ino = allocino(request, IFDIR|mode);
620 dirp = &dirhead;
621 dirp->dot_ino = ino;
622 dirp->dotdot_ino = parent;
623 dp = ginode(ino);
617 struct bufarea *bp;
618 struct inoinfo *inp;
619 struct dirtemplate *dirp;
620
621 ino = allocino(request, IFDIR|mode);
622 dirp = &dirhead;
623 dirp->dot_ino = ino;
624 dirp->dotdot_ino = parent;
625 dp = ginode(ino);
624 bp = getdirblk(dp->di_db[0], sblock.fs_fsize);
626 bp = getdirblk(DIP(dp, di_db[0]), sblock.fs_fsize);
625 if (bp->b_errs) {
626 freeino(ino);
627 return (0);
628 }
629 memmove(bp->b_un.b_buf, dirp, sizeof(struct dirtemplate));
630 for (cp = &bp->b_un.b_buf[DIRBLKSIZ];
631 cp < &bp->b_un.b_buf[sblock.fs_fsize];
632 cp += DIRBLKSIZ)
633 memmove(cp, &emptydir, sizeof emptydir);
634 dirty(bp);
627 if (bp->b_errs) {
628 freeino(ino);
629 return (0);
630 }
631 memmove(bp->b_un.b_buf, dirp, sizeof(struct dirtemplate));
632 for (cp = &bp->b_un.b_buf[DIRBLKSIZ];
633 cp < &bp->b_un.b_buf[sblock.fs_fsize];
634 cp += DIRBLKSIZ)
635 memmove(cp, &emptydir, sizeof emptydir);
636 dirty(bp);
635 dp->di_nlink = 2;
637 DIP(dp, di_nlink) = 2;
636 inodirty();
637 if (ino == ROOTINO) {
638 inodirty();
639 if (ino == ROOTINO) {
638 inoinfo(ino)->ino_linkcnt = dp->di_nlink;
640 inoinfo(ino)->ino_linkcnt = DIP(dp, di_nlink);
639 cacheino(dp, ino);
640 return(ino);
641 }
642 if (inoinfo(parent)->ino_state != DSTATE &&
643 inoinfo(parent)->ino_state != DFOUND) {
644 freeino(ino);
645 return (0);
646 }
647 cacheino(dp, ino);
648 inp = getinoinfo(ino);
649 inp->i_parent = parent;
650 inp->i_dotdot = parent;
651 inoinfo(ino)->ino_state = inoinfo(parent)->ino_state;
652 if (inoinfo(ino)->ino_state == DSTATE) {
641 cacheino(dp, ino);
642 return(ino);
643 }
644 if (inoinfo(parent)->ino_state != DSTATE &&
645 inoinfo(parent)->ino_state != DFOUND) {
646 freeino(ino);
647 return (0);
648 }
649 cacheino(dp, ino);
650 inp = getinoinfo(ino);
651 inp->i_parent = parent;
652 inp->i_dotdot = parent;
653 inoinfo(ino)->ino_state = inoinfo(parent)->ino_state;
654 if (inoinfo(ino)->ino_state == DSTATE) {
653 inoinfo(ino)->ino_linkcnt = dp->di_nlink;
655 inoinfo(ino)->ino_linkcnt = DIP(dp, di_nlink);
654 inoinfo(parent)->ino_linkcnt++;
655 }
656 dp = ginode(parent);
656 inoinfo(parent)->ino_linkcnt++;
657 }
658 dp = ginode(parent);
657 dp->di_nlink++;
659 DIP(dp, di_nlink)++;
658 inodirty();
659 return (ino);
660}
661
662/*
663 * free a directory inode
664 */
665static void
666freedir(ino_t ino, ino_t parent)
667{
660 inodirty();
661 return (ino);
662}
663
664/*
665 * free a directory inode
666 */
667static void
668freedir(ino_t ino, ino_t parent)
669{
668 struct dinode *dp;
670 union dinode *dp;
669
670 if (ino != parent) {
671 dp = ginode(parent);
671
672 if (ino != parent) {
673 dp = ginode(parent);
672 dp->di_nlink--;
674 DIP(dp, di_nlink)--;
673 inodirty();
674 }
675 freeino(ino);
676}
677
678/*
679 * generate a temporary name for the lost+found directory.
680 */

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

699 return (namlen);
700}
701
702/*
703 * Get a directory block.
704 * Insure that it is held until another is requested.
705 */
706static struct bufarea *
675 inodirty();
676 }
677 freeino(ino);
678}
679
680/*
681 * generate a temporary name for the lost+found directory.
682 */

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

701 return (namlen);
702}
703
704/*
705 * Get a directory block.
706 * Insure that it is held until another is requested.
707 */
708static struct bufarea *
707getdirblk(ufs_daddr_t blkno, long size)
709getdirblk(ufs2_daddr_t blkno, long size)
708{
709
710 if (pdirbp != 0)
711 pdirbp->b_flags &= ~B_INUSE;
712 pdirbp = getdatablk(blkno, size);
713 return (pdirbp);
714}
710{
711
712 if (pdirbp != 0)
713 pdirbp->b_flags &= ~B_INUSE;
714 pdirbp = getdatablk(blkno, size);
715 return (pdirbp);
716}