28.08.2015 Views

The Design and Implementation of the Anykernel and Rump Kernels

1F3KDce

1F3KDce

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

113<br />

any functions <strong>the</strong>y desire. We demonstrated <strong>the</strong> ability to call arbitrary kernel<br />

interfaces with <strong>the</strong> example on how to access <strong>the</strong> BPF driver without going through<br />

<strong>the</strong> file system (Figure 2.3). In that example we had to provide our own prototype<br />

<strong>and</strong> execute <strong>the</strong> entry point manually, since we did not use predefined application<br />

interfaces.<br />

3.6.1 System Calls<br />

On a regular NetBSD system, a user process calls <strong>the</strong> kernel through a stub in libc.<br />

<strong>The</strong> libc stub’s task is to trap into <strong>the</strong> kernel. <strong>The</strong> kernel examines <strong>the</strong> trapframe<br />

to see which system call was requested <strong>and</strong> proceeds to call <strong>the</strong> system call h<strong>and</strong>ler.<br />

After <strong>the</strong> call returns from <strong>the</strong> kernel, <strong>the</strong> libc stub sets errno.<br />

We are interested in preserving <strong>the</strong> st<strong>and</strong>ard libc application interface signature for<br />

rump kernel clients. Preserving <strong>the</strong> signature will make using existing code in rump<br />

kernel clients easier, since <strong>the</strong> calling convention for system calls will remain <strong>the</strong><br />

same. In this section we will examine how to generate h<strong>and</strong>lers for rump kernels<br />

with minimal manual labor. All <strong>of</strong> our discussion is written against how system<br />

calls are implemented in NetBSD. We use lseek() as an example <strong>of</strong> <strong>the</strong> problem<br />

<strong>and</strong> our solution.<br />

<strong>The</strong> signature <strong>of</strong> <strong>the</strong> lseek() system call stub in libc is as follows:<br />

<strong>of</strong>f_t<br />

lseek(int fildes, <strong>of</strong>f_t <strong>of</strong>fset, int whence)<br />

Prototypes are provided in header files. <strong>The</strong> header file varies from call to call. For<br />

example, <strong>the</strong> prototype <strong>of</strong> lseek() is made available to an application by including

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!