Root/
Source at commit 2740 created 8 years 11 months ago. By ifabio, sync with trunk. | |
---|---|
1 | /*␊ |
2 | * befs.c␊ |
3 | * ␊ |
4 | *␊ |
5 | * Created by scorpius␊ |
6 | * Copyright 2010␊ |
7 | *␊ |
8 | */␊ |
9 | ␊ |
10 | #include "libsaio.h"␊ |
11 | #include "sl.h"␊ |
12 | #include "befs.h"␊ |
13 | ␊ |
14 | #define BeFSProbeSize␉2048␊ |
15 | ␊ |
16 | #define SUPER_BLOCK_MAGIC1 0x42465331 /* BFS1 */ ␊ |
17 | #define SUPER_BLOCK_MAGIC2 0xdd121031 ␊ |
18 | #define SUPER_BLOCK_MAGIC3 0x15b6830e␊ |
19 | ␊ |
20 | /* Find BeFS signature */␊ |
21 | bool BeFSProbe (const void *buf)␊ |
22 | {␊ |
23 | ␉return (OSReadLittleInt32(buf+0x220,0) == SUPER_BLOCK_MAGIC1);␊ |
24 | }␊ |
25 | ␊ |
26 | /* Find BeFS volume label */␊ |
27 | void BeFSGetDescription(CICell ih, char *str, long strMaxLen)␊ |
28 | {␊ |
29 | ␉char * buf=malloc (BeFSProbeSize);␊ |
30 | ␉str[0]=0;␊ |
31 | ␉if (!buf) {␊ |
32 | ␉␉return;␊ |
33 | ␉}␊ |
34 | ␉Seek(ih, 0);␊ |
35 | ␉Read(ih, (long)buf, BeFSProbeSize);␊ |
36 | ␉if (!BeFSProbe (buf))␊ |
37 | ␉{␊ |
38 | ␉␉free (buf);␊ |
39 | ␉␉return;␊ |
40 | ␉}␊ |
41 | ␉str[strMaxLen]=0;␊ |
42 | ␉strncpy (str, buf+0x200, MIN (strMaxLen, 32));␊ |
43 | ␉free (buf);␊ |
44 | }␊ |
45 |