Add basic data structures that will allow us to move named semaphore support out of the OS and into the VFS (not complete).
This commit is contained in:
parent
344f439b38
commit
a41c1de32c
|
@ -46,7 +46,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
/********************************************************************************
|
||||
* Definitions
|
||||
* Pre-processor Definitions
|
||||
********************************************************************************/
|
||||
|
||||
/* open flag settings for open() (and related APIs) */
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
/**************************************************************************
|
||||
* Definitions
|
||||
* Pre-processor Definitions
|
||||
**************************************************************************/
|
||||
|
||||
/* Common numbers */
|
||||
|
|
|
@ -45,11 +45,7 @@
|
|||
#include "queue.h"
|
||||
|
||||
/********************************************************************************
|
||||
* Compilations Switches
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Definitions
|
||||
* Pre-processor Definitions
|
||||
********************************************************************************/
|
||||
|
||||
#define MQ_NONBLOCK O_NONBLOCK
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* All 7-bit ASCII codes */
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* GCC-specific definitions *************************************************/
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
#ifdef CONFIG_PLATFORM_CONFIGDATA
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
/* CONFIG_AUDIO - Enables Audio driver support
|
||||
|
|
|
@ -48,8 +48,10 @@
|
|||
#include <stdbool.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#include <nuttx/semaphore.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Stream flags for the fs_flags field of in struct file_struct */
|
||||
|
||||
|
@ -57,7 +59,7 @@
|
|||
#define __FS_FLAG_ERROR (1 << 1) /* Error detected by any operation */
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* This structure is provided by devices when they are registered with the
|
||||
|
@ -66,7 +68,6 @@
|
|||
|
||||
struct file;
|
||||
struct pollfd;
|
||||
|
||||
struct file_operations
|
||||
{
|
||||
/* The device driver open method differs from the mountpoint open method */
|
||||
|
@ -114,9 +115,9 @@ struct block_operations
|
|||
int (*open)(FAR struct inode *inode);
|
||||
int (*close)(FAR struct inode *inode);
|
||||
ssize_t (*read)(FAR struct inode *inode, FAR unsigned char *buffer,
|
||||
size_t start_sector, unsigned int nsectors);
|
||||
size_t start_sector, unsigned int nsectors);
|
||||
ssize_t (*write)(FAR struct inode *inode, FAR const unsigned char *buffer,
|
||||
size_t start_sector, unsigned int nsectors);
|
||||
size_t start_sector, unsigned int nsectors);
|
||||
int (*geometry)(FAR struct inode *inode, FAR struct geometry *geometry);
|
||||
int (*ioctl)(FAR struct inode *inode, int cmd, unsigned long arg);
|
||||
};
|
||||
|
@ -140,16 +141,17 @@ struct mountpt_operations
|
|||
*/
|
||||
|
||||
int (*open)(FAR struct file *filep, FAR const char *relpath,
|
||||
int oflags, mode_t mode);
|
||||
int oflags, mode_t mode);
|
||||
|
||||
/* The following methods must be identical in signature and position because
|
||||
* the struct file_operations and struct mountp_operations are treated like
|
||||
* unions.
|
||||
/* The following methods must be identical in signature and position
|
||||
* because the struct file_operations and struct mountp_operations are
|
||||
* treated like unions.
|
||||
*/
|
||||
|
||||
int (*close)(FAR struct file *filep);
|
||||
ssize_t (*read)(FAR struct file *filep, FAR char *buffer, size_t buflen);
|
||||
ssize_t (*write)(FAR struct file *filep, FAR const char *buffer, size_t buflen);
|
||||
ssize_t (*write)(FAR struct file *filep, FAR const char *buffer,
|
||||
size_t buflen);
|
||||
off_t (*seek)(FAR struct file *filep, off_t offset, int whence);
|
||||
int (*ioctl)(FAR struct file *filep, int cmd, unsigned long arg);
|
||||
|
||||
|
@ -165,43 +167,74 @@ struct mountpt_operations
|
|||
|
||||
/* Directory operations */
|
||||
|
||||
int (*opendir)(FAR struct inode *mountpt, FAR const char *relpath, FAR struct fs_dirent_s *dir);
|
||||
int (*closedir)(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir);
|
||||
int (*readdir)(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir);
|
||||
int (*rewinddir)(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir);
|
||||
int (*opendir)(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
FAR struct fs_dirent_s *dir);
|
||||
int (*closedir)(FAR struct inode *mountpt,
|
||||
FAR struct fs_dirent_s *dir);
|
||||
int (*readdir)(FAR struct inode *mountpt,
|
||||
FAR struct fs_dirent_s *dir);
|
||||
int (*rewinddir)(FAR struct inode *mountpt,
|
||||
FAR struct fs_dirent_s *dir);
|
||||
|
||||
/* General volume-related mountpoint operations: */
|
||||
|
||||
int (*bind)(FAR struct inode *blkdriver, FAR const void *data, FAR void **handle);
|
||||
int (*bind)(FAR struct inode *blkdriver, FAR const void *data,
|
||||
FAR void **handle);
|
||||
int (*unbind)(FAR void *handle, FAR struct inode **blkdriver);
|
||||
|
||||
int (*statfs)(FAR struct inode *mountpt, FAR struct statfs *buf);
|
||||
|
||||
/* Operations on paths */
|
||||
|
||||
int (*unlink)(FAR struct inode *mountpt, FAR const char *relpath);
|
||||
int (*mkdir)(FAR struct inode *mountpt, FAR const char *relpath, mode_t mode);
|
||||
int (*mkdir)(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
mode_t mode);
|
||||
int (*rmdir)(FAR struct inode *mountpt, FAR const char *relpath);
|
||||
int (*rename)(FAR struct inode *mountpt, FAR const char *oldrelpath, FAR const char *newrelpath);
|
||||
int (*stat)(FAR struct inode *mountpt, FAR const char *relpath, FAR struct stat *buf);
|
||||
int (*rename)(FAR struct inode *mountpt, FAR const char *oldrelpath,
|
||||
FAR const char *newrelpath);
|
||||
int (*stat)(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
FAR struct stat *buf);
|
||||
|
||||
/* NOTE: More operations will be needed here to support: disk usage stats
|
||||
* file stat(), file attributes, file truncation, etc.
|
||||
/* NOTE: More operations will be needed here to support: disk usage
|
||||
* stats file stat(), file attributes, file truncation, etc.
|
||||
*/
|
||||
};
|
||||
#endif /* CONFIG_DISABLE_MOUNTPOUNT */
|
||||
|
||||
/* Named OS resources are also maintained by the VFS. This includes:
|
||||
*
|
||||
* - Named semaphores: sem_open(), sem_close(), and sem_unlink()
|
||||
* - POSIX Message Queues: mq_open() and mq_close()
|
||||
* - Shared memory: shm_open() and shm_unlink();
|
||||
*
|
||||
* These are a special case in that they do not follow quite the same
|
||||
* pattern as the other file system types in that they have no read or
|
||||
* write methods.
|
||||
*
|
||||
* Each inode type carries a payload specific to the OS resource;
|
||||
* Only the contents of struct special_operations is visible to the VFS.
|
||||
*/
|
||||
|
||||
struct inode;
|
||||
struct special_operations
|
||||
{
|
||||
int (*open)(FAR struct inode *inode);
|
||||
int (*close)(FAR struct inode *inode);
|
||||
int (*unlink)(FAR struct inode *inode, FAR const char *relpath);
|
||||
};
|
||||
|
||||
/* These are the various kinds of operations that can be associated with
|
||||
* an inode.
|
||||
*/
|
||||
|
||||
union inode_ops_u
|
||||
{
|
||||
FAR const struct file_operations *i_ops; /* Driver operations for inode */
|
||||
FAR const struct file_operations *i_ops; /* Driver operations for inode */
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOUNT
|
||||
FAR const struct block_operations *i_bops; /* Block driver operations */
|
||||
FAR const struct mountpt_operations *i_mops; /* Operations on a mountpoint */
|
||||
FAR const struct block_operations *i_bops; /* Block driver operations */
|
||||
FAR const struct mountpt_operations *i_mops; /* Operations on a mountpoint */
|
||||
#endif
|
||||
FAR const struct special_operations *i_xops; /* Generic operations on OS resources */
|
||||
FAR const struct semaphore_operations *i_sops; /* Operations for named semaphores */
|
||||
};
|
||||
|
||||
/* This structure represents one inode in the Nuttx pseudo-file system */
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* General ioctl definitions ************************************************/
|
||||
/* Each NuttX ioctl commands are uint16_t's consisting of an 8-bit type
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include <nuttx/fs/fs.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
/* If the erased state of FLASH memory is anything other than 0xff, then this
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include <nuttx/fs/fs.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Data entry declaration prototypes ****************************************/
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Macros to hide implementation */
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include <nuttx/compiler.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* IRQ detach is a convenience definition. Detaching an interrupt handler
|
||||
* is equivalent to setting a NULL interrupt handler.
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include <sched.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include <nuttx/fs/fs.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
#if CONFIG_MQ_MAXMSGSIZE > 0
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
#ifdef CONFIG_PAGING
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#ifdef CONFIG_MM_PGALLOC
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
/* CONFIG_MM_PGALLOC - Enable page allocator support
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include <sched.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Default pthread attribute initializer */
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
#ifdef CONFIG_PWM
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
/* CONFIG_PWM - Enables because PWM driver support
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include <nuttx/fs/fs.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* SCSI commands ************************************************************/
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#include <nuttx/wqueue.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* SDIO events needed by the driver
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include <time.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* If Gregorian time is not supported, then neither is Julian */
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include <nuttx/ascii.h>
|
||||
|
||||
/********************************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
********************************************************************************************/
|
||||
|
||||
#define VT100_SETNL {ASCII_ESC, '[', '2', '0', 'h'} /* Set new line mode */
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include <queue.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
/* CONFIG_SCHED_WORKQUEUE. Create a dedicated "worker" thread to
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
#include <time.h> /* Needed for struct timespec */
|
||||
|
||||
/********************************************************************************
|
||||
* Compilation Switches
|
||||
* Pre-processor Definitions
|
||||
********************************************************************************/
|
||||
|
||||
/* Standard POSIX switches */
|
||||
|
@ -67,10 +67,6 @@
|
|||
# define _POSIX_THREAD_ATTR_STACKSIZE
|
||||
#endif
|
||||
|
||||
/********************************************************************************
|
||||
* Definitions
|
||||
********************************************************************************/
|
||||
|
||||
/* Values for the process shared (pshared) attribute */
|
||||
|
||||
#define PTHREAD_PROCESS_PRIVATE 0
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* The C standard specifies two constants, EXIT_SUCCESS and
|
||||
|
|
|
@ -75,7 +75,7 @@ typedef struct nsem_s nsem_t;
|
|||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
/* This is a list of dyanamically allocated named semaphores */
|
||||
/* This is a list of dynamically allocated named semaphores */
|
||||
|
||||
extern dq_queue_t g_nsems;
|
||||
|
||||
|
|
Loading…
Reference in New Issue