diff --git a/rtl/linux/syscalls.inc b/rtl/linux/syscalls.inc index 806523f2ef..7d272cb836 100644 --- a/rtl/linux/syscalls.inc +++ b/rtl/linux/syscalls.inc @@ -16,7 +16,7 @@ {No debugging for syslinux include !} {$IFDEF SYS_LINUX} {$UNDEF SYSCALL_DEBUG} -{$ENDIF SYS_LINUX} +{$ENDIF SYS_LINUX} {***************************************************************************** @@ -95,7 +95,7 @@ var LastEax, LastCall : longint; DebugTxt : string[20]; -{$ENDIF} +{$ENDIF} Function SysCall( callnr:longint;var regs : SysCallregs ):longint; { This function serves as an interface to do_SysCall. @@ -135,7 +135,7 @@ begin lastcnt:=0; writeln(sys_nr_txt[lastcall],debugtxt,lasteax); end; - end; + end; {$endif} end; @@ -220,6 +220,15 @@ begin end; +Function Sys_fstat(fd : longint;var Info:stat):Longint; +var + regs : SysCallregs; +begin + regs.reg2:=fd; + regs.reg3:=longint(@Info); + Sys_fStat:=SysCall(SysCall_nr_fstat,regs); +end; + Function Sys_Rename(Oldname,Newname:pchar):longint; var @@ -317,7 +326,7 @@ begin if sys_stat(f,st)<0 then exit; { Is it a dir ? } - if not((st.mode and $f000)=$4000)then + if not((st.mode and $f000)=$4000)then begin errno:=sys_enotdir; exit @@ -360,9 +369,9 @@ begin regs.reg4:=1; dummy:=SysCall(SysCall_nr_readdir,regs); { the readdir system call returns the number of bytes written } - if dummy=0 then - sys_readdir:=nil - else + if dummy=0 then + sys_readdir:=nil + else sys_readdir:=p^.buf end; @@ -389,7 +398,10 @@ end; { $Log$ - Revision 1.10 2000-02-09 16:59:32 peter + Revision 1.11 2000-07-08 18:02:39 peter + * do_open checks for directory, if directory then ioerror 2 + + Revision 1.10 2000/02/09 16:59:32 peter * truncated log Revision 1.9 2000/02/08 11:47:09 peter diff --git a/rtl/linux/syslinux.pp b/rtl/linux/syslinux.pp index 698bb60217..ec05bbdb23 100644 --- a/rtl/linux/syslinux.pp +++ b/rtl/linux/syslinux.pp @@ -352,6 +352,7 @@ Procedure Do_Open(var f;p:pchar;flags:longint); } var oflags : longint; + dirtest : stat; Begin { close first if opened } if ((flags and $10000)=0) then @@ -412,6 +413,15 @@ Begin Oflags:=Oflags and not(Open_RDWR); FileRec(f).Handle:=sys_open(p,oflags,438); end; +{ Check if it's a directory, then we should return io error 2 } + if ErrNo=0 then + begin + if (Sys_fstat(filerec(f).handle,dirtest)<>0) then + inoutres:=2 + else + if (dirtest.mode and STAT_IFMT)<>STAT_IFREG then + inoutres:=2; + end; Errno2Inoutres; End; @@ -783,7 +793,10 @@ End. { $Log$ - Revision 1.48 2000-06-30 22:14:03 peter + Revision 1.49 2000-07-08 18:02:39 peter + * do_open checks for directory, if directory then ioerror 2 + + Revision 1.48 2000/06/30 22:14:03 peter * removed obsolete crtlib code * support EINTR for read/write to restart the syscall