2
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
2
* Copyright (c) 2000-2001 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/
47
47
if (INT_GET(agf->agf_magicnum, ARCH_CONVERT) != XFS_AGF_MAGIC) {
48
48
retval = XR_AG_AGF;
49
do_warn("bad magic # 0x%x for agf %d\n", INT_GET(agf->agf_magicnum, ARCH_CONVERT), i);
49
do_warn(_("bad magic # 0x%x for agf %d\n"),
50
INT_GET(agf->agf_magicnum, ARCH_CONVERT), i);
52
53
INT_SET(agf->agf_magicnum, ARCH_CONVERT, XFS_AGF_MAGIC);
55
56
if (!XFS_AGF_GOOD_VERSION(INT_GET(agf->agf_versionnum, ARCH_CONVERT))) {
56
57
retval = XR_AG_AGF;
57
do_warn("bad version # %d for agf %d\n",
58
do_warn(_("bad version # %d for agf %d\n"),
58
59
INT_GET(agf->agf_versionnum, ARCH_CONVERT), i);
61
INT_SET(agf->agf_versionnum, ARCH_CONVERT, XFS_AGF_VERSION);
62
INT_SET(agf->agf_versionnum, ARCH_CONVERT,
64
66
if (INT_GET(agf->agf_seqno, ARCH_CONVERT) != i) {
65
67
retval = XR_AG_AGF;
66
do_warn("bad sequence # %d for agf %d\n", INT_GET(agf->agf_seqno, ARCH_CONVERT), i);
68
do_warn(_("bad sequence # %d for agf %d\n"),
69
INT_GET(agf->agf_seqno, ARCH_CONVERT), i);
69
72
INT_SET(agf->agf_seqno, ARCH_CONVERT, i);
72
75
if (INT_GET(agf->agf_length, ARCH_CONVERT) != mp->m_sb.sb_agblocks) {
73
76
if (i != mp->m_sb.sb_agcount - 1) {
74
77
retval = XR_AG_AGF;
75
do_warn("bad length %d for agf %d, should be %d\n",
76
INT_GET(agf->agf_length, ARCH_CONVERT), i, mp->m_sb.sb_agblocks);
78
do_warn(_("bad length %d for agf %d, should be %d\n"),
79
INT_GET(agf->agf_length, ARCH_CONVERT), i,
80
mp->m_sb.sb_agblocks);
78
INT_SET(agf->agf_length, ARCH_CONVERT, mp->m_sb.sb_agblocks);
82
INT_SET(agf->agf_length, ARCH_CONVERT,
83
mp->m_sb.sb_agblocks);
80
85
agblocks = mp->m_sb.sb_dblocks -
81
86
(xfs_drfsbno_t) mp->m_sb.sb_agblocks * i;
83
88
if (INT_GET(agf->agf_length, ARCH_CONVERT) != agblocks) {
84
89
retval = XR_AG_AGF;
86
"bad length %d for agf %d, should be %llu\n",
87
INT_GET(agf->agf_length, ARCH_CONVERT), i, agblocks);
91
_("bad length %d for agf %d, should be %llu\n"),
92
INT_GET(agf->agf_length, ARCH_CONVERT),
89
INT_SET(agf->agf_length, ARCH_CONVERT, (xfs_agblock_t) agblocks);
95
INT_SET(agf->agf_length, ARCH_CONVERT,
96
(xfs_agblock_t) agblocks);
95
102
* check first/last AGF fields. if need be, lose the free
96
103
* space in the AGFL, we'll reclaim it later.
98
if (INT_GET(agf->agf_flfirst, ARCH_CONVERT) >= XFS_AGFL_SIZE) {
99
do_warn("flfirst %d in agf %d too large (max = %d)\n",
100
INT_GET(agf->agf_flfirst, ARCH_CONVERT), i, XFS_AGFL_SIZE);
105
if (INT_GET(agf->agf_flfirst, ARCH_CONVERT) >= XFS_AGFL_SIZE(mp)) {
106
do_warn(_("flfirst %d in agf %d too large (max = %d)\n"),
107
INT_GET(agf->agf_flfirst, ARCH_CONVERT),
108
i, XFS_AGFL_SIZE(mp));
102
110
INT_ZERO(agf->agf_flfirst, ARCH_CONVERT);
105
if (INT_GET(agf->agf_fllast, ARCH_CONVERT) >= XFS_AGFL_SIZE) {
106
do_warn("fllast %d in agf %d too large (max = %d)\n",
107
INT_GET(agf->agf_fllast, ARCH_CONVERT), i, XFS_AGFL_SIZE);
113
if (INT_GET(agf->agf_fllast, ARCH_CONVERT) >= XFS_AGFL_SIZE(mp)) {
114
do_warn(_("fllast %d in agf %d too large (max = %d)\n"),
115
INT_GET(agf->agf_fllast, ARCH_CONVERT),
116
i, XFS_AGFL_SIZE(mp));
109
118
INT_ZERO(agf->agf_fllast, ARCH_CONVERT);
125
134
if (INT_GET(agi->agi_magicnum, ARCH_CONVERT) != XFS_AGI_MAGIC) {
126
135
retval = XR_AG_AGI;
127
do_warn("bad magic # 0x%x for agi %d\n", INT_GET(agi->agi_magicnum, ARCH_CONVERT), i);
136
do_warn(_("bad magic # 0x%x for agi %d\n"),
137
INT_GET(agi->agi_magicnum, ARCH_CONVERT), i);
130
140
INT_SET(agi->agi_magicnum, ARCH_CONVERT, XFS_AGI_MAGIC);
133
143
if (!XFS_AGI_GOOD_VERSION(INT_GET(agi->agi_versionnum, ARCH_CONVERT))) {
134
144
retval = XR_AG_AGI;
135
do_warn("bad version # %d for agi %d\n",
145
do_warn(_("bad version # %d for agi %d\n"),
136
146
INT_GET(agi->agi_versionnum, ARCH_CONVERT), i);
139
INT_SET(agi->agi_versionnum, ARCH_CONVERT, XFS_AGI_VERSION);
149
INT_SET(agi->agi_versionnum, ARCH_CONVERT,
142
153
if (INT_GET(agi->agi_seqno, ARCH_CONVERT) != i) {
143
154
retval = XR_AG_AGI;
144
do_warn("bad sequence # %d for agi %d\n", INT_GET(agi->agi_seqno, ARCH_CONVERT), i);
155
do_warn(_("bad sequence # %d for agi %d\n"),
156
INT_GET(agi->agi_seqno, ARCH_CONVERT), i);
147
159
INT_SET(agi->agi_seqno, ARCH_CONVERT, i);
150
162
if (INT_GET(agi->agi_length, ARCH_CONVERT) != mp->m_sb.sb_agblocks) {
151
163
if (i != mp->m_sb.sb_agcount - 1) {
152
164
retval = XR_AG_AGI;
153
do_warn("bad length # %d for agi %d, should be %d\n",
154
INT_GET(agi->agi_length, ARCH_CONVERT), i, mp->m_sb.sb_agblocks);
165
do_warn(_("bad length # %d for agi %d, should be %d\n"),
166
INT_GET(agi->agi_length, ARCH_CONVERT), i,
167
mp->m_sb.sb_agblocks);
156
INT_SET(agi->agi_length, ARCH_CONVERT, mp->m_sb.sb_agblocks);
169
INT_SET(agi->agi_length, ARCH_CONVERT,
170
mp->m_sb.sb_agblocks);
158
172
agblocks = mp->m_sb.sb_dblocks -
159
173
(xfs_drfsbno_t) mp->m_sb.sb_agblocks * i;
161
175
if (INT_GET(agi->agi_length, ARCH_CONVERT) != agblocks) {
162
176
retval = XR_AG_AGI;
164
"bad length # %d for agi %d, should be %llu\n",
165
INT_GET(agi->agi_length, ARCH_CONVERT), i, agblocks);
178
_("bad length # %d for agi %d, should be %llu\n"),
179
INT_GET(agi->agi_length, ARCH_CONVERT),
167
INT_SET(agi->agi_length, ARCH_CONVERT, (xfs_agblock_t) agblocks);
182
INT_SET(agi->agi_length, ARCH_CONVERT,
183
(xfs_agblock_t) agblocks);
209
225
* zero and the shared version bit should be cleared for
210
226
* current mkfs's.
212
* And everything else in the buffer beyond either sb_width
213
* or sb_dirblklog (v2 dirs) should be zeroed.
228
* And everything else in the buffer beyond either sb_width,
229
* sb_dirblklog (v2 dirs), or sb_logsectsize can be zeroed.
231
* Note: contrary to the name, this routine is called for all
232
* superblocks, not just the secondary superblocks.
216
235
secondary_sb_wack(xfs_mount_t *mp, xfs_buf_t *sbuf, xfs_sb_t *sb,
235
254
(sb->sb_versionnum & XR_GOOD_SECSB_VNMASK) == 0 ||
236
255
sb->sb_versionnum < XFS_SB_VERSION_4) {
238
* check for garbage beyond the last field set by the
239
* pre-6.5 mkfs's. Don't blindly use sizeof(sb).
257
* Check for garbage beyond the last field.
240
258
* Use field addresses instead so this code will still
241
259
* work against older filesystems when the superblock
242
260
* gets rev'ed again with new fields appended.
244
if (XFS_SB_VERSION_HASDIRV2(sb))
262
if (XFS_SB_VERSION_HASLOGV2(sb))
263
size = (__psint_t)&sb->sb_logsunit
264
+ sizeof(sb->sb_logsunit) - (__psint_t)sb;
265
else if (XFS_SB_VERSION_HASSECTOR(sb))
266
size = (__psint_t)&sb->sb_logsectsize
267
+ sizeof(sb->sb_logsectsize) - (__psint_t)sb;
268
else if (XFS_SB_VERSION_HASDIRV2(sb))
245
269
size = (__psint_t)&sb->sb_dirblklog
246
270
+ sizeof(sb->sb_dirblklog) - (__psint_t)sb;
260
284
rval |= XR_AG_SB_SEC;
261
285
if (!no_modify) {
263
"zeroing unused portion of secondary superblock %d sector\n",
287
_("zeroing unused portion of %s superblock (AG #%u)\n"),
288
!i ? _("primary") : _("secondary"), i);
265
289
bzero((void *)((__psint_t)sb + size),
266
290
mp->m_sb.sb_sectsize - size);
269
"would zero unused portion of secondary superblock %d sector\n",
293
_("would zero unused portion of %s superblock (AG #%u)\n"),
294
!i ? _("primary") : _("secondary"), i);
365
394
if (sb->sb_versionnum & XR_GOOD_SECSB_VNMASK || !do_bzero) {
366
395
rval |= XR_AG_SB;
368
"bad stripe unit/width fields in superblock %d\n",
397
_("bad stripe unit/width fields in superblock %d\n"),
400
rval |= XR_AG_SB_SEC;
403
if (!XFS_SB_VERSION_HASSECTOR(sb) &&
404
(sb->sb_sectsize != BBSIZE || sb->sb_sectlog != BBSHIFT ||
405
sb->sb_logsectsize != 0 || sb->sb_logsectlog != 0)) {
407
sb->sb_sectsize = BBSIZE;
408
sb->sb_sectlog = BBSHIFT;
409
sb->sb_logsectsize = 0;
410
sb->sb_logsectlog = 0;
412
if (sb->sb_versionnum & XR_GOOD_SECSB_VNMASK || !do_bzero) {
415
_("bad log/data device sector size fields in superblock %d\n"),
371
418
rval |= XR_AG_SB_SEC;
396
443
status = verify_sb(sb, (i == 0));
398
445
if (status != XR_OK) {
399
do_warn("bad on-disk superblock %d - %s\n",
446
do_warn(_("bad on-disk superblock %d - %s\n"),
400
447
i, err_string(status));
403
450
status_sb = compare_sb(mp, sb);
405
452
if (status_sb != XR_OK) {
406
do_warn("primary and secondary superblock %d conflict - %s\n",
453
do_warn(_("primary/secondary superblock %d conflict - %s\n"),
407
454
i, err_string(status_sb));