Move prototypes of mkfifo2() from sys/stat.h and pipe2() from unistd.h. They are non-standard and should not be in such a public place. They are not in include/nuttx/fs/fs.h (which isn't a great place either).

This commit is contained in:
Gregory Nutt 2016-07-20 11:57:18 -06:00
parent aa8a52aacd
commit e73e82a923
7 changed files with 79 additions and 9 deletions

View File

@ -44,13 +44,15 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/fs/fs.h>
#include <stdio.h>
#include <unistd.h>
#include <semaphore.h>
#include <fcntl.h>
#include <errno.h>
#include <nuttx/fs/fs.h>
#include "pipe_common.h"
#if CONFIG_DEV_PIPE_SIZE > 0

View File

@ -60,6 +60,7 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Stream flags for the fs_flags field of in struct file_struct */
#define __FS_FLAG_EOF (1 << 0) /* EOF detected by a read operation */
@ -1160,6 +1161,71 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset,
ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset,
size_t len);
/****************************************************************************
* Name: pipe2
*
* Description:
* pipe() creates a pair of file descriptors, pointing to a pipe inode,
* and places them in the array pointed to by 'fd'. fd[0] is for reading,
* fd[1] is for writing.
*
* NOTE: mkfifo2 is a special, non-standard, NuttX-only interface. Since
* the NuttX FIFOs are based in in-memory, circular buffers, the ability
* to control the size of those buffers is critical for system tuning.
*
* Inputs:
* fd[2] - The user provided array in which to catch the pipe file
* descriptors
* bufsize - The size of the in-memory, circular buffer in bytes.
*
* Return:
* 0 is returned on success; otherwise, -1 is returned with errno set
* appropriately.
*
****************************************************************************/
#if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0
int pipe2(int fd[2], size_t bufsize);
#endif
/****************************************************************************
* Name: mkfifo2
*
* Description:
* mkfifo() makes a FIFO device driver file with name 'pathname.' Unlike
* Linux, a NuttX FIFO is not a special file type but simply a device
* driver instance. 'mode' specifies the FIFO's permissions.
*
* Once the FIFO has been created by mkfifo(), any thread can open it for
* reading or writing, in the same way as an ordinary file. However, it
* must have been opened from both reading and writing before input or
* output can be performed. This FIFO implementation will block all
* attempts to open a FIFO read-only until at least one thread has opened
* the FIFO for writing.
*
* If all threads that write to the FIFO have closed, subsequent calls to
* read() on the FIFO will return 0 (end-of-file).
*
* NOTE: mkfifo2 is a special, non-standard, NuttX-only interface. Since
* the NuttX FIFOs are based in in-memory, circular buffers, the ability
* to control the size of those buffers is critical for system tuning.
*
* Inputs:
* pathname - The full path to the FIFO instance to attach to or to create
* (if not already created).
* mode - Ignored for now
* bufsize - The size of the in-memory, circular buffer in bytes.
*
* Return:
* 0 is returned on success; otherwise, -1 is returned with errno set
* appropriately.
*
****************************************************************************/
#if defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0
int mkfifo2(FAR const char *pathname, mode_t mode, size_t bufsize);
#endif
#undef EXTERN
#if defined(__cplusplus)
}

View File

@ -130,7 +130,6 @@ extern "C"
#endif
int mkdir(FAR const char *pathname, mode_t mode);
int mkfifo2(FAR const char *pathname, mode_t mode, size_t bufsize); /* NuttX only */
int mkfifo(FAR const char *pathname, mode_t mode);
int stat(const char *path, FAR struct stat *buf);
#if 0 /* Not yet supported */

View File

@ -174,7 +174,6 @@ FAR void *sbrk(intptr_t incr);
/* Special devices */
int pipe2(int fd[2], size_t bufsize); /* NuttX only */
int pipe(int fd[2]);
/* Working directory operations */

View File

@ -42,7 +42,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#if CONFIG_DEV_FIFO_SIZE > 0
#include <nuttx/fs/fs.h>
#if defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0
/****************************************************************************
* Public Functions
@ -82,5 +84,5 @@ int mkfifo(FAR const char *pathname, mode_t mode)
return mkfifo2(pathname, mode, CONFIG_DEV_FIFO_SIZE);
}
#endif /* CONFIG_DEV_FIFO_SIZE > 0 */
#endif /* CONFIG_PIPES && CONFIG_DEV_FIFO_SIZE > 0 */

View File

@ -41,7 +41,9 @@
#include <unistd.h>
#if CONFIG_DEV_PIPE_SIZE > 0
#include <nuttx/fs/fs.h>
#if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0
/****************************************************************************
* Public Functions
@ -70,5 +72,5 @@ int pipe(int fd[2])
return pipe2(fd, CONFIG_DEV_PIPE_SIZE);
}
#endif /* CONFIG_DEV_PIPE_SIZE > 0 */
#endif /* CONFIG_PIPES && CONFIG_DEV_PIPE_SIZE > 0 */

View File

@ -34,7 +34,7 @@
"listen","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int"
"lseek","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","off_t","int","off_t","int"
"mkdir","sys/stat.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char*","mode_t"
"mkfifo2","sys/stat.h","CONFIG_NFILE_DESCRIPTORS > 0","int","FAR const char*","mode_t","size_t"
"mkfifo2","nuttx/fs/fs.h","defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0","int","FAR const char*","mode_t","size_t"
"mmap","sys/mman.h","CONFIG_NFILE_DESCRIPTORS > 0","FAR void*","FAR void*","size_t","int","int","int","off_t"
"mount","sys/mount.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_READABLE)","int","const char*","const char*","const char*","unsigned long","const void*"
"mq_close","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","mqd_t"
@ -52,7 +52,7 @@
"open","fcntl.h","CONFIG_NFILE_DESCRIPTORS > 0","int","const char*","int","..."
"opendir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","FAR DIR*","FAR const char*"
"pgalloc", "nuttx/arch.h", "defined(CONFIG_BUILD_KERNEL)", "uintptr_t", "uintptr_t", "unsigned int"
"pipe2","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","int","int [2]|int*","size_t"
"pipe2","nuttx/fs/fs.h","defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0","int","int [2]|int*","size_t"
"poll","poll.h","!defined(CONFIG_DISABLE_POLL) && (CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0)","int","FAR struct pollfd*","nfds_t","int"
"prctl","sys/prctl.h", "CONFIG_TASK_NAME_SIZE > 0","int","int","..."
"pread","unistd.h","CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0","ssize_t","int","FAR void*","size_t","off_t"

Can't render this file because it has a wrong number of fields in line 2.