# HG changeset patch # User Shinji KONO # Date 1531984907 -32400 # Node ID 07c84761da6f315033643a6862fbdcf84c46a343 # Parent b26c23331d02a6657babd8c79ca331f333204304 dd vrbf asm code diff -r b26c23331d02 -r 07c84761da6f io.c --- a/io.c Thu Jul 19 11:31:17 2018 +0900 +++ b/io.c Thu Jul 19 16:21:47 2018 +0900 @@ -71,10 +71,11 @@ * IOPAGE + 0x31- YY/MM/DD/HH/MM/SS * * IOPAGE + 0x40 Disk control 0x81 read/0x55 write 0 ... ok / 0xff .. error - * IOPAGE + 0x41 drive no / ( VDISK 0 for system, 1 for user ) - * IOPAGE + 0x42 LSN2 - * IOPAGE + 0x43 LSN1 - * IOPAGE + 0x44 LSN0 + * 0xd1- VDISK command + * IOPAGE + 0x41 drive no / VDISK drv + * IOPAGE + 0x42 LSN2 / VDISK sysmode 0 for system, 1 for user + * IOPAGE + 0x43 LSN1 / VDISK Curdir pd number + * IOPAGE + 0x44 LSN0 / VDISK file attribute * IOPAGE + 0x45 ADR2 * IOPAGE + 0x46 ADR1 * diff -r b26c23331d02 -r 07c84761da6f os9/level2/vrbf.asm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os9/level2/vrbf.asm Thu Jul 19 16:21:47 2018 +0900 @@ -0,0 +1,343 @@ +******************************************************************** +* Virtual RBF - Random Block File Manager +* + + nam VRBF + ttl VRandom Block File Manager + + ifp1 + use defsfile + endc + +rev set $00 +ty set FlMgr + IFNE H6309 +lg set Obj6309 + ELSE +lg set Objct + ENDC +tylg set ty+lg +atrv set ReEnt+rev +edition set 37 + + org $00 +size equ . + + mod eom,name,tylg,atrv,start,size + +name fcs /VRBF/ + fcb edition + +*L0012 fcb DRVMEM + + +**************************** +* +* Main entry point for RBF +* +* Entry: Y = Path descriptor pointer +* U = Register stack pointer + +start bra Create + nop + lbra Open + lbra MakDir + lbra ChgDir + lbra Delete + lbra Seek + lbra Read + lbra Write + lbra ReadLn + lbra WriteLn + lbra GetStat + lbra SetStat + lbra Close + + +* +* I$Create Entry Point +* +* Entry: A = access mode desired (0 read, 1 write, 2 update, bit 4 for exex) +* B = file attributes +* X = address of the pathlist +* +* Exit: A = pathnum +* X = last byte of pathlist address +* +* Error: CC Carry set +* B = errcode +* +Create pshs y,u Preserve path desc ptr + sta PD.MOD,y + bsr setuppd + stb 4,u put file attribute + ldb #$d0 + stb ,u + ldb ,u + beq ok00 +err00 orcc #$1 +ok00 pull y,u,pc + +setuppd pshs x + ldu #$FFc0 vdisk port + lda =MAXVDRV) return -1; + drvRoot[drv] = name; + return 0; +} + PathDesc *findPD() { for(int i=0;iname))+1; + char *base ; + if (name[0]!='/') { base = curdir->name; ps += strlen(curdir->name)+1; } + else { base = drvRoot[pd->drv]; ps += strlen(drvRoot[pd->drv])+1; } char *path = (char*)malloc(ps+1); int i = 0; - if (ds) { - for(;iname[i]; - path[i++] = '/'; - } + for(;base[i];i++) path[i] = base[i]; + path[i++] = '/'; for(int j=0;jname = name1; return p; } -void os9setmode(char &os9mode,int mode) { +void os9setmode(char *os9mode,int mode) { char m = 0; if (mode&S_IFDIR) m|=0x80; if (mode&S_IRUSR) m|=0x01; @@ -150,6 +160,15 @@ * MINSEC SET 16 */ +#define FD_ATT 0 +#define FD_OWN 1 +#define FD_DAT 3 +#define FD_LNK 8 +#define FD_SIZ 9 +#define FD_Creat 13 +#define FD_SEG 16 + + /* * os9 directory structure * @@ -158,24 +177,25 @@ *DIR.FD RMB 3 File descriptor physical sector number *DIR.SZ EQU . Directory record size */ +#define DIR_SZ 32 +#define DIR_NM 29 /* read direcotry entry */ -int os9opendir(PathDesc pd) { +int os9opendir(PathDesc *pd) { DIR *dir; struct dirent *dp; dir = opendir(pd->name); - pd->name=fname; int dircount = 0; - while ((dp = readdir(dirp)) != NULL) dircout++; // pass 1 to determine the size + while ((dp = readdir(dir)) != NULL) dircount++; // pass 1 to determine the size if (dircount==0) return 0; // should contains . and .. at least - pd->sz = dircount*DIR_SZ + pd->sz = dircount*DIR_SZ; pd->dirfp = (char *)malloc(dircount*DIR_SZ); rewinddir(dir); int i = 0; - while ((dp = readdir(dirp)) != NULL) { + while ((dp = readdir(dir)) != NULL) { i += DIR_SZ; - if (i>pd->SZ) return 0; + if (i>pd->sz) return 0; int j = 0; for(j = 0; j < DIR_NM ; j++) { if (j< dp->d_namlen) @@ -183,14 +203,17 @@ else pd->dirfp[j] = 0; } - pd->dirfp[j] = (d_ino&0xff0000)>>16; - pd->dirfp[j+1] = (d_ino&0xff00)>>8; - pd->dirfp[j+2] = d_ino&0xff; + pd->dirfp[j] = (dp->d_ino&0xff0000)>>16; + pd->dirfp[j+1] = (dp->d_ino&0xff00)>>8; + pd->dirfp[j+2] = dp->d_ino&0xff; } pd->fp = fmemopen(pd->dirfp,pd->sz,"r"); return 0; } +void os9setdate(char *d,struct timespec * unixtime) { + // yymmddhhss +} /* read file descriptor of Path Desc * create file descriptor sector if necessary @@ -200,18 +223,18 @@ struct stat st; if (pd->fd) return 1; pd->fd = (char *)malloc(256); - stat((pd->name,&st); - os9setmode(pd->fd,st.st_mode); - pd->fd+FD_OWN=(st.st_uid&0xff00)>>8; - pd->fd+FD_OWN+1=st.st_uid&0xff; - os9setdate(pd->fd,st.st_mtimespec); - pd->fd+FD_LNK+0=(st.st_uid&0xff000000)>>24; - pd->fd+FD_LNK+1=(st.st_uid&0xff0000)>>16; - pd->fd+FD_LNK+2=(st.st_uid&0xff00)>>8; - pd->fd+FD_LNK+3=st.st_nlink&0xff; - os9setdate(pd->fd,st.st_ctimespec); + stat(pd->name,&st); + os9setmode(pd->fd+FD_ATT,st.st_mode); + pd->fd[FD_OWN]=(st.st_uid&0xff00)>>8; + pd->fd[FD_OWN+1]=st.st_uid&0xff; + os9setdate(pd->fd + FD_DAT,&st.st_mtimespec); + pd->fd[FD_LNK+0]=(st.st_uid&0xff000000)>>24; + pd->fd[FD_LNK+1]=(st.st_uid&0xff0000)>>16; + pd->fd[FD_LNK+2]=(st.st_uid&0xff00)>>8; + pd->fd[FD_LNK+3]=st.st_nlink&0xff; + os9setdate(pd->fd+FD_Creat,&st.st_ctimespec); // dummy segment list - for(int i=0x10 ; i < 256; i++) pd->fd[i] = 0; + for(int i=FD_SEG ; i < 256; i++) pd->fd[i] = 0; return 0; } @@ -221,7 +244,7 @@ * inode==0 should return disk id section * inode==bitmap should return disk sector map for os9 free command */ -int fdinfo(Byte *buf,int len, int inode) { +int fdinfo(Byte *buf,int len, int inode, PathDesc *pd) { int i; for(i=0;isz ) { Byte *p = (Byte *)(dir + DIR_NM); int dinode = (p[0]<<16)+(p[1]<<8)+p[2]; - if (inode == dir) { + if (inode == dinode) { filedescriptor(buf,len,pd); return 1; } @@ -245,11 +268,13 @@ * * name or buffer, can be in a user map, pmem check that drive number ( mem[0x41+IOPAGE] 0 sys 1 user ) * current directory path number mem[0x42+IOPAGE] + * yreg has pd number */ void do_vdisk(Byte cmd) { int err; - PathDesc *pd = pdv + *areg; - PathDesc *curdir = pdv+mem[0x42+IOPAGE]; + PathDesc *pd = pdv + yreg; + PathDesc *curdir = pdv+mem[0x43+IOPAGE]; + pd->drv = mem[0x41+IOPAGE]; Byte mode,attr ; char *path,*next,*buf; @@ -305,7 +330,7 @@ attr = *breg; pd->fp = 0; path = (char*)pmem(xreg); - next = pd->name = checkFileName(path,pd,curdir); + next = checkFileName(path,pd,curdir); if (next!=0) { struct stat buf; if (stat(pd->name,&buf)!=0) break; @@ -313,11 +338,8 @@ pd->dir = 1; os9opendir(pd); } else { - char *fname; pd->dir = 0; - if (curdir==0 && name[0]!='/') return 0; // no current directory - pd->fp = fopen( fname=findfile(pd->name,curdir),"r+"); - free(fname); + pd->fp = fopen( pd->name,os9toUnixAttr(mode)); } } if (next!=0 && pd->fp !=0) { @@ -407,7 +429,7 @@ path = (char*)pmem(xreg); next = checkFileName(path,pd,curdir); if (next!=0 && stat(pd->name,&st)!=0) break; - if (next!=0 && ((st->st_mode&S_IFDIR)?rmdir(pd->name):unlink(pd->name)) == 0) { + if (next!=0 && ((st.st_mode&S_IFDIR)?rmdir(pd->name):unlink(pd->name)) == 0) { xreg += ( next - path ); *breg = 0; }