A2osX/SYS/KERNEL.S.STAT.txt

265 lines
4.9 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
PREFIX /A2OSX.BUILD
2017-12-22 21:24:30 +00:00
AUTO 4,1
*--------------------------------------
* # FStat
2018-10-04 15:30:14 +00:00
* Return information about a hFILE
2018-08-08 15:13:37 +00:00
* ## C
* `int fstat(short int hFILE, struct stat *statbuf);`
2018-07-20 11:51:08 +00:00
* ## ASM
2018-06-18 08:44:02 +00:00
* **In:**
2018-08-08 15:13:37 +00:00
* `>PUSHW statbuf`
* `lda hFILE`
* `>SYSCALL fstat`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
*--------------------------------------
2018-08-08 15:13:37 +00:00
K.FStat jsr PFT.CheckNodeA
2018-10-04 15:30:14 +00:00
jsr STDIO.GetHFile
2018-09-06 12:27:37 +00:00
bcs .9
2018-10-04 15:30:14 +00:00
lda Nod.Table.hPath,x
jsr K.GetMemPtr
2018-11-07 16:11:02 +00:00
jsr K.Stat.I
bcs K.Stat.9
jsr STDIO.GetHFileREG.I
bcs K.Stat.BLK2SIZE
>MLICALL MLIGETEOF
bcs K.Stat.BLK2SIZE
ldy #S.STAT.SIZE+3
lda #0
sta (ZPPtr1),y
ldx #2
.1 lda K.MLI.PARAMS+2,x
dey
sta (ZPPtr1),y
dex
bpl .1
* clc
rts
2018-08-08 15:13:37 +00:00
2018-10-04 15:30:14 +00:00
.9 >RET 2 discard statbuf
*/--------------------------------------
* # Stat
* Return information about a file
2018-07-20 11:51:08 +00:00
* ## C
* `int stat(const char *pathname, struct stat *statbuf);`
* ## ASM
2018-06-18 08:44:02 +00:00
* **In:**
2018-07-20 11:51:08 +00:00
* `>PUSHW statbuf`
* `>LDYA pathname`
* `>SYSCALL stat`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
*\--------------------------------------
2018-07-20 11:51:08 +00:00
K.Stat jsr PFT.CheckPathYA
2018-11-07 16:11:02 +00:00
jsr K.Stat.I
bcs K.Stat.9
K.Stat.BLK2SIZE
ldy #S.STAT.SIZE
lda #0
sta (ZPPtr1),y
iny
lda K.MLI.PARAMS+S.FI.UBLKS
asl
sta (ZPPtr1),y
iny
lda K.MLI.PARAMS+S.FI.UBLKS+1
rol
sta (ZPPtr1),y
iny
lda #0
rol
sta (ZPPtr1),y
* clc
K.Stat.9 rts
2018-08-08 15:13:37 +00:00
K.Stat.I jsr STDIO.SetMLIPathYA
2018-07-20 11:51:08 +00:00
2018-09-06 15:36:44 +00:00
>PULLW ZPPtr1
2018-07-20 11:51:08 +00:00
>MLICALL MLIGETFILEINFO
bcs .9
2017-10-27 14:56:46 +00:00
ldx K.MLI.PARAMS+S.FI.A
lda #S.STAT.MODE.XO+S.STAT.MODE.WO+S.STAT.MODE.RO
2017-10-27 14:56:46 +00:00
cpx #S.FI.A.FULL
beq .2
lda #S.STAT.MODE.XO+S.STAT.MODE.RO
2017-10-27 14:56:46 +00:00
cpx #S.FI.A.R
beq .2
lda #0
.2 ldy #S.STAT.MODE
2018-09-06 15:36:44 +00:00
sta (ZPPtr1),y
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
2018-09-06 15:36:44 +00:00
sta (ZPPtr1),y
dex
bne .3
clc
.9 rts
*--------------------------------------
2017-10-27 14:56:46 +00:00
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
*/-------------------------------------
2018-06-21 15:12:10 +00:00
* # MKDir
2018-09-20 15:33:05 +00:00
* create a directory
* ## C
* `int mkdir(const char *pathname, int mode);`
* ## ASM
2018-06-14 15:31:36 +00:00
* **In:**
2018-09-20 15:33:05 +00:00
* `>PUSHW mode`
* `>LDYA pathname`
* `>SYSCALL mkdir`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2018-09-20 15:33:05 +00:00
* CC : success
* CS : error
* A = EC
*\-------------------------------------
2018-06-21 15:12:10 +00:00
K.MKDir jsr PFT.CheckPathYA
jsr STDIO.SetMLIPathYA
2018-09-20 15:33:05 +00:00
2017-10-27 14:56:46 +00:00
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
2018-10-03 15:25:03 +00:00
K.MKDir.RTS rts
*/--------------------------------------
2018-06-21 15:12:10 +00:00
* # MkNod
2018-10-02 15:52:30 +00:00
* Create a special or ordinary file.
2018-09-20 15:33:05 +00:00
* (CDEV, BDEV, DSOCKS, SSOCK, PIPE)
* ## C
2018-10-03 15:25:03 +00:00
* `hFILE mknod(const char *pathname, int mode, hFD fd);`
2018-09-20 15:33:05 +00:00
* ## ASM
2018-06-14 15:31:36 +00:00
* **In:**
2018-09-20 15:33:05 +00:00
* `>PUSHB fd`
* `>PUSHW mode`
* `>LDYA pathname`
* `>SYSCALL mknod`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2018-09-20 15:33:05 +00:00
* CC = OK, CS = ERROR
* A = hFILE
*\--------------------------------------
2018-09-20 15:33:05 +00:00
K.MkNod >STYA ZPPtr1 pathname
2018-09-20 15:33:05 +00:00
>PULLW K.S.STAT+S.STAT.MODE
>PULLB K.S.STAT+S.STAT.DEV
2018-09-20 15:33:05 +00:00
jsr K.GetMemPtr
2018-10-03 15:25:03 +00:00
bcs K.MKDir.RTS
2018-09-20 15:33:05 +00:00
>STYA pFD
2018-10-03 05:52:08 +00:00
>LDYA ZPPtr1
2018-10-03 15:25:03 +00:00
ldx K.S.STAT+S.STAT.DEV
jsr STDIO.NewHFileYAX
bcs K.MKDir.RTS
2018-10-03 05:52:08 +00:00
2018-09-20 15:33:05 +00:00
lda (pFD) #S.FD.T
tax
jmp (.8,x)
.8 .DA STDIO.IOERR REG
.DA STDIO.IOERR DIR
.DA STAT.MKNOD.CDEV
.DA STAT.MKNOD.BDEV
.DA STDIO.IOERR LNK
.DA STAT.MKNOD.DSOCK
.DA STAT.MKNOD.SSOCK
2018-10-02 15:52:30 +00:00
.DA STAT.MKNOD.PIPE
2018-09-20 15:33:05 +00:00
*--------------------------------------
STAT.MKNOD.CDEV
STAT.MKNOD.BDEV
STAT.MKNOD.DSOCK
STAT.MKNOD.SSOCK
2018-10-02 15:52:30 +00:00
STAT.MKNOD.PIPE
2018-10-03 05:52:08 +00:00
clc
rts
*/--------------------------------------
* # MKFIFO
* return a hFILE to a new FIFO
2018-09-20 15:33:05 +00:00
* ## C
* `hFILE mkfifo(const char *pathname, int mode);`
* ## ASM
2018-06-14 15:31:36 +00:00
* **In:**
2018-09-20 15:33:05 +00:00
* `>PUSHW mode`
* `>LDYA pathname`
* `>SYSCALL mkfifo`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2018-09-20 15:33:05 +00:00
* CC = OK, CS = ERROR
* A = hFILE
*\--------------------------------------
2018-10-02 15:52:30 +00:00
K.MKFIFO >LDYAI K.PIPE.SIZE
2018-06-21 15:12:10 +00:00
jsr K.GetMem
bcs .99
2018-10-02 15:52:30 +00:00
stx .1+1 save PIPE buffer
2018-10-02 15:52:30 +00:00
>LDYAI S.FD.PIPE
2018-06-21 15:12:10 +00:00
jsr K.GetMem0
bcs .9
2018-08-08 15:13:37 +00:00
>STYA pFD
2018-07-10 15:33:13 +00:00
ldy #S.FD.T
2018-10-02 15:52:30 +00:00
lda #S.FD.T.PIPE
2018-08-08 15:13:37 +00:00
sta (pFD),y
2018-10-02 15:52:30 +00:00
iny S.FD.PIPE.hMem
.1 lda #$ff Self Modified
2018-08-08 15:13:37 +00:00
sta (pFD),y
txa
clc
rts
.9 pha save error code
2018-10-02 15:52:30 +00:00
lda .1+1 get back PIPE buffer
2018-06-22 06:24:35 +00:00
jsr K.FreeMem
pla
sec
.99 rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.STAT
LOAD /A2OSX.SRC/SYS/KERNEL.S
ASM