-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: BioTheWolff <[email protected]>
- Loading branch information
1 parent
b4ab148
commit 0a6c6a5
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use std::fs::{File, Permissions}; | ||
use std::os::unix::fs::PermissionsExt; | ||
use std::io::Write; | ||
use std::path::Path; | ||
|
||
const INIT_FILE: &[u8;220] = b"#! /bin/sh | ||
# | ||
# /init executable file in the initramfs | ||
# | ||
mount -t devtmpfs dev /dev | ||
mount -t proc proc /proc | ||
mount -t sysfs sysfs /sys | ||
ip link set up dev lo | ||
exec /sbin/getty -n -l /bin/sh 115200 /dev/console | ||
poweroff -f | ||
"; | ||
|
||
pub fn create_init_file(path: &Path) { | ||
let file_path = path.join("init"); | ||
let mut file = File::create(file_path).unwrap(); | ||
|
||
file.write_all(INIT_FILE).expect("Could not write init file"); | ||
file.set_permissions(Permissions::from_mode(0o755)).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters