annotate src/vdisk.c @ 152:97a597b0afcd

Linux version
author kono
date Thu, 17 Jan 2019 16:54:05 +0900
parents ef5959682d03
children dc4c7e7ec5c9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /********************************************************************
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 * Virtual RBF - Random Block File Manager
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 *
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 * Shinji KONO (kono@ie.u-ryukyu.ac.jp) 2018/7/17
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 * GPL v1 license
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 */
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
8 #define engine extern
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
9 #include "v09.h"
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #include <stdio.h>
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 #include <stdlib.h>
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #include <unistd.h>
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #include <sys/stat.h>
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #include <sys/select.h>
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
15 #include <dirent.h>
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
16 #include <string.h>
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
17 #include <time.h>
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
18 #include <arpa/inet.h>
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
19 #include <fcntl.h>
151
ef5959682d03 fix for linux
kono
parents: 150
diff changeset
20 #include <sys/types.h>
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
62
5b3871f8bdaa remove debug log
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 61
diff changeset
22 static int vdiskdebug = 0; // bit 1 trace, bit 2 filename
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
24
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
25 Byte pmmu[8]; // process dat mmu
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
26
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
27 extern char *prog ; // for disass
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
28 #ifdef USE_MMU
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
29 extern Byte * mem0(Byte *iphymem, Word adr, Byte *immu) ;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
30 // smem physical address using system mmu
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
31 // pmem physical address using caller's mmu
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
32 #define smem(a) mem0(phymem,a,&mem[0x20+IOPAGE])
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
33 #define pmem(a) mem0(phymem,a,pmmu)
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
34 #else
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
35 #define smem(a) (&mem[a])
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
36 #define pmem(a) (&mem[a])
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
37 #endif
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
38
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
39 #define MAXPDV 256
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
40
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
41 /*
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
42 * os9 has one path descriptor for one open file or directory
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
43 * keep coresponding information in vdisk file manager
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
44 */
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
45
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
46 typedef struct pathDesc {
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
47 char *name; // path name relative to drvRoot
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
48 FILE *fp; // file , memfile for directory
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
49 int mode;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
50 int inode ; // lower 24 bit of unix inode, os9 lsn
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
51 int num ;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
52 int sz ; // used only for directory
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
53 char drv ;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
54 char use ;
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
55 char dir; // is directory?
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
56 char *fd ; // simulated os9 file descriptor ( not used now)
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
57 char *dirfp; // simulated os9 directory file
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
58 } PathDesc, *PathDescPtr;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
60 static void
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
61 vdisklog(Word u,PathDesc *pd, Word pdptr, int curdir,FILE *fp) ;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
62
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
63 #define MAXVDRV 4
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
65 static char *drvRoot[] = { ".",".",".","."};
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
66 static PathDesc pdv[MAXPDV];
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
67
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
68 /*
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
69 * byte order staff
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
70 */
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
71 static inline Word
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
72 getword(Byte *adr) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
73 Word *padr = (Word*)adr;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
74 return ntohs(*padr);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
75 }
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
76
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
77 static inline void
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
78 setword(Byte *adr,Word value) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
79 Word *padr = (Word*)adr;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
80 *padr = htons(value);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
81 }
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
82
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
83 int
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
84 setVdisk(int drv,char *name) {
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
85 if (drv<0 || drv>=MAXVDRV) return -1;
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
86 drvRoot[drv] = name;
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
87 return 0;
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
88 }
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
89
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
90 static void
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
91 closepd(PathDesc *pd) {
48
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
92 if(pd->fp) fclose(pd->fp) ;
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
93 pd->dir = 0;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
94 pd->use = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
95 pd->fp = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
96 pd->mode = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
97 free(pd->dirfp); pd->dirfp = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
98 free(pd->name); pd->name = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
99 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
101 /*
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
102 * keep track current directory ( most recently 256 entry )
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
103 * too easy approach
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
104 *
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
105 * dir command keep old directory LSN, so we have to too
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
106 */
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
107 char *cdt[512];
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
108 static int cdtptr = 0;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
109
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
110 Byte
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
111 setcd(char *name) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
112 int len;
51
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
113 for(int i=0;i<512;i++) {
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
114 if (cdt[i] && strcmp(name,cdt[i])==0) return i;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
115 }
51
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
116 cdtptr &= 0x1ff;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
117 if (cdt[cdtptr]) free(cdt[cdtptr]);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
118 cdt[cdtptr] = (char*)malloc(len=strlen(name)+1);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
119 strcpy(cdt[cdtptr],name);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
120 return cdtptr++;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
121 }
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
122
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 #define MAXPAHTLEN 256
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
125 /*
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
126 * print os9 string for debug
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
127 */
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
128 static void
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
129 putOs9str(char *s,int max) {
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
130 if (s==0) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
131 printf("(null)");
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
132 return;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
133 }
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
134 while(*s && (*s&0x7f)>=' ' && ((*s&0x80)==0) && --max !=0) {
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
135 putchar(*s); s++;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
136 }
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
137 if (*s&0x80) putchar(*s&0x7f);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
138 }
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
139
51
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
140 static void
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
141 err(int error) {
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
142 printf("err %d\n",error);
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
143 }
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
144
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
145 /*
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
146 * add current directory name to the path
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
147 * if name starts /v0, drvRoot will be add
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
148 */
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
149 static char *
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
150 addCurdir(char *name, PathDesc *pd, int curdir) {
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
151 int ns =0 ;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
152 char *n = name;
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
153 if(vdiskdebug&0x2) { printf("addcur \""); putOs9str(name,0); printf("\" cur \""); putOs9str( cdt[curdir],0); printf("\"\n"); }
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
154 if (name[0]=='/') {
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
155 name++; while(*name !='/' && *name!=0) name ++ ; // skip /d0
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
156 while(name[ns]!=0) ns++;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
157 } else if (!cdt[curdir] ) return 0; // no current directory
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
158 else ns = strlen(name);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
159 int ps = ns;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
160 char *base ;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
161 if (name[0]=='/') {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
162 base = drvRoot[pd->drv]; ps += strlen(drvRoot[pd->drv])+1; name++;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
163 } else if (name[0]==0) {
48
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
164 base = drvRoot[pd->drv];
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
165 char *path = (char*)malloc(strlen(base)+1); // we'll free this, malloc it.
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
166 int i = 0;
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
167 for(;base[i];i++) path[i] = base[i];
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
168 path[i]=0;
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
169 return path;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
170 } else {
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
171 base = cdt[curdir]; ps += strlen(cdt[curdir])+2;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
172 }
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
173 char *path = (char*)malloc(ps);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
174 int i = 0;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
175 for(;base[i];i++) path[i] = base[i];
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
176 path[i++] = '/';
51
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
177 for(int j=0;i<ps;j++,i++) path[i] = name[j];
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
178 path[i] = 0;
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
179 if (i>ps)
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
180 printf("overrun i=%d ps=%d\n",i,ps); // err(__LINE__);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
181 return path;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
182 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
183
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
184 /*
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
185 * os9 file name may contains garbage such as 8th bit on or traling space
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
186 * fix it. and make the pointer to next path for the return value
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
187 *
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
188 * pd->name will be freed, we have to malloc it
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
189 */
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
190 static char *
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
191 checkFileName(char *path, PathDesc *pd, int curdir) {
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 char *p = path;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
193 char *name = path;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 int maxlen = MAXPAHTLEN;
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
195 if(vdiskdebug&2) { printf("checkf \""); putOs9str(name,0); printf("\"\n"); }
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
196 while(*p!=0 && (*p&0x80)==0 && (*p&0x7f)>' ' && maxlen-->0) p++;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 if (maxlen==MAXPAHTLEN) return 0;
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
198 if (*p) { // 8th bit termination or non ascii termination
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
199 int eighth = ((*p&0x80)!=0);
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
200 name = (char *)malloc(p-path+1+eighth);
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
201 int i;
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
202 for(i=0;i<p-path;i++) name[i] = path[i];
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
203 if (eighth) { name[i] = path[i]&0x7f; p++ ; i++; }
51
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
204 name[i] = 0;
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
205 // skip trailing space
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
206 while(*p==' ') p++;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 }
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
208 char *name1 = addCurdir(name,pd,curdir);
71
eb9be32c701c fix leval
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
209 if (name1!=name && path!=name) free(name);
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
210 if (name1==0) return 0;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
211 pd->name = name1;
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
212 if(vdiskdebug&2) {
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
213 printf(" remain = \"");
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
214 char *p1 = p; int max=31;
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
215 while(*p1 && (*p1&0x80)==0 && max-->0) { if (*p1<0x20) printf("(0x%02x)",*p1); else putchar(*p1); p1++; }
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
216 if (*p1) { if ((*p1&0x7f)<0x20) printf("(0x%02x)",*p1); else putchar(*p1&0x7f); }
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
217 printf("\" checkname result \""); putOs9str(pd->name,0); printf("\"\n");
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
218 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 return p;
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
222 /*
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
223 * os9 / unix mode conversion
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
224 */
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
225 static void
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
226 os9setmode(Byte *os9mode,int mode) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
227 char m = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
228 if (mode&S_IFDIR) m|=0x80;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
229 if (mode&S_IRUSR) m|=0x01;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
230 if (mode&S_IWUSR) m|=0x02;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
231 if (mode&S_IXUSR) m|=0x04;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
232 if (mode&S_IROTH) m|=0x08;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
233 if (mode&S_IWOTH) m|=0x10;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
234 if (mode&S_IXOTH) m|=0x20;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
235 m|=0x60; // always sharable
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
236 *os9mode = m;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
239 static char *
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
240 os9toUnixAttr(Byte mode) {
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
241 if ((mode&0x1) && (mode&0x2)) return "r+";
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
242 if (!(mode&0x1) && (mode&0x2)) return "w";
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
243 if ((mode&0x1) && !(mode&0x2)) return "r";
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
244 return "r";
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
247 static int
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
248 os9mode(Byte m) {
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
249 int mode = 0;
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
250 if ((m&0x80)) mode|=S_IFDIR ;
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
251 if ((m&0x01)) mode|=S_IRUSR ;
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
252 if ((m&0x02)) mode|=S_IWUSR ;
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
253 if ((m&0x04)) mode|=S_IXUSR ;
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
254 if ((m&0x08)) mode|=S_IROTH ;
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
255 if ((m&0x10)) mode|=S_IWOTH ;
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
256 if ((m&0x20)) mode|=S_IXOTH ;
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
257 return mode;
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
258 }
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
259
150
da020c491fbb add more fmemopen mess
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
260 #ifdef NOFMEMOPEN
148
fa0fbcbccbc9 add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 71
diff changeset
261
fa0fbcbccbc9 add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 71
diff changeset
262 FILE *fmemopen(char *buf,long sz, const char *mode) {
fa0fbcbccbc9 add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 71
diff changeset
263 static char fname[] = "/tmp/myfileXXXXXX";
fa0fbcbccbc9 add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 71
diff changeset
264 int fd;
fa0fbcbccbc9 add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 71
diff changeset
265 fd = mkstemp(fname); /* Create and open temp file */
fa0fbcbccbc9 add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 71
diff changeset
266 write(fd, buf, sz); /* Write something to file */
fa0fbcbccbc9 add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 71
diff changeset
267 lseek(fd, 0L, SEEK_SET);
fa0fbcbccbc9 add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 71
diff changeset
268 FILE *fp = fdopen(fd,mode);
fa0fbcbccbc9 add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 71
diff changeset
269 unlink(fname);
fa0fbcbccbc9 add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 71
diff changeset
270 return fp;
fa0fbcbccbc9 add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 71
diff changeset
271 }
fa0fbcbccbc9 add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 71
diff changeset
272
fa0fbcbccbc9 add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 71
diff changeset
273 #endif
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
274
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 /*
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
276 * os9 file descriptor
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
277 * * File Descriptor Format
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
278 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
279 * The file descriptor is a sector that is present for every file
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
280 * on an RBF device. It contains attributes, modification dates,
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
281 * and segment information on a file.
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
282 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
283 * ORG 0
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
284 *FD.ATT RMB 1 Attributes
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
285 *FD.OWN RMB 2 Owner
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
286 *FD.DAT RMB 5 Date last modified
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
287 *FD.LNK RMB 1 Link count
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
288 *FD.SIZ RMB 4 File size
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
289 *FD.Creat RMB 3 File creation date (YY/MM/DD)
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
290 *FD.SEG EQU . Beginning of segment list
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
291 * Segment List Entry Format
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
292 ORG 0
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
293 * FDSL.A RMB 3 Segment beginning physical sector number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
294 * FDSL.B RMB 2 Segment size
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
295 * FDSL.S EQU . Segment list entry size
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
296 * FD.LS1 EQU FD.SEG+((256-FD.SEG)/FDSL.S-1)*FDSL.S
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
297 * FD.LS2 EQU (256/FDSL.S-1)*FDSL.S
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
298 * MINSEC SET 16
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
299 */
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
300
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
301 #define FD_ATT 0
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
302 #define FD_OWN 1
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
303 #define FD_DAT 3
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
304 #define FD_LNK 8
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
305 #define FD_SIZ 9
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
306 #define FD_Creat 13
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
307 #define FD_SEG 16
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
308
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
309
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
310 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
311 * os9 directory structure
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
312 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
313 * ORG 0
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
314 *DIR.NM RMB 29 File name
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
315 *DIR.FD RMB 3 File descriptor physical sector number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
316 *DIR.SZ EQU . Directory record size
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
317 */
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
318 #define DIR_SZ 32
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
319 #define DIR_NM 29
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
320
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
321
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
322 /* read direcotry entry
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
323 *
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
324 * create simulated os9 directory structure for dir command
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
325 * writing to the directory is not allowed
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
326 * */
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
327 static int
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
328 os9opendir(PathDesc *pd) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
329 DIR *dir;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
330 struct dirent *dp;
48
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
331 if (pd->dirfp) return 0; // already opened
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
332 dir = opendir(pd->name);
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
333 if (dir==0) return -1;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
334 int dircount = 0;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
335 while ((dp = readdir(dir)) != NULL) dircount++; // pass 1 to determine the size
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
336 if (dircount==0) return 0; // should contains . and .. at least
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
337 pd->sz = dircount*DIR_SZ;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
338 pd->dirfp = (char *)malloc(dircount*DIR_SZ);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
339 rewinddir(dir);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
340 int i = 0;
51
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
341 while ((dp = readdir(dir)) != NULL && dircount-->=0) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
342 int j = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
343 for(j = 0; j < DIR_NM ; j++) {
48
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
344 if (j< dp->d_namlen) {
152
97a597b0afcd Linux version
kono
parents: 151
diff changeset
345 pd->dirfp[i+j] = dp->d_name[j]&0x7f; // this is wrong but os9 does not allow 8th bit
97a597b0afcd Linux version
kono
parents: 151
diff changeset
346 if (j== dp->d_namlen-1 || dp->d_name[j+1]==0) {
48
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
347 pd->dirfp[i+j] |= 0x80; // os9 EOL
152
97a597b0afcd Linux version
kono
parents: 151
diff changeset
348 }
48
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
349 } else
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
350 pd->dirfp[i+j] = 0;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
351 }
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
352 pd->dirfp[i+j] = (dp->d_ino&0xff0000)>>16;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
353 pd->dirfp[i+j+1] = (dp->d_ino&0xff00)>>8;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
354 pd->dirfp[i+j+2] = dp->d_ino&0xff;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
355 i += DIR_SZ;
51
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
356 if (i>pd->sz)
498b6fcaf270 vdisk worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 50
diff changeset
357 return 0;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
358 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
359 pd->fp = fmemopen(pd->dirfp,pd->sz,"r");
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
360 return 0;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
361 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
362
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
363 static void
151
ef5959682d03 fix for linux
kono
parents: 150
diff changeset
364 os9setdate(Byte *d,time_t * unixtime) {
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
365 // yymmddhhss
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
366 struct tm r;
151
ef5959682d03 fix for linux
kono
parents: 150
diff changeset
367 localtime_r(unixtime,&r);
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
368 d[0] = r.tm_year-2048;
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
369 d[1] = r.tm_mon + 1;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
370 d[2] = r.tm_mday;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
371 d[3] = r.tm_hour;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
372 d[4] = r.tm_min;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
373 d[5] = r.tm_sec;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
374 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
375
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
376 /* read file descriptor of Path Desc
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
377 * create file descriptor sector if necessary
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
378 * if buf!=0, copy it
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
379 *
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
380 * only dir command accesses this using undocumented getstat fdinfo command
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
381 */
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
382 static int
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
383 filedescriptor(Byte *buf, int len, Byte *name,int curdir) {
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
384 int err = 0x255;
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
385 PathDesc pd;
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
386 if (len<13) return -1;
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
387 checkFileName((char*)name,&pd,curdir);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
388 struct stat st;
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
389 if (stat(pd.name,&st)!=0) goto err1;
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
390 os9setmode(buf+FD_ATT,st.st_mode);
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
391 buf[FD_OWN]=(st.st_uid&0xff00)>>8;
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
392 buf[FD_OWN+1]=st.st_uid&0xff;
151
ef5959682d03 fix for linux
kono
parents: 150
diff changeset
393 os9setdate(buf+ FD_DAT,&st.st_mtime);
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
394 buf[FD_LNK]=st.st_nlink&0xff;
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
395 buf[FD_SIZ+0]=(st.st_size&0xff000000)>>24;
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
396 buf[FD_SIZ+1]=(st.st_size&0xff0000)>>16;
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
397 buf[FD_SIZ+2]=(st.st_size&0xff00)>>8;
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
398 buf[FD_SIZ+3]=st.st_size&0xff;
151
ef5959682d03 fix for linux
kono
parents: 150
diff changeset
399 os9setdate(buf+FD_Creat,&st.st_ctime);
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
400 err = 0;
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
401 err1:
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
402 free(pd.name);
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
403 return err;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
405
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
406 /*
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
407 * undocumented getstat command
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
408 *
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
409 * read direcotry entry for *any* file in the directory
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
410 * we only returns a file descriptor only in the current opened directory
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
411 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
412 * inode==0 should return disk id section
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
413 * inode==bitmap should return disk sector map for os9 free command
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
414 */
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
415 static int
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
416 fdinfo(Byte *buf,int len, int inode, PathDesc *pd,int curdir) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
417 int i;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
418 for(i=0;i<MAXPDV;i++) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
419 PathDesc *pd = pdv+i;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
420 if (!pd->use || !pd->dir) continue;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
421 // find inode in directory
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
422 Byte *dir = (Byte*)pd->dirfp;
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
423 Byte *end = (Byte*)pd->dirfp + pd->sz;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
424 while( dir < end ) {
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
425 Byte *p = (dir + DIR_NM);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
426 int dinode = (p[0]<<16)+(p[1]<<8)+p[2];
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
427 if (inode == dinode) {
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
428 return filedescriptor(buf,len,dir,curdir);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
429 }
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
430 dir += 0x20;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
431 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 }
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
433 return 255;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
435
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
436 /*
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
437 * on os9 level 2, user process may on different memory map
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
438 * get DAT table on process descriptor on 0x50 in system page
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
439 */
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
440 void
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
441 getDAT() {
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
442 #ifdef USE_MMU
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
443 Word ps = getword(smem(0x50)); // process structure
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
444 Byte *dat = smem(ps+0x40); // process dat (dynamic address translation)
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
445 for(int i=0; i<8; i++) {
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
446 pmmu[i] = dat[i*2+1];
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
447 }
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
448 #endif
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
449 }
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
450
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
451 /*
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
452 * vdisk command processing
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
453 *
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
454 * vrbf.asm will write a command on 0x40+IOPAGE ( 0xffc0 or 0xe040)
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
455 *
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
456 * U contains caller's stack (call and return value) on 0x45+IOPAGE
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
457 * current directory (cwd or cxd) on 0x44+IOPAGE
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
458 * Path dcriptor number on 0x47+IOPAGE
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
459 * drive number on 0x41+IOPAGE
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
460 * caller's process descriptor on <0x50
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
461 *
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
462 * each command should have preallocated os9 path descriptor on Y
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
463 *
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
464 * name or buffer, can be in a user map, check that drive number ( mem[0x41+IOPAGE] 0 sys 1 user )
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
465 * current directory path number mem[0x42+IOPAGE]
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
466 * yreg has pd number
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
467 */
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
468 void
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
469 do_vdisk(Byte cmd) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
470 int err;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
471 int curdir = mem[0x44+IOPAGE]; // garbage until set
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
472 Byte attr ;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
473 Word u = getword(&mem[0x45+IOPAGE]); // caller's stack in system segment
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
474 Byte *frame = smem(u);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
475 xreg = getword(frame+4);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
476 yreg = getword(frame+6);
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
477 *areg = *smem(u+1);
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
478 *breg = *smem(u+2);
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
479 Byte mode = 0;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
480 Byte *os9pd = smem(getword(&mem[0x47+IOPAGE]));
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
481 PathDesc *pd = pdv+*os9pd;
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
482
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
483 getDAT();
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
484 pd->num = *os9pd;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
485 pd->drv = mem[0x41+IOPAGE];
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
486 char *path,*next,*buf;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
487 if (vdiskdebug&1) vdisklog(u,pd,getword(&mem[0x47+IOPAGE]),curdir,stdout);
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
488
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
489 switch(cmd) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
490 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
491 * I$Create Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
492 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
493 * Entry: A = access mode desired
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
494 * B = file attributes
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
495 * X = address of the pathlist
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
496 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
497 * Exit: A = pathnum
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
498 * X = last byte of pathlist address
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
499 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
500 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
501 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
502 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
503 case 0xd1:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
504 mode = *areg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
505 attr = *breg;
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
506 pd->fp = 0;
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
507 path = (char *)pmem(xreg);
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
508 next = checkFileName(path,pd,curdir);
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
509 *breg = 0xff;
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
510 int fd = open(pd->name, O_RDWR+O_CREAT,os9mode(attr) );
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
511 if (fd>0)
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
512 pd->fp = fdopen(fd, os9toUnixAttr(mode));
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
513 if (next!=0 && pd->fp ) {
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
514 *breg = 0;
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
515 *areg = pd->num;
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
516 *smem(u+1) = *areg ;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
517 xreg += ( next - path );
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
518 pd->use = 1;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
519 } else {
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
520 pd->use = 0;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
522 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
523
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
524 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
525 * I$Open Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
526 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
527 * Entry: A = access mode desired
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
528 * X = address of the pathlist
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
529 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
530 * Exit: A = pathnum
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
531 * X = last byte of pathlist address
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
532 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
533 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
534 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
535 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
536 case 0xd2:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
537 mode = *areg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
538 attr = *breg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
539 pd->fp = 0;
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
540 path = (char*)pmem(xreg);
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
541 next = checkFileName(path,pd,curdir);
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
542 *breg = 0xff;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
543 if (next!=0) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
544 struct stat buf;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
545 if (stat(pd->name,&buf)!=0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
546 if ((buf.st_mode & S_IFMT) == S_IFDIR) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
547 pd->dir = 1;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
548 os9opendir(pd);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
549 } else {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
550 pd->dir = 0;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
551 pd->fp = fopen( pd->name,os9toUnixAttr(mode));
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
552 }
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
553 pd->use = 1;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
554 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
555 if (next!=0 && pd->fp !=0) {
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
556 *breg = 0;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
557 *areg = pd->num;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
558 *smem(u+1) = *areg ;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
559 xreg += ( next - path );
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
560 pd->use = 1;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
561 } else {
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
562 pd->use = 0;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
563 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
564 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
565
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
566 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
567 * I$MakDir Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
568 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
569 * Entry: X = address of the pathlist
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
570 * B = directory attributes
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
571 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
572 * Exit: X = last byte of pathlist address
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
573 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
574 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
575 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
576 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
577
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
578 case 0xd3:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
579 *breg = 0xff;
63
1887f7098f15 makdir/del checked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 62
diff changeset
580 mode = *areg;
1887f7098f15 makdir/del checked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 62
diff changeset
581 attr = *breg;
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
582 path = (char*)pmem(xreg);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
583 next = checkFileName(path,pd,curdir);
63
1887f7098f15 makdir/del checked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 62
diff changeset
584 if (next!=0 && mkdir(pd->name,os9mode(attr))== 0 ) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
585 xreg += ( next - path );
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
586 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
587 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
588 closepd(pd);
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
589 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
590
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
591 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
592 * I$ChgDir Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
593 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
594 * data dir P$DIO 3-5 contains open dir Path number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
595 * exec dir P$DIO 9-11 contains open dir Path number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
596 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
597 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
598 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
599 * *areg = access mode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
600 * 0 = Use any special device capabilities
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
601 * 1 = Read only
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
602 * 2 = Write only
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
603 * 3 = Update (read and write)
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
604 * Entry: X = address of the pathlist
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
605 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
606 * Exit: X = last byte of pathlist address
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
607 * A = open directory Path Number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
608 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
609 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
610 * B = errcode
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
611 *
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
612 *
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
613 * we keep track a cwd and a cxd for a process using 8bit id
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
614 * don't use path descriptor on y
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
615 */
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
616 case 0xd4: {
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
617 PathDesc dm = *pd;
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
618 path = (char*)pmem(xreg);
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
619 next = checkFileName(path,&dm,curdir);
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
620 if (next!=0) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
621 struct stat buf;
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
622 if (stat(dm.name,&buf)!=0) break;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
623 if ((buf.st_mode & S_IFMT) != S_IFDIR) break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
624 xreg += ( next - path );
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
625 *areg = setcd(dm.name);
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
626 *smem(u+1) = *areg ;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
627 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
628 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
629 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
630 *breg = 0xff;
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
631 }
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
632 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
633
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
634 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
635 * I$Delete Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
636 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
637 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
638 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
639 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
640 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
641 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
642 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
643 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
644 case 0xd5: {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
645 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
646 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
647 struct stat st;
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
648 path = (char*)pmem(xreg);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
649 next = checkFileName(path,pd,curdir);
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
650 pd->use = 0;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
651 if (next!=0 && stat(pd->name,&st)!=0) break;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
652 if (next!=0 && ((st.st_mode&S_IFDIR)?rmdir(pd->name):unlink(pd->name)) == 0) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
653 xreg += ( next - path );
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
654 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
655 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
656 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
657 break;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
658
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
659 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
660 * I$Seek Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
661 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
662 * Entry Conditions
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
663 * A path number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
664 * X MS 16 bits of the desired file position
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
665 * U LS 16 bits of the desired file position
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
666 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
667 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
668 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
669 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
670 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
671 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
672 case 0xd6: {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
673 *breg = 0xff;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
674 ureg = (*smem(u+8)<<8)+*smem(u+9);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
675 off_t seek = (xreg<<16)+ureg;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
676 *breg = fseek(pd->fp,(off_t)seek,SEEK_SET);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
677 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
678 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
679 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
680 * I$ReadLn Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
681 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
682 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
683 * Entry Conditions in correct mmu map
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
684 * A path number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
685 * X address at which to store data
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
686 * Y maximum number of bytes to read
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
687 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
688 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
689 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
690 * Y number of bytes read
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
691 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
692 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
693 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
694 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
695 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
696 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
697 case 0xd7:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
698 *breg = 0xff;
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
699 buf = (char*)pmem(xreg);
48
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
700 char *b;
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
701 if ((b=fgets(buf,yreg,pd->fp))) {
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
702 if (b==0) {
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
703 *breg = 0xd3;
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
704 break;
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
705 }
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
706 int i;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
707 for(i=0;i<yreg && buf[i];i++);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
708 if (i>0 && buf[i-1]=='\n') {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
709 buf[i-1] = '\r';
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
710 yreg = i;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
711 }
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
712 // set y
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
713 setword(smem(u+6),yreg);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
714 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
715 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
716 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
717
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
718 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
719 * I$Read Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
720 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
721 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
722 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
723 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
724 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
725 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
726 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
727 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
728 case 0xd8:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
729 *breg = 0xff;
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
730 buf = (char*)pmem(xreg);
48
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
731 int i = fread(buf,1,yreg,pd->fp);
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
732 // set y
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
733 setword(smem(u+6),i);
48
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
734 *breg = (i==0?0xd3:0) ;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
735 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
736
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
737 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
738 * I$WritLn Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
739 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
740 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
741 * A path number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
742 * X address of the data to write
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
743 * Y maximum number of bytes to read
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
744
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
745 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
746 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
747 * Y number of bytes written
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
748 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
749 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
750 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
751 */
48
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
752 case 0xd9: {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
753 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
754 if (pd->dir) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
755 int len = yreg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
756 int i = 0;
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
757 Byte *buf = pmem(xreg);
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
758 while(len>0 && buf[i] !='\r') {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
759 fputc(buf[i++],pd->fp);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
760 len--;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
761 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
762 if (buf[i]=='\r') {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
763 fputc('\n',pd->fp);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
764 i++;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
765 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
766 *breg = 0;
48
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
767 // set y
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
768 setword(smem(u+6),i);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
769 break;
48
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
770 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
771
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
772 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
773 * I$Write Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
774 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
775 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
776 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
777 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
778 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
779 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
780 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
781 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
782 case 0xda :
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
783 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
784 if (!pd->dir) {
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
785 Byte *buf = pmem(xreg);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
786 int len = yreg;
48
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
787 int err = fwrite(buf,1,len,pd->fp);
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
788 *breg = err?0:0xff;
48
ea1b17311bf3 dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 47
diff changeset
789 // set y
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
790 setword(smem(u+6),err);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
791 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
792 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
793
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
794 /* I$Close Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
795 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
796 * Entry: A = path number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
797 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
798 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
799 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
800 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
801 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
802 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
803 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
804 case 0xdb:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
805 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
806 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
807 closepd(pd);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
808 *breg = 0;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
809 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
810
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
811 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
812 * I$GetStat Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
813 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
814 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
815 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
816 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
817 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
818 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
819 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
820 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
821 case 0xdc: {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
822 struct stat st;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
823 off_t pos;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
824 switch (*breg) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
825 case 01: // SS.Ready
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
826 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
827 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
828 fstat(fileno(pd->fp),&st);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
829 if ((pos = ftell(pd->fp))) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
830 xreg = st.st_size - pos;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
831 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
832 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
833 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
834 case 02: // SS.SIZ
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
835 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
836 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
837 fstat(fileno(pd->fp),&st);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
838 xreg = st.st_size ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
839 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
840 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
841 case 05: // SS.Pos
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
842 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
843 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
844 xreg = ftell(pd->fp);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
845 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
846 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
847 case 15: // SS.FD
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
848 /* SS.FD ($0F) - Returns a file descriptor
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
849 * Entry: R$A=Path #
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
850 * R$B=SS.FD ($0F)
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
851 * R$X=Pointer to a 256 byte buffer
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
852 * R$Y=# bytes of FD required
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
853 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
854 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
855 if (pd==0) break;
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
856 *breg = filedescriptor(pmem(xreg), yreg,(Byte*)pd->name,curdir) ;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
857 break;
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
858 case 0x20: // Pos.FDInf mandatry for dir command (undocumented, use the source)
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
859 /* SS.FDInf ($20) - Directly reads a file descriptor from anywhere
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
860 * on drive.
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
861 * Entry: R$A=Path #
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
862 * R$B=SS.FDInf ($20)
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
863 * R$X=Pointer to a 256 byte buffer
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
864 * R$Y= MSB - Length of read
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
865 * LSB - MSB of logical sector #
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
866 * R$U= LSW of logical sector #
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
867 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
868 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
869 if (pd==0) break;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
870 ureg = getword(smem(u+8));
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
871 *breg = fdinfo(pmem(xreg),(yreg&0xff),((yreg&0xff00)>>8)*0x10000+ureg,pd,curdir);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
872 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
873 default:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
874 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
875 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
876 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
877 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
878
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
879 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
880 * I$SetStat Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
881 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
882 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
883 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
884 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
885 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
886 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
887 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
888 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
889 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
890 case 0xdd:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
891 switch (*breg) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
892 case 0: // SS.Opt
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
893 case 02: // SS.SIZ
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
894 case 15: // SS.FD
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
895 case 0x11: // SS.Lock
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
896 case 0x10: // SS.Ticks
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
897 case 0x20: // SS.RsBit
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
898 case 0x1c: // SS.Attr
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
899 default:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
900 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
901 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
902 break;
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
903 }
52
51b437557f42 boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 51
diff changeset
904 if (vdiskdebug && *breg) printf(" vdisk call error %x\n",*breg);
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
905 // return value
56
4fa2bdb0c457 level vrbf and clock
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 52
diff changeset
906 mem[0x40+IOPAGE] = *breg;
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
907 *smem(u+2) = *breg ;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
908 setword(smem(u+4),xreg);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
909 }
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
910
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
911 static void
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
912 vdisklog(Word u,PathDesc *pd, Word pdptr, int curdir, FILE *fp) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
913 char *cd = cdt[curdir]?cdt[curdir]:"(null)";
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
914 fprintf(fp,"pd %d 0x%x cd[%d]=%s ",pd->num, pdptr, curdir,cd);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
915 Byte *frame = smem(u);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
916 sreg = u;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
917 ccreg = frame[0];
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
918 *areg = frame[1];
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
919 *breg = frame[2];
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
920 xreg = getword(frame+4);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
921 yreg = getword(frame+6);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
922 ureg = getword(frame+8);
59
7c6dc25c2b05 add comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 57
diff changeset
923 pcreg = getword(frame+10)-3; // point os9 swi2
50
1430678cd4fb use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 49
diff changeset
924 prog = (char*)(pmem(pcreg) - pcreg);
61
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
925 if (*pmem(pcreg)==0 && *pmem(pcreg+1)==0) {
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
926 // may be we are called from system state
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
927 // of coursel, this may wrong. but in system state, <$50 process has wrong DAT for pc
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
928 // and we can't know wether we are called from system or user
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
929 prog = (char*)(smem(pcreg) - pcreg);
80f4ec9a3420 fix writeln
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 59
diff changeset
930 }
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
931 do_trace(fp);
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
932 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
933
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
934
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
935 /* end */