summaryrefslogtreecommitdiffstats
path: root/src/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/io.c b/src/io.c
index 9dae2e1..682eea2 100644
--- a/src/io.c
+++ b/src/io.c
@@ -20,7 +20,6 @@
static int stream_open_out(struct stream * const in);
static int stream_open_out_lite(struct stream * const in);
static int stream_open_in(struct stream * const in);
-static int stream_open_chardev(struct stream * const in);
static int stream_flush(struct stream * const in);
static int stream_flush_array(struct stream * const in);
static int stream_flush_list(struct stream * const in);
@@ -29,7 +28,7 @@ int stream_open(struct stream * const in)
{
int ret = 0;
- try(!in || in->fd > 0 || !in->name, err, EINVAL, "invalid argunent");
+ try(!in || in->fd > 0 || (!in->name && in->type != stream_randread), err, EINVAL, "invalid argunent");
switch (in->type) {
case (stream_outlite):
@@ -43,8 +42,8 @@ int stream_open(struct stream * const in)
try(!in->name, err, EINVAL, "no filename given");
ret = stream_open_in(in);
break;
- case (stream_chardev):
- ret = stream_open_chardev(in);
+ case (stream_randread):
+ ; /* NOOP */
break;
default:
try(0, err, EINVAL, "cannot open stream: stream is invalid");
@@ -58,7 +57,7 @@ int stream_close(struct stream * const in)
{
int ret = 0;
- try(!in || in->fd < 0, early_err, EINVAL, "invalid argunent");
+ try(!in || (in->fd < 0 && in->type != stream_randread), early_err, EINVAL, "invalid argunent");
if (in->type != stream_out) {
goto out;
@@ -166,19 +165,6 @@ err:
return ret;
}
-static int stream_open_chardev(struct stream * const in)
-{
- struct stat st;
- int ret = 0;
-
- try(stat(in->name, &st), err, errno, "stat failed: %s", strerror(ret));
- in->fd = open(in->name, O_RDONLY);
- try(in->fd < 0, err, errno, "failed opening input file: %s", strerror(ret));
-
-err:
- return ret;
-}
-
int stream_flush(struct stream * const in)
{
int ret = 0;