~ubuntu-branches/ubuntu/hoary/xfsprogs/hoary

« back to all changes in this revision

Viewing changes to repair/phase6.c

  • Committer: Bazaar Package Importer
  • Author(s): Nathan Scott
  • Date: 2004-07-28 21:11:38 UTC
  • Revision ID: james.westby@ubuntu.com-20040728211138-0v4pdnunnp7na5lm
Tags: 2.6.20-1
* New upstream release.
* Fix xfs_io segfault on non-XFS files.  (closes: #260470)
* Fix packaging botch, deleted files included.  (closes: #260491)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
3
 
 * 
 
2
 * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
 
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify it
5
5
 * under the terms of version 2 of the GNU General Public License as
6
6
 * published by the Free Software Foundation.
7
 
 * 
 
7
 *
8
8
 * This program is distributed in the hope that it would be useful, but
9
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 
 * 
 
11
 *
12
12
 * Further, this software is distributed without any warranty that it is
13
13
 * free of the rightful claim of any third person regarding infringement
14
14
 * or the like.  Any license provided herein, whether implied or
15
15
 * otherwise, applies only to this software file.  Patent licenses, if
16
16
 * any, provided herein do not apply to combinations of this program with
17
17
 * other software, or any other product whatsoever.
18
 
 * 
 
18
 *
19
19
 * You should have received a copy of the GNU General Public License along
20
20
 * with this program; if not, write the Free Software Foundation, Inc., 59
21
21
 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22
 
 * 
 
22
 *
23
23
 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24
24
 * Mountain View, CA  94043, or:
25
 
 * 
26
 
 * http://www.sgi.com 
27
 
 * 
28
 
 * For further information regarding this notice, see: 
29
 
 * 
 
25
 *
 
26
 * http://www.sgi.com
 
27
 *
 
28
 * For further information regarding this notice, see:
 
29
 *
30
30
 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31
31
 */
32
32
 
69
69
 * Track the contents of the freespace table in a directory.
70
70
 */
71
71
typedef struct freetab {
72
 
        int                     naents;
73
 
        int                     nents;
 
72
        int                     naents; /* expected number of data blocks */
 
73
        int                     nents;  /* number of data blocks processed */
74
74
        struct freetab_ent {
75
75
                xfs_dir2_data_off_t     v;
76
76
                short                   s;
85
85
#define DIR_HASH_CK_NODATA      3
86
86
#define DIR_HASH_CK_NOLEAF      4
87
87
#define DIR_HASH_CK_BADSTALE    5
 
88
#define DIR_HASH_CK_TOTAL       6
88
89
 
89
90
static void
90
91
dir_hash_add(
97
98
        dir_hash_ent_t          *p;
98
99
 
99
100
        i = DIR_HASH_FUNC(hashtab, addr);
100
 
        if ((p = malloc(sizeof(*p))) == NULL) {
101
 
                do_error("malloc failed in dir_hash_add (%u bytes)\n",
 
101
        if ((p = malloc(sizeof(*p))) == NULL)
 
102
                do_error(_("malloc failed in dir_hash_add (%u bytes)\n"),
102
103
                        sizeof(*p));
103
 
                exit(1);
104
 
        }
105
104
        p->next = hashtab->tab[i];
106
105
        hashtab->tab[i] = p;
107
106
        if (!(p->junkit = junk))
132
131
        xfs_inode_t     *ip,
133
132
        int             seeval)
134
133
{
135
 
        static char     *seevalstr[] = {
136
 
                "ok",
137
 
                "duplicate leaf",
138
 
                "hash value mismatch",
139
 
                "no data entry",
140
 
                "no leaf entry",
141
 
                "bad stale count",
142
 
        };
 
134
        static char     *seevalstr[DIR_HASH_CK_TOTAL];
 
135
        static int      done;
 
136
 
 
137
        if (!done) {
 
138
                seevalstr[DIR_HASH_CK_OK] = _("ok");
 
139
                seevalstr[DIR_HASH_CK_DUPLEAF] = _("duplicate leaf");
 
140
                seevalstr[DIR_HASH_CK_BADHASH] = _("hash value mismatch");
 
141
                seevalstr[DIR_HASH_CK_NODATA] = _("no data entry");
 
142
                seevalstr[DIR_HASH_CK_NOLEAF] = _("no leaf entry");
 
143
                seevalstr[DIR_HASH_CK_BADSTALE] = _("bad stale count");
 
144
                done = 1;
 
145
        }
143
146
 
144
147
        if (seeval == DIR_HASH_CK_OK && dir_hash_unseen(hashtab))
145
148
                seeval = DIR_HASH_CK_NOLEAF;
146
149
        if (seeval == DIR_HASH_CK_OK)
147
150
                return 0;
148
 
        do_warn("bad hash table for directory inode %llu (%s): ", ip->i_ino,
149
 
                seevalstr[seeval]);
 
151
        do_warn(_("bad hash table for directory inode %llu (%s): "),
 
152
                ip->i_ino, seevalstr[seeval]);
150
153
        if (!no_modify)
151
 
                do_warn("rebuilding\n");
 
154
                do_warn(_("rebuilding\n"));
152
155
        else
153
 
                do_warn("would rebuild\n");
 
156
                do_warn(_("would rebuild\n"));
154
157
        return 1;
155
158
}
156
159
 
183
186
                hsize = 1024;
184
187
        else if (hsize < 16)
185
188
                hsize = 16;
186
 
        if ((hashtab = calloc(DIR_HASH_TAB_SIZE(hsize), 1)) == NULL) {
187
 
                do_error("calloc failed in dir_hash_init\n");
188
 
                exit(1);
189
 
        }
 
189
        if ((hashtab = calloc(DIR_HASH_TAB_SIZE(hsize), 1)) == NULL)
 
190
                do_error(_("calloc failed in dir_hash_init\n"));
190
191
        hashtab->size = hsize;
191
192
        return hashtab;
192
193
}
318
319
        int     err)
319
320
{
320
321
        if (err == ENOSPC) {
321
 
                do_error("ran out of disk space!\n");
 
322
                do_error(_("ran out of disk space!\n"));
322
323
        } else
323
 
                do_error("xfs_trans_reserve returned %d\n", err);
 
324
                do_error(_("xfs_trans_reserve returned %d\n"), err);
324
325
}
325
326
 
326
327
void
348
349
 
349
350
        error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, &ip);
350
351
        if (error) {
351
 
                do_error("couldn't iget realtime bitmap inode -- error - %d\n",
 
352
                do_error(
 
353
                _("couldn't iget realtime bitmap inode -- error - %d\n"),
352
354
                        error);
353
355
        }
354
356
 
355
357
        bzero(&ip->i_d, sizeof(xfs_dinode_core_t));
356
358
 
357
359
        ip->i_d.di_magic = XFS_DINODE_MAGIC;
358
 
        ip->i_d.di_mode = IFREG;
 
360
        ip->i_d.di_mode = S_IFREG;
359
361
        ip->i_d.di_version = XFS_DINODE_VERSION_1;
360
362
        ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
361
363
        ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
397
399
                          XFS_BMAPI_WRITE, &first, mp->m_sb.sb_rbmblocks,
398
400
                          map, &nmap, &flist);
399
401
                if (error) {
400
 
                        do_error("couldn't allocate realtime bitmap - err %d\n",
 
402
                        do_error(
 
403
                        _("couldn't allocate realtime bitmap, error = %d\n"),
401
404
                                error);
402
405
                }
403
406
                for (i = 0, ep = map; i < nmap; i++, ep++) {
410
413
        error = libxfs_bmap_finish(&tp, &flist, first, &committed);
411
414
        if (error) {
412
415
                do_error(
413
 
                "allocation of the realtime bitmap failed, error = %d\n",
 
416
                _("allocation of the realtime bitmap failed, error = %d\n"),
414
417
                        error);
415
418
        }
416
419
        libxfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_SYNC, 0);
439
442
 
440
443
        error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, &ip);
441
444
        if (error) {
442
 
                do_error("couldn't iget realtime bitmap inode -- error - %d\n",
 
445
                do_error(
 
446
                _("couldn't iget realtime bitmap inode -- error - %d\n"),
443
447
                        error);
444
448
        }
445
449
 
452
456
                                        &first, 1, &map, &nmap, NULL);
453
457
                if (error || nmap != 1) {
454
458
                        do_error(
455
 
                        "couldn't map realtime bitmap block %llu - err %d\n",
 
459
                _("couldn't map realtime bitmap block %llu, error = %d\n"),
456
460
                                bno, error);
457
461
                }
458
462
 
460
464
 
461
465
                error = libxfs_trans_read_buf(
462
466
                                mp, tp, mp->m_dev,
463
 
                                XFS_FSB_TO_DADDR(mp, map.br_startblock), 
 
467
                                XFS_FSB_TO_DADDR(mp, map.br_startblock),
464
468
                                XFS_FSB_TO_BB(mp, 1), 1, &bp);
465
469
 
466
470
                if (error) {
467
471
                        do_warn(
468
 
        "can't access block %llu (fsbno %llu) of realtime bitmap inode %llu\n",
 
472
_("can't access block %llu (fsbno %llu) of realtime bitmap inode %llu\n"),
469
473
                                bno, map.br_startblock, mp->m_sb.sb_rbmino);
470
474
                        return(1);
471
475
                }
508
512
 
509
513
        error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0, &ip);
510
514
        if (error) {
511
 
                do_error("couldn't iget realtime summary inode -- error - %d\n",
 
515
                do_error(
 
516
                _("couldn't iget realtime summary inode -- error - %d\n"),
512
517
                        error);
513
518
        }
514
519
 
521
526
                                        &first, 1, &map, &nmap, NULL);
522
527
                if (error || nmap != 1) {
523
528
                        do_error(
524
 
                "couldn't map realtime summary inode block %llu - err %d\n",
 
529
        _("couldn't map realtime summary inode block %llu, error = %d\n"),
525
530
                                bno, error);
526
531
                }
527
532
 
529
534
 
530
535
                error = libxfs_trans_read_buf(
531
536
                                mp, tp, mp->m_dev,
532
 
                                XFS_FSB_TO_DADDR(mp, map.br_startblock), 
 
537
                                XFS_FSB_TO_DADDR(mp, map.br_startblock),
533
538
                                XFS_FSB_TO_BB(mp, 1), 1, &bp);
534
539
 
535
540
                if (error) {
536
541
                        do_warn(
537
 
        "can't access block %llu (fsbno %llu) of realtime summary inode %llu\n",
 
542
_("can't access block %llu (fsbno %llu) of realtime summary inode %llu\n"),
538
543
                                bno, map.br_startblock, mp->m_sb.sb_rsumino);
539
544
                        return(1);
540
545
                }
579
584
 
580
585
        error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0, &ip);
581
586
        if (error) {
582
 
                do_error("couldn't iget realtime summary inode -- error - %d\n",
 
587
                do_error(
 
588
                _("couldn't iget realtime summary inode -- error - %d\n"),
583
589
                        error);
584
590
        }
585
591
 
586
592
        bzero(&ip->i_d, sizeof(xfs_dinode_core_t));
587
593
 
588
594
        ip->i_d.di_magic = XFS_DINODE_MAGIC;
589
 
        ip->i_d.di_mode = IFREG;
 
595
        ip->i_d.di_mode = S_IFREG;
590
596
        ip->i_d.di_version = XFS_DINODE_VERSION_1;
591
597
        ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
592
598
        ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
635
641
                          map, &nmap, &flist);
636
642
                if (error) {
637
643
                        do_error(
638
 
                        "couldn't allocate realtime summary inode - err %d\n",
 
644
                _("couldn't allocate realtime summary inode, error = %d\n"),
639
645
                                error);
640
646
                }
641
647
                for (i = 0, ep = map; i < nmap; i++, ep++) {
642
648
                        libxfs_device_zero(mp->m_dev,
643
649
                                      XFS_FSB_TO_DADDR(mp, ep->br_startblock),
644
650
                                      XFS_FSB_TO_BB(mp, ep->br_blockcount));
645
 
                                do_error("dev_zero of rtbitmap failed\n");
646
651
                        bno += ep->br_blockcount;
647
652
                }
