A2osX/SYS/KERNEL.S.STAT.txt
2018-08-08 17:13:37 +02:00

257 lines
4.6 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
*--------------------------------------
* # FStat
* Return information about a hfile
* ## C
* `int fstat(short int hFILE, struct stat *statbuf);`
* ## ASM
* **In:**
* `>PUSHW statbuf`
* `lda hFILE`
* `>SYSCALL fstat`
* **Out:**
*--------------------------------------
K.FStat jsr PFT.CheckNodeA
jsr K.GetMemPtr
bcs .9
>STYA pFD
lda #S.FD.REG
clc
adc pFD
tay
lda /S.FD.REG
adc pFD+1
jsr K.Stat.I
bcs .99
ldy #S.FD.DIR.REF
lda (pFD),y
sta K.MLI.PARAMS+1
>MLICALL MLIGETEOF
bcs .99
ldy #S.STAT.SIZE+3
lda #0
jsr K.Stat.StoreY
ldx #2
.1 dey
lda K.MLI.PARAMS+2,x
jsr K.Stat.StoreY
dex
bpl .1
.99 rts
.9 >RET 2
*/--------------------------------------
* # Stat
* Return information about a file
* ## C
* `int stat(const char *pathname, struct stat *statbuf);`
* ## ASM
* **In:**
* `>PUSHW statbuf`
* `>LDYA pathname`
* `>SYSCALL stat`
* **Out:**
*\--------------------------------------
K.Stat jsr PFT.CheckPathYA
K.Stat.I jsr STDIO.SetMLIPathYA
>PULLW K.Stat.StoreY+1
>MLICALL MLIGETFILEINFO
bcs .9
ldx K.MLI.PARAMS+S.FI.A
lda #S.STAT.MODE.XO+S.STAT.MODE.WO+S.STAT.MODE.RO
cpx #S.FI.A.FULL
beq .2
lda #S.STAT.MODE.XO+S.STAT.MODE.RO
cpx #S.FI.A.R
beq .2
lda #0
.2 ldy #S.STAT.MODE
jsr K.Stat.StoreY
ldx #K.Stat.DST-K.Stat.SRC
.3 ldy K.Stat.SRC-1,x
lda K.MLI.PARAMS,y
ldy K.Stat.DST-1,x
jsr K.Stat.StoreY
dex
bne .3
ldy #S.STAT.SIZE
lda #0
jsr K.Stat.StoreY
iny
lda K.MLI.PARAMS+S.FI.UBLKS
asl
jsr K.Stat.StoreY
iny
lda K.MLI.PARAMS+S.FI.UBLKS+1
rol
jsr K.Stat.StoreY
iny
lda #0
rol
jsr K.Stat.StoreY
clc
.9 rts
K.Stat.StoreY sta $ffff,y
rts
*--------------------------------------
K.Stat.SRC .DA #S.FI.T
.DA #S.FI.AUXTYPE,#S.FI.AUXTYPE+1
.DA #S.FI.UBLKS,#S.FI.UBLKS+1
K.Stat.DST .DA #S.STAT.P.TYPE
.DA #S.STAT.P.AUXTYPE,#S.STAT.P.AUXTYPE+1
.DA #S.STAT.BLOCKS,#S.STAT.BLOCKS+1
*/-------------------------------------
* # MKDir
* **In:**
* Y,A = DIR name
* **Out:**
* CC : success
* CS : error
* A = EC
*\-------------------------------------
K.MKDir jsr PFT.CheckPathYA
jsr STDIO.SetMLIPathYA
lda #S.FI.A.FULL
sta K.MLI.PARAMS+S.FI.A
lda #S.FI.T.DIR
sta K.MLI.PARAMS+S.FI.T
lda #S.FI.ST.DIR
sta K.MLI.PARAMS+S.FI.ST
* jsr DATETIME
ldx #3
.1 lda DATELO,x
sta K.MLI.PARAMS+8,x
dex
bpl .1
>MLICALL MLICREATE
rts
*/--------------------------------------
* # MkNod
* int mknod(const char *pathname, mode_t mode, dev_t dev);
* return a hFile for a given Device Name
* **In:**
* Y,A=DevName
* **Out:**
* CC = OK, CS = ERROR
* A = hFILE
*\--------------------------------------
K.MkNod jsr K.GetDevByName Y,A=NAME
bcs .9
>STYA .1+1 pFD
stx .2+1 devID
ldy #S.FD.T
lda (pFD),y
cmp #S.FD.T.CDEV
bne .99
txa Pass DEV.ID to OPEN
ldx #IOCTL.OPEN
.1 jsr $FFFF SELF MODIFIED
bcs .9
>LDYAI S.FD.DEV
jsr K.GetMem0
bcs .9
>STYA ZPPtr3 Ptr3=S.FD
ldy #S.FD.T
lda #S.FD.T.CDEV
sta (ZPPtr3),y
ldy #S.FD.DEV.DEVID
.2 lda #$ff Self Modified
sta (ZPPtr3),y
ldy #S.FD.DEV.DRVPTR
lda .1+1
sta (ZPPtr3),y
iny
lda .1+2
sta (ZPPtr3),y
txa
clc
.9 rts
.99 lda #MLI.E.IO
sec
rts
*/--------------------------------------
* # MKFIFO
* int mkfifo(const char *pathname, mode_t mode);
* return a hFILE to a new FIFO
* **In:**
* **Out:**
* CC = OK, CS = ERROR
* A = hFILE
*\--------------------------------------
K.MKFIFO >LDYAI 256
jsr K.GetMem
bcs .99
stx .1+1 save FIFO buffer
>LDYAI S.FD.FIFO
jsr K.GetMem0
bcs .9
>STYA pFD
ldy #S.FD.T
lda #S.FD.T.FIFO
sta (pFD),y
iny S.FD.FIFO.hMem
.1 lda #$ff Self Modified
sta (pFD),y
txa
clc
rts
.9 pha save error code
lda .1+1 get back FIFO buffer
jsr K.FreeMem
pla
sec
.99 rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.STAT
LOAD /A2OSX.SRC/SYS/KERNEL.S
ASM