summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreehugger Robot2018-06-20 14:06:59 -0500
committerGerrit Code Review2018-06-20 14:06:59 -0500
commitc50fe3dc542e6970e27e38118398a04d1a0abc29 (patch)
tree40aa336bb968a6d2f66e555cadbc09593ca22f31 /toolbox
parent81101cb216c9009a60edf4e3fa6709b0c6437f2e (diff)
parent76858a06d094dde07f1588a5e74d12f4c5c54de8 (diff)
downloadplatform-system-core-c50fe3dc542e6970e27e38118398a04d1a0abc29.tar.gz
platform-system-core-c50fe3dc542e6970e27e38118398a04d1a0abc29.tar.xz
platform-system-core-c50fe3dc542e6970e27e38118398a04d1a0abc29.zip
Merge "newfs_msdos: switch to external/newfs_msdos."
Diffstat (limited to 'toolbox')
-rw-r--r--toolbox/Android.bp9
-rw-r--r--toolbox/MODULE_LICENSE_APACHE2 (renamed from toolbox/MODULE_LICENSE_BSD)0
-rw-r--r--toolbox/NOTICE973
-rw-r--r--toolbox/getprop.cpp30
-rw-r--r--toolbox/newfs_msdos.c1108
-rw-r--r--toolbox/tools.h1
6 files changed, 16 insertions, 2105 deletions
diff --git a/toolbox/Android.bp b/toolbox/Android.bp
index f12c810cd..fc5170537 100644
--- a/toolbox/Android.bp
+++ b/toolbox/Android.bp
@@ -26,7 +26,6 @@ cc_defaults {
26 "toolbox.c", 26 "toolbox.c",
27 "getevent.c", 27 "getevent.c",
28 "getprop.cpp", 28 "getprop.cpp",
29 "newfs_msdos.c",
30 ], 29 ],
31 generated_headers: [ 30 generated_headers: [
32 "toolbox_input_labels", 31 "toolbox_input_labels",
@@ -39,7 +38,6 @@ cc_defaults {
39 symlinks: [ 38 symlinks: [
40 "getevent", 39 "getevent",
41 "getprop", 40 "getprop",
42 "newfs_msdos",
43 ], 41 ],
44} 42}
45 43
@@ -62,10 +60,3 @@ cc_binary {
62 defaults: ["toolbox_defaults"], 60 defaults: ["toolbox_defaults"],
63 srcs: ["r.c"], 61 srcs: ["r.c"],
64} 62}
65
66cc_binary_host {
67 name: "newfs_msdos",
68 defaults: ["toolbox_defaults"],
69 srcs: ["newfs_msdos.c"],
70 cflags: ["-Dnewfs_msdos_main=main"]
71}
diff --git a/toolbox/MODULE_LICENSE_BSD b/toolbox/MODULE_LICENSE_APACHE2
index e69de29bb..e69de29bb 100644
--- a/toolbox/MODULE_LICENSE_BSD
+++ b/toolbox/MODULE_LICENSE_APACHE2
diff --git a/toolbox/NOTICE b/toolbox/NOTICE
index e9ab58dd8..8e8a91ca1 100644
--- a/toolbox/NOTICE
+++ b/toolbox/NOTICE
@@ -1,4 +1,4 @@
1Copyright (C) 2010 The Android Open Source Project 1Copyright (C) 2017 The Android Open Source Project
2 2
3Licensed under the Apache License, Version 2.0 (the "License"); 3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License. 4you may not use this file except in compliance with the License.
@@ -14,974 +14,3 @@ limitations under the License.
14 14
15------------------------------------------------------------------- 15-------------------------------------------------------------------
16 16
17Copyright (C) 2014, The Android Open Source Project
18All rights reserved.
19
20Redistribution and use in source and binary forms, with or without
21modification, are permitted provided that the following conditions
22are met:
23 * Redistributions of source code must retain the above copyright
24 notice, this list of conditions and the following disclaimer.
25 * Redistributions in binary form must reproduce the above copyright
26 notice, this list of conditions and the following disclaimer in
27 the documentation and/or other materials provided with the
28 distribution.
29
30THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
33FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
34COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
35INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
36BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
37OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
38AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
39OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
40OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41SUCH DAMAGE.
42
43-------------------------------------------------------------------
44
45Copyright (c) 1987, 1993
46 The Regents of the University of California. All rights reserved.
47
48Redistribution and use in source and binary forms, with or without
49modification, are permitted provided that the following conditions
50are met:
511. Redistributions of source code must retain the above copyright
52 notice, this list of conditions and the following disclaimer.
532. Redistributions in binary form must reproduce the above copyright
54 notice, this list of conditions and the following disclaimer in the
55 documentation and/or other materials provided with the distribution.
563. Neither the name of the University nor the names of its contributors
57 may be used to endorse or promote products derived from this software
58 without specific prior written permission.
59
60THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70SUCH DAMAGE.
71
72-------------------------------------------------------------------
73
74Copyright (c) 1987, 1993, 1994
75 The Regents of the University of California. All rights reserved.
76
77Redistribution and use in source and binary forms, with or without
78modification, are permitted provided that the following conditions
79are met:
801. Redistributions of source code must retain the above copyright
81 notice, this list of conditions and the following disclaimer.
822. Redistributions in binary form must reproduce the above copyright
83 notice, this list of conditions and the following disclaimer in the
84 documentation and/or other materials provided with the distribution.
853. Neither the name of the University nor the names of its contributors
86 may be used to endorse or promote products derived from this software
87 without specific prior written permission.
88
89THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
90ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
91IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
92ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
93FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
94DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
95OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
96HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
97LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
98OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
99SUCH DAMAGE.
100
101-------------------------------------------------------------------
102
103Copyright (c) 1988, 1993
104 The Regents of the University of California. All rights reserved.
105
106This code is derived from software contributed to Berkeley by
107Jeffrey Mogul.
108
109Redistribution and use in source and binary forms, with or without
110modification, are permitted provided that the following conditions
111are met:
1121. Redistributions of source code must retain the above copyright
113 notice, this list of conditions and the following disclaimer.
1142. Redistributions in binary form must reproduce the above copyright
115 notice, this list of conditions and the following disclaimer in the
116 documentation and/or other materials provided with the distribution.
1173. Neither the name of the University nor the names of its contributors
118 may be used to endorse or promote products derived from this software
119 without specific prior written permission.
120
121THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
122ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
123IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
124ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
125FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
126DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
127OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
128HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
129LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
130OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
131SUCH DAMAGE.
132
133-------------------------------------------------------------------
134
135Copyright (c) 1988, 1993, 1994
136 The Regents of the University of California. All rights reserved.
137
138Redistribution and use in source and binary forms, with or without
139modification, are permitted provided that the following conditions
140are met:
1411. Redistributions of source code must retain the above copyright
142 notice, this list of conditions and the following disclaimer.
1432. Redistributions in binary form must reproduce the above copyright
144 notice, this list of conditions and the following disclaimer in the
145 documentation and/or other materials provided with the distribution.
1463. Neither the name of the University nor the names of its contributors
147 may be used to endorse or promote products derived from this software
148 without specific prior written permission.
149
150THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
151ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
152IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
153ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
154FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
155DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
156OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
157HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
158LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
159OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
160SUCH DAMAGE.
161
162-------------------------------------------------------------------
163
164Copyright (c) 1988, 1993, 1994
165 The Regents of the University of California. All rights reserved.
166
167This code is derived from software contributed to Berkeley by
168David Hitz of Auspex Systems Inc.
169
170Redistribution and use in source and binary forms, with or without
171modification, are permitted provided that the following conditions
172are met:
1731. Redistributions of source code must retain the above copyright
174 notice, this list of conditions and the following disclaimer.
1752. Redistributions in binary form must reproduce the above copyright
176 notice, this list of conditions and the following disclaimer in the
177 documentation and/or other materials provided with the distribution.
1783. Neither the name of the University nor the names of its contributors
179 may be used to endorse or promote products derived from this software
180 without specific prior written permission.
181
182THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
183ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
184IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
185ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
186FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
187DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
188OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
189HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
190LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
191OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
192SUCH DAMAGE.
193
194-------------------------------------------------------------------
195
196Copyright (c) 1988, 1993, 1994, 2003
197 The Regents of the University of California. All rights reserved.
198
199Redistribution and use in source and binary forms, with or without
200modification, are permitted provided that the following conditions
201are met:
2021. Redistributions of source code must retain the above copyright
203 notice, this list of conditions and the following disclaimer.
2042. Redistributions in binary form must reproduce the above copyright
205 notice, this list of conditions and the following disclaimer in the
206 documentation and/or other materials provided with the distribution.
2073. Neither the name of the University nor the names of its contributors
208 may be used to endorse or promote products derived from this software
209 without specific prior written permission.
210
211THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
212ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
213IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
214ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
215FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
216DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
217OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
218HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
219LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
220OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
221SUCH DAMAGE.
222
223-------------------------------------------------------------------
224
225Copyright (c) 1989, 1993
226 The Regents of the University of California. All rights reserved.
227
228Redistribution and use in source and binary forms, with or without
229modification, are permitted provided that the following conditions
230are met:
2311. Redistributions of source code must retain the above copyright
232 notice, this list of conditions and the following disclaimer.
2332. Redistributions in binary form must reproduce the above copyright
234 notice, this list of conditions and the following disclaimer in the
235 documentation and/or other materials provided with the distribution.
2363. Neither the name of the University nor the names of its contributors
237 may be used to endorse or promote products derived from this software
238 without specific prior written permission.
239
240THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
241ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
242IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
243ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
244FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
245DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
246OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
247HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
248LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
249OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
250SUCH DAMAGE.
251
252-------------------------------------------------------------------
253
254Copyright (c) 1989, 1993
255 The Regents of the University of California. All rights reserved.
256
257This code is derived from software contributed to Berkeley by
258Kevin Fall.
259
260Redistribution and use in source and binary forms, with or without
261modification, are permitted provided that the following conditions
262are met:
2631. Redistributions of source code must retain the above copyright
264 notice, this list of conditions and the following disclaimer.
2652. Redistributions in binary form must reproduce the above copyright
266 notice, this list of conditions and the following disclaimer in the
267 documentation and/or other materials provided with the distribution.
2683. Neither the name of the University nor the names of its contributors
269 may be used to endorse or promote products derived from this software
270 without specific prior written permission.
271
272THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
273ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
274IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
275ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
276FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
277DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
278OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
279HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
280LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
281OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
282SUCH DAMAGE.
283
284-------------------------------------------------------------------
285
286Copyright (c) 1989, 1993, 1994
287 The Regents of the University of California. All rights reserved.
288
289This code is derived from software contributed to Berkeley by
290Chris Newcomb.
291
292Redistribution and use in source and binary forms, with or without
293modification, are permitted provided that the following conditions
294are met:
2951. Redistributions of source code must retain the above copyright
296 notice, this list of conditions and the following disclaimer.
2972. Redistributions in binary form must reproduce the above copyright
298 notice, this list of conditions and the following disclaimer in the
299 documentation and/or other materials provided with the distribution.
3003. Neither the name of the University nor the names of its contributors
301 may be used to endorse or promote products derived from this software
302 without specific prior written permission.
303
304THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
305ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
306IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
307ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
308FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
309DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
310OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
312LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
313OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
314SUCH DAMAGE.
315
316-------------------------------------------------------------------
317
318Copyright (c) 1989, 1993, 1994
319 The Regents of the University of California. All rights reserved.
320
321This code is derived from software contributed to Berkeley by
322Ken Smith of The State University of New York at Buffalo.
323
324Redistribution and use in source and binary forms, with or without
325modification, are permitted provided that the following conditions
326are met:
3271. Redistributions of source code must retain the above copyright
328 notice, this list of conditions and the following disclaimer.
3292. Redistributions in binary form must reproduce the above copyright
330 notice, this list of conditions and the following disclaimer in the
331 documentation and/or other materials provided with the distribution.
3323. Neither the name of the University nor the names of its contributors
333 may be used to endorse or promote products derived from this software
334 without specific prior written permission.
335
336THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
337ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
338IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
339ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
340FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
341DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
342OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
343HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
344LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
345OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
346SUCH DAMAGE.
347
348-------------------------------------------------------------------
349
350Copyright (c) 1990, 1993, 1994, 2003
351 The Regents of the University of California. All rights reserved.
352
353Redistribution and use in source and binary forms, with or without
354modification, are permitted provided that the following conditions
355are met:
3561. Redistributions of source code must retain the above copyright
357 notice, this list of conditions and the following disclaimer.
3582. Redistributions in binary form must reproduce the above copyright
359 notice, this list of conditions and the following disclaimer in the
360 documentation and/or other materials provided with the distribution.
3613. Neither the name of the University nor the names of its contributors
362 may be used to endorse or promote products derived from this software
363 without specific prior written permission.
364
365THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
366ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
367IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
368ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
369FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
370DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
371OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
372HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
373LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
374OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
375SUCH DAMAGE.
376
377-------------------------------------------------------------------
378
379Copyright (c) 1991, 1993
380 The Regents of the University of California. All rights reserved.
381
382Redistribution and use in source and binary forms, with or without
383modification, are permitted provided that the following conditions
384are met:
3851. Redistributions of source code must retain the above copyright
386 notice, this list of conditions and the following disclaimer.
3872. Redistributions in binary form must reproduce the above copyright
388 notice, this list of conditions and the following disclaimer in the
389 documentation and/or other materials provided with the distribution.
3903. Neither the name of the University nor the names of its contributors
391 may be used to endorse or promote products derived from this software
392 without specific prior written permission.
393
394THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
395ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
396IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
397ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
398FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
399DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
400OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
401HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
402LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
403OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
404SUCH DAMAGE.
405
406-------------------------------------------------------------------
407
408Copyright (c) 1991, 1993, 1994
409 The Regents of the University of California. All rights reserved.
410
411Redistribution and use in source and binary forms, with or without
412modification, are permitted provided that the following conditions
413are met:
4141. Redistributions of source code must retain the above copyright
415 notice, this list of conditions and the following disclaimer.
4162. Redistributions in binary form must reproduce the above copyright
417 notice, this list of conditions and the following disclaimer in the
418 documentation and/or other materials provided with the distribution.
4193. Neither the name of the University nor the names of its contributors
420 may be used to endorse or promote products derived from this software
421 without specific prior written permission.
422
423THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
424ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
425IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
426ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
427FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
428DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
429OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
430HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
431LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
432OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
433SUCH DAMAGE.
434
435-------------------------------------------------------------------
436
437Copyright (c) 1991, 1993, 1994
438 The Regents of the University of California. All rights reserved.
439
440This code is derived from software contributed to Berkeley by
441Keith Muller of the University of California, San Diego and Lance
442Visser of Convex Computer Corporation.
443
444Redistribution and use in source and binary forms, with or without
445modification, are permitted provided that the following conditions
446are met:
4471. Redistributions of source code must retain the above copyright
448 notice, this list of conditions and the following disclaimer.
4492. Redistributions in binary form must reproduce the above copyright
450 notice, this list of conditions and the following disclaimer in the
451 documentation and/or other materials provided with the distribution.
4523. Neither the name of the University nor the names of its contributors
453 may be used to endorse or promote products derived from this software
454 without specific prior written permission.
455
456THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
457ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
458IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
459ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
460FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
461DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
462OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
463HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
464LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
465OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
466SUCH DAMAGE.
467
468-------------------------------------------------------------------
469
470Copyright (c) 1992, 1993, 1994
471 The Regents of the University of California. All rights reserved.
472
473Redistribution and use in source and binary forms, with or without
474modification, are permitted provided that the following conditions
475are met:
4761. Redistributions of source code must retain the above copyright
477 notice, this list of conditions and the following disclaimer.
4782. Redistributions in binary form must reproduce the above copyright
479 notice, this list of conditions and the following disclaimer in the
480 documentation and/or other materials provided with the distribution.
4813. Neither the name of the University nor the names of its contributors
482 may be used to endorse or promote products derived from this software
483 without specific prior written permission.
484
485THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
486ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
487IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
488ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
489FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
490DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
491OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
492HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
493LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
494OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
495SUCH DAMAGE.
496
497-------------------------------------------------------------------
498
499Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
500All rights reserved.
501
502This code is derived from software contributed to The NetBSD Foundation
503by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
504NASA Ames Research Center, by Luke Mewburn and by Tomas Svensson.
505
506Redistribution and use in source and binary forms, with or without
507modification, are permitted provided that the following conditions
508are met:
5091. Redistributions of source code must retain the above copyright
510 notice, this list of conditions and the following disclaimer.
5112. Redistributions in binary form must reproduce the above copyright
512 notice, this list of conditions and the following disclaimer in the
513 documentation and/or other materials provided with the distribution.
514
515THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
516``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
517TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
518PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
519BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
520CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
521SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
522INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
523CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
524ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
525POSSIBILITY OF SUCH DAMAGE.
526
527-------------------------------------------------------------------
528
529Copyright (c) 1998 Robert Nordier
530All rights reserved.
531
532Redistribution and use in source and binary forms, with or without
533modification, are permitted provided that the following conditions
534are met:
5351. Redistributions of source code must retain the above copyright
536 notice, this list of conditions and the following disclaimer.
5372. Redistributions in binary form must reproduce the above copyright
538 notice, this list of conditions and the following disclaimer in
539 the documentation and/or other materials provided with the
540 distribution.
541
542THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
543OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
544WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
545ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY
546DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
547DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
548GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
549INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
550IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
551OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
552IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
553
554-------------------------------------------------------------------
555
556Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
557All rights reserved.
558
559Redistribution and use in source and binary forms, with or without
560modification, are permitted provided that the following conditions
561are met:
5621. Redistributions of source code must retain the above copyright
563 notice, this list of conditions and the following disclaimer.
5642. Redistributions in binary form must reproduce the above copyright
565 notice, this list of conditions and the following disclaimer in the
566 documentation and/or other materials provided with the distribution.
567
568THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
569ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
570IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
571ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
572FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
573DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
574OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
575HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
576LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
577OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
578SUCH DAMAGE.
579
580-------------------------------------------------------------------
581
582Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
583Copyright (C) 2008 Gabor Kovesdan <gabor@FreeBSD.org>
584All rights reserved.
585
586Redistribution and use in source and binary forms, with or without
587modification, are permitted provided that the following conditions
588are met:
5891. Redistributions of source code must retain the above copyright
590 notice, this list of conditions and the following disclaimer.
5912. Redistributions in binary form must reproduce the above copyright
592 notice, this list of conditions and the following disclaimer in the
593 documentation and/or other materials provided with the distribution.
594
595THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
596ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
597IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
598ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
599FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
600DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
601OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
602HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
603LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
604OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
605SUCH DAMAGE.
606
607-------------------------------------------------------------------
608
609Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
610Copyright (C) 2008-2009 Gabor Kovesdan <gabor@FreeBSD.org>
611All rights reserved.
612
613Redistribution and use in source and binary forms, with or without
614modification, are permitted provided that the following conditions
615are met:
6161. Redistributions of source code must retain the above copyright
617 notice, this list of conditions and the following disclaimer.
6182. Redistributions in binary form must reproduce the above copyright
619 notice, this list of conditions and the following disclaimer in the
620 documentation and/or other materials provided with the distribution.
621
622THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
623ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
624IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
625ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
626FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
627DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
628OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
629HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
630LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
631OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
632SUCH DAMAGE.
633
634-------------------------------------------------------------------
635
636Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
637Copyright (C) 2008-2010 Gabor Kovesdan <gabor@FreeBSD.org>
638All rights reserved.
639
640Redistribution and use in source and binary forms, with or without
641modification, are permitted provided that the following conditions
642are met:
6431. Redistributions of source code must retain the above copyright
644 notice, this list of conditions and the following disclaimer.
6452. Redistributions in binary form must reproduce the above copyright
646 notice, this list of conditions and the following disclaimer in the
647 documentation and/or other materials provided with the distribution.
648
649THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
650ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
651IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
652ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
653FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
654DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
655OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
656HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
657LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
658OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
659SUCH DAMAGE.
660
661-------------------------------------------------------------------
662
663Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
664Copyright (C) 2008-2010 Gabor Kovesdan <gabor@FreeBSD.org>
665Copyright (C) 2010 Dimitry Andric <dimitry@andric.com>
666All rights reserved.
667
668Redistribution and use in source and binary forms, with or without
669modification, are permitted provided that the following conditions
670are met:
6711. Redistributions of source code must retain the above copyright
672 notice, this list of conditions and the following disclaimer.
6732. Redistributions in binary form must reproduce the above copyright
674 notice, this list of conditions and the following disclaimer in the
675 documentation and/or other materials provided with the distribution.
676
677THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
678ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
679IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
680ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
681FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
682DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
683OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
684HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
685LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
686OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
687SUCH DAMAGE.
688
689-------------------------------------------------------------------
690
691Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
692Copyright (c) 2008-2009 Gabor Kovesdan <gabor@FreeBSD.org>
693All rights reserved.
694
695Redistribution and use in source and binary forms, with or without
696modification, are permitted provided that the following conditions
697are met:
6981. Redistributions of source code must retain the above copyright
699 notice, this list of conditions and the following disclaimer.
7002. Redistributions in binary form must reproduce the above copyright
701 notice, this list of conditions and the following disclaimer in the
702 documentation and/or other materials provided with the distribution.
703
704THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
705ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
706IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
707ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
708FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
709DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
710OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
711HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
712LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
713OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
714SUCH DAMAGE.
715
716-------------------------------------------------------------------
717
718Copyright (c) 2001-2002,2004 The NetBSD Foundation, Inc.
719All rights reserved.
720
721This code is derived from software contributed to The NetBSD Foundation
722by Luke Mewburn.
723
724Redistribution and use in source and binary forms, with or without
725modification, are permitted provided that the following conditions
726are met:
7271. Redistributions of source code must retain the above copyright
728 notice, this list of conditions and the following disclaimer.
7292. Redistributions in binary form must reproduce the above copyright
730 notice, this list of conditions and the following disclaimer in the
731 documentation and/or other materials provided with the distribution.
732
733THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
734``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
735TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
736PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
737BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
738CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
739SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
740INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
741CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
742ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
743POSSIBILITY OF SUCH DAMAGE.
744
745-------------------------------------------------------------------
746
747Copyright (c) 2007 The NetBSD Foundation, Inc.
748All rights reserved.
749
750This code is derived from software contributed to The NetBSD Foundation
751by Luke Mewburn.
752
753Redistribution and use in source and binary forms, with or without
754modification, are permitted provided that the following conditions
755are met:
7561. Redistributions of source code must retain the above copyright
757 notice, this list of conditions and the following disclaimer.
7582. Redistributions in binary form must reproduce the above copyright
759 notice, this list of conditions and the following disclaimer in the
760 documentation and/or other materials provided with the distribution.
761
762THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
763``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
764TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
765PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
766BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
767CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
768SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
769INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
770CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
771ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
772POSSIBILITY OF SUCH DAMAGE.
773
774-------------------------------------------------------------------
775
776Copyright (c) 2008, The Android Open Source Project
777All rights reserved.
778
779Redistribution and use in source and binary forms, with or without
780modification, are permitted provided that the following conditions
781are met:
782 * Redistributions of source code must retain the above copyright
783 notice, this list of conditions and the following disclaimer.
784 * Redistributions in binary form must reproduce the above copyright
785 notice, this list of conditions and the following disclaimer in
786 the documentation and/or other materials provided with the
787 distribution.
788 * Neither the name of Google, Inc. nor the names of its contributors
789 may be used to endorse or promote products derived from this
790 software without specific prior written permission.
791
792THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
793"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
794LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
795FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
796COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
797INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
798BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
799OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
800AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
801OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
802OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
803SUCH DAMAGE.
804
805-------------------------------------------------------------------
806
807Copyright (c) 2009, The Android Open Source Project
808All rights reserved.
809
810Redistribution and use in source and binary forms, with or without
811modification, are permitted provided that the following conditions
812are met:
813 * Redistributions of source code must retain the above copyright
814 notice, this list of conditions and the following disclaimer.
815 * Redistributions in binary form must reproduce the above copyright
816 notice, this list of conditions and the following disclaimer in
817 the documentation and/or other materials provided with the
818 distribution.
819 * Neither the name of Google, Inc. nor the names of its contributors
820 may be used to endorse or promote products derived from this
821 software without specific prior written permission.
822
823THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
824"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
825LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
826FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
827COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
828INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
829BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
830OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
831AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
832OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
833OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
834SUCH DAMAGE.
835
836-------------------------------------------------------------------
837
838Copyright (c) 2010 The NetBSD Foundation, Inc.
839All rights reserved.
840
841Redistribution and use in source and binary forms, with or without
842modification, are permitted provided that the following conditions
843are met:
8441. Redistributions of source code must retain the above copyright
845 notice, this list of conditions and the following disclaimer.
8462. Redistributions in binary form must reproduce the above copyright
847 notice, this list of conditions and the following disclaimer in the
848 documentation and/or other materials provided with the distribution.
849
850THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
851``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
852TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
853PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
854BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
855CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
856SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
857INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
858CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
859ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
860POSSIBILITY OF SUCH DAMAGE.
861
862-------------------------------------------------------------------
863
864Copyright (c) 2010, The Android Open Source Project
865All rights reserved.
866
867Redistribution and use in source and binary forms, with or without
868modification, are permitted provided that the following conditions
869are met:
870 * Redistributions of source code must retain the above copyright
871 notice, this list of conditions and the following disclaimer.
872 * Redistributions in binary form must reproduce the above copyright
873 notice, this list of conditions and the following disclaimer in
874 the documentation and/or other materials provided with the
875 distribution.
876 * Neither the name of Google, Inc. nor the names of its contributors
877 may be used to endorse or promote products derived from this
878 software without specific prior written permission.
879
880THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
881"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
882LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
883FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
884COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
885INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
886BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
887OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
888AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
889OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
890OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
891SUCH DAMAGE.
892
893-------------------------------------------------------------------
894
895Copyright (c) 2012, The Android Open Source Project
896All rights reserved.
897
898Redistribution and use in source and binary forms, with or without
899modification, are permitted provided that the following conditions
900are met:
901 * Redistributions of source code must retain the above copyright
902 notice, this list of conditions and the following disclaimer.
903 * Redistributions in binary form must reproduce the above copyright
904 notice, this list of conditions and the following disclaimer in
905 the documentation and/or other materials provided with the
906 distribution.
907 * Neither the name of Google, Inc. nor the names of its contributors
908 may be used to endorse or promote products derived from this
909 software without specific prior written permission.
910
911THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
912"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
913LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
914FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
915COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
916INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
917BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
918OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
919AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
920OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
921OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
922SUCH DAMAGE.
923
924-------------------------------------------------------------------
925
926Copyright (c) 2013, The Android Open Source Project
927All rights reserved.
928
929Redistribution and use in source and binary forms, with or without
930modification, are permitted provided that the following conditions
931are met:
932 * Redistributions of source code must retain the above copyright
933 notice, this list of conditions and the following disclaimer.
934 * Redistributions in binary form must reproduce the above copyright
935 notice, this list of conditions and the following disclaimer in
936 the documentation and/or other materials provided with the
937 distribution.
938 * Neither the name of Google, Inc. nor the names of its contributors
939 may be used to endorse or promote products derived from this
940 software without specific prior written permission.
941
942THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
943"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
944LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
945FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
946COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
947INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
948BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
949OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
950AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
951OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
952OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
953SUCH DAMAGE.
954
955-------------------------------------------------------------------
956
957Copyright (c) 2014, The Android Open Source Project
958All rights reserved.
959
960Redistribution and use in source and binary forms, with or without
961modification, are permitted provided that the following conditions
962are met:
963 * Redistributions of source code must retain the above copyright
964 notice, this list of conditions and the following disclaimer.
965 * Redistributions in binary form must reproduce the above copyright
966 notice, this list of conditions and the following disclaimer in
967 the documentation and/or other materials provided with the
968 distribution.
969 * Neither the name of Google, Inc. nor the names of its contributors
970 may be used to endorse or promote products derived from this
971 software without specific prior written permission.
972
973THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
974"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
975LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
976FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
977COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
978INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
979BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
980OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
981AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
982OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
983OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
984SUCH DAMAGE.
985
986-------------------------------------------------------------------
987
diff --git a/toolbox/getprop.cpp b/toolbox/getprop.cpp
index 9e324a06f..ca345cb07 100644
--- a/toolbox/getprop.cpp
+++ b/toolbox/getprop.cpp
@@ -1,18 +1,18 @@
1// 1/*
2// Copyright (C) 2017 The Android Open Source Project 2 * Copyright (C) 2017 The Android Open Source Project
3// 3 *
4// Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at 6 * You may obtain a copy of the License at
7// 7 *
8// http://www.apache.org/licenses/LICENSE-2.0 8 * http://www.apache.org/licenses/LICENSE-2.0
9// 9 *
10// Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS, 11 * distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14// limitations under the License. 14 * limitations under the License.
15// 15 */
16 16
17#include <getopt.h> 17#include <getopt.h>
18#include <sys/system_properties.h> 18#include <sys/system_properties.h>
diff --git a/toolbox/newfs_msdos.c b/toolbox/newfs_msdos.c
deleted file mode 100644
index 5fc8b0242..000000000
--- a/toolbox/newfs_msdos.c
+++ /dev/null
@@ -1,1108 +0,0 @@
1/*
2 * Copyright (c) 1998 Robert Nordier
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
23 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
25 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef lint
29static const char rcsid[] =
30 "$FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.33 2009/04/11 14:56:29 ed Exp $";
31#endif /* not lint */
32
33#include <sys/param.h>
34
35#ifdef __APPLE__
36#elif defined(ANDROID)
37#include <linux/fs.h>
38#include <linux/hdreg.h>
39#include <stdarg.h>
40#include <sys/ioctl.h>
41#else
42#include <sys/fdcio.h>
43#include <sys/disk.h>
44#include <sys/disklabel.h>
45#include <sys/mount.h>
46#endif
47
48#include <sys/stat.h>
49#include <sys/time.h>
50
51#include <ctype.h>
52#include <err.h>
53#include <errno.h>
54#include <fcntl.h>
55#include <inttypes.h>
56#include <paths.h>
57#include <stdio.h>
58#include <stdlib.h>
59#include <string.h>
60#include <time.h>
61#include <unistd.h>
62
63#ifndef __unused
64#define __unused __attribute__((__unused__))
65#endif
66
67#define MAXU16 0xffff /* maximum unsigned 16-bit quantity */
68#define BPN 4 /* bits per nibble */
69#define NPB 2 /* nibbles per byte */
70
71#define DOSMAGIC 0xaa55 /* DOS magic number */
72#define MINBPS 512 /* minimum bytes per sector */
73#define MAXSPC 128 /* maximum sectors per cluster */
74#define MAXNFT 16 /* maximum number of FATs */
75#define DEFBLK 4096 /* default block size */
76#define DEFBLK16 2048 /* default block size FAT16 */
77#define DEFRDE 512 /* default root directory entries */
78#define RESFTE 2 /* reserved FAT entries */
79#define MINCLS12 1 /* minimum FAT12 clusters */
80#define MINCLS16 0x1000 /* minimum FAT16 clusters */
81#define MINCLS32 2 /* minimum FAT32 clusters */
82#define MAXCLS12 0xfed /* maximum FAT12 clusters */
83#define MAXCLS16 0xfff5 /* maximum FAT16 clusters */
84#define MAXCLS32 0xffffff5 /* maximum FAT32 clusters */
85
86#define mincls(fat) ((fat) == 12 ? MINCLS12 : \
87 (fat) == 16 ? MINCLS16 : \
88 MINCLS32)
89
90#define maxcls(fat) ((fat) == 12 ? MAXCLS12 : \
91 (fat) == 16 ? MAXCLS16 : \
92 MAXCLS32)
93
94#define mk1(p, x) \
95 (p) = (u_int8_t)(x)
96
97#define mk2(p, x) \
98 (p)[0] = (u_int8_t)(x), \
99 (p)[1] = (u_int8_t)((x) >> 010)
100
101#define mk4(p, x) \
102 (p)[0] = (u_int8_t)(x), \
103 (p)[1] = (u_int8_t)((x) >> 010), \
104 (p)[2] = (u_int8_t)((x) >> 020), \
105 (p)[3] = (u_int8_t)((x) >> 030)
106
107#define argto1(arg, lo, msg) argtou(arg, lo, 0xff, msg)
108#define argto2(arg, lo, msg) argtou(arg, lo, 0xffff, msg)
109#define argto4(arg, lo, msg) argtou(arg, lo, 0xffffffff, msg)
110#define argtox(arg, lo, msg) argtou(arg, lo, UINT_MAX, msg)
111
112struct bs {
113 u_int8_t jmp[3]; /* bootstrap entry point */
114 u_int8_t oem[8]; /* OEM name and version */
115};
116
117struct bsbpb {
118 u_int8_t bps[2]; /* bytes per sector */
119 u_int8_t spc; /* sectors per cluster */
120 u_int8_t res[2]; /* reserved sectors */
121 u_int8_t nft; /* number of FATs */
122 u_int8_t rde[2]; /* root directory entries */
123 u_int8_t sec[2]; /* total sectors */
124 u_int8_t mid; /* media descriptor */
125 u_int8_t spf[2]; /* sectors per FAT */
126 u_int8_t spt[2]; /* sectors per track */
127 u_int8_t hds[2]; /* drive heads */
128 u_int8_t hid[4]; /* hidden sectors */
129 u_int8_t bsec[4]; /* big total sectors */
130};
131
132struct bsxbpb {
133 u_int8_t bspf[4]; /* big sectors per FAT */
134 u_int8_t xflg[2]; /* FAT control flags */
135 u_int8_t vers[2]; /* file system version */
136 u_int8_t rdcl[4]; /* root directory start cluster */
137 u_int8_t infs[2]; /* file system info sector */
138 u_int8_t bkbs[2]; /* backup boot sector */
139 u_int8_t rsvd[12]; /* reserved */
140};
141
142struct bsx {
143 u_int8_t drv; /* drive number */
144 u_int8_t rsvd; /* reserved */
145 u_int8_t sig; /* extended boot signature */
146 u_int8_t volid[4]; /* volume ID number */
147 u_int8_t label[11]; /* volume label */
148 u_int8_t type[8]; /* file system type */
149};
150
151struct de {
152 u_int8_t namext[11]; /* name and extension */
153 u_int8_t attr; /* attributes */
154 u_int8_t rsvd[10]; /* reserved */
155 u_int8_t time[2]; /* creation time */
156 u_int8_t date[2]; /* creation date */
157 u_int8_t clus[2]; /* starting cluster */
158 u_int8_t size[4]; /* size */
159};
160
161struct bpb {
162 u_int bps; /* bytes per sector */
163 u_int spc; /* sectors per cluster */
164 u_int res; /* reserved sectors */
165 u_int nft; /* number of FATs */
166 u_int rde; /* root directory entries */
167 u_int sec; /* total sectors */
168 u_int mid; /* media descriptor */
169 u_int spf; /* sectors per FAT */
170 u_int spt; /* sectors per track */
171 u_int hds; /* drive heads */
172 u_int hid; /* hidden sectors */
173 u_int bsec; /* big total sectors */
174 u_int bspf; /* big sectors per FAT */
175 u_int rdcl; /* root directory start cluster */
176 u_int infs; /* file system info sector */
177 u_int bkbs; /* backup boot sector */
178};
179
180#define BPBGAP 0, 0, 0, 0, 0, 0
181
182static struct {
183 const char *name;
184 struct bpb bpb;
185} const stdfmt[] = {
186 {"160", {512, 1, 1, 2, 64, 320, 0xfe, 1, 8, 1, BPBGAP}},
187 {"180", {512, 1, 1, 2, 64, 360, 0xfc, 2, 9, 1, BPBGAP}},
188 {"320", {512, 2, 1, 2, 112, 640, 0xff, 1, 8, 2, BPBGAP}},
189 {"360", {512, 2, 1, 2, 112, 720, 0xfd, 2, 9, 2, BPBGAP}},
190 {"640", {512, 2, 1, 2, 112, 1280, 0xfb, 2, 8, 2, BPBGAP}},
191 {"720", {512, 2, 1, 2, 112, 1440, 0xf9, 3, 9, 2, BPBGAP}},
192 {"1200", {512, 1, 1, 2, 224, 2400, 0xf9, 7, 15, 2, BPBGAP}},
193 {"1232", {1024,1, 1, 2, 192, 1232, 0xfe, 2, 8, 2, BPBGAP}},
194 {"1440", {512, 1, 1, 2, 224, 2880, 0xf0, 9, 18, 2, BPBGAP}},
195 {"2880", {512, 2, 1, 2, 240, 5760, 0xf0, 9, 36, 2, BPBGAP}}
196};
197
198static const u_int8_t bootcode[] = {
199 0xfa, /* cli */
200 0x31, 0xc0, /* xor ax,ax */
201 0x8e, 0xd0, /* mov ss,ax */
202 0xbc, 0x00, 0x7c, /* mov sp,7c00h */
203 0xfb, /* sti */
204 0x8e, 0xd8, /* mov ds,ax */
205 0xe8, 0x00, 0x00, /* call $ + 3 */
206 0x5e, /* pop si */
207 0x83, 0xc6, 0x19, /* add si,+19h */
208 0xbb, 0x07, 0x00, /* mov bx,0007h */
209 0xfc, /* cld */
210 0xac, /* lodsb */
211 0x84, 0xc0, /* test al,al */
212 0x74, 0x06, /* jz $ + 8 */
213 0xb4, 0x0e, /* mov ah,0eh */
214 0xcd, 0x10, /* int 10h */
215 0xeb, 0xf5, /* jmp $ - 9 */
216 0x30, 0xe4, /* xor ah,ah */
217 0xcd, 0x16, /* int 16h */
218 0xcd, 0x19, /* int 19h */
219 0x0d, 0x0a,
220 'N', 'o', 'n', '-', 's', 'y', 's', 't',
221 'e', 'm', ' ', 'd', 'i', 's', 'k',
222 0x0d, 0x0a,
223 'P', 'r', 'e', 's', 's', ' ', 'a', 'n',
224 'y', ' ', 'k', 'e', 'y', ' ', 't', 'o',
225 ' ', 'r', 'e', 'b', 'o', 'o', 't',
226 0x0d, 0x0a,
227 0
228};
229
230static void check_mounted(const char *, mode_t);
231static void getstdfmt(const char *, struct bpb *);
232static void getdiskinfo(int, const char *, const char *, int, struct bpb *);
233static void print_bpb(struct bpb *);
234static u_int ckgeom(const char *, u_int, const char *);
235static u_int argtou(const char *, u_int, u_int, const char *);
236static off_t argtooff(const char *, const char *);
237static int oklabel(const char *);
238static void mklabel(u_int8_t *, const char *);
239static void setstr(u_int8_t *, const char *, size_t);
240static void usage(void);
241
242/*
243 * Construct a FAT12, FAT16, or FAT32 file system.
244 */
245int newfs_msdos_main(int argc, char *argv[])
246{
247 static const char opts[] = "@:NAB:C:F:I:L:O:S:a:b:c:e:f:h:i:k:m:n:o:r:s:u:";
248 const char *opt_B = NULL, *opt_L = NULL, *opt_O = NULL, *opt_f = NULL;
249 u_int opt_F = 0, opt_I = 0, opt_S = 0, opt_a = 0, opt_b = 0, opt_c = 0;
250 u_int opt_e = 0, opt_h = 0, opt_i = 0, opt_k = 0, opt_m = 0, opt_n = 0;
251 u_int opt_o = 0, opt_r = 0, opt_s = 0, opt_u = 0;
252 u_int opt_A = 0;
253 int opt_N = 0;
254 int Iflag = 0, mflag = 0, oflag = 0;
255 char buf[MAXPATHLEN];
256 struct stat sb;
257 struct timeval tv;
258 struct bpb bpb;
259 struct tm *tm;
260 struct bs *bs;
261 struct bsbpb *bsbpb;
262 struct bsxbpb *bsxbpb;
263 struct bsx *bsx;
264 struct de *de;
265 u_int8_t *img;
266 const char *fname, *dtype, *bname;
267 ssize_t n;
268 time_t now;
269 u_int fat, bss, rds, cls, dir, lsn, x, x1, x2;
270 u_int extra_res, alignment=0, set_res, set_spf, set_spc, tempx, attempts=0;
271 int ch, fd, fd1;
272 off_t opt_create = 0, opt_ofs = 0;
273
274 while ((ch = getopt(argc, argv, opts)) != -1)
275 switch (ch) {
276 case '@':
277 opt_ofs = argtooff(optarg, "offset");
278 break;
279 case 'N':
280 opt_N = 1;
281 break;
282 case 'A':
283 opt_A = 1;
284 break;
285 case 'B':
286 opt_B = optarg;
287 break;
288 case 'C':
289 opt_create = argtooff(optarg, "create size");
290 break;
291 case 'F':
292 if (strcmp(optarg, "12") && strcmp(optarg, "16") && strcmp(optarg, "32"))
293 errx(1, "%s: bad FAT type", optarg);
294 opt_F = atoi(optarg);
295 break;
296 case 'I':
297 opt_I = argto4(optarg, 0, "volume ID");
298 Iflag = 1;
299 break;
300 case 'L':
301 if (!oklabel(optarg))
302 errx(1, "%s: bad volume label", optarg);
303 opt_L = optarg;
304 break;
305 case 'O':
306 if (strlen(optarg) > 8)
307 errx(1, "%s: bad OEM string", optarg);
308 opt_O = optarg;
309 break;
310 case 'S':
311 opt_S = argto2(optarg, 1, "bytes/sector");
312 break;
313 case 'a':
314 opt_a = argto4(optarg, 1, "sectors/FAT");
315 break;
316 case 'b':
317 opt_b = argtox(optarg, 1, "block size");
318 opt_c = 0;
319 break;
320 case 'c':
321 opt_c = argto1(optarg, 1, "sectors/cluster");
322 opt_b = 0;
323 break;
324 case 'e':
325 opt_e = argto2(optarg, 1, "directory entries");
326 break;
327 case 'f':
328 opt_f = optarg;
329 break;
330 case 'h':
331 opt_h = argto2(optarg, 1, "drive heads");
332 break;
333 case 'i':
334 opt_i = argto2(optarg, 1, "info sector");
335 break;
336 case 'k':
337 opt_k = argto2(optarg, 1, "backup sector");
338 break;
339 case 'm':
340 opt_m = argto1(optarg, 0, "media descriptor");
341 mflag = 1;
342 break;
343 case 'n':
344 opt_n = argto1(optarg, 1, "number of FATs");
345 break;
346 case 'o':
347 opt_o = argto4(optarg, 0, "hidden sectors");
348 oflag = 1;
349 break;
350 case 'r':
351 opt_r = argto2(optarg, 1, "reserved sectors");
352 break;
353 case 's':
354 opt_s = argto4(optarg, 1, "file system size");
355 break;
356 case 'u':
357 opt_u = argto2(optarg, 1, "sectors/track");
358 break;
359 default:
360 usage();
361 }
362 argc -= optind;
363 argv += optind;
364 if (argc < 1 || argc > 2)
365 usage();
366 fname = *argv++;
367 if (!opt_create && !strchr(fname, '/')) {
368 snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname);
369 if (!(fname = strdup(buf)))
370 err(1, "%s", buf);
371 }
372 dtype = *argv;
373 if (opt_A) {
374 if (opt_r)
375 errx(1, "align (-A) is incompatible with -r");
376 if (opt_N)
377 errx(1, "align (-A) is incompatible with -N");
378 }
379 if (opt_create) {
380 if (opt_N)
381 errx(1, "create (-C) is incompatible with -N");
382 fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, 0644);
383 if (fd == -1)
384 errx(1, "failed to create %s", fname);
385 if (ftruncate(fd, opt_create))
386 errx(1, "failed to initialize %jd bytes", (intmax_t)opt_create);
387 } else if ((fd = open(fname, opt_N ? O_RDONLY : O_RDWR)) == -1)
388 err(1, "%s", fname);
389 if (fstat(fd, &sb))
390 err(1, "%s", fname);
391 if (opt_create) {
392 if (!S_ISREG(sb.st_mode))
393 warnx("warning, %s is not a regular file", fname);
394 } else {
395 if (!S_ISCHR(sb.st_mode))
396 warnx("warning, %s is not a character device", fname);
397 }
398 if (!opt_N)
399 check_mounted(fname, sb.st_mode);
400 if (opt_ofs && opt_ofs != lseek(fd, opt_ofs, SEEK_SET))
401 errx(1, "cannot seek to %jd", (intmax_t)opt_ofs);
402 memset(&bpb, 0, sizeof(bpb));
403 if (opt_f) {
404 getstdfmt(opt_f, &bpb);
405 bpb.bsec = bpb.sec;
406 bpb.sec = 0;
407 bpb.bspf = bpb.spf;
408 bpb.spf = 0;
409 }
410 if (opt_h)
411 bpb.hds = opt_h;
412 if (opt_u)
413 bpb.spt = opt_u;
414 if (opt_S)
415 bpb.bps = opt_S;
416 if (opt_s)
417 bpb.bsec = opt_s;
418 if (oflag)
419 bpb.hid = opt_o;
420 if (!(opt_f || (opt_h && opt_u && opt_S && opt_s && oflag))) {
421 off_t delta;
422 getdiskinfo(fd, fname, dtype, oflag, &bpb);
423 if (opt_s) {
424 bpb.bsec = opt_s;
425 }
426 bpb.bsec -= (opt_ofs / bpb.bps);
427 delta = bpb.bsec % bpb.spt;
428 if (delta != 0) {
429 warnx("trim %d sectors from %d to adjust to a multiple of %d",
430 (int)delta, bpb.bsec, bpb.spt);
431 bpb.bsec -= delta;
432 }
433 if (bpb.spc == 0) { /* set defaults */
434 if (bpb.bsec <= 6000) /* about 3MB -> 512 bytes */
435 bpb.spc = 1;
436 else if (bpb.bsec <= (1<<17)) /* 64M -> 4k */
437 bpb.spc = 8;
438 else if (bpb.bsec <= (1<<19)) /* 256M -> 8k */
439 bpb.spc = 16;
440 else if (bpb.bsec <= (1<<22)) /* 2G -> 16k, some versions of windows
441 require a minimum of 65527 clusters */
442 bpb.spc = 32;
443 else
444 bpb.spc = 64; /* otherwise 32k */
445 }
446 }
447 if (!powerof2(bpb.bps))
448 errx(1, "bytes/sector (%u) is not a power of 2", bpb.bps);
449 if (bpb.bps < MINBPS)
450 errx(1, "bytes/sector (%u) is too small; minimum is %u",
451 bpb.bps, MINBPS);
452 if (!(fat = opt_F)) {
453 if (opt_f)
454 fat = 12;
455 else if (!opt_e && (opt_i || opt_k))
456 fat = 32;
457 }
458 if ((fat == 32 && opt_e) || (fat != 32 && (opt_i || opt_k)))
459 errx(1, "-%c is not a legal FAT%s option",
460 fat == 32 ? 'e' : opt_i ? 'i' : 'k',
461 fat == 32 ? "32" : "12/16");
462 if (opt_f && fat == 32)
463 bpb.rde = 0;
464 if (opt_b) {
465 if (!powerof2(opt_b))
466 errx(1, "block size (%u) is not a power of 2", opt_b);
467 if (opt_b < bpb.bps)
468 errx(1, "block size (%u) is too small; minimum is %u",
469 opt_b, bpb.bps);
470 if (opt_b > bpb.bps * MAXSPC)
471 errx(1, "block size (%u) is too large; maximum is %u", opt_b, bpb.bps * MAXSPC);
472 bpb.spc = opt_b / bpb.bps;
473 }
474 if (opt_c) {
475 if (!powerof2(opt_c))
476 errx(1, "sectors/cluster (%u) is not a power of 2", opt_c);
477 bpb.spc = opt_c;
478 }
479 if (opt_r)
480 bpb.res = opt_r;
481 if (opt_n) {
482 if (opt_n > MAXNFT)
483 errx(1, "number of FATs (%u) is too large; maximum is %u", opt_n, MAXNFT);
484 bpb.nft = opt_n;
485 }
486 if (opt_e)
487 bpb.rde = opt_e;
488 if (mflag) {
489 if (opt_m < 0xf0)
490 errx(1, "illegal media descriptor (%#x)", opt_m);
491 bpb.mid = opt_m;
492 }
493 if (opt_a)
494 bpb.bspf = opt_a;
495 if (opt_i)
496 bpb.infs = opt_i;
497 if (opt_k)
498 bpb.bkbs = opt_k;
499 bss = 1;
500 bname = NULL;
501 fd1 = -1;
502 if (opt_B) {
503 bname = opt_B;
504 if (!strchr(bname, '/')) {
505 snprintf(buf, sizeof(buf), "/boot/%s", bname);
506 if (!(bname = strdup(buf)))
507 err(1, "%s", buf);
508 }
509 if ((fd1 = open(bname, O_RDONLY)) == -1 || fstat(fd1, &sb))
510 err(1, "%s", bname);
511 if (!S_ISREG(sb.st_mode) || sb.st_size % bpb.bps ||
512 sb.st_size < bpb.bps || sb.st_size > bpb.bps * MAXU16)
513 errx(1, "%s: inappropriate file type or format", bname);
514 bss = sb.st_size / bpb.bps;
515 }
516 if (!bpb.nft)
517 bpb.nft = 2;
518 if (!fat) {
519 if (bpb.bsec < (bpb.res ? bpb.res : bss) +
520 howmany((RESFTE + (bpb.spc ? MINCLS16 : MAXCLS12 + 1)) *
521 ((bpb.spc ? 16 : 12) / BPN), bpb.bps * NPB) *
522 bpb.nft +
523 howmany(bpb.rde ? bpb.rde : DEFRDE,
524 bpb.bps / sizeof(struct de)) +
525 (bpb.spc ? MINCLS16 : MAXCLS12 + 1) *
526 (bpb.spc ? bpb.spc : howmany(DEFBLK, bpb.bps)))
527 fat = 12;
528 else if (bpb.rde || bpb.bsec <
529 (bpb.res ? bpb.res : bss) +
530 howmany((RESFTE + MAXCLS16) * 2, bpb.bps) * bpb.nft +
531 howmany(DEFRDE, bpb.bps / sizeof(struct de)) +
532 (MAXCLS16 + 1) *
533 (bpb.spc ? bpb.spc : howmany(8192, bpb.bps)))
534 fat = 16;
535 else
536 fat = 32;
537 }
538 x = bss;
539 if (fat == 32) {
540 if (!bpb.infs) {
541 if (x == MAXU16 || x == bpb.bkbs)
542 errx(1, "no room for info sector");
543 bpb.infs = x;
544 }
545 if (bpb.infs != MAXU16 && x <= bpb.infs)
546 x = bpb.infs + 1;
547 if (!bpb.bkbs) {
548 if (x == MAXU16)
549 errx(1, "no room for backup sector");
550 bpb.bkbs = x;
551 } else if (bpb.bkbs != MAXU16 && bpb.bkbs == bpb.infs)
552 errx(1, "backup sector would overwrite info sector");
553 if (bpb.bkbs != MAXU16 && x <= bpb.bkbs)
554 x = bpb.bkbs + 1;
555 }
556
557 extra_res = 0;
558 set_res = !bpb.res;
559 set_spf = !bpb.bspf;
560 set_spc = !bpb.spc;
561 tempx = x;
562 /*
563 * Attempt to align if opt_A is set. This is done by increasing the number
564 * of reserved blocks. This can cause other factors to change, which can in
565 * turn change the alignment. This should take at most 2 iterations, as
566 * increasing the reserved amount may cause the FAT size to decrease by 1,
567 * requiring another nft reserved blocks. If spc changes, it will
568 * be half of its previous size, and thus will not throw off alignment.
569 */
570 do {
571 x = tempx;
572 if (set_res)
573 bpb.res = (fat == 32 ? MAX(x, MAX(16384 / bpb.bps, 4)) : x) + extra_res;
574 else if (bpb.res < x)
575 errx(1, "too few reserved sectors");
576 if (fat != 32 && !bpb.rde)
577 bpb.rde = DEFRDE;
578 rds = howmany(bpb.rde, bpb.bps / sizeof(struct de));
579 if (set_spc)
580 for (bpb.spc = howmany(fat == 16 ? DEFBLK16 : DEFBLK, bpb.bps);
581 bpb.spc < MAXSPC &&
582 bpb.res +
583 howmany((RESFTE + maxcls(fat)) * (fat / BPN),
584 bpb.bps * NPB) * bpb.nft +
585 rds +
586 (u_int64_t)(maxcls(fat) + 1) * bpb.spc <= bpb.bsec;
587 bpb.spc <<= 1);
588 if (fat != 32 && bpb.bspf > MAXU16)
589 errx(1, "too many sectors/FAT for FAT12/16");
590 x1 = bpb.res + rds;
591 x = bpb.bspf ? bpb.bspf : 1;
592 if (x1 + (u_int64_t)x * bpb.nft > bpb.bsec)
593 errx(1, "meta data exceeds file system size");
594 x1 += x * bpb.nft;
595 x = (u_int64_t)(bpb.bsec - x1) * bpb.bps * NPB /
596 (bpb.spc * bpb.bps * NPB + fat / BPN * bpb.nft);
597 x2 = howmany((RESFTE + MIN(x, maxcls(fat))) * (fat / BPN), bpb.bps * NPB);
598 if (set_spf) {
599 if (!bpb.bspf) {
600 bpb.bspf = x2;
601 }
602 x1 += (bpb.bspf - 1) * bpb.nft;
603 }
604 if(set_res) {
605 /* attempt to align root directory */
606 alignment = (bpb.res + bpb.bspf * bpb.nft) % bpb.spc;
607 extra_res += bpb.spc - alignment;
608 }
609 attempts++;
610 } while(opt_A && alignment != 0 && attempts < 2);
611 if (alignment != 0)
612 warnx("warning: Alignment failed.");
613
614 cls = (bpb.bsec - x1) / bpb.spc;
615 x = (u_int64_t)bpb.bspf * bpb.bps * NPB / (fat / BPN) - RESFTE;
616 if (cls > x)
617 cls = x;
618 if (bpb.bspf < x2)
619 warnx("warning: sectors/FAT limits file system to %u clusters", cls);
620 if (cls < mincls(fat))
621 errx(1, "%u clusters too few clusters for FAT%u, need %u", cls, fat, mincls(fat));
622 if (cls > maxcls(fat)) {
623 cls = maxcls(fat);
624 bpb.bsec = x1 + (cls + 1) * bpb.spc - 1;
625 warnx("warning: FAT type limits file system to %u sectors", bpb.bsec);
626 }
627 printf("%s: %u sector%s in %u FAT%u cluster%s (%u bytes/cluster)\n",
628 fname, cls * bpb.spc, cls * bpb.spc == 1 ? "" : "s", cls, fat,
629 cls == 1 ? "" : "s", bpb.bps * bpb.spc);
630 if (!bpb.mid)
631 bpb.mid = !bpb.hid ? 0xf0 : 0xf8;
632 if (fat == 32)
633 bpb.rdcl = RESFTE;
634 if (bpb.hid + bpb.bsec <= MAXU16) {
635 bpb.sec = bpb.bsec;
636 bpb.bsec = 0;
637 }
638 if (fat != 32) {
639 bpb.spf = bpb.bspf;
640 bpb.bspf = 0;
641 }
642 print_bpb(&bpb);
643 if (!opt_N) {
644 gettimeofday(&tv, NULL);
645 now = tv.tv_sec;
646 tm = localtime(&now);
647 if (!(img = malloc(bpb.bps)))
648 err(1, "%u", bpb.bps);
649 dir = bpb.res + (bpb.spf ? bpb.spf : bpb.bspf) * bpb.nft;
650 for (lsn = 0; lsn < dir + (fat == 32 ? bpb.spc : rds); lsn++) {
651 x = lsn;
652 if (opt_B && fat == 32 && bpb.bkbs != MAXU16 && bss <= bpb.bkbs && x >= bpb.bkbs) {
653 x -= bpb.bkbs;
654 if (!x && lseek(fd1, opt_ofs, SEEK_SET))
655 err(1, "%s", bname);
656 }
657 if (opt_B && x < bss) {
658 if ((n = read(fd1, img, bpb.bps)) == -1)
659 err(1, "%s", bname);
660 if ((unsigned)n != bpb.bps)
661 errx(1, "%s: can't read sector %u", bname, x);
662 } else
663 memset(img, 0, bpb.bps);
664 if (!lsn || (fat == 32 && bpb.bkbs != MAXU16 && lsn == bpb.bkbs)) {
665 x1 = sizeof(struct bs);
666 bsbpb = (struct bsbpb *)(img + x1);
667 mk2(bsbpb->bps, bpb.bps);
668 mk1(bsbpb->spc, bpb.spc);
669 mk2(bsbpb->res, bpb.res);
670 mk1(bsbpb->nft, bpb.nft);
671 mk2(bsbpb->rde, bpb.rde);
672 mk2(bsbpb->sec, bpb.sec);
673 mk1(bsbpb->mid, bpb.mid);
674 mk2(bsbpb->spf, bpb.spf);
675 mk2(bsbpb->spt, bpb.spt);
676 mk2(bsbpb->hds, bpb.hds);
677 mk4(bsbpb->hid, bpb.hid);
678 mk4(bsbpb->bsec, bpb.bsec);
679 x1 += sizeof(struct bsbpb);
680 if (fat == 32) {
681 bsxbpb = (struct bsxbpb *)(img + x1);
682 mk4(bsxbpb->bspf, bpb.bspf);
683 mk2(bsxbpb->xflg, 0);
684 mk2(bsxbpb->vers, 0);
685 mk4(bsxbpb->rdcl, bpb.rdcl);
686 mk2(bsxbpb->infs, bpb.infs);
687 mk2(bsxbpb->bkbs, bpb.bkbs);
688 x1 += sizeof(struct bsxbpb);
689 }
690 bsx = (struct bsx *)(img + x1);
691 mk1(bsx->sig, 0x29);
692 if (Iflag)
693 x = opt_I;
694 else
695 x = (((u_int)(1 + tm->tm_mon) << 8 |
696 (u_int)tm->tm_mday) +
697 ((u_int)tm->tm_sec << 8 |
698 (u_int)(tv.tv_usec / 10))) << 16 |
699 ((u_int)(1900 + tm->tm_year) +
700 ((u_int)tm->tm_hour << 8 |
701 (u_int)tm->tm_min));
702 mk4(bsx->volid, x);
703 mklabel(bsx->label, opt_L ? opt_L : "NO NAME");
704 snprintf(buf, sizeof(buf), "FAT%u", fat);
705 setstr(bsx->type, buf, sizeof(bsx->type));
706 if (!opt_B) {
707 x1 += sizeof(struct bsx);
708 bs = (struct bs *)img;
709 mk1(bs->jmp[0], 0xeb);
710 mk1(bs->jmp[1], x1 - 2);
711 mk1(bs->jmp[2], 0x90);
712 setstr(bs->oem, opt_O ? opt_O : "BSD 4.4",
713 sizeof(bs->oem));
714 memcpy(img + x1, bootcode, sizeof(bootcode));
715 mk2(img + MINBPS - 2, DOSMAGIC);
716 }
717 } else if (fat == 32 && bpb.infs != MAXU16 &&
718 (lsn == bpb.infs || (bpb.bkbs != MAXU16 &&
719 lsn == bpb.bkbs + bpb.infs))) {
720 mk4(img, 0x41615252);
721 mk4(img + MINBPS - 28, 0x61417272);
722 mk4(img + MINBPS - 24, 0xffffffff);
723 mk4(img + MINBPS - 20, bpb.rdcl);
724 mk2(img + MINBPS - 2, DOSMAGIC);
725 } else if (lsn >= bpb.res && lsn < dir &&
726 !((lsn - bpb.res) % (bpb.spf ? bpb.spf : bpb.bspf))) {
727 mk1(img[0], bpb.mid);
728 for (x = 1; x < fat * (fat == 32 ? 3 : 2) / 8; x++)
729 mk1(img[x], fat == 32 && x % 4 == 3 ? 0x0f : 0xff);
730 } else if (lsn == dir && opt_L) {
731 de = (struct de *)img;
732 mklabel(de->namext, opt_L);
733 mk1(de->attr, 050);
734 x = (u_int)tm->tm_hour << 11 |
735 (u_int)tm->tm_min << 5 |
736 (u_int)tm->tm_sec >> 1;
737 mk2(de->time, x);
738 x = (u_int)(tm->tm_year - 80) << 9 |
739 (u_int)(tm->tm_mon + 1) << 5 |
740 (u_int)tm->tm_mday;
741 mk2(de->date, x);
742 }
743 if ((n = write(fd, img, bpb.bps)) == -1)
744 err(1, "%s", fname);
745 if ((unsigned)n != bpb.bps) {
746 errx(1, "%s: can't write sector %u", fname, lsn);
747 exit(1);
748 }
749 }
750 free(img);
751 }
752 return 0;
753}
754
755/*
756 * Exit with error if file system is mounted.
757 */
758static void check_mounted(const char *fname, mode_t mode)
759{
760#ifdef ANDROID
761 warnx("Skipping mount checks");
762#else
763 struct statfs *mp;
764 const char *s1, *s2;
765 size_t len;
766 int n, r;
767
768 if (!(n = getmntinfo(&mp, MNT_NOWAIT)))
769 err(1, "getmntinfo");
770 len = strlen(_PATH_DEV);
771 s1 = fname;
772 if (!strncmp(s1, _PATH_DEV, len))
773 s1 += len;
774 r = S_ISCHR(mode) && s1 != fname && *s1 == 'r';
775 for (; n--; mp++) {
776 s2 = mp->f_mntfromname;
777 if (!strncmp(s2, _PATH_DEV, len))
778 s2 += len;
779 if ((r && s2 != mp->f_mntfromname && !strcmp(s1 + 1, s2)) || !strcmp(s1, s2))
780 errx(1, "%s is mounted on %s", fname, mp->f_mntonname);
781 }
782#endif
783}
784
785/*
786 * Get a standard format.
787 */
788static void getstdfmt(const char *fmt, struct bpb *bpb)
789{
790 u_int x, i;
791
792 x = sizeof(stdfmt) / sizeof(stdfmt[0]);
793 for (i = 0; i < x && strcmp(fmt, stdfmt[i].name); i++);
794 if (i == x)
795 errx(1, "%s: unknown standard format", fmt);
796 *bpb = stdfmt[i].bpb;
797}
798
799/*
800 * Get disk slice, partition, and geometry information.
801 */
802
803#ifdef __APPLE__
804static void getdiskinfo(__unused int fd, __unused const char* fname, __unused const char* dtype,
805 __unused int oflag, __unused struct bpb* bpb) {}
806#elif ANDROID
807static void getdiskinfo(int fd, const char *fname, const char *dtype,
808 __unused int oflag,struct bpb *bpb)
809{
810 struct hd_geometry geom;
811 u_long block_size;
812
813 if (ioctl(fd, BLKSSZGET, &bpb->bps)) {
814 fprintf(stderr, "Error getting bytes / sector (%s)\n", strerror(errno));
815 exit(1);
816 }
817
818 ckgeom(fname, bpb->bps, "bytes/sector");
819
820 if (ioctl(fd, BLKGETSIZE, &block_size)) {
821 fprintf(stderr, "Error getting blocksize (%s)\n", strerror(errno));
822 exit(1);
823 }
824
825 if (block_size > UINT32_MAX) {
826 fprintf(stderr, "Error blocksize too large: %lu\n", block_size);
827 exit(1);
828 }
829
830 bpb->bsec = (u_int)block_size;
831
832 if (ioctl(fd, HDIO_GETGEO, &geom)) {
833 fprintf(stderr, "Error getting gemoetry (%s) - trying sane values\n", strerror(errno));
834 geom.heads = 64;
835 geom.sectors = 63;
836 }
837
838 if (!geom.heads) {
839 printf("Bogus heads from kernel - setting sane value\n");
840 geom.heads = 64;
841 }
842
843 if (!geom.sectors) {
844 printf("Bogus sectors from kernel - setting sane value\n");
845 geom.sectors = 63;
846 }
847
848 bpb->spt = geom.sectors;
849 ckgeom(fname, bpb->spt, "sectors/track");
850
851 bpb->hds = geom.heads;
852 ckgeom(fname, bpb->hds, "drive heads");
853}
854
855#else
856
857static void getdiskinfo(int fd, const char *fname, const char *dtype,
858 __unused int oflag, struct bpb *bpb)
859{
860 struct disklabel *lp, dlp;
861 struct fd_type type;
862 off_t ms, hs = 0;
863
864 lp = NULL;
865
866 /* If the user specified a disk type, try to use that */
867 if (dtype != NULL) {
868 lp = getdiskbyname(dtype);
869 }
870
871 /* Maybe it's a floppy drive */
872 if (lp == NULL) {
873 if (ioctl(fd, DIOCGMEDIASIZE, &ms) == -1) {
874 struct stat st;
875
876 if (fstat(fd, &st))
877 err(1, "Cannot get disk size");
878 /* create a fake geometry for a file image */
879 ms = st.st_size;
880 dlp.d_secsize = 512;
881 dlp.d_nsectors = 63;
882 dlp.d_ntracks = 255;
883 dlp.d_secperunit = ms / dlp.d_secsize;
884 lp = &dlp;
885 } else if (ioctl(fd, FD_GTYPE, &type) != -1) {
886 dlp.d_secsize = 128 << type.secsize;
887 dlp.d_nsectors = type.sectrac;
888 dlp.d_ntracks = type.heads;
889 dlp.d_secperunit = ms / dlp.d_secsize;
890 lp = &dlp;
891 }
892 }
893
894 /* Maybe it's a fixed drive */
895 if (lp == NULL) {
896 if (ioctl(fd, DIOCGDINFO, &dlp) == -1) {
897 if (bpb->bps == 0 && ioctl(fd, DIOCGSECTORSIZE, &dlp.d_secsize) == -1)
898 errx(1, "Cannot get sector size, %s", strerror(errno));
899
900 /* XXX Should we use bpb->bps if it's set? */
901 dlp.d_secperunit = ms / dlp.d_secsize;
902
903 if (bpb->spt == 0 && ioctl(fd, DIOCGFWSECTORS, &dlp.d_nsectors) == -1) {
904 warnx("Cannot get number of sectors per track, %s", strerror(errno));
905 dlp.d_nsectors = 63;
906 }
907 if (bpb->hds == 0 && ioctl(fd, DIOCGFWHEADS, &dlp.d_ntracks) == -1) {
908 warnx("Cannot get number of heads, %s", strerror(errno));
909 if (dlp.d_secperunit <= 63*1*1024)
910 dlp.d_ntracks = 1;
911 else if (dlp.d_secperunit <= 63*16*1024)
912 dlp.d_ntracks = 16;
913 else
914 dlp.d_ntracks = 255;
915 }
916 }
917
918 hs = (ms / dlp.d_secsize) - dlp.d_secperunit;
919 lp = &dlp;
920 }
921
922 if (bpb->bps == 0)
923 bpb->bps = ckgeom(fname, lp->d_secsize, "bytes/sector");
924 if (bpb->spt == 0)
925 bpb->spt = ckgeom(fname, lp->d_nsectors, "sectors/track");
926 if (bpb->hds == 0)
927 bpb->hds = ckgeom(fname, lp->d_ntracks, "drive heads");
928 if (bpb->bsec == 0)
929 bpb->bsec = lp->d_secperunit;
930 if (bpb->hid == 0)
931 bpb->hid = hs;
932}
933#endif
934
935/*
936 * Print out BPB values.
937 */
938static void print_bpb(struct bpb *bpb)
939{
940 printf("bps=%u spc=%u res=%u nft=%u", bpb->bps, bpb->spc, bpb->res,
941 bpb->nft);
942 if (bpb->rde)
943 printf(" rde=%u", bpb->rde);
944 if (bpb->sec)
945 printf(" sec=%u", bpb->sec);
946 printf(" mid=%#x", bpb->mid);
947 if (bpb->spf)
948 printf(" spf=%u", bpb->spf);
949 printf(" spt=%u hds=%u hid=%u", bpb->spt, bpb->hds, bpb->hid);
950 if (bpb->bsec)
951 printf(" bsec=%u", bpb->bsec);
952 if (!bpb->spf) {
953 printf(" bspf=%u rdcl=%u", bpb->bspf, bpb->rdcl);
954 printf(" infs=");
955 printf(bpb->infs == MAXU16 ? "%#x" : "%u", bpb->infs);
956 printf(" bkbs=");
957 printf(bpb->bkbs == MAXU16 ? "%#x" : "%u", bpb->bkbs);
958 }
959 printf("\n");
960}
961
962/*
963 * Check a disk geometry value.
964 */
965static u_int ckgeom(const char *fname, u_int val, const char *msg)
966{
967 if (!val)
968 errx(1, "%s: no default %s", fname, msg);
969 if (val > MAXU16)
970 errx(1, "%s: illegal %s %d", fname, msg, val);
971 return val;
972}
973
974/*
975 * Convert and check a numeric option argument.
976 */
977static u_int argtou(const char *arg, u_int lo, u_int hi, const char *msg)
978{
979 char *s;
980 u_long x;
981
982 errno = 0;
983 x = strtoul(arg, &s, 0);
984 if (errno || !*arg || *s || x < lo || x > hi)
985 errx(1, "%s: bad %s", arg, msg);
986 return x;
987}
988
989/*
990 * Same for off_t, with optional skmgpP suffix
991 */
992static off_t argtooff(const char *arg, const char *msg)
993{
994 char *s;
995 off_t x;
996
997 x = strtoll(arg, &s, 0);
998 /* allow at most one extra char */
999 if (errno || x < 0 || (s[0] && s[1]) )
1000 errx(1, "%s: bad %s", arg, msg);
1001 if (*s) { /* the extra char is the multiplier */
1002 switch (*s) {
1003 default:
1004 errx(1, "%s: bad %s", arg, msg);
1005 /* notreached */
1006
1007 case 's': /* sector */
1008 case 'S':
1009 x <<= 9; /* times 512 */
1010 break;
1011
1012 case 'k': /* kilobyte */
1013 case 'K':
1014 x <<= 10; /* times 1024 */
1015 break;
1016
1017 case 'm': /* megabyte */
1018 case 'M':
1019 x <<= 20; /* times 1024*1024 */
1020 break;
1021
1022 case 'g': /* gigabyte */
1023 case 'G':
1024 x <<= 30; /* times 1024*1024*1024 */
1025 break;
1026
1027 case 'p': /* partition start */
1028 case 'P': /* partition start */
1029 case 'l': /* partition length */
1030 case 'L': /* partition length */
1031 errx(1, "%s: not supported yet %s", arg, msg);
1032 /* notreached */
1033 }
1034 }
1035 return x;
1036}
1037
1038/*
1039 * Check a volume label.
1040 */
1041static int oklabel(const char *src)
1042{
1043 int c, i;
1044
1045 for (i = 0; i <= 11; i++) {
1046 c = (u_char)*src++;
1047 if (c < ' ' + !i || strchr("\"*+,./:;<=>?[\\]|", c))
1048 break;
1049 }
1050 return i && !c;
1051}
1052
1053/*
1054 * Make a volume label.
1055 */
1056static void mklabel(u_int8_t *dest, const char *src)
1057{
1058 int c, i;
1059
1060 for (i = 0; i < 11; i++) {
1061 c = *src ? toupper(*src++) : ' ';
1062 *dest++ = !i && c == '\xe5' ? 5 : c;
1063 }
1064}
1065
1066/*
1067 * Copy string, padding with spaces.
1068 */
1069static void setstr(u_int8_t *dest, const char *src, size_t len)
1070{
1071 while (len--)
1072 *dest++ = *src ? *src++ : ' ';
1073}
1074
1075/*
1076 * Print usage message.
1077 */
1078static void usage(void)
1079{
1080 fprintf(stderr,
1081 "usage: newfs_msdos [ -options ] special [disktype]\n"
1082 "where the options are:\n"
1083 "\t-@ create file system at specified offset\n"
1084 "\t-A Attempt to cluster align root directory\n"
1085 "\t-B get bootstrap from file\n"
1086 "\t-C create image file with specified size\n"
1087 "\t-F FAT type (12, 16, or 32)\n"
1088 "\t-I volume ID\n"
1089 "\t-L volume label\n"
1090 "\t-N don't create file system: just print out parameters\n"
1091 "\t-O OEM string\n"
1092 "\t-S bytes/sector\n"
1093 "\t-a sectors/FAT\n"
1094 "\t-b block size\n"
1095 "\t-c sectors/cluster\n"
1096 "\t-e root directory entries\n"
1097 "\t-f standard format\n"
1098 "\t-h drive heads\n"
1099 "\t-i file system info sector\n"
1100 "\t-k backup boot sector\n"
1101 "\t-m media descriptor\n"
1102 "\t-n number of FATs\n"
1103 "\t-o hidden sectors\n"
1104 "\t-r reserved sectors\n"
1105 "\t-s file system size (sectors)\n"
1106 "\t-u sectors/track\n");
1107 exit(1);
1108}
diff --git a/toolbox/tools.h b/toolbox/tools.h
index 3d4bc3e12..abeb3ef24 100644
--- a/toolbox/tools.h
+++ b/toolbox/tools.h
@@ -1,4 +1,3 @@
1TOOL(getevent) 1TOOL(getevent)
2TOOL(getprop) 2TOOL(getprop)
3TOOL(newfs_msdos)
4TOOL(toolbox) 3TOOL(toolbox)