完善路径

This commit is contained in:
zhangzheng
2025-03-02 23:50:14 +08:00
parent 6049dad2b1
commit c8a5262463
9 changed files with 32 additions and 11 deletions

View File

@@ -5,3 +5,4 @@
int ns_register(const char *path, obj_handler_t svr_hd, int flags);
int ns_query(const char *path, obj_handler_t *svr_hd, int flags);
int ns_query_svr(const char *path, obj_handler_t *svr_hd, int flags);

View File

@@ -566,7 +566,7 @@ int net_socket(int domain, int type, int protocol)
{
case AF_INET:
case AF_INET6:
ret = ns_query("/net" /*FIXME:更改为宏*/, &hd, 1);
ret = ns_query_svr("/sys/net" /*FIXME:更改为宏*/, &hd, 1);
break;
default:
return -ENOSYS;

View File

@@ -110,6 +110,7 @@ int ns_register(const char *path, obj_handler_t svr_hd, int flags)
return msg_tag_get_val(tag);
}
int ns_query(const char *path, obj_handler_t *svr_hd, int flags)
{
int inx = 0;
@@ -183,3 +184,18 @@ next:
*svr_hd = newfd;
return msg_tag_get_val(tag);
}
int ns_query_svr(const char *path, obj_handler_t *svr_hd, int flags)
{
int ret;
ret = ns_query(path, svr_hd, flags);
if (ret < 0)
{
return ret;
}
if (ret != strlen(path))
{
return -ENOENT;
}
return 0;
}

View File

@@ -105,7 +105,7 @@ int hw_init_block(fs_info_t *fs, const char *dev_path)
fs->cb.hw_write_and_erase_block = hw_write_and_erase_block;
again:
ret = ns_query(dev_path, &blk_drv_hd, 0x1);
ret = ns_query_svr(dev_path, &blk_drv_hd, 0x1);
if (ret < 0)
{
u_sleep_ms(50);

View File

@@ -1,6 +1,6 @@
#一次读取一行,每行代表启动的应用程序
block /block
appfs -m /bin -d /block
block /dev/block
appfs -m /bin -d /dev/block
# fatfs
# pin
# i2c

View File

@@ -1,6 +1,6 @@
#一次读取一行,每行代表启动的应用程序
block /block
appfs -m /bin -d /block
block /dev/block
appfs -m /bin -d /dev/block
# cpiofs -m /bin
# fatfs
# pin

View File

@@ -30,7 +30,7 @@
#include <stdio.h>
#include <string.h>
#include <u_fast_ipc.h>
#include "nsfs.h"
#define DEFAULT_INIT_CFG "init.cfg"
#define STACK_COM_ITME_SIZE (2 * 1024 /*sizeof(struct pthread) + TP_OFFSET*/)
@@ -67,6 +67,8 @@ int main(int argc, char *args[])
console_init();
parse_cfg_init();
fs_ns_mkdir("/dev");
fs_ns_mkdir("/sys");
#if defined(MKRTOS_TEST_MODE)
printf("test_main..\n");
test_main();

View File

@@ -58,15 +58,17 @@ int main(int args, char *argv[])
return -1;
}
again:
ret = ns_query("/eth", &net_drv_hd, 0x1);
ret = ns_query_svr("/eth", &net_drv_hd, 0x1);
if (ret < 0)
{
// 0代表根节点
u_sleep_ms(50);
count_net_link++;
if (count_net_link < 20)
{
goto again;
}
net_drv_hd = HANDLER_INVALID;
}
cons_write_str("net init..\n");
net_hw_init();
@@ -107,7 +109,7 @@ again:
}
}
ret = ns_register("/net", hd, 0);
ret = ns_register("/sys/net", hd, 0);
if (ret < 0)
{
printf("ns reg failed.\n");

View File

@@ -557,7 +557,7 @@ int nes_sound_open(int samples_per_sync, int sample_rate)
int ret;
msg_tag_t tag;
again:
ret = ns_query("/snd", &snd_drv_hd, 0x1);
ret = ns_query_svr("/snd", &snd_drv_hd, 0x1);
if (ret < 0)
{
u_sleep_ms(50);