From owner-freebsd-hackers@FreeBSD.ORG Wed Nov 10 14:00:28 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CECB316A4CE for ; Wed, 10 Nov 2004 14:00:28 +0000 (GMT) Received: from vsmtp14.tin.it (vsmtp14.tin.it [212.216.176.118]) by mx1.FreeBSD.org (Postfix) with ESMTP id 28C3B43D45 for ; Wed, 10 Nov 2004 14:00:28 +0000 (GMT) (envelope-from gerarra@tin.it) Received: from ims3a.cp.tin.it (192.168.70.103) by vsmtp14.tin.it (7.0.027) id 414B1A5801705B8A; Wed, 10 Nov 2004 15:00:29 +0100 Received: from [192.168.70.225] by ims3a.cp.tin.it with HTTP; Wed, 10 Nov 2004 15:00:27 +0100 Date: Wed, 10 Nov 2004 15:00:27 +0100 Message-ID: <41536AD50005DCD2@ims3a.cp.tin.it> In-Reply-To: <41921229.9080404@icyb.net.ua> From: gerarra@tin.it To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable cc: avg@icyb.net.ua Subject: RE: syscall: td_retval and zero return value X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Nov 2004 14:00:28 -0000 >I have very little assembler/x86 knowledge. >Could anyone please help me understand what it means to assign a >non-zero value to td_retval in a system call when return value of the >call is zero/success? > >I see in syscall() in src/sys/i386/i386/trap.c (btw is this the right >place?) that in such circumstances value from td_retval[] is put into >EAX and EDX registers and PSL_C (carry bit) is cleared in status/flags >register in a stack frame of a calling process. But I don't understand >what it practically means for the calling process. > >Thank you in advance. The way the handler advice you about syscalls failing is setting (and not= clearing as you were saying) the carry bit in eflags register (about ia32= ). A sort of errno (if you see in a C-coder view) value is set in eax (or, alternatively, edx) to show the reason of failing. There's no way to know= where error code is set; you can just verify pratically. You can find all these things on "Programmers handbook". cheers, rookie