Skip to content
Snippets Groups Projects
Commit 975665ff authored by Zhiyuan Shao's avatar Zhiyuan Shao
Browse files

revise app and user lib

parent bc4a1874
No related merge requests found
......@@ -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;
......
......@@ -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);
}
......@@ -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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment