annotate vdisk.c @ 49:947cbecdd8d5

read and dir worked. exec failed
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 21 Jul 2018 19:25:53 +0900
parents ea1b17311bf3
children 1430678cd4fb
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>
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
20 static int vdiskdebug = 1; // 1 trace, 2 filename
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
22 extern char *prog ; // for disass
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
23 #ifdef USE_MMU
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
24 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
25 // smem physical address using system mmu
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
26 // umem physical address using caller's mmu
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
27 #define smem(a) mem0(phymem,a,&mem[0x20+IOPAGE])
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
28 #define umem(a) (mem[0x42+IOPAGE]?mem0(phymem,a,&mem[0x28+IOPAGE]):mem0(phymem,a,&mem[0x20+IOPAGE]))
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
29 #else
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
30 #define umem(a) (&mem[a])
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
31 #define smem(a) (&mem[a])
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
32 #endif
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
33
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
34 #define MAXPDV 256
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
35
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
36
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
37 typedef struct pathDesc {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
38 char *name;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
39 FILE *fp;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
40 int mode;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
41 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
42 int num ;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
43 int sz ; // used only for directory
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
44 char drv ;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
45 char use ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
46 char dir;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
47 char *fd ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
48 char *dirfp;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
49 } PathDesc, *PathDescPtr;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
51 static void
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
52 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
53
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
54 #define MAXVDRV 4
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
56 static char *drvRoot[] = { ".",".",".","."};
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
57 static PathDesc pdv[MAXPDV];
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
58
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
59 /*
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
60 * us 0 system
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
61 * 1 caller
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
62 */
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
63 static inline Word
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
64 getword(Byte *adr) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
65 Word *padr = (Word*)adr;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
66 return ntohs(*padr);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
67 }
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
68
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
69 static inline void
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
70 setword(Byte *adr,Word value) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
71 Word *padr = (Word*)adr;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
72 *padr = htons(value);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
73 }
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
74
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
75 static int
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
76 setVdisk(int drv,char *name) {
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
77 if (drv<0 || drv>=MAXVDRV) return -1;
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
78 drvRoot[drv] = name;
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
79 return 0;
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
80 }
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
81
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
82 static void
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
83 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
84 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
85 pd->dir = 0;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
86 pd->use = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
87 pd->fp = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
88 pd->mode = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
89 free(pd->dirfp); pd->dirfp = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
90 free(pd->name); pd->name = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
91 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
93 /*
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
94 * 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
95 * too easy approach
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
96 */
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
97 char *cdt[512];
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
98 static int cdtptr = 0;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
99
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
100 Byte
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
101 setcd(char *name) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
102 int len;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
103 for(int i=0;i<256;i++) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
104 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
105 }
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
106 cdtptr &= 0xff;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
107 if (cdt[cdtptr]) free(cdt[cdtptr]);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
108 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
109 strcpy(cdt[cdtptr],name);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
110 return cdtptr++;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
111 }
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
112
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 #define MAXPAHTLEN 256
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
115 static void
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
116 putOs9str(char *s) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
117 if (s==0) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
118 printf("(null)");
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
119 return;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
120 }
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
121 while(*s && *s>=' ' && ((*s&0x80)==0)) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
122 putchar(*s); s++;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
123 }
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
124 if (*s&0x80) putchar(*s&0x7f);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
125 }
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
126
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
127 static char *
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
128 addCurdir(char *name, PathDesc *pd, int curdir) {
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
129 int ns =0 ;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
130 char *n = name;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
131 if(vdiskdebug&0x2) { printf("addcur \""); putOs9str(name); printf("\" cur \""); putOs9str( cdt[curdir]); printf("\"\n"); }
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
132 if (name[0]=='/') {
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
133 name++; while(*name !='/' && *name!=0) name ++ ; // skip /d0
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
134 while(name[ns]!=0) ns++;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
135 } 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
136 else ns = strlen(name);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
137 int ps = ns;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
138 char *base ;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
139 if (name[0]=='/') {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
140 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
141 } 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
142 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
143 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
144 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
145 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
146 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
147 return path;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
148 } else {
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
149 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
150 }
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
151 char *path = (char*)malloc(ps);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
152 int i = 0;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
153 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
154 path[i++] = '/';
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
155 for(int j=0;j<ps;j++,i++) path[i] = name[j];
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
156 path[i++] = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
157 return path;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
158 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
159
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
160 static char *
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
161 checkFileName(char *path, PathDesc *pd, int curdir) {
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 char *p = path;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
163 char *name = path;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 int maxlen = MAXPAHTLEN;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
165 if(vdiskdebug) { printf("checkf \""); putOs9str(name); printf("\"\n"); }
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
166 while(*p!=0 && (*p&0x80)==0 && (*p>0x1f) && maxlen-->0) p++;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 if (maxlen==MAXPAHTLEN) return 0;
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 if (*p!=0) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
169 name = (char *)malloc(p-path+1);
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
170 strncpy(name,path, MAXPAHTLEN-maxlen);
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
171 name[MAXPAHTLEN-maxlen-1] &= 0x7f;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
172 name[MAXPAHTLEN-maxlen] = 0;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 }
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
174 char *name1 = addCurdir(name,pd,curdir);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
175 if (name1!=name && name1!=path) free(name);
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
176 if (name1==0) return 0;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
177 pd->name = name1;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
178 if(vdiskdebug) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
179 printf(" remain = \"");
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
180 char *p1 = p;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
181 while(*p1 && (*p1&0x80)==0 ) { if (*p1<0x20) printf("(0x%02x)",*p1); else putchar(*p1); p1++; }
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
182 if (*p1) { if ((*p1&0x7f)<0x20) printf("(0x%02x)",*p1); else putchar(*p1&0x7f); }
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
183 printf("\" checkname result \""); putOs9str(pd->name); printf("\"\n");
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
184 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 return p;
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
187
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
188 static void
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
189 os9setmode(char *os9mode,int mode) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
190 char m = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
191 if (mode&S_IFDIR) m|=0x80;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
192 if (mode&S_IRUSR) m|=0x01;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
193 if (mode&S_IWUSR) m|=0x02;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
194 if (mode&S_IXUSR) m|=0x04;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
195 if (mode&S_IROTH) m|=0x08;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
196 if (mode&S_IWOTH) m|=0x10;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
197 if (mode&S_IXOTH) m|=0x20;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
198 m|=0x60; // always sharable
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
199 *os9mode = m;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
202 static char *
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
203 os9toUnixAttr(Byte attr) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
204 if ((attr&0x1) && (attr&0x2)) return "r+";
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
205 if (!(attr&0x1) && (attr&0x2)) return "w";
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
206 if ((attr&0x1) && !(attr&0x2)) return "r";
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
207 return "r";
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
209
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 /*
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
211 * os9 file descriptor
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
212 * * File Descriptor Format
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
213 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
214 * 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
215 * 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
216 * and segment information on a file.
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
217 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
218 * ORG 0
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
219 *FD.ATT RMB 1 Attributes
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
220 *FD.OWN RMB 2 Owner
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
221 *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
222 *FD.LNK RMB 1 Link count
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
223 *FD.SIZ RMB 4 File size
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
224 *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
225 *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
226 * Segment List Entry Format
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
227 ORG 0
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
228 * 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
229 * FDSL.B RMB 2 Segment size
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
230 * 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
231 * 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
232 * 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
233 * MINSEC SET 16
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
234 */
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
236 #define FD_ATT 0
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
237 #define FD_OWN 1
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
238 #define FD_DAT 3
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
239 #define FD_LNK 8
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
240 #define FD_SIZ 9
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
241 #define FD_Creat 13
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
242 #define FD_SEG 16
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
243
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
244
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
245 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
246 * os9 directory structure
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
247 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
248 * ORG 0
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
249 *DIR.NM RMB 29 File name
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
250 *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
251 *DIR.SZ EQU . Directory record size
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
252 */
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
253 #define DIR_SZ 32
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
254 #define DIR_NM 29
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
255
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
256
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
257 /* read direcotry entry */
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
258 static int
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
259 os9opendir(PathDesc *pd) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
260 DIR *dir;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
261 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
262 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
263 dir = opendir(pd->name);
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
264 if (dir==0) return -1;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
265 int dircount = 0;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
266 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
267 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
268 pd->sz = dircount*DIR_SZ;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
269 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
270 rewinddir(dir);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
271 int i = 0;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
272 while ((dp = readdir(dir)) != NULL) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
273 int j = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
274 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
275 if (j< dp->d_namlen) {
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
276 pd->dirfp[i+j] = dp->d_name[j]&0x7f;
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
277 if (j== dp->d_namlen-1)
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
278 pd->dirfp[i+j] |= 0x80; // os9 EOL
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
279 } else
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
280 pd->dirfp[i+j] = 0;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
281 }
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
282 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
283 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
284 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
285 i += DIR_SZ;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
286 if (i>pd->sz) return 0;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
287 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
288 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
289 return 0;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
291
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
292 static void
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
293 os9setdate(char *d,struct timespec * unixtime) {
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
294 // yymmddhhss
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
295 struct tm r;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
296 localtime_r(&unixtime->tv_sec,&r);
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
297 d[0] = r.tm_year-2000;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
298 d[1] = r.tm_mon;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
299 d[2] = r.tm_mday;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
300 d[3] = r.tm_hour;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
301 d[4] = r.tm_min;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
302 d[5] = r.tm_sec;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
303 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
304
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
305 /* read file descriptor of Path Desc
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
306 * create file descriptor sector if necessary
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
307 * if buf!=0, copy it
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
308 */
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
309 static int
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
310 filedescriptor(Byte *buf, int len, PathDesc *pd) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
311 struct stat st;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
312 if (pd->fd) return 1;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
313 pd->fd = (char *)malloc(256);
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
314 stat(pd->name,&st);
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
315 os9setmode(pd->fd+FD_ATT,st.st_mode);
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
316 pd->fd[FD_OWN]=(st.st_uid&0xff00)>>8;
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
317 pd->fd[FD_OWN+1]=st.st_uid&0xff;
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
318 os9setdate(pd->fd + FD_DAT,&st.st_mtimespec);
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
319 pd->fd[FD_LNK]=st.st_nlink&0xff;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
320 pd->fd[FD_SIZ+0]=(st.st_size&0xff000000)>>24;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
321 pd->fd[FD_SIZ+1]=(st.st_size&0xff0000)>>16;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
322 pd->fd[FD_SIZ+2]=(st.st_size&0xff00)>>8;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
323 pd->fd[FD_SIZ+3]=st.st_size&0xff;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
324 os9setdate(pd->fd+FD_Creat,&st.st_ctimespec);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
325 // dummy segment list
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
326 for(int i=FD_SEG ; i < 256; i++) pd->fd[i] = 0;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
327 return 0;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
329
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
330 /* read direcotry entry for any file in the directory
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
331 * 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
332 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
333 * 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
334 * 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
335 */
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
336 static int
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
337 fdinfo(Byte *buf,int len, int inode, PathDesc *pd) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
338 int i;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
339 for(i=0;i<MAXPDV;i++) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
340 PathDesc *pd = pdv+i;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
341 if (!pd->use || !pd->dir) continue;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
342 // find inode in directory
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
343 char *dir = (char *)pd->dirfp;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
344 char *end = (char *)pd->dirfp + pd->sz;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
345 while( dir < end ) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
346 Byte *p = (Byte *)(dir + DIR_NM);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
347 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
348 if (inode == dinode) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
349 filedescriptor(buf,len,pd);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
350 return 1;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
351 }
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
352 dir += 0x20;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
353 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 }
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
355 return 0;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
357
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 /*
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
359 * 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
360 *
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
361 * 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
362 * 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
363 * yreg has pd number
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
364 */
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
365 void
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
366 do_vdisk(Byte cmd) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
367 int err;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
368 int curdir = mem[0x44+IOPAGE]; // garbage until set
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
369 Byte attr ;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
370 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
371 Byte *frame = smem(u);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
372 xreg = getword(frame+4);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
373 yreg = getword(frame+6);
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
374 *areg = *smem(u+1);
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
375 *breg = *smem(u+2);
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
376 Byte mode = 0;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
377 Byte *os9pd = smem(getword(&mem[0x47+IOPAGE]));
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
378 PathDesc *pd = pdv+*os9pd;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
379 pd->num = *os9pd;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
380 pd->drv = mem[0x41+IOPAGE];
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
381 char *path,*next,*buf;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
382 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
383
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
384 switch(cmd) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
385 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
386 * I$Create Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
387 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
388 * Entry: A = access mode desired
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
389 * B = file attributes
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
390 * X = address of the pathlist
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
391 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
392 * Exit: A = pathnum
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
393 * X = last byte of pathlist address
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
394 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
395 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
396 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
397 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
398 case 0xd1:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
399 mode = *areg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
400 attr = *breg;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
401 path = (char *)umem(xreg);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
402 next = pd->name = checkFileName(path,pd,curdir);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
403 pd->dir = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
404 pd->fp = fopen(pd->name, os9toUnixAttr(attr));
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
405 if (next!=0 && pd->fp ) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
406 xreg += ( next - path );
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
407 pd->use = 1;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
408 } else {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
409 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
410 free(pd->name);
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
411 pd->use = 0;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
414
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
415 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
416 * I$Open Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
417 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
418 * Entry: A = access mode desired
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
419 * X = address of the pathlist
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
420 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
421 * Exit: A = pathnum
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
422 * X = last byte of pathlist address
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
423 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
424 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
425 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
426 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
427 case 0xd2:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
428 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
429 mode = *areg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
430 attr = *breg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
431 pd->fp = 0;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
432 path = (char*)umem(xreg);
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
433 next = checkFileName(path,pd,curdir);
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
434 *breg = 0xff;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
435 if (next!=0) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
436 struct stat buf;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
437 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
438 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
439 pd->dir = 1;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
440 os9opendir(pd);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
441 } else {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
442 pd->dir = 0;
45
07c84761da6f dd vrbf asm code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 44
diff changeset
443 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
444 }
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
445 pd->use = 1;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
446 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
447 if (next!=0 && pd->fp !=0) {
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
448 *breg = 0;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
449 *areg = pd->num;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
450 *smem(u+1) = *areg ;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
451 xreg += ( next - path );
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
452 pd->use = 1;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
453 } else {
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
454 pd->use = 0;
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
455 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
457
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
458 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
459 * I$MakDir Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
460 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
461 * Entry: X = address of the pathlist
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
462 * B = directory attributes
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
463 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
464 * 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
465 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
466 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
467 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
468 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
469
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
470 case 0xd3:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
471 *breg = 0xff;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
472 path = (char*)umem(xreg);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
473 next = checkFileName(path,pd,curdir);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
474 if (next!=0 && mkdir(pd->name,0)!= 0 ) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
475 xreg += ( next - path );
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
476 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
477 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
478 closepd(pd);
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
479 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
480
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
481 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
482 * I$ChgDir Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
483 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
484 * 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
485 * 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
486 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
487 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
488 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
489 * *areg = access mode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
490 * 0 = Use any special device capabilities
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
491 * 1 = Read only
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
492 * 2 = Write only
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
493 * 3 = Update (read and write)
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
494 * Entry: X = address of the pathlist
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
495 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
496 * 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
497 * A = open directory Path Number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
498 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
499 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
500 * B = errcode
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
501 *
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
502 *
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
503 * we keep track a cwd and a cxd for a process using 8bit id
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
504 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
505 case 0xd4:
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
506 path = (char*)umem(xreg);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
507 next = checkFileName(path,pd,curdir);
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
508 if (next!=0) {
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
509 struct stat buf;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
510 if (stat(pd->name,&buf)!=0) break;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
511 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
512 xreg += ( next - path );
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
513 *areg = setcd(pd->name);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
514 *smem(u+1) = *areg ;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
515 pd->use = 1;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
516 pd->dir = 1;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
517 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
518 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
519 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
520 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
521 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
522
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 * I$Delete Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
525 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
526 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
527 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
528 * Exit:
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 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
531 * B = errcode
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 case 0xd5: {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
534 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
535 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
536 struct stat st;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
537 path = (char*)umem(xreg);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
538 next = checkFileName(path,pd,curdir);
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
539 pd->use = 0;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
540 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
541 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
542 xreg += ( next - path );
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
543 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
544 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
545 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
546 break;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
547
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
548 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
549 * I$Seek Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
550 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
551 * Entry Conditions
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
552 * A path number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
553 * 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
554 * 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
555 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
556 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
557 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
558 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
559 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
560 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
561 case 0xd6: {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
562 *breg = 0xff;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
563 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
564 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
565 *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
566 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
567 }
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 * I$ReadLn Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
570 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
571 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
572 * Entry Conditions in correct mmu map
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
573 * A path number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
574 * 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
575 * 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
576 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
577 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
578 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
579 * Y number of bytes read
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
580 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
581 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
582 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
583 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
584 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
585 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
586 case 0xd7:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
587 *breg = 0xff;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
588 buf = (char*)umem(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
589 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
590 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
591 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
592 *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
593 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
594 }
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
595 int i;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
596 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
597 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
598 buf[i-1] = '\r';
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
599 yreg = i;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
600 }
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
601 // set y
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
602 setword(smem(u+6),yreg);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
603 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
604 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
605 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
606
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
607 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
608 * I$Read Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
609 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
610 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
611 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
612 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
613 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
614 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
615 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
616 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
617 case 0xd8:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
618 *breg = 0xff;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
619 buf = (char*)umem(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
620 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
621 // set y
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
622 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
623 *breg = (i==0?0xd3:0) ;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
624 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
625
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
626 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
627 * I$WritLn Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
628 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
629 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
630 * A path number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
631 * 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
632 * 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
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 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
636 * Y number of bytes written
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
637 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
638 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
639 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
640 */
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
641 case 0xd9: {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
642 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
643 if (pd->dir) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
644 int len = yreg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
645 int i = 0;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
646 Byte *buf = umem(xreg);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
647 while(len>0 && *buf !='\r') {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
648 fputc(buf[i++],pd->fp);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
649 len--;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
650 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
651 if (buf[i]=='\r') {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
652 fputc('\n',pd->fp);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
653 i++;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
654 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
655 *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
656 // set y
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
657 setword(smem(u+6),i);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
658 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
659 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
660
44
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 * I$Write Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
663 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
664 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
665 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
666 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
667 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
668 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
669 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
670 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
671 case 0xda :
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
672 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
673 if (!pd->dir) {
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
674 Byte *buf = umem(xreg);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
675 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
676 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
677 *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
678 // set y
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
679 setword(smem(u+6),err);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
680 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
681 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
682
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
683 /* I$Close Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
684 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
685 * Entry: A = path number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
686 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
687 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
688 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
689 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
690 * B = errcode
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 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
693 case 0xdb:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
694 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
695 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
696 closepd(pd);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
697 *breg = 0;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
698 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
699
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
700 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
701 * I$GetStat Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
702 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
703 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
704 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
705 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
706 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
707 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
708 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
709 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
710 case 0xdc: {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
711 struct stat st;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
712 off_t pos;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
713 switch (*breg) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
714 case 01: // SS.Ready
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
715 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
716 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
717 fstat(fileno(pd->fp),&st);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
718 if ((pos = ftell(pd->fp))) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
719 xreg = st.st_size - pos;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
720 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
721 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
722 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
723 case 02: // SS.SIZ
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
724 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
725 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
726 fstat(fileno(pd->fp),&st);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
727 xreg = st.st_size ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
728 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
729 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
730 case 05: // SS.Pos
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
731 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
732 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
733 xreg = ftell(pd->fp);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
734 *breg = 0;
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 case 15: // SS.FD
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
737 /* 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
738 * Entry: R$A=Path #
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
739 * R$B=SS.FD ($0F)
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
740 * 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
741 * R$Y=# bytes of FD required
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
742 * this should be handled in vrbf
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
743 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
744 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
745 if (pd==0) break;
47
15f1e1b49928 open dir worked ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 46
diff changeset
746 *breg = filedescriptor(umem(xreg), yreg,pd) ;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
747 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
748 case 0x20: // Pos.FDInf mandatry for dir command
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
749 /* 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
750 * on drive.
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
751 * Entry: R$A=Path #
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
752 * R$B=SS.FDInf ($20)
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
753 * 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
754 * R$Y= MSB - Length of read
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
755 * LSB - MSB of logical sector #
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
756 * R$U= LSW of logical sector #
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
757 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
758 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
759 if (pd==0) break;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
760 ureg = getword(smem(u+8));
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
761 *breg = fdinfo(umem(xreg),yreg,xreg*0x10000+ureg,pd);
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
762 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
763 default:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
764 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
765 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
766 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
767 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
768
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
769 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
770 * I$SetStat Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
771 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
772 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
773 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
774 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
775 *
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 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
778 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
779 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
780 case 0xdd:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
781 switch (*breg) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
782 case 0: // SS.Opt
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
783 case 02: // SS.SIZ
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
784 case 15: // SS.FD
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
785 case 0x11: // SS.Lock
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
786 case 0x10: // SS.Ticks
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
787 case 0x20: // SS.RsBit
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
788 case 0x1c: // SS.Attr
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
789 default:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
790 *breg = 0xff;
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;
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
793 }
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
794 // return value
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
795 mem[0xffc0] = *breg;
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
796 *smem(u+2) = *breg ;
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
797 setword(smem(u+4),xreg);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
798 }
46
ec9f494497e1 vdisk fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 45
diff changeset
799
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
800 static void
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
801 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
802 char *cd = cdt[curdir]?cdt[curdir]:"(null)";
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
803 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
804 Byte *frame = smem(u);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
805 sreg = u;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
806 ccreg = frame[0];
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
807 *areg = frame[1];
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
808 *breg = frame[2];
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
809 xreg = getword(frame+4);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
810 yreg = getword(frame+6);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
811 ureg = getword(frame+8);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
812 pcreg = getword(frame+10)-3;
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
813 prog = (char*)(umem(pcreg) - pcreg);
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
814 do_trace(fp);
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
815 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
816
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
817
49
947cbecdd8d5 read and dir worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 48
diff changeset
818 /* end */