annotate vdisk.c @ 44:b26c23331d02

add more function on vdisk
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 19 Jul 2018 11:31:17 +0900
parents 7a83a6a1685a
children 07c84761da6f
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>
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
19 #ifdef USE_MMU
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
20 extern char *prog ; // for disass
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
21 extern Byte * mem0(Byte *iphymem, Word adr, Byte *immu) ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
22 #define pmem(a) mem0(phymem,a,mmu)
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
23 #define umem(a) (mem[0x41+IOPAGE]?mem0(phymem,a,&mem[0x21+IOPAGE]):mem0(phymem,a,&mem[0x20+IOPAGE]))
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
24 #else
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
25 #define pmem(a) (&mem[a])
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
26 #define umem(a) (&mem[a])
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
27 #endif
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
28
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
29 #define MAXPDV 256
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
30
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
31 typedef struct pathDesc {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
32 char *name;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
33 FILE *fp;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
34 int mode;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
35 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
36 int num ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
37 char use ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
38 char dir;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
39 char *fd ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
40 char *dirfp;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
41 } PathDesc, *PathDescPtr;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
44 PathDesc pdv[MAXPDV];
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
45
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
46 PathDesc *findPD() {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
47 for(int i=0;i<MAXPDV;i++) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
48 if (!pdv[i].use) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
49 pdv[i].use = 1;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
50 pdv[i].num = i;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
51 pd[i].mode = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
52 pd[i].fp = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
53 pd[i].dirfp = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
54 pd[i].name = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
55 pd[i].fd = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
56 return &pdv[i];
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
57 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
58 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
59 return 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
60 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
61
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
62 void closepd(PathDesc *pd) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
63 int err = fclose(pd->fp) ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
64 pd->use = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
65 pd->fp = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
66 pd->mode = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
67 free(pd->dirfp); pd->dirfp = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
68 free(pd->name); pd->name = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
69 free(pd->fd); pd->fd = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
70 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 #define MAXPAHTLEN 256
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
74 char *addCurdir(char *name, PathDesc *curdir) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
75 int ns = strlen(name);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
76 int ps = ns;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
77 int ds=0 ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
78 if (curdir==0 && name[0]!='/') return 0; // no current directory
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
79 if (name[0]!='/') ps += (ds=strlen(curdir->name))+1;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
80 char *path = (char*)malloc(ps+1);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
81 int i = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
82 if (ds) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
83 for(;i<ds;i++) path[i] = curdir->name[i];
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
84 path[i++] = '/';
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
85 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
86 for(int j=0;j<ns;j++,i++) path[i] = name[j];
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
87 path[i++] = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
88 return path;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
89 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
90
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
91 char * checkFileName(char *path, PathDesc *pd, PathDesc *curdir) {
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 char *p = path;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
93 char *name = path;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 int maxlen = MAXPAHTLEN;
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 while(*p!=0 && (*p&80)==0 && maxlen-->0) p++;
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 if (maxlen==MAXPAHTLEN) return 0;
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 if (*p!=0) {
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
98 name = (char *)malloc(p-path+1);
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 strncpy(path,p, MAXPAHTLEN-maxlen);
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 }
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
101 char *name1 = addCurdir(name,curdir);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
102 if (name1!=name && name1!=path) free(name);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
103 pd->name = name1;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 return p;
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
107 void os9setmode(char &os9mode,int mode) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
108 char m = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
109 if (mode&S_IFDIR) m|=0x80;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
110 if (mode&S_IRUSR) m|=0x01;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
111 if (mode&S_IWUSR) m|=0x02;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
112 if (mode&S_IXUSR) m|=0x04;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
113 if (mode&S_IROTH) m|=0x08;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
114 if (mode&S_IWOTH) m|=0x10;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
115 if (mode&S_IXOTH) m|=0x20;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
116 m|=0x60; // always sharable
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
117 *os9mode = m;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
120 char * os9toUnixAttr(Byte attr) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
121 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
122 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
123 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
124 return "r";
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 /*
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
128 * os9 file descriptor
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
129 * * File Descriptor Format
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
130 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
131 * 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
132 * 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
133 * and segment information on a file.
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
134 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
135 * ORG 0
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
136 *FD.ATT RMB 1 Attributes
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
137 *FD.OWN RMB 2 Owner
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
138 *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
139 *FD.LNK RMB 1 Link count
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
140 *FD.SIZ RMB 4 File size
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
141 *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
142 *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
143 * Segment List Entry Format
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
144 ORG 0
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
145 * 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
146 * FDSL.B RMB 2 Segment size
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
147 * 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
148 * 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
149 * 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
150 * MINSEC SET 16
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
151 */
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
153 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
154 * os9 directory structure
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
155 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
156 * ORG 0
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
157 *DIR.NM RMB 29 File name
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
158 *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
159 *DIR.SZ EQU . Directory record size
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
160 */
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
163 /* read direcotry entry */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
164 int os9opendir(PathDesc pd) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
165 DIR *dir;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
166 struct dirent *dp;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
167 dir = opendir(pd->name);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
168 pd->name=fname;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
169 int dircount = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
170 while ((dp = readdir(dirp)) != NULL) dircout++; // pass 1 to determine the size
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
171 if (dircount==0) return 0; // should contains . and .. at least
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
172 pd->sz = dircount*DIR_SZ
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
173 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
174 rewinddir(dir);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
175 int i = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
176 while ((dp = readdir(dirp)) != NULL) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
177 i += DIR_SZ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
178 if (i>pd->SZ) return 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
179 int j = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
180 for(j = 0; j < DIR_NM ; j++) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
181 if (j< dp->d_namlen)
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
182 pd->dirfp[j] = dp->d_name[j];
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
183 else
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
184 pd->dirfp[j] = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
185 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
186 pd->dirfp[j] = (d_ino&0xff0000)>>16;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
187 pd->dirfp[j+1] = (d_ino&0xff00)>>8;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
188 pd->dirfp[j+2] = d_ino&0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
189 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
190 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
191 return 0;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
193
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
195 /* read file descriptor of Path Desc
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
196 * create file descriptor sector if necessary
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
197 * if buf!=0, copy it
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
198 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
199 int filedescriptor(Byte *buf, int len, PathDesc *pd) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
200 struct stat st;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
201 if (pd->fd) return 1;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
202 pd->fd = (char *)malloc(256);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
203 stat((pd->name,&st);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
204 os9setmode(pd->fd,st.st_mode);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
205 pd->fd+FD_OWN=(st.st_uid&0xff00)>>8;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
206 pd->fd+FD_OWN+1=st.st_uid&0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
207 os9setdate(pd->fd,st.st_mtimespec);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
208 pd->fd+FD_LNK+0=(st.st_uid&0xff000000)>>24;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
209 pd->fd+FD_LNK+1=(st.st_uid&0xff0000)>>16;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
210 pd->fd+FD_LNK+2=(st.st_uid&0xff00)>>8;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
211 pd->fd+FD_LNK+3=st.st_nlink&0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
212 os9setdate(pd->fd,st.st_ctimespec);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
213 // dummy segment list
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
214 for(int i=0x10 ; i < 256; i++) pd->fd[i] = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
215 return 0;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
218 /* 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
219 * 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
220 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
221 * 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
222 * 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
223 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
224 int fdinfo(Byte *buf,int len, int inode) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
225 int i;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
226 for(i=0;i<MAXPDV;i++) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
227 PathDesc *pd = pdv+i;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
228 if (!pd->use || !pd->dir) continue;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
229 // find inode in directory
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
230 char *dir = (char *)pd->dirfp;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
231 while( dir < dir + pd->sz ) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
232 Byte *p = (Byte *)(dir + DIR_NM);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
233 int dinode = (p[0]<<16)+(p[1]<<8)+p[2];
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
234 if (inode == dir) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
235 filedescriptor(buf,len,pd);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
236 return 1;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
237 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
238 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 }
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
240 return 0;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 /*
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
244 * 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
245 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
246 * name or buffer, can be in a user map, pmem check that drive number ( mem[0x41+IOPAGE] 0 sys 1 user )
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
247 * current directory path number mem[0x42+IOPAGE]
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
248 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
249 void do_vdisk(Byte cmd) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
250 int err;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
251 PathDesc *pd = pdv + *areg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
252 PathDesc *curdir = pdv+mem[0x42+IOPAGE];
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
253 Byte mode,attr ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
254 char *path,*next,*buf;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
255
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
256 switch(cmd) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
257 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
258 * I$Create Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
259 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
260 * Entry: A = access mode desired
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
261 * B = file attributes
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
262 * X = address of the pathlist
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
263 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
264 * Exit: A = pathnum
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
265 * X = last byte of pathlist address
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
266 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
267 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
268 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
269 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
270 case 0xd1:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
271 pd = findPD();
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
272 if (pd==0) { *breg = 0xff; break; }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
273 mode = *areg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
274 attr = *breg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
275 path = (char *)pmem(xreg);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
276 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
277 pd->dir = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
278 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
279 if (next!=0 && pd->fp ) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
280 xreg += ( next - path );
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
281 pd->use = 1;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
282 } else {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
283 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
284 free(pd->name);
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 break;
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 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
289 * I$Open Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
290 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
291 * Entry: A = access mode desired
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
292 * X = address of the pathlist
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
293 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
294 * Exit: A = pathnum
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
295 * X = last byte of pathlist address
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
296 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
297 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
298 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
299 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
300 case 0xd2:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
301 pd = findPD();
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
302 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
303 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
304 mode = *areg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
305 attr = *breg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
306 pd->fp = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
307 path = (char*)pmem(xreg);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
308 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
309 if (next!=0) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
310 struct stat buf;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
311 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
312 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
313 pd->dir = 1;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
314 os9opendir(pd);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
315 } else {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
316 char *fname;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
317 pd->dir = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
318 if (curdir==0 && name[0]!='/') return 0; // no current directory
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
319 pd->fp = fopen( fname=findfile(pd->name,curdir),"r+");
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
320 free(fname);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
321 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
322 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
323 if (next!=0 && pd->fp !=0) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
324 *areg = pd->num;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
325 xreg += ( next - path );
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
326 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
328
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
329 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
330 * I$MakDir Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
331 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
332 * Entry: X = address of the pathlist
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
333 * B = directory attributes
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
334 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
335 * 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
336 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
337 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
338 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
339 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
340
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
341 case 0xd3:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
342 pd = findPD();
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
343 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
344 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
345 path = (char*)pmem(xreg);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
346 next = checkFileName(path,pd,curdir);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
347 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
348 xreg += ( next - path );
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
349 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
350 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
351 closepd(pd);
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
353
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
354 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
355 * I$ChgDir Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
356 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
357 * 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
358 * 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
359 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
360 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
361 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
362 * *areg = access mode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
363 * 0 = Use any special device capabilities
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
364 * 1 = Read only
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
365 * 2 = Write only
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
366 * 3 = Update (read and write)
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
367 * Entry: X = address of the pathlist
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
368 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
369 * 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
370 * A = open directory Path Number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
371 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
372 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
373 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
374 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
375 case 0xd4:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
376 pd = findPD();
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
377 if (pd==0) { *breg = 0xff; break; }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
378 path = (char*)pmem(xreg);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
379 next = checkFileName(path,pd,curdir);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
380 if (next!=0 && os9opendir(pd)) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
381 if (curdir!=pd) closepd(curdir);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
382 if (pd->name != path) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
383 free(path);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
384 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
385 xreg += ( next - path );
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
386 *areg = pd->num;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
387 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
388 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
389 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
390 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
391 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
392
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
393 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
394 * I$Delete Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
395 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
396 * Entry:
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 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
399 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
400 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
401 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
402 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
403 case 0xd5: {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
404 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
405 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
406 struct stat st;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
407 path = (char*)pmem(xreg);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
408 next = checkFileName(path,pd,curdir);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
409 if (next!=0 && stat(pd->name,&st)!=0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
410 if (next!=0 && ((st->st_mode&S_IFDIR)?rmdir(pd->name):unlink(pd->name)) == 0) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
411 xreg += ( next - path );
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
412 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
413 }
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 break;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
416
44
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 * I$Seek Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
419 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
420 * Entry Conditions
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
421 * A path number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
422 * X MS 16 bits of the desired file position
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
423 * Y LS 16 bits of the desired file position
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
424 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
425 * Exit:
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 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
428 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
429 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
430 case 0xd6: {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
431 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
432 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
433 off_t seek = (xreg<<16)+yreg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
434 *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
435 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
436 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
437 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
438 * I$ReadLn Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
439 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
440 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
441 * Entry Conditions in correct mmu map
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
442 * A path number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
443 * 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
444 * 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
445 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
446 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
447 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
448 * Y number of bytes read
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
449 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
450 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
451 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
452 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
453 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
454 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
455 case 0xd7:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
456 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
457 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
458 if (pd->dir) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
459 buf = (char*)pmem(xreg);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
460 if (fgets(buf,yreg,pd->fp)) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
461 int len = yreg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
462 int i;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
463 for(i=0;i<len && buf[i];i++);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
464 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
465 buf[i-1] = '\r';
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
466 yreg = i;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
467 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
468 *breg = 0;
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 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
471
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
472 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
473 * I$Read Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
474 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
475 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
476 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
477 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
478 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
479 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
480 * B = errcode
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 case 0xd8:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
483 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
484 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
485 buf = (char*)pmem(xreg);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
486 err = fread(buf,yreg,1,pd->fp);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
487 *breg = err==0?0xff:0 ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
488 yreg = err ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
489 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
490
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
491 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
492 * I$WritLn Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
493 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
494 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
495 * A path number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
496 * 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
497 * 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
498
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
499 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
500 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
501 * Y number of bytes written
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
502 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
503 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
504 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
505 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
506 case 0xd9:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
507 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
508 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
509 if (pd->dir) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
510 int len = yreg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
511 int i = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
512 Byte *buf = pmem(xreg);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
513 while(len>0 && *buf !='\r') {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
514 fputc(buf[i++],pd->fp);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
515 len--;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
516 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
517 if (buf[i]=='\r') {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
518 fputc('\n',pd->fp);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
519 i++;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
520 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
521 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
522 yreg = i;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
523 break;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
524
44
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 * I$Write Entry Point
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 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
529 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
530 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
531 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
532 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
533 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
534 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
535 case 0xda :
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
536 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
537 if (!pd->dir) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
538 Byte *buf = pmem(xreg);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
539 int len = yreg;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
540 int err = fwrite(buf,len,1,pd->fp);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
541 *breg = err?0xff:0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
542 yreg = err;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
543 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 break;
44
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 /* I$Close Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
547 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
548 * Entry: A = path number
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
549 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
550 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
551 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
552 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
553 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
554 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
555 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
556 case 0xdb:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
557 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
558 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
559 closepd(pd);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
560 *breg = 0;
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
561 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
562
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
563 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
564 * I$GetStat Entry Point
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
565 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
566 * Entry:
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 * Exit:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
569 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
570 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
571 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
572 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
573 case 0xdc: {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
574 struct stat st;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
575 off_t pos;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
576 switch (*breg) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
577 case 01: // SS.Ready
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
578 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
579 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
580 fstat(fileno(pd->fp),&st);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
581 if ((pos = ftell(pd->fp))) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
582 xreg = st.st_size - pos;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
583 *breg = 0;
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 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
586 case 02: // SS.SIZ
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
587 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
588 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
589 fstat(fileno(pd->fp),&st);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
590 xreg = st.st_size ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
591 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
592 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
593 case 05: // SS.Pos
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
594 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
595 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
596 xreg = ftell(pd->fp);
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
597 *breg = 0;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
598 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
599 case 15: // SS.FD
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
600 /* 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
601 * Entry: R$A=Path #
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
602 * R$B=SS.FD ($0F)
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
603 * 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
604 * R$Y=# bytes of FD required
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
605 * this should be handled in vrbf
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 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
608 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
609 *breg = filedescriptor(pmem(xreg), yreg,pd) ;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
610 break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
611 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
612 /* 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
613 * on drive.
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
614 * Entry: R$A=Path #
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
615 * R$B=SS.FDInf ($20)
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
616 * 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
617 * R$Y= MSB - Length of read
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
618 * LSB - MSB of logical sector #
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
619 * R$U= LSW of logical sector #
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
620 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
621 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
622 if (pd==0) break;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
623 *breg = fdinfo(pmem(xreg),yreg,xreg*0x10000+ureg,pd);
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 default:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
626 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
627 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
628 break;
44
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
629 }
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
630
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
631 /*
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
632 * I$SetStat Entry Point
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 * Entry:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
635 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
636 * Exit:
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 *
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
639 * Error: CC Carry set
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
640 * B = errcode
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
641 */
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
642 case 0xdd:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
643 switch (*breg) {
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
644 case 0: // SS.Opt
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
645 case 02: // SS.SIZ
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
646 case 15: // SS.FD
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
647 case 0x11: // SS.Lock
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
648 case 0x10: // SS.Ticks
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
649 case 0x20: // SS.RsBit
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
650 case 0x1c: // SS.Attr
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
651 default:
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
652 *breg = 0xff;
b26c23331d02 add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 43
diff changeset
653 }
43
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 break;
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
655 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
656 }
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
657
7a83a6a1685a vdisk start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
658