Files
mkrtos-real/mkrtos_user/server/fs/appfs/main.c
zhangzheng 5bce3adf01 appfs集成
2025-01-25 15:29:06 +08:00

84 lines
2.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
#include "u_log.h"
#include "ns_cli.h"
#include "u_rpc_svr.h"
#include "u_prot.h"
#include "u_env.h"
#include "u_task.h"
#include "cons_cli.h"
#include "fs_rpc.h"
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <getopt.h>
#include <u_fast_ipc.h>
#include "appfs.h"
#include "hw_block.h"
#include "appfs_open.h"
#define STACK_COM_ITME_SIZE (2 * 1024)
ATTR_ALIGN(8)
uint8_t stack_coms[STACK_COM_ITME_SIZE];
uint8_t msg_buf_coms[MSG_BUG_LEN];
static fs_info_t fs_obj;
void fast_ipc_init(void)
{
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
}
int main(int argc, char *argv[])
{
obj_handler_t hd;
int ret;
char *mount_path = NULL;
char *dev_path = NULL;
task_set_obj_name(TASK_THIS, TASK_THIS, "tk_appfs");
task_set_obj_name(TASK_THIS, THREAD_MAIN, "th_appfs");
for (int i = 0; i < argc; i++)
{
printf("args[%d]:%s\n", i, argv[i]);
}
fast_ipc_init();
int o;
const char *optstring = "d:m:"; // 有三个选项-abc其中c选项后有冒号所以后面必须有参数
while ((o = getopt(argc, argv, optstring)) != -1)
{
switch (o)
{
case 'd':
dev_path = optarg;
break;
case 'm':
printf("mount path:%s\n", optarg);
mount_path = optarg;
break;
case '?':
printf("error optopt: %c\n", optopt);
printf("error opterr: %d\n", opterr);
break;
}
}
if (dev_path == NULL || mount_path == NULL)
{
printf("dev or mout path don't setting.\n");
printf("example:appfs -m /bin -d /block\n");
return -1;
}
ret = hw_init_block(&fs_obj, dev_path);
assert(ret >= 0);
ret = appfs_init(&fs_obj);
assert(ret >= 0);
ret = appfs_open_init(&fs_obj);
assert(ret >= 0);
ret = rpc_meta_init(THREAD_MAIN, &hd);
assert(ret >= 0);
fs_svr_init();
ns_register(mount_path, hd, MOUNT_NODE);
cons_write_str("appfs mount success\n");
fs_svr_loop();
return 0;
}