shell: change the current working directory

git-svn-id: svn://kolibrios.org@5210 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2014-12-02 02:21:37 +00:00
parent 27b5fdd406
commit a9061d0700

View File

@ -1,4 +1,12 @@
static inline void set_cwd(const char* cwd)
{
__asm__ __volatile__(
"int $0x40"
::"a"(30),"b"(1),"c"(cwd));
};
int cmd_cd(char dir[]) int cmd_cd(char dir[])
{ {
@ -22,6 +30,7 @@ if ( ( 0 == strcmp(dir, "..") ) && ( 0 != strcmp(cur_dir, "/")) )
{ {
cur_dir[strlen(cur_dir)-1]='\0'; cur_dir[strlen(cur_dir)-1]='\0';
dir_truncate(cur_dir); dir_truncate(cur_dir);
set_cwd(cur_dir);
return TRUE; return TRUE;
} }
@ -30,6 +39,7 @@ if ( '/' == dir[0])
if ( dir_check(dir) ) if ( dir_check(dir) )
{ {
strcpy(cur_dir, dir); strcpy(cur_dir, dir);
set_cwd(cur_dir);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@ -45,6 +55,7 @@ else
{ {
strcpy(cur_dir, temp); strcpy(cur_dir, temp);
set_cwd(cur_dir);
return TRUE; return TRUE;
} }