Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Documentation/lkl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ defined by the application or a host library (tools/lkl/lib).
Building LKL on FreeBSD
-----------------------

$ pkg install binutils gcc49
$ pkg install binutils gcc49 gnubc

If you don't have a gcc binary:
$ ln -sf /usr/local/bin/gcc49 /usr/local/bin/gcc

Prefer ports binutils:
Prefer ports binutils and GNU bc(1):
$ export PATH=/sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/lib64/ccache

$ cd tools/lkl
Expand Down
1 change: 1 addition & 0 deletions arch/lkl/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include arch/lkl/auto.conf

KBUILD_CFLAGS += -fno-builtin
KBUILD_CFLAGS += -D__arch_um__

ifneq (,$(filter $(OUTPUT_FORMAT),elf64-x86-64 elf64-x86-64-freebsd))
KBUILD_CFLAGS += -fPIC
Expand Down
6 changes: 6 additions & 0 deletions arch/lkl/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ CONFIG_EXT4_FS_SECURITY=y
# CONFIG_DNOTIFY is not set
# CONFIG_INOTIFY_USER is not set
# CONFIG_MISC_FILESYSTEMS is not set
CONFIG_VFAT_FS=y
CONFIG_JFFS2_FS=y
CONFIG_XFS_FS=y
CONFIG_XFS_POSIX_ACL=y
CONFIG_BTRFS_FS=y
CONFIG_BTRFS_POSIX_ACL=y
CONFIG_CRYPTO_ANSI_CPRNG=y
CONFIG_PRINTK_TIME=y
CONFIG_DEBUG_INFO=y
Expand Down
6 changes: 6 additions & 0 deletions arch/lkl/include/asm/xor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef _ASM_LKL_XOR_H
#define _ASM_LKL_XOR_H

#include <asm-generic/xor.h>

#endif
2 changes: 1 addition & 1 deletion arch/lkl/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ LKL_SYSCALL0(sync);
LKL_SYSCALL5(llseek, unsigned int, fd, unsigned long, offset_high,
unsigned long, offset_low, __lkl__kernel_loff_t *, result,
unsigned int, whence);
LKL_SYSCALL2(fstat64, unsigned int, fd, struct lkl_stat64 *, statbuf);
LKL_SYSCALL2(fstat64, unsigned long, fd, struct lkl_stat64 *, statbuf);
LKL_SYSCALL4(fstatat64, unsigned int, dfd, const char *, filname,
struct lkl_stat64 *, statbuf, int, flag);
LKL_SYSCALL2(stat64, const char *, filename, struct lkl_stat64 *, statbuf);
Expand Down
83 changes: 63 additions & 20 deletions tools/lkl/lklfuse.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -96,6 +97,40 @@ static int lklfuse_opt_proc(void *data, const char *arg, int key,
}
}

static void lklfuse_xlat_stat(const struct lkl_stat64 *in, struct stat *st)
{
st->st_dev = in->st_dev;
st->st_ino = in->st_ino;
st->st_mode = in->st_mode;
st->st_nlink = in->st_nlink;
st->st_uid = in->st_uid;
st->st_gid = in->st_gid;
st->st_rdev = in->st_rdev;
st->st_size = in->st_size;
st->st_blksize = in->st_blksize;
st->st_blocks = in->st_blocks;
st->st_atim.tv_sec = in->st_atime;
st->st_atim.tv_nsec = in->st_atime_nsec;
st->st_mtim.tv_sec = in->st_mtime;
st->st_mtim.tv_nsec = in->st_mtime_nsec;
st->st_ctim.tv_sec = in->st_ctime;
st->st_ctim.tv_nsec = in->st_ctime_nsec;
}

static int lklfuse_fgetattr(const char *path, struct stat *st,
struct fuse_file_info *fi)
{
long ret;
struct lkl_stat64 lkl_stat;

ret = lkl_sys_fstat64(fi->fh, &lkl_stat);
if (ret)
return ret;

lklfuse_xlat_stat(&lkl_stat, st);
return 0;
}

static int lklfuse_getattr(const char *path, struct stat *st)
{
long ret;
Expand All @@ -105,23 +140,7 @@ static int lklfuse_getattr(const char *path, struct stat *st)
if (ret)
return ret;

st->st_dev = lkl_stat.st_dev;
st->st_ino = lkl_stat.st_ino;
st->st_mode = lkl_stat.st_mode;
st->st_nlink = lkl_stat.st_nlink;
st->st_uid = lkl_stat.st_uid;
st->st_gid = lkl_stat.st_gid;
st->st_rdev = lkl_stat.st_rdev;
st->st_size = lkl_stat.st_size;
st->st_blksize = lkl_stat.st_blksize;
st->st_blocks = lkl_stat.st_blocks;
st->st_atim.tv_sec = lkl_stat.st_atime;
st->st_atim.tv_nsec = lkl_stat.st_atime_nsec;
st->st_mtim.tv_sec = lkl_stat.st_mtime;
st->st_mtim.tv_nsec = lkl_stat.st_mtime_nsec;
st->st_ctim.tv_sec = lkl_stat.st_ctime;
st->st_ctim.tv_nsec = lkl_stat.st_ctime_nsec;

lklfuse_xlat_stat(&lkl_stat, st);
return 0;
}

Expand Down Expand Up @@ -193,7 +212,8 @@ static int lklfuse_truncate(const char *path, off_t off)
return lkl_sys_truncate(path, off);
}

static int lklfuse_open(const char *path, struct fuse_file_info *fi)
static int lklfuse_open3(const char *path, bool create, mode_t mode,
struct fuse_file_info *fi)
{
long ret;
int flags;
Expand All @@ -205,9 +225,12 @@ static int lklfuse_open(const char *path, struct fuse_file_info *fi)
else if ((fi->flags & O_ACCMODE) == O_RDWR)
flags = LKL_O_RDWR;
else
return -LKL_EINVAL;
return -EINVAL;

ret = lkl_sys_open(path, flags, 0);
if (create)
flags |= LKL_O_CREAT;

ret = lkl_sys_open(path, flags, mode);
if (ret < 0)
return ret;

Expand All @@ -216,6 +239,17 @@ static int lklfuse_open(const char *path, struct fuse_file_info *fi)
return 0;
}

static int lklfuse_create(const char *path, mode_t mode,
struct fuse_file_info *fi)
{
return lklfuse_open3(path, true, mode, fi);
}

static int lklfuse_open(const char *path, struct fuse_file_info *fi)
{
return lklfuse_open3(path, false, 0, fi);
}

static int lklfuse_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
Expand Down Expand Up @@ -451,7 +485,16 @@ const struct fuse_operations lklfuse_ops = {
.releasedir = lklfuse_releasedir,
.fsyncdir = lklfuse_fsyncdir,
.access = lklfuse_access,
.create = lklfuse_create,
.fgetattr = lklfuse_fgetattr,
/* .lock, */
.utimens = lklfuse_utimens,
/* .bmap, */
/* .ioctl, */
/* .poll, */
/* .write_buf, (SG io) */
/* .read_buf, (SG io) */
/* .flock, */
.fallocate = lklfuse_fallocate,
};

Expand Down