Root/
Source at commit 2740 created 8 years 11 months ago. By ifabio, sync with trunk. | |
---|---|
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 | void EX2GetDescription(CICell ih, char *str, long strMaxLen)␊ |
22 | {␊ |
23 | ␉char * buf=malloc (EX2ProbeSize);␊ |
24 | ␉str[0]=0;␊ |
25 | ␉if (!buf) {␊ |
26 | ␉␉return;␊ |
27 | ␉}␊ |
28 | ␉Seek(ih, 0);␊ |
29 | ␉Read(ih, (long)buf, EX2ProbeSize);␊ |
30 | ␉if (!EX2Probe (buf)) {␊ |
31 | ␉␉free (buf);␊ |
32 | ␉␉return;␊ |
33 | ␉}␊ |
34 | ␉if (OSReadLittleInt32 (buf+0x44c,0)<1) {␊ |
35 | ␉␉free (buf);␊ |
36 | ␉␉return;␊ |
37 | ␉}␊ |
38 | ␉str[strMaxLen]=0;␊ |
39 | ␉strncpy (str, buf+0x478, MIN(strMaxLen, 16));␊ |
40 | ␉free (buf);␊ |
41 | }␊ |
42 | ␊ |
43 | long EX2GetUUID(CICell ih, char *uuidStr)␊ |
44 | {␊ |
45 | ␉uint8_t *b, *buf=malloc (EX2ProbeSize);␊ |
46 | ␉if (!buf) {␊ |
47 | ␉␉return -1;␊ |
48 | ␉}␊ |
49 | ␉Seek(ih, 0);␊ |
50 | ␉Read(ih, (long)buf, EX2ProbeSize);␊ |
51 | ␉if (!EX2Probe (buf)) {␊ |
52 | ␉␉free (buf);␊ |
53 | ␉␉return -1;␊ |
54 | ␉}␊ |
55 | ␉if (OSReadLittleInt32 (buf+0x44c,0)<1) {␊ |
56 | ␉␉free (buf);␊ |
57 | ␉␉return -1;␊ |
58 | ␉}␊ |
59 | ␉b=buf+0x468;␊ |
60 | ␉sprintf(uuidStr,␊ |
61 | ␉␉"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",␊ |
62 | ␉␉b[0], b[1], b[2], b[3],␊ |
63 | ␉␉b[4], b[5],␊ |
64 | ␉␉b[6], b[7],␊ |
65 | ␉␉b[8], b[9],␊ |
66 | ␉␉b[10], b[11], b[12], b[13], b[14], b[15]);␊ |
67 | ␉free (buf);␊ |
68 | ␉return 0;␊ |
69 | }␊ |
70 |