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

fix doc and build issue (for linux) #2071

Merged
merged 8 commits into from
Oct 11, 2024
Merged
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
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ brew install x86_64-elf-binutils
brew tap nanovms/homebrew-qemu
brew install nanovms/homebrew-qemu/qemu
```
(note: ```go``` is only needed for certain [examples](#examples), but not for building the kernel)

For ARM-based Macs (M1/M2):

Expand Down Expand Up @@ -109,18 +110,24 @@ Note: This is only recommended for those that wish to make code changes to Nanos

Nanos doesn't need too many dependencies on Linux.

To build you need to install nasm && qemu:
To build you need to install nasm, qemu and go:

```
sudo apt-get install qemu-system-x86 nasm
sudo apt-get install qemu-system-x86 nasm golang-go
```
(note: ```go``` is only needed for certain [examples](#examples), but not for building the kernel)

For tests you'll also need the following installed:

```
sudo apt-get install ent ruby
```

Ops:
```
curl https://ops.city/get.sh -sSfL | sh
```

Rust:
```
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Expand All @@ -137,7 +144,11 @@ sudo apt-get install libfuse-dev fuse
make kernel
```

#### To run an example program from the test/runtime folder:
#### Examples


To run an example program from the test/runtime folder:

With hardware acceleration:

```
Expand All @@ -149,6 +160,15 @@ Without hardware acceleration:
make run-noaccel
```

Set ```TARGET``` to run a specific example:
```
make TARGET=<example> run
```

Check out [test/runtime](test/runtime/README.md) for a list of examples. Certain examples require ```go``` to be built.

More examples can be found in [docs/examples#examples](https://docs.ops.city/ops/examples#examples).

### Documentation

You can find more documentation on the ops [docs site](https://nanovms.gitbook.io/ops/)
Expand Down
2 changes: 1 addition & 1 deletion kernel.mk
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ msg_sed= SED $@
cmd_sed= $(SED) -e 's/\#/%/' <$^ >$@

msg_version= VERSION $@
cmd_version= $(MKDIR) $(dir $@); $(ECHO) "\#include <runtime.h>\nconst sstring gitversion = ss_static_init(\"$(shell $(GIT) rev-parse HEAD)\");" >$@
cmd_version= $(MKDIR) $(dir $@); ( $(ECHO) "\#include <runtime.h>"; $(ECHO) "const sstring gitversion = ss_static_init(\"$(shell $(GIT) rev-parse HEAD)\");" ) >$@

include ../../klib/klib.mk

Expand Down
2 changes: 1 addition & 1 deletion src/kernel/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ closure_function(1, 2, boolean, volume_add_mount_each,

boolean volume_add(u8 *uuid, char *label, void *priv, fs_init_handler init_handler, int attach_id)
{
storage_debug("new volume (%ld bytes)", size);
storage_debug("new volume");
volume v = allocate(storage.h, sizeof(*v));
if (v == INVALID_ADDRESS)
return false;
Expand Down
8 changes: 5 additions & 3 deletions src/unix/unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ sstring string_from_mmap_type(int type)
ss("unknown"));
}

#define format_protection_violation(vaddr, ctx, vm) \
#define pf_debug_protection_violation(vaddr, ctx, vm) \
pf_debug( \
"page_protection_violation\naddr 0x%lx, pc 0x%lx, " \
"error %c%c%c vm->flags (%s%s %s%s%s)\n", \
vaddr, frame_fault_pc(ctx->frame), \
Expand All @@ -218,7 +219,8 @@ sstring string_from_mmap_type(int type)
string_from_mmap_type(vm->flags & VMAP_MMAP_TYPE_MASK), \
(vm->flags & VMAP_FLAG_READABLE) ? ss("readable ") : sstring_empty(), \
(vm->flags & VMAP_FLAG_WRITABLE) ? ss("writable ") : sstring_empty(), \
(vm->flags & VMAP_FLAG_EXEC) ? ss("executable ") : sstring_empty()
(vm->flags & VMAP_FLAG_EXEC) ? ss("executable ") : sstring_empty() \
)

static boolean handle_protection_fault(context ctx, u64 vaddr, vmap vm)
{
Expand All @@ -238,7 +240,7 @@ static boolean handle_protection_fault(context ctx, u64 vaddr, vmap vm)
}

if (is_thread_context(ctx)) {
pf_debug(format_protection_violation(vaddr, ctx, vm));
pf_debug_protection_violation(vaddr, ctx, vm);
deliver_fault_signal(SIGSEGV, (thread)ctx, vaddr, SEGV_ACCERR);
return true;
}
Expand Down
66 changes: 66 additions & 0 deletions test/runtime/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Examples

Set ```TARGET``` to run a specific example:
```
make TARGET=<example> run
```

Certain examples require ```go``` to be built.

More examples can be found in [docs/examples#examples](https://docs.opsity/ops/examples#examples).

Example | Language | Description
-|-|-
aio | c |
aslr | c |
creat | c |
dup | c |
epoll | c |
eventfd | c |
fadvise | c |
fallocate | c |
fcntl | c |
fst | go |
fs_full | c |
ftrace | c |
futex | c |
futexrobust | c |
getdents | c |
getrandom | c |
hw | c | hello world (dynamic linking)
hws | c | hello world (static linking)
hwg | go | hello world
inotify | c |
io_uring | c |
ktest | c |
mkdir | c |
mmap | c |
netlink | c |
netsock | c |
nullpage | c |
paging | c |
pipe | c |
readv | c |
rename | c |
sandbox | c |
sendfile | c |
shmem | c |
signal | c |
sigoverflow | c |
socketpair | c |
symlink | c |
syslog | c |
thread_test | c |
time | c |
tlbshootdown | c |
tun | c |
udploop | c |
umcg | c |
unixsocket | c |
unlink | c |
vsyscall | c |
web | c | webserver on localhost:8080 (dynamic linking)
webs | c | webserver on localhost:8080 (static linking)
webg | go | webserver on localhost:8080
write | c |
writev | c |
3 changes: 2 additions & 1 deletion test/unit/udp_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ int main(int argc, char ** argv)
buffer target = vector_pop(unassoc);
u32 daddr;
u16 dport;
parse_v4_address_and_port(target, &daddr, &dport);
if (!parse_v4_address_and_port(target, &daddr, &dport))
test_error("failed to parse address and port");

u16 lport = DEFAULT_LOCAL_PORT;
u64 result;
Expand Down