miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Toggle main menu visibility
Loading...
Searching...
No Matches
pipe.h
Go to the documentation of this file.
1
// MIT License
2
//
3
// Copyright (c) 2026 Christian Spoo
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included in all
13
// copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
23
#ifndef _MINIOS_FS_PIPE_H_
24
#define _MINIOS_FS_PIPE_H_
25
26
#include <
miniOS/types.h
>
27
28
/* Forward-declare the ops struct to break the circular include with vfs.h.
29
* vfs.h includes pipe.h (pipe_t in vfs_file_t); pipe.h uses struct vfs_ops *
30
* to avoid needing the full vfs_ops_t typedef. The typedef and full definition
31
* live in vfs.h which callers should include directly. */
32
struct
vfs_ops
;
33
39
#define PIPE_SIZE 4096
40
54
typedef
struct
{
55
uint8_t
buf
[
PIPE_SIZE
];
56
uint32_t
write_pos
;
/* monotonically increasing; use % PIPE_SIZE to index */
57
uint32_t
read_pos
;
/* monotonically increasing; use % PIPE_SIZE to index */
58
uint32_t
ref_count
;
/* total number of fds (read + write ends) alive */
59
uint8_t
write_closed
;
/* non-zero when all write-end fds have been closed */
60
}
pipe_t
;
61
70
pipe_t
*
pipe_create
(
void
);
71
84
int
pipe_read
(
uint32_t
ino,
uint64_t
off,
void
*buf,
uint32_t
len
);
85
98
int
pipe_write
(
uint32_t
ino,
uint64_t
off,
const
void
*buf,
uint32_t
len
);
99
106
void
pipe_free
(
pipe_t
*p);
107
111
extern
struct
vfs_ops
pipe_ops
;
112
120
int
pipe_write_buf
(
pipe_t
*p,
const
void
*buf,
uint32_t
len
);
121
int
pipe_read_buf
(
pipe_t
*p,
void
*buf,
uint32_t
len
);
122
123
#endif
/* _MINIOS_FS_PIPE_H_ */
pipe_create
pipe_t * pipe_create(void)
Definition
pipe.c:37
pipe_write_buf
int pipe_write_buf(pipe_t *p, const void *buf, uint32_t len)
Definition
pipe.c:89
pipe_ops
struct vfs_ops pipe_ops
Definition
pipe.c:125
pipe_read_buf
int pipe_read_buf(pipe_t *p, void *buf, uint32_t len)
Definition
pipe.c:57
pipe_free
void pipe_free(pipe_t *p)
Definition
pipe.c:113
pipe_read
int pipe_read(uint32_t ino, uint64_t off, void *buf, uint32_t len)
Definition
pipe.c:71
PIPE_SIZE
#define PIPE_SIZE
Definition
pipe.h:39
pipe_write
int pipe_write(uint32_t ino, uint64_t off, const void *buf, uint32_t len)
Definition
pipe.c:101
pipe_t
Definition
pipe.h:54
pipe_t::write_closed
uint8_t write_closed
Definition
pipe.h:59
pipe_t::write_pos
uint32_t write_pos
Definition
pipe.h:56
pipe_t::ref_count
uint32_t ref_count
Definition
pipe.h:58
pipe_t::buf
uint8_t buf[PIPE_SIZE]
Definition
pipe.h:55
pipe_t::read_pos
uint32_t read_pos
Definition
pipe.h:57
vfs_ops
Definition
vfs.h:75
types.h
uint32_t
unsigned int uint32_t
Definition
types.h:34
uint64_t
unsigned long int uint64_t
Definition
types.h:37
uint8_t
unsigned char uint8_t
Definition
types.h:28
len
uint32_t len
Definition
virtio_net.c:1
include
miniOS
fs
pipe.h
Generated by
1.18.0