From owner-freebsd-questions@freebsd.org Sun Oct 29 13:50:34 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 63DF9E63DE5 for ; Sun, 29 Oct 2017 13:50:34 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mailrelay11.qsc.de (mailrelay11.qsc.de [212.99.187.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.antispameurope.com", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D0A157E882 for ; Sun, 29 Oct 2017 13:50:33 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de ([213.148.129.14]) by mailrelay11.qsc.de; Sun, 29 Oct 2017 14:50:24 +0100 Received: from r56.edvax.de (port-92-195-74-193.dynamic.qsc.de [92.195.74.193]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPS id 63E9F3CBF9; Sun, 29 Oct 2017 14:50:22 +0100 (CET) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id v9TDoLc4002049; Sun, 29 Oct 2017 14:50:21 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Sun, 29 Oct 2017 14:50:21 +0100 From: Polytropon To: =?UTF-8?B?6aKc5Z+65bG5?= Cc: freebsd-questions@freebsd.org Subject: Re: FreeBSD Kernel Question Message-Id: <20171029145021.00d5e829.freebsd@edvax.de> In-Reply-To: References: Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-cloud-security-sender: freebsd@edvax.de X-cloud-security-recipient: freebsd-questions@freebsd.org X-cloud-security-Virusscan: CLEAN X-cloud-security-disclaimer: This E-Mail was scanned by E-Mailservice on mailrelay11.qsc.de with 9F7666A357B X-cloud-security-connect: mx01.qsc.de[213.148.129.14], TLS=1, IP=213.148.129.14 X-cloud-security: scantime:.1469 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Oct 2017 13:50:34 -0000 On Sun, 29 Oct 2017 17:03:34 +0800, 颜基屹 wrote: > Hello! I would like to know how to provide an API in the kernel space to > user space.Such As 'printf'. To be precise, printf() isn't a kernel interface, it's a library function (of the system's C library). The kernel equivalent would probably be the system call write(). See "man 2 write" and "man 3 printf" for details. If you want to add a mechanism that deals with kernel structures and functions from user space, I'd suggest having a look at the source code of the system C library. You can implement you own API in a similar way. But you can also add a new system call; extend the system call table and add your own code to the kernel. The kernel source is a good place to learn how to do this. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...