• R/O
  • SSH
  • HTTPS

haribote: Commit


Commit MetaInfo

Revision194 (tree)
Time2010-03-04 18:20:10
Authortatsupc

Log Message

orbspace

Change Summary

Incremental Difference

--- haribote/trunk/orbspace/mkorbfs/io_img.c (revision 193)
+++ haribote/trunk/orbspace/mkorbfs/io_img.c (nonexistent)
@@ -1,41 +0,0 @@
1-#include "..\orbspace\io.h"
2-#include <stdio.h>
3-#include <stdlib.h>
4-#include <string.h>
5-
6-FILE *imgfp;
7-unsigned char *imgbuf;
8-unsigned int imgsize;
9-
10-unsigned char ptable[16] = {
11- 0x80, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
12- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
13-};
14-
15-int io_img_init(unsigned char *name, unsigned int size, unsigned char *iplname)
16-{
17- FILE *fp;
18-
19- if ((imgfp = fopen(name, "wb")) == 0) {
20- return 1;
21- }
22- imgsize = size * 1024;
23- imgbuf = (unsigned char *) malloc(imgsize);
24- memset(imgbuf, 0, imgsize);
25- if ((fp = fopen(iplname, "rb")) == 0) {
26- return 1;
27- }
28- fread(imgbuf, 1, 446, fp);
29- memcpy(imgbuf + 446, ptable, 16);
30- *((int *) (imgbuf + 446 + 0xc)) = imgsize / 512;
31- imgbuf[510] = 0x55; imgbuf[511] = 0xaa;
32- return 0;
33-}
34-
35-int io_img_final(void)
36-{
37- if (fwrite(imgbuf, 1, imgsize, imgfp) != imgsize) {
38- return 1;
39- }
40- return 0;
41-}
--- haribote/trunk/orbspace/mkorbfs/mkorbfs.c (revision 193)
+++ haribote/trunk/orbspace/mkorbfs/mkorbfs.c (revision 194)
@@ -1,24 +1,107 @@
11 #include "..\orbspace\orbfs.h"
2-/* io_img.c */
3-int io_img_init(unsigned char *name, unsigned int size, unsigned char *iplname);
4-int io_img_final(void);
52
63 #include <stdio.h>
74 #include <stdlib.h>
5+#include <string.h>
86
7+FILE *imgfp;
8+unsigned char *imgbuf;
9+unsigned int imgsize;
10+
11+int io_read(unsigned char *buf, unsigned int addr, unsigned int size)
12+{
13+ memcpy(buf, imgbuf + addr, size);
14+ return 0;
15+}
16+
17+int io_write(unsigned char *buf, unsigned int addr, unsigned int size)
18+{
19+ memcpy(imgbuf + addr, buf, size);
20+ return 0;
21+}
22+
23+unsigned char *errmsg[] = {
24+ "Syntax error",
25+ "Image file error",
26+ "IPL file error",
27+ "File error"
28+};
29+
30+void print_error(int no)
31+{
32+ printf("%s\n", errmsg[no]);
33+ exit(1);
34+}
35+
36+unsigned char ptable[16] = {
37+ 0x80, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
38+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
39+};
40+
941 int main(int argc, char **argv)
1042 {
43+ FILE *fp;
44+ unsigned char *buf, *name, *p;
45+ int size, n, m, i;
46+
1147 if (argc < 4) {
12- puts("Syntax error");
13- return 1;
48+ print_error(0);
1449 }
15- if (io_img_init(argv[1], atoi(argv[2]), argv[3]) != 0) {
16- puts("File error");
17- return 1;
50+
51+ if ((imgfp = fopen(argv[1], "wb")) == 0) {
52+ print_error(1);
1853 }
19- if (io_img_final() != 0) {
20- puts("File error");
54+ imgsize = atoi(argv[2]) * 1024;
55+ imgbuf = (unsigned char *) malloc(imgsize);
56+ memset(imgbuf, 0, imgsize);
57+ if ((fp = fopen(argv[3], "rb")) == 0) {
58+ print_error(2);
2159 return 1;
2260 }
61+ fread(imgbuf, 1, 446, fp);
62+ fclose(fp);
63+ memcpy(imgbuf + 446, ptable, 16);
64+ *((unsigned int *) (imgbuf + 446 + 0xc)) = imgsize / 512;
65+ imgbuf[510] = 0x55; imgbuf[511] = 0xaa;
66+ orbfs_init();
67+
68+ for (n = 4; n < argc;) {
69+ if (strncmp(argv[n], "+File", 4) == 0) {
70+ for (m = ++n; m < argc && argv[m][0] != '+'; m++);
71+ if ((fp = fopen(argv[n], "rb")) == 0) {
72+ print_error(3);
73+ }
74+ fseek(fp, 0, SEEK_END);
75+ size = ftell(fp);
76+ fseek(fp, 0, SEEK_SET);
77+ buf = (unsigned char *) malloc(size);
78+ fread(buf, 1, size, fp);
79+ for (name = p = argv[n]; *p; p++) {
80+ if (*p == '\\') {
81+ name = p + 1;
82+ }
83+ }
84+ if (orbfs_create(name, size, buf) != 0) {
85+ print_error(3);
86+ }
87+ if (orbfs_meta_add(name, "Type=File") != 0) {
88+ print_error(3);
89+ }
90+ for (i = n + 1; i < m; i++) {
91+ if (orbfs_meta_add(name, argv[i]) != 0) {
92+ print_error(3);
93+ }
94+ }
95+ free(buf);
96+ fclose(fp);
97+ n = m;
98+ } else {
99+ print_error(0);
100+ }
101+ }
102+
103+ if (fwrite(imgbuf, 1, imgsize, imgfp) != imgsize) {
104+ print_error(1);
105+ }
23106 return 0;
24107 }
--- haribote/trunk/orbspace/mkorbfs/orbfs.c (nonexistent)
+++ haribote/trunk/orbspace/mkorbfs/orbfs.c (revision 194)
@@ -0,0 +1,175 @@
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/mkorbfs/Makefile (revision 193)
+++ haribote/trunk/orbspace/mkorbfs/Makefile (revision 194)
@@ -1,10 +1,105 @@
11 TARGET = mkorbfs
22 MODE = exe
3-OBJS = $(TARGET).obj io_img.obj ..\orbspace\orbfs.obj
3+OBJS = $(TARGET).obj orbfs.obj
44 STACKSIZE = 0x1000000 # 16MB (default)
55
6-INCPATH = ../../z_tools/win32/
7-CC1OPT = -Dmain=main0
8-include ../com_mak.txt
6+TOOLPATH = ../../z_tools/
7+INCPATH = $(TOOLPATH)win32/
8+CC1OPT = -Dmain=main0
9+RULEFILE = $(TOOLPATH)guigui00/guigui00.rul
10+MAKE = $(TOOLPATH)make.exe -r
11+SJISCONV = $(TOOLPATH)sjisconv.exe -s
12+CC1 = $(TOOLPATH)cc1.exe -I$(INCPATH) $(CC1OPT) -Os -Wall -quiet
13+CPP = $(TOOLPATH)c++.exe -I$(CPPINCPATH) $(CC1OPT) -Os -Wall -nostdlib -fno-builtin -fno-exceptions \
14+ -fno-rtti -B$(TOOLPATH) -x c++ -c
15+GAS2NASK = $(TOOLPATH)gas2nask.exe -a
16+NASK = $(TOOLPATH)nask.exe
17+OBJ2BIM = $(TOOLPATH)obj2bim.exe
18+BIM2BIN = $(TOOLPATH)bim2bin.exe
19+CPP0 = $(TOOLPATH)cpp0.exe -P -I$(INCPATH)
20+ASKA = $(TOOLPATH)aska.exe
21+NASKCNV = $(TOOLPATH)naskcnv0.exe -l -s -w
22+GOLIB = $(TOOLPATH)golib00.exe
23+LINK = $(TOOLPATH)ld.exe -s -Bdynamic --stack $(STACKSIZE)
24+EDIMG = $(TOOLPATH)edimg.exe
25+SARTOL = $(TOOLPATH)sartol.exe
26+DELE = del
27+COPY = copy
928
10-# tolset08対応Makefile
29+LIBPATH = $(INCPATH)
30+LIBS = $(LIBPATH)w32clibc.lib $(LIBPATH)golibc.lib $(LIBPATH)libmingw.lib
31+
32+# 以上の項目はあなたのディレクトリ構成にあわせて書き換える
33+
34+ALL:
35+ copy ..\orbspace\orbfs.c orbfs.c
36+ $(MAKE) $(TARGET).$(MODE)
37+
38+%.ca : %.c Makefile
39+ $(SJISCONV) $*.c $*.ca
40+
41+%.cpa : %.cpp Makefile
42+ $(SJISCONV) $*.cpp $*.cpa
43+
44+%.gas : %.ca Makefile
45+ $(CC1) -o $*.gas $*.ca
46+
47+%.nas : %.gas Makefile
48+ $(GAS2NASK) $*.gas $*.nas
49+
50+%.obj : %.nas Makefile
51+ $(NASK) $*.nas $*.obj
52+
53+%.obj : %.cpa Makefile
54+ $(CPP) -o $*.obj $*.cpa
55+
56+%.ias : %.ask Makefile
57+ $(CPP0) -o $*.ias $*.ask
58+
59+%.3as : %.ias Makefile
60+ $(ASKA) $*.ias $*.3as
61+
62+%.nas : %.3as Makefile
63+ $(NASKCNV) $*.3as $*.nas
64+
65+%.lst : %.nas Makefile
66+ $(NASK) $*.nas $*.obj $*.lst
67+
68+$(TARGET).bim : $(OBJS) Makefile
69+ $(OBJ2BIM) @$(RULEFILE) out:$(TARGET).bim stack:$(STACKSIZE) map:$(TARGET).map $(OBJS)
70+
71+%.bin : %.bim Makefile
72+ $(BIM2BIN) in:$*.bim out:$*.org malloc:$(MALLOCSIZE) mmarea:$(MMAREA) $(BIMOPT0)
73+ $(BIM2BIN) -osacmp in:$*.org out:$*.bin $(BIMOPT1)
74+
75+$(TARGET).lib : $(OBJS) Makefile
76+ $(GOLIB) out:$@ $(OBJS)
77+
78+$(TARGET).dll : $(TARGET).bim Makefile
79+ $(OBJ2BIM) @$(RULEFILE) out:$(TARGET).bim map:$(TARGET).map $(OBJS)
80+ $(BIM2BIN) -osacmp -tek1 in:$(TARGET).bim out:$(TARGET).dll
81+
82+$(TARGET).exe : $(OBJS) Makefile
83+ $(LINK) -o $(TARGET).exe -Map $(TARGET).map $(OBJS) $(LIBS)
84+
85+clean :
86+ -$(DELE) *.obj
87+ -$(DELE) $(TARGET).bim
88+ -$(DELE) $(TARGET).map
89+ -$(DELE) $(TARGET).org
90+
91+run :
92+ $(MAKE) $(TARGET).$(MODE)
93+ $(COPY) $(TARGET).$(MODE) ..\z_tools\!built.bin
94+ $(MAKE) -C $(TOOLPATH)osa_qemu
95+ $(EDIMG) @$(TOOLPATH)edimgopt.txt $(EDIMGOPT) imgout:../z_tools/qemu/fdimage0.bin
96+ $(MAKE) -C $(TOOLPATH)qemu
97+
98+arc :
99+ $(MAKE) $(TARGET).$(MODE)
100+ $(SARTOL) e $(ARCORG) . @-4k ARCINFO0.TXT $(ARCFLIES)
101+ $(BIM2BIN) -osacmp in:$(ARCORG) out:$(ARCTEK) $(BIMOPT2)
102+
103+src_only :
104+ $(MAKE) clean
105+ -$(DELE) $(TARGET).$(MODE)
--- haribote/trunk/orbspace/orbspace.txt (revision 193)
+++ haribote/trunk/orbspace/orbspace.txt (revision 194)
@@ -2,13 +2,13 @@
22
33
44
5-・カラフルなボールで”整理”する(一般・機能タグ)
6-  サムネイル表示のファイルを半透明のカラフルなボールの中に入れて整理する!
7- さらにorbScriptでメタデータを用いた分類や検索ができる!
8-・カラフルなボールが”GUIアプリ”に(機能タグ)
9-  orbScriptでGUIアプリケーションも!数学学習での視覚化などに便利!
10-・たまにはカラフルなボールを”楽しむ”
11-  カラフルなボールの周りをぐるぐる回るスクリーンセーバで楽しむ!
5+ -カラフルなボールで”整理”する
6+ -サムネイル表示のファイルを半透明のカラフルなボールで見通しよく整理できる!
7+ -orbScriptでメタデータを用いた分類や検索ができる!
8+ -カラフルなボールが”GUIアプリケーション”に
9+ -orbScriptで数学学習での視覚化などに便利なGUIアプリケーションもできる!
10+ -カラフルなボールで”楽しむ”
11+ -カラフルなボールの周りを動くスクリーンセーバを楽しむ!
1212
1313
1414
@@ -22,7 +22,7 @@
2222 1-2.orbSAT:orb Sector Allocation Table
2323 -連続していないセクタを管理するときに使用
2424 -例:0x00000800 0x00001000 0x0000fff1 0x00000000
25- =>0x800番目の次が0x1000番目、0xfff1番目が最後(つまりディスクは128MB)
25+ =>0x800番目の次が0x1000番目、0xfff1番目が最後(つまりディスクは32MB使われている)
2626 -このテーブルはデータ領域を対象とする(0x00001e00-0x00001fffまでを1番目とする)
2727
2828 1-3.データ領域の構造
@@ -33,7 +33,7 @@
3333
3434 1-3-1.メタデータの構造
3535 -この部分は次のようなテキストデータである(先頭の" + "は引用文であることを示す)
36- + Type=file
36+ + Type=File
3737 + CreateDate=2010/1/1
3838 + CreateTime=12:29:06
3939 + UpdateDate=2010/1/1
@@ -45,10 +45,10 @@
4545
4646 1-4.mkorbfs:ディスクイメージツール
4747 >mkorbfs orbspace.img 131072 orbspace\ipl.bin \
48- file orbspace\orbspace.sys \
49- tag orbspace Color=0xff0000 \
50- tag orbfs Color=0x00ff00 \
51- file [orbspace]orbspace\main.c Author=tatsu Keyword=orbspace \
52- file [orbspace][orbfs]orbspace\orbfs.c Author=tatsu Keyword=orbspace \
53- ftag search.orb Color=0x0000ff
48+ +File orbspace\orbspace.sys \
49+ +Ball orbspace Color=0xff0000 \
50+ +Ball orbfs Color=0x00ff00 \
51+ +File [orbspace]orbspace\main.c Author=tatsu Keyword=orbspace \
52+ +File [orbspace][orbfs]orbspace\orbfs.c Author=tatsu Keyword=orbspace \
53+ +Func search.orb Color=0x0000ff
5454 >
--- haribote/trunk/orbspace/Makefile (revision 193)
+++ haribote/trunk/orbspace/Makefile (revision 194)
@@ -1,7 +1,15 @@
1+MKORBFS = mkorbfs/mkorbfs.exe
2+
13 default:
24 make -C mkorbfs
35 make -C orbspace
6+ make orbspace.img
47
8+orbspace.img: $(MKORBFS) orbspace\ipl.bin Makefile
9+ $(MKORBFS) orbspace.img 131072 orbspace\ipl.bin \
10+ +File orbspace\ipl.bin Author=tatsu Keyword=orbspace \
11+ +File orbspace.txt Author=tatsu Keyword=orbspace
12+
513 clean:
614 make -C mkorbfs clean
715 make -C orbspace clean
--- haribote/trunk/orbspace/orbspace/orbfs.h (revision 193)
+++ haribote/trunk/orbspace/orbspace/orbfs.h (revision 194)
@@ -1 +1,10 @@
11 #include "io.h"
2+
3+struct entry {
4+ unsigned int size;
5+ unsigned char name[12], meta[496];
6+};
7+
8+void orbfs_init(void);
9+int orbfs_create(unsigned char *name, unsigned int size, unsigned char *fbuf);
10+int orbfs_meta_add(unsigned char *name, unsigned char *str);
--- haribote/trunk/orbspace/orbspace/orbfs.c (revision 193)
+++ haribote/trunk/orbspace/orbspace/orbfs.c (revision 194)
@@ -0,0 +1,175 @@
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/Makefile (revision 193)
+++ haribote/trunk/orbspace/orbspace/Makefile (revision 194)
@@ -8,5 +8,7 @@
88 $(NASK) ipl.nas ipl.bin ipl.lst
99
1010 clean:
11+ del ipl.bin
12+ del ipl.lst
1113 del *.obj
1214 del *.map
--- haribote/trunk/orbspace/orbspace/io.h (revision 193)
+++ haribote/trunk/orbspace/orbspace/io.h (revision 194)
@@ -0,0 +1,2 @@
1+int io_read(unsigned char *buf, unsigned int addr, unsigned int size);
2+int io_write(unsigned char *buf, unsigned int addr, unsigned int size);
Show on old repository browser