Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Oct 2017 14:50:21 +0100
From:      Polytropon <freebsd@edvax.de>
To:        =?UTF-8?B?6aKc5Z+65bG5?= <aynuxsakura@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: FreeBSD Kernel Question
Message-ID:  <20171029145021.00d5e829.freebsd@edvax.de>
In-Reply-To: <CAJFY08yVZv7b7TqXp9qELCjmqfBJO-jf_KZ-cqgOEVnJLTbROg@mail.gmail.com>
References:  <CAJFY08yVZv7b7TqXp9qELCjmqfBJO-jf_KZ-cqgOEVnJLTbROg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20171029145021.00d5e829.freebsd>