hosfs_rpmsg: merge hostfs_rpmsg to rpmsgfs

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd
2021-11-30 20:00:03 +08:00
committed by Xiang Xiao
parent 5ed85ef476
commit 985cc4fc6d
18 changed files with 3476 additions and 1896 deletions
+1
View File
@@ -134,3 +134,4 @@ source "fs/littlefs/Kconfig"
source "fs/unionfs/Kconfig"
source "fs/userfs/Kconfig"
source "fs/hostfs/Kconfig"
source "fs/rpmsgfs/Kconfig"
+1
View File
@@ -56,6 +56,7 @@ include unionfs/Make.defs
include userfs/Make.defs
include hostfs/Make.defs
include littlefs/Make.defs
include rpmsgfs/Make.defs
endif
-20
View File
@@ -36,23 +36,3 @@ config FS_HOSTFS
option to enable the handling of the trap.
Theoretically, it can work for other environments as well.
E.g. a real hardware + JTAG + OpenOCD.
config FS_HOSTFS_RPMSG
bool "Host File System Rpmsg"
default n
depends on FS_HOSTFS
depends on OPENAMP
---help---
Use Host file system to mount directories through rpmsg.
This is the driver that sending the message.
This effectively replaces the ordinary hostfs backend.
Right now, there is no way to enable both backends.
config FS_HOSTFS_RPMSG_SERVER
bool "Host File System Rpmsg Server"
default n
depends on OPENAMP
---help---
Use Host file system to mount directories through rpmsg.
This is the driver that receiving the message.
-8
View File
@@ -26,11 +26,3 @@ VPATH += :hostfs
ifeq ($(CONFIG_FS_HOSTFS),y)
CSRCS += hostfs.c
endif
ifeq ($(CONFIG_FS_HOSTFS_RPMSG),y)
CSRCS += hostfs_rpmsg.c
endif
ifeq ($(CONFIG_FS_HOSTFS_RPMSG_SERVER),y)
CSRCS += hostfs_rpmsg_server.c
endif
File diff suppressed because it is too large Load Diff
-203
View File
@@ -1,203 +0,0 @@
/****************************************************************************
* fs/hostfs/hostfs_rpmsg.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __FS_HOSTFS_HOSTFS_RPMSG_H
#define __FS_HOSTFS_HOSTFS_RPMSG_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <sys/stat.h>
#include <sys/statfs.h>
/****************************************************************************
* Pre-processor definitions
****************************************************************************/
#ifndef ARRAY_SIZE
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
#define HOSTFS_RPMSG_EPT_NAME "rpmsg-hostfs"
#define HOSTFS_RPMSG_OPEN 1
#define HOSTFS_RPMSG_CLOSE 2
#define HOSTFS_RPMSG_READ 3
#define HOSTFS_RPMSG_WRITE 4
#define HOSTFS_RPMSG_LSEEK 5
#define HOSTFS_RPMSG_IOCTL 6
#define HOSTFS_RPMSG_SYNC 7
#define HOSTFS_RPMSG_DUP 8
#define HOSTFS_RPMSG_FSTAT 9
#define HOSTFS_RPMSG_FTRUNCATE 10
#define HOSTFS_RPMSG_OPENDIR 11
#define HOSTFS_RPMSG_READDIR 12
#define HOSTFS_RPMSG_REWINDDIR 13
#define HOSTFS_RPMSG_CLOSEDIR 14
#define HOSTFS_RPMSG_STATFS 15
#define HOSTFS_RPMSG_UNLINK 16
#define HOSTFS_RPMSG_MKDIR 17
#define HOSTFS_RPMSG_RMDIR 18
#define HOSTFS_RPMSG_RENAME 19
#define HOSTFS_RPMSG_STAT 20
#define HOSTFS_RPMSG_FCHSTAT 21
#define HOSTFS_RPMSG_CHSTAT 22
/****************************************************************************
* Public Types
****************************************************************************/
begin_packed_struct struct hostfs_rpmsg_header_s
{
uint32_t command;
int32_t result;
uint64_t cookie;
} end_packed_struct;
begin_packed_struct struct hostfs_rpmsg_open_s
{
struct hostfs_rpmsg_header_s header;
int32_t flags;
int32_t mode;
char pathname[0];
} end_packed_struct;
begin_packed_struct struct hostfs_rpmsg_close_s
{
struct hostfs_rpmsg_header_s header;
int32_t fd;
} end_packed_struct;
begin_packed_struct struct hostfs_rpmsg_read_s
{
struct hostfs_rpmsg_header_s header;
int32_t fd;
uint32_t count;
char buf[0];
} end_packed_struct;
#define hostfs_rpmsg_write_s hostfs_rpmsg_read_s
begin_packed_struct struct hostfs_rpmsg_lseek_s
{
struct hostfs_rpmsg_header_s header;
int32_t fd;
int32_t whence;
int32_t offset;
} end_packed_struct;
begin_packed_struct struct hostfs_rpmsg_ioctl_s
{
struct hostfs_rpmsg_header_s header;
int32_t fd;
int32_t request;
int32_t arg;
} end_packed_struct;
#define hostfs_rpmsg_sync_s hostfs_rpmsg_close_s
#define hostfs_rpmsg_dup_s hostfs_rpmsg_close_s
begin_packed_struct struct hostfs_rpmsg_fstat_s
{
struct hostfs_rpmsg_header_s header;
union
{
struct stat buf;
uint32_t reserved[16];
};
union
{
int32_t fd;
char pathname[0];
};
} end_packed_struct;
begin_packed_struct struct hostfs_rpmsg_ftruncate_s
{
struct hostfs_rpmsg_header_s header;
int32_t fd;
int32_t length;
} end_packed_struct;
begin_packed_struct struct hostfs_rpmsg_opendir_s
{
struct hostfs_rpmsg_header_s header;
char pathname[0];
} end_packed_struct;
begin_packed_struct struct hostfs_rpmsg_readdir_s
{
struct hostfs_rpmsg_header_s header;
int32_t fd;
uint32_t type;
char name[0];
} end_packed_struct;
#define hostfs_rpmsg_rewinddir_s hostfs_rpmsg_close_s
#define hostfs_rpmsg_closedir_s hostfs_rpmsg_close_s
begin_packed_struct struct hostfs_rpmsg_statfs_s
{
struct hostfs_rpmsg_header_s header;
union
{
struct statfs buf;
uint32_t reserved[16];
};
char pathname[0];
} end_packed_struct;
#define hostfs_rpmsg_unlink_s hostfs_rpmsg_opendir_s
begin_packed_struct struct hostfs_rpmsg_mkdir_s
{
struct hostfs_rpmsg_header_s header;
int32_t mode;
uint32_t reserved;
char pathname[0];
} end_packed_struct;
#define hostfs_rpmsg_rmdir_s hostfs_rpmsg_opendir_s
#define hostfs_rpmsg_rename_s hostfs_rpmsg_opendir_s
#define hostfs_rpmsg_stat_s hostfs_rpmsg_fstat_s
begin_packed_struct struct hostfs_rpmsg_fchstat_s
{
struct hostfs_rpmsg_header_s header;
int32_t flags;
union
{
struct stat buf;
uint32_t reserved[16];
};
union
{
int32_t fd;
char pathname[0];
};
} end_packed_struct;
#define hostfs_rpmsg_chstat_s hostfs_rpmsg_fchstat_s
#endif /* __FS_HOSTFS_HOSTFS_RPMSG_H */
File diff suppressed because it is too large Load Diff
+6
View File
@@ -135,6 +135,12 @@ FAR const char *fs_gettype(FAR struct statfs *statbuf)
break;
#endif
#ifdef CONFIG_FS_RPMSGFS
case RPMSGFS_MAGIC:
fstype = "rpmsgfs";
break;
#endif
#ifdef CONFIG_FS_USERFS
case USERFS_MAGIC:
fstype = "userfs";
+6
View File
@@ -178,6 +178,9 @@ extern const struct mountpt_operations cromfs_operations;
#ifdef CONFIG_FS_UNIONFS
extern const struct mountpt_operations unionfs_operations;
#endif
#ifdef CONFIG_FS_RPMSGFS
extern const struct mountpt_operations rpmsgfs_operations;
#endif
static const struct fsmap_t g_nonbdfsmap[] =
{
@@ -207,6 +210,9 @@ static const struct fsmap_t g_nonbdfsmap[] =
#endif
#ifdef CONFIG_FS_UNIONFS
{ "unionfs", &unionfs_operations },
#endif
#ifdef CONFIG_FS_RPMSGFS
{ "rpmsgfs", &rpmsgfs_operations },
#endif
{ NULL, NULL },
};
+12
View File
@@ -0,0 +1,12 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config FS_RPMSGFS
bool "RPMSG File System"
default n
depends on OPENAMP
---help---
Use rpmsg file system to mount remote directories to local.
This the method for user to use remote file like own core.
+28
View File
@@ -0,0 +1,28 @@
############################################################################
# fs/rpmsgfs/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
# Include RPSMGFS build support
DEPPATH += --dep-path rpmsgfs
VPATH += :rpmsgfs
ifeq ($(CONFIG_FS_RPMSGFS),y)
CSRCS += rpmsgfs.c rpmsgfs_client.c rpmsgfs_server.c
endif
+1456
View File
File diff suppressed because it is too large Load Diff
+246
View File
@@ -0,0 +1,246 @@
/****************************************************************************
* fs/rpmsgfs/rpmsgfs.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __FS_RPMSGFS_H
#define __FS_RPMSGFS_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <dirent.h>
#include <sys/stat.h>
#include <sys/statfs.h>
/****************************************************************************
* Pre-processor definitions
****************************************************************************/
#ifndef ARRAY_SIZE
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
#define RPMSGFS_NAME_PREFIX "rpmsgfs-"
#define RPMSGFS_OPEN 1
#define RPMSGFS_CLOSE 2
#define RPMSGFS_READ 3
#define RPMSGFS_WRITE 4
#define RPMSGFS_LSEEK 5
#define RPMSGFS_IOCTL 6
#define RPMSGFS_SYNC 7
#define RPMSGFS_DUP 8
#define RPMSGFS_FSTAT 9
#define RPMSGFS_FTRUNCATE 10
#define RPMSGFS_OPENDIR 11
#define RPMSGFS_READDIR 12
#define RPMSGFS_REWINDDIR 13
#define RPMSGFS_CLOSEDIR 14
#define RPMSGFS_STATFS 15
#define RPMSGFS_UNLINK 16
#define RPMSGFS_MKDIR 17
#define RPMSGFS_RMDIR 18
#define RPMSGFS_RENAME 19
#define RPMSGFS_STAT 20
#define RPMSGFS_FCHSTAT 21
#define RPMSGFS_CHSTAT 22
/****************************************************************************
* Public Types
****************************************************************************/
begin_packed_struct struct rpmsgfs_header_s
{
uint32_t command;
int32_t result;
uint64_t cookie;
} end_packed_struct;
begin_packed_struct struct rpmsgfs_open_s
{
struct rpmsgfs_header_s header;
int32_t flags;
int32_t mode;
char pathname[0];
} end_packed_struct;
begin_packed_struct struct rpmsgfs_close_s
{
struct rpmsgfs_header_s header;
int32_t fd;
} end_packed_struct;
begin_packed_struct struct rpmsgfs_read_s
{
struct rpmsgfs_header_s header;
int32_t fd;
uint32_t count;
char buf[0];
} end_packed_struct;
#define rpmsgfs_write_s rpmsgfs_read_s
begin_packed_struct struct rpmsgfs_lseek_s
{
struct rpmsgfs_header_s header;
int32_t fd;
int32_t whence;
int32_t offset;
} end_packed_struct;
begin_packed_struct struct rpmsgfs_ioctl_s
{
struct rpmsgfs_header_s header;
int32_t fd;
int32_t request;
int32_t arg;
} end_packed_struct;
#define rpmsgfs_sync_s rpmsgfs_close_s
#define rpmsgfs_dup_s rpmsgfs_close_s
begin_packed_struct struct rpmsgfs_fstat_s
{
struct rpmsgfs_header_s header;
union
{
struct stat buf;
uint32_t reserved[16];
};
union
{
int32_t fd;
char pathname[0];
};
} end_packed_struct;
begin_packed_struct struct rpmsgfs_ftruncate_s
{
struct rpmsgfs_header_s header;
int32_t fd;
int32_t length;
} end_packed_struct;
begin_packed_struct struct rpmsgfs_opendir_s
{
struct rpmsgfs_header_s header;
char pathname[0];
} end_packed_struct;
begin_packed_struct struct rpmsgfs_readdir_s
{
struct rpmsgfs_header_s header;
int32_t fd;
uint32_t type;
char name[0];
} end_packed_struct;
#define rpmsgfs_rewinddir_s rpmsgfs_close_s
#define rpmsgfs_closedir_s rpmsgfs_close_s
begin_packed_struct struct rpmsgfs_statfs_s
{
struct rpmsgfs_header_s header;
union
{
struct statfs buf;
uint32_t reserved[16];
};
char pathname[0];
} end_packed_struct;
#define rpmsgfs_unlink_s rpmsgfs_opendir_s
begin_packed_struct struct rpmsgfs_mkdir_s
{
struct rpmsgfs_header_s header;
int32_t mode;
uint32_t reserved;
char pathname[0];
} end_packed_struct;
#define rpmsgfs_rmdir_s rpmsgfs_opendir_s
#define rpmsgfs_rename_s rpmsgfs_opendir_s
#define rpmsgfs_stat_s rpmsgfs_fstat_s
begin_packed_struct struct rpmsgfs_fchstat_s
{
struct rpmsgfs_header_s header;
int32_t flags;
union
{
struct stat buf;
uint32_t reserved[16];
};
union
{
int32_t fd;
char pathname[0];
};
} end_packed_struct;
#define rpmsgfs_chstat_s rpmsgfs_fchstat_s
/****************************************************************************
* Internal function prototypes
****************************************************************************/
int rpmsgfs_client_open(FAR void *handle,
FAR const char *pathname, int flags, int mode);
int rpmsgfs_client_close(FAR void *handle, int fd);
ssize_t rpmsgfs_client_read(FAR void *handle, int fd,
FAR void *buf, size_t count);
ssize_t rpmsgfs_client_write(FAR void *handle, int fd,
FAR const void *buf, size_t count);
off_t rpmsgfs_client_lseek(FAR void *handle, int fd,
off_t offset, int whence);
int rpmsgfs_client_ioctl(FAR void *handle, int fd,
int request, unsigned long arg);
void rpmsgfs_client_sync(FAR void *handle, int fd);
int rpmsgfs_client_dup(FAR void *handle, int fd);
int rpmsgfs_client_fstat(FAR void *handle, int fd,
FAR struct stat *buf);
int rpmsgfs_client_fchstat(FAR void *handle, int fd,
FAR const struct stat *buf, int flags);
int rpmsgfs_client_ftruncate(FAR void *handle, int fd, off_t length);
FAR void *rpmsgfs_client_opendir(FAR void *handle, FAR const char *name);
int rpmsgfs_client_readdir(FAR void *handle, FAR void *dirp,
FAR struct dirent *entry);
void rpmsgfs_client_rewinddir(FAR void *handle, FAR void *dirp);
int rpmsgfs_client_bind(FAR void **handle, FAR const char *cpuname);
int rpmsgfs_client_unbind(FAR void *handle);
int rpmsgfs_client_closedir(FAR void *handle, FAR void *dirp);
int rpmsgfs_client_statfs(FAR void *handle, FAR const char *path,
FAR struct statfs *buf);
int rpmsgfs_client_unlink(FAR void *handle, FAR const char *pathname);
int rpmsgfs_client_mkdir(FAR void *handle, FAR const char *pathname,
mode_t mode);
int rpmsgfs_client_rmdir(FAR void *handle, FAR const char *pathname);
int rpmsgfs_client_rename(FAR void *handle, FAR const char *oldpath,
FAR const char *newpath);
int rpmsgfs_client_stat(FAR void *handle, FAR const char *path,
FAR struct stat *buf);
int rpmsgfs_client_chstat(FAR void *handle, FAR const char *path,
FAR const struct stat *buf, int flags);
#endif /* __FS_RPMSGFS_H */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+14
View File
@@ -207,6 +207,17 @@ struct fs_hostfsdir_s
};
#endif
#ifdef CONFIG_FS_RPMSGFS
/* RPMSGFS provides mapping to directories on the host machine in the
* sim environment.
*/
struct fs_rpmsgfsdir_s
{
FAR void *fs_dir; /* Opaque pointer to remote DIR */
};
#endif
#endif /* CONFIG_DISABLE_MOUNTPOINT */
struct fs_dirent_s
@@ -288,6 +299,9 @@ struct fs_dirent_s
#ifdef CONFIG_FS_HOSTFS
struct fs_hostfsdir_s hostfs;
#endif
#ifdef CONFIG_FS_RPMSGFS
struct fs_rpmsgfsdir_s rpmsgfs;
#endif
#endif /* !CONFIG_DISABLE_MOUNTPOINT */
} u;
@@ -1,5 +1,5 @@
/****************************************************************************
* include/nuttx/fs/hostfs_rpmsg.h
* include/nuttx/fs/rpmsgfs.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -33,12 +33,8 @@ extern "C"
#define EXTERN extern
#endif
#ifdef CONFIG_FS_HOSTFS_RPMSG
int hostfs_rpmsg_init(FAR const char *cpu_name);
#endif
#ifdef CONFIG_FS_HOSTFS_RPMSG_SERVER
int hostfs_rpmsg_server_init(void);
#ifdef CONFIG_FS_RPMSGFS
int rpmsgfs_server_init(void);
#endif
#undef EXTERN
+1
View File
@@ -93,6 +93,7 @@
#define HOSTFS_MAGIC 0x54534f48
#define USERFS_MAGIC 0x52455355
#define CROMFS_MAGIC 0x4d4f5243
#define RPMSGFS_MAGIC 0x54534f47
#if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG)
# define statfs64 statfs