Skip to content

Commit

Permalink
Porting RawPosix to Lind_Project (#6)
Browse files Browse the repository at this point in the history
* change to use V6

* accept debug

* debug accept

* debug accept

* debug accept

* debug accept

* debug accept

* debug accept

* debug accept

* debug accept

* debug accept

* debug accept

* debug accept

* debug accept

* debug accept

* debug accept

* debug accept

* debug accept

* rm debug info

* debug bind

* debug connect

* recvfrom

* recvfrom

* recvfrom

* recvfrom

* sem

* sem

* sem

* sem

* sem

* poll

* poll

* poll

* poll

* poll

* poll

* poll

* poll

* poll

* poll

* poll

* poll

* poll

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* select

* accept

* accept

* accept

* accept

* accept

* accept

* accept

* accept

* accept

* accept

* accept

* setitimer/getrlimit/setrlimit

* epoll

* epoll

* epoll_create

* epoll_ctl

* epoll_wait

* epoll_wait

* epoll_wait

* epoll_wait

* epoll_wait

* epoll_wait

* epoll_wait

* epoll_wait

* epoll_wait

* epoll - add mapping table

* epoll

* epoll

* epoll

* epoll

* epoll

* epoll cleanup

* add writev

* cloexec

* cloexec

* fix warnings

* removing panic in netcalls

* add err handling for fscalls

* err handling for get_fd

* getdents

* open

* unlink/link

* fix return value

* fix return value

* fix return value

* fix return value

* callback refine

* add bind path conversion

* accept

* accept

* accept

* accept

* accept

* accept

* accept

* bind

* bind

* bind

* bind

* bind

* bind

* connect/sendto

* uds

* debug

* debug

* debug

* debug

* debug postgres

* [feature] add err handling for all libc:: calls

* fix

* mmap

* getsockname

* getsockname

* getsockname

* getsockname

* getsockname

* getsockname

* getsockname

* getsockname

* getsockopt

* getsockopt

* getsockopt

* getsockopt

* getsockopt

* getsockopt

* getsockopt

* getsockopt

* getsockopt

* getsockopt

* comment out err print

* comment out err print

* select

* bind

* bind

* bind

* bind

* fcntl

* rm select print

* accept

* refine bind/connect

* debug dashmap arr'

* debug dashmap arr

* debug dashmap arr

* debug dashmap arr

* debug dashmap arr

* debug dashmap arr

* debug dashmap arr

* vec

* arr

* arr

* arr

* arr

* arr

* change to vec

* change to vec

* bind

* bind

* connect

* rm bind/connect pt

* bind

* bind

* bind

* bind

* bind

* check fd_set

* check fd_set

* close

* update fd interface and select syscall

* select

* debug select

* debug select

* debug select

* debug select

* debug select

* debug select

* printing fdtable details

* printing fdtable details

* printing fdtable details

* printing fdtable details

* printing fdtable details

* printing fdtable details

* made new container work

* debug select

* debug select

* debug select

* debug select

* debug select

* debug select

* debug select

* try fix by adding rm ref count in close

* try to see why kernel fd start from 8 instead of 3

* try run lamp

* socket

* getpeername

* getpeername

* getpeername

* getpeername

* getpeername

* getpeername

* getpeername

* getpeername

* getpeername

* getpeername

* getpeername

* getpeername

* cleanup print

* update the fdtable to newer version

* check the error cause

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* comment out print

---------

Co-authored-by: Alice W. <[email protected]>
  • Loading branch information
yashaswi2000 and Yaxuan-w authored Sep 12, 2024
1 parent 4251219 commit 409aa58
Show file tree
Hide file tree
Showing 62 changed files with 19,532 additions and 212 deletions.
26 changes: 26 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Use an official Rust image as a parent image
FROM ubuntu:latest
ARG DEBIAN_FRONTEND=noninteractive
ARG arch=x86_64

# Install tools and dependencies for building Rust projects
RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
curl \
libssl-dev \
git
# Install Rust from source
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
# Add cargo bin to PATH
ENV PATH="/root/.cargo/bin:${PATH}"

# Install the nightly Rust toolchain
RUN rustup toolchain install nightly

# Set the default toolchain to nightly
RUN rustup default nightly

# Verify installation
RUN rustc --version

20 changes: 20 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Rust (Unstable)",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"rust-lang.rust"
]
}
},
"forwardPorts": [],
"postCreateCommand": "cargo check",
"remoteUser": "root"
}

35 changes: 35 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Description

Fixes # (issue)

<!-- Please include a summary of the changes and the related issue. -->
<!-- Please also include relevant motivation and context. Why is this change required? What problem does it solve? -->
<!-- List any dependencies that are required for this change. -->

### Type of change

<!-- Please delete options that are not relevant. -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

## How Has This Been Tested?

<!-- Please describe the tests that you ran to verify your changes. -->
<!-- Provide instructions so we can reproduce. -->
<!-- Please also list any relevant details for your test configuration -->

