Contents of /trunk/mkinitrd-magellan/busybox/util-linux/volume_id/unused_ufs.c
Parent Directory | Revision Log
Revision 984 -
(show annotations)
(download)
Sun May 30 11:32:42 2010 UTC (13 years, 11 months ago) by niro
File MIME type: text/plain
File size: 5029 byte(s)
Sun May 30 11:32:42 2010 UTC (13 years, 11 months ago) by niro
File MIME type: text/plain
File size: 5029 byte(s)
-updated to busybox-1.16.1 and enabled blkid/uuid support in default config
1 | /* |
2 | * volume_id - reads filesystem label and uuid |
3 | * |
4 | * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org> |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Lesser General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2.1 of the License, or (at your option) any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Lesser General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Lesser General Public |
17 | * License along with this library; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ |
20 | |
21 | #include "volume_id_internal.h" |
22 | |
23 | struct ufs_super_block { |
24 | uint32_t fs_link; |
25 | uint32_t fs_rlink; |
26 | uint32_t fs_sblkno; |
27 | uint32_t fs_cblkno; |
28 | uint32_t fs_iblkno; |
29 | uint32_t fs_dblkno; |
30 | uint32_t fs_cgoffset; |
31 | uint32_t fs_cgmask; |
32 | uint32_t fs_time; |
33 | uint32_t fs_size; |
34 | uint32_t fs_dsize; |
35 | uint32_t fs_ncg; |
36 | uint32_t fs_bsize; |
37 | uint32_t fs_fsize; |
38 | uint32_t fs_frag; |
39 | uint32_t fs_minfree; |
40 | uint32_t fs_rotdelay; |
41 | uint32_t fs_rps; |
42 | uint32_t fs_bmask; |
43 | uint32_t fs_fmask; |
44 | uint32_t fs_bshift; |
45 | uint32_t fs_fshift; |
46 | uint32_t fs_maxcontig; |
47 | uint32_t fs_maxbpg; |
48 | uint32_t fs_fragshift; |
49 | uint32_t fs_fsbtodb; |
50 | uint32_t fs_sbsize; |
51 | uint32_t fs_csmask; |
52 | uint32_t fs_csshift; |
53 | uint32_t fs_nindir; |
54 | uint32_t fs_inopb; |
55 | uint32_t fs_nspf; |
56 | uint32_t fs_optim; |
57 | uint32_t fs_npsect_state; |
58 | uint32_t fs_interleave; |
59 | uint32_t fs_trackskew; |
60 | uint32_t fs_id[2]; |
61 | uint32_t fs_csaddr; |
62 | uint32_t fs_cssize; |
63 | uint32_t fs_cgsize; |
64 | uint32_t fs_ntrak; |
65 | uint32_t fs_nsect; |
66 | uint32_t fs_spc; |
67 | uint32_t fs_ncyl; |
68 | uint32_t fs_cpg; |
69 | uint32_t fs_ipg; |
70 | uint32_t fs_fpg; |
71 | struct ufs_csum { |
72 | uint32_t cs_ndir; |
73 | uint32_t cs_nbfree; |
74 | uint32_t cs_nifree; |
75 | uint32_t cs_nffree; |
76 | } PACKED fs_cstotal; |
77 | int8_t fs_fmod; |
78 | int8_t fs_clean; |
79 | int8_t fs_ronly; |
80 | int8_t fs_flags; |
81 | union { |
82 | struct { |
83 | int8_t fs_fsmnt[512]; |
84 | uint32_t fs_cgrotor; |
85 | uint32_t fs_csp[31]; |
86 | uint32_t fs_maxcluster; |
87 | uint32_t fs_cpc; |
88 | uint16_t fs_opostbl[16][8]; |
89 | } PACKED fs_u1; |
90 | struct { |
91 | int8_t fs_fsmnt[468]; |
92 | uint8_t fs_volname[32]; |
93 | uint64_t fs_swuid; |
94 | int32_t fs_pad; |
95 | uint32_t fs_cgrotor; |
96 | uint32_t fs_ocsp[28]; |
97 | uint32_t fs_contigdirs; |
98 | uint32_t fs_csp; |
99 | uint32_t fs_maxcluster; |
100 | uint32_t fs_active; |
101 | int32_t fs_old_cpc; |
102 | int32_t fs_maxbsize; |
103 | int64_t fs_sparecon64[17]; |
104 | int64_t fs_sblockloc; |
105 | struct ufs2_csum_total { |
106 | uint64_t cs_ndir; |
107 | uint64_t cs_nbfree; |
108 | uint64_t cs_nifree; |
109 | uint64_t cs_nffree; |
110 | uint64_t cs_numclusters; |
111 | uint64_t cs_spare[3]; |
112 | } PACKED fs_cstotal; |
113 | struct ufs_timeval { |
114 | int32_t tv_sec; |
115 | int32_t tv_usec; |
116 | } PACKED fs_time; |
117 | int64_t fs_size; |
118 | int64_t fs_dsize; |
119 | uint64_t fs_csaddr; |
120 | int64_t fs_pendingblocks; |
121 | int32_t fs_pendinginodes; |
122 | } PACKED fs_u2; |
123 | } fs_u11; |
124 | union { |
125 | struct { |
126 | int32_t fs_sparecon[53]; |
127 | int32_t fs_reclaim; |
128 | int32_t fs_sparecon2[1]; |
129 | int32_t fs_state; |
130 | uint32_t fs_qbmask[2]; |
131 | uint32_t fs_qfmask[2]; |
132 | } PACKED fs_sun; |
133 | struct { |
134 | int32_t fs_sparecon[53]; |
135 | int32_t fs_reclaim; |
136 | int32_t fs_sparecon2[1]; |
137 | uint32_t fs_npsect; |
138 | uint32_t fs_qbmask[2]; |
139 | uint32_t fs_qfmask[2]; |
140 | } PACKED fs_sunx86; |
141 | struct { |
142 | int32_t fs_sparecon[50]; |
143 | int32_t fs_contigsumsize; |
144 | int32_t fs_maxsymlinklen; |
145 | int32_t fs_inodefmt; |
146 | uint32_t fs_maxfilesize[2]; |
147 | uint32_t fs_qbmask[2]; |
148 | uint32_t fs_qfmask[2]; |
149 | int32_t fs_state; |
150 | } PACKED fs_44; |
151 | } fs_u2; |
152 | int32_t fs_postblformat; |
153 | int32_t fs_nrpos; |
154 | int32_t fs_postbloff; |
155 | int32_t fs_rotbloff; |
156 | uint32_t fs_magic; |
157 | uint8_t fs_space[1]; |
158 | } PACKED; |
159 | |
160 | #define UFS_MAGIC 0x00011954 |
161 | #define UFS2_MAGIC 0x19540119 |
162 | #define UFS_MAGIC_FEA 0x00195612 |
163 | #define UFS_MAGIC_LFN 0x00095014 |
164 | |
165 | int FAST_FUNC volume_id_probe_ufs(struct volume_id *id, uint64_t off) |
166 | { |
167 | static const short offsets[] = { 0, 8, 64, 256 }; |
168 | |
169 | uint32_t magic; |
170 | unsigned i; |
171 | struct ufs_super_block *ufs; |
172 | |
173 | dbg("probing at offset 0x%llx", (unsigned long long) off); |
174 | |
175 | for (i = 0; i < ARRAY_SIZE(offsets); i++) { |
176 | ufs = volume_id_get_buffer(id, off + (offsets[i] * 0x400), 0x800); |
177 | if (ufs == NULL) |
178 | return -1; |
179 | |
180 | dbg("offset 0x%x", offsets[i] * 0x400); |
181 | magic = ufs->fs_magic; |
182 | if ((magic == cpu_to_be32(UFS_MAGIC)) |
183 | || (magic == cpu_to_be32(UFS2_MAGIC)) |
184 | || (magic == cpu_to_be32(UFS_MAGIC_FEA)) |
185 | || (magic == cpu_to_be32(UFS_MAGIC_LFN)) |
186 | ) { |
187 | dbg("magic 0x%08x(be)", magic); |
188 | goto found; |
189 | } |
190 | if ((magic == cpu_to_le32(UFS_MAGIC)) |
191 | || (magic == cpu_to_le32(UFS2_MAGIC)) |
192 | || (magic == cpu_to_le32(UFS_MAGIC_FEA)) |
193 | || (magic == cpu_to_le32(UFS_MAGIC_LFN)) |
194 | ) { |
195 | dbg("magic 0x%08x(le)", magic); |
196 | goto found; |
197 | } |
198 | } |
199 | return -1; |
200 | |
201 | found: |
202 | // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); |
203 | // id->type = "ufs"; |
204 | |
205 | return 0; |
206 | } |