Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Enoch_Modules/i386/libsaio/ext2fs.c

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

Archive Download this file

Revision: 2238