Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support iso images #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
10 changes: 5 additions & 5 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
{
'action_name': "lkl_make",
'inputs': [
"src/linux/**"
"vendor/linux/**"
],
'outputs': [
"src/linux/tools/lkl/liblkl.a"
"vendor/linux/tools/lkl/liblkl.a"
],
'action': [ 'make', '-j4', '-C', 'src/linux/tools/lkl', 'static' ],
'action': [ 'make', '-j4', '-C', 'vendor/linux/tools/lkl', 'static' ],
'message': 'Compiling LKL kernel..'
}
],
"cflags_cc": [ '-fpermissive', '-Wno-pointer-arith' ],
"defines": [ "CONFIG_AUTO_LKL_POSIX_HOST" ],
"libraries": [
"../src/linux/tools/lkl/liblkl.a"
"../vendor/linux/tools/lkl/liblkl.a"
],
"include_dirs": [
"<!(node -e \"require('nan')\")",
"src/linux/tools/lkl/include"
"vendor/linux/tools/lkl/include"
]
}
]
Expand Down
14 changes: 14 additions & 0 deletions defconfig.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/linux-tmp/arch/lkl/defconfig b/linux-tmp/arch/lkl/defconfig
--- a/linux-tmp/arch/lkl/defconfig
+++ b/linux-tmp/arch/lkl/defconfig
@@ -33,6 +33,10 @@ CONFIG_XFS_FS=y
CONFIG_XFS_POSIX_ACL=y
CONFIG_BTRFS_FS=y
CONFIG_BTRFS_FS_POSIX_ACL=y
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_UDF_FS=y
# CONFIG_FILE_LOCKING is not set
# CONFIG_DNOTIFY is not set
# CONFIG_INOTIFY_USER is not set
Binary file added test/fixtures/test.iso
Binary file not shown.
Binary file added test/fixtures/test.udf
Binary file not shown.
53 changes: 53 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ lkl.fs = Promise.promisifyAll(lkl.fs);
const RAW_FS_PATH = path.join(__dirname, 'fixtures/test.ext4');
const TMP_RAW_FS_PATH = path.join(__dirname, '.tmp-test.ext4');
const DISK_PATH = path.join(__dirname, 'fixtures/disk.img');
const ISO_FS_PATH = path.join(__dirname, 'fixtures/test.iso');
const UDF_FS_PATH = path.join(__dirname, 'fixtures/test.udf');

describe('node-lkl', function() {
it('should start the kernel', function() {
Expand Down Expand Up @@ -127,6 +129,57 @@ describe('node-lkl', function() {
})
});
});

describe('iso9660 image', function() {
before(function() {
this.disk = new lkl.disk.FileDisk(ISO_FS_PATH);
});

it('should mount', function() {
let diskId;
return lkl.diskAddAsync(this.disk)
.then(function(id) {
diskId = id;
return lkl.mountAsync(diskId, { readOnly: true, filesystem: 'iso9660'})
})
.then(lkl.umountAsync)
.then(function() {
return lkl.diskRemoveAsync(diskId);
});
});
});

describe('udf image', function() {
before(function() {
this.disk = new lkl.disk.FileDisk(UDF_FS_PATH);
});

it('should mount', function() {
let diskId;
let mpoint;
return lkl.diskAddAsync(this.disk)
.then(function(id) {
diskId = id;
return lkl.mountAsync(diskId, { readOnly: true, filesystem: 'udf'})
})
.then(function(mp) {
mpoint = mp;
return lkl.fs.readdirAsync(mp);
})
.then(function(files) {
assert.deepEqual(
files.sort(),
[ 'lost+found', '┬──┬◡ノ(° -°ノ)' ]
)
})
.then(function() {
return lkl.umountAsync(mpoint);
})
.then(function() {
return lkl.diskRemoveAsync(diskId);
});
});
});
});

