• R/O
  • SSH
  • HTTPS

haribote: Commit


Commit MetaInfo

Revision195 (tree)
Zeit2010-03-04 18:23:03
Autortatsupc

Log Message

orbspace

Ändern Zusammenfassung

Diff

--- haribote/trunk/orbspace/mkorbfs/orbfs.c (revision 194)
+++ haribote/trunk/orbspace/mkorbfs/orbfs.c (nonexistent)
@@ -1,175 +0,0 @@
1-#ifdef ORBSPACE
2- #include "orbfs.h"
3-#else
4- #include "..\orbspace\orbfs.h"
5- #include <stdlib.h>
6- #include <stdio.h>
7-#endif
8-#include <string.h>
9-
10-unsigned char *bpb;
11-unsigned int *orbsat;
12-unsigned int disksize;
13-
14-void orbfs_init(void)
15-{
16-#ifdef ORBSPACE
17-#else
18- bpb = (unsigned char *) malloc(7680);
19- io_read(bpb, 0, 7680);
20-#endif
21- disksize = *((unsigned int *) (bpb + 446 + 0xc));
22- orbsat = (unsigned int *) (bpb + 512);
23- return;
24-}
25-
26-unsigned int orbsat_getnext(unsigned int addr, unsigned int size)
27-{
28- unsigned int no, *p;
29-
30- for (no = (addr - 0x1e00) / 512 + 1; size > 512; size -= 512) {
31- for (p = orbsat;
32- p < (orbsat + 0x1c00) && *p && *p < no; p += 2);
33- if (p == (orbsat + 0x1c00)) {
34- return 0;
35- } else {
36- no = *(p + 1) ? *(p + 1) : no + 1;
37- }
38- }
39- return no * 512 + 0x1e00;
40-}
41-
42-unsigned int *orbsat_add(unsigned int no, unsigned int next)
43-{
44- unsigned int *p, *q;
45-
46- for (p = orbsat; p < (orbsat + 0x1c00) && *p && *p < no; p += 2);
47- if (p == (orbsat + 0x1c00)) {
48- return 0;
49- }
50- if (*p) {
51- for (q = orbsat + 0x1c00; p < q; q -= 2) {
52- *q = *(q - 2);
53- *(q - 1) = *(q - 3);
54- }
55- }
56- *p = no;
57- *(p + 1) = next;
58- return p;
59-}
60-
61-unsigned int *orbfs_search(unsigned char *name)
62-{
63-#ifdef ORBSPACE
64-#else
65- unsigned char *buf = (unsigned char *) malloc(512);
66-#endif
67- unsigned int addr;
68-
69- if (!*orbsat) {
70- return 0;
71- }
72- for (addr = 0x1e00;;){
73- io_read(buf, addr, 512);
74- if (strncmp((unsigned char *) (buf + 4), name, 12) == 0) {
75-#ifdef ORBSPACE
76-#else
77- free(buf);
78-#endif
79- return addr;
80- } else if (!*(buf + 4)) {
81- break;
82- }
83- if ((addr = orbsat_getnext(addr,
84- ((unsigned int) *buf + 512 + 511) / 512 * 512)) == 0) {
85- break;
86- }
87- }
88-#ifdef ORBSPACE
89-#else
90- free(buf);
91-#endif
92- return 0;
93-}
94-
95-int orbfs_create(unsigned char *name, unsigned int size, unsigned char *fbuf)
96-{
97- struct entry *ent;
98- unsigned char *buf;
99- unsigned int *sat, addr;
100-
101- if (orbfs_search(name) != 0) {
102- return 1;
103- }
104- for (sat = orbsat; sat < (orbsat + 0x1c00) && *sat; sat++);
105- if (sat == (orbsat + 0x1c00)) {
106- return 1;
107- } else if (sat-- == orbsat) {
108- sat = orbsat;
109- }
110- if (*sat) {
111- if ((unsigned int) (*sat * 512 + 0x1e00 + size) > disksize) {
112- return 1;
113- }
114- addr = (unsigned int) ((*sat - 1) * 512 + 0x1e00);
115- *sat += (size + 512 + 511) / 512;
116- } else if (orbsat_add((size + 512 + 511) / 512 + 1, 0) == 0) {
117- return 1;
118- } else {
119- addr = 0x1e00;
120- }
121- io_write((unsigned char *) orbsat, 0x200, 7168);
122-#ifdef ORBSPACE
123-#else
124- buf = (unsigned char *) malloc(512);
125-#endif
126- io_read(buf, addr, 512);
127- ent = (struct entry *) buf;
128- ent->size = size;
129- strncpy(ent->name, name, 12);
130- memset(ent->meta, 0, 496);
131- io_write(buf, addr, 512);
132- for (addr += 512;; size -= 512) {
133- io_read(buf, addr, 512);
134- memcpy(buf, fbuf, size > 512 ? 512 : size);
135- io_write(buf, addr, 512);
136- if (size <= 512) {
137- break;
138- }
139- addr += 512;
140- fbuf += 512;
141- }
142-#ifdef ORBSPACE
143-#else
144- free(buf);
145-#endif
146- return 0;
147-}
148-
149-int orbfs_meta_add(unsigned char *name, unsigned char *str)
150-{
151- struct entry *ent;
152- unsigned char *p;
153- unsigned int addr, len = strlen(str);
154-
155- if ((addr = orbfs_search(name)) == 0) {
156- return 1;
157- }
158-#ifdef ORBSPACE
159-#else
160- ent = (struct entry *) malloc(512);
161-#endif
162- io_read(ent, addr, 512);
163- for (p = ent->meta; *p; p++);
164- if ((ent + 512 - (unsigned int) p) <= len) {
165- return 1;
166- }
167- strcpy(p, str);
168- p[len] = 0x0a;
169- io_write(ent, addr, 512);
170-#ifdef ORBSPACE
171-#else
172- free(ent);
173-#endif
174- return 0;
175-}
--- haribote/trunk/orbspace/orbspace/orbfs.c (revision 194)
+++ haribote/trunk/orbspace/orbspace/orbfs.c (revision 195)
@@ -58,7 +58,7 @@
5858 return p;
5959 }
6060
61-unsigned int *orbfs_search(unsigned char *name)
61+unsigned int orbfs_search(unsigned char *name)
6262 {
6363 #ifdef ORBSPACE
6464 #else
@@ -159,14 +159,14 @@
159159 #else
160160 ent = (struct entry *) malloc(512);
161161 #endif
162- io_read(ent, addr, 512);
162+ io_read((unsigned char *) ent, addr, 512);
163163 for (p = ent->meta; *p; p++);
164- if ((ent + 512 - (unsigned int) p) <= len) {
164+ if ((unsigned int) (ent + 512 - (unsigned int) p) <= len) {
165165 return 1;
166166 }
167167 strcpy(p, str);
168168 p[len] = 0x0a;
169- io_write(ent, addr, 512);
169+ io_write((unsigned char *) ent, addr, 512);
170170 #ifdef ORBSPACE
171171 #else
172172 free(ent);
Show on old repository browser