A2osX/LIB/LIBCIFS.S.IO.txt

949 lines
13 KiB
Plaintext
Raw Normal View History

2021-05-19 12:44:47 +00:00
NEW
AUTO 3,1
*--------------------------------------
CIFS.ChTyp
CIFS2.ChTyp
*--------------------------------------
CIFS.ChMod
CIFS2.ChMod
*--------------------------------------
CIFS.FStat
*--------------------------------------
2021-06-17 17:38:34 +00:00
CIFS2.FStat >DEBUG
lda #MLI.E.BADCALL
2021-05-19 12:44:47 +00:00
sec
rts
*--------------------------------------
CIFS.Stat >STYA pPath resolved path
jsr ClearSocket
2021-06-17 17:38:34 +00:00
jsr GetGTX
2021-06-03 17:43:28 +00:00
jsr MakeTrans2Req
2021-05-19 12:44:47 +00:00
ldx #0
.1 lda SMB.QueryPathInfo,x
sta (ZPReqPtr),y
iny
inx
cpx #SMB.QueryPathInfo.Len
bne .1
2021-06-17 17:38:34 +00:00
jsr ReqT2SetupPtr2
2021-05-19 12:44:47 +00:00
2021-06-17 17:38:34 +00:00
jsr AppendPathPtr2
2021-05-19 12:44:47 +00:00
2021-06-17 17:38:34 +00:00
tya
inc +1 for \0
clc
adc ZPReqLen
sta ZPReqLen
bcc .2
inc ZPReqLen+1
2021-05-19 12:44:47 +00:00
2021-06-17 17:38:34 +00:00
.2 jsr SetT2ReqLen
2021-06-11 17:20:35 +00:00
jsr WriteSocket
2021-05-19 12:44:47 +00:00
bcs .9
jmp Sleep
.9 >RET 4
*--------------------------------------
CIFS2.Stat jsr ReadSocket
bcs .9
jsr GetRespData
ldy #S.NETBIOS+S.SMB.H.STATUS
lda (ZPRespPtr),y
beq .1
2021-06-17 17:38:34 +00:00
lda hResp
>SYSCALL2 FreeMem
2021-05-19 12:44:47 +00:00
lda #MLI.E.FNOTFND
bra .99
2021-06-17 17:38:34 +00:00
.1 jsr GetRespDataOffset
jsr FileInfo2StatBuf
>PULLW ZPPtr2 Stat Buffer
2021-05-19 12:44:47 +00:00
inc pStack Skip Filename
inc pStack
jsr StatBuf2Ptr2
lda hResp
>SYSCALL2 FreeMem
2021-06-17 17:38:34 +00:00
2021-05-19 12:44:47 +00:00
stz CIFS.Status
clc
rts
.9 cmp #E.NODATA
2021-06-03 17:43:28 +00:00
bne .99
2021-05-19 12:44:47 +00:00
dec CIFS.Retries
beq .90
lda #0
sec
rts
.90 lda #MLI.E.IO
.99 sec
stz CIFS.Status
>RET 4
*--------------------------------------
CIFS.MKDir >STYA pPath resolved path
2021-06-17 17:38:34 +00:00
jsr GetGTX
2021-06-03 17:43:28 +00:00
jsr MakeTrans2Req
2021-05-19 12:44:47 +00:00
ldx #0
.1 lda SMB.CreateDirectory,x
sta (ZPReqPtr),y
iny
inx
cpx #SMB.CreateDirectory.Len
bne .1
jsr AppendPath
lda #0
sta (ZPReqPtr),y
iny
jsr SetT2ReqLenYA
2021-06-11 17:20:35 +00:00
jsr WriteSocket
2021-05-19 12:44:47 +00:00
bcs .9
jmp Sleep
.9 >RET 4
*--------------------------------------
CIFS2.MKDir jsr ReadSocket
bcs .9
jsr GetRespData
ldy #S.NETBIOS+S.SMB.H.STATUS
lda (ZPRespPtr),y
clc
beq .8
lda #MLI.E.DUPFILE
sec
2021-06-17 17:38:34 +00:00
2021-05-19 12:44:47 +00:00
.8 jsr FreeRespData
stz CIFS.Status
>RET 4
.9 cmp #E.NODATA
bne .99
dec CIFS.Retries
beq .98
lda #0
sec
rts
.98 lda #MLI.E.IO
.99 sec
stz CIFS.Status
>RET 4
*--------------------------------------
CIFS.OpenDir >STYA pPath resolved path
>LDYAI S.FD.DIR
>SYSCALL2 GetMem
bcs .9
>STYA ZPPtr2
lda #S.FD.T.DIR
sta (ZPPtr2)
lda hHandler
ldy #S.FD.PFT
sta (ZPPtr2),y
lda #0
ldy #S.FD.DIR.EPB
sta (ZPPtr2),y EOF Flag
iny
sta (ZPPtr2),y
iny
sta (ZPPtr2),y
>PUSHW pPath
>PUSHWI 0
txa
>PUSHA
>SYSCALL2 mknod
.9 rts
*--------------------------------------
CIFS2.OpenDir lda #MLI.E.BADCALL
sec
rts
*--------------------------------------
CIFS.ReadDir jsr GetPFD
jsr ClearSocket
2021-06-17 17:38:34 +00:00
jsr GetGTX
2021-05-19 12:44:47 +00:00
ldy #S.FD.DIR.EPB
lda (pFD),y
beq .1
lda #MLI.E.EOF
sec
rts
.1 iny
lda (pFD),y
iny
ora (pFD),y
bne CIFS.ReadDir.Next
2021-06-03 17:43:28 +00:00
jsr MakeTrans2Req
2021-05-19 12:44:47 +00:00
ldx #0
.2 lda SMB.FindFirst2,x
sta (ZPReqPtr),y
iny
inx
cpx #SMB.FindFirst2.Len
bne .2
bra CIFS.ReadDir.Send
CIFS.ReadDir.Next
2021-06-03 17:43:28 +00:00
jsr MakeTrans2Req
2021-05-19 12:44:47 +00:00
ldx #0
.2 lda SMB.FindNext2,x
sta (ZPReqPtr),y
iny
inx
cpx #SMB.FindNext2.Len
bne .2
phy
ldy #S.FD.DIR.FC+1
lda (pFD),y
tax
dey
lda (pFD),y
2021-06-17 17:38:34 +00:00
ldy #S.NETBIOS+S.SMB.H+SMB.Trans2.H.Len+7 Search ID
2021-05-19 12:44:47 +00:00
sta (ZPReqPtr),y
txa
iny
sta (ZPReqPtr),y
ply
CIFS.ReadDir.Send
lda (pPath)
beq .1
jsr AppendPath
lda #'\'
sta (ZPReqPtr),y
iny
.1 lda #'*'
sta (ZPReqPtr),y
iny
lda #0
sta (ZPReqPtr),y
iny
jsr SetT2ReqLenYA
2021-06-11 17:20:35 +00:00
jsr WriteSocket
2021-05-19 12:44:47 +00:00
bcs .9
jmp Sleep
.9 rts
*--------------------------------------
CIFS2.ReadDir jsr GetPFD
jsr ReadSocket
bcs .90
jsr GetRespData
ldy #S.NETBIOS+S.SMB.H.STATUS
lda (ZPRespPtr),y
beq .1
.91 sec
lda #MLI.E.IO
bra .9
.1 ldy #S.FD.DIR.FC
lda (pFD),y
iny
ora (pFD),y
sta bFlag
bne .2
ldy #S.NETBIOS+S.SMB.H+S.TRANS2.H+1 Search ID
lda (ZPRespPtr),y
tax
dey
ora (ZPRespPtr),y
beq .91
lda (ZPRespPtr),y
2021-06-17 17:38:34 +00:00
2021-05-19 12:44:47 +00:00
ldy #S.FD.DIR.FC
sta (pFD),y
iny
txa
sta (pFD),y
.2 jsr GetRespDataOffset
jsr CIFS2.ReadDir.GetBuf
bcs .9
jsr GetRespDataOffset
jsr CIFS2.ReadDir.FillBuf
lda hResp
>SYSCALL2 FreeMem
>LDYA BufPtr
ldx hBuf
2021-06-17 17:38:34 +00:00
2021-05-19 12:44:47 +00:00
stz CIFS.Status
clc
rts
2021-06-17 17:38:34 +00:00
2021-05-19 12:44:47 +00:00
.9 stz CIFS.Status
2021-06-17 17:38:34 +00:00
2021-05-19 12:44:47 +00:00
jmp FreeRespData
.90 cmp #E.NODATA
bne .99
dec CIFS.Retries
beq .98
lda #0
sec
rts
.98 lda #MLI.E.IO
.99 stz CIFS.Status
sec
rts
*--------------------------------------
CIFS2.ReadDir.GetBuf
ldy #S.NETBIOS+S.SMB.H+S.TRANS2.H Search Count
lda bFlag
bne .10
iny
iny
.10 iny
iny
lda (ZPRespPtr),y End Of Search
phy
ldy #S.FD.DIR.EPB
sta (pFD),y
ply
dey
dey
lda (ZPRespPtr),y Search Count
beq .99
tax
lda #1 +Ending 0
sta ZPPtr2
stz ZPPtr2+1
.1 lda ZPPtr2
clc
adc #S.STAT
sta ZPPtr2
bcc .2
inc ZPPtr2+1
.2 lda ZPPtr1
clc
adc #22
sta ZPPtr1
bcc .3
inc ZPPtr1+1
.3 lda (ZPPtr1) Filename Len
pha
sec
adc ZPPtr2
sta ZPPtr2
bcc .4
inc ZPPtr2+1
.4 pla
inc
sec
adc ZPPtr1
sta ZPPtr1
bcc .5
inc ZPPtr1+1
.5 dex
bne .1
>LDYA ZPPtr2
>SYSCALL2 GetMem
bcs .9
>STYA BufPtr
>STYA ZPPtr2
stx hBuf
.9 rts
.99 lda #MLI.E.EOF
sec
rts
*--------------------------------------
CIFS2.ReadDir.FillBuf
ldy #S.NETBIOS+S.SMB.H+S.TRANS2.H Search Count
lda bFlag
bne .10
iny
iny
.10 lda (ZPRespPtr),y
tax
.1 jsr FileInfo2StatBuf
lda ZPPtr1
sec skip Filename Len
adc #22
sta ZPPtr1
bcc .2
inc ZPPtr1+1
.2 ldy #$ff
.3 iny
lda (ZPPtr1),y
sta (ZPPtr2),y
bne .3
tya
sec
adc ZPPtr1
sta ZPPtr1
bcc .4
inc ZPPtr1+1
.4 tya
sec
adc ZPPtr2
sta ZPPtr2
bcc .5
inc ZPPtr2+1
.5 jsr StatBuf2Ptr2
lda #S.STAT
clc
adc ZPPtr2
sta ZPPtr2
bcc .7
inc ZPPtr2+1
.7 dex
bne .1
lda #0
sta (ZPPtr2)
rts
*--------------------------------------
CIFS.CloseDir tax
lda Nod.Table.hName-2,x
beq .1
phx
stz Nod.Table.hName-2,x
>SYSCALL2 FreeMem
plx
.1 lda Nod.Table.hFD-2,x
stz Nod.Table.hFD-2,x
>SYSCALL2 FreeMem
stz CIFS.Status
clc
rts
*--------------------------------------
CIFS2.CloseDir lda #MLI.E.INVPATH
sec
rts
*--------------------------------------
CIFS.ChOwn
CIFS2.ChOwn
lda #MLI.E.BADCALL
sec
rts
2021-06-05 15:48:54 +00:00
*--------------------------------------
2021-06-06 19:06:49 +00:00
CIFS.FOpen >STYA pPath resolved path
2021-06-05 15:48:54 +00:00
2021-06-11 17:20:35 +00:00
jsr GetGTX
2021-06-06 19:06:49 +00:00
ldx #S.SMB.H.CMD.NT.CREATE.ANDX
jsr RequestSetupX
2021-05-19 12:44:47 +00:00
2021-05-22 21:05:12 +00:00
ldx #0
2021-06-06 19:06:49 +00:00
.1 lda SMB.ComCreate.H,x
2021-05-22 21:05:12 +00:00
sta (ZPReqPtr),y
iny
inx
2021-06-06 19:06:49 +00:00
cpx #SMB.ComCreate.H.Len
2021-05-22 21:05:12 +00:00
bne .1
2021-05-19 12:44:47 +00:00
2021-06-17 17:38:34 +00:00
jsr ReqSetupPtr2
jsr AppendPathPtr2
tya
ldy #S.NETBIOS+S.SMB.H+6 NameLength
2021-06-06 19:06:49 +00:00
sta (ZPReqPtr),y
2021-05-19 12:44:47 +00:00
2021-06-17 17:38:34 +00:00
inc +1 for \0
ldy ByteCountOfs
sta (ZPReqPtr),y
clc
adc ZPReqLen
sta ZPReqLen
bcc .2
2021-05-22 21:05:12 +00:00
2021-06-17 17:38:34 +00:00
inc ZPReqLen+1
.2 lda #0
ror
iny ByteCountOfs+1
sta (ZPReqPtr),y
2021-05-22 21:05:12 +00:00
2021-06-17 17:38:34 +00:00
jsr SetReqLen
ldx #1 FILE_OPEN
ldy #3 fopen flags
lda (pStack),y
bpl .3 O.CREATE
2021-06-06 19:06:49 +00:00
2021-06-17 17:38:34 +00:00
ldx #3 FILE_OPEN_IF
2021-05-22 21:05:12 +00:00
2021-06-17 17:38:34 +00:00
.3 bit #O.APPEND
bmi .4
ldx #5 FILE_OVERWRITE_IF
2021-05-22 21:05:12 +00:00
2021-06-17 17:38:34 +00:00
.4 txa
2021-06-05 15:48:54 +00:00
2021-06-17 17:38:34 +00:00
ldy #S.NETBIOS+S.SMB.H+SMB.Trans2.H.Len+7 CreateDisposition
sta (ZPReqPtr),y
2021-05-22 21:05:12 +00:00
2021-06-11 17:20:35 +00:00
jsr WriteSocket
2021-06-06 19:06:49 +00:00
bcs .9
jmp Sleep
.9 >RET 6
*--------------------------------------
CIFS2.FOpen jsr ReadSocket
bcs .9
jsr GetRespData
ldy #S.NETBIOS+S.SMB.H.STATUS
lda (ZPRespPtr),y
clc
beq .8
lda #MLI.E.DUPFILE
sec
bra .80
2021-06-17 17:38:34 +00:00
2021-06-06 19:06:49 +00:00
.8 >LDYAI S.FD.REG
>SYSCALL2 GetMem
bcs .99
2021-06-11 17:20:35 +00:00
>STYA pFD
2021-06-06 19:06:49 +00:00
lda #S.FD.T.REG
2021-06-11 17:20:35 +00:00
sta (pFD)
2021-06-06 19:06:49 +00:00
lda hHandler
ldy #S.FD.PFT
2021-06-11 17:20:35 +00:00
sta (pFD),y
2021-06-06 19:06:49 +00:00
ldy #S.NETBIOS+S.SMB.H+6 FileID
lda (ZPRespPtr),y
2021-05-22 21:05:12 +00:00
pha
2021-06-06 19:06:49 +00:00
iny
lda (ZPRespPtr),y
2021-06-17 17:38:34 +00:00
2021-06-06 19:06:49 +00:00
ldy #S.FD.REG.REF+1
2021-06-11 17:20:35 +00:00
sta (pFD),y
2021-06-06 19:06:49 +00:00
dey
pla
2021-06-11 17:20:35 +00:00
sta (pFD),y
2021-06-06 19:06:49 +00:00
ldy #4 path
2021-05-22 21:05:12 +00:00
2021-06-06 19:06:49 +00:00
lda (pStack),y
>PUSHA
lda (pStack),y
>PUSHA
2021-06-17 17:38:34 +00:00
2021-06-06 19:06:49 +00:00
>PUSHWZ mod
txa hFD
>PUSHA
>SYSCALL2 mknod
2021-05-22 21:05:12 +00:00
2021-06-06 19:06:49 +00:00
.80 jsr FreeRespData
2021-06-05 15:48:54 +00:00
2021-06-06 19:06:49 +00:00
stz CIFS.Status
>RET 6
2021-05-22 21:05:12 +00:00
2021-06-06 19:06:49 +00:00
.9 cmp #E.NODATA
bne .99
dec CIFS.Retries
beq .98
2021-05-22 21:05:12 +00:00
lda #0
2021-06-06 19:06:49 +00:00
sec
rts
.98 lda #MLI.E.IO
.99 sec
stz CIFS.Status
>RET 6
*--------------------------------------
CIFS.FClose jsr GetPFD
2021-06-11 17:20:35 +00:00
jsr GetGtx
2021-06-17 17:38:34 +00:00
2021-06-06 19:06:49 +00:00
ldx #S.SMB.H.CMD.CLOSE
jsr RequestSetupX
ldx #0
2021-06-11 17:20:35 +00:00
.1 lda SMB.ComClose.H,x
2021-05-22 21:05:12 +00:00
sta (ZPReqPtr),y
iny
2021-06-06 19:06:49 +00:00
inx
2021-06-11 17:20:35 +00:00
cpx #SMB.ComClose.H.Len
2021-06-06 19:06:49 +00:00
bne .1
2021-06-17 17:38:34 +00:00
sty ZPReqLen
stz ZPReqLen+1
2021-06-11 17:20:35 +00:00
ldy #S.FD.REG.REF
lda (pFD),y
pha
iny
lda (pFD),y
2021-06-17 17:38:34 +00:00
2021-06-11 17:20:35 +00:00
ldy #S.NETBIOS+S.SMB.H+2 FileID
sta (ZPReqPtr),y
pla
dey
sta (ZPReqPtr),y
2021-06-17 17:38:34 +00:00
jsr SetReqLen
2021-05-22 21:05:12 +00:00
2021-06-11 17:20:35 +00:00
jsr WriteSocket
2021-05-22 21:05:12 +00:00
bcs .9
jmp Sleep
2021-06-06 19:06:49 +00:00
.9 rts
2021-05-22 21:05:12 +00:00
*--------------------------------------
2021-06-06 19:06:49 +00:00
CIFS2.FClose sta hFILE
jsr ReadSocket
2021-05-22 21:05:12 +00:00
bcs .9
jsr GetRespData
ldy #S.NETBIOS+S.SMB.H.STATUS
lda (ZPRespPtr),y
clc
beq .8
lda #MLI.E.DUPFILE
sec
2021-06-06 19:06:49 +00:00
bra .80
2021-06-17 17:38:34 +00:00
2021-06-06 19:06:49 +00:00
.8 lda hFILE
jsr CIFS.CloseDir
clc
2021-06-17 17:38:34 +00:00
2021-06-06 19:06:49 +00:00
.80 jsr FreeRespData
2021-05-22 21:05:12 +00:00
stz CIFS.Status
2021-06-06 19:06:49 +00:00
rts
2021-05-22 21:05:12 +00:00
.9 cmp #E.NODATA
bne .99
dec CIFS.Retries
beq .98
lda #0
2021-05-19 12:44:47 +00:00
sec
rts
2021-05-22 21:05:12 +00:00
.98 lda #MLI.E.IO
.99 sec
stz CIFS.Status
2021-06-06 19:06:49 +00:00
rts
2021-05-19 12:44:47 +00:00
*--------------------------------------
CIFS.FRead
2021-06-06 19:06:49 +00:00
clc
>RET 5
*--------------------------------------
2021-05-19 12:44:47 +00:00
CIFS2.FRead
2021-06-06 19:06:49 +00:00
clc
>RET 5
*--------------------------------------
2021-06-17 17:38:34 +00:00
CIFS.FWrite ldy #4 hNod
2021-06-11 17:20:35 +00:00
lda (pStack),y
2021-06-17 17:38:34 +00:00
2021-06-11 17:20:35 +00:00
jsr GetPFD
2021-06-17 17:38:34 +00:00
2021-06-11 17:20:35 +00:00
jsr GetGTX
ldx #S.SMB.H.CMD.WRITE.ANDX
jsr RequestSetupX
ldx #0
.1 lda SMB.ComWrite.H,x
sta (ZPReqPtr),y
iny
inx
cpx #SMB.ComWrite.H.Len
bne .1
2021-06-17 17:38:34 +00:00
jsr ReqSetupPtr2
2021-06-11 17:20:35 +00:00
ldy #S.FD.REG.REF
lda (pFD),y
pha
iny
lda (pFD),y
2021-06-17 17:38:34 +00:00
2021-06-11 17:20:35 +00:00
ldy #S.NETBIOS+S.SMB.H+6 FileID
sta (ZPReqPtr),y
pla
dey
sta (ZPReqPtr),y
2021-06-17 17:38:34 +00:00
ldy #3 DataPtr HI
lda (pStack),y
sta ZPPtr1+1
dey DataPtr LO
lda (pStack),y
sta ZPPtr1
dey DataLen HI
lda (pStack),y
beq .5
lda #0
ldx #1 write $100
bra .6
.5 dey DataLen LO
lda (pStack),y
ldx #0 write $0xx
.6 pha
ldy #S.NETBIOS+S.SMB.H+21 DataLength
clc
adc #2
sta (ZPReqPtr),y
iny
txa
adc #0
sta (ZPReqPtr),y
pla
pha
clc
adc ZPReqLen
sta ZPReqLen
txa
adc ZPReqLen+1
sta ZPReqLen+1
pla
pha
ldy ByteCountOfs
sta (ZPReqPtr),y
txa
iny
sta (ZPReqPtr),y
ldy #0
plx
.70 lda (ZPPtr1),y
sta (ZPPtr2),y
iny
dex
bne .70
2021-06-11 17:20:35 +00:00
jsr SetReqLen
jsr WriteSocket
bcs .9
2021-06-17 17:38:34 +00:00
ldy #1 DataLen HI
lda (pStack),y
beq .7
dec
sta (pStack),y
ldy #3 DataPtr HI
lda (pStack),y
inc
sta (pStack),y
bra .8
.7 lda #0
sta (pStack) DataLen LO
.8 jmp Sleep
2021-06-11 17:20:35 +00:00
.9 >RET 5
2021-06-06 19:06:49 +00:00
*--------------------------------------
2021-06-11 17:20:35 +00:00
CIFS2.FWrite ldy #4
lda (pStack),y
2021-06-17 17:38:34 +00:00
2021-06-11 17:20:35 +00:00
jsr ReadSocket
bcs .9
jsr GetRespData
ldy #S.NETBIOS+S.SMB.H.STATUS
lda (ZPRespPtr),y
2021-06-06 19:06:49 +00:00
clc
2021-06-11 17:20:35 +00:00
beq .8
lda #MLI.E.IO
sec
2021-06-17 17:38:34 +00:00
2021-06-11 17:20:35 +00:00
.8 jsr FreeRespData
2021-06-17 17:38:34 +00:00
ldy #1
lda (pStack),y
ora (pStack)
clc
beq .90
2021-06-11 17:20:35 +00:00
2021-06-17 17:38:34 +00:00
jmp Sleep2
2021-06-11 17:20:35 +00:00
.9 cmp #E.NODATA
bne .99
dec CIFS.Retries
beq .98
lda #0
sec
rts
.98 lda #MLI.E.IO
.99 sec
2021-06-17 17:38:34 +00:00
.90 stz CIFS.Status
2021-06-11 17:20:35 +00:00
2021-06-06 19:06:49 +00:00
>RET 5
*--------------------------------------
2021-05-19 12:44:47 +00:00
CIFS.FFlush
CIFS2.FFlush
CIFS.FSeek
CIFS2.FSeek
CIFS.FTell
CIFS2.FTell
CIFS.FEOF
CIFS2.FEOF
CIFS.Remove
CIFS2.Remove
CIFS.Rename
2021-06-17 17:38:34 +00:00
CIFS2.Rename >DEBUG
lda #MLI.E.BADCALL
2021-05-19 12:44:47 +00:00
sec
rts
*--------------------------------------
MAN
SAVE usr/src/lib/libcifs.io.s
LOAD usr/src/lib/libcifs.s
ASM