fix mkdir issue; add cd command in finsh.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1185 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
46914144c9
commit
f8397a1693
@ -28,7 +28,7 @@ struct dfs_filesystem filesystem_table[DFS_FILESYSTEMS_MAX];
|
|||||||
static struct rt_mutex fslock;
|
static struct rt_mutex fslock;
|
||||||
|
|
||||||
#ifdef DFS_USING_WORKDIR
|
#ifdef DFS_USING_WORKDIR
|
||||||
char working_directory[DFS_PATH_MAX];
|
char working_directory[DFS_PATH_MAX] = {"/"};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DFS_USING_STDIO
|
#ifdef DFS_USING_STDIO
|
||||||
|
@ -355,6 +355,8 @@ int mkdir (const char *path, mode_t mode)
|
|||||||
int result;
|
int result;
|
||||||
|
|
||||||
fd = fd_new();
|
fd = fd_new();
|
||||||
|
if (fd == -1) { rt_kprintf("no fd\n"); return -1; }
|
||||||
|
|
||||||
d = fd_get(fd);
|
d = fd_get(fd);
|
||||||
|
|
||||||
result = dfs_file_open(d, path, DFS_O_DIRECTORY | DFS_O_CREAT);
|
result = dfs_file_open(d, path, DFS_O_DIRECTORY | DFS_O_CREAT);
|
||||||
@ -362,10 +364,11 @@ int mkdir (const char *path, mode_t mode)
|
|||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
{
|
||||||
rt_set_errno(result);
|
rt_set_errno(result);
|
||||||
|
fd_put(d);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd_put(d);
|
dfs_file_close(d);
|
||||||
fd_put(d);
|
fd_put(d);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -597,7 +600,15 @@ int chdir(const char *path)
|
|||||||
char* fullpath;
|
char* fullpath;
|
||||||
DIR* d;
|
DIR* d;
|
||||||
|
|
||||||
if(path == RT_NULL || rt_strlen(path) > DFS_PATH_MAX)
|
if(path == RT_NULL)
|
||||||
|
{
|
||||||
|
dfs_lock();
|
||||||
|
rt_kprintf("%s\n", working_directory);
|
||||||
|
dfs_unlock();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rt_strlen(path) > DFS_PATH_MAX)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
fullpath = dfs_normalize_path(NULL, path);
|
fullpath = dfs_normalize_path(NULL, path);
|
||||||
@ -625,6 +636,9 @@ int chdir(const char *path)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
FINSH_FUNCTION_EXPORT_ALIAS(chdir, cd, change current working directory);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -639,9 +653,9 @@ int chdir(const char *path)
|
|||||||
char *getcwd(char *buf, size_t size)
|
char *getcwd(char *buf, size_t size)
|
||||||
{
|
{
|
||||||
#ifdef DFS_USING_WORKDIR
|
#ifdef DFS_USING_WORKDIR
|
||||||
dfs_lock();
|
rt_enter_critical();
|
||||||
rt_strncpy(buf, working_directory, size);
|
rt_strncpy(buf, working_directory, size);
|
||||||
dfs_unlock();
|
rt_exit_critical();
|
||||||
#else
|
#else
|
||||||
rt_kprintf("WARNING: not support working directory\n");
|
rt_kprintf("WARNING: not support working directory\n");
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user