2017-12-22 21:24:30 +00:00
|
|
|
|
NEW
|
2019-04-19 05:42:43 +00:00
|
|
|
|
AUTO 3,1
|
2020-02-14 16:32:52 +00:00
|
|
|
|
*/--------------------------------------
|
2019-04-19 05:42:43 +00:00
|
|
|
|
* # ChMod
|
|
|
|
|
* change permissions of a file
|
|
|
|
|
* ## C
|
|
|
|
|
* `int chmod(const char *pathname, int mode);`
|
|
|
|
|
* ## ASM
|
2020-02-14 07:21:56 +00:00
|
|
|
|
* `>PUSHW pathname`
|
2019-04-19 05:42:43 +00:00
|
|
|
|
* `>PUSHW mode`
|
|
|
|
|
* `>SYSCALL chmod`
|
2019-01-30 06:20:13 +00:00
|
|
|
|
* ## RETURN VALUE
|
2022-03-06 22:28:52 +00:00
|
|
|
|
*\--------------------------------------
|
2020-02-14 07:21:56 +00:00
|
|
|
|
K.ChMod jsr PFT.CheckPath2
|
2022-03-06 22:28:52 +00:00
|
|
|
|
bcs STAT.RET4
|
2019-01-30 06:20:13 +00:00
|
|
|
|
|
2021-05-04 17:31:21 +00:00
|
|
|
|
jsr STAT.PM
|
2020-02-14 07:21:56 +00:00
|
|
|
|
|
2020-07-28 20:37:26 +00:00
|
|
|
|
stz K.MLI.PARAMS+3+S.FIEX.ACL read mode
|
2023-10-18 05:41:12 +00:00
|
|
|
|
|
2023-11-04 14:42:28 +00:00
|
|
|
|
>MLICALL MLI.ACL
|
2020-07-22 15:51:03 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>LDYA K.S.STAT+S.STAT.MODE
|
|
|
|
|
>STYA K.MLI.PARAMS+3+S.FIEX.ACL.MOD
|
2023-10-18 05:41:12 +00:00
|
|
|
|
|
2020-07-22 15:51:03 +00:00
|
|
|
|
lda #$57 write mode
|
|
|
|
|
sta K.MLI.PARAMS+3+S.FIEX.ACL
|
|
|
|
|
|
2023-11-04 14:42:28 +00:00
|
|
|
|
>MLICALL MLI.ACL
|
2020-07-22 15:51:03 +00:00
|
|
|
|
.9 rts
|
2020-03-10 16:42:07 +00:00
|
|
|
|
|
2022-03-06 22:28:52 +00:00
|
|
|
|
STAT.RET4 inc pStack
|
2021-08-10 10:20:41 +00:00
|
|
|
|
|
2022-03-06 22:28:52 +00:00
|
|
|
|
STAT.RET3 inc pStack
|
2020-08-19 19:39:43 +00:00
|
|
|
|
inc pStack
|
|
|
|
|
inc pStack
|
|
|
|
|
rts
|
2022-03-06 22:28:52 +00:00
|
|
|
|
*/--------------------------------------
|
2017-10-09 15:30:48 +00:00
|
|
|
|
* # 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
|
2020-02-14 07:21:56 +00:00
|
|
|
|
* `>PUSHB hFILE`
|
2018-08-08 15:13:37 +00:00
|
|
|
|
* `>PUSHW statbuf`
|
|
|
|
|
* `>SYSCALL fstat`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2022-03-06 22:28:52 +00:00
|
|
|
|
*\--------------------------------------
|
2021-07-24 20:42:23 +00:00
|
|
|
|
K.FStat ldy #2
|
|
|
|
|
jsr PFT.CheckNodeY
|
2022-03-06 22:28:52 +00:00
|
|
|
|
bcs STAT.RET3
|
2019-12-02 07:09:58 +00:00
|
|
|
|
|
2020-08-19 19:39:43 +00:00
|
|
|
|
>PULLW K.Stat.Store.2+1
|
2023-10-18 05:41:12 +00:00
|
|
|
|
|
2020-12-15 13:23:22 +00:00
|
|
|
|
>PULLA
|
|
|
|
|
tax
|
2023-10-18 05:41:12 +00:00
|
|
|
|
lda FILEs.hName-1,x get path
|
2020-12-15 13:23:22 +00:00
|
|
|
|
jsr K.GetMemPtr
|
|
|
|
|
jsr PFT.YAToMLIPATH
|
|
|
|
|
|
|
|
|
|
jsr FS.Stat.203
|
2021-05-04 17:31:21 +00:00
|
|
|
|
bcs STAT.RTS
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.FD.REG.REF
|
|
|
|
|
lda (pFD),y
|
|
|
|
|
sta K.MLI.PARAMS+1
|
|
|
|
|
|
2023-11-04 14:42:28 +00:00
|
|
|
|
>MLICALL MLI.GETEOF
|
2021-05-04 17:31:21 +00:00
|
|
|
|
bcs STAT.RTS
|
2023-10-18 05:41:12 +00:00
|
|
|
|
|
2020-12-15 13:23:22 +00:00
|
|
|
|
ldx #2
|
|
|
|
|
|
|
|
|
|
.1 lda K.MLI.PARAMS+2,x
|
|
|
|
|
sta K.S.STAT+S.STAT.SIZE,x
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
2023-10-18 05:41:12 +00:00
|
|
|
|
|
2019-12-02 07:09:58 +00:00
|
|
|
|
K.Stat.Store ldy #S.STAT-1
|
|
|
|
|
|
|
|
|
|
K.Stat.Store.1 lda K.S.STAT,y
|
|
|
|
|
K.Stat.Store.2 sta $ffff,y SELF MODIFIED
|
|
|
|
|
dey
|
|
|
|
|
bpl K.Stat.Store.1
|
|
|
|
|
|
2018-11-07 16:11:02 +00:00
|
|
|
|
* clc
|
2021-05-04 17:31:21 +00:00
|
|
|
|
STAT.RTS rts
|
2017-08-24 12:46:48 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # Stat
|
|
|
|
|
* Return information about a file
|
2018-07-20 11:51:08 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `int stat(const char *pathname, struct stat *statbuf);`
|
|
|
|
|
* ## ASM
|
2020-02-14 07:21:56 +00:00
|
|
|
|
* `>PUSHW pathname`
|
2018-07-20 11:51:08 +00:00
|
|
|
|
* `>PUSHW statbuf`
|
|
|
|
|
* `>SYSCALL stat`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2017-08-24 12:46:48 +00:00
|
|
|
|
*\--------------------------------------
|
2020-02-14 07:21:56 +00:00
|
|
|
|
K.Stat jsr PFT.CheckPath2
|
2022-03-06 22:28:52 +00:00
|
|
|
|
bcs STAT.RET4 go discard statbuf
|
2019-04-19 05:42:43 +00:00
|
|
|
|
|
2019-12-02 07:09:58 +00:00
|
|
|
|
>PULLW K.Stat.Store.2+1
|
2019-04-19 05:42:43 +00:00
|
|
|
|
|
2020-02-14 07:21:56 +00:00
|
|
|
|
inc pStack
|
|
|
|
|
inc pStack
|
|
|
|
|
|
2020-07-10 13:59:56 +00:00
|
|
|
|
jsr FS.Stat
|
2019-12-02 07:09:58 +00:00
|
|
|
|
bcc K.Stat.Store
|
2019-04-19 05:42:43 +00:00
|
|
|
|
|
2019-04-15 05:40:13 +00:00
|
|
|
|
rts
|
2017-08-24 15:29:22 +00:00
|
|
|
|
*/-------------------------------------
|
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
|
2020-02-14 07:21:56 +00:00
|
|
|
|
* `>PUSHW pathname`
|
2018-09-20 15:33:05 +00:00
|
|
|
|
* `>PUSHW mode`
|
|
|
|
|
* `>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
|
2017-08-24 15:29:22 +00:00
|
|
|
|
*\-------------------------------------
|
2020-02-14 07:21:56 +00:00
|
|
|
|
K.MKDir jsr PFT.CheckPath2
|
2022-03-06 22:28:52 +00:00
|
|
|
|
bcs STAT.RET4
|
2020-02-14 07:21:56 +00:00
|
|
|
|
|
2021-05-04 17:31:21 +00:00
|
|
|
|
jsr STAT.PM
|
2023-10-18 05:41:12 +00:00
|
|
|
|
|
2017-10-27 14:56:46 +00:00
|
|
|
|
lda #S.FI.T.DIR
|
2018-12-19 16:45:09 +00:00
|
|
|
|
sta K.MLI.PARAMS+4
|
|
|
|
|
stz K.MLI.PARAMS+5
|
|
|
|
|
stz K.MLI.PARAMS+6
|
2017-10-27 14:56:46 +00:00
|
|
|
|
lda #S.FI.ST.DIR
|
2023-10-18 05:41:12 +00:00
|
|
|
|
jmp FS.MLICREATE
|
2017-08-24 15:29:22 +00:00
|
|
|
|
*/--------------------------------------
|
2019-06-03 15:50:41 +00:00
|
|
|
|
* # MKFIFO
|
|
|
|
|
* return a pathname to a new FIFO
|
|
|
|
|
* ## C
|
2020-03-16 06:50:15 +00:00
|
|
|
|
* `hFILE mkfifo(const char *pathname, int mode);`
|
2019-06-03 15:50:41 +00:00
|
|
|
|
* ## ASM
|
2020-03-10 16:42:07 +00:00
|
|
|
|
* `>PUSHW pathname`
|
2019-06-03 15:50:41 +00:00
|
|
|
|
* `>PUSHW mode`
|
|
|
|
|
* `>SYSCALL mkfifo`
|
|
|
|
|
* ## RETURN VALUE
|
|
|
|
|
* CC = OK, CS = ERROR
|
2020-03-16 06:50:15 +00:00
|
|
|
|
* A = hFILE
|
2019-06-03 15:50:41 +00:00
|
|
|
|
*\--------------------------------------
|
2021-05-04 17:31:21 +00:00
|
|
|
|
K.MKFIFO jsr STAT.PM
|
2020-03-10 16:42:07 +00:00
|
|
|
|
|
2019-06-03 15:50:41 +00:00
|
|
|
|
>LDYAI 512
|
|
|
|
|
jsr K.pipe
|
2021-05-04 17:31:21 +00:00
|
|
|
|
bcs STAT.RTS
|
2019-06-03 15:50:41 +00:00
|
|
|
|
|
2019-07-12 06:22:32 +00:00
|
|
|
|
ldy #0
|
2021-07-24 20:42:23 +00:00
|
|
|
|
|
2023-11-26 13:17:41 +00:00
|
|
|
|
.1 lda STAT.DEVFIFO,y
|
2020-03-16 06:50:15 +00:00
|
|
|
|
sta (ZPPtr1),y fill pathname buffer
|
2019-07-12 06:22:32 +00:00
|
|
|
|
iny
|
2021-07-24 20:42:23 +00:00
|
|
|
|
cpy #9
|
2019-07-12 06:22:32 +00:00
|
|
|
|
bne .1
|
2019-06-04 15:49:58 +00:00
|
|
|
|
|
2019-07-12 14:51:57 +00:00
|
|
|
|
lda IO.hFD
|
2021-04-29 11:56:34 +00:00
|
|
|
|
jsr STDIO.A2HexAX
|
2019-07-12 06:22:32 +00:00
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
txa
|
|
|
|
|
iny
|
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
iny
|
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
bra K.MkNod.I
|
2019-06-03 15:50:41 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-21 15:12:10 +00:00
|
|
|
|
* # MkNod
|
2018-10-02 15:52:30 +00:00
|
|
|
|
* Create a special or ordinary file.
|
2023-10-18 05:41:12 +00:00
|
|
|
|
* (CDEV, BDEV, DSOCK, SSOCK, PIPE)
|
2018-09-20 15:33:05 +00:00
|
|
|
|
* ## 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
|
2020-03-10 16:42:07 +00:00
|
|
|
|
* `>PUSHW pathname`
|
2018-09-20 15:33:05 +00:00
|
|
|
|
* `>PUSHW mode`
|
2020-03-10 16:42:07 +00:00
|
|
|
|
* `>PUSHB fd`
|
2018-09-20 15:33:05 +00:00
|
|
|
|
* `>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
|
2017-08-24 15:29:22 +00:00
|
|
|
|
*\--------------------------------------
|
2023-10-18 05:41:12 +00:00
|
|
|
|
K.MkNod >PULLA
|
|
|
|
|
jsr DEV.GetPFD
|
2020-03-10 16:42:07 +00:00
|
|
|
|
|
2021-05-04 17:31:21 +00:00
|
|
|
|
jsr STAT.PM
|
2023-10-18 05:41:12 +00:00
|
|
|
|
|
|
|
|
|
K.MkNod.I ldx #1
|
|
|
|
|
|
|
|
|
|
.1 lda FILEs.hFD-1,x
|
|
|
|
|
beq .2
|
|
|
|
|
|
|
|
|
|
inx
|
|
|
|
|
cpx #K.FILE.MAX+1
|
|
|
|
|
bcc .1
|
|
|
|
|
|
|
|
|
|
lda #E.OOH
|
|
|
|
|
|
|
|
|
|
* sec
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.2 stx IO.hFILE
|
|
|
|
|
|
2021-07-26 13:45:29 +00:00
|
|
|
|
lda IO.hFD
|
2023-10-18 05:41:12 +00:00
|
|
|
|
sta FILEs.hFD-1,x
|
|
|
|
|
|
|
|
|
|
stz FILEs.oCnt-1,x
|
|
|
|
|
|
|
|
|
|
lda (pFD)
|
|
|
|
|
cmp #S.FD.T.CDEV
|
|
|
|
|
beq .8
|
2021-07-26 13:45:29 +00:00
|
|
|
|
|
2023-10-18 05:41:12 +00:00
|
|
|
|
cmp #S.FD.T.BDEV
|
|
|
|
|
beq .8
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
2018-10-03 05:52:08 +00:00
|
|
|
|
>LDYA ZPPtr1
|
2020-03-16 06:50:15 +00:00
|
|
|
|
>SYSCALL2 StrDup
|
2019-02-04 16:37:15 +00:00
|
|
|
|
bcs .9
|
2020-03-16 06:50:15 +00:00
|
|
|
|
|
2019-02-04 16:37:15 +00:00
|
|
|
|
txa
|
2020-03-16 06:50:15 +00:00
|
|
|
|
|
2021-07-24 20:42:23 +00:00
|
|
|
|
ldx IO.hFILE
|
2023-10-18 05:41:12 +00:00
|
|
|
|
sta FILEs.hName-1,x store path
|
|
|
|
|
|
|
|
|
|
.8 txa hFILE
|
2020-12-15 13:23:22 +00:00
|
|
|
|
|
2018-10-03 05:52:08 +00:00
|
|
|
|
clc
|
2023-10-18 05:41:12 +00:00
|
|
|
|
|
2019-02-04 16:37:15 +00:00
|
|
|
|
.9 rts
|
2017-08-24 15:29:22 +00:00
|
|
|
|
*/--------------------------------------
|
2019-02-04 16:37:15 +00:00
|
|
|
|
* # pipe
|
|
|
|
|
* ## C
|
2019-05-02 15:59:11 +00:00
|
|
|
|
* `hFD pipe(int size);`
|
2019-02-04 16:37:15 +00:00
|
|
|
|
* ## ASM
|
2019-05-02 15:59:11 +00:00
|
|
|
|
* `>LDYA size`
|
2019-02-04 16:37:15 +00:00
|
|
|
|
* `>SYSCALL pipe`
|
|
|
|
|
* ## RETURN VALUE
|
|
|
|
|
* CC = OK, CS = ERROR
|
|
|
|
|
* A = hFD
|
|
|
|
|
*\--------------------------------------
|
2019-06-03 15:50:41 +00:00
|
|
|
|
K.Pipe sta .1+1 SIZE HI
|
|
|
|
|
|
2020-02-16 20:45:16 +00:00
|
|
|
|
>SYSCALL2 NewStkObj
|
2017-08-24 15:29:22 +00:00
|
|
|
|
bcs .99
|
2020-02-16 20:45:16 +00:00
|
|
|
|
|
2019-06-03 15:50:41 +00:00
|
|
|
|
stx .8+1 save PIPE buffer
|
2020-02-16 20:45:16 +00:00
|
|
|
|
|
2021-07-24 20:42:23 +00:00
|
|
|
|
lda #S.FD.T.PIPE
|
2020-12-15 13:23:22 +00:00
|
|
|
|
jsr DEV.MkFD
|
2017-08-24 15:29:22 +00:00
|
|
|
|
bcs .9
|
2020-02-16 20:45:16 +00:00
|
|
|
|
|
2019-06-03 15:50:41 +00:00
|
|
|
|
.1 lda #$ff SELF MODIFIED
|
|
|
|
|
ldy #S.FD.PIPE.Free+1
|
2019-05-02 15:59:11 +00:00
|
|
|
|
sta (pFD),y
|
|
|
|
|
|
2019-06-03 15:50:41 +00:00
|
|
|
|
ldy #S.FD.PIPE.Size+1
|
2019-02-21 22:03:08 +00:00
|
|
|
|
sta (pFD),y
|
2023-10-18 05:41:12 +00:00
|
|
|
|
|
2019-02-26 16:50:42 +00:00
|
|
|
|
ldy #S.FD.PIPE.hMem
|
2023-10-18 05:41:12 +00:00
|
|
|
|
|
2019-06-03 15:50:41 +00:00
|
|
|
|
.8 lda #$ff Self Modified
|
2018-08-08 15:13:37 +00:00
|
|
|
|
sta (pFD),y
|
2021-07-24 20:42:23 +00:00
|
|
|
|
lda IO.hFD
|
2019-02-15 16:38:17 +00:00
|
|
|
|
* clc
|
2017-08-24 15:29:22 +00:00
|
|
|
|
rts
|
2020-03-12 07:46:43 +00:00
|
|
|
|
|
2017-08-24 15:29:22 +00:00
|
|
|
|
.9 pha save error code
|
2019-06-03 15:50:41 +00:00
|
|
|
|
lda .8+1 get back PIPE buffer
|
2020-02-16 20:45:16 +00:00
|
|
|
|
|
|
|
|
|
>SYSCALL2 FreeStkObj
|
|
|
|
|
|
2017-08-24 15:29:22 +00:00
|
|
|
|
pla
|
|
|
|
|
sec
|
2021-07-24 20:42:23 +00:00
|
|
|
|
.99 rts
|
2019-12-02 16:47:53 +00:00
|
|
|
|
*--------------------------------------
|
2021-05-04 17:31:21 +00:00
|
|
|
|
STAT.PM >PULLW K.S.STAT+S.STAT.MODE
|
2020-03-10 16:42:07 +00:00
|
|
|
|
>PULLW ZPPtr1 pathname
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2023-11-26 13:17:41 +00:00
|
|
|
|
STAT.DEVFIFO .AS "/dev/fifo"
|
2023-10-18 05:41:12 +00:00
|
|
|
|
*--------------------------------------
|
2017-08-24 12:46:48 +00:00
|
|
|
|
MAN
|
2020-05-28 21:13:52 +00:00
|
|
|
|
SAVE usr/src/sys/kernel.s.stat
|
|
|
|
|
LOAD usr/src/sys/kernel.s
|
2017-08-24 12:46:48 +00:00
|
|
|
|
ASM
|