--- soxkfs/S/Modmain Sun Sep 7 15:35:30 1997 +++ /data/PROJECTS/SOCKETFS/S/MODMAIN Tue Apr 21 19:21:18 1998 @@ -5,7 +5,7 @@ ; Created : 04-07-97 ; Author : R G Gammans ; -; Modified: 18-08-97 +; Modified: 21-04-98 ; SocketFS - BSD sockets filing system for RISC-OS. @@ -33,8 +33,8 @@ GET AsmLib:s.DebugHdr - ;Debug SETL {TRUE} -Debug SETL {FALSE} +Debug SETL {TRUE} +;Debug SETL {FALSE} GET AsmLib:h.SWINames GET AsmLib:h.FSControls @@ -81,7 +81,7 @@ DCD 0,0 Socket_Title DCB "SocketFS",0 -Socket_HelpStr DCB "SocketFS",9,"0.01 (18 Aug 1997) © Roger Gammans. Distribute as per GPL V2",0 +Socket_HelpStr DCB "SocketFS",9,"0.02p1(21 Apr 1998) © Roger Gammans. Distribution Forbidden",0 ALIGN Socket_HC_Table DCB "SocketFS",0 ALIGN @@ -192,7 +192,9 @@ 0 << 17+\ 0 << 16+\ 0 << 8+\ - &00FF ;SocketFS Number + 146 ;SocketFS Number + ;As allocated by pineapple in MID + ; socket_FSinfo @@ -255,19 +257,23 @@ ;Ignore file offset as we have streams... SWI XSocket_Read ;Call Internet module.. - LDRVC R0,[R13] ;If no error get byte from buff ADD R13,R13,#4 ;Release ws. - LDMVCFD R13!,{PC}^ - + BVS socket_read_error_hand ;Handle error + CMP R0,#0 ;Are we beyond EOF? + LDR R0,[R13,#-4] ;Get got octet + + LDMFD R13!,{R14} ;Get copy of lr + MOVNES PC,R14 ;Not eof just return + ORRS PC,R14,#C_Bit ;Return with Cset if EOF-on-next +socket_read_error_hand LDR R1,[R0] ;Get Errno DBF "Socket Err %1w\n" CMP R1,#EWOULDBLOCK ;Is Rx/Tx limits. - LDMEQFD R13!,{R14} ;Get lr early so we can set flags - MOV R0,#0 ;Retrun 0 char - t - ORREQ PC,R14,#C_Bit + LDMFD R13!,{R14} ;Get lr early so we can set flags + MOVEQ R0,#0 ;Retrun 0 char - t + ORREQS PC,R14,#C_Bit ;Now we have to work out what to do in the case of other errs!. - LDMFD R13!,{R14} ;Return with V set!., m - ORR PC,R14,#V_Bit ;Set V flag + ORRS PC,R14,#V_Bit ;Set V flag socket_write STMFD R13!,{R1-R2,R14} DBF "File write entry called\n - R0 %0b\n - R1 %1w\n" @@ -348,14 +354,16 @@ ;Swi dispatch trick B socket_unknownCall - B socket_returnZero + B socket_returnZero ;I suppose if we get real posy + ;we could try to return th TCP seq no + ;associted with the next-to-read octet. LDMFD R13!,{r0-R4,PC} ;Ignore ARgs 1 - B socket_returnZero + B socket_Extent ;Try to determine if Len(Rcvbuf)>0 LDMFD R13!,{R0-R4,PC} ;Ignore Args 3 B socket_allocedsize B socket_EOFcheck ;Is TCP connection open? B socket_Flush ;Not called but triv to code! - B socket_Extent + B socket_Ensure LDMFD R13!,{R0-R4,PC} ;Not suported .. unbuffered B socket_returnZeros LDMFD R13!,{R0-R4,PC} ;If you've implemented an imagefs over socketfs I'd be shocked! @@ -365,9 +373,14 @@ MOV R2,#1 MOV PC,R14 -socket_Extent +socket_Ensure LDMFD R13!,{R0-R4,R14} ;What do we need to tell Fileswitch + ;In the Acorn only stack case we could uses + ;SIOCGPCBHEADS but I suspect this interface is libale to + ;change between stacks. Also it is not provided by + ;freenet + MOV R2,#1 MOV PC,R14 @@ -388,9 +401,17 @@ SUB R0,R1,#1 ;Get File handle ADD R1,R12,#tempbyte MOV R2,#0 ;Send 0 octets - SWI XSocket_Send - LDMFD R13!,{R1-R4,PC} - + SWI XSocket_Write ;Std BSD method of flushing (allegdly) + LDMVCFD R13!,{R1-R4,PC} + ;Write now as it would not be un-reasonable for one of our clients to + ;loop till EOF, then call Fileswitch's close- which flushes files before + ;closing, we must check for EPIPE as the remote end may now be down. + + LDR R1,[R0] ;Get ErrNo + CMP R1,#EPIPE ;Is error Broken pipe? + LDMFD R13!,{R1-R4,R14} ;Get regs to return.. + BICEQS Pc,R14,#V_Bit ;If so then clear the error + ;and return socket_EOFcheck LDMFD R13!,{R0-R4,R14} STMFD R13!,{R14} @@ -399,11 +420,24 @@ MOV R2,#1 ;Get a byte MOV R3,#(MSG_PEEK + MSG_DONTWAIT) ;but don't remove it from the queue SWI XSocket_Recv + MOV R1,#0 ;Clear in case of no error LDRVS R1,[R0] ;If err get ErrNo MOVS R0,R0 ;IF read()==0 CMPNE R1,#ECONNRESET ; || ==ECONNRESET MOV R2,#0 ; then R2=0 SUBEQ R2,R2,#1 ; else R2=-1 + LDMFD R13!,{PC}^ ;return! + +socket_Extent + LDMFD R13!,{R0-R4,R14} + STMFD R13!,{R14} + SUB R0,R1,#1 ;Get socket handle + ADD R1,R12,#tempbyte + MOV R2,#1 ;Get a byte + MOV R3,#(MSG_PEEK + MSG_DONTWAIT) ;but don't remove it from the queue + SWI XSocket_Recv + MOV R2,#0 ;Clear return value + ADDVC R2,R2,#1 ;Inc in case of no error. LDMFD R13!,{PC}^ ;return! socket_unknownCall