]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - repair/phase1.c
2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "err_protos.h"
28 do_warn(_("Sorry, could not find valid secondary superblock\n"));
29 do_warn(_("Exiting now.\n"));
34 alloc_ag_buf(int size
)
38 bp
= (char *)memalign(MEM_ALIGN
, size
);
40 do_error(_("could not allocate ag header buffer (%d bytes)\n"),
46 * this has got to be big enough to hold 4 sectors
48 #define MAX_SECTSIZE (512 * 1024)
52 phase1(xfs_mount_t
*mp
)
60 do_log(_("Phase 1 - find and verify superblock...\n"));
62 primary_sb_modified
= 0;
68 old_orphanage_ino
= (xfs_ino_t
) 0;
71 * get AG 0 into ag header buf
73 ag_bp
= alloc_ag_buf(MAX_SECTSIZE
);
74 sb
= (xfs_sb_t
*) ag_bp
;
76 if (get_sb(sb
, 0LL, MAX_SECTSIZE
, 0) == XR_EOF
)
77 do_error(_("error reading primary superblock\n"));
80 * is this really an sb, verify internal consistency
82 if ((rval
= verify_sb(sb
, 1)) != XR_OK
) {
83 do_warn(_("bad primary superblock - %s !!!\n"),
85 if (!find_secondary_sb(sb
))
87 primary_sb_modified
= 1;
88 } else if ((rval
= verify_set_primary_sb(sb
, 0,
89 &primary_sb_modified
)) != XR_OK
) {
90 do_warn(_("couldn't verify primary superblock - %s !!!\n"),
92 if (!find_secondary_sb(sb
))
94 primary_sb_modified
= 1;
97 if (primary_sb_modified
) {
99 do_warn(_("writing modified primary superblock\n"));
100 write_primary_sb(sb
, sb
->sb_sectsize
);
102 do_warn(_("would write modified primary superblock\n"));
107 * misc. global var initialization
109 sb_ifree
= sb_icount
= sb_fdblocks
= sb_frextents
= 0;