1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
9 #include "err_protos.h"
14 * filesystem feature global vars, set to 1 if the feature
22 int fs_aligned_inodes
;
23 int fs_sb_feature_bits
;
27 * inode chunk alignment, fsblocks
30 xfs_extlen_t fs_ino_alignment
;
33 update_sb_version(xfs_mount_t
*mp
)
39 if (fs_attributes
&& !xfs_sb_version_hasattr(sb
))
40 xfs_sb_version_addattr(sb
);
42 if (fs_attributes2
&& !xfs_sb_version_hasattr2(sb
))
43 xfs_sb_version_addattr2(sb
);
45 /* V2 inode conversion is now always going to happen */
46 if (!(sb
->sb_versionnum
& XFS_SB_VERSION_NLINKBIT
))
47 sb
->sb_versionnum
|= XFS_SB_VERSION_NLINKBIT
;
50 * fix up the superblock version number and feature bits,
51 * turn off quota bits and flags if the filesystem doesn't
55 if (!xfs_sb_version_hasquota(sb
))
56 xfs_sb_version_addquota(sb
);
59 * protect against stray bits in the quota flag field
61 if (sb
->sb_qflags
& ~XFS_MOUNT_QUOTA_ALL
) {
63 * update the incore superblock, if we're in
64 * no_modify mode, it'll never get flushed out
67 do_warn(_("bogus quota flags 0x%x set in superblock"),
68 sb
->sb_qflags
& ~XFS_MOUNT_QUOTA_ALL
);
70 sb
->sb_qflags
&= XFS_MOUNT_QUOTA_ALL
;
73 do_warn(_(", bogus flags will be cleared\n"));
75 do_warn(_(", bogus flags would be cleared\n"));
80 if (xfs_sb_version_hasquota(sb
)) {
82 sb
->sb_versionnum
&= ~XFS_SB_VERSION_QUOTABIT
;
86 if (!fs_aligned_inodes
&& xfs_sb_version_hasalign(sb
))
87 sb
->sb_versionnum
&= ~XFS_SB_VERSION_ALIGNBIT
;
91 * returns 0 if things are fine, 1 if we don't understand
92 * this superblock version. Sets superblock geometry-dependent
96 parse_sb_version(xfs_sb_t
*sb
)
102 fs_aligned_inodes
= 0;
103 fs_sb_feature_bits
= 0;
104 fs_ino_alignment
= 0;
105 fs_has_extflgbit
= 1;
110 if (sb
->sb_versionnum
& XFS_SB_VERSION_SHAREDBIT
) {
111 do_warn(_("Shared Version bit set. Not supported. Ever.\n"));
116 * ok, check to make sure that the sb isn't newer
119 if (!xfs_sb_good_version(sb
)) {
120 do_warn(_("WARNING: unknown superblock version %d\n"),
121 XFS_SB_VERSION_NUM(sb
));
123 _("This filesystem contains features not understood by this program.\n"));
127 if (XFS_SB_VERSION_NUM(sb
) >= XFS_SB_VERSION_4
)
128 fs_sb_feature_bits
= 1;
130 /* Look for V5 feature flags we don't know about */
131 if (XFS_SB_VERSION_NUM(sb
) >= XFS_SB_VERSION_5
&&
132 (xfs_sb_has_compat_feature(sb
, XFS_SB_FEAT_COMPAT_UNKNOWN
) ||
133 xfs_sb_has_ro_compat_feature(sb
, XFS_SB_FEAT_RO_COMPAT_UNKNOWN
) ||
134 xfs_sb_has_incompat_feature(sb
, XFS_SB_FEAT_INCOMPAT_UNKNOWN
))) {
136 _("Superblock has unknown compat/rocompat/incompat features (0x%x/0x%x/0x%x).\n"
137 "Using a more recent xfs_repair is recommended.\n"),
138 sb
->sb_features_compat
& XFS_SB_FEAT_COMPAT_UNKNOWN
,
139 sb
->sb_features_ro_compat
& XFS_SB_FEAT_RO_COMPAT_UNKNOWN
,
140 sb
->sb_features_incompat
& XFS_SB_FEAT_INCOMPAT_UNKNOWN
);
144 if (xfs_sb_version_hasattr(sb
))
147 if (xfs_sb_version_hasattr2(sb
))
150 if (!(sb
->sb_versionnum
& XFS_SB_VERSION_NLINKBIT
)) {
153 _("WARNING: you have a V1 inode filesystem. It will be converted to a\n"
154 "\tversion 2 inode filesystem. If you do not want this, run an older\n"
155 "\tversion of xfs_repair.\n"));
158 _("WARNING: you have a V1 inode filesystem. It would be converted to a\n"
159 "\tversion 2 inode filesystem. If you do not want this, run an older\n"
160 "\tversion of xfs_repair.\n"));
164 if (xfs_sb_version_hasquota(sb
)) {
167 if (sb
->sb_uquotino
!= 0 && sb
->sb_uquotino
!= NULLFSINO
)
170 if (sb
->sb_gquotino
!= 0 && sb
->sb_gquotino
!= NULLFSINO
)
173 if (sb
->sb_pquotino
!= 0 && sb
->sb_pquotino
!= NULLFSINO
)
177 if (xfs_sb_version_hasalign(sb
)) {
178 fs_aligned_inodes
= 1;
179 fs_ino_alignment
= sb
->sb_inoalignmt
;
183 * calculate maximum file offset for this geometry
185 fs_max_file_offset
= 0x7fffffffffffffffLL
>> sb
->sb_blocklog
;