From a9061d07001d2efdcc31ac90a3d0cdf597bd320d Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Tue, 2 Dec 2014 02:21:37 +0000 Subject: [PATCH] shell: change the current working directory git-svn-id: svn://kolibrios.org@5210 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/system/shell/cmd/cmd_cd.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/programs/system/shell/cmd/cmd_cd.c b/programs/system/shell/cmd/cmd_cd.c index 8648d2b3aa..a0c597dfff 100644 --- a/programs/system/shell/cmd/cmd_cd.c +++ b/programs/system/shell/cmd/cmd_cd.c @@ -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[]) { @@ -18,10 +26,11 @@ if (NULL == dir) if ( 0 == strcmp(dir, ".") ) return FALSE; -if ( ( 0 == strcmp(dir, "..") ) && ( 0 != strcmp(cur_dir, "/")) ) +if ( ( 0 == strcmp(dir, "..") ) && ( 0 != strcmp(cur_dir, "/")) ) { cur_dir[strlen(cur_dir)-1]='\0'; dir_truncate(cur_dir); + set_cwd(cur_dir); return TRUE; } @@ -30,6 +39,7 @@ if ( '/' == dir[0]) if ( dir_check(dir) ) { strcpy(cur_dir, dir); + set_cwd(cur_dir); return TRUE; } return FALSE; @@ -37,7 +47,7 @@ if ( '/' == dir[0]) else { strcpy(temp, cur_dir); - if (cur_dir[strlen(cur_dir)-1] != '/') + if (cur_dir[strlen(cur_dir)-1] != '/') strcat(temp, "/"); strcat(temp, dir); @@ -45,6 +55,7 @@ else { strcpy(cur_dir, temp); + set_cwd(cur_dir); return TRUE; }