mirror of
https://github.com/A2osX/A2osX.git
synced 2024-10-31 23:09:33 +00:00
278 lines
5.0 KiB
Plaintext
278 lines
5.0 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
*/--------------------------------------
|
||
* # ChMod
|
||
* change permissions of a file
|
||
* ## C
|
||
* `int chmod(const char *pathname, int mode);`
|
||
* ## ASM
|
||
* `>PUSHW pathname`
|
||
* `>PUSHW mode`
|
||
* `>SYSCALL chmod`
|
||
* ## RETURN VALUE
|
||
*\--------------------------------------
|
||
K.ChMod jsr PFT.CheckPath2
|
||
bcs STAT.RET4
|
||
|
||
jsr STAT.PM
|
||
|
||
stz K.MLI.PARAMS+3+S.FIEX.ACL read mode
|
||
|
||
>MLICALL MLIACL
|
||
bcs .9
|
||
|
||
>LDYA K.S.STAT+S.STAT.MODE
|
||
>STYA K.MLI.PARAMS+3+S.FIEX.ACL.MOD
|
||
|
||
lda #$57 write mode
|
||
sta K.MLI.PARAMS+3+S.FIEX.ACL
|
||
|
||
>MLICALL MLIACL
|
||
.9 rts
|
||
|
||
STAT.RET4 inc pStack
|
||
|
||
STAT.RET3 inc pStack
|
||
inc pStack
|
||
inc pStack
|
||
rts
|
||
*/--------------------------------------
|
||
* # FStat
|
||
* Return information about a hFILE
|
||
* ## C
|
||
* `int fstat(short int hFILE, struct stat *statbuf);`
|
||
* ## ASM
|
||
* `>PUSHB hFILE`
|
||
* `>PUSHW statbuf`
|
||
* `>SYSCALL fstat`
|
||
* ## RETURN VALUE
|
||
*\--------------------------------------
|
||
K.FStat ldy #2
|
||
jsr PFT.CheckNodeY
|
||
bcs STAT.RET3
|
||
|
||
>PULLW K.Stat.Store.2+1
|
||
|
||
>PULLA
|
||
tax
|
||
lda hFDs.hName-1,x get path
|
||
jsr K.GetMemPtr
|
||
jsr PFT.YAToMLIPATH
|
||
|
||
jsr FS.Stat.203
|
||
bcs STAT.RTS
|
||
|
||
ldy #S.FD.REG.REF
|
||
lda (pFD),y
|
||
sta K.MLI.PARAMS+1
|
||
|
||
>MLICALL MLIGETEOF
|
||
bcs STAT.RTS
|
||
|
||
ldx #2
|
||
|
||
.1 lda K.MLI.PARAMS+2,x
|
||
sta K.S.STAT+S.STAT.SIZE,x
|
||
dex
|
||
bpl .1
|
||
|
||
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
|
||
|
||
* clc
|
||
STAT.RTS rts
|
||
*/--------------------------------------
|
||
* # Stat
|
||
* Return information about a file
|
||
* ## C
|
||
* `int stat(const char *pathname, struct stat *statbuf);`
|
||
* ## ASM
|
||
* `>PUSHW pathname`
|
||
* `>PUSHW statbuf`
|
||
* `>SYSCALL stat`
|
||
* ## RETURN VALUE
|
||
*\--------------------------------------
|
||
K.Stat jsr PFT.CheckPath2
|
||
bcs STAT.RET4 go discard statbuf
|
||
|
||
>PULLW K.Stat.Store.2+1
|
||
|
||
inc pStack
|
||
inc pStack
|
||
|
||
jsr FS.Stat
|
||
bcc K.Stat.Store
|
||
|
||
rts
|
||
*/-------------------------------------
|
||
* # MKDir
|
||
* create a directory
|
||
* ## C
|
||
* `int mkdir(const char *pathname, int mode);`
|
||
* ## ASM
|
||
* `>PUSHW pathname`
|
||
* `>PUSHW mode`
|
||
* `>SYSCALL mkdir`
|
||
* ## RETURN VALUE
|
||
* CC : success
|
||
* CS : error
|
||
* A = EC
|
||
*\-------------------------------------
|
||
K.MKDir jsr PFT.CheckPath2
|
||
bcs STAT.RET4
|
||
|
||
jsr STAT.PM
|
||
|
||
lda #S.FI.T.DIR
|
||
sta K.MLI.PARAMS+4
|
||
stz K.MLI.PARAMS+5
|
||
stz K.MLI.PARAMS+6
|
||
lda #S.FI.ST.DIR
|
||
jmp FS.CREATE
|
||
*/--------------------------------------
|
||
* # MKFIFO
|
||
* return a pathname to a new FIFO
|
||
* ## C
|
||
* `hFILE mkfifo(const char *pathname, int mode);`
|
||
* ## ASM
|
||
* `>PUSHW pathname`
|
||
* `>PUSHW mode`
|
||
* `>SYSCALL mkfifo`
|
||
* ## RETURN VALUE
|
||
* CC = OK, CS = ERROR
|
||
* A = hFILE
|
||
*\--------------------------------------
|
||
K.MKFIFO jsr STAT.PM
|
||
|
||
>LDYAI 512
|
||
jsr K.pipe
|
||
bcs STAT.RTS
|
||
|
||
ldy #0
|
||
|
||
.1 lda UNISTD.DEVFIFO,y
|
||
sta (ZPPtr1),y fill pathname buffer
|
||
iny
|
||
cpy #9
|
||
bne .1
|
||
|
||
lda IO.hFD
|
||
jsr STDIO.A2HexAX
|
||
sta (ZPPtr1),y
|
||
txa
|
||
iny
|
||
sta (ZPPtr1),y
|
||
iny
|
||
lda #0
|
||
sta (ZPPtr1),y
|
||
|
||
lda ZPPtr1
|
||
clc
|
||
adc #5 skip /dev/
|
||
sta ZPPtr1
|
||
bcc K.MkNod.I
|
||
|
||
inc ZPPtr1+1
|
||
bra K.MkNod.I
|
||
*/--------------------------------------
|
||
* # MkNod
|
||
* Create a special or ordinary file.
|
||
* (CDEV, BDEV, DSOCKS, SSOCK, PIPE)
|
||
* ## C
|
||
* `hFILE mknod(const char *pathname, int mode, hFD fd);`
|
||
* ## ASM
|
||
* `>PUSHW pathname`
|
||
* `>PUSHW mode`
|
||
* `>PUSHB fd`
|
||
* `>SYSCALL mknod`
|
||
* ## RETURN VALUE
|
||
* CC = OK, CS = ERROR
|
||
* A = hFILE
|
||
*\--------------------------------------
|
||
K.MkNod >PULLB IO.hFD
|
||
|
||
jsr STAT.PM
|
||
|
||
K.MkNod.I lda IO.hFD
|
||
jsr DEV.GetFD
|
||
bcc .2
|
||
|
||
jsr DEV.GetFreeFD
|
||
bcs .9
|
||
|
||
lda IO.hFD
|
||
sta hFDs-1,x
|
||
|
||
.2 stx IO.hFILE
|
||
|
||
>LDYA ZPPtr1
|
||
>SYSCALL2 StrDup
|
||
bcs .9
|
||
|
||
txa
|
||
|
||
ldx IO.hFILE
|
||
sta hFDs.hName-1,x store path
|
||
|
||
txa hFILE
|
||
clc
|
||
.9 rts
|
||
*/--------------------------------------
|
||
* # pipe
|
||
* ## C
|
||
* `hFD pipe(int size);`
|
||
* ## ASM
|
||
* `>LDYA size`
|
||
* `>SYSCALL pipe`
|
||
* ## RETURN VALUE
|
||
* CC = OK, CS = ERROR
|
||
* A = hFD
|
||
*\--------------------------------------
|
||
K.Pipe sta .1+1 SIZE HI
|
||
|
||
>SYSCALL2 NewStkObj
|
||
bcs .99
|
||
|
||
stx .8+1 save PIPE buffer
|
||
|
||
lda #S.FD.T.PIPE
|
||
jsr DEV.MkFD
|
||
bcs .9
|
||
|
||
.1 lda #$ff SELF MODIFIED
|
||
ldy #S.FD.PIPE.Free+1
|
||
sta (pFD),y
|
||
|
||
ldy #S.FD.PIPE.Size+1
|
||
sta (pFD),y
|
||
|
||
ldy #S.FD.PIPE.hMem
|
||
|
||
.8 lda #$ff Self Modified
|
||
sta (pFD),y
|
||
lda IO.hFD
|
||
* clc
|
||
rts
|
||
|
||
.9 pha save error code
|
||
lda .8+1 get back PIPE buffer
|
||
|
||
>SYSCALL2 FreeStkObj
|
||
|
||
pla
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
STAT.PM >PULLW K.S.STAT+S.STAT.MODE
|
||
>PULLW ZPPtr1 pathname
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/sys/kernel.s.stat
|
||
LOAD usr/src/sys/kernel.s
|
||
ASM
|