Debian Codegraph @

beos.c

raw symbols SCIP
1 /*
2 * beos.c
3 * Detection of BeOS file systems
4 *
5 * Copyright (c) 2003-2006 Christoph Pfisterer
6 * Based on a contribution by Shadowcaster
7 *
8 * Permission is hereby granted, free of charge, to any person
9 * obtaining a copy of this software and associated documentation
10 * files (the "Software"), to deal in the Software without
11 * restriction, including without limitation the rights to use, copy,
12 * modify, merge, publish, distribute, sublicense, and/or sell copies
13 * of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * SOFTWARE.
27 */
28
29 #include "global.h"
30
31 /*
32 * BeOS BFS (BeFS) file system
33 */
34
35 void detect_bfs(SECTION *section, int level)
36 {
37 unsigned char *buf;
38 char s[256];
39 int off, en;
40 u4 blocksize;
41 u8 blockcount;
42
43 for (off = 0; off <= 512; off += 512) {
44 if (get_buffer(section, off, 512, (void **)&buf) < 512)
45 continue;
46
47 for (en = 0; en < 2; en++) {
48 if (get_ve_long(en, buf + 32) == 0x42465331 && /* magic 1 */
49 get_ve_long(en, buf + 36) == 0x42494745 && /* endianness */
50 get_ve_long(en, buf + 68) == 0xdd121031 && /* magic 2 */
51 get_ve_long(en, buf + 112) == 0x15b6830e) { /* magic 3 */
52
53 print_line(level, "BeOS BFS (BeFS) file system, %s placement, %s",
54 (off == 0) ? "Apple" : "Intel",
55 get_ve_name(en));
56
57 /* get label */
58 get_string(buf, 32, s);
59 if (s[0])
60 print_line(level + 1, "Volume name \"%s\"", s);
61
62 /* get size */
63 blocksize = get_ve_long(en, buf + 40);
64 blockcount = get_ve_quad(en, buf + 48);
65 /* possible further consistency checks:
66 blocksize must be in ( 512, 1024, 2048, 4096 )
67 long @ 44 is shift number for the block size, i.e.
68 blocksize == 1 << get_ve_long(en, buf + 44)
69 */
70
71 format_blocky_size(s, blockcount, blocksize, "blocks", NULL);
72 print_line(level + 1, "Volume size %s", s);
73
74 return;
75 }
76 }
77 }
78 }
79
80 /*
81 * BeOS boot loader
82 */
83
84 void detect_beos_loader(SECTION *section, int level)
85 {
86 unsigned char *buf;
87
88 if (section->flags & FLAG_IN_DISKLABEL)
89 return;
90
91 if (get_buffer(section, 0, 512, (void **)&buf) < 512)
92 return;
93
94 if (find_memory(buf, 512, "Be Boot Loader", 14) >= 0)
95 print_line(level, "BeOS boot loader");
96 if (find_memory(buf, 512, "yT Boot Loader", 14) >= 0)
97 print_line(level, "ZETA/yellowTab boot loader");
98 if (find_memory(buf, 512, "\x04" "beos\x06" "system\x05" "zbeos", 18) >= 0)
99 print_line(level, "Haiku boot loader");
100 }
101
102 /* EOF */