parent
7f6576c9dc
commit
4ce1ba8f6d
@ -1,2 +1,3 @@
|
|||||||
build
|
build
|
||||||
target
|
target
|
||||||
|
Cargo.lock
|
@ -1,16 +1,19 @@
|
|||||||
# Blog OS (Double Faults)
|
# RustOS for x86_64 SMP
|
||||||
[![Build Status](https://travis-ci.org/phil-opp/blog_os.svg?branch=post_10)](https://travis-ci.org/phil-opp/blog_os/branches)
|
|
||||||
|
|
||||||
This repository contains the source code for the [Double Faults](http://os.phil-opp.com/double-faults.html) post of the [Writing an OS in Rust](http://os.phil-opp.com) series.
|
A project of THU OS2018 spring.
|
||||||
|
|
||||||
**Check out the [master branch](https://github.com/phil-opp/blog_os) for more information.**
|
[Project Wiki](http://os.cs.tsinghua.edu.cn/oscourse/OS2018spring/projects/g11)
|
||||||
|
|
||||||
|
The goal is to write a mini OS in Rust with multicore supporting.
|
||||||
|
|
||||||
|
It will start from the post of the [Writing an OS in Rust](http://os.phil-opp.com) series. Then reimplement [xv6-x86_64](https://github.com/jserv/xv6-x86_64) in Rust style.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
You need to have `nasm`, `grub-mkrescue`, `xorriso`, `qemu`, a nightly Rust compiler, and [xargo] installed. Then you can run it using `make run`.
|
|
||||||
|
|
||||||
[xargo]: https://github.com/japaric/xargo
|
You need to have `nasm`, `grub-mkrescue`, `xorriso`, `qemu`, a nightly Rust compiler, and `xargo` installed. Then you can run it using `make run`.
|
||||||
|
|
||||||
Please file an issue if you have any problems.
|
A docker image is available and recommanded. Read [this](docker/README.md) for details.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
The source code is dual-licensed under MIT or the Apache License (Version 2.0).
|
The source code is dual-licensed under MIT or the Apache License (Version 2.0).
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[1;35m\]<$IMAGE_NAME>\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
|
@ -0,0 +1,40 @@
|
|||||||
|
FROM rustlang/rust:nightly
|
||||||
|
|
||||||
|
ENV IMAGE_NAME=blog_os-docker
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -q -y --no-install-recommends \
|
||||||
|
nasm \
|
||||||
|
binutils \
|
||||||
|
grub-common \
|
||||||
|
xorriso \
|
||||||
|
grub-pc-bin && \
|
||||||
|
apt-get autoremove -q -y && \
|
||||||
|
apt-get clean -q -y && \
|
||||||
|
rm -rf /var/lib/apt/lists/* && \
|
||||||
|
cargo install xargo && \
|
||||||
|
rustup component add rust-src
|
||||||
|
|
||||||
|
ENV GOSU_VERSION 1.10
|
||||||
|
|
||||||
|
RUN set -ex; \
|
||||||
|
\
|
||||||
|
fetchDeps=' \
|
||||||
|
ca-certificates \
|
||||||
|
wget \
|
||||||
|
'; \
|
||||||
|
apt-get update; \
|
||||||
|
apt-get install -y --no-install-recommends $fetchDeps; \
|
||||||
|
rm -rf /var/lib/apt/lists/*; \
|
||||||
|
\
|
||||||
|
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
|
||||||
|
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
|
||||||
|
chmod +x /usr/local/bin/gosu; \
|
||||||
|
# verify that the binary works
|
||||||
|
gosu nobody true;
|
||||||
|
|
||||||
|
COPY entrypoint.sh /usr/local/bin/
|
||||||
|
COPY .bash_aliases /etc/skel/
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||||
|
CMD ["/bin/bash"]
|
@ -0,0 +1,18 @@
|
|||||||
|
# Building Blog OS using Docker
|
||||||
|
Inspired by [redox].
|
||||||
|
You just need `git`, `make`, and `docker`.
|
||||||
|
It is beter to use a non-privileged user to run the `docker` command, which is usually achieved by adding the user to the `docker` group.
|
||||||
|
|
||||||
|
## Run the container to build Blog OS
|
||||||
|
You can build the docker image using `make docker_build` and run it using `make docker_run`.
|
||||||
|
|
||||||
|
## Run the container interactively
|
||||||
|
You can use the `make` target `docker_interactive` to get a shell in the container.
|
||||||
|
|
||||||
|
## Clear the toolchain caches (Cargo & Rustup)
|
||||||
|
To clean the docker volumes used by the toolchain, you just need to run `make docker_clean`.
|
||||||
|
|
||||||
|
[redox]: https://github.com/redox-os/redox
|
||||||
|
|
||||||
|
## License
|
||||||
|
The source code is dual-licensed under MIT or the Apache License (Version 2.0). This excludes the `blog` directory.
|
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
USER_NAME=blogos
|
||||||
|
USER_UID=${LOCAL_UID:-9001}
|
||||||
|
USER_GID=${LOCAL_GID:-9001}
|
||||||
|
|
||||||
|
groupadd --non-unique --gid $USER_GID $USER_NAME
|
||||||
|
useradd --non-unique --create-home --uid $USER_UID --gid $USER_GID $USER_NAME
|
||||||
|
|
||||||
|
export HOME=/home/$USER_NAME
|
||||||
|
|
||||||
|
TESTFILE=$RUSTUP_HOME/settings.toml
|
||||||
|
CACHED_UID=$(stat -c "%u" $TESTFILE)
|
||||||
|
CACHED_GID=$(stat -c "%g" $TESTFILE)
|
||||||
|
|
||||||
|
if [ $CACHED_UID != $USER_UID ] || [ $USER_GID != $CACHED_GID ]; then
|
||||||
|
chown $USER_UID:$USER_GID -R $CARGO_HOME $RUSTUP_HOME
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec gosu $USER_NAME "$@"
|
Loading…
Reference in new issue