I am trying to determine the size of a file passed as a command line
argument. I am using SYS_lseek. Here is the code up to that point:

_start:
        pop     eax             ; argc
        pop     eax             ; program name
        pop     ecx             ; file to convert
        jecxz   usage

        pop     eax
        or      eax, eax        ; Too many arguments?
        jne     usage

        ; Open the file
        push    dword O_RDWR
        push    ecx
        sys.open
        jc      cantopen

        mov     ebp, eax        ; Save fd

        ; Find file size
        sub     eax, eax
        push    dword SEEK_END
        push    eax
        push    eax             ; 0 bytes from eof
        push    ebp             ; fd
        sys.lseek
        jc      facerr

Unfortunately, the SYS_lseek returns an error (carry is set, EAX=0x16=ESPIPE).
Why? I am not creating any pipes there. The fd returned by the SYS_open
is 3, as expected, so why does SYS_lseek fail?

The sys.lseek macro does a mov eax, 199 / call kernel.function, where
kernel.function is int 80h / ret.

Adam

-- 
Can you imagine the silence if everyone said only what he knows!
                -- Karel Čapek


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to