diff --git a/src/kernel/linux/v4.14/fs/hostfs/Makefile b/src/kernel/linux/v4.14/fs/hostfs/Makefile
new file mode 100644
index 0000000..d5beaff
--- /dev/null
+++ b/src/kernel/linux/v4.14/fs/hostfs/Makefile
@@ -0,0 +1,11 @@
+#
+# Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
+# Licensed under the GPL
+#
+
+hostfs-objs := hostfs_kern.o hostfs_user.o
+
+obj-y :=
+obj-$(CONFIG_HOSTFS) += hostfs.o
+
+include arch/um/scripts/Makefile.rules
diff --git a/src/kernel/linux/v4.14/fs/hostfs/hostfs.h b/src/kernel/linux/v4.14/fs/hostfs/hostfs.h
new file mode 100644
index 0000000..ffaec2e
--- /dev/null
+++ b/src/kernel/linux/v4.14/fs/hostfs/hostfs.h
@@ -0,0 +1,99 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __UM_FS_HOSTFS
+#define __UM_FS_HOSTFS
+
+#include <os.h>
+
+/*
+ * These are exactly the same definitions as in fs.h, but the names are
+ * changed so that this file can be included in both kernel and user files.
+ */
+
+#define HOSTFS_ATTR_MODE	1
+#define HOSTFS_ATTR_UID 	2
+#define HOSTFS_ATTR_GID 	4
+#define HOSTFS_ATTR_SIZE	8
+#define HOSTFS_ATTR_ATIME	16
+#define HOSTFS_ATTR_MTIME	32
+#define HOSTFS_ATTR_CTIME	64
+#define HOSTFS_ATTR_ATIME_SET	128
+#define HOSTFS_ATTR_MTIME_SET	256
+
+/* These two are unused by hostfs. */
+#define HOSTFS_ATTR_FORCE	512	/* Not a change, but a change it */
+#define HOSTFS_ATTR_ATTR_FLAG	1024
+
+/*
+ * If you are very careful, you'll notice that these two are missing:
+ *
+ * #define ATTR_KILL_SUID	2048
+ * #define ATTR_KILL_SGID	4096
+ *
+ * and this is because they were added in 2.5 development.
+ * Actually, they are not needed by most ->setattr() methods - they are set by
+ * callers of notify_change() to notify that the setuid/setgid bits must be
+ * dropped.
+ * notify_change() will delete those flags, make sure attr->ia_valid & ATTR_MODE
+ * is on, and remove the appropriate bits from attr->ia_mode (attr is a
+ * "struct iattr *"). -BlaisorBlade
+ */
+
+struct hostfs_iattr {
+	unsigned int	ia_valid;
+	unsigned short	ia_mode;
+	uid_t		ia_uid;
+	gid_t		ia_gid;
+	loff_t		ia_size;
+	struct timespec	ia_atime;
+	struct timespec	ia_mtime;
+	struct timespec	ia_ctime;
+};
+
+struct hostfs_stat {
+	unsigned long long ino;
+	unsigned int mode;
+	unsigned int nlink;
+	unsigned int uid;
+	unsigned int gid;
+	unsigned long long size;
+	struct timespec atime, mtime, ctime;
+	unsigned int blksize;
+	unsigned long long blocks;
+	unsigned int maj;
+	unsigned int min;
+};
+
+extern int stat_file(const char *path, struct hostfs_stat *p, int fd);
+extern int access_file(char *path, int r, int w, int x);
+extern int open_file(char *path, int r, int w, int append);
+extern void *open_dir(char *path, int *err_out);
+extern void seek_dir(void *stream, unsigned long long pos);
+extern char *read_dir(void *stream, unsigned long long *pos_out,
+		      unsigned long long *ino_out, int *len_out,
+		      unsigned int *type_out);
+extern void close_file(void *stream);
+extern int replace_file(int oldfd, int fd);
+extern void close_dir(void *stream);
+extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
+extern int write_file(int fd, unsigned long long *offset, const char *buf,
+		      int len);
+extern int lseek_file(int fd, long long offset, int whence);
+extern int fsync_file(int fd, int datasync);
+extern int file_create(char *name, int mode);
+extern int set_attr(const char *file, struct hostfs_iattr *attrs, int fd);
+extern int make_symlink(const char *from, const char *to);
+extern int unlink_file(const char *file);
+extern int do_mkdir(const char *file, int mode);
+extern int do_rmdir(const char *file);
+extern int do_mknod(const char *file, int mode, unsigned int major,
+		    unsigned int minor);
+extern int link_file(const char *from, const char *to);
+extern int hostfs_do_readlink(char *file, char *buf, int size);
+extern int rename_file(char *from, char *to);
+extern int rename2_file(char *from, char *to, unsigned int flags);
+extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
+		     long long *bfree_out, long long *bavail_out,
+		     long long *files_out, long long *ffree_out,
+		     void *fsid_out, int fsid_size, long *namelen_out);
+
+#endif
diff --git a/src/kernel/linux/v4.14/fs/hostfs/hostfs_kern.c b/src/kernel/linux/v4.14/fs/hostfs/hostfs_kern.c
new file mode 100644
index 0000000..c148e7f
--- /dev/null
+++ b/src/kernel/linux/v4.14/fs/hostfs/hostfs_kern.c
@@ -0,0 +1,1018 @@
+/*
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
+ * Licensed under the GPL
+ *
+ * Ported the filesystem routines to 2.5.
+ * 2003-02-10 Petr Baudis <pasky@ucw.cz>
+ */
+
+#include <linux/fs.h>
+#include <linux/magic.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/pagemap.h>
+#include <linux/statfs.h>
+#include <linux/slab.h>
+#include <linux/seq_file.h>
+#include <linux/mount.h>
+#include <linux/namei.h>
+#include "hostfs.h"
+#include <init.h>
+#include <kern.h>
+
+struct hostfs_inode_info {
+	int fd;
+	fmode_t mode;
+	struct inode vfs_inode;
+	struct mutex open_mutex;
+};
+
+static inline struct hostfs_inode_info *HOSTFS_I(struct inode *inode)
+{
+	return list_entry(inode, struct hostfs_inode_info, vfs_inode);
+}
+
+#define FILE_HOSTFS_I(file) HOSTFS_I(file_inode(file))
+
+/* Changed in hostfs_args before the kernel starts running */
+static char *root_ino = "";
+static int append = 0;
+
+static const struct inode_operations hostfs_iops;
+static const struct inode_operations hostfs_dir_iops;
+static const struct inode_operations hostfs_link_iops;
+
+#ifndef MODULE
+static int __init hostfs_args(char *options, int *add)
+{
+	char *ptr;
+
+	ptr = strchr(options, ',');
+	if (ptr != NULL)
+		*ptr++ = '\0';
+	if (*options != '\0')
+		root_ino = options;
+
+	options = ptr;
+	while (options) {
+		ptr = strchr(options, ',');
+		if (ptr != NULL)
+			*ptr++ = '\0';
+		if (*options != '\0') {
+			if (!strcmp(options, "append"))
+				append = 1;
+			else printf("hostfs_args - unsupported option - %s\n",
+				    options);
+		}
+		options = ptr;
+	}
+	return 0;
+}
+
+__uml_setup("hostfs=", hostfs_args,
+"hostfs=<root dir>,<flags>,...\n"
+"    This is used to set hostfs parameters.  The root directory argument\n"
+"    is used to confine all hostfs mounts to within the specified directory\n"
+"    tree on the host.  If this isn't specified, then a user inside UML can\n"
+"    mount anything on the host that's accessible to the user that's running\n"
+"    it.\n"
+"    The only flag currently supported is 'append', which specifies that all\n"
+"    files opened by hostfs will be opened in append mode.\n\n"
+);
+#endif
+
+static char *__dentry_name(struct dentry *dentry, char *name)
+{
+	char *p = dentry_path_raw(dentry, name, PATH_MAX);
+	char *root;
+	size_t len;
+
+	root = dentry->d_sb->s_fs_info;
+	len = strlen(root);
+	if (IS_ERR(p)) {
+		__putname(name);
+		return NULL;
+	}
+
+	/*
+	 * This function relies on the fact that dentry_path_raw() will place
+	 * the path name at the end of the provided buffer.
+	 */
+	BUG_ON(p + strlen(p) + 1 != name + PATH_MAX);
+
+	strlcpy(name, root, PATH_MAX);
+	if (len > p - name) {
+		__putname(name);
+		return NULL;
+	}
+
+	if (p > name + len)
+		strcpy(name + len, p);
+
+	return name;
+}
+
+static char *dentry_name(struct dentry *dentry)
+{
+	char *name = __getname();
+	if (!name)
+		return NULL;
+
+	return __dentry_name(dentry, name);
+}
+
+static char *inode_name(struct inode *ino)
+{
+	struct dentry *dentry;
+	char *name;
+
+	dentry = d_find_alias(ino);
+	if (!dentry)
+		return NULL;
+
+	name = dentry_name(dentry);
+
+	dput(dentry);
+
+	return name;
+}
+
+static char *follow_link(char *link)
+{
+	int len, n;
+	char *name, *resolved, *end;
+
+	name = __getname();
+	if (!name) {
+		n = -ENOMEM;
+		goto out_free;
+	}
+
+	n = hostfs_do_readlink(link, name, PATH_MAX);
+	if (n < 0)
+		goto out_free;
+	else if (n == PATH_MAX) {
+		n = -E2BIG;
+		goto out_free;
+	}
+
+	if (*name == '/')
+		return name;
+
+	end = strrchr(link, '/');
+	if (end == NULL)
+		return name;
+
+	*(end + 1) = '\0';
+	len = strlen(link) + strlen(name) + 1;
+
+	resolved = kmalloc(len, GFP_KERNEL);
+	if (resolved == NULL) {
+		n = -ENOMEM;
+		goto out_free;
+	}
+
+	sprintf(resolved, "%s%s", link, name);
+	__putname(name);
+	kfree(link);
+	return resolved;
+
+ out_free:
+	__putname(name);
+	return ERR_PTR(n);
+}
+
+static struct inode *hostfs_iget(struct super_block *sb)
+{
+	struct inode *inode = new_inode(sb);
+	if (!inode)
+		return ERR_PTR(-ENOMEM);
+	return inode;
+}
+
+static int hostfs_statfs(struct dentry *dentry, struct kstatfs *sf)
+{
+	/*
+	 * do_statfs uses struct statfs64 internally, but the linux kernel
+	 * struct statfs still has 32-bit versions for most of these fields,
+	 * so we convert them here
+	 */
+	int err;
+	long long f_blocks;
+	long long f_bfree;
+	long long f_bavail;
+	long long f_files;
+	long long f_ffree;
+
+	err = do_statfs(dentry->d_sb->s_fs_info,
+			&sf->f_bsize, &f_blocks, &f_bfree, &f_bavail, &f_files,
+			&f_ffree, &sf->f_fsid, sizeof(sf->f_fsid),
+			&sf->f_namelen);
+	if (err)
+		return err;
+	sf->f_blocks = f_blocks;
+	sf->f_bfree = f_bfree;
+	sf->f_bavail = f_bavail;
+	sf->f_files = f_files;
+	sf->f_ffree = f_ffree;
+	sf->f_type = HOSTFS_SUPER_MAGIC;
+	return 0;
+}
+
+static struct inode *hostfs_alloc_inode(struct super_block *sb)
+{
+	struct hostfs_inode_info *hi;
+
+	hi = kmalloc(sizeof(*hi), GFP_KERNEL_ACCOUNT);
+	if (hi == NULL)
+		return NULL;
+	hi->fd = -1;
+	hi->mode = 0;
+	inode_init_once(&hi->vfs_inode);
+	mutex_init(&hi->open_mutex);
+	return &hi->vfs_inode;
+}
+
+static void hostfs_evict_inode(struct inode *inode)
+{
+	truncate_inode_pages_final(&inode->i_data);
+	clear_inode(inode);
+	if (HOSTFS_I(inode)->fd != -1) {
+		close_file(&HOSTFS_I(inode)->fd);
+		HOSTFS_I(inode)->fd = -1;
+	}
+}
+
+static void hostfs_i_callback(struct rcu_head *head)
+{
+	struct inode *inode = container_of(head, struct inode, i_rcu);
+	kfree(HOSTFS_I(inode));
+}
+
+static void hostfs_destroy_inode(struct inode *inode)
+{
+	call_rcu(&inode->i_rcu, hostfs_i_callback);
+}
+
+static int hostfs_show_options(struct seq_file *seq, struct dentry *root)
+{
+	const char *root_path = root->d_sb->s_fs_info;
+	size_t offset = strlen(root_ino) + 1;
+
+	if (strlen(root_path) > offset)
+		seq_show_option(seq, root_path + offset, NULL);
+
+	if (append)
+		seq_puts(seq, ",append");
+
+	return 0;
+}
+
+static const struct super_operations hostfs_sbops = {
+	.alloc_inode	= hostfs_alloc_inode,
+	.destroy_inode	= hostfs_destroy_inode,
+	.evict_inode	= hostfs_evict_inode,
+	.statfs		= hostfs_statfs,
+	.show_options	= hostfs_show_options,
+};
+
+static int hostfs_readdir(struct file *file, struct dir_context *ctx)
+{
+	void *dir;
+	char *name;
+	unsigned long long next, ino;
+	int error, len;
+	unsigned int type;
+
+	name = dentry_name(file->f_path.dentry);
+	if (name == NULL)
+		return -ENOMEM;
+	dir = open_dir(name, &error);
+	__putname(name);
+	if (dir == NULL)
+		return -error;
+	next = ctx->pos;
+	seek_dir(dir, next);
+	while ((name = read_dir(dir, &next, &ino, &len, &type)) != NULL) {
+		if (!dir_emit(ctx, name, len, ino, type))
+			break;
+		ctx->pos = next;
+	}
+	close_dir(dir);
+	return 0;
+}
+
+static int hostfs_open(struct inode *ino, struct file *file)
+{
+	char *name;
+	fmode_t mode;
+	int err;
+	int r, w, fd;
+
+	mode = file->f_mode & (FMODE_READ | FMODE_WRITE);
+	if ((mode & HOSTFS_I(ino)->mode) == mode)
+		return 0;
+
+	mode |= HOSTFS_I(ino)->mode;
+
+retry:
+	r = w = 0;
+
+	if (mode & FMODE_READ)
+		r = 1;
+	if (mode & FMODE_WRITE)
+		r = w = 1;
+
+	name = dentry_name(file->f_path.dentry);
+	if (name == NULL)
+		return -ENOMEM;
+
+	fd = open_file(name, r, w, append);
+	__putname(name);
+	if (fd < 0)
+		return fd;
+
+	mutex_lock(&HOSTFS_I(ino)->open_mutex);
+	/* somebody else had handled it first? */
+	if ((mode & HOSTFS_I(ino)->mode) == mode) {
+		mutex_unlock(&HOSTFS_I(ino)->open_mutex);
+		close_file(&fd);
+		return 0;
+	}
+	if ((mode | HOSTFS_I(ino)->mode) != mode) {
+		mode |= HOSTFS_I(ino)->mode;
+		mutex_unlock(&HOSTFS_I(ino)->open_mutex);
+		close_file(&fd);
+		goto retry;
+	}
+	if (HOSTFS_I(ino)->fd == -1) {
+		HOSTFS_I(ino)->fd = fd;
+	} else {
+		err = replace_file(fd, HOSTFS_I(ino)->fd);
+		close_file(&fd);
+		if (err < 0) {
+			mutex_unlock(&HOSTFS_I(ino)->open_mutex);
+			return err;
+		}
+	}
+	HOSTFS_I(ino)->mode = mode;
+	mutex_unlock(&HOSTFS_I(ino)->open_mutex);
+
+	return 0;
+}
+
+static int hostfs_file_release(struct inode *inode, struct file *file)
+{
+	filemap_write_and_wait(inode->i_mapping);
+
+	return 0;
+}
+
+static int hostfs_fsync(struct file *file, loff_t start, loff_t end,
+			int datasync)
+{
+	struct inode *inode = file->f_mapping->host;
+	int ret;
+
+	ret = file_write_and_wait_range(file, start, end);
+	if (ret)
+		return ret;
+
+	inode_lock(inode);
+	ret = fsync_file(HOSTFS_I(inode)->fd, datasync);
+	inode_unlock(inode);
+
+	return ret;
+}
+
+static const struct file_operations hostfs_file_fops = {
+	.llseek		= generic_file_llseek,
+	.splice_read	= generic_file_splice_read,
+	.read_iter	= generic_file_read_iter,
+	.write_iter	= generic_file_write_iter,
+	.mmap		= generic_file_mmap,
+	.open		= hostfs_open,
+	.release	= hostfs_file_release,
+	.fsync		= hostfs_fsync,
+};
+
+static const struct file_operations hostfs_dir_fops = {
+	.llseek		= generic_file_llseek,
+	.iterate_shared	= hostfs_readdir,
+	.read		= generic_read_dir,
+	.open		= hostfs_open,
+	.fsync		= hostfs_fsync,
+};
+
+static int hostfs_writepage(struct page *page, struct writeback_control *wbc)
+{
+	struct address_space *mapping = page->mapping;
+	struct inode *inode = mapping->host;
+	char *buffer;
+	loff_t base = page_offset(page);
+	int count = PAGE_SIZE;
+	int end_index = inode->i_size >> PAGE_SHIFT;
+	int err;
+
+	if (page->index >= end_index)
+		count = inode->i_size & (PAGE_SIZE-1);
+
+	buffer = kmap(page);
+
+	err = write_file(HOSTFS_I(inode)->fd, &base, buffer, count);
+	if (err != count) {
+		ClearPageUptodate(page);
+		goto out;
+	}
+
+	if (base > inode->i_size)
+		inode->i_size = base;
+
+	if (PageError(page))
+		ClearPageError(page);
+	err = 0;
+
+ out:
+	kunmap(page);
+
+	unlock_page(page);
+	return err;
+}
+
+static int hostfs_readpage(struct file *file, struct page *page)
+{
+	char *buffer;
+	loff_t start = page_offset(page);
+	int bytes_read, ret = 0;
+
+	buffer = kmap(page);
+	bytes_read = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer,
+			PAGE_SIZE);
+	if (bytes_read < 0) {
+		ClearPageUptodate(page);
+		SetPageError(page);
+		ret = bytes_read;
+		goto out;
+	}
+
+	memset(buffer + bytes_read, 0, PAGE_SIZE - bytes_read);
+
+	ClearPageError(page);
+	SetPageUptodate(page);
+
+ out:
+	flush_dcache_page(page);
+	kunmap(page);
+	unlock_page(page);
+	return ret;
+}
+
+static int hostfs_write_begin(struct file *file, struct address_space *mapping,
+			      loff_t pos, unsigned len, unsigned flags,
+			      struct page **pagep, void **fsdata)
+{
+	pgoff_t index = pos >> PAGE_SHIFT;
+
+	*pagep = grab_cache_page_write_begin(mapping, index, flags);
+	if (!*pagep)
+		return -ENOMEM;
+	return 0;
+}
+
+static int hostfs_write_end(struct file *file, struct address_space *mapping,
+			    loff_t pos, unsigned len, unsigned copied,
+			    struct page *page, void *fsdata)
+{
+	struct inode *inode = mapping->host;
+	void *buffer;
+	unsigned from = pos & (PAGE_SIZE - 1);
+	int err;
+
+	buffer = kmap(page);
+	err = write_file(FILE_HOSTFS_I(file)->fd, &pos, buffer + from, copied);
+	kunmap(page);
+
+	if (!PageUptodate(page) && err == PAGE_SIZE)
+		SetPageUptodate(page);
+
+	/*
+	 * If err > 0, write_file has added err to pos, so we are comparing
+	 * i_size against the last byte written.
+	 */
+	if (err > 0 && (pos > inode->i_size))
+		inode->i_size = pos;
+	unlock_page(page);
+	put_page(page);
+
+	return err;
+}
+
+static const struct address_space_operations hostfs_aops = {
+	.writepage 	= hostfs_writepage,
+	.readpage	= hostfs_readpage,
+	.set_page_dirty = __set_page_dirty_nobuffers,
+	.write_begin	= hostfs_write_begin,
+	.write_end	= hostfs_write_end,
+};
+
+static int read_name(struct inode *ino, char *name)
+{
+	dev_t rdev;
+	struct hostfs_stat st;
+	int err = stat_file(name, &st, -1);
+	if (err)
+		return err;
+
+	/* Reencode maj and min with the kernel encoding.*/
+	rdev = MKDEV(st.maj, st.min);
+
+	switch (st.mode & S_IFMT) {
+	case S_IFLNK:
+		ino->i_op = &hostfs_link_iops;
+		break;
+	case S_IFDIR:
+		ino->i_op = &hostfs_dir_iops;
+		ino->i_fop = &hostfs_dir_fops;
+		break;
+	case S_IFCHR:
+	case S_IFBLK:
+	case S_IFIFO:
+	case S_IFSOCK:
+		init_special_inode(ino, st.mode & S_IFMT, rdev);
+		ino->i_op = &hostfs_iops;
+		break;
+	case S_IFREG:
+		ino->i_op = &hostfs_iops;
+		ino->i_fop = &hostfs_file_fops;
+		ino->i_mapping->a_ops = &hostfs_aops;
+		break;
+	default:
+		return -EIO;
+	}
+
+	ino->i_ino = st.ino;
+	ino->i_mode = st.mode;
+	set_nlink(ino, st.nlink);
+	i_uid_write(ino, st.uid);
+	i_gid_write(ino, st.gid);
+	ino->i_atime = st.atime;
+	ino->i_mtime = st.mtime;
+	ino->i_ctime = st.ctime;
+	ino->i_size = st.size;
+	ino->i_blocks = st.blocks;
+	return 0;
+}
+
+static int hostfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
+			 bool excl)
+{
+	struct inode *inode;
+	char *name;
+	int error, fd;
+
+	inode = hostfs_iget(dir->i_sb);
+	if (IS_ERR(inode)) {
+		error = PTR_ERR(inode);
+		goto out;
+	}
+
+	error = -ENOMEM;
+	name = dentry_name(dentry);
+	if (name == NULL)
+		goto out_put;
+
+	fd = file_create(name, mode & 0777);
+	if (fd < 0)
+		error = fd;
+	else
+		error = read_name(inode, name);
+
+	__putname(name);
+	if (error)
+		goto out_put;
+
+	HOSTFS_I(inode)->fd = fd;
+	HOSTFS_I(inode)->mode = FMODE_READ | FMODE_WRITE;
+	d_instantiate(dentry, inode);
+	return 0;
+
+ out_put:
+	iput(inode);
+ out:
+	return error;
+}
+
+static struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
+				    unsigned int flags)
+{
+	struct inode *inode;
+	char *name;
+	int err;
+
+	inode = hostfs_iget(ino->i_sb);
+	if (IS_ERR(inode)) {
+		err = PTR_ERR(inode);
+		goto out;
+	}
+
+	err = -ENOMEM;
+	name = dentry_name(dentry);
+	if (name == NULL)
+		goto out_put;
+
+	err = read_name(inode, name);
+
+	__putname(name);
+	if (err == -ENOENT) {
+		iput(inode);
+		inode = NULL;
+	}
+	else if (err)
+		goto out_put;
+
+	d_add(dentry, inode);
+	return NULL;
+
+ out_put:
+	iput(inode);
+ out:
+	return ERR_PTR(err);
+}
+
+static int hostfs_link(struct dentry *to, struct inode *ino,
+		       struct dentry *from)
+{
+	char *from_name, *to_name;
+	int err;
+
+	if ((from_name = dentry_name(from)) == NULL)
+		return -ENOMEM;
+	to_name = dentry_name(to);
+	if (to_name == NULL) {
+		__putname(from_name);
+		return -ENOMEM;
+	}
+	err = link_file(to_name, from_name);
+	__putname(from_name);
+	__putname(to_name);
+	return err;
+}
+
+static int hostfs_unlink(struct inode *ino, struct dentry *dentry)
+{
+	char *file;
+	int err;
+
+	if (append)
+		return -EPERM;
+
+	if ((file = dentry_name(dentry)) == NULL)
+		return -ENOMEM;
+
+	err = unlink_file(file);
+	__putname(file);
+	return err;
+}
+
+static int hostfs_symlink(struct inode *ino, struct dentry *dentry,
+			  const char *to)
+{
+	char *file;
+	int err;
+
+	if ((file = dentry_name(dentry)) == NULL)
+		return -ENOMEM;
+	err = make_symlink(file, to);
+	__putname(file);
+	return err;
+}
+
+static int hostfs_mkdir(struct inode *ino, struct dentry *dentry, umode_t mode)
+{
+	char *file;
+	int err;
+
+	if ((file = dentry_name(dentry)) == NULL)
+		return -ENOMEM;
+	err = do_mkdir(file, mode);
+	__putname(file);
+	return err;
+}
+
+static int hostfs_rmdir(struct inode *ino, struct dentry *dentry)
+{
+	char *file;
+	int err;
+
+	if ((file = dentry_name(dentry)) == NULL)
+		return -ENOMEM;
+	err = do_rmdir(file);
+	__putname(file);
+	return err;
+}
+
+static int hostfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
+{
+	struct inode *inode;
+	char *name;
+	int err;
+
+	inode = hostfs_iget(dir->i_sb);
+	if (IS_ERR(inode)) {
+		err = PTR_ERR(inode);
+		goto out;
+	}
+
+	err = -ENOMEM;
+	name = dentry_name(dentry);
+	if (name == NULL)
+		goto out_put;
+
+	init_special_inode(inode, mode, dev);
+	err = do_mknod(name, mode, MAJOR(dev), MINOR(dev));
+	if (err)
+		goto out_free;
+
+	err = read_name(inode, name);
+	__putname(name);
+	if (err)
+		goto out_put;
+
+	d_instantiate(dentry, inode);
+	return 0;
+
+ out_free:
+	__putname(name);
+ out_put:
+	iput(inode);
+ out:
+	return err;
+}
+
+static int hostfs_rename2(struct inode *old_dir, struct dentry *old_dentry,
+			  struct inode *new_dir, struct dentry *new_dentry,
+			  unsigned int flags)
+{
+	char *old_name, *new_name;
+	int err;
+
+	if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE))
+		return -EINVAL;
+
+	old_name = dentry_name(old_dentry);
+	if (old_name == NULL)
+		return -ENOMEM;
+	new_name = dentry_name(new_dentry);
+	if (new_name == NULL) {
+		__putname(old_name);
+		return -ENOMEM;
+	}
+	if (!flags)
+		err = rename_file(old_name, new_name);
+	else
+		err = rename2_file(old_name, new_name, flags);
+
+	__putname(old_name);
+	__putname(new_name);
+	return err;
+}
+
+static int hostfs_permission(struct inode *ino, int desired)
+{
+	char *name;
+	int r = 0, w = 0, x = 0, err;
+
+	if (desired & MAY_NOT_BLOCK)
+		return -ECHILD;
+
+	if (desired & MAY_READ) r = 1;
+	if (desired & MAY_WRITE) w = 1;
+	if (desired & MAY_EXEC) x = 1;
+	name = inode_name(ino);
+	if (name == NULL)
+		return -ENOMEM;
+
+	if (S_ISCHR(ino->i_mode) || S_ISBLK(ino->i_mode) ||
+	    S_ISFIFO(ino->i_mode) || S_ISSOCK(ino->i_mode))
+		err = 0;
+	else
+		err = access_file(name, r, w, x);
+	__putname(name);
+	if (!err)
+		err = generic_permission(ino, desired);
+	return err;
+}
+
+static int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
+{
+	struct inode *inode = d_inode(dentry);
+	struct hostfs_iattr attrs;
+	char *name;
+	int err;
+
+	int fd = HOSTFS_I(inode)->fd;
+
+	err = setattr_prepare(dentry, attr);
+	if (err)
+		return err;
+
+	if (append)
+		attr->ia_valid &= ~ATTR_SIZE;
+
+	attrs.ia_valid = 0;
+	if (attr->ia_valid & ATTR_MODE) {
+		attrs.ia_valid |= HOSTFS_ATTR_MODE;
+		attrs.ia_mode = attr->ia_mode;
+	}
+	if (attr->ia_valid & ATTR_UID) {
+		attrs.ia_valid |= HOSTFS_ATTR_UID;
+		attrs.ia_uid = from_kuid(&init_user_ns, attr->ia_uid);
+	}
+	if (attr->ia_valid & ATTR_GID) {
+		attrs.ia_valid |= HOSTFS_ATTR_GID;
+		attrs.ia_gid = from_kgid(&init_user_ns, attr->ia_gid);
+	}
+	if (attr->ia_valid & ATTR_SIZE) {
+		attrs.ia_valid |= HOSTFS_ATTR_SIZE;
+		attrs.ia_size = attr->ia_size;
+	}
+	if (attr->ia_valid & ATTR_ATIME) {
+		attrs.ia_valid |= HOSTFS_ATTR_ATIME;
+		attrs.ia_atime = attr->ia_atime;
+	}
+	if (attr->ia_valid & ATTR_MTIME) {
+		attrs.ia_valid |= HOSTFS_ATTR_MTIME;
+		attrs.ia_mtime = attr->ia_mtime;
+	}
+	if (attr->ia_valid & ATTR_CTIME) {
+		attrs.ia_valid |= HOSTFS_ATTR_CTIME;
+		attrs.ia_ctime = attr->ia_ctime;
+	}
+	if (attr->ia_valid & ATTR_ATIME_SET) {
+		attrs.ia_valid |= HOSTFS_ATTR_ATIME_SET;
+	}
+	if (attr->ia_valid & ATTR_MTIME_SET) {
+		attrs.ia_valid |= HOSTFS_ATTR_MTIME_SET;
+	}
+	name = dentry_name(dentry);
+	if (name == NULL)
+		return -ENOMEM;
+	err = set_attr(name, &attrs, fd);
+	__putname(name);
+	if (err)
+		return err;
+
+	if ((attr->ia_valid & ATTR_SIZE) &&
+	    attr->ia_size != i_size_read(inode))
+		truncate_setsize(inode, attr->ia_size);
+
+	setattr_copy(inode, attr);
+	mark_inode_dirty(inode);
+	return 0;
+}
+
+static const struct inode_operations hostfs_iops = {
+	.permission	= hostfs_permission,
+	.setattr	= hostfs_setattr,
+};
+
+static const struct inode_operations hostfs_dir_iops = {
+	.create		= hostfs_create,
+	.lookup		= hostfs_lookup,
+	.link		= hostfs_link,
+	.unlink		= hostfs_unlink,
+	.symlink	= hostfs_symlink,
+	.mkdir		= hostfs_mkdir,
+	.rmdir		= hostfs_rmdir,
+	.mknod		= hostfs_mknod,
+	.rename		= hostfs_rename2,
+	.permission	= hostfs_permission,
+	.setattr	= hostfs_setattr,
+};
+
+static const char *hostfs_get_link(struct dentry *dentry,
+				   struct inode *inode,
+				   struct delayed_call *done)
+{
+	char *link;
+	if (!dentry)
+		return ERR_PTR(-ECHILD);
+	link = kmalloc(PATH_MAX, GFP_KERNEL);
+	if (link) {
+		char *path = dentry_name(dentry);
+		int err = -ENOMEM;
+		if (path) {
+			err = hostfs_do_readlink(path, link, PATH_MAX);
+			if (err == PATH_MAX)
+				err = -E2BIG;
+			__putname(path);
+		}
+		if (err < 0) {
+			kfree(link);
+			return ERR_PTR(err);
+		}
+	} else {
+		return ERR_PTR(-ENOMEM);
+	}
+
+	set_delayed_call(done, kfree_link, link);
+	return link;
+}
+
+static const struct inode_operations hostfs_link_iops = {
+	.get_link	= hostfs_get_link,
+};
+
+static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
+{
+	struct inode *root_inode;
+	char *host_root_path, *req_root = d;
+	int err;
+
+	sb->s_blocksize = 1024;
+	sb->s_blocksize_bits = 10;
+	sb->s_magic = HOSTFS_SUPER_MAGIC;
+	sb->s_op = &hostfs_sbops;
+	sb->s_d_op = &simple_dentry_operations;
+	sb->s_maxbytes = MAX_LFS_FILESIZE;
+
+	/* NULL is printed as <NULL> by sprintf: avoid that. */
+	if (req_root == NULL)
+		req_root = "";
+
+	err = -ENOMEM;
+	sb->s_fs_info = host_root_path =
+		kmalloc(strlen(root_ino) + strlen(req_root) + 2, GFP_KERNEL);
+	if (host_root_path == NULL)
+		goto out;
+
+	sprintf(host_root_path, "%s/%s", root_ino, req_root);
+
+	root_inode = new_inode(sb);
+	if (!root_inode)
+		goto out;
+
+	err = read_name(root_inode, host_root_path);
+	if (err)
+		goto out_put;
+
+	if (S_ISLNK(root_inode->i_mode)) {
+		char *name = follow_link(host_root_path);
+		if (IS_ERR(name)) {
+			err = PTR_ERR(name);
+			goto out_put;
+		}
+		err = read_name(root_inode, name);
+		kfree(name);
+		if (err)
+			goto out_put;
+	}
+
+	err = -ENOMEM;
+	sb->s_root = d_make_root(root_inode);
+	if (sb->s_root == NULL)
+		goto out;
+
+	return 0;
+
+out_put:
+	iput(root_inode);
+out:
+	return err;
+}
+
+static struct dentry *hostfs_read_sb(struct file_system_type *type,
+			  int flags, const char *dev_name,
+			  void *data)
+{
+	return mount_nodev(type, flags, data, hostfs_fill_sb_common);
+}
+
+static void hostfs_kill_sb(struct super_block *s)
+{
+	kill_anon_super(s);
+	kfree(s->s_fs_info);
+}
+
+static struct file_system_type hostfs_type = {
+	.owner 		= THIS_MODULE,
+	.name 		= "hostfs",
+	.mount	 	= hostfs_read_sb,
+	.kill_sb	= hostfs_kill_sb,
+	.fs_flags 	= 0,
+};
+MODULE_ALIAS_FS("hostfs");
+
+static int __init init_hostfs(void)
+{
+	return register_filesystem(&hostfs_type);
+}
+
+static void __exit exit_hostfs(void)
+{
+	unregister_filesystem(&hostfs_type);
+}
+
+module_init(init_hostfs)
+module_exit(exit_hostfs)
+MODULE_LICENSE("GPL");
diff --git a/src/kernel/linux/v4.14/fs/hostfs/hostfs_user.c b/src/kernel/linux/v4.14/fs/hostfs/hostfs_user.c
new file mode 100644
index 0000000..9c1e0f0
--- /dev/null
+++ b/src/kernel/linux/v4.14/fs/hostfs/hostfs_user.c
@@ -0,0 +1,410 @@
+/*
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
+ * Licensed under the GPL
+ */
+
+#include <stdio.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/vfs.h>
+#include <sys/syscall.h>
+#include "hostfs.h"
+#include <utime.h>
+
+static void stat64_to_hostfs(const struct stat64 *buf, struct hostfs_stat *p)
+{
+	p->ino = buf->st_ino;
+	p->mode = buf->st_mode;
+	p->nlink = buf->st_nlink;
+	p->uid = buf->st_uid;
+	p->gid = buf->st_gid;
+	p->size = buf->st_size;
+	p->atime.tv_sec = buf->st_atime;
+	p->atime.tv_nsec = 0;
+	p->ctime.tv_sec = buf->st_ctime;
+	p->ctime.tv_nsec = 0;
+	p->mtime.tv_sec = buf->st_mtime;
+	p->mtime.tv_nsec = 0;
+	p->blksize = buf->st_blksize;
+	p->blocks = buf->st_blocks;
+	p->maj = os_major(buf->st_rdev);
+	p->min = os_minor(buf->st_rdev);
+}
+
+int stat_file(const char *path, struct hostfs_stat *p, int fd)
+{
+	struct stat64 buf;
+
+	if (fd >= 0) {
+		if (fstat64(fd, &buf) < 0)
+			return -errno;
+	} else if (lstat64(path, &buf) < 0) {
+		return -errno;
+	}
+	stat64_to_hostfs(&buf, p);
+	return 0;
+}
+
+int access_file(char *path, int r, int w, int x)
+{
+	int mode = 0;
+
+	if (r)
+		mode = R_OK;
+	if (w)
+		mode |= W_OK;
+	if (x)
+		mode |= X_OK;
+	if (access(path, mode) != 0)
+		return -errno;
+	else return 0;
+}
+
+int open_file(char *path, int r, int w, int append)
+{
+	int mode = 0, fd;
+
+	if (r && !w)
+		mode = O_RDONLY;
+	else if (!r && w)
+		mode = O_WRONLY;
+	else if (r && w)
+		mode = O_RDWR;
+	else panic("Impossible mode in open_file");
+
+	if (append)
+		mode |= O_APPEND;
+	fd = open64(path, mode);
+	if (fd < 0)
+		return -errno;
+	else return fd;
+}
+
+void *open_dir(char *path, int *err_out)
+{
+	DIR *dir;
+
+	dir = opendir(path);
+	*err_out = errno;
+
+	return dir;
+}
+
+void seek_dir(void *stream, unsigned long long pos)
+{
+	DIR *dir = stream;
+
+	seekdir(dir, pos);
+}
+
+char *read_dir(void *stream, unsigned long long *pos_out,
+	       unsigned long long *ino_out, int *len_out,
+	       unsigned int *type_out)
+{
+	DIR *dir = stream;
+	struct dirent *ent;
+
+	ent = readdir(dir);
+	if (ent == NULL)
+		return NULL;
+	*len_out = strlen(ent->d_name);
+	*ino_out = ent->d_ino;
+	*type_out = ent->d_type;
+	*pos_out = ent->d_off;
+	return ent->d_name;
+}
+
+int read_file(int fd, unsigned long long *offset, char *buf, int len)
+{
+	int n;
+
+	n = pread64(fd, buf, len, *offset);
+	if (n < 0)
+		return -errno;
+	*offset += n;
+	return n;
+}
+
+int write_file(int fd, unsigned long long *offset, const char *buf, int len)
+{
+	int n;
+
+	n = pwrite64(fd, buf, len, *offset);
+	if (n < 0)
+		return -errno;
+	*offset += n;
+	return n;
+}
+
+int lseek_file(int fd, long long offset, int whence)
+{
+	int ret;
+
+	ret = lseek64(fd, offset, whence);
+	if (ret < 0)
+		return -errno;
+	return 0;
+}
+
+int fsync_file(int fd, int datasync)
+{
+	int ret;
+	if (datasync)
+		ret = fdatasync(fd);
+	else
+		ret = fsync(fd);
+
+	if (ret < 0)
+		return -errno;
+	return 0;
+}
+
+int replace_file(int oldfd, int fd)
+{
+	return dup2(oldfd, fd);
+}
+
+void close_file(void *stream)
+{
+	close(*((int *) stream));
+}
+
+void close_dir(void *stream)
+{
+	closedir(stream);
+}
+
+int file_create(char *name, int mode)
+{
+	int fd;
+
+	fd = open64(name, O_CREAT | O_RDWR, mode);
+	if (fd < 0)
+		return -errno;
+	return fd;
+}
+
+int set_attr(const char *file, struct hostfs_iattr *attrs, int fd)
+{
+	struct hostfs_stat st;
+	struct timeval times[2];
+	int err, ma;
+
+	if (attrs->ia_valid & HOSTFS_ATTR_MODE) {
+		if (fd >= 0) {
+			if (fchmod(fd, attrs->ia_mode) != 0)
+				return -errno;
+		} else if (chmod(file, attrs->ia_mode) != 0) {
+			return -errno;
+		}
+	}
+	if (attrs->ia_valid & HOSTFS_ATTR_UID) {
+		if (fd >= 0) {
+			if (fchown(fd, attrs->ia_uid, -1))
+				return -errno;
+		} else if (chown(file, attrs->ia_uid, -1)) {
+			return -errno;
+		}
+	}
+	if (attrs->ia_valid & HOSTFS_ATTR_GID) {
+		if (fd >= 0) {
+			if (fchown(fd, -1, attrs->ia_gid))
+				return -errno;
+		} else if (chown(file, -1, attrs->ia_gid)) {
+			return -errno;
+		}
+	}
+	if (attrs->ia_valid & HOSTFS_ATTR_SIZE) {
+		if (fd >= 0) {
+			if (ftruncate(fd, attrs->ia_size))
+				return -errno;
+		} else if (truncate(file, attrs->ia_size)) {
+			return -errno;
+		}
+	}
+
+	/*
+	 * Update accessed and/or modified time, in two parts: first set
+	 * times according to the changes to perform, and then call futimes()
+	 * or utimes() to apply them.
+	 */
+	ma = (HOSTFS_ATTR_ATIME_SET | HOSTFS_ATTR_MTIME_SET);
+	if (attrs->ia_valid & ma) {
+		err = stat_file(file, &st, fd);
+		if (err != 0)
+			return err;
+
+		times[0].tv_sec = st.atime.tv_sec;
+		times[0].tv_usec = st.atime.tv_nsec / 1000;
+		times[1].tv_sec = st.mtime.tv_sec;
+		times[1].tv_usec = st.mtime.tv_nsec / 1000;
+
+		if (attrs->ia_valid & HOSTFS_ATTR_ATIME_SET) {
+			times[0].tv_sec = attrs->ia_atime.tv_sec;
+			times[0].tv_usec = attrs->ia_atime.tv_nsec / 1000;
+		}
+		if (attrs->ia_valid & HOSTFS_ATTR_MTIME_SET) {
+			times[1].tv_sec = attrs->ia_mtime.tv_sec;
+			times[1].tv_usec = attrs->ia_mtime.tv_nsec / 1000;
+		}
+
+		if (fd >= 0) {
+			if (futimes(fd, times) != 0)
+				return -errno;
+		} else if (utimes(file, times) != 0) {
+			return -errno;
+		}
+	}
+
+	/* Note: ctime is not handled */
+	if (attrs->ia_valid & (HOSTFS_ATTR_ATIME | HOSTFS_ATTR_MTIME)) {
+		err = stat_file(file, &st, fd);
+		attrs->ia_atime = st.atime;
+		attrs->ia_mtime = st.mtime;
+		if (err != 0)
+			return err;
+	}
+	return 0;
+}
+
+int make_symlink(const char *from, const char *to)
+{
+	int err;
+
+	err = symlink(to, from);
+	if (err)
+		return -errno;
+	return 0;
+}
+
+int unlink_file(const char *file)
+{
+	int err;
+
+	err = unlink(file);
+	if (err)
+		return -errno;
+	return 0;
+}
+
+int do_mkdir(const char *file, int mode)
+{
+	int err;
+
+	err = mkdir(file, mode);
+	if (err)
+		return -errno;
+	return 0;
+}
+
+int do_rmdir(const char *file)
+{
+	int err;
+
+	err = rmdir(file);
+	if (err)
+		return -errno;
+	return 0;
+}
+
+int do_mknod(const char *file, int mode, unsigned int major, unsigned int minor)
+{
+	int err;
+
+	err = mknod(file, mode, os_makedev(major, minor));
+	if (err)
+		return -errno;
+	return 0;
+}
+
+int link_file(const char *to, const char *from)
+{
+	int err;
+
+	err = link(to, from);
+	if (err)
+		return -errno;
+	return 0;
+}
+
+int hostfs_do_readlink(char *file, char *buf, int size)
+{
+	int n;
+
+	n = readlink(file, buf, size);
+	if (n < 0)
+		return -errno;
+	if (n < size)
+		buf[n] = '\0';
+	return n;
+}
+
+int rename_file(char *from, char *to)
+{
+	int err;
+
+	err = rename(from, to);
+	if (err < 0)
+		return -errno;
+	return 0;
+}
+
+int rename2_file(char *from, char *to, unsigned int flags)
+{
+	int err;
+
+#ifndef SYS_renameat2
+#  ifdef __x86_64__
+#    define SYS_renameat2 316
+#  endif
+#  ifdef __i386__
+#    define SYS_renameat2 353
+#  endif
+#endif
+
+#ifdef SYS_renameat2
+	err = syscall(SYS_renameat2, AT_FDCWD, from, AT_FDCWD, to, flags);
+	if (err < 0) {
+		if (errno != ENOSYS)
+			return -errno;
+		else
+			return -EINVAL;
+	}
+	return 0;
+#else
+	return -EINVAL;
+#endif
+}
+
+int do_statfs(char *root, long *bsize_out, long long *blocks_out,
+	      long long *bfree_out, long long *bavail_out,
+	      long long *files_out, long long *ffree_out,
+	      void *fsid_out, int fsid_size, long *namelen_out)
+{
+	struct statfs64 buf;
+	int err;
+
+	err = statfs64(root, &buf);
+	if (err < 0)
+		return -errno;
+
+	*bsize_out = buf.f_bsize;
+	*blocks_out = buf.f_blocks;
+	*bfree_out = buf.f_bfree;
+	*bavail_out = buf.f_bavail;
+	*files_out = buf.f_files;
+	*ffree_out = buf.f_ffree;
+	memcpy(fsid_out, &buf.f_fsid,
+	       sizeof(buf.f_fsid) > fsid_size ? fsid_size :
+	       sizeof(buf.f_fsid));
+	*namelen_out = buf.f_namelen;
+
+	return 0;
+}
