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
)
35 if (fs_attributes
&& !xfs_sb_version_hasattr(sb
)) {
36 ASSERT(fs_attributes_allowed
);
37 xfs_sb_version_addattr(sb
);
40 if (fs_attributes2
&& !xfs_sb_version_hasattr2(sb
)) {
41 ASSERT(fs_attributes2_allowed
);
42 xfs_sb_version_addattr2(sb
);
45 if (fs_inode_nlink
&& !xfs_sb_version_hasnlink(sb
)) {
46 ASSERT(fs_inode_nlink_allowed
);
47 xfs_sb_version_addnlink(sb
);
51 * fix up the superblock version number and feature bits,
52 * turn off quota bits and flags if the filesystem doesn't
56 if (!xfs_sb_version_hasquota(sb
)) {
57 ASSERT(fs_quotas_allowed
);
58 xfs_sb_version_addquota(sb
);
62 * protect against stray bits in the quota flag field
64 if (sb
->sb_qflags
& ~XFS_MOUNT_QUOTA_ALL
) {
66 * update the incore superblock, if we're in
67 * no_modify mode, it'll never get flushed out
70 do_warn(_("bogus quota flags 0x%x set in superblock"),
71 sb
->sb_qflags
& ~XFS_MOUNT_QUOTA_ALL
);
73 sb
->sb_qflags
&= XFS_MOUNT_QUOTA_ALL
;
76 do_warn(_(", bogus flags will be cleared\n"));
78 do_warn(_(", bogus flags would be cleared\n"));
83 if (xfs_sb_version_hasquota(sb
)) {
85 vn
= sb
->sb_versionnum
;
86 vn
&= ~XFS_SB_VERSION_QUOTABIT
;
88 if (!(vn
& XFS_SB_VERSION_ALLFBITS
))
89 vn
= xfs_sb_version_toold(vn
);
92 sb
->sb_versionnum
= vn
;
96 if (!fs_aligned_inodes
&& xfs_sb_version_hasalign(sb
))
97 sb
->sb_versionnum
&= ~XFS_SB_VERSION_ALIGNBIT
;
101 * returns 0 if things are fine, 1 if we don't understand
102 * this superblock version. Sets superblock geometry-dependent
106 parse_sb_version(xfs_sb_t
*sb
)
114 fs_aligned_inodes
= 0;
115 fs_sb_feature_bits
= 0;
116 fs_ino_alignment
= 0;
117 fs_has_extflgbit
= 0;
123 * ok, check to make sure that the sb isn't newer
126 if (xfs_sb_version_hasextflgbit(sb
)) {
127 fs_has_extflgbit
= 1;
128 if (!fs_has_extflgbit_allowed
) {
131 _("This filesystem has uninitialized extent flags.\n"));
135 if (xfs_sb_version_hasshared(sb
)) {
137 if (!fs_shared_allowed
) {
139 do_warn(_("This filesystem is marked shared.\n"));
145 _("This filesystem uses feature(s) not yet supported in this release.\n"
146 "Please run a more recent version of xfs_repair.\n"));
150 if (!xfs_sb_good_version(sb
)) {
151 do_warn(_("WARNING: unknown superblock version %d\n"),
152 XFS_SB_VERSION_NUM(sb
));
154 _("This filesystem contains features not understood by this program.\n"));
158 if (XFS_SB_VERSION_NUM(sb
) >= XFS_SB_VERSION_4
) {
159 if (!fs_sb_feature_bits_allowed
) {
162 _("WARNING: you have disallowed superblock-feature-bits-allowed\n"
163 "\tbut this superblock has feature bits. The superblock\n"
164 "\twill be downgraded. This may cause loss of filesystem meta-data\n"));
167 _("WARNING: you have disallowed superblock-feature-bits-allowed\n"
168 "\tbut this superblock has feature bits. The superblock\n"
169 "\twould be downgraded. This might cause loss of filesystem\n"
173 fs_sb_feature_bits
= 1;
177 if (xfs_sb_version_hasattr(sb
)) {
178 if (!fs_attributes_allowed
) {
181 _("WARNING: you have disallowed attributes but this filesystem\n"
182 "\thas attributes. The filesystem will be downgraded and\n"
183 "\tall attributes will be removed.\n"));
186 _("WARNING: you have disallowed attributes but this filesystem\n"
187 "\thas attributes. The filesystem would be downgraded and\n"
188 "\tall attributes would be removed.\n"));
195 if (xfs_sb_version_hasattr2(sb
)) {
196 if (!fs_attributes2_allowed
) {
199 _("WARNING: you have disallowed attr2 attributes but this filesystem\n"
200 "\thas attributes. The filesystem will be downgraded and\n"
201 "\tall attr2 attributes will be removed.\n"));
204 _("WARNING: you have disallowed attr2 attributes but this filesystem\n"
205 "\thas attributes. The filesystem would be downgraded and\n"
206 "\tall attr2 attributes would be removed.\n"));
213 if (xfs_sb_version_hasnlink(sb
)) {
214 if (!fs_inode_nlink_allowed
) {
217 _("WARNING: you have disallowed version 2 inodes but this filesystem\n"
218 "\thas version 2 inodes. The filesystem will be downgraded and\n"
219 "\tall version 2 inodes will be converted to version 1 inodes.\n"
220 "\tThis may cause some hard links to files to be destroyed\n"));
223 _("WARNING: you have disallowed version 2 inodes but this filesystem\n"
224 "\thas version 2 inodes. The filesystem would be downgraded and\n"
225 "\tall version 2 inodes would be converted to version 1 inodes.\n"
226 "\tThis might cause some hard links to files to be destroyed\n"));
233 if (xfs_sb_version_hasquota(sb
)) {
234 if (!fs_quotas_allowed
) {
237 _("WARNING: you have disallowed quotas but this filesystem\n"
238 "\thas quotas. The filesystem will be downgraded and\n"
239 "\tall quota information will be removed.\n"));
242 _("WARNING: you have disallowed quotas but this filesystem\n"
243 "\thas quotas. The filesystem would be downgraded and\n"
244 "\tall quota information would be removed.\n"));
249 if (sb
->sb_uquotino
!= 0 &&
250 sb
->sb_uquotino
!= NULLFSINO
)
253 if (sb
->sb_gquotino
!= 0 &&
254 sb
->sb_gquotino
!= NULLFSINO
)
259 if (xfs_sb_version_hasalign(sb
)) {
260 if (fs_aligned_inodes_allowed
) {
261 fs_aligned_inodes
= 1;
262 fs_ino_alignment
= sb
->sb_inoalignmt
;
266 _("WARNING: you have disallowed aligned inodes but this filesystem\n"
267 "\thas aligned inodes. The filesystem will be downgraded.\n"
268 "\tThis will permanently degrade the performance of this filesystem.\n"));
271 _("WARNING: you have disallowed aligned inodes but this filesystem\n"
272 "\thas aligned inodes. The filesystem would be downgraded.\n"
273 "\tThis would permanently degrade the performance of this filesystem.\n"));
279 * calculate maximum file offset for this geometry
281 fs_max_file_offset
= 0x7fffffffffffffffLL
>> sb
->sb_blocklog
;