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.

115<br />

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

rump___sysimpl_lseek(int fd, <strong>of</strong>f_t <strong>of</strong>fset, int whence)<br />

{<br />

register_t retval[2] = {0, 0};<br />

int error = 0;<br />

<strong>of</strong>f_t rv = -1;<br />

struct sys_lseek_args callarg;<br />

SPARG(&callarg, fd) = fd;<br />

SPARG(&callarg, PAD) = 0;<br />

SPARG(&callarg, <strong>of</strong>fset) = <strong>of</strong>fset;<br />

SPARG(&callarg, whence) = whence;<br />

}<br />

error = rsys_syscall(SYS_lseek, &callarg, size<strong>of</strong>(callarg), retval);<br />

rsys_seterrno(error);<br />

if (error == 0) {<br />

if (size<strong>of</strong>(<strong>of</strong>f_t) > size<strong>of</strong>(register_t))<br />

rv = *(<strong>of</strong>f_t *)retval;<br />

else<br />

rv = *retval;<br />

}<br />

return rv;<br />

Figure 3.12: Call stub for rump_sys_lseek(). <strong>The</strong> arguments from <strong>the</strong> client<br />

are marshalled into <strong>the</strong> argument structure which is supplied to <strong>the</strong> kernel entry<br />

point. <strong>The</strong> execution <strong>of</strong> <strong>the</strong> system call is requested using <strong>the</strong> rsys_syscall()<br />

routine. This routine invokes ei<strong>the</strong>r a direct function call into <strong>the</strong> rump kernel or a<br />

remote request, depending on if <strong>the</strong> rump kernel is local or remote, respectively.<br />

generated into sys/rump/librump/rumpkern/rump_syscalls.c — in our example<br />

this arranging means moving <strong>the</strong> arguments that rump_sys_lseek() was called<br />

with into <strong>the</strong> fields <strong>of</strong> struct sys_lseek_args. <strong>The</strong> wrapper for lseek is presented<br />

in Figure 3.12. <strong>The</strong> name <strong>of</strong> <strong>the</strong> wrapper in <strong>the</strong> illustration does not match<br />

rump_sys_lseek(). but <strong>the</strong> reference will be correctly translated by an alias in <strong>the</strong><br />

rump system call header. We will not go into details, except to say that <strong>the</strong> reason<br />

for it is to support compatibility system calls. For interested parties, <strong>the</strong> details are<br />

available in <strong>the</strong> rump_syscalls.h header file.

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

Saved successfully!

Ooh no, something went wrong!