Add symbolic file support for FISH demo
This commit is contained in:
		
							parent
							
								
									bddb87a11b
								
							
						
					
					
						commit
						9ce23a8c08
					
				| @ -1,12 +1,18 @@ | ||||
| { | ||||
|     "vm": { | ||||
|         "user_space_size": "512MB" | ||||
|     "resource_limits": { | ||||
|         "user_space_size": "512MB", | ||||
|         "kernel_space_heap_size": "32MB", | ||||
|         "kernel_space_stack_size": "1MB", | ||||
|         "max_num_of_threads": 32 | ||||
|     }, | ||||
|     "process": { | ||||
|         "default_stack_size": "4MB", | ||||
|         "default_heap_size": "32MB", | ||||
|         "default_mmap_size": "80MB" | ||||
|     }, | ||||
|     "entry_points": [ | ||||
|         "/bin" | ||||
|     ], | ||||
|     "env": { | ||||
|         "default": [ | ||||
|             "OCCLUM=yes", | ||||
| @ -15,9 +21,11 @@ | ||||
|         "untrusted": [ | ||||
|         ] | ||||
|     }, | ||||
|     "entry_points": [ | ||||
|         "/bin" | ||||
|     ], | ||||
|     "metadata": { | ||||
|         "product_id": 0, | ||||
|         "version_number": 0, | ||||
|         "debuggable": true | ||||
|     }, | ||||
|     "mount": [ | ||||
|         { | ||||
|             "target": "/", | ||||
|  | ||||
| @ -11,12 +11,15 @@ for most of the utilities you usually find in GNU fileutils, shellutils, etc. | ||||
| 
 | ||||
| This shell script contains executable binaries, pipe symbols and output redirection like this: | ||||
| ``` | ||||
| busybox echo "Hello-world-from-fish" | busybox awk '$1=$1' FS="-" OFS=" " > /root/output.txt | ||||
| command echo "Hello-world-from-fish" | awk '$1=$1' FS="-" OFS=" " > /root/output.txt | ||||
| cat /root/output.txt | ||||
| ``` | ||||
| 
 | ||||
| which is defined in `fish_script.sh`. `awk` will replace `-` to `space` and should output result | ||||
| string `Hello world from fish` and store in `/root/output.txt` of Occlum SEFS and can only be read | ||||
| inside Occlum. | ||||
| inside Occlum. `echo`, `awk`, `cat` here are actually symbolic files linked to busybox and in this way, we don't need | ||||
| to write `busybox` prefix. The `command` keyword tells FISH that `echo` is an external command because FISH also provides | ||||
| builtin `echo` command. | ||||
| 
 | ||||
| ## Step 1: | ||||
| Downlaod FISH and busybox and build them with Occlum tool chain: | ||||
| @ -25,26 +28,13 @@ Downlaod FISH and busybox and build them with Occlum tool chain: | ||||
| ``` | ||||
| 
 | ||||
| ## Step 2: | ||||
| Prepare environment by running: | ||||
| Run command to prepare context and execute script: | ||||
| ``` | ||||
| ./env_setup.sh | ||||
| ./run_fish_test.sh | ||||
| ``` | ||||
| 
 | ||||
| If user wants to run this demo on non-SGX platform, run command: | ||||
| Or if this demo is running on non-SGX platform, use: | ||||
| ``` | ||||
| SGX_MODE=SIM ./env_setup.sh | ||||
| ``` | ||||
| 
 | ||||
| ## Step 3: | ||||
| Run command to execute script: | ||||
| ``` | ||||
| cd occlum-context && occlum run /bin/fish /fish_script.sh | ||||
| ``` | ||||
| 
 | ||||
| ## Step 4: | ||||
| Go to `occlum-context` and check result by running: | ||||
| ``` | ||||
| occlum run /bin/busybox cat /root/output.txt | ||||
| SGX_MODE=SIM ./run_fish_test.sh | ||||
| ``` | ||||
| 
 | ||||
| And you should see `Hello world from fish`. | ||||
|  | ||||
| @ -6,7 +6,7 @@ git clone -b v6.1 --depth 1 https://github.com/mirror/ncurses.git | ||||
| cd ncurses | ||||
| CC=occlum-gcc CXX=occlum-g++ CFLAGS="-O2 -fPIC" CXXFLAGS="-O2 -fPIC" LDFLAGS="-pie"  \ | ||||
| ./configure --without-shared --without-cxx-shared --prefix=/usr/local/occlum --enable-overwrite | ||||
| make && make install | ||||
| make -j$(nproc) && make install | ||||
| cd .. | ||||
| 
 | ||||
| # download and build FISH | ||||
| @ -22,7 +22,7 @@ cmake ../  -DCMAKE_BUILD_TYPE=Debug -DCURSES_LIBRARY=/opt/occlum/toolchains/gcc/ | ||||
| -DCMAKE_C_COMPILER_RANLIB=/usr/local/occlum/bin/occlum-ranlib \ | ||||
| -DCMAKE_LINKER=/usr/local/occlum/bin/occlum-ld -DCMAKE_C_FLAGS="-I/usr/local/occlum/include -fpic -pie" \ | ||||
| -DCMAKE_CXX_FLAGS="-I/usr/local/occlum/include -fpic -pie" | ||||
| make | ||||
| make -j$(nproc) | ||||
| cd ../../ | ||||
| 
 | ||||
| # download and build busybox | ||||
| @ -31,4 +31,4 @@ cd busybox | ||||
| CROSS_COMPILE=/opt/occlum/toolchains/gcc/bin/occlum- | ||||
| make CROSS_COMPILE="$CROSS_COMPILE" defconfig | ||||
| cp ../.config . | ||||
| make CROSS_COMPILE="$CROSS_COMPILE" | ||||
| make CROSS_COMPILE="$CROSS_COMPILE" -j$(nproc) | ||||
|  | ||||
| @ -1,2 +1,3 @@ | ||||
| #! /bin/fish | ||||
| busybox echo "Hello-world-from-fish" | busybox awk '$1=$1' FS="-" OFS=" " > /root/output.txt | ||||
| command echo "Hello-world-from-fish" | awk '$1=$1' FS="-" OFS=" " > /root/output.txt | ||||
| cat /root/output.txt | ||||
|  | ||||
| @ -1,7 +1,6 @@ | ||||
| #!/bin/bash | ||||
| set -e | ||||
| 
 | ||||
| # | ||||
| rm -rf occlum-context | ||||
| mkdir occlum-context && cd occlum-context | ||||
| occlum init | ||||
| @ -9,5 +8,12 @@ cp ../Occlum.json . | ||||
| cp ../fish-shell/build/fish image/bin | ||||
| cp ../busybox/busybox image/bin | ||||
| cp ../fish_script.sh image | ||||
| pushd image/bin | ||||
| ln -s /bin/busybox cat | ||||
| ln -s /bin/busybox echo | ||||
| ln -s /bin/busybox awk | ||||
| popd | ||||
| 
 | ||||
| occlum build | ||||
| echo -e "\nBuild done. Running fish script ..." | ||||
| occlum run /bin/fish /fish_script.sh | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user