mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 05:16:47 +08:00
net/net_procfs.c: Add basic support for networking procfs entries
This commit is contained in:
@@ -11172,4 +11172,7 @@
|
||||
definition in the common network device structure defined in netdev.h
|
||||
where they can be accessed by network applications. All Ethernet
|
||||
drivers that collect statistics have been adapted to use these common
|
||||
statistics (2015-11-26).
|
||||
statistics (2015-11-26).
|
||||
* net/net_procfs.c: Add basic support for networking entries in the
|
||||
procfs (2015-11-27).
|
||||
|
||||
|
||||
@@ -453,6 +453,9 @@ o Kernel/Protected Build
|
||||
|
||||
http://git.busybox.net/busybox/tree/util-linux/mkfs_vfat.c
|
||||
|
||||
ps, ifup, ifdown, ifconfig should be implemented using
|
||||
extensions to the procfs file system.
|
||||
|
||||
Status: Open
|
||||
Priority: Medium/High -- the kernel build configuration is not fully fielded
|
||||
yet.
|
||||
@@ -1553,6 +1556,7 @@ o Graphics subsystem (graphics/)
|
||||
Status: Open
|
||||
Priority: Low, not a serious issue but worth noting. There is no plan
|
||||
to change this behavior.
|
||||
|
||||
o Pascal Add-On (pcode/)
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -1795,7 +1799,7 @@ o NuttShell (NSH) (apps/nshlib)
|
||||
show status for the single interface on the command line; it will
|
||||
still show status for all interfaces.
|
||||
Status: Open
|
||||
Priority: Low (multiple network interfaces not fully supported yet anyway).
|
||||
Priority: Low
|
||||
|
||||
Title: ARP COMMAND
|
||||
Description: Add an ARP command so that we can see and modify the contents of
|
||||
|
||||
+1
-1
Submodule arch updated: 26a3df8169...7a800cc36f
+1
-1
Submodule configs updated: b52f98b9c9...18c27d6535
@@ -39,6 +39,11 @@ config FS_PROCFS_EXCLUDE_MOUNTS
|
||||
default n
|
||||
depends on !DISABLE_MOUNTPOINT
|
||||
|
||||
config FS_PROCFS_EXCLUDE_NET
|
||||
bool "Exclude network"
|
||||
depends on NET
|
||||
default n
|
||||
|
||||
config FS_PROCFS_EXCLUDE_MTD
|
||||
bool "Exclude mtd"
|
||||
depends on MTD
|
||||
|
||||
+14
-6
@@ -79,10 +79,13 @@ extern const struct procfs_operations proc_operations;
|
||||
extern const struct procfs_operations cpuload_operations;
|
||||
extern const struct procfs_operations uptime_operations;
|
||||
|
||||
/* This is not good. These are implemented in drivers/mtd. Having to
|
||||
* deal with them here is not a good coupling.
|
||||
/* This is not good. These are implemented in other sub-systems. Having to
|
||||
* deal with them here is not a good coupling. What is really needed is a
|
||||
* run-time procfs registration system vs. a build time, fixed procfs
|
||||
* configuration.
|
||||
*/
|
||||
|
||||
extern const struct procfs_operations net_procfsoperations;
|
||||
extern const struct procfs_operations mtd_procfsoperations;
|
||||
extern const struct procfs_operations part_procfsoperations;
|
||||
extern const struct procfs_operations smartfs_procfsoperations;
|
||||
@@ -117,6 +120,11 @@ static const struct procfs_entry_s g_procfsentries[] =
|
||||
{ "fs/smartfs**", &smartfs_procfsoperations },
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NET) && !defined(CONFIG_FS_PROCFS_EXCLUDE_NET)
|
||||
{ "net", &net_procfsoperations },
|
||||
{ "net/**", &net_procfsoperations },
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_MTD) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MTD)
|
||||
{ "mtd", &mtd_procfsoperations },
|
||||
#endif
|
||||
@@ -483,7 +491,7 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
level0->base.nentries = 0;
|
||||
#endif
|
||||
|
||||
/* Initialze lastread entries */
|
||||
/* Initialize lastread entries */
|
||||
|
||||
level0->lastread = "";
|
||||
level0->lastlen = 0;
|
||||
@@ -533,7 +541,7 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
|
||||
/* Doing an intermediate directory search */
|
||||
|
||||
/* The path refers to the top level directory. Allocate the level0
|
||||
/* The path refers to the top level directory. Allocate the level1
|
||||
* dirent structure.
|
||||
*/
|
||||
|
||||
@@ -756,8 +764,8 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
|
||||
*/
|
||||
|
||||
if (strncmp(g_procfsentries[level1->base.index].pathpattern,
|
||||
g_procfsentries[level1->firstindex].pathpattern,
|
||||
level1->subdirlen) == 0)
|
||||
g_procfsentries[level1->firstindex].pathpattern,
|
||||
level1->subdirlen) == 0)
|
||||
{
|
||||
/* This entry matches. Report the subdir entry */
|
||||
|
||||
|
||||
@@ -125,9 +125,9 @@ struct proc_file_s
|
||||
|
||||
struct proc_dir_s
|
||||
{
|
||||
struct procfs_dir_priv_s base; /* Base directory private data */
|
||||
struct procfs_dir_priv_s base; /* Base directory private data */
|
||||
FAR const struct proc_node_s *node; /* Directory node description */
|
||||
pid_t pid; /* ID of task/thread for attributes */
|
||||
pid_t pid; /* ID of task/thread for attributes */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
+12
-9
@@ -110,7 +110,8 @@ static ssize_t skel_read(FAR struct file *filep, FAR char *buffer,
|
||||
static int skel_dup(FAR const struct file *oldp,
|
||||
FAR struct file *newp);
|
||||
|
||||
static int skel_opendir(const char *relpath, FAR struct fs_dirent_s *dir);
|
||||
static int skel_opendir(FAR const char *relpath,
|
||||
FAR struct fs_dirent_s *dir);
|
||||
static int skel_closedir(FAR struct fs_dirent_s *dir);
|
||||
static int skel_readdir(FAR struct fs_dirent_s *dir);
|
||||
static int skel_rewinddir(FAR struct fs_dirent_s *dir);
|
||||
@@ -118,7 +119,7 @@ static int skel_rewinddir(FAR struct fs_dirent_s *dir);
|
||||
static int skel_stat(FAR const char *relpath, FAR struct stat *buf);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
@@ -158,7 +159,7 @@ const struct procfs_operations skel_procfsoperations =
|
||||
****************************************************************************/
|
||||
|
||||
static int skel_open(FAR struct file *filep, FAR const char *relpath,
|
||||
int oflags, mode_t mode)
|
||||
int oflags, mode_t mode)
|
||||
{
|
||||
FAR struct skel_file_s *priv;
|
||||
|
||||
@@ -220,7 +221,7 @@ static int skel_close(FAR struct file *filep)
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t skel_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen)
|
||||
size_t buflen)
|
||||
{
|
||||
FAR struct skel_file_s *priv;
|
||||
ssize_t ret;
|
||||
@@ -356,11 +357,12 @@ static int skel_closedir(FAR struct fs_dirent_s *dir)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int skel_readdir(struct fs_dirent_s *dir)
|
||||
static int skel_readdir(FAR struct fs_dirent_s *dir)
|
||||
{
|
||||
FAR struct skel_level1_s *level1;
|
||||
char filename[16];
|
||||
int ret, index;
|
||||
int index;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(dir && dir->u.procfs);
|
||||
level1 = dir->u.procfs;
|
||||
@@ -396,12 +398,13 @@ static int skel_readdir(struct fs_dirent_s *dir)
|
||||
/* TODO: Specify the type of entry */
|
||||
|
||||
dir->fd_dir.d_type = DTYPE_FILE;
|
||||
strncpy(dir->fd_dir.d_name, filename, NAME_MAX+1);
|
||||
strncpy(dir->fd_dir.d_name, filename, NAME_MAX + 1);
|
||||
|
||||
/* Set up the next directory entry offset. NOTE that we could use the
|
||||
* standard f_pos instead of our own private index.
|
||||
*/
|
||||
|
||||
level1->base.index = index + 1;
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
@@ -415,7 +418,7 @@ static int skel_readdir(struct fs_dirent_s *dir)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int skel_rewinddir(struct fs_dirent_s *dir)
|
||||
static int skel_rewinddir(FAR struct fs_dirent_s *dir)
|
||||
{
|
||||
FAR struct skel_level1_s *priv;
|
||||
|
||||
@@ -433,7 +436,7 @@ static int skel_rewinddir(struct fs_dirent_s *dir)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int skel_stat(const char *relpath, struct stat *buf)
|
||||
static int skel_stat(FAR const char *relpath, FAR truct stat *buf)
|
||||
{
|
||||
int ret = -ENOENT;
|
||||
|
||||
|
||||
@@ -42,6 +42,12 @@ ifeq ($(CONFIG_NET),y)
|
||||
NET_ASRCS =
|
||||
NET_CSRCS = net_initialize.c
|
||||
|
||||
ifeq ($(CONFIG_FS_PROCFS),y)
|
||||
ifneq ($(CONFIG_FS_PROCFS_EXCLUDE_NET),y)
|
||||
NET_CSRCS += net_procfs.c
|
||||
endif
|
||||
endif
|
||||
|
||||
# Socket support
|
||||
|
||||
SOCK_ASRCS =
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user