source: rtems/cpukit/libfs/src/pipe/pipe.h @ 1f16a9f

Last change on this file since 1f16a9f was 1f16a9f, checked in by Sebastian Huber <sebastian.huber@…>, on 04/12/12 at 15:15:53

Filesystem: Add select() support for pipes

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/**
2 * @file rtems/pipe.h
3 *
4 * This include file defines the interface to the POSIX FIFO/pipe file system
5 * support.
6 */
7
8/*
9 * Author: Wei Shen <cquark@gmail.com>
10 *
11 * The license and distribution terms for this file may be
12 * found in the file LICENSE in this distribution or at
13 * http://www.rtems.com/license/LICENSE.
14 *
15 * $Id$
16 */
17
18#ifndef _RTEMS_PIPE_H
19#define _RTEMS_PIPE_H
20
21#include <rtems/libio.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* Control block to manage each pipe */
28typedef struct pipe_control {
29  char *Buffer;
30  unsigned int Size;
31  unsigned int Start;
32  unsigned int Length;
33  unsigned int Readers;
34  unsigned int Writers;
35  unsigned int waitingReaders;
36  unsigned int waitingWriters;
37  unsigned int readerCounter;     /* incremental counters */
38  unsigned int writerCounter;     /* for differentiation of successive opens */
39  rtems_id Semaphore;
40  rtems_id readBarrier;   /* wait queues */
41  rtems_id writeBarrier;
42  rtems_id select_read_task_id;
43  rtems_id select_write_task_id;
44#if 0
45  boolean Anonymous;      /* anonymous pipe or FIFO */
46#endif
47} pipe_control_t;
48
49/*
50 * Called by pipe() to create an anonymous pipe.
51 */
52extern int pipe_create(
53  int filsdes[2]
54);
55
56/*
57 * Interface to file system close.
58 *
59 * *pipep points to pipe control structure. When the last user releases pipe,
60 * it will be set to NULL.
61 */
62extern void pipe_release(
63  pipe_control_t **pipep,
64  rtems_libio_t *iop
65);
66
67/*
68 * Interface to file system open.
69 *
70 * *pipep points to pipe control structure. If called with *pipep = NULL,
71 * fifo_open will try allocating and initializing a control structure. If the
72 * call succeeds, *pipep will be set to address of new control structure.
73 */
74extern int fifo_open(
75  pipe_control_t **pipep,
76  rtems_libio_t *iop
77);
78
79/*
80 * Interface to file system read.
81 */
82extern ssize_t pipe_read(
83  pipe_control_t *pipe,
84  void           *buffer,
85  size_t          count,
86  rtems_libio_t  *iop
87);
88
89/*
90 * Interface to file system write.
91 */
92extern ssize_t pipe_write(
93  pipe_control_t *pipe,
94  const void     *buffer,
95  size_t          count,
96  rtems_libio_t  *iop
97);
98
99/*
100 * Interface to file system ioctl.
101 */
102extern int pipe_ioctl(
103  pipe_control_t *pipe,
104  uint32_t        cmd,
105  void           *buffer,
106  rtems_libio_t  *iop
107);
108
109/*
110 * Interface to file system lseek.
111 */
112extern int pipe_lseek(
113  pipe_control_t *pipe,
114  off_t           offset,
115  int             whence,
116  rtems_libio_t  *iop
117);
118
119#ifdef __cplusplus
120}
121#endif
122
123#endif
Note: See TracBrowser for help on using the repository browser.