From owner-freebsd-hackers Mon Feb 10 2:12:45 2003 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 B90FB37B401 for ; Mon, 10 Feb 2003 02:12:43 -0800 (PST) Received: from relay1.ntu-kpi.kiev.ua (www.ntu-kpi.kiev.ua [212.111.192.161]) by mx1.FreeBSD.org (Postfix) with ESMTP id F0CE343F75 for ; Mon, 10 Feb 2003 02:12:38 -0800 (PST) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: by relay1.ntu-kpi.kiev.ua (Postfix, from userid 426) id 9CEE819D23; Mon, 10 Feb 2003 12:12:32 +0200 (EET) Received: from comsys.ntu-kpi.kiev.ua (eth0.comsys.ntu-kpi.kiev.ua [10.0.1.184]) by relay1.ntu-kpi.kiev.ua (Postfix) with ESMTP id CFCD119D65; Mon, 10 Feb 2003 12:12:31 +0200 (EET) Received: from pm514-9.comsys.ntu-kpi.kiev.ua (pm514-9.comsys.ntu-kpi.kiev.ua [10.18.54.109]) by comsys.ntu-kpi.kiev.ua (8.11.6/8.11.6) with ESMTP id h1AAGub02378; Mon, 10 Feb 2003 12:16:56 +0200 (EET) Received: from pm514-9.comsys.ntu-kpi.kiev.ua (localhost [127.0.0.1]) by pm514-9.comsys.ntu-kpi.kiev.ua (8.12.6/8.12.6) with ESMTP id h1AAC4H0008193; Mon, 10 Feb 2003 12:12:04 +0200 (EET) (envelope-from simon@pm514-9.comsys.ntu-kpi.kiev.ua) Received: (from simon@localhost) by pm514-9.comsys.ntu-kpi.kiev.ua (8.12.6/8.12.6/Submit) id h1AAC2GR008192; Mon, 10 Feb 2003 12:12:02 +0200 (EET) Date: Mon, 10 Feb 2003 12:12:02 +0200 (EET) Message-Id: <200302101012.h1AAC2GR008192@pm514-9.comsys.ntu-kpi.kiev.ua> From: Andrey Simonenko To: "Auge Mike" Cc: freebsd-hackers@freebsd.org Subject: Re: printf....! In-Reply-To: X-Newsgroups: lucky.freebsd.hackers User-Agent: tin/1.5.12-20020427 ("Sugar") (UNIX) (FreeBSD/4.7-STABLE (i386)) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sat, 8 Feb 2003 22:13:32 +0000 (UTC) in lucky.freebsd.hackers, Auge Mike wrote: > Hi all, > > I was trying to know how "printf" works in FreeBSD... I hvae reached to this > point : > > #define _write(fd, s, n) \ > __syscall(SYS_write, (int)(fd), (const void *)(s), (size_t)(n)) > > I'am not really familiar with the way FreeBSD handle interrupts. I like from > any one of you to tell me what functions will be called next and in which > files, till we get the string of the printf function argment displayed in > the terminal. > That means that printf(3) uses write(2). Write(2) is a system call with syscall number SYS_write (look at __syscall(2)). Syscalls are described in syscalls.master like files. There is at least one such file for every supported binary: /sys/kern/syscals.master, /sys/i386/linux/syscalls.master, etc. Syscalls implementation is a part of the kernel, so you need to get information about the name of the appropriate function for the syscall with the SYS_write number from the syscalls.master file and find this function in /sys sources. I suppose you need this one /sys/kern/sys_generic.c:write() See also: manual pages for write(2), syscall(2); "System Calls" chapter from the "x86 Assembly Language Programming" (available in "FreeBSD Developers' Handbook"). To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message