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
24 #include "err_protos.h"
28 update_sb_version(xfs_mount_t
*mp
)
34 if (fs_attributes
&& !xfs_sb_version_hasattr(sb
))
35 xfs_sb_version_addattr(sb
);
37 if (fs_attributes2
&& !xfs_sb_version_hasattr2(sb
))
38 xfs_sb_version_addattr2(sb
);
40 /* V2 inode conversion is now always going to happen */
41 if (!(sb
->sb_versionnum
& XFS_SB_VERSION_NLINKBIT
))
42 sb
->sb_versionnum
|= XFS_SB_VERSION_NLINKBIT
;
45 * fix up the superblock version number and feature bits,
46 * turn off quota bits and flags if the filesystem doesn't
50 if (!xfs_sb_version_hasquota(sb
))
51 xfs_sb_version_addquota(sb
);
54 * protect against stray bits in the quota flag field
56 if (sb
->sb_qflags
& ~XFS_MOUNT_QUOTA_ALL
) {
58 * update the incore superblock, if we're in
59 * no_modify mode, it'll never get flushed out
62 do_warn(_("bogus quota flags 0x%x set in superblock"),
63 sb
->sb_qflags
& ~XFS_MOUNT_QUOTA_ALL
);
65 sb
->sb_qflags
&= XFS_MOUNT_QUOTA_ALL
;
68 do_warn(_(", bogus flags will be cleared\n"));
70 do_warn(_(", bogus flags would be cleared\n"));
75 if (xfs_sb_version_hasquota(sb
)) {
77 sb
->sb_versionnum
&= ~XFS_SB_VERSION_QUOTABIT
;
81 if (!fs_aligned_inodes
&& xfs_sb_version_hasalign(sb
))
82 sb
->sb_versionnum
&= ~XFS_SB_VERSION_ALIGNBIT
;
86 * returns 0 if things are fine, 1 if we don't understand
87 * this superblock version. Sets superblock geometry-dependent
91 parse_sb_version(xfs_sb_t
*sb
)
97 fs_aligned_inodes
= 0;
98 fs_sb_feature_bits
= 0;
100 fs_has_extflgbit
= 0;
105 if (sb
->sb_versionnum
& XFS_SB_VERSION_SHAREDBIT
) {
106 do_warn(_("Shared Version bit set. Not supported. Ever.\n"));
110 if (sb
->sb_versionnum
& XFS_SB_VERSION_SHAREDBIT
) {
111 do_warn(_("Shared Version bit set. Not supported. Ever.\n"));
115 if (sb
->sb_versionnum
& XFS_SB_VERSION_SHAREDBIT
) {
116 do_warn(_("Shared Version bit set. Not supported. Ever.\n"));
121 * ok, check to make sure that the sb isn't newer
124 if (xfs_sb_version_hasextflgbit(sb
))
125 fs_has_extflgbit
= 1;
127 if (!xfs_sb_good_version(sb
)) {
128 do_warn(_("WARNING: unknown superblock version %d\n"),
129 XFS_SB_VERSION_NUM(sb
));
131 _("This filesystem contains features not understood by this program.\n"));
135 if (XFS_SB_VERSION_NUM(sb
) >= XFS_SB_VERSION_4
)
136 fs_sb_feature_bits
= 1;
138 /* Look for V5 feature flags we don't know about */
139 if (XFS_SB_VERSION_NUM(sb
) >= XFS_SB_VERSION_5
&&
140 (xfs_sb_has_compat_feature(sb
, XFS_SB_FEAT_COMPAT_UNKNOWN
) ||
141 xfs_sb_has_ro_compat_feature(sb
, XFS_SB_FEAT_RO_COMPAT_UNKNOWN
) ||
142 xfs_sb_has_incompat_feature(sb
, XFS_SB_FEAT_INCOMPAT_UNKNOWN
))) {
144 _("Superblock has unknown compat/rocompat/incompat features (0x%x/0x%x/0x%x).\n"
145 "Using a more recent xfs_repair is recommended.\n"),
146 sb
->sb_features_compat
& XFS_SB_FEAT_COMPAT_UNKNOWN
,
147 sb
->sb_features_ro_compat
& XFS_SB_FEAT_RO_COMPAT_UNKNOWN
,
148 sb
->sb_features_incompat
& XFS_SB_FEAT_INCOMPAT_UNKNOWN
);
152 if (xfs_sb_version_hasattr(sb
))
155 if (xfs_sb_version_hasattr2(sb
))
158 if (!(sb
->sb_versionnum
& XFS_SB_VERSION_NLINKBIT
)) {
161 _("WARNING: you have a V1 inode filesystem. It will be converted to a\n"
162 "\tversion 2 inode filesystem. If you do not want this, run an older\n"
163 "\tversion of xfs_repair.\n"));
166 _("WARNING: you have a V1 inode filesystem. It would be converted to a\n"
167 "\tversion 2 inode filesystem. If you do not want this, run an older\n"
168 "\tversion of xfs_repair.\n"));
172 if (xfs_sb_version_hasquota(sb
)) {
175 if (sb
->sb_uquotino
!= 0 && sb
->sb_uquotino
!= NULLFSINO
)
178 if (sb
->sb_gquotino
!= 0 && sb
->sb_gquotino
!= NULLFSINO
)
181 if (sb
->sb_pquotino
!= 0 && sb
->sb_pquotino
!= NULLFSINO
)
185 if (xfs_sb_version_hasalign(sb
)) {
186 fs_aligned_inodes
= 1;
187 fs_ino_alignment
= sb
->sb_inoalignmt
;
191 * calculate maximum file offset for this geometry
193 fs_max_file_offset
= 0x7fffffffffffffffLL
>> sb
->sb_blocklog
;