648
653
        }
649
654
        error = libxfs_bmap_finish(&tp, &flist, first, &committed);
650
655
        if (error) {
651
656
                do_error(
652
 
                "allocation of the realtime summary ino failed, err = %d\n",
 
657
        _("allocation of the realtime summary ino failed, error = %d\n"),
653
658
                        error);
654
659
        }
655
660
        libxfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_SYNC, 0);
676
681
 
677
682
        error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rootino, 0, &ip);
678
683
        if (error) {
679
 
                do_error("could not iget root inode -- error - %d\n", error);
 
684
                do_error(_("could not iget root inode -- error - %d\n"), error);
680
685
        }
681
686
 
682
687
        /*
685
690
        bzero(&ip->i_d, sizeof(xfs_dinode_core_t));
686
691
 
687
692
        ip->i_d.di_magic = XFS_DINODE_MAGIC;
688
 
        ip->i_d.di_mode = (__uint16_t) mode|IFDIR;
 
693
        ip->i_d.di_mode = (__uint16_t) mode|S_IFDIR;
689
694
        ip->i_d.di_version = XFS_DINODE_VERSION_1;
690
695
        ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
691
696
        ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
744
749
         * wrapper can commit the transaction and start a new one
745
750
         */
746
751
        if ((i = libxfs_iget(mp, NULL, mp->m_sb.sb_rootino, 0, &pip, 0)))
747
 
                do_error("%d - couldn't iget root inode to make %s\n",
 
752
                do_error(_("%d - couldn't iget root inode to make %s\n"),
748
753
                        i, ORPHANAGE);
749
754
 
750
 
        error = libxfs_inode_alloc(&tp, pip, mode|IFDIR,
751
 
                                        1, mp->m_dev, &zerocr, &ip);
 
755
        error = libxfs_inode_alloc(&tp, pip, mode|S_IFDIR,
 
756
                                        1, 0, &zerocr, &ip);
752
757
 
753
758
        if (error) {
754
 
                do_error("%s inode allocation failed %d\n",
 
759
                do_error(_("%s inode allocation failed %d\n"),
755
760
                        ORPHANAGE, error);
756
761
        }
757
762
 
770
775
         */
771
776
        if ((error = dir_createname(mp, tp, pip, ORPHANAGE,
772
777
                        strlen(ORPHANAGE), ip->i_ino, &first, &flist, nres))) {
773
 
                do_warn("can't make %s, createname error %d, will try later\n",
 
778
                do_warn(
 
779
                _("can't make %s, createname error %d, will try later\n"),
774
780
                        ORPHANAGE, error);
775
781
                orphanage_entered = 0;
776
782
        } else
777
783
                orphanage_entered = 1;
778
784
 
779
 
        /* 
 
785
        /*
780
786
         * bump up the link count in the root directory to account
781
787
         * for .. in the new directory
782
788
         */
788
794
 
789
795
        error = libxfs_bmap_finish(&tp, &flist, first, &committed);
790
796
        if (error) {
791
 
                do_error("%s directory creation failed -- bmapf error %d\n",
 
797
                do_error(_("%s directory creation failed -- bmapf error %d\n"),
792
798
                        ORPHANAGE, error);
793
799
        }
794
800
 
825
831
        snprintf(fname, sizeof(fname), "%llu", (unsigned long long)ino);
826
832
 
827
833
        if ((err = libxfs_iget(mp, NULL, dir_ino, 0, &dir_ino_p, 0)))
828
 
                do_error("%d - couldn't iget orphanage inode\n", err);
 
834
                do_error(_("%d - couldn't iget orphanage inode\n"), err);
829
835
 
830
836
        tp = libxfs_trans_alloc(mp, 0);
831
837
 
832
838
        if ((err = libxfs_iget(mp, NULL, ino, 0, &ino_p, 0)))
833
 
                do_error("%d - couldn't iget disconnected inode\n", err);
 
839
                do_error(_("%d - couldn't iget disconnected inode\n"), err);
834
840
 
835
841
        if (isa_dir)  {
836
842
                nres = XFS_DIRENTER_SPACE_RES(mp, strlen(fname)) +
844
850
                                        XFS_TRANS_PERM_LOG_RES,
845
851
                                        XFS_RENAME_LOG_COUNT)))
846
852
                                do_error(
847
 
                "space reservation failed (%d), filesystem may be out of space\n",
 
853
        _("space reservation failed (%d), filesystem may be out of space\n"),
848
854
                                        err);
849
855
 
850
856
                        libxfs_trans_ijoin(tp, dir_ino_p, 0);
855
861
                                                strlen(fname), ino, &first,
856
862
                                                &flist, nres)))
857
863
                                do_error(
858
 
        "name create failed in %s (%d), filesystem may be out of space\n",
 
864
        _("name create failed in %s (%d), filesystem may be out of space\n"),
859
865
                                        ORPHANAGE, err);
860
866
 
861
867
                        dir_ino_p->i_d.di_nlink++;
864
870
                        if ((err = dir_createname(mp, tp, ino_p, "..", 2,
865
871
                                                dir_ino, &first, &flist, nres)))
866
872
                                do_error(
867
 
        "creation of .. entry failed (%d), filesystem may be out of space\n",
 
873
        _("creation of .. entry failed (%d), filesystem may be out of space\n"),
868
874
                                        err);
869
875
 
870
876
                        ino_p->i_d.di_nlink++;
872
878
 
873
879
                        if ((err = libxfs_bmap_finish(&tp, &flist, first, &committed)))
874
880
                                do_error(
875
 
        "bmap finish failed (err - %d), filesystem may be out of space\n",
 
881
        _("bmap finish failed (err - %d), filesystem may be out of space\n"),
876
882
                                        err);
877
883
 
878
884
                        libxfs_trans_commit(tp,
883
889
                                        XFS_TRANS_PERM_LOG_RES,
884
890
                                        XFS_RENAME_LOG_COUNT)))
885
891
                                do_error(
886
 
        "space reservation failed (%d), filesystem may be out of space\n",
 
892
        _("space reservation failed (%d), filesystem may be out of space\n"),
887
893
                                        err);
888
894
 
889
895
                        libxfs_trans_ijoin(tp, dir_ino_p, 0);
895
901
                                                strlen(fname), ino, &first,
896
902
                                                &flist, nres)))
897
903
                                do_error(
898
 
        "name create failed in %s (%d), filesystem may be out of space\n",
 
904
        _("name create failed in %s (%d), filesystem may be out of space\n"),
899
905
                                        ORPHANAGE, err);
900
906
 
901
907
                        dir_ino_p->i_d.di_nlink++;
910
916
                                                        2, dir_ino, &first,
911
917
                                                        &flist, nres)))
912
918
                                        do_error(
913
 
                "name replace op failed (%d), filesystem may be out of space\n",
 
919
        _("name replace op failed (%d), filesystem may be out of space\n"),
914
920
                                                err);
915
921
                        }
916
922
 
917
923
                        if ((err = libxfs_bmap_finish(&tp, &flist, first,
918
924
                                                        &committed)))
919
925
                                do_error(
920
 
                "bmap finish failed (%d), filesystem may be out of space\n",
 
926
        _("bmap finish failed (%d), filesystem may be out of space\n"),
921
927
                                        err);
922
928
 
923
929
                        libxfs_trans_commit(tp,
934
940
                if ((err = libxfs_trans_reserve(tp, nres, XFS_REMOVE_LOG_RES(mp), 0,
935
941
                                XFS_TRANS_PERM_LOG_RES, XFS_REMOVE_LOG_COUNT)))
936
942
                        do_error(
937
 
        "space reservation failed (%d), filesystem may be out of space\n",
 
943
        _("space reservation failed (%d), filesystem may be out of space\n"),
938
944
                                err);
939
945
 
940
946
                libxfs_trans_ijoin(tp, dir_ino_p, 0);
944
950
                if ((err = dir_createname(mp, tp, dir_ino_p, fname,
945
951
                                strlen(fname), ino, &first, &flist, nres)))
946
952
                        do_error(
947
 
        "name create failed in %s (%d), filesystem may be out of space\n",
 
953
        _("name create failed in %s (%d), filesystem may be out of space\n"),
948
954
                                ORPHANAGE, err);
949
955
                ASSERT(err == 0);
950
956
 
953
959
 
954
960
                if ((err = libxfs_bmap_finish(&tp, &flist, first, &committed)))
955
961
                        do_error(
956
 
                "bmap finish failed (%d), filesystem may be out of space\n",
 
962
        _("bmap finish failed (%d), filesystem may be out of space\n"),
957
963
                                err);
958
964
 
959
965
                libxfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_SYNC, 0);
994
1000
        i = -1;
995
1001
        node = NULL;
996
1002
        fblock = NULLFSBLOCK;
997
 
        ftype = "dir";
 
1003
        ftype = _("dir");
998
1004
 
999
1005
        nmap = 1;
