2
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
2
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
23
23
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24
24
* Mountain View, CA 94043, or:
28
* For further information regarding this notice, see:
28
* For further information regarding this notice, see:
30
30
* http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
135
static char *seevalstr[] = {
138
"hash value mismatch",
134
static char *seevalstr[DIR_HASH_CK_TOTAL];
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
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)
148
do_warn("bad hash table for directory inode %llu (%s): ", ip->i_ino,
151
do_warn(_("bad hash table for directory inode %llu (%s): "),
152
ip->i_ino, seevalstr[seeval]);
151
do_warn("rebuilding\n");
154
do_warn(_("rebuilding\n"));
153
do_warn("would rebuild\n");
156
do_warn(_("would rebuild\n"));
349
350
error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, &ip);
351
do_error("couldn't iget realtime bitmap inode -- error - %d\n",
353
_("couldn't iget realtime bitmap inode -- error - %d\n"),
355
357
bzero(&ip->i_d, sizeof(xfs_dinode_core_t));
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;
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);
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);
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);
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);
580
585
error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0, &ip);
582
do_error("couldn't iget realtime summary inode -- error - %d\n",
588
_("couldn't iget realtime summary inode -- error - %d\n"),
586
592
bzero(&ip->i_d, sizeof(xfs_dinode_core_t));
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);
638
"couldn't allocate realtime summary inode - err %d\n",
644
_("couldn't allocate realtime summary inode, error = %d\n"),
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;
649
654
error = libxfs_bmap_finish(&tp, &flist, first, &committed);
652
"allocation of the realtime summary ino failed, err = %d\n",
657
_("allocation of the realtime summary ino failed, error = %d\n"),
655
660
libxfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_SYNC, 0);
744
749
* wrapper can commit the transaction and start a new one
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"),
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,
754
do_error("%s inode allocation failed %d\n",
759
do_error(_("%s inode allocation failed %d\n"),
755
760
ORPHANAGE, error);
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",
779
_("can't make %s, createname error %d, will try later\n"),
774
780
ORPHANAGE, error);
775
781
orphanage_entered = 0;
777
783
orphanage_entered = 1;
780
786
* bump up the link count in the root directory to account
781
787
* for .. in the new directory
825
831
snprintf(fname, sizeof(fname), "%llu", (unsigned long long)ino);
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);
830
836
tp = libxfs_trans_alloc(mp, 0);
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);
836
842
nres = XFS_DIRENTER_SPACE_RES(mp, strlen(fname)) +
864
870
if ((err = dir_createname(mp, tp, ino_p, "..", 2,
865
871
dir_ino, &first, &flist, nres)))
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"),
870
876
ino_p->i_d.di_nlink++;
910
916
2, dir_ino, &first,
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"),
917
923
if ((err = libxfs_bmap_finish(&tp, &flist, first,
920
"bmap finish failed (%d), filesystem may be out of space\n",
926
_("bmap finish failed (%d), filesystem may be out of space\n"),
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)))
937
"space reservation failed (%d), filesystem may be out of space\n",
943
_("space reservation failed (%d), filesystem may be out of space\n"),
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)))
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"),
949
955
ASSERT(err == 0);
1003
1009
if (error || nmap != 1) {
1004
1010
if (!no_modify)
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);
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);
1073
1079
if (error || nmap != 1) {
1074
1080
if (!no_modify)
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);
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);
1211
1217
&map, &nmap, NULL);
1212
1218
if (error || nmap != 1)
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) {
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);
1403
1410
irec = find_inode_rec(XFS_INO_TO_AGNO(mp, lino),
1404
1411
XFS_INO_TO_AGINO(mp, lino));
1406
1413
if (irec == NULL) {
1409
"entry \"%s\" in dir inode %llu points to non-existent inode, ",
1416
_("entry \"%s\" in dir inode %llu points to non-existent inode, "),
1412
1419
if (!no_modify) {
1413
1420
namest->name[0] = '/';
1415
do_warn("marking entry to be junked\n");
1422
do_warn(_("marking entry to be junked\n"));
1417
do_warn("would junk entry\n");
1424
do_warn(_("would junk entry\n"));
1435
1442
if (verbose || no_modify || lino != old_orphanage_ino)
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);
1441
1448
if (!no_modify) {
1442
1449
if (verbose || lino != old_orphanage_ino)
1443
do_warn(", marking entry to be junked\n");
1451
_(", marking entry to be junked\n"));
1447
1455
namest->name[0] = '/';
1450
do_warn(", would junk entry\n");
1458
do_warn(_(", would junk entry\n"));
1567
1577
da_bno = INT_GET(leaf->hdr.info.forw, ARCH_CONVERT);
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) {
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,
1574
1586
ino, da_bno, fsbno);
1575
1587
/* NOTREACHED */
1604
1616
if (error || nmap != 1) {
1605
1617
if (!no_modify)
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);
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);
1670
1682
error = libxfs_dir2_shrink_inode(&args,
1671
1683
XFS_DIR2_DA_TO_DB(mp, da_bno), bp);
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);
1742
1755
wantmagic = XFS_DIR2_DATA_MAGIC;
1744
1757
db = XFS_DIR2_DA_TO_DB(mp, da_bno);
1759
/* check for data block beyond expected end */
1745
1760
if (freetab->naents <= db) {
1746
1761
struct freetab_ent e;
1748
1763
*freetabp = freetab = realloc(freetab, FREETAB_SIZE(db + 1));
1749
1764
if (!freetab) {
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));
1755
1769
e.v = NULLDATAOFF;
1758
1772
freetab->ents[i] = e;
1759
1773
freetab->naents = db + 1;
1761
if (freetab->nents < db + 1)
1762
freetab->nents = db + 1;
1776
/* check the data block */
1763
1777
while (ptr < endptr) {
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)) {
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)))
1769
if (INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P_ARCH(dup, ARCH_CONVERT), ARCH_CONVERT) !=
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)
1797
/* check for block with no data entries */
1798
if ((ptr == (char *)d->u) &&
1799
(ptr + INT_GET(dup->length, ARCH_CONVERT) >=
1806
/* continue at the end of the freespace */
1772
1807
ptr += INT_GET(dup->length, ARCH_CONVERT);
1773
1808
if (ptr >= endptr)
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)
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)
1781
1819
ptr += XFS_DIR2_DATA_ENTSIZE(dep->namelen);
1822
/* did we find an empty or corrupt block? */
1783
1823
if (ptr != endptr) {
1784
do_warn("corrupt block %u in directory inode %llu: ",
1826
_("empty data block %u in directory inode %llu: "),
1829
do_warn(_("corrupt block %u in directory inode %llu: "),
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);
1790
do_warn("would junk block\n");
1836
do_warn(_("would junk block\n"));
1791
1837
libxfs_da_brelse(NULL, bp);
1793
1839
freetab->ents[db].v = NULLDATAOFF;
1844
/* update number of data blocks processed */
1845
if (freetab->nents < db + 1)
1846
freetab->nents = db + 1;
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 "
1860
do_warn(_("bad directory block magic # %#x for directory inode "
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);
1817
do_warn("would fix magic # to %#x\n", wantmagic);
1868
do_warn(_("would fix magic # to %#x\n"), wantmagic);
1820
1871
ptr = (char *)d->u;
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,
1911
1963
* skip entries with bogus inumbers if we're in no modify mode
1913
if (no_modify && verify_inum(mp, INT_GET(dep->inumber, ARCH_CONVERT)))
1966
verify_inum(mp, INT_GET(dep->inumber, ARCH_CONVERT)))
1916
1969
* ok, now handle the rest of the cases besides '.' and '..'
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(
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) {
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"));
1930
do_warn("would junk entry\n");
1986
do_warn(_("would junk entry\n"));
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)) -
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
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) !=
2007
_("entry \"%s\" in directory inode %llu points to free inode %llu"),
2009
INT_GET(dep->inumber, ARCH_CONVERT));
1952
2011
if (!no_modify) {
1954
INT_GET(dep->inumber, ARCH_CONVERT) != old_orphanage_ino)
1955
do_warn(", marking entry to be "
2013
INT_GET(dep->inumber, ARCH_CONVERT) !=
2016
_(", marking entry to be junked\n"));
1959
2019
dep->name[0] = '/';
1960
2020
libxfs_dir2_data_log_entry(tp, bp, dep);
1962
do_warn(", would junk entry\n");
2022
do_warn(_(", would junk entry\n"));
1983
2043
if (is_inode_reached(irec, ino_offset)) {
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));
2046
_("entry \"%s\" in dir %llu points to an already connected directory inode %llu,\n"),
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,
1993
push_dir(stack, INT_GET(dep->inumber, ARCH_CONVERT));
2056
INT_GET(dep->inumber, ARCH_CONVERT));
1996
do_warn("entry \"%s\" in directory inode %llu not "
1997
"consistent with .. value (%llu) in ino "
1999
fname, ip->i_ino, parent, INT_GET(dep->inumber, ARCH_CONVERT));
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));
2005
2068
dep->name[0] = '/';
2006
2069
libxfs_dir2_data_log_entry(tp, bp, dep);
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) !=
2074
_("\twill clear entry \"%s\"\n"),
2012
do_warn("\twould clear entry \"%s\"\n", fname);
2077
do_warn(_("\twould clear entry \"%s\"\n"),
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 */
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)] >
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);
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);
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 "
2189
_("can't read block %u for directory inode %llu\n"),
2117
2190
da_bno, ip->i_ino);
2118
2191
/* NOTREACHED */
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);
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),
2129
2205
libxfs_da_brelse(NULL, bp);
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 "
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 "
2136
2214
da_bno, ip->i_ino);
2137
2215
libxfs_da_brelse(NULL, bp);
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 "
2234
do_error(_("can't read block %u for directory inode "
2158
2236
da_bno, ip->i_ino);
2159
2237
/* NOTREACHED */
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 "
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 "
2170
2250
da_bno, ip->i_ino);
2171
2251
libxfs_da_brelse(NULL, bp);
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) >=
2257
freetab->ents[i + INT_GET(free->hdr.firstdb,
2177
2259
INT_GET(free->bests[i], ARCH_CONVERT)) {
2178
do_warn("free block %u entry %i for directory "
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);
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 */
2253
if (dbp && (data = dbp->data)->hdr.magic == XFS_DIR2_BLOCK_MAGIC) {
2340
/* check for block format directory */
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;
2349
/* convert directory block from block format to data format */
2260
2350
INT_SET(data->hdr.magic, ARCH_CONVERT, XFS_DIR2_DATA_MAGIC);
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);
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 */
2388
2482
data = malloc(mp->m_dirblksize);
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);
2540
2636
if (libxfs_bmap_next_offset(NULL, ip, &next_da_bno, XFS_DATA_FORK))
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 "
2639
do_error(_("can't get block %u for directory inode "
2546
2642
/* NOTREACHED */
2548
2644
dir2_kill_block(mp, ip, da_bno, bp);
2647
/* rebuild empty btree and freelist */
2550
2648
longform_dir2_rebuild_setup(mp, ino, ip, freetab);
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) {
2604
2706
freetab->ents[i].v = NULLDATAOFF;
2605
2707
freetab->ents[i].s = 0;
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);
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))
2616
if (libxfs_da_read_bufr(NULL, ip, da_bno, -1, &bp,
2618
do_error("can't read block %u for directory inode "
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 "
2621
2726
/* NOTREACHED */
2728
/* is there a hole at the start? */
2729
if (da_bno == 0 && bp == NULL)
2623
2731
longform_dir2_entry_check_data(mp, ip, num_illegal, need_dot,
2624
2732
stack, irec, ino_offset, &bp, hashtab, &freetab, da_bno,
2626
2734
/* it releases the buffer unless isblock is set */
2628
2736
fixit = (*num_illegal != 0) || dir2_is_badino(ino);
2738
/* check btree and freespace */
2631
2741
block = bp->data;
2809
2920
if (verbose || no_modify || lino != old_orphanage_ino)
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);
2814
2925
if (!no_modify) {
2817
do_warn("would junk entry \"%s\"\n",
2928
do_warn(_("would junk entry \"%s\"\n"),
2820
2931
} else if (!inode_isadir(irec, ino_offset)) {
3080
3191
add_inode_ref(current_irec, current_ino_offset);
3194
* Initialise i8 counter -- the parent inode number counts as well.
3196
i8 = (XFS_DIR2_SF_GET_INUMBER_ARCH(sfp, &sfp->hdr.parent, ARCH_CONVERT) > XFS_DIR2_MAX_SHORT_INUM);
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.
3157
if ((lino == orphanage_ino && strcmp(fname, ORPHANAGE) == 0)
3158
|| (no_modify && verify_inum(mp, lino))) {
3269
* link is already accounted for.
3272
if (lino == orphanage_ino && strcmp(fname, ORPHANAGE) == 0) {
3273
if (lino > XFS_DIR2_MAX_SHORT_INUM)
3275
next_sfep = (xfs_dir2_sf_entry_t *)
3277
XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp, sfep));
3282
* Also skip entries with bogus inode numbers if we're
3283
* in no modify mode.
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));
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"));
3188
3316
* and now-free lost+found inode
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 "
3319
do_warn(_("entry \"%s\" in shortform directory "
3320
"inode %llu points to free inode "
3194
3322
fname, ino, lino);
3196
3324
if (!no_modify) {
3199
do_warn("would junk entry \"%s\"\n",
3327
do_warn(_("would junk entry \"%s\"\n"),
3202
3330
} else if (!inode_isadir(irec, ino_offset)) {
3204
3332
* check easy case first, regular inode, just bump
3205
* the link count and continue
3207
3335
add_inode_reached(irec, ino_offset);
3209
next_sfep = (xfs_dir2_sf_entry_t *)
3211
XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp, sfep));
3214
3337
parent = get_inode_parent(irec, ino_offset);
3273
3396
*ino_dirty = 1;
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"),
3280
do_warn("would junk entry \"%s\"\n", fname);
3403
do_warn(_("would junk entry \"%s\"\n"), fname);
3282
3405
} else if (lino > XFS_DIR2_MAX_SHORT_INUM)
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",
3502
_("couldn't map inode %llu, err = %d\n"),
3381
do_warn("couldn't map inode %llu, err = %d\n",
3506
_("couldn't map inode %llu, err = %d\n"),
3384
3509
* see below for what we're doing if this
3517
3642
strlen(ORPHANAGE),
3518
3643
orphanage_ino, &first, &flist,
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);
3565
3690
if ((error = dir_createname(mp, tp, ip, "..", 2,
3566
3691
ip->i_ino, &first, &flist, nres)))
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"),
3571
3696
libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
3658
3783
if (no_modify) {
3660
"would create missing \".\" entry in dir ino %llu\n",
3785
_("would create missing \".\" entry in dir ino %llu\n"),
3662
3787
} else if (ip->i_d.di_format != XFS_DINODE_FMT_LOCAL) {
3664
3789
* need to create . entry in longform dir.
3667
"creating missing \".\" entry in dir ino %llu\n",
3792
_("creating missing \".\" entry in dir ino %llu\n"),
3670
3795
tp = libxfs_trans_alloc(mp, 0);
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;
3796
do_warn("would reinitialize root directory\n");
3921
do_warn(_("would reinitialize root directory\n"));
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"));
3804
3929
need_rbmino = 0;
3806
do_warn("would reinitialize realtime bitmap inode\n");
3931
do_warn(_("would reinitialize realtime bitmap inode\n"));
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;
3816
do_warn("would reinitialize realtime summary inode\n");
3941
do_warn(_("would reinitialize realtime summary inode\n"));
3820
3945
if (!no_modify) {
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)) {
3825
"Warning: realtime bitmap may be inconsistent\n");
3950
_("Warning: realtime bitmap may be inconsistent\n"));
3828
3953
if (fill_rsumino(mp)) {
3830
"Warning: realtime bitmap may be inconsistent\n");
3955
_("Warning: realtime bitmap may be inconsistent\n"));
3848
3973
* push root dir on stack, then go
3850
3975
if (!need_root_inode) {
3851
do_log(" - traversing filesystem starting at / ... \n");
3976
do_log(_(" - traversing filesystem starting at / ... \n"));
3853
3978
push_dir(&stack, mp->m_sb.sb_rootino);
3854
3979
process_dirstack(mp, &stack);
3856
do_log(" - traversal finished ... \n");
3981
do_log(_(" - traversal finished ... \n"));
3858
3983
ASSERT(no_modify != 0);
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"));
3863
" - skipping filesystem traversal from / ... \n");
3988
_(" - skipping filesystem traversal from / ... \n"));
3866
do_log(" - traversing all unattached subtrees ... \n");
3991
do_log(_(" - traversing all unattached subtrees ... \n"));
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));
3939
4064
j + irec->ino_startnum);
3940
4065
if (inode_isadir(irec, j))
3942
"disconnected dir inode %llu, ",
4067
_("disconnected dir inode %llu, "),
3946
"disconnected inode %llu, ",
4071
_("disconnected inode %llu, "),
3948
4073
if (!no_modify) {
3949
do_warn("moving to %s\n",
4074
do_warn(_("moving to %s\n"),
3951
4076
mv_orphanage(mp, orphanage_ino,
3953
4078
inode_isadir(irec, j));
3955
do_warn("would move to %s\n",
4080
do_warn(_("would move to %s\n"),