Commit 312d3ec5 authored by Kevin Wolf's avatar Kevin Wolf

libc: pipe() implementiert

+ libc: Statt einem Stub, der immer einen Fehler zurückgibt, können wir
  jetzt in pipe() eine richtige Pipe erstellen
Signed-off-by: Kevin Wolf's avatarKevin Wolf <kevin@tyndur.org>
parent 2a2aac8a
......@@ -58,15 +58,6 @@ pid_t fork()
return -1;
}
/**
* Pipe einrichten
*/
int pipe(int mode[2])
{
errno = ENFILE;
return -1;
}
/**
* Gibt den Hostnamen dieses Rechners zurueck
*/
......
......@@ -320,6 +320,50 @@ int open(const char* filename, int flags, ...)
return fd;
}
/**
* Pipe einrichten
*/
int pipe(int fd[2])
{
lio_stream_t reader, writer;
io_resource_t* reader_file;
io_resource_t* writer_file;
int ret;
ret = lio_pipe(&reader, &writer, false);
if (ret < 0) {
errno = -ret;
return -1;
}
/* Datenstruktur anlegen */
reader_file = malloc(sizeof(*reader_file));
writer_file = malloc(sizeof(*writer_file));
if (!reader_file || !writer_file) {
free(reader_file);
free(writer_file);
errno = -ENOMEM;
return -1;
}
*reader_file = (io_resource_t) {
.lio2_stream = reader,
.lio2_res = 0x42424242, /* Muss != 0 sein für LIOv2 */
.flags = IO_RES_FLAG_READAHEAD,
};
fd[0] = __iores_fileno(reader_file);
*writer_file = (io_resource_t) {
.lio2_stream = writer,
.lio2_res = 0x42424242, /* Muss != 0 sein für LIOv2 */
.flags = IO_RES_FLAG_READAHEAD,
};
fd[1] = __iores_fileno(writer_file);
return 0;
}
/**
* Eine Datei erstellen und als Unix-Dateideskriptor oeffnen
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment