poke-devel
[Top][All Lists]
Advanced

[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: Egeyar Bagcioglu
Subject: Re: [PATCH 2/2] ios: Introduce IO stream device for stdin, stdout, stderr.
Date: Sun, 10 May 2020 23:04:14 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0



On 5/10/20 9:53 PM, Jose E. Marchesi wrote:
     +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.

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
Ege



reply via email to

[Prev in Thread] Current Thread [Next in Thread]