Mercurial > hg > Members > kono > os9 > sbc09
comparison src/vdisk.c @ 157:dc4c7e7ec5c9
some free makes error on Linux
author | kono |
---|---|
date | Mon, 21 Jan 2019 01:00:29 +0900 |
parents | 97a597b0afcd |
children | a4aa3ec95b75 |
comparison
equal
deleted
inserted
replaced
156:61b475820ea1 | 157:dc4c7e7ec5c9 |
---|---|
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 | |
25 Byte pmmu[8]; // process dat mmu | 24 Byte pmmu[8]; // process dat mmu |
26 | 25 |
27 extern char *prog ; // for disass | 26 extern char *prog ; // for disass |
28 #ifdef USE_MMU | 27 #ifdef USE_MMU |
29 extern Byte * mem0(Byte *iphymem, Word adr, Byte *immu) ; | 28 extern Byte * mem0(Byte *iphymem, Word adr, Byte *immu) ; |
93 pd->dir = 0; | 92 pd->dir = 0; |
94 pd->use = 0; | 93 pd->use = 0; |
95 pd->fp = 0; | 94 pd->fp = 0; |
96 pd->mode = 0; | 95 pd->mode = 0; |
97 free(pd->dirfp); pd->dirfp = 0; | 96 free(pd->dirfp); pd->dirfp = 0; |
98 free(pd->name); pd->name = 0; | 97 // free(pd->name); pd->name = 0; |
99 } | 98 } |
100 | 99 |
101 /* | 100 /* |
102 * keep track current directory ( most recently 256 entry ) | 101 * keep track current directory ( most recently 256 entry ) |
103 * too easy approach | 102 * too easy approach |
204 name[i] = 0; | 203 name[i] = 0; |
205 // skip trailing space | 204 // skip trailing space |
206 while(*p==' ') p++; | 205 while(*p==' ') p++; |
207 } | 206 } |
208 char *name1 = addCurdir(name,pd,curdir); | 207 char *name1 = addCurdir(name,pd,curdir); |
209 if (name1!=name && path!=name) free(name); | 208 if (name1!=name && path!=name) { |
209 free(name); | |
210 } | |
210 if (name1==0) return 0; | 211 if (name1==0) return 0; |
211 pd->name = name1; | 212 pd->name = name1; |
212 if(vdiskdebug&2) { | 213 if(vdiskdebug&2) { |
213 printf(" remain = \""); | 214 printf(" remain = \""); |
214 char *p1 = p; int max=31; | 215 char *p1 = p; int max=31; |
380 * only dir command accesses this using undocumented getstat fdinfo command | 381 * only dir command accesses this using undocumented getstat fdinfo command |
381 */ | 382 */ |
382 static int | 383 static int |
383 filedescriptor(Byte *buf, int len, Byte *name,int curdir) { | 384 filedescriptor(Byte *buf, int len, Byte *name,int curdir) { |
384 int err = 0x255; | 385 int err = 0x255; |
385 PathDesc pd; | 386 PathDesc pd; pd.name = 0; |
386 if (len<13) return -1; | 387 if (len<13) return -1; |
387 checkFileName((char*)name,&pd,curdir); | 388 if (checkFileName((char*)name,&pd,curdir)==0) goto err1; |
388 struct stat st; | 389 struct stat st; |
389 if (stat(pd.name,&st)!=0) goto err1; | 390 if (stat(pd.name,&st)!=0) goto err1; |
390 os9setmode(buf+FD_ATT,st.st_mode); | 391 os9setmode(buf+FD_ATT,st.st_mode); |
391 buf[FD_OWN]=(st.st_uid&0xff00)>>8; | 392 buf[FD_OWN]=(st.st_uid&0xff00)>>8; |
392 buf[FD_OWN+1]=st.st_uid&0xff; | 393 buf[FD_OWN+1]=st.st_uid&0xff; |
397 buf[FD_SIZ+2]=(st.st_size&0xff00)>>8; | 398 buf[FD_SIZ+2]=(st.st_size&0xff00)>>8; |
398 buf[FD_SIZ+3]=st.st_size&0xff; | 399 buf[FD_SIZ+3]=st.st_size&0xff; |
399 os9setdate(buf+FD_Creat,&st.st_ctime); | 400 os9setdate(buf+FD_Creat,&st.st_ctime); |
400 err = 0; | 401 err = 0; |
401 err1: | 402 err1: |
402 free(pd.name); | 403 // free(pd.name); should be free |
403 return err; | 404 return err; |
404 } | 405 } |
405 | 406 |
406 /* | 407 /* |
407 * undocumented getstat command | 408 * undocumented getstat command |
534 * B = errcode | 535 * B = errcode |
535 */ | 536 */ |
536 case 0xd2: | 537 case 0xd2: |
537 mode = *areg; | 538 mode = *areg; |
538 attr = *breg; | 539 attr = *breg; |
539 pd->fp = 0; | 540 pd->fp = 0; pd->name = 0; |
540 path = (char*)pmem(xreg); | 541 path = (char*)pmem(xreg); |
541 next = checkFileName(path,pd,curdir); | 542 next = checkFileName(path,pd,curdir); |
542 *breg = 0xff; | 543 *breg = 0xff; |
543 if (next!=0) { | 544 if (next!=0) { |
544 struct stat buf; | 545 struct stat buf; |