ns支持symlink
This commit is contained in:
6
.vscode/launch.json
vendored
6
.vscode/launch.json
vendored
@@ -45,9 +45,9 @@
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
// "miDebuggerPath": "/opt/homebrew/bin/arm-none-eabi-gdb",
|
||||
"miDebuggerPath": "/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb",
|
||||
// "miDebuggerPath": "/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gdb",
|
||||
"miDebuggerServerAddress": "127.0.0.1:3333",
|
||||
// "miDebuggerPath": "/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb",
|
||||
"miDebuggerPath": "/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gdb",
|
||||
"miDebuggerServerAddress": "127.0.0.1:33333",
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
#include "assert.h"
|
||||
#include "mm_man.h"
|
||||
#include "ipc.h"
|
||||
static mem_t global_mem; //!< 全局内存管理块
|
||||
static uint8_t mem_block[31*1024 * 1024]; //!< 内核内存分配堆 TODO:自动识别大小,或者从bootstrap中读取
|
||||
static kobject_t *kobj_ls[FACTORY_FUNC_MAX]; //!< 全局静态内核对象
|
||||
static mem_t global_mem; //!< 全局内存管理块
|
||||
static uint8_t mem_block[9 * 1024 * 1024 + 1024 * 1000]; //!< 内核内存分配堆 TODO:自动识别大小,或者从bootstrap中读取
|
||||
static kobject_t *kobj_ls[FACTORY_FUNC_MAX]; //!< 全局静态内核对象
|
||||
/**
|
||||
* @brief 注册一个全局静态的内核对象
|
||||
*
|
||||
@@ -55,7 +55,7 @@ mem_t *mm_get_global(void)
|
||||
}
|
||||
/**
|
||||
* @brief 系统内存初始化
|
||||
*
|
||||
*
|
||||
*/
|
||||
static void mem_sys_init(void)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
ENTRY(Reset_Handler)
|
||||
MEMORY
|
||||
{
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32M
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 10M
|
||||
FLASH (rx) : ORIGIN = 0x8000000 + 0x2000, LENGTH = 64K - 0x2000
|
||||
}
|
||||
SECTIONS
|
||||
|
||||
@@ -6,8 +6,7 @@ export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-n
|
||||
# export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
|
||||
export KEN_OFFSET=0x2000
|
||||
export INIT_OFFSET=0x10000
|
||||
export BOOTFS_ADDR_OFFSET=0x20000
|
||||
export KNL_TEXT=0x8000000
|
||||
export BOOTFS_ADDR_OFFSET=0x21000
|
||||
export KNL_DATA=0x20000000
|
||||
export KNL_DATA_SIZE=10M
|
||||
export BOARD=STM32F2x
|
||||
|
||||
@@ -334,7 +334,10 @@ long be_lseek(long fd, long offset, long whence)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
long be_symlink(const char *src, const char *dst)
|
||||
{
|
||||
return fs_symlink(src, dst);
|
||||
}
|
||||
long be_getdents(long fd, char *buf, size_t size)
|
||||
{
|
||||
fd_map_entry_t u_fd;
|
||||
|
||||
@@ -2,10 +2,18 @@
|
||||
#include <fcntl.h>
|
||||
#include "syscall.h"
|
||||
|
||||
#ifndef NO_LITTLE_MODE
|
||||
#include "syscall_backend.h"
|
||||
#endif
|
||||
|
||||
int symlink(const char *existing, const char *new)
|
||||
{
|
||||
#ifdef SYS_symlink
|
||||
#ifdef NO_LITTLE_MODE
|
||||
return syscall(SYS_symlink, existing, new);
|
||||
#else
|
||||
return be_symlink(existing, new);
|
||||
#endif
|
||||
#else
|
||||
return syscall(SYS_symlinkat, existing, AT_FDCWD, new);
|
||||
#endif
|
||||
|
||||
@@ -223,10 +223,26 @@ static ns_node_t *node_lookup(ns_node_t *dir, const char *name, size_t *ret_inx)
|
||||
goto end;
|
||||
}
|
||||
break;
|
||||
case SYM_NODE:
|
||||
{
|
||||
size_t ret_inx;
|
||||
ns_node_t *sym_node = node_lookup(&ns.root_node,
|
||||
pos->sym_path, &ret_inx);
|
||||
|
||||
if (sym_node == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
node = sym_node;
|
||||
r_inx += inx;
|
||||
find = TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
find_inx += inx;
|
||||
}
|
||||
@@ -392,6 +408,10 @@ int fs_svr_unlink(char *path)
|
||||
int ret_inx;
|
||||
|
||||
node = node_lookup(&ns.root_node, path, &ret_inx);
|
||||
if (!node)
|
||||
{
|
||||
return -EEXIST;
|
||||
}
|
||||
if (node && ret_inx == strlen(path))
|
||||
{
|
||||
if (node->ref == 1)
|
||||
@@ -422,6 +442,7 @@ int fs_svr_symlink(const char *src, const char *dst)
|
||||
ns_node_t *node;
|
||||
size_t ret_inx;
|
||||
int len;
|
||||
printf("%s:%d. %s --> %s\n", __func__, __LINE__, src, dst);
|
||||
|
||||
node = node_lookup(&ns.root_node, dst, &ret_inx);
|
||||
if (!node)
|
||||
@@ -481,6 +502,10 @@ int ns_reg(const char *path, obj_handler_t hd, enum node_type type)
|
||||
ns_node_t *node;
|
||||
|
||||
node = node_lookup(&ns.root_node, path, &ret_inx);
|
||||
if (!node)
|
||||
{
|
||||
return -EEXIST;
|
||||
}
|
||||
if (node && ret_inx == strlen(path))
|
||||
{
|
||||
handler_free_umap(hd);
|
||||
@@ -556,6 +581,10 @@ int namespace_query(const char *path, obj_handler_t *hd)
|
||||
}
|
||||
|
||||
node = node_lookup(&ns.root_node, path, &ret_inx);
|
||||
if (!node)
|
||||
{
|
||||
return -EEXIST;
|
||||
}
|
||||
if (node && ret_inx == strlen(path))
|
||||
{
|
||||
return -EEXIST;
|
||||
|
||||
Reference in New Issue
Block a user