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.

123<br />

Due to how etfs is implemented as part <strong>of</strong> <strong>the</strong> file system lookup routine, <strong>the</strong> mapped<br />

filenames is not browseable (i.e. readdir). However, it does not affect <strong>the</strong> intended<br />

use cases such as access to firmware images, since <strong>the</strong> pathnames are hardcoded into<br />

<strong>the</strong> kernel.<br />

In addition to taking a lookup key <strong>and</strong> <strong>the</strong> backing file path, <strong>the</strong> etfs interface<br />

takes an argument controlling how <strong>the</strong> mapped path is presented inside <strong>the</strong> rump<br />

kernel. <strong>The</strong> following three options are valid for non-directory host files: regular file,<br />

character device or block device. <strong>The</strong> main purpose <strong>of</strong> <strong>the</strong> type mapping feature is to<br />

be able to present a regular file on <strong>the</strong> host as a block device in <strong>the</strong> rump kernel. This<br />

mapping addresses an implementation detail in <strong>the</strong> NetBSD kernel: <strong>the</strong> only valid<br />

backends for disk file systems are block devices. On a regular system <strong>the</strong> mapping<br />

is done using <strong>the</strong> vnconfig utility to map regular files to /dev/vndxx block device<br />

nodes which can be mounted 11 . Avoiding vnconfig on <strong>the</strong> host is beneficial since<br />

using it requires root privileges regardless <strong>of</strong> <strong>the</strong> permissions <strong>of</strong> <strong>the</strong> backing file.<br />

With <strong>the</strong> etfs interface, a rump kernel requires only <strong>the</strong> minimal host privileges<br />

which allow it to read or write <strong>the</strong> backing file <strong>and</strong> <strong>the</strong>refore more finegrained access<br />

control is possible.<br />

In addition to mapping files, it is possible to map directories. <strong>The</strong>re are two options:<br />

a single-level mapping or <strong>the</strong> mapping <strong>of</strong> <strong>the</strong> whole directory subtree. For example,<br />

if /rump_a from <strong>the</strong> host is directory mapped to /a in <strong>the</strong> rump kernel, it is possible<br />

to access /rump_a/b from /a/b in both single-level <strong>and</strong> subtree mappings. However,<br />

/rump_a/b/c is visible at /a/b/c only if <strong>the</strong> directory subtree was mapped.<br />

Directory mappings do not allow <strong>the</strong> use <strong>of</strong> <strong>the</strong> type <strong>and</strong> <strong>of</strong>fset/size translations,<br />

but allow mappings without having to explicitly add <strong>the</strong>m for every single file. <strong>The</strong><br />

original use case for <strong>the</strong> directory mapping functionality was to get <strong>the</strong> kernel mod-<br />

11 For disk images with a partition table vnconfig provides multiple block devices in /dev. <strong>The</strong><br />

withsize variant <strong>of</strong> <strong>the</strong> etfs interface can be used to map a range <strong>of</strong> <strong>the</strong> host file corresponding to<br />

<strong>the</strong> desired partition. <strong>The</strong> p2k <strong>and</strong> ukfs libraries’ interfaces for mounting disk file systems provide<br />

support for this variant (manual pages at A–12 <strong>and</strong> A–38, respectively).

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

Saved successfully!

Ooh no, something went wrong!