1 | /*␊ |
2 | * ext2fs.c␊ |
3 | * ␊ |
4 | *␊ |
5 | * Created by mackerintel on 1/26/09.␊ |
6 | * Copyright 2009 __MyCompanyName__. All rights reserved.␊ |
7 | *␊ |
8 | */␊ |
9 | ␊ |
10 | #include "libsaio.h"␊ |
11 | #include "sl.h"␊ |
12 | #include "ext2fs.h"␊ |
13 | ␊ |
14 | #define EX2ProbeSize␉2048␊ |
15 | ␊ |
16 | bool EX2Probe (const void *buf)␊ |
17 | {␊ |
18 | ␉return (OSReadLittleInt16(buf+0x438,0)==0xEF53);␊ |
19 | }␊ |
20 | ␊ |
21 | long EX2GetUUID(CICell ih, char *uuidStr)␊ |
22 | {␊ |
23 | ␉uint8_t *b, *buf=malloc (EX2ProbeSize);␊ |
24 | ␉if (!buf)␊ |
25 | ␉␉return -1;␊ |
26 | ␉Seek(ih, 0);␊ |
27 | ␉Read(ih, (long)buf, EX2ProbeSize);␊ |
28 | ␉if (!EX2Probe (buf))␊ |
29 | ␉{␊ |
30 | ␉␉free (buf);␊ |
31 | ␉␉return -1;␊ |
32 | ␉}␊ |
33 | ␉if (OSReadLittleInt32 (buf+0x44c,0)<1)␊ |
34 | ␉{␊ |
35 | ␉␉free (buf);␊ |
36 | ␉␉return -1;␊ |
37 | ␉}␊ |
38 | ␉b=buf+0x468;␊ |
39 | ␉sprintf(uuidStr,␊ |
40 | ␉␉"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",␊ |
41 | ␉␉b[0], b[1], b[2], b[3],␊ |
42 | ␉␉b[4], b[5],␊ |
43 | ␉␉b[6], b[7],␊ |
44 | ␉␉b[8], b[9],␊ |
45 | ␉␉b[10], b[11], b[12], b[13], b[14], b[15]);␊ |
46 | ␉free (buf);␊ |
47 | ␉return 0;␊ |
48 | }␊ |
49 | ␊ |
50 | void EX2GetDescription(CICell ih, char *str, long strMaxLen)␊ |
51 | {␊ |
52 | ␉char * buf=malloc (EX2ProbeSize);␊ |
53 | ␉str[0]=0;␊ |
54 | ␉if (!buf)␊ |
55 | ␉␉return;␊ |
56 | ␉Seek(ih, 0);␊ |
57 | ␉Read(ih, (long)buf, EX2ProbeSize);␊ |
58 | ␉if (!EX2Probe (buf))␊ |
59 | ␉{␊ |
60 | ␉␉free (buf);␊ |
61 | ␉␉return;␊ |
62 | ␉}␊ |
63 | ␉if (OSReadLittleInt32 (buf+0x44c,0)<1)␊ |
64 | ␉{␊ |
65 | ␉␉free (buf);␊ |
66 | ␉␉return;␊ |
67 | ␉}␊ |
68 | ␉str[strMaxLen]=0;␊ |
69 | ␉strncpy (str, buf+0x478, MIN(strMaxLen, 16));␊ |
70 | ␉free (buf);␊ |
71 | }␊ |
72 | |