summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-12-09 13:24:38 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-12-09 13:24:38 -0600
commit1ef64d9cfc05972c4c935d3cdb4876ee1bfce898 (patch)
treea2553832b9a17816c27a7ce63b1025f53b4d7d69 /nuttx
parent8ab7a739d631354264d73bec1e945ea18c12a906 (diff)
downloadnuttx-1ef64d9cfc05972c4c935d3cdb4876ee1bfce898.tar.gz
nuttx-1ef64d9cfc05972c4c935d3cdb4876ee1bfce898.tar.bz2
nuttx-1ef64d9cfc05972c4c935d3cdb4876ee1bfce898.zip
Add procfs write support. From Ken Petit
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/fs/procfs/fs_procfs.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/nuttx/fs/procfs/fs_procfs.c b/nuttx/fs/procfs/fs_procfs.c
index a0b851655..322573691 100644
--- a/nuttx/fs/procfs/fs_procfs.c
+++ b/nuttx/fs/procfs/fs_procfs.c
@@ -151,6 +151,8 @@ static int procfs_open(FAR struct file *filep, FAR const char *relpath,
static int procfs_close(FAR struct file *filep);
static ssize_t procfs_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
+static ssize_t procfs_write(FAR struct file *filep, FAR const char *buffer,
+ size_t buflen);
static int procfs_ioctl(FAR struct file *filep, int cmd,
unsigned long arg);
@@ -193,7 +195,7 @@ const struct mountpt_operations procfs_operations =
procfs_open, /* open */
procfs_close, /* close */
procfs_read, /* read */
- NULL, /* write */
+ procfs_write, /* write */
NULL, /* seek */
procfs_ioctl, /* ioctl */
@@ -361,6 +363,33 @@ static ssize_t procfs_read(FAR struct file *filep, FAR char *buffer,
}
/****************************************************************************
+ * Name: procfs_write
+ ****************************************************************************/
+
+static ssize_t procfs_write(FAR struct file *filep, FAR const char *buffer,
+ size_t buflen)
+{
+ FAR struct procfs_file_s *handler;
+ ssize_t ret = 0;
+
+ fvdbg("buffer=%p buflen=%d\n", buffer, (int)buflen);
+
+ /* Recover our private data from the struct file instance */
+
+ handler = (FAR struct procfs_file_s *)filep->f_priv;
+ DEBUGASSERT(handler);
+
+ /* Call the handler's read routine */
+
+ if (handler->procfsentry->ops->write)
+ {
+ ret = handler->procfsentry->ops->write(filep, buffer, buflen);
+ }
+
+ return ret;
+}
+
+/****************************************************************************
* Name: procfs_ioctl
****************************************************************************/
@@ -743,7 +772,10 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
*/
while (dir->fd_dir.d_name[level1->lastlen - 1] == '*')
- level1->lastlen--;
+ {
+ level1->lastlen--;
+ }
+
dir->fd_dir.d_name[level1->lastlen] = '\0';
if (name[level1->lastlen] == '/')