-
Notifications
You must be signed in to change notification settings - Fork 19
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
add environ functions #3
Conversation
ulib/axlibc/src/env.rs
Outdated
strnlen(s, usize::MAX) | ||
} | ||
|
||
unsafe fn strnlen(s: *const c_char, size: usize) -> usize { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this two functions into another file string.rs
, and remove strlen
and strnlen
in axlibc/c/string.c.
@@ -53,6 +53,10 @@ NET_DEV ?= user | |||
IP ?= 10.0.2.15 | |||
GW ?= 10.0.2.2 | |||
|
|||
#args and env | |||
ARGS ?= | |||
ENVS ?= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add this two parameter to the doc in the head of this file
apps/c/memtest/memtest.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I this env test can be put into another file. Also test using ARGS=xxx ENVS=xxx
in test_cmd
crates/dtb/src/lib.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this crate into the root Cargo.toml
/// | ||
/// The Multiboot information structure may be placed anywhere in memory by the boot loader, | ||
/// so we should save cmdline in a buf before this memory is set free | ||
pub static mut COMLINE_BUF: [u8; 256] = [0; 256]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this variable ONLY used in x86? If so, try to add #[cfg(...)]
Try to run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix warnings generated by cargo clippy
, and rebase these commits into one.
I think it's ok to merge. @MrRobertYuan
modules/axruntime/src/lib.rs
Outdated
Some((a, e)) => (a, e), | ||
None => ("", ""), | ||
}; | ||
let envs: Vec<&str> = envs.split(",").collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix warning in cargo clippy
modules/axruntime/src/lib.rs
Outdated
OUR_ENVIRON.push(core::ptr::null_mut()); | ||
environ = OUR_ENVIRON.as_mut_ptr(); | ||
// set up argvs | ||
let args: Vec<&str> = args.split(",").filter(|i| i.len() != 0).collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix warning in cargo clippy
let mbi = mbi as *const u32; | ||
let flag = mbi.read(); | ||
if (flag & (1 << 2)) > 0 { | ||
let cmdline = *mbi.add(4) as *const u8; // cmdline的物理地址 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this Chinese word
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to narrow down unsafe block
size. That is to say:
When use unsafe fn xxxx
, please point out which expression line is unsafe, and wrap corresponding expression with unsafe {}
.
Line 76: unsafe { core::ptr::xxx}
modules/axruntime/src/env.rs
Outdated
pub static mut environ: *mut *mut c_char = ptr::null_mut(); | ||
|
||
/// Save environment variables | ||
pub static mut OUR_ENVIRON: Vec<*mut c_char> = Vec::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to RX_ENVIRON
To use environment variables and command-line parameters, use ARGS="xxx" and ENVS="xxx=xxx" when make run, e.g.,
make ARCH=aarch64 A=apps/c/env_test ARGS="arg1 arg2" ENVS="HOSTNAME=QEMU LOGNAME=arceos_user" run
.