1000
1006
        error = libxfs_bmapi(NULL, ip, (xfs_fileoff_t) da_bno, 1,
1003
1009
        if (error || nmap != 1)  {
1004
1010
                if (!no_modify)
1005
1011
                        do_error(
1006
 
"can't map block %d in %s inode %llu, xfs_bmapi returns %d, nmap = %d\n",
 
1012
_("can't map block %d in %s inode %llu, xfs_bmapi returns %d, nmap = %d\n"),
1007
1013
                                da_bno, ftype, ino, error, nmap);
1008
1014
                else  {
1009
1015
                        do_warn(
1010
 
"can't map block %d in %s inode %llu, xfs_bmapi returns %d, nmap = %d\n",
 
1016
_("can't map block %d in %s inode %llu, xfs_bmapi returns %d, nmap = %d\n"),
1011
1017
                                da_bno, ftype, ino, error, nmap);
1012
1018
                        return(NULLDFSBNO);
1013
1019
                }
1015
1021
 
1016
1022
        if ((fsbno = map.br_startblock) == HOLESTARTBLOCK)  {
1017
1023
                if (!no_modify)
1018
 
                        do_error("block %d in %s ino %llu doesn't exist\n",
 
1024
                        do_error(_("block %d in %s ino %llu doesn't exist\n"),
1019
1025
                                da_bno, ftype, ino);
1020
1026
                else  {
1021
 
                        do_warn("block %d in %s ino %llu doesn't exist\n",
 
1027
                        do_warn(_("block %d in %s ino %llu doesn't exist\n"),
1022
1028
                                da_bno, ftype, ino);
1023
1029
                        return(NULLDFSBNO);
1024
1030
                }
1035
1041
                 * walk down left side of btree, release buffers as you
1036
1042
                 * go.  if the root block is a leaf (single-level btree),
1037
1043
                 * just return it.
1038
 
                 * 
 
1044
                 *
1039
1045
                 */
1040
1046
 
1041
1047
                bp = libxfs_readbuf(mp->m_dev, XFS_FSB_TO_DADDR(mp, fsbno),
1043
1049
 
1044
1050
                if (!bp) {
1045
1051
                        do_warn(
1046
 
                "can't read block %u (fsbno %llu) for directory inode %llu\n",
 
1052
        _("can't read block %u (fsbno %llu) for directory inode %llu\n"),
1047
1053
                                        da_bno, fsbno, ino);
1048
1054
                        return(NULLDFSBNO);
1049
1055
                }
1053
1059
                if (INT_GET(node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC)  {
1054
1060
                        libxfs_putbuf(bp);
1055
1061
                        do_warn(
1056
 
"bad dir/attr magic number in inode %llu, file bno = %u, fsbno = %llu\n",
 
1062
_("bad dir/attr magic number in inode %llu, file bno = %u, fsbno = %llu\n"),
1057
1063
                                ino, da_bno, fsbno);
1058
1064
                        return(NULLDFSBNO);
1059
1065
                }
1073
1079
                if (error || nmap != 1)  {
1074
1080
                        if (!no_modify)
1075
1081
                                do_error(
1076
 
        "can't map block %d in %s ino %llu, xfs_bmapi returns %d, nmap = %d\n",
 
1082
_("can't map block %d in %s ino %llu, xfs_bmapi returns %d, nmap = %d\n"),
1077
1083
                                        da_bno, ftype, ino, error, nmap);
1078
1084
                        else  {
1079
1085
                                do_warn(
1080
 
        "can't map block %d in %s ino %llu, xfs_bmapi returns %d, nmap = %d\n",
 
1086
_("can't map block %d in %s ino %llu, xfs_bmapi returns %d, nmap = %d\n"),
1081
1087
                                        da_bno, ftype, ino, error, nmap);
1082
1088
                                return(NULLDFSBNO);
1083
1089
                        }
1085
1091
                if ((fsbno = map.br_startblock) == HOLESTARTBLOCK)  {
1086
1092
                        if (!no_modify)
1087
1093
                                do_error(
1088
 
                                "block %d in %s inode %llu doesn't exist\n",
 
1094
                                _("block %d in %s inode %llu doesn't exist\n"),
1089
1095
                                        da_bno, ftype, ino);
1090
1096
                        else  {
1091
1097
                                do_warn(
1092
 
                                "block %d in %s inode %llu doesn't exist\n",
 
1098
                                _("block %d in %s inode %llu doesn't exist\n"),
1093
1099
                                        da_bno, ftype, ino);
1094
1100
                                return(NULLDFSBNO);
1095
1101
                        }
1151
1157
         * first, grab the dinode and find the right leaf block.
1152
1158
         */
1153
1159
 
1154
 
        ftype = "dir";
 
1160
        ftype = _("dir");
1155
1161
        da_bno = 0;
1156
1162
        bp = NULL;
1157
1163
        namest = NULL;
1169
1175
 
1170
1176
                if (!bp)  {
1171
1177
                        do_error(
1172
 
        "can't read directory inode %llu (leaf) block %u (fsbno %llu)\n",
 
1178
        _("can't read directory inode %llu (leaf) block %u (fsbno %llu)\n"),
1173
1179
                                ino, da_bno, fsbno);
1174
1180
                        /* NOTREACHED */
1175
1181
                }
1211
1217
                                                &map, &nmap, NULL);
1212
1218
                                if (error || nmap != 1)
1213
1219
                                        do_error(
1214
 
"can't map block %d in directory %llu, xfs_bmapi returns %d, nmap = %d\n",
 
1220
_("can't map block %d in directory %llu, xfs_bmapi returns %d, nmap = %d\n"),
1215
1221
                                                da_bno, ino, error, nmap);
1216
1222
                                if ((fsbno = map.br_startblock)
1217
1223
                                                == HOLESTARTBLOCK)  {
1218
1224
                                        do_error(
1219
 
                                "%s ino %llu block %d doesn't exist\n",
 
1225
                                _("%s ino %llu block %d doesn't exist\n"),
1220
1226
                                                ftype, ino, da_bno);
1221
1227
                                }
1222
1228
                        }
1232
1238
 
1233
1239
        ASSERT(index >= 0);
1234
1240
        ASSERT(entry == &leaf->entries[index]);
1235
 
        ASSERT(namest == XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)));
 
1241
        ASSERT(namest == XFS_DIR_LEAF_NAMESTRUCT(leaf,
 
1242
                                INT_GET(entry->nameidx, ARCH_CONVERT)));
1236
1243
 
1237
1244
        /*
1238
1245
         * snag the info we need out of the directory then release all buffers
1270
1277
 
1271
1278
        if (error)  {
1272
1279
                do_error(
1273
 
"couldn't remove bogus entry \"%s\" in\n\tdirectory inode %llu, errno = %d\n",
 
1280
_("couldn't remove bogus entry \"%s\" in\n\tdirectory inode %llu, errno = %d\n"),
1274
1281
                        fname, ino, error);
1275
1282
                /* NOTREACHED */
1276
1283
        }
1402
1409
                 */
1403
1410
                irec = find_inode_rec(XFS_INO_TO_AGNO(mp, lino),
1404
1411
                                        XFS_INO_TO_AGINO(mp, lino));
1405
 
                
 
1412
 
1406
1413
                if (irec == NULL)  {
1407
1414
                        nbad++;
1408
1415
                        do_warn(
1409
 
        "entry \"%s\" in dir inode %llu points to non-existent inode, ",
 
1416
        _("entry \"%s\" in dir inode %llu points to non-existent inode, "),
1410
1417
                                fname, ino);
1411
1418
 
1412
1419
                        if (!no_modify)  {
1413
1420
                                namest->name[0] = '/';
1414
1421
                                *dirty = 1;
1415
 
                                do_warn("marking entry to be junked\n");
 
1422
                                do_warn(_("marking entry to be junked\n"));
1416
1423
                        } else  {
1417
 
                                do_warn("would junk entry\n");
 
1424
                                do_warn(_("would junk entry\n"));
1418
1425
                        }
1419
1426
 
1420
1427
                        continue;
1434
1441
                         */
1435
1442
                        if (verbose || no_modify || lino != old_orphanage_ino)
1436
1443
                                do_warn(
1437
 
                "entry \"%s\" in dir inode %llu points to free inode %llu",
 
1444
                _("entry \"%s\" in dir inode %llu points to free inode %llu"),
1438
1445
                                        fname, ino, lino);
1439
1446
                        nbad++;
1440
1447
 
1441
1448
                        if (!no_modify)  {
1442
1449
                                if (verbose || lino != old_orphanage_ino)
1443
 
                                        do_warn(", marking entry to be junked\n");
 
1450
                                        do_warn(
 
1451
                                        _(", marking entry to be junked\n"));
1444
1452
 
1445
1453
                                else
1446
1454
                                        do_warn("\n");
1447
1455
                                namest->name[0] = '/';
1448
1456
                                *dirty = 1;
1449
1457
                        } else  {
1450
 
                                do_warn(", would junk entry\n");
 
1458
                                do_warn(_(", would junk entry\n"));
1451
1459
                        }
1452
1460
 
1453
1461
                        continue;
1475
1483
                if (is_inode_reached(irec, ino_offset))  {
1476
1484
                        junkit = 1;
1477
1485
                        do_warn(
1478
 
"entry \"%s\" in dir %llu points to an already connected dir inode %llu,\n",
 
1486
_("entry \"%s\" in dir %llu points to an already connected dir inode %llu,\n"),
1479
1487
                                fname, ino, lino);
1480
1488
                } else if (parent == ino)  {
1481
1489
                        add_inode_reached(irec, ino_offset);
1486
1494
                } else  {
1487
1495
                        junkit = 1;
1488
1496
                        do_warn(
1489
 
"entry \"%s\" in dir ino %llu not consistent with .. value (%llu) in ino %llu,\n",
 
1497
_("entry \"%s\" in dir ino %llu not consistent with .. value (%llu) in ino %llu,\n"),
1490
1498
                                fname, ino, parent, lino);
1491
1499
                }
1492
1500
 
1498
1506
                                namest->name[0] = '/';
1499
1507
                                *dirty = 1;
1500
1508
                                if (verbose || lino != old_orphanage_ino)
1501
 
                                        do_warn("\twill clear entry \"%s\"\n",
 
1509
                                        do_warn(
 
1510
                                        _("\twill clear entry \"%s\"\n"),
1502
1511
                                                fname);
1503
1512
                        } else  {
1504
 
                                do_warn("\twould clear entry \"%s\"\n", fname);
 
1513
                                do_warn(_("\twould clear entry \"%s\"\n"),
 
1514
                                        fname);
1505
1515
                        }
1506
1516
                }
1507
1517
        }
1539
1549
        da_bno = 0;
1540
1550
        fblock = NULLFSBLOCK;
1541
1551
        *need_dot = 1;
1542
 
        ftype = "dir";
 
1552
        ftype = _("dir");
1543
1553
 
1544
1554
        fsbno = map_first_dblock_fsbno(mp, ino, ip, &da_bno);
1545
1555
 
1546
1556
        if (fsbno == NULLDFSBNO && no_modify)  {
1547
 
                do_warn("cannot map block 0 of directory inode %llu\n", ino);
 
1557
                do_warn(_("cannot map block 0 of directory inode %llu\n"), ino);
1548
1558
                return;
1549
1559
        }
1550
1560
 
1557
1567
 
1558
1568
                if (!bp) {
1559
1569
                        do_error(
1560
 
                "can't read block %u (fsbno %llu) for directory inode %llu\n",
 
1570
        _("can't read block %u (fsbno %llu) for directory inode %llu\n"),
1561
1571
                                        da_bno, fsbno, ino);
1562
1572
                        /* NOTREACHED */
1563
1573
                }
1566
1576
 
1567
1577
                da_bno = INT_GET(leaf->hdr.info.forw, ARCH_CONVERT);
1568
1578
 
1569
 
                if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC)  {
 
1579
                if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) !=
 
1580
                    XFS_DIR_LEAF_MAGIC)  {
1570
1581
                        if (!no_modify)  {
1571
1582
                                do_error(
1572
 
        "bad magic # (0x%x) for dir ino %llu leaf block (bno %u fsbno %llu)\n",
1573
 
                                        INT_GET(leaf->hdr.info.magic, ARCH_CONVERT),
 
1583
_("bad magic # (0x%x) for dir ino %llu leaf block (bno %u fsbno %llu)\n"),
 
1584
                                        INT_GET(leaf->hdr.info.magic,
 
1585
                                                ARCH_CONVERT),
1574
1586
                                        ino, da_bno, fsbno);
1575
1587
                                /* NOTREACHED */
1576
1588
                        } else  {
1604
1616
                        if (error || nmap != 1)  {
1605
1617
                                if (!no_modify)
1606
1618
                                        do_error(
1607
 
"can't map leaf block %d in dir %llu, xfs_bmapi returns %d, nmap = %d\n",
 
1619
_("can't map leaf block %d in dir %llu, xfs_bmapi returns %d, nmap = %d\n"),
1608
1620
                                                da_bno, ino, error, nmap);
1609
1621
                                else  {
1610
1622
                                        do_warn(
1611
 
"can't map leaf block %d in dir %llu, xfs_bmapi returns %d, nmap = %d\n",
 
1623
_("can't map leaf block %d in dir %llu, xfs_bmapi returns %d, nmap = %d\n"),
1612
1624
                                                da_bno, ino, error, nmap);
1613
1625
                                        return;
1614
1626
                                }
1616
1628
                        if ((fsbno = map.br_startblock) == HOLESTARTBLOCK)  {
1617
1629
                                if (!no_modify)
1618
1630
                                        do_error(
1619
 
                                "block %d in %s ino %llu doesn't exist\n",
 
1631
                                _("block %d in %s ino %llu doesn't exist\n"),
1620
1632
                                                da_bno, ftype, ino);
1621
1633
                                else  {
1622
1634
                                        do_warn(
1623
 
                                "block %d in %s ino %llu doesn't exist\n",
 
1635
                                _("block %d in %s ino %llu doesn't exist\n"),
1624
1636
                                                da_bno, ftype, ino);
1625
1637
                                        return;
1626
1638
                                }
1670
1682
                error = libxfs_dir2_shrink_inode(&args,
1671
1683
                                XFS_DIR2_DA_TO_DB(mp, da_bno), bp);
1672
1684
        if (error)
1673
 
                do_error("shrink_inode failed inode %llu block %u\n",
 
1685
                do_error(_("shrink_inode failed inode %llu block %u\n"),
1674
1686
                        ip->i_ino, da_bno);
1675
1687
        libxfs_bmap_finish(&tp, &flist, firstblock, &committed);
1676
1688
        libxfs_trans_commit(tp, 0, 0);
1729
1741
        ptr = (char *)d->u;
1730
1742
        nbad = 0;
1731
1743
        needscan = needlog = 0;
 
1744
        junkit = 0;
1732
1745
        freetab = *freetabp;
1733
1746
        if (isblock) {
1734
1747
                btp = XFS_DIR2_BLOCK_TAIL_P(mp, d);
1742
1755
                wantmagic = XFS_DIR2_DATA_MAGIC;
1743
1756
        }
1744
1757
        db = XFS_DIR2_DA_TO_DB(mp, da_bno);
 
1758
 
 
1759
        /* check for data block beyond expected end */
1745
1760
        if (freetab->naents <= db) {
1746
1761
                struct freetab_ent e;
1747
1762
 
1748
1763
                *freetabp = freetab = realloc(freetab, FREETAB_SIZE(db + 1));
1749
1764
                if (!freetab) {
1750
1765
                        do_error(
1751
 
                "realloc failed in longform_dir2_entry_check_data (%u bytes)\n",
 
1766
        _("realloc failed in longform_dir2_entry_check_data (%u bytes)\n"),
1752
1767
                                FREETAB_SIZE(db + 1));
1753
 
                        exit(1);
1754
1768
                }
1755
1769
                e.v = NULLDATAOFF;
1756
1770
                e.s = 0;
1758
1772
                        freetab->ents[i] = e;
1759
1773
                freetab->naents = db + 1;
1760
1774
        }
1761
 
        if (freetab->nents < db + 1)
1762
 
                freetab->nents = db + 1;
 
1775
 
 
1776
        /* check the data block */
1763
1777
        while (ptr < endptr) {
 
1778
 
 
1779
                /* check for freespace */
1764
1780
                dup = (xfs_dir2_data_unused_t *)ptr;
1765
 
                if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) {
1766
 
                        if (ptr + INT_GET(dup->length, ARCH_CONVERT) > endptr || INT_GET(dup->length, ARCH_CONVERT) == 0 ||
1767
 
                            (INT_GET(dup->length, ARCH_CONVERT) & (XFS_DIR2_DATA_ALIGN - 1)))
 
1781
                if (XFS_DIR2_DATA_FREE_TAG ==
 
1782
                    INT_GET(dup->freetag, ARCH_CONVERT)) {
 
1783
 
 
1784
                        /* check for invalid freespace length */
 
1785
                        if (ptr + INT_GET(dup->length, ARCH_CONVERT) > endptr ||
 
1786
                            INT_GET(dup->length, ARCH_CONVERT) == 0 ||
 
1787
                            (INT_GET(dup->length, ARCH_CONVERT) &
 
1788
                             (XFS_DIR2_DATA_ALIGN - 1)))
1768
1789
                                break;
1769
 
                        if (INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P_ARCH(dup, ARCH_CONVERT), ARCH_CONVERT) != 
 
1790
 
 
1791
                        /* check for invalid tag */
 
1792
                        if (INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P_ARCH(
 
1793
                                    dup, ARCH_CONVERT), ARCH_CONVERT) !=
1770
1794
                            (char *)dup - (char *)d)
1771
1795
                                break;
 
1796
 
 
1797
                        /* check for block with no data entries */
 
1798
                        if ((ptr == (char *)d->u) &&
 
1799
                            (ptr + INT_GET(dup->length, ARCH_CONVERT) >=
 
1800
                             endptr)) {
 
1801
                                junkit = 1;
 
1802
                                *num_illegal += 1;
 
1803
                                break;
 
1804
                        }
 
1805
 
 
1806
                        /* continue at the end of the freespace */
1772
1807
                        ptr += INT_GET(dup->length, ARCH_CONVERT);
1773
1808
                        if (ptr >= endptr)
1774
1809
                                break;
1775
1810
                }
 
1811
 
 
1812
                /* validate data entry size */
1776
1813
                dep = (xfs_dir2_data_entry_t *)ptr;
1777
1814
                if (ptr + XFS_DIR2_DATA_ENTSIZE(dep->namelen) > endptr)
1778
1815
                        break;
1779
 
                if (INT_GET(*XFS_DIR2_DATA_ENTRY_TAG_P(dep), ARCH_CONVERT) != (char *)dep - (char *)d)
 
1816
                if (INT_GET(*XFS_DIR2_DATA_ENTRY_TAG_P(dep), ARCH_CONVERT) !=
 
1817
                    (char *)dep - (char *)d)
1780
1818
                        break;
1781
1819
                ptr += XFS_DIR2_DATA_ENTSIZE(dep->namelen);
1782
1820
        }
 
1821
 
 
1822
        /* did we find an empty or corrupt block? */
1783
1823
        if (ptr != endptr) {
1784
 
                do_warn("corrupt block %u in directory inode %llu: ",
1785
 
                        da_bno, ip->i_ino);
 
1824
                if (junkit) {
 
1825
                        do_warn(
 
1826
                        _("empty data block %u in directory inode %llu: "),
 
1827
                                da_bno, ip->i_ino);
 
1828
                } else {
 
1829
                        do_warn(_("corrupt block %u in directory inode %llu: "),
 
1830
                                da_bno, ip->i_ino);
 
1831
                }
1786
1832
                if (!no_modify) {
1787
 
                        do_warn("junking block\n");
 
1833
                        do_warn(_("junking block\n"));
1788
1834
                        dir2_kill_block(mp, ip, da_bno, bp);
1789
1835
                } else {
1790
 
                        do_warn("would junk block\n");
 
1836
                        do_warn(_("would junk block\n"));
1791
1837
                        libxfs_da_brelse(NULL, bp);
1792
1838
                }
1793
1839
                freetab->ents[db].v = NULLDATAOFF;
1794
1840
                *bpp = NULL;
1795
1841
                return;
1796
1842
        }
 
1843
 
 
1844
        /* update number of data blocks processed */
 
1845
        if (freetab->nents < db + 1)
 
1846
                freetab->nents = db + 1;
 
1847
 
1797
1848
        tp = libxfs_trans_alloc(mp, 0);
1798
1849
        error = libxfs_trans_reserve(tp, 0, XFS_REMOVE_LOG_RES(mp), 0,
1799
1850
                XFS_TRANS_PERM_LOG_RES, XFS_REMOVE_LOG_COUNT);
1806
1857
                libxfs_da_bhold(tp, bp);
1807
1858
        XFS_BMAP_INIT(&flist, &firstblock);
1808
1859
        if (INT_GET(d->hdr.magic, ARCH_CONVERT) != wantmagic) {
1809
 
                do_warn("bad directory block magic # %#x for directory inode "
1810
 
                        "%llu block %d: ",
 
1860
                do_warn(_("bad directory block magic # %#x for directory inode "
 
1861
                        "%llu block %d: "),
1811
1862
                        INT_GET(d->hdr.magic, ARCH_CONVERT), ip->i_ino, da_bno);
1812
1863
                if (!no_modify) {
1813
 
                        do_warn("fixing magic # to %#x\n", wantmagic);
 
1864
                        do_warn(_("fixing magic # to %#x\n"), wantmagic);
1814
1865
                        INT_SET(d->hdr.magic, ARCH_CONVERT, wantmagic);
1815
1866
                        needlog = 1;
1816
1867
                } else
1817
 
                        do_warn("would fix magic # to %#x\n", wantmagic);
 
1868
                        do_warn(_("would fix magic # to %#x\n"), wantmagic);
1818
1869
        }
1819
1870
        lastfree = 0;
1820
1871
        ptr = (char *)d->u;
1832
1883
         */
1833
1884
        while (ptr < endptr) {
1834
1885
                dup = (xfs_dir2_data_unused_t *)ptr;
1835
 
                if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) {
 
1886
                if (INT_GET(dup->freetag, ARCH_CONVERT) ==
 
1887
                    XFS_DIR2_DATA_FREE_TAG) {
1836
1888
                        if (lastfree) {
1837
 
                                do_warn("directory inode %llu block %u has "
1838
 
                                        "consecutive free entries: ",
 
1889
                                do_warn(_("directory inode %llu block %u has "
 
1890
                                          "consecutive free entries: "),
1839
1891
                                        ip->i_ino, da_bno);
1840
1892
                                if (!no_modify) {
1841
 
                                        do_warn("joining together\n");
 
1893
                                        do_warn(_("joining together\n"));
1842
1894
                                        len = INT_GET(dup->length, ARCH_CONVERT);
1843
1895
                                        libxfs_dir2_data_use_free(tp, bp, dup,
1844
1896
                                                ptr - (char *)d, len, &needlog,
1847
1899
                                                ptr - (char *)d, len, &needlog,
1848
1900
                                                &needscan);
1849
1901
                                } else
1850
 
                                        do_warn("would join together\n");
 
1902
                                        do_warn(_("would join together\n"));
1851
1903
                        }
1852
1904
                        ptr += INT_GET(dup->length, ARCH_CONVERT);
1853
1905
                        lastfree = 1;
1910
1962
                /*
1911
1963
                 * skip entries with bogus inumbers if we're in no modify mode
1912
1964
                 */
1913
 
                if (no_modify && verify_inum(mp, INT_GET(dep->inumber, ARCH_CONVERT)))
 
1965
                if (no_modify &&
 
1966
                    verify_inum(mp, INT_GET(dep->inumber, ARCH_CONVERT)))
1914
1967
                        continue;
1915
1968
                /*
1916
1969
                 * ok, now handle the rest of the cases besides '.' and '..'
1917
1970
                 */
1918
 
                irec = find_inode_rec(XFS_INO_TO_AGNO(mp, INT_GET(dep->inumber, ARCH_CONVERT)),
1919
 
                        XFS_INO_TO_AGINO(mp, INT_GET(dep->inumber, ARCH_CONVERT)));
 
1971
                irec = find_inode_rec(
 
1972
                        XFS_INO_TO_AGNO(mp,
 
1973
                                INT_GET(dep->inumber, ARCH_CONVERT)),
 
1974
                        XFS_INO_TO_AGINO(mp,
 
1975
                                INT_GET(dep->inumber, ARCH_CONVERT)));
1920
1976
                if (irec == NULL)  {
1921
1977
                        nbad++;
1922
 
                        do_warn("entry \"%s\" in directory inode %llu points "
1923
 
                                "to non-existent inode, ",
 
1978
                        do_warn(_("entry \"%s\" in directory inode %llu points "
 
1979
                                  "to non-existent inode, "),
1924
1980
                                fname, ip->i_ino);
1925
1981
                        if (!no_modify)  {
1926
1982
                                dep->name[0] = '/';
1927
1983
                                libxfs_dir2_data_log_entry(tp, bp, dep);
1928
 
                                do_warn("marking entry to be junked\n");
 
1984
                                do_warn(_("marking entry to be junked\n"));
1929
1985
                        } else  {
1930
 
                                do_warn("would junk entry\n");
 
1986
                                do_warn(_("would junk entry\n"));
1931
1987
                        }
1932
1988
                        continue;
1933
1989
                }
1934
 
                ino_offset =
1935
 
                        XFS_INO_TO_AGINO(mp, INT_GET(dep->inumber, ARCH_CONVERT)) - irec->ino_startnum;
 
1990
                ino_offset = XFS_INO_TO_AGINO(mp,
 
1991
                                INT_GET(dep->inumber, ARCH_CONVERT)) -
 
1992
                                        irec->ino_startnum;
1936
1993
                /*
1937
1994
                 * if it's a free inode, blow out the entry.
1938
1995
                 * by now, any inode that we think is free
1944
2001
                         * and now-free lost+found inode
1945
2002
                         */
1946
2003
                        if (verbose || no_modify ||
1947
 
                            INT_GET(dep->inumber, ARCH_CONVERT) != old_orphanage_ino)
1948
 
                                do_warn("entry \"%s\" in directory inode %llu "
1949
 
                                        "points to free inode %llu",
1950
 
                                        fname, ip->i_ino, INT_GET(dep->inumber, ARCH_CONVERT));
 
2004
                            INT_GET(dep->inumber, ARCH_CONVERT) !=
 
2005
                            old_orphanage_ino)
 
2006
                                do_warn(
 
2007
        _("entry \"%s\" in directory inode %llu points to free inode %llu"),
 
2008
                                        fname, ip->i_ino,
 
2009
                                        INT_GET(dep->inumber, ARCH_CONVERT));
1951
2010
                        nbad++;
1952
2011
                        if (!no_modify)  {
1953
2012
                                if (verbose ||
1954
 
                                    INT_GET(dep->inumber, ARCH_CONVERT) != old_orphanage_ino)
1955
 
                                        do_warn(", marking entry to be "
1956
 
                                                "junked\n");
 
2013
                                    INT_GET(dep->inumber, ARCH_CONVERT) !=
 
2014
                                    old_orphanage_ino)
 
2015
                                        do_warn(
 
2016
                                        _(", marking entry to be junked\n"));
1957
2017
                                else
1958
2018
                                        do_warn("\n");
1959
2019
                                dep->name[0] = '/';
1960
2020
                                libxfs_dir2_data_log_entry(tp, bp, dep);
1961
2021
                        } else  {
1962
 
                                do_warn(", would junk entry\n");
 
2022
                                do_warn(_(", would junk entry\n"));
1963
2023
                        }
1964
2024
                        continue;
1965
2025
                }
1982
2042
                 */
1983
2043
                if (is_inode_reached(irec, ino_offset))  {
1984
2044
                        junkit = 1;
1985
 
                        do_warn("entry \"%s\" in dir %llu points to an already "
1986
 
                                "connected directory inode %llu,\n", fname,
1987
 
                                ip->i_ino, INT_GET(dep->inumber, ARCH_CONVERT));
 
2045
                        do_warn(
 
2046
_("entry \"%s\" in dir %llu points to an already connected directory inode %llu,\n"),
 
2047
                                fname, ip->i_ino,
 
2048
                                INT_GET(dep->inumber, ARCH_CONVERT));
1988
2049
                } else if (parent == ip->i_ino)  {
1989
2050
                        add_inode_reached(irec, ino_offset);
1990
2051
                        add_inode_ref(current_irec, current_ino_offset);
1991
 
                        if (!is_inode_refchecked(INT_GET(dep->inumber, ARCH_CONVERT), irec,
 
2052
                        if (!is_inode_refchecked(
 
2053
                                INT_GET(dep->inumber, ARCH_CONVERT), irec,
1992
2054
                                        ino_offset))
1993
 
                                push_dir(stack, INT_GET(dep->inumber, ARCH_CONVERT));
 
2055
                                push_dir(stack,
 
2056
                                        INT_GET(dep->inumber, ARCH_CONVERT));
1994
2057
                } else  {
1995
2058
                        junkit = 1;
1996
 
                        do_warn("entry \"%s\" in directory inode %llu not "
1997
 
                                "consistent with .. value (%llu) in ino "
1998
 
                                "%llu,\n",
1999
 
                                fname, ip->i_ino, parent, INT_GET(dep->inumber, ARCH_CONVERT));
 
2059
                        do_warn(
 
2060
_("entry \"%s\" in dir inode %llu inconsistent with .. value (%llu) in ino %llu,\n"),
 
2061
                                fname, ip->i_ino, parent,
 
2062
                                INT_GET(dep->inumber, ARCH_CONVERT));
2000
2063
                }
2001
2064
                if (junkit)  {
2002
2065
                        junkit = 0;
2005
2068
                                dep->name[0] = '/';
2006
2069
                                libxfs_dir2_data_log_entry(tp, bp, dep);
2007
2070
                                if (verbose ||
2008
 
                                    INT_GET(dep->inumber, ARCH_CONVERT) != old_orphanage_ino)
2009
 
                                        do_warn("\twill clear entry \"%s\"\n",
 
2071
                                    INT_GET(dep->inumber, ARCH_CONVERT) !=
 
2072
                                    old_orphanage_ino)
 
2073
                                        do_warn(
 
2074
                                        _("\twill clear entry \"%s\"\n"),
2010
2075
                                                fname);
2011
2076
                        } else  {
2012
 
                                do_warn("\twould clear entry \"%s\"\n", fname);
 
2077
                                do_warn(_("\twould clear entry \"%s\"\n"),
 
2078
                                        fname);
2013
2079
                        }
2014
2080
                }
2015
2081
        }
2045
2111
 
2046
2112
        da_bno = mp->m_dirleafblk;
2047
2113
        if (libxfs_da_read_bufr(NULL, ip, da_bno, -1, &bp, XFS_DATA_FORK)) {
2048
 
                do_error("can't read block %u for directory inode %llu\n",
 
2114
                do_error(_("can't read block %u for directory inode %llu\n"),
2049
2115
                        da_bno, ip->i_ino);
2050
2116
                /* NOTREACHED */
2051
2117
        }
2052
2118
        leaf = bp->data;
2053
2119
        ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
2054
2120
        bestsp = XFS_DIR2_LEAF_BESTS_P_ARCH(ltp, ARCH_CONVERT);
2055
 
        if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR2_LEAF1_MAGIC ||
2056
 
            INT_GET(leaf->hdr.info.forw, ARCH_CONVERT) || INT_GET(leaf->hdr.info.back, ARCH_CONVERT) ||
2057
 
            INT_GET(leaf->hdr.count, ARCH_CONVERT) < INT_GET(leaf->hdr.stale, ARCH_CONVERT) ||
2058
 
            INT_GET(leaf->hdr.count, ARCH_CONVERT) > XFS_DIR2_MAX_LEAF_ENTS(mp) ||
2059
 
            (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] > (char *)bestsp) {
2060
 
                do_warn("leaf block %u for directory inode %llu bad header\n",
 
2121
        if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) !=
 
2122
                        XFS_DIR2_LEAF1_MAGIC ||
 
2123
            INT_GET(leaf->hdr.info.forw, ARCH_CONVERT) ||
 
2124
                        INT_GET(leaf->hdr.info.back, ARCH_CONVERT) ||
 
2125
            INT_GET(leaf->hdr.count, ARCH_CONVERT) <
 
2126
                        INT_GET(leaf->hdr.stale, ARCH_CONVERT) ||
 
2127
            INT_GET(leaf->hdr.count, ARCH_CONVERT) >
 
2128
                        XFS_DIR2_MAX_LEAF_ENTS(mp) ||
 
2129
            (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] >
 
2130
                        (char *)bestsp) {
 
2131
                do_warn(
 
2132
                _("leaf block %u for directory inode %llu bad header\n"),
2061
2133
                        da_bno, ip->i_ino);
2062
2134
                libxfs_da_brelse(NULL, bp);
2063
2135
                return 1;
2064
2136
        }
2065
 
        seeval = dir_hash_see_all(hashtab, leaf->ents, INT_GET(leaf->hdr.count, ARCH_CONVERT),
 
2137
        seeval = dir_hash_see_all(hashtab, leaf->ents,
 
2138
                                INT_GET(leaf->hdr.count, ARCH_CONVERT),
2066
2139
                INT_GET(leaf->hdr.stale, ARCH_CONVERT));
2067
2140
        if (dir_hash_check(hashtab, ip, seeval)) {
2068
2141
                libxfs_da_brelse(NULL, bp);
2074
2147
                badtail = freetab->ents[i].v != INT_GET(bestsp[i], ARCH_CONVERT);
2075
2148
        }
2076
2149
        if (badtail) {
2077
 
                do_warn("leaf block %u for directory inode %llu bad tail\n",
 
2150
                do_warn(_("leaf block %u for directory inode %llu bad tail\n"),
2078
2151
                        da_bno, ip->i_ino);
2079
2152
                libxfs_da_brelse(NULL, bp);
2080
2153
                return 1;
2112
2185
                        break;
2113
2186
                if (libxfs_da_read_bufr(NULL, ip, da_bno, -1, &bp,
2114
2187
                                XFS_DATA_FORK)) {
2115
 
                        do_error("can't read block %u for directory inode "
2116
 
                                 "%llu\n",
 
2188
                        do_error(
 
2189
                        _("can't read block %u for directory inode %llu\n"),
2117
2190
                                da_bno, ip->i_ino);
2118
2191
                        /* NOTREACHED */
2119
2192
                }
2120
2193
                leaf = bp->data;
2121
 
                if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR2_LEAFN_MAGIC) {
2122
 
                        if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) {
 
2194
                if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) !=
 
2195
                    XFS_DIR2_LEAFN_MAGIC) {
 
2196
                        if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ==
 
2197
                            XFS_DA_NODE_MAGIC) {
2123
2198
                                libxfs_da_brelse(NULL, bp);
2124
2199
                                continue;
2125
2200
                        }
2126
 
                        do_warn("unknown magic number %#x for block %u in "
2127
 
                                "directory inode %llu\n",
2128
 
                                INT_GET(leaf->hdr.info.magic, ARCH_CONVERT), da_bno, ip->i_ino);
 
2201
                        do_warn(_("unknown magic number %#x for block %u in "
 
2202
                                  "directory inode %llu\n"),
 
2203
                                INT_GET(leaf->hdr.info.magic, ARCH_CONVERT),
 
2204
                                da_bno, ip->i_ino);
2129
2205
                        libxfs_da_brelse(NULL, bp);
2130
2206
                        return 1;
2131
2207
                }
2132
 
                if (INT_GET(leaf->hdr.count, ARCH_CONVERT) < INT_GET(leaf->hdr.stale, ARCH_CONVERT) ||
2133
 
                    INT_GET(leaf->hdr.count, ARCH_CONVERT) > XFS_DIR2_MAX_LEAF_ENTS(mp)) {
2134
 
                        do_warn("leaf block %u for directory inode %llu bad "
2135
 
                                "header\n",
 
2208
                if (INT_GET(leaf->hdr.count, ARCH_CONVERT) <
 
2209
                                INT_GET(leaf->hdr.stale, ARCH_CONVERT) ||
 
2210
                    INT_GET(leaf->hdr.count, ARCH_CONVERT) >
 
2211
                                XFS_DIR2_MAX_LEAF_ENTS(mp)) {
 
2212
                        do_warn(_("leaf block %u for directory inode %llu bad "
 
2213
                                  "header\n"),
2136
2214
                                da_bno, ip->i_ino);
2137
2215
                        libxfs_da_brelse(NULL, bp);
2138
2216
                        return 1;
2153
2231
                        break;
2154
2232
                if (libxfs_da_read_bufr(NULL, ip, da_bno, -1, &bp,
2155
2233
                                XFS_DATA_FORK)) {
2156
 
                        do_error("can't read block %u for directory inode "
2157
 
                                 "%llu\n",
 
2234
                        do_error(_("can't read block %u for directory inode "
 
2235
                                   "%llu\n"),
2158
2236
                                da_bno, ip->i_ino);
2159
2237
                        /* NOTREACHED */
2160
2238
                }
2161
2239
                free = bp->data;
2162
2240
                fdb = XFS_DIR2_DA_TO_DB(mp, da_bno);
2163
 
                if (INT_GET(free->hdr.magic, ARCH_CONVERT) != XFS_DIR2_FREE_MAGIC ||
 
2241
                if (INT_GET(free->hdr.magic, ARCH_CONVERT) !=
 
2242
                                XFS_DIR2_FREE_MAGIC ||
2164
2243
                    INT_GET(free->hdr.firstdb, ARCH_CONVERT) !=
2165
 
                        (fdb - XFS_DIR2_FREE_FIRSTDB(mp)) *
2166
 
                        XFS_DIR2_MAX_FREE_BESTS(mp) ||
2167
 
                    INT_GET(free->hdr.nvalid, ARCH_CONVERT) < INT_GET(free->hdr.nused, ARCH_CONVERT)) {
2168
 
                        do_warn("free block %u for directory inode %llu bad "
2169
 
                                "header\n",
 
2244
                                (fdb - XFS_DIR2_FREE_FIRSTDB(mp)) *
 
2245
                                XFS_DIR2_MAX_FREE_BESTS(mp) ||
 
2246
                    INT_GET(free->hdr.nvalid, ARCH_CONVERT) <
 
2247
                                INT_GET(free->hdr.nused, ARCH_CONVERT)) {
 
2248
                        do_warn(_("free block %u for directory inode %llu bad "
 
2249
                                  "header\n"),
2170
2250
                                da_bno, ip->i_ino);
2171
2251
                        libxfs_da_brelse(NULL, bp);
2172
2252
                        return 1;
2173
2253
                }
2174
2254
                for (i = used = 0; i < INT_GET(free->hdr.nvalid, ARCH_CONVERT); i++) {
2175
 
                        if (i + INT_GET(free->hdr.firstdb, ARCH_CONVERT) >= freetab->nents ||
2176
 
                            freetab->ents[i + INT_GET(free->hdr.firstdb, ARCH_CONVERT)].v !=
 
2255
                        if (i + INT_GET(free->hdr.firstdb, ARCH_CONVERT) >=
 
2256
                                        freetab->nents ||
 
2257
                            freetab->ents[i + INT_GET(free->hdr.firstdb,
 
2258
                                        ARCH_CONVERT)].v !=
2177
2259
                            INT_GET(free->bests[i], ARCH_CONVERT)) {
2178
 
                                do_warn("free block %u entry %i for directory "
2179
 
                                        "ino %llu bad\n",
 
2260
                                do_warn(
 
2261
                _("free block %u entry %i for directory ino %llu bad\n"),
2180
2262
                                        da_bno, i, ip->i_ino);
2181
2263
                                libxfs_da_brelse(NULL, bp);
2182
2264
                                return 1;
2185
2267
                        freetab->ents[i + INT_GET(free->hdr.firstdb, ARCH_CONVERT)].s = 1;
2186
2268
                }
2187
2269
                if (used != INT_GET(free->hdr.nused, ARCH_CONVERT)) {
2188
 
                        do_warn("free block %u for directory inode %llu bad "
2189
 
                                "nused\n",
 
2270
                        do_warn(_("free block %u for directory inode %llu bad "
 
2271
                                  "nused\n"),
2190
2272
                                da_bno, ip->i_ino);
2191
2273
                        libxfs_da_brelse(NULL, bp);
2192
2274
                        return 1;
2195
2277
        }
2196
2278
        for (i = 0; i < freetab->nents; i++) {
2197
2279
                if (freetab->ents[i].s == 0) {
2198
 
                        do_warn("missing freetab entry %u for directory inode "
2199
 
                                "%llu\n",
 
2280
                        do_warn(_("missing freetab entry %u for "
 
2281
                                  "directory inode %llu\n"),
2200
2282
                                i, ip->i_ino);
2201
2283
                        return 1;
2202
2284
                }
2218
2300
{
2219
2301
        xfs_da_args_t           args;
2220
2302
        int                     committed;
2221
 
        xfs_dir2_data_t         *data;
 
2303
        xfs_dir2_data_t         *data = NULL;
2222
2304
        xfs_dabuf_t             *dbp;
2223
2305
        int                     error;
2224
2306
        xfs_dir2_db_t           fbno;
2234
2316
        int                     nres;
2235
2317
        xfs_trans_t             *tp;
2236
2318
 
 
2319
        /* read first directory block */
2237
2320
        tp = libxfs_trans_alloc(mp, 0);
2238
2321
        nres = XFS_DAENTER_SPACE_RES(mp, XFS_DATA_FORK);
2239
2322
        error = libxfs_trans_reserve(tp,
2246
2329
        XFS_BMAP_INIT(&flist, &firstblock);
2247
2330
        if (libxfs_da_read_buf(tp, ip, mp->m_dirdatablk, -2, &dbp,
2248
2331
                        XFS_DATA_FORK)) {
2249
 
                do_error("can't read block %u for directory inode %llu\n",
 
2332
                do_error(_("can't read block %u for directory inode %llu\n"),
2250
2333
                        mp->m_dirdatablk, ino);
2251
2334
                /* NOTREACHED */
2252
2335
        }
2253
 
        if (dbp && (data = dbp->data)->hdr.magic == XFS_DIR2_BLOCK_MAGIC) {
 
2336
 
 
2337
        if (dbp)
 
2338
                data = dbp->data;
 
2339
 
 
2340
        /* check for block format directory */
 
2341
        if (data &&
 
2342
            INT_GET((data)->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) {
2254
2343
                xfs_dir2_block_t        *block;
2255
2344
                xfs_dir2_leaf_entry_t   *blp;
2256
2345
                xfs_dir2_block_tail_t   *btp;
2257
2346
                int                     needlog;
2258
2347
                int                     needscan;
2259
2348
 
 
2349
                /* convert directory block from block format to data format */
2260
2350
                INT_SET(data->hdr.magic, ARCH_CONVERT, XFS_DIR2_DATA_MAGIC);
 
2351
 
 
2352
                /* construct freelist */
2261
2353
                block = (xfs_dir2_block_t *)data;
2262
2354
                btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
2263
2355
                blp = XFS_DIR2_BLOCK_LEAF_P_ARCH(btp, ARCH_CONVERT);
2269
2361
                        libxfs_dir2_data_freescan(mp, data, &needlog, NULL);
2270
2362
                libxfs_da_log_buf(tp, dbp, 0, mp->m_dirblksize - 1);
2271
2363
        }
 
2364
 
 
2365
        /* allocate blocks for btree */
2272
2366
        bzero(&args, sizeof(args));
2273
2367
        args.trans = tp;
2274
2368
        args.dp = ip;
2278
2372
        args.total = nres;
2279
2373
        if ((error = libxfs_da_grow_inode(&args, &lblkno)) ||
2280
2374
            (error = libxfs_da_get_buf(tp, ip, lblkno, -1, &lbp, XFS_DATA_FORK))) {
2281
 
                do_error("can't add btree block to directory inode %llu\n",
 
2375
                do_error(_("can't add btree block to directory inode %llu\n"),
2282
2376
                        ino);
2283
2377
                /* NOTREACHED */
2284
2378
        }
2311
2405
                                                 &fbno)) ||
2312
2406
                    (error = libxfs_da_get_buf(tp, ip, XFS_DIR2_DB_TO_DA(mp, fbno),
2313
2407
                                            -1, &fbp, XFS_DATA_FORK))) {
2314
 
                        do_error("can't add free block to directory inode "
2315
 
                                 "%llu\n",
 
2408
                        do_error(_("can't add free block to directory inode "
 
2409
                                   "%llu\n"),
2316
2410
                                ino);
2317
2411
                        /* NOTREACHED */
2318
2412
                }
2367
2461
 
2368
2462
        if (libxfs_da_read_buf(NULL, ip, da_bno, da_bno == 0 ? -2 : -1, &bp,
2369
2463
                        XFS_DATA_FORK)) {
2370
 
                do_error("can't read block %u for directory inode %llu\n",
 
2464
                do_error(_("can't read block %u for directory inode %llu\n"),
2371
2465
                        da_bno, ino);
2372
2466
                /* NOTREACHED */
2373
2467
        }
2381
2475
        fdb = XFS_DIR2_DB_TO_FDB(mp, dbno);
2382
2476
        if (libxfs_da_read_buf(NULL, ip, XFS_DIR2_DB_TO_DA(mp, fdb), -1, &fbp,
2383
2477
                        XFS_DATA_FORK)) {
2384
 
                do_error("can't read block %u for directory inode %llu\n",
 
2478
                do_error(_("can't read block %u for directory inode %llu\n"),
2385
2479
                        XFS_DIR2_DB_TO_DA(mp, fdb), ino);
2386
2480
                /* NOTREACHED */
2387
2481
        }
2388
2482
        data = malloc(mp->m_dirblksize);
2389
2483
        if (!data) {
2390
2484
                do_error(
2391
 
                "malloc failed in longform_dir2_rebuild_data (%u bytes)\n",
 
2485
                _("malloc failed in longform_dir2_rebuild_data (%u bytes)\n"),
2392
2486
                        mp->m_dirblksize);
2393
2487
                exit(1);
2394
2488
        }
2463
2557
 
2464
2558
/*
2465
2559
 * Finish the rebuild of a directory.
2466
 
 * Stuff / in and then remove it, this forces the directory to end 
 
2560
 * Stuff / in and then remove it, this forces the directory to end
2467
2561
 * up in the right format.
2468
2562
 */
2469
2563
void
2532
2626
        xfs_dablk_t     da_bno;
2533
2627
        xfs_fileoff_t   next_da_bno;
2534
2628
 
2535
 
        do_warn("rebuilding directory inode %llu\n", ino);
 
2629
        do_warn(_("rebuilding directory inode %llu\n"), ino);
 
2630
 
 
2631
        /* kill leaf blocks */
2536
2632
        for (da_bno = mp->m_dirleafblk, next_da_bno = isblock ? NULLFILEOFF : 0;
2537
2633
             next_da_bno != NULLFILEOFF;
2538
2634
             da_bno = (xfs_dablk_t)next_da_bno) {
2540
2636
                if (libxfs_bmap_next_offset(NULL, ip, &next_da_bno, XFS_DATA_FORK))
2541
2637
                        break;
2542
2638
                if (libxfs_da_get_buf(NULL, ip, da_bno, -1, &bp, XFS_DATA_FORK)) {
2543
 
                        do_error("can't get block %u for directory inode "
2544
 
                                 "%llu\n",
 
2639
                        do_error(_("can't get block %u for directory inode "
 
2640
                                   "%llu\n"),
2545
2641
                                da_bno, ino);
2546
2642
                        /* NOTREACHED */
2547
2643
                }
2548
2644
                dir2_kill_block(mp, ip, da_bno, bp);
2549
2645
        }
 
2646
 
 
2647
        /* rebuild empty btree and freelist */
2550
2648
        longform_dir2_rebuild_setup(mp, ino, ip, freetab);
 
2649
 
 
2650
        /* rebuild directory */
2551
2651
        for (da_bno = mp->m_dirdatablk, next_da_bno = 0;
2552
2652
             da_bno < mp->m_dirleafblk && next_da_bno != NULLFILEOFF;
2553
2653
             da_bno = (xfs_dablk_t)next_da_bno) {
2556
2656
                        break;
2557
2657
                longform_dir2_rebuild_data(mp, ino, ip, da_bno);
2558
2658
        }
 
2659
 
 
2660
        /* put the directory in the appropriate on-disk format */
2559
2661
        longform_dir2_rebuild_finish(mp, ino, ip);
2560
2662
        *num_illegal = 0;
2561
2663
}
2594
2696
        freetab = malloc(FREETAB_SIZE(ip->i_d.di_size / mp->m_dirblksize));
2595
2697
        if (!freetab) {
2596
2698
                do_error(
2597
 
                "malloc failed in longform_dir2_entry_check (%u bytes)\n",
 
2699
                _("malloc failed in longform_dir2_entry_check (%u bytes)\n"),
2598
2700
                        FREETAB_SIZE(ip->i_d.di_size / mp->m_dirblksize));
2599
2701
                exit(1);
2600
2702
        }
2604
2706
                freetab->ents[i].v = NULLDATAOFF;
2605
2707
                freetab->ents[i].s = 0;
2606
2708
        }
 
2709
        /* is this a block, leaf, or node directory? */
2607
2710
        libxfs_dir2_isblock(NULL, ip, &isblock);
2608
2711
        libxfs_dir2_isleaf(NULL, ip, &isleaf);
 
2712
 
 
2713
        /* check directory data */
2609
2714
        hashtab = dir_hash_init(ip->i_d.di_size);
2610
2715
        for (da_bno = 0, next_da_bno = 0;
2611
2716
             next_da_bno != NULLFILEOFF && da_bno < mp->m_dirleafblk;
2613
2718
                next_da_bno = da_bno + mp->m_dirblkfsbs - 1;
2614
2719
                if (libxfs_bmap_next_offset(NULL, ip, &next_da_bno, XFS_DATA_FORK))
2615
2720
                        break;
2616
 
                if (libxfs_da_read_bufr(NULL, ip, da_bno, -1, &bp,
2617
 
                                XFS_DATA_FORK)) {
2618
 
                        do_error("can't read block %u for directory inode "
2619
 
                                 "%llu\n",
 
2721
                if (libxfs_da_read_bufr(NULL, ip, da_bno,
 
2722
                                da_bno == 0 ? -2 : -1, &bp, XFS_DATA_FORK)) {
 
2723
                        do_error(_("can't read block %u for directory inode "
 
2724
                                   "%llu\n"),
2620
2725
                                da_bno, ino);
2621
2726
                        /* NOTREACHED */
2622
2727
                }
 
2728
                /* is there a hole at the start? */
 
2729
                if (da_bno == 0 && bp == NULL)
 
2730
                        continue;
2623
2731
                longform_dir2_entry_check_data(mp, ip, num_illegal, need_dot,
2624
2732
                        stack, irec, ino_offset, &bp, hashtab, &freetab, da_bno,
2625
2733
                        isblock);
2626
2734
                /* it releases the buffer unless isblock is set */
2627
2735
        }
2628
2736
        fixit = (*num_illegal != 0) || dir2_is_badino(ino);
 
2737
 
 
2738
        /* check btree and freespace */
2629
2739
        if (isblock) {
2630
2740
                ASSERT(bp);
2631
2741
                block = bp->data;
2699
2809
         * no need to worry about '.' since it doesn't exist.
2700
2810
         */
2701
2811
        sf_entry = next_sfe = &sf->list[0];
2702
 
        if (sf == NULL) { 
 
2812
        if (sf == NULL) {
2703
2813
                junkit = 1;
2704
 
                do_warn("shortform dir inode %llu has null data entries \n", ino);
 
2814
                do_warn(_("shortform dir inode %llu has null data entries \n"),
 
2815
                        ino);
2705
2816
 
2706
2817
                }
2707
2818
        else {
2786
2897
 
2787
2898
                if (irec == NULL && no_modify)  {
2788
2899
                        do_warn(
2789
 
"entry \"%s\" in shortform dir %llu references non-existent ino %llu\n",
 
2900
_("entry \"%s\" in shortform dir %llu references non-existent ino %llu\n"),
2790
2901
                                fname, ino, lino);
2791
 
                        do_warn("would junk entry\n");
 
2902
                        do_warn(_("would junk entry\n"));
2792
2903
                        continue;
2793
2904
                }
2794
2905
 
2808
2919
                         */
2809
2920
                        if (verbose || no_modify || lino != old_orphanage_ino)
2810
2921
                                do_warn(
2811
 
        "entry \"%s\" in shortform dir inode %llu points to free inode %llu\n",
 
2922
_("entry \"%s\" in shortform dir inode %llu points to free inode %llu\n"),
2812
2923
                                        fname, ino, lino);
2813
2924
 
2814
2925
                        if (!no_modify)  {
2815
2926
                                junkit = 1;
2816
2927
                        } else  {
2817
 
                                do_warn("would junk entry \"%s\"\n",
 
2928
                                do_warn(_("would junk entry \"%s\"\n"),
2818
2929
                                        fname);
2819
2930
                        }
2820
2931
                } else if (!inode_isadir(irec, ino_offset))  {
2839
2950
                        if (is_inode_reached(irec, ino_offset))  {
2840
2951
                                junkit = 1;
2841
2952
                                do_warn(
2842
 
        "entry \"%s\" in dir %llu references already connected dir ino %llu,\n",
 
2953
_("entry \"%s\" in dir %llu references already connected dir ino %llu,\n"),
2843
2954
                                        fname, ino, lino);
2844
2955
                        } else if (parent == ino)  {
2845
2956
                                add_inode_reached(irec, ino_offset);
2851
2962
                        } else  {
2852
2963
                                junkit = 1;
2853
2964
                                do_warn(
2854
 
"entry \"%s\" in dir %llu not consistent with .. value (%llu) in dir ino %llu,\n",
 
2965
_("entry \"%s\" in dir %llu not consistent with .. value (%llu) in dir ino %llu,\n"),
2855
2966
                                        fname, ino, parent, lino);
2856
2967
                        }
2857
2968
                }
2890
3001
 
2891
3002
                                if (verbose || lino != old_orphanage_ino)
2892
3003
                                        do_warn(
2893
 
                        "junking entry \"%s\" in directory inode %llu\n",
 
3004
                        _("junking entry \"%s\" in directory inode %llu\n"),
2894
3005
                                                fname, lino);
2895
3006
                        } else  {
2896
 
                                do_warn("would junk entry \"%s\"\n", fname);
 
3007
                                do_warn(_("would junk entry \"%s\"\n"), fname);
2897
3008
                        }
2898
3009
                }
2899
3010
 
2932
3043
                ip->i_d.di_size = (xfs_fsize_t)
2933
3044
                                ((__psint_t) next_sfe - (__psint_t) sf);
2934
3045
                do_warn(
2935
 
                "setting size to %lld bytes to reflect junked entries\n",
 
3046
                _("setting size to %lld bytes to reflect junked entries\n"),
2936
3047
                                ip->i_d.di_size);
2937
3048
                *ino_dirty = 1;
2938
3049
        }
3027
3138
                ip->i_d.di_size = (xfs_fsize_t)
3028
3139
                                ((__psint_t) next_sfe - (__psint_t) sf);
3029
3140
                do_warn(
3030
 
                "setting size to %lld bytes to reflect junked entries\n",
 
3141
                _("setting size to %lld bytes to reflect junked entries\n"),
3031
3142
                                ip->i_d.di_size);
3032
3143
        }
3033
3144
}
3066
3177
        ifp = &ip->i_df;
3067
3178
        sfp = (xfs_dir2_sf_t *) ifp->if_u1.if_data;
3068
3179
        *ino_dirty = 0;
3069
 
        bytes_deleted = i8 = 0;
 
3180
        bytes_deleted = 0;
3070
3181
 
3071
3182
        max_size = ifp->if_bytes;
3072
3183
        ASSERT(ip->i_d.di_size <= ifp->if_bytes);
3080
3191
        add_inode_ref(current_irec, current_ino_offset);
3081
3192
 
3082
3193
        /*
 
3194
         * Initialise i8 counter -- the parent inode number counts as well.
 
3195
         */
 
3196
        i8 = (XFS_DIR2_SF_GET_INUMBER_ARCH(sfp, &sfp->hdr.parent, ARCH_CONVERT) > XFS_DIR2_MAX_SHORT_INUM);
 
3197
 
 
3198
        /*
3083
3199
         * now run through entries, stop at first bad entry, don't need
3084
3200
         * to skip over '..' since that's encoded in its own field and
3085
3201
         * no need to worry about '.' since it doesn't exist.
3150
3266
                 * to where we think lost+found should be.  if that's
3151
3267
                 * the case, that's the one we created in phase 6.
3152
3268
                 * just skip it.  no need to process it and its ..
3153
 
                 * link is already accounted for.  Also skip entries
3154
 
                 * with bogus inode numbers if we're in no modify mode.
3155
 
                 */
3156
 
 
3157
 
                if ((lino == orphanage_ino && strcmp(fname, ORPHANAGE) == 0)
3158
 
                                || (no_modify && verify_inum(mp, lino))) {
 
3269
                 * link is already accounted for.
 
3270
                 */
 
3271
 
 
3272
                if (lino == orphanage_ino && strcmp(fname, ORPHANAGE) == 0) {
 
3273
                        if (lino > XFS_DIR2_MAX_SHORT_INUM)
 
3274
                                i8++;
 
3275
                        next_sfep = (xfs_dir2_sf_entry_t *)
 
3276
                                ((__psint_t) sfep +
 
3277
                                XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp, sfep));
 
3278
                        continue;
 
3279
                }
 
3280
 
 
3281
                /*
 
3282
                 * Also skip entries with bogus inode numbers if we're
 
3283
                 * in no modify mode.
 
3284
                 */
 
3285
 
 
3286
                if (no_modify && verify_inum(mp, lino))  {
3159
3287
                        next_sfep = (xfs_dir2_sf_entry_t *)
3160
3288
                                ((__psint_t) sfep +
3161
3289
                                XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp, sfep));
3166
3294
                                        XFS_INO_TO_AGINO(mp, lino));
3167
3295
 
3168
3296
                if (irec == NULL && no_modify)  {
3169
 
                        do_warn("entry \"%s\" in shortform directory %llu "
3170
 
                                "references non-existent inode %llu\n",
 
3297
                        do_warn(_("entry \"%s\" in shortform directory %llu "
 
3298
                                  "references non-existent inode %llu\n"),
3171
3299
                                fname, ino, lino);
3172
 
                        do_warn("would junk entry\n");
 
3300
                        do_warn(_("would junk entry\n"));
3173
3301
                        continue;
3174
3302
                }
3175
3303
 
3188
3316
                         * and now-free lost+found inode
3189
3317
                         */
3190
3318
                        if (verbose || no_modify || lino != old_orphanage_ino)
3191
 
                                do_warn("entry \"%s\" in shortform directory "
3192
 
                                        "inode %llu points to free inode "
3193
 
                                        "%llu\n",
 
3319
                                do_warn(_("entry \"%s\" in shortform directory "
 
3320
                                          "inode %llu points to free inode "
 
3321
                                          "%llu\n"),
3194
3322
                                        fname, ino, lino);
3195
3323
 
3196
3324
                        if (!no_modify)  {
3197
3325
                                junkit = 1;
3198
3326
                        } else  {
3199
 
                                do_warn("would junk entry \"%s\"\n",
 
3327
                                do_warn(_("would junk entry \"%s\"\n"),
3200
3328
                                        fname);
3201
3329
                        }
3202
3330
                } else if (!inode_isadir(irec, ino_offset))  {
3203
3331
                        /*
3204
3332
                         * check easy case first, regular inode, just bump
3205
 
                         * the link count and continue
 
3333
                         * the link count
3206
3334
                         */
3207
3335
                        add_inode_reached(irec, ino_offset);
3208
 
 
3209
 
                        next_sfep = (xfs_dir2_sf_entry_t *)
3210
 
                                ((__psint_t) sfep +
3211
 
                                XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp, sfep));
3212
 
                        continue;
3213
3336
                } else  {
3214
3337
                        parent = get_inode_parent(irec, ino_offset);
3215
3338
 
3220
3343
                         */
3221
3344
                        if (is_inode_reached(irec, ino_offset))  {
3222
3345
                                junkit = 1;
3223
 
                                do_warn("entry \"%s\" in directory inode %llu "
3224
 
                                        "references already connected inode "
3225
 
                                        "%llu,\n",
 
3346
                                do_warn(_("entry \"%s\" in directory inode %llu"
 
3347
                                          " references already connected inode "
 
3348
                                          "%llu,\n"),
3226
3349
                                        fname, ino, lino);
3227
3350
                        } else if (parent == ino)  {
3228
3351
                                add_inode_reached(irec, ino_offset);
3233
3356
                                        push_dir(stack, lino);
3234
3357
                        } else  {
3235
3358
                                junkit = 1;
3236
 
                                do_warn("entry \"%s\" in directory inode %llu "
3237
 
                                        "not consistent with .. value (%llu) "
3238
 
                                        "in inode %llu,\n",
 
3359
                                do_warn(_("entry \"%s\" in directory inode %llu"
 
3360
                                          " not consistent with .. value (%llu)"
 
3361
                                          " in inode %llu,\n"),
3239
3362
                                        fname, ino, parent, lino);
3240
3363
                        }
3241
3364
                }
3273
3396
                                *ino_dirty = 1;
3274
3397
 
3275
3398
                                if (verbose || lino != old_orphanage_ino)
3276
 
                                        do_warn("junking entry \"%s\" in "
3277
 
                                                "directory inode %llu\n",
 
3399
                                        do_warn(_("junking entry \"%s\" in "
 
3400
                                                  "directory inode %llu\n"),
3278
3401
                                                fname, lino);
3279
3402
                        } else  {
3280
 
                                do_warn("would junk entry \"%s\"\n", fname);
 
3403
                                do_warn(_("would junk entry \"%s\"\n"), fname);
3281
3404
                        }
3282
3405
                } else if (lino > XFS_DIR2_MAX_SHORT_INUM)
3283
3406
                        i8++;
3301
3424
 
3302
3425
        if (sfp->hdr.i8count != i8) {
3303
3426
                if (no_modify) {
3304
 
                        do_warn("would fix i8count in inode %llu\n", ino);
 
3427
                        do_warn(_("would fix i8count in inode %llu\n"), ino);
3305
3428
                } else {
3306
3429
                        if (i8 == 0) {
3307
3430
                                tmp_sfep = next_sfep;
3313
3436
                        } else
3314
3437
                                sfp->hdr.i8count = i8;
3315
3438
                        *ino_dirty = 1;
3316
 
                        do_warn("fixing i8count in inode %llu\n", ino);
 
3439
                        do_warn(_("fixing i8count in inode %llu\n"), ino);
3317
3440
                }
3318
3441
        }
3319
3442
 
3332
3455
                                ((__psint_t) next_sfep - (__psint_t) sfp));
3333
3456
                ip->i_d.di_size = (xfs_fsize_t)
3334
3457
                                ((__psint_t) next_sfep - (__psint_t) sfp);
3335
 
                do_warn("setting size to %lld bytes to reflect junked "
3336
 
                        "entries\n",
 
3458
                do_warn(_("setting size to %lld bytes to reflect junked "
 
3459
                          "entries\n"),
3337
3460
                        ip->i_d.di_size);
3338
3461
                *ino_dirty = 1;
3339
3462
        }
3375
3498
 
3376
3499
                if ((error = libxfs_iget(mp, NULL, ino, 0, &ip, 0))) {
3377
3500
                        if (!no_modify)
3378
 
                                do_error("couldn't map inode %llu, err = %d\n",
 
3501
                                do_error(
 
3502
                                _("couldn't map inode %llu, err = %d\n"),
3379
3503
                                        ino, error);
3380
3504
                        else  {
3381
 
                                do_warn("couldn't map inode %llu, err = %d\n",
 
3505
                                do_warn(
 
3506
                                _("couldn't map inode %llu, err = %d\n"),
3382
3507
                                        ino, error);
3383
3508
                                /*
3384
3509
                                 * see below for what we're doing if this
3500
3625
 
3501
3626
                if (!no_modify && !orphanage_entered &&
3502
3627
                    ino == mp->m_sb.sb_rootino) {
3503
 
                        do_warn("re-entering %s into root directory\n",
 
3628
                        do_warn(_("re-entering %s into root directory\n"),
3504
3629
                                ORPHANAGE);
3505
3630
                        tp = libxfs_trans_alloc(mp, 0);
3506
3631
                        nres = XFS_MKDIR_SPACE_RES(mp, strlen(ORPHANAGE));
3517
3642
                                                strlen(ORPHANAGE),
3518
3643
                                                orphanage_ino, &first, &flist,
3519
3644
                                                nres)))
3520
 
                                do_error("can't make %s entry in root inode "
3521
 
                                         "%llu, createname error %d\n",
 
3645
                                do_error(_("can't make %s entry in root inode "
 
3646
                                           "%llu, createname error %d\n"),
3522
3647
                                        ORPHANAGE, ino, error);
3523
3648
                        libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
3524
3649
                        error = libxfs_bmap_finish(&tp, &flist, first, &committed);
3542
3667
                                ino == mp->m_sb.sb_rootino)  {
3543
3668
                        ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_LOCAL);
3544
3669
 
3545
 
                        do_warn("recreating root directory .. entry\n");
 
3670
                        do_warn(_("recreating root directory .. entry\n"));
3546
3671
 
3547
3672
                        tp = libxfs_trans_alloc(mp, 0);
3548
3673
                        ASSERT(tp != NULL);
3565
3690
                        if ((error = dir_createname(mp, tp, ip, "..", 2,
3566
3691
                                        ip->i_ino, &first, &flist, nres)))
3567
3692
                                do_error(
3568
 
"can't make \"..\" entry in root inode %llu, createname error %d\n",
 
3693
_("can't make \"..\" entry in root inode %llu, createname error %d\n"),
3569
3694
                                        ino, error);
3570
3695
 
3571
3696
                        libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
3578
3703
 
3579
3704
                        need_root_dotdot = 0;
3580
3705
                } else if (need_root_dotdot && ino == mp->m_sb.sb_rootino)  {
3581
 
                        do_warn("would recreate root directory .. entry\n");
 
3706
                        do_warn(_("would recreate root directory .. entry\n"));
3582
3707
                }
3583
3708
 
3584
3709
                /*
3657
3782
 
3658
3783
                        if (no_modify)  {
3659
3784
                                do_warn(
3660
 
        "would create missing \".\" entry in dir ino %llu\n",
 
3785
        _("would create missing \".\" entry in dir ino %llu\n"),
3661
3786
                                        ino);
3662
3787
                        } else if (ip->i_d.di_format != XFS_DINODE_FMT_LOCAL)  {
3663
3788
                                /*
3664
3789
                                 * need to create . entry in longform dir.
3665
3790
                                 */
3666
3791
                                do_warn(
3667
 
        "creating missing \".\" entry in dir ino %llu\n",
 
3792
        _("creating missing \".\" entry in dir ino %llu\n"),
3668
3793
                                        ino);
3669
3794
 
3670
3795
                                tp = libxfs_trans_alloc(mp, 0);
3689
3814
                                                1, ip->i_ino, &first, &flist,
3690
3815
                                                nres)))
3691
3816
                                        do_error(
3692
 
        "can't make \".\" entry in dir ino %llu, createname error %d\n",
 
3817
        _("can't make \".\" entry in dir ino %llu, createname error %d\n"),
3693
3818
                                                ino, error);
3694
3819
 
3695
3820
                                libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
3729
3854
        irec = find_inode_rec(XFS_INO_TO_AGNO(mp, mp->m_sb.sb_rsumino),
3730
3855
                        XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rsumino));
3731
3856
 
3732
 
        offset = XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rsumino) - 
 
3857
        offset = XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rsumino) -
3733
3858
                        irec->ino_startnum;
3734
3859
 
3735
3860
        ASSERT(irec != NULL);
3769
3894
 
3770
3895
        bzero(&zerocr, sizeof(cred_t));
3771
3896
 
3772
 
        do_log("Phase 6 - check inode connectivity...\n");
 
3897
        do_log(_("Phase 6 - check inode connectivity...\n"));
3773
3898
 
3774
3899
        if (!no_modify)
3775
3900
                teardown_bmap_finish(mp);
3788
3913
         */
3789
3914
        if (need_root_inode)  {
3790
3915
                if (!no_modify)  {
3791
 
                        do_warn("reinitializing root directory\n");
 
3916
                        do_warn(_("reinitializing root directory\n"));
3792
3917
                        mk_root_dir(mp);
3793
3918
                        need_root_inode = 0;
3794
3919
                        need_root_dotdot = 0;
3795
3920
                } else  {
3796
 
                        do_warn("would reinitialize root directory\n");
 
3921
                        do_warn(_("would reinitialize root directory\n"));
3797
3922
                }
3798
3923
        }
3799
3924
 
3800
3925
        if (need_rbmino)  {
3801
3926
                if (!no_modify)  {
3802
 
                        do_warn("reinitializing realtime bitmap inode\n");
 
3927
                        do_warn(_("reinitializing realtime bitmap inode\n"));
3803
3928
                        mk_rbmino(mp);
3804
3929
                        need_rbmino = 0;
3805
3930
                } else  {
3806
 
                        do_warn("would reinitialize realtime bitmap inode\n");
 
3931
                        do_warn(_("would reinitialize realtime bitmap inode\n"));
3807
3932
                }
3808
3933
        }
3809
3934
 
3810
3935
        if (need_rsumino)  {
3811
3936
                if (!no_modify)  {
3812
 
                        do_warn("reinitializing realtime summary inode\n");
 
3937
                        do_warn(_("reinitializing realtime summary inode\n"));
3813
3938
                        mk_rsumino(mp);
3814
3939
                        need_rsumino = 0;
3815
3940
                } else  {
3816
 
                        do_warn("would reinitialize realtime summary inode\n");
 
3941
                        do_warn(_("would reinitialize realtime summary inode\n"));
3817
3942
                }
3818
3943
        }
3819
3944
 
3820
3945
        if (!no_modify)  {
3821
3946
                do_log(
3822
 
        "        - resetting contents of realtime bitmap and summary inodes\n");
 
3947
_("        - resetting contents of realtime bitmap and summary inodes\n"));
3823
3948
                if (fill_rbmino(mp))  {
3824
3949
                        do_warn(
3825
 
                        "Warning:  realtime bitmap may be inconsistent\n");
 
3950
                        _("Warning:  realtime bitmap may be inconsistent\n"));
3826
3951
                }
3827
3952
 
3828
3953
                if (fill_rsumino(mp))  {
3829
3954
                        do_warn(
3830
 
                        "Warning:  realtime bitmap may be inconsistent\n");
 
3955
                        _("Warning:  realtime bitmap may be inconsistent\n"));
3831
3956
                }
3832
3957
        }
3833
3958
 
3835
3960
         * make orphanage (it's guaranteed to not exist now)
3836
3961
         */
3837
3962
        if (!no_modify)  {
3838
 
                do_log("        - ensuring existence of %s directory\n",
 
3963
                do_log(_("        - ensuring existence of %s directory\n"),
3839
3964
                        ORPHANAGE);
3840
3965
                orphanage_ino = mk_orphanage(mp);
3841
3966
        }
3848
3973
         * push root dir on stack, then go
3849
3974
         */
3850
3975
        if (!need_root_inode)  {
3851
 
                do_log("        - traversing filesystem starting at / ... \n");
 
3976
                do_log(_("        - traversing filesystem starting at / ... \n"));
3852
3977
 
3853
3978
                push_dir(&stack, mp->m_sb.sb_rootino);
3854
3979
                process_dirstack(mp, &stack);
3855
3980
 
3856
 
                do_log("        - traversal finished ... \n");
 
3981
                do_log(_("        - traversal finished ... \n"));
3857
3982
        } else  {
3858
3983
                ASSERT(no_modify != 0);
3859
3984
 
3860
3985
                do_log(
3861
 
"        - root inode lost, cannot make new one in no modify mode ... \n");
 
3986
_("        - root inode lost, cannot make new one in no modify mode ... \n"));
3862
3987
                do_log(
3863
 
"        - skipping filesystem traversal from / ... \n");
 
3988
_("        - skipping filesystem traversal from / ... \n"));
3864
3989
        }
3865
3990
 
3866
 
        do_log("        - traversing all unattached subtrees ... \n");
 
3991
        do_log(_("        - traversing all unattached subtrees ... \n"));
3867
3992
 
3868
3993
        irec = find_inode_rec(XFS_INO_TO_AGNO(mp, mp->m_sb.sb_rootino),
3869
3994
                                XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rootino));
3914
4039
                }
3915
4040
        }
3916
4041
 
3917
 
        do_log("        - traversals finished ... \n");
3918
 
        do_log("        - moving disconnected inodes to lost+found ... \n");
 
4042
        do_log(_("        - traversals finished ... \n"));
 
4043
        do_log(_("        - moving disconnected inodes to lost+found ... \n"));
3919
4044
 
3920
4045
        /*
3921
4046
         * move all disconnected inodes to the orphanage
3939
4064
                                                j + irec->ino_startnum);
3940
4065
                                        if (inode_isadir(irec, j))
3941
4066
                                                do_warn(
3942
 
                                                "disconnected dir inode %llu, ",
 
4067
                                        _("disconnected dir inode %llu, "),
3943
4068
                                                        ino);
3944
4069
                                        else
3945
4070
                                                do_warn(
3946
 
                                                "disconnected inode %llu, ",
 
4071
                                        _("disconnected inode %llu, "),
3947
4072
                                                        ino);
3948
4073
                                        if (!no_modify)  {
3949
 
                                                do_warn("moving to %s\n",
 
4074
                                                do_warn(_("moving to %s\n"),
3950
4075
                                                        ORPHANAGE);
3951
4076
                                                mv_orphanage(mp, orphanage_ino,
3952
4077
                                                        ino,
3953
4078
                                                        inode_isadir(irec, j));
3954
4079
                                        } else  {
3955
 
                                                do_warn("would move to %s\n",
 
4080
                                                do_warn(_("would move to %s\n"),
3956
4081
                                                        ORPHANAGE);
3957
4082
                                        }
3958
4083
                                        /*