Mercurial > hg > Members > kono > os9 > sbc09
comparison src/vdisk.c @ 158:a4aa3ec95b75
fix addCurrent
author | kono |
---|---|
date | Mon, 21 Jan 2019 10:39:50 +0900 |
parents | dc4c7e7ec5c9 |
children | b93996f54090 |
comparison
equal
deleted
inserted
replaced
157:dc4c7e7ec5c9 | 158:a4aa3ec95b75 |
---|---|
19 #include <fcntl.h> | 19 #include <fcntl.h> |
20 #include <sys/types.h> | 20 #include <sys/types.h> |
21 | 21 |
22 static int vdiskdebug = 0; // bit 1 trace, bit 2 filename | 22 static int vdiskdebug = 0; // bit 1 trace, bit 2 filename |
23 | 23 |
24 Byte pmmu[8]; // process dat mmu | |
25 | |
26 extern char *prog ; // for disass | 24 extern char *prog ; // for disass |
27 #ifdef USE_MMU | 25 #ifdef USE_MMU |
26 Byte pmmu[8]; // process dat mmu | |
27 | |
28 extern Byte * mem0(Byte *iphymem, Word adr, Byte *immu) ; | 28 extern Byte * mem0(Byte *iphymem, Word adr, Byte *immu) ; |
29 // smem physical address using system mmu | 29 // smem physical address using system mmu |
30 // pmem physical address using caller's mmu | 30 // pmem physical address using caller's mmu |
31 #define smem(a) mem0(phymem,a,&mem[0x20+IOPAGE]) | 31 #define smem(a) mem0(phymem,a,&mem[0x20+IOPAGE]) |
32 #define pmem(a) mem0(phymem,a,pmmu) | 32 #define pmem(a) mem0(phymem,a,pmmu) |
92 pd->dir = 0; | 92 pd->dir = 0; |
93 pd->use = 0; | 93 pd->use = 0; |
94 pd->fp = 0; | 94 pd->fp = 0; |
95 pd->mode = 0; | 95 pd->mode = 0; |
96 free(pd->dirfp); pd->dirfp = 0; | 96 free(pd->dirfp); pd->dirfp = 0; |
97 // free(pd->name); pd->name = 0; | 97 free(pd->name); pd->name = 0; |
98 } | 98 } |
99 | 99 |
100 /* | 100 /* |
101 * keep track current directory ( most recently 256 entry ) | 101 * keep track current directory ( most recently 256 entry ) |
102 * too easy approach | 102 * too easy approach |
171 } | 171 } |
172 char *path = (char*)malloc(ps); | 172 char *path = (char*)malloc(ps); |
173 int i = 0; | 173 int i = 0; |
174 for(;base[i];i++) path[i] = base[i]; | 174 for(;base[i];i++) path[i] = base[i]; |
175 path[i++] = '/'; | 175 path[i++] = '/'; |
176 for(int j=0;i<ps;j++,i++) path[i] = name[j]; | 176 for(int j=0;i<ps-1;j++,i++) path[i] = name[j]; |
177 path[i] = 0; | 177 path[i] = 0; |
178 if (i>ps) | 178 if (i>ps) |
179 printf("overrun i=%d ps=%d\n",i,ps); // err(__LINE__); | 179 printf("overrun i=%d ps=%d\n",i,ps); // err(__LINE__); |
180 return path; | 180 return path; |
181 } | 181 } |
355 pd->dirfp[i+j+2] = dp->d_ino&0xff; | 355 pd->dirfp[i+j+2] = dp->d_ino&0xff; |
356 i += DIR_SZ; | 356 i += DIR_SZ; |
357 if (i>pd->sz) | 357 if (i>pd->sz) |
358 return 0; | 358 return 0; |
359 } | 359 } |
360 pd->fp = fmemopen(pd->dirfp,pd->sz,"r"); | 360 pd->fp = fmemopen(pd->dirfp,pd->sz+1,"r"); |
361 return 0; | 361 return 0; |
362 } | 362 } |
363 | 363 |
364 static void | 364 static void |
365 os9setdate(Byte *d,time_t * unixtime) { | 365 os9setdate(Byte *d,time_t * unixtime) { |
398 buf[FD_SIZ+2]=(st.st_size&0xff00)>>8; | 398 buf[FD_SIZ+2]=(st.st_size&0xff00)>>8; |
399 buf[FD_SIZ+3]=st.st_size&0xff; | 399 buf[FD_SIZ+3]=st.st_size&0xff; |
400 os9setdate(buf+FD_Creat,&st.st_ctime); | 400 os9setdate(buf+FD_Creat,&st.st_ctime); |
401 err = 0; | 401 err = 0; |
402 err1: | 402 err1: |
403 // free(pd.name); should be free | 403 free(pd.name); |
404 return err; | 404 return err; |
405 } | 405 } |
406 | 406 |
407 /* | 407 /* |
408 * undocumented getstat command | 408 * undocumented getstat command |
923 ureg = getword(frame+8); | 923 ureg = getword(frame+8); |
924 pcreg = getword(frame+10)-3; // point os9 swi2 | 924 pcreg = getword(frame+10)-3; // point os9 swi2 |
925 prog = (char*)(pmem(pcreg) - pcreg); | 925 prog = (char*)(pmem(pcreg) - pcreg); |
926 if (*pmem(pcreg)==0 && *pmem(pcreg+1)==0) { | 926 if (*pmem(pcreg)==0 && *pmem(pcreg+1)==0) { |
927 // may be we are called from system state | 927 // may be we are called from system state |
928 // of coursel, this may wrong. but in system state, <$50 process has wrong DAT for pc | 928 // of course, this may wrong. but in system state, <$50 process has wrong DAT for pc |
929 // and we can't know wether we are called from system or user | 929 // and we can't know wether we are called from system or user |
930 prog = (char*)(smem(pcreg) - pcreg); | 930 prog = (char*)(smem(pcreg) - pcreg); |
931 } | 931 } |
932 do_trace(fp); | 932 do_trace(fp); |
933 } | 933 } |