Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACS
Public
HermitOS
kernel
Commits
2822b9a1
Commit
2822b9a1
authored
3 years ago
by
Jonas Schroeder
Browse files
Options
Downloads
Patches
Plain Diff
read network configuration into environment from cli
parent
48d2b80b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/environment.rs
+17
-0
17 additions, 0 deletions
src/environment.rs
src/syscalls/interfaces/mod.rs
+12
-3
12 additions, 3 deletions
src/syscalls/interfaces/mod.rs
with
29 additions
and
3 deletions
src/environment.rs
+
17
−
0
View file @
2822b9a1
...
...
@@ -21,6 +21,7 @@ use core::{slice, str};
static
mut
COMMAND_LINE_CPU_FREQUENCY
:
Option
<
u16
>
=
None
;
static
mut
IS_PROXY
:
bool
=
false
;
static
mut
COMMAND_LINE_ENVIRONMENT
:
Vec
<
String
>
=
Vec
::
new
();
static
mut
COMMAND_LINE_APPLICATION
:
Option
<
Vec
<
String
>>
=
None
;
static
mut
COMMAND_LINE_PATH
:
Option
<
String
>
=
None
;
...
...
@@ -46,6 +47,18 @@ unsafe fn parse_command_line() {
let
mhz_str
=
tokeniter
.next
()
.expect
(
"Invalid -freq command line"
);
COMMAND_LINE_CPU_FREQUENCY
=
mhz_str
.parse
()
.ok
();
}
"-ip"
=>
{
COMMAND_LINE_ENVIRONMENT
.push
(
format!
(
"HERMIT_IP={}"
,
tokeniter
.next
()
.expect
(
"Invalid -ip command line"
)));
}
"-mask"
=>
{
COMMAND_LINE_ENVIRONMENT
.push
(
format!
(
"HERMIT_MASK={}"
,
tokeniter
.next
()
.expect
(
"Invalid -mask command line"
)));
}
"-gateway"
=>
{
COMMAND_LINE_ENVIRONMENT
.push
(
format!
(
"HERMIT_GATEWAY={}"
,
tokeniter
.next
()
.expect
(
"Invalid -gateway command line"
)));
}
"-mac"
=>
{
COMMAND_LINE_ENVIRONMENT
.push
(
format!
(
"HERMIT_MAC={}"
,
tokeniter
.next
()
.expect
(
"Invalid -mac command line"
)));
}
"-proxy"
=>
{
IS_PROXY
=
true
;
}
...
...
@@ -78,6 +91,10 @@ pub fn get_command_line_path() -> Option<&'static str> {
unsafe
{
COMMAND_LINE_PATH
.as_deref
()
}
}
pub
fn
get_command_line_envv
()
->
&
'static
[
String
]
{
unsafe
{
COMMAND_LINE_ENVIRONMENT
.as_slice
()
}
}
pub
fn
init
()
{
unsafe
{
parse_command_line
();
...
...
This diff is collapsed.
Click to expand it.
src/syscalls/interfaces/mod.rs
+
12
−
3
View file @
2822b9a1
use
alloc
::
boxed
::
Box
;
use
alloc
::
vec
::
Vec
;
use
core
::{
isize
,
ptr
,
slice
,
str
};
use
core
::{
isize
,
slice
,
str
};
use
crate
::
arch
;
use
crate
::
console
::
CONSOLE
;
...
...
@@ -97,12 +97,21 @@ pub trait SyscallInterface: Send + Sync {
}
}
let
environ
=
ptr
::
null
()
as
*
const
*
const
u8
;
let
mut
envv
=
Vec
::
new
();
let
envs
=
environment
::
get_command_line_envv
();
debug!
(
"Setting envv as: {:?}"
,
envs
);
for
a
in
envs
{
let
ptr
=
Box
::
leak
(
format!
(
"{}
\0
"
,
a
)
.into_boxed_str
())
.as_ptr
();
envv
.push
(
ptr
);
}
envv
.push
(
0usize
as
*
const
u8
);
let
argc
=
argv
.len
()
as
i32
;
let
argv
=
Box
::
leak
(
argv
.into_boxed_slice
())
.as_ptr
();
let
envv
=
Box
::
leak
(
envv
.into_boxed_slice
())
.as_ptr
();
(
argc
,
argv
,
env
iron
)
(
argc
,
argv
,
env
v
)
}
fn
shutdown
(
&
self
,
_arg
:
i32
)
->
!
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment