[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] ios: Introduce IO stream device for stdin, stdout, stder
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH 2/2] ios: Introduce IO stream device for stdin, stdout, stderr. |
Date: |
Sun, 10 May 2020 23:23:25 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> +static char *
> +ios_dev_stream_handler_normalize (const char *handler)
> +{
> + if (strcmp (handler, "stdin")
> + && strcmp (handler, "stdout")
> + && strcmp (handler, "stderr"))
> + return NULL;
> +
> + return strdup (handler);
> +}
>
> I think we should introduce a new flag to use in ios_open,
> IOS_F_STREAM. This way, ios_open can do the following:
>
> - If IOS_M_RDONLY & IOS_F_STREAM -> Use the stream IOD to open the given
> filename.
>
> - If IOS_M_WRONLY & IOS_F_STREAM -> Use the stream IOD to open the given
> filename.
>
> At the Poke level this translates to:
>
> open ("foo/bar", IOS_F_STREAM & IOS_M_RDONLY)
> -> Open the file foo/bar as a read-only stream.
>
> open ("foo/bar", IOS_F_STREAM & IOS_M_WRONLY)
> -> Open the file foo/bar as a write-only stream.
>
> open ("foo/bar", IOS_F_STREAM & IOS_M_RDWR)
> -> ERROR. Not possible to open a stream for both read and write.
>
> This means that handler of the stream IOD won't ever be used, so it can
> just return NULL in all cases...
The filename is the handler, right? So "foo/bar" in this case. Plus,
it is used in .info ios too.
Also, if handler_normalize returns NULL, that is a rejection of the
handler by that IO device. It would eventually be opened as a regular
file.
Yeah, the filename is the handler. I forgot the interface.
Since the stream IOD operates on files reachable in the filesystem, I
would use exactly the same normalization than ios-dev-file. So we need
to factor the code currently in ios_dev_file_handler_normalize into a
function that can be also used by ios_dev_stream_handler_normalize...
> This will allow us to poke character devices, and named pipes created
> with mkfifo.
Right, I can add the flag IOS_F_STREAM. I need to check if they are
read and written to differently. Assuming it wouldn't be too
complicated, I can add the support for them too.
Thanks!
- [PATCH 1/2] ios: Introduce ios_flush and ios_dev_<...>_flush., Egeyar Bagcioglu, 2020/05/10
- [PATCH 2/2] ios: Introduce IO stream device for stdin, stdout, stderr., Egeyar Bagcioglu, 2020/05/10
- Re: [PATCH 2/2] ios: Introduce IO stream device for stdin, stdout, stderr., Jose E. Marchesi, 2020/05/10
- Re: [PATCH 2/2] ios: Introduce IO stream device for stdin, stdout, stderr., Jose E. Marchesi, 2020/05/10
- Re: [PATCH 2/2] ios: Introduce IO stream device for stdin, stdout, stderr., Jose E. Marchesi, 2020/05/10
- Re: [PATCH 1/2] ios: Introduce ios_flush and ios_dev_<...>_flush., Jose E. Marchesi, 2020/05/10