describe('fs', function() {
Expand Down
5 changes: 3 additions & 2 deletions vendor.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -o errexit

git clone https://github.com/lkl/linux.git --depth=1 --branch master linux-tmp
git apply defconfig.patch

# Reset all access times to be in the past
find linux-tmp | xargs touch -a -d 2015-01-01
Expand Down Expand Up @@ -32,5 +33,5 @@ git -C linux-tmp clean -ffxd
rm -rf linux-tmp/.git

# Vendor the code
rm -rf src/linux
mv linux-tmp src/linux
rm -rf vendor/linux
mv linux-tmp vendor/linux
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions src/linux/arch/lkl/Kconfig → vendor/linux/arch/lkl/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ config LKL
select ARCH_THREAD_STACK_ALLOCATOR
select RWSEM_GENERIC_SPINLOCK
select GENERIC_ATOMIC64
select SEMAPHORE_SLEEPERS
select GENERIC_TIME
select GENERIC_FIND_NEXT_BIT
select GENERIC_HWEIGHT
select GENERIC_HARDIRQS
select FLATMEM
select FLAT_NODE_MEM_MAP
select GENERIC_CLOCKEVENTS
Expand All @@ -23,6 +19,10 @@ config LKL
select 64BIT if OUTPUT_FORMAT = "elf64-x86-64-freebsd"
select IP_PNP
select IP_PNP_DHCP
select TCP_CONG_BBR
select HIGH_RES_TIMERS
select NET_SCHED
select NET_SCH_FQ

config OUTPUTFORMAT
string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ endif

LDFLAGS_vmlinux += -r
LKL_ENTRY_POINTS := lkl_start_kernel lkl_sys_halt lkl_syscall lkl_trigger_irq \
lkl_get_free_irq lkl_put_irq lkl_create_syscall_thread \
lkl_stop_syscall_thread lkl_is_running
lkl_get_free_irq lkl_put_irq lkl_is_running

core-y += arch/lkl/kernel/
core-y += arch/lkl/mm/
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ CONFIG_XFS_FS=y
CONFIG_XFS_POSIX_ACL=y
CONFIG_BTRFS_FS=y
CONFIG_BTRFS_FS_POSIX_ACL=y
CONFIG_ISO9660_FS=y
CONFIG_JOLIET=y
CONFIG_ZISOFS=y
CONFIG_UDF_FS=y
# CONFIG_FILE_LOCKING is not set
# CONFIG_DNOTIFY is not set
# CONFIG_INOTIFY_USER is not set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,10 @@ struct lkl_host_operations {
* The function returns only after the kernel is shutdown with lkl_sys_halt.
*
* @lkl_ops - pointer to host operations
* @mem_size - how much memory to allocate to the Linux kernel
* @cmd_line - format for command line string that is going to be used to
* generate the Linux kernel command line
*/
int lkl_start_kernel(struct lkl_host_operations *lkl_ops,
unsigned long mem_size,
const char *cmd_line, ...);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ struct sockaddr {
#include <linux/virtio_blk.h>
#include <linux/virtio_net.h>
#include <linux/virtio_ring.h>
#include <linux/pkt_sched.h>

struct user_msghdr {
void __user *msg_name; /* ptr to socket address structure */
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ static struct irq_info {

static bool irqs_enabled;

static struct pt_regs dummy;

static void run_irq(int irq)
{
unsigned long flags;
struct pt_regs *old_regs = set_irq_regs((struct pt_regs *)&dummy);

/* interrupt handlers need to run with interrupts disabled */
local_irq_save(flags);
irq_enter();
generic_handle_irq(irq);
irq_exit();
set_irq_regs(old_regs);
local_irq_restore(flags);
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,26 @@ static char cmd_line[COMMAND_LINE_SIZE];
static void *init_sem;
static int is_running;
void (*pm_power_off)(void) = NULL;
static unsigned long mem_size;
static unsigned long mem_size = 64 * 1024 * 1024;

long lkl_panic_blink(int state)
{
lkl_ops->panic();
return 0;
}

static int __init setup_mem_size(char *str)
{
mem_size = memparse(str, NULL);
return 0;
}
early_param("mem", setup_mem_size);

void __init setup_arch(char **cl)
{
*cl = cmd_line;
panic_blink = lkl_panic_blink;
parse_early_param();
bootmem_init(mem_size);
}

Expand All @@ -41,14 +49,12 @@ static void __init lkl_run_kernel(void *arg)
}

int __init lkl_start_kernel(struct lkl_host_operations *ops,
unsigned long _mem_size,
const char *fmt, ...)
{
va_list ap;
int ret;

lkl_ops = ops;
mem_size = _mem_size;

va_start(ap, fmt);
ret = vsnprintf(boot_command_line, COMMAND_LINE_SIZE, fmt, ap);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading