Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
riscv-pke
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
胡瑞
riscv-pke
Commits
975665ff
Commit
975665ff
authored
2 years ago
by
Zhiyuan Shao
Browse files
Options
Downloads
Patches
Plain Diff
revise app and user lib
parent
bc4a1874
Branches
lab4_challenge1_relativepath
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
user/app_relativepath.c
+11
-0
11 additions, 0 deletions
user/app_relativepath.c
user/user_lib.c
+14
-0
14 additions, 0 deletions
user/user_lib.c
user/user_lib.h
+2
-0
2 additions, 0 deletions
user/user_lib.h
with
27 additions
and
0 deletions
user/app_relativepath.c
+
11
−
0
View file @
975665ff
...
...
@@ -2,6 +2,17 @@
#include
"util/string.h"
#include
"util/types.h"
void
pwd
()
{
char
path
[
30
];
read_cwd
(
path
);
printu
(
"cwd:%s
\n
"
,
path
);
}
void
cd
(
const
char
*
path
)
{
if
(
change_cwd
(
path
)
!=
0
)
printu
(
"cd failed
\n
"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
fd
;
int
MAXBUF
=
512
;
...
...
This diff is collapsed.
Click to expand it.
user/user_lib.c
+
14
−
0
View file @
975665ff
...
...
@@ -167,3 +167,17 @@ int unlink_u(const char *fn){
int
close
(
int
fd
)
{
return
do_user_call
(
SYS_user_close
,
fd
,
0
,
0
,
0
,
0
,
0
,
0
);
}
//
// lib call to read present working directory (pwd)
//
int
read_cwd
(
char
*
path
)
{
return
do_user_call
(
SYS_user_rcwd
,
(
uint64
)
path
,
0
,
0
,
0
,
0
,
0
,
0
);
}
//
// lib call to change pwd
//
int
change_cwd
(
const
char
*
path
)
{
return
do_user_call
(
SYS_user_ccwd
,
(
uint64
)
path
,
0
,
0
,
0
,
0
,
0
,
0
);
}
This diff is collapsed.
Click to expand it.
user/user_lib.h
+
2
−
0
View file @
975665ff
...
...
@@ -33,5 +33,7 @@ int closedir_u(int fd);
int
link_u
(
const
char
*
fn1
,
const
char
*
fn2
);
int
unlink_u
(
const
char
*
fn
);
int
read_cwd
(
char
*
path
);
int
change_cwd
(
const
char
*
path
);
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
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