- Test A - `lind_project/tests/test_cases/test_a.c`
- Test B - `lind_project/tests/test_cases/test_b.c`

## Checklist:

<!-- Add details about the checklist whenever needed -->

- [ ] My code follows the style guidelines of this project
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] Any dependent changes have been added to a pull request and/or merged in other modules (native-client, lind-glibc, lind-project)
63 changes: 63 additions & 0 deletions .github/workflows/lind-selfhost.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: RustPOSIX Build

# Controls when the workflow will run
on:
push:
branches:
- develop
- main
pull_request:
branches:
- develop
- main
# Triggers the workflow on push or pull request events but only for the develop branch
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: self-hosted
if: github.event.pull_request.draft == false
steps:
- name: Echo out branch values
run: |
echo github.base_ref: ${{ github.base_ref }}
echo github.head_ref: ${{ github.head_ref }}
echo github.ref: ${{ github.ref }}
cd /home/lind/lind_project/
- name: Checkout lind-project
run: |
git --git-dir /home/lind/lind_project/.git remote update origin --prune;
git --git-dir /home/lind/lind_project/.git checkout --force remotes/origin/develop;
- name: In the land of RUSTPOSIX where the shadows lie (PR request)
if: github.head_ref != ''
run: |
git --git-dir /home/lind/lind_project/src/safeposix-rust/.git remote update origin --prune;
git --git-dir /home/lind/lind_project/src/safeposix-rust/.git checkout remotes/origin/${{ github.head_ref }};
make rustposix;
- name: In the land of RUSTPOSIX where the shadows lie (Develop/Push)
if: github.head_ref == ''
run: |
git --git-dir /home/lind/lind_project/src/safeposix-rust/.git remote update origin --prune;
git --git-dir /home/lind/lind_project/src/safeposix-rust/.git checkout remotes/origin/develop;
make rustposix;
- name: One NACL to rule them all
run: |
git --git-dir /home/lind/lind_project/src/native_client/.git remote update origin --prune;
git --git-dir /home/lind/lind_project/src/native_client/.git checkout remotes/origin/develop;
make nacl;
- name: One GLIBC to find them
run: |
git --git-dir /home/lind/lind_project/src/lind_glibc/.git remote update origin --prune;
git --git-dir /home/lind/lind_project/src/lind_glibc/.git checkout remotes/origin/develop;
make glibc;
- name: One ring to INSTALL them all
run: |
make install;
- name: And in darkness TEST them
run: |
make test-verbose;
26 changes: 26 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Rust

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

env:
CARGO_TERM_COLOR: always

jobs:

build_and_test:
name: Rust project - latest
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- nightly
steps:
- uses: actions/checkout@v4
- run: ./gen_netdevs.sh
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo build --verbose
- run: cargo test --lib --verbose
21 changes: 11 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/
/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Expand All @@ -10,12 +9,14 @@ Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# RustRover
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Added by cargo

/target

**/net_devices

linddata*
gen_netdevs
lind.metadata
lind.md.log
5 changes: 5 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ignore = [
"src/safeposix/syscalls/net_constants.rs",
"src/safeposix/syscalls/sys_constants.rs",
"src/safeposix/syscalls/fs_constants.rs",
]
63 changes: 63 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[package]
name = "rustposix"
version = "0.1.0"
authors = ["Nicholas Smith Renner <[email protected]>", "Jonathan Eli Singer <[email protected]>", "Tristan J. Brigham <[email protected]>"]
edition = "2018"

[lib]
path = "src/lib.rs"
# cdylib is a dynamically linkable library, which is great for linking into
# C programs and similar. rlib is needed for the criterion benchmarking libary
# and creates one of Rust's static libraries. We are currently not generating
# dylib files which are Rust's internal (non-stable) ABI.
# Source: https://users.rust-lang.org/t/what-is-the-difference-between-dylib-and-cdylib/28847/3
crate-type = ["cdylib","rlib"]
test = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0", features = ["derive", "rc"] }
serde_cbor = "0.10"
libc = "0.2"
ringbuf = "0.2.6"
dashmap = { version = "5.1", features=["serde"] }
parking_lot = "0.12"
bit-set = "0.5"

[dependencies.lazy_static]
version = "1.0"
features = ["spin_no_std"]

[dev-dependencies]
criterion = { version = "0.3", features = ["html_reports"]}
tempfile = "3.2.0"
grcov="0.8.19" # code coverage

[[bin]]
name = "lind_fs_utils"
path = "src/tools/fs_utils.rs"

# many benchmarks follow. Don't put any non-benchmarks below this...
[[bench]]
name = "gen_getid"
path = "benches/gen_getid.rs"
harness= false

[[bench]]
name = "fs_open_close"
path = "benches/fs_open_close.rs"
harness= false

[[bench]]
name = "fs_read_write"
path = "benches/fs_read_write.rs"
harness= false

[[bench]]
name = "fs_read_write_seek"
path = "benches/fs_read_write_seek.rs"
harness= false


# Don't put any thing below this... benchmarks above!
Loading

0 comments on commit 409aa58

Please sign in to comment.