Re: [libvirt RFCv4 04/20] runio: add arguments to extend use beyond just stdin and stdout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/28/22 2:54 PM, Daniel P. Berrangé wrote:
> On Wed, Apr 27, 2022 at 11:13:23PM +0200, Claudio Fontana wrote:
>> add arguments to runio to allow read/write from/to arbitrary
>> file descriptors, as opposed to just stdin and stdout.
>>
>> Signed-off-by: Claudio Fontana <cfontana@xxxxxxx>
>> ---
>>  src/util/iohelper.c |  2 +-
>>  src/util/runio.c    | 10 +++++-----
>>  src/util/runio.h    | 17 ++++++++++++++++-
>>  3 files changed, 22 insertions(+), 7 deletions(-)
>>
>> diff --git a/src/util/iohelper.c b/src/util/iohelper.c
>> index 5a0098542e..93674c1e2f 100644
>> --- a/src/util/iohelper.c
>> +++ b/src/util/iohelper.c
>> @@ -96,7 +96,7 @@ main(int argc, char **argv)
>>          usage(EXIT_FAILURE);
>>      }
>>  
>> -    if (fd < 0 || runIO(path, fd, oflags) < 0)
>> +    if (fd < 0 || runIO(path, fd, oflags, STDIN_FILENO, STDOUT_FILENO) < 0)
>>          goto error;
>>  
>>      return 0;
>> diff --git a/src/util/runio.c b/src/util/runio.c
>> index a7b902af7e..f42acddae9 100644
>> --- a/src/util/runio.c
>> +++ b/src/util/runio.c
>> @@ -134,7 +134,7 @@ runIOCopy(const struct runIOParams p)
>>  
>>  
>>  off_t
>> -runIO(const char *path, int fd, int oflags)
>> +runIO(const char *path, int fd, int oflags, int in_fd, int out_fd)
> 
> This is getting rather wierd as a signature.
> 
> If O_RDONLY, then in_fd is ignored, 'fd' is input.
> 
> If O_WRONLY, then out_fd is ignored, 'fd' is output
> 
> What about instead simply :
> 
>    runIO(const char *srcpath, int srcfd,
>          const char *dstpath, int dstfd)
> 
> so there's no read vs write distinction at all.

maybe I am a bit confused/tired, but I don't see how this would work,
which side one of those is the disk, where we want to check for S_ISBLK and O_DIRECT, and buffer accordingly?

...

Alternative:

off_t runIO(int disk_fd, const char *disk_path, int remote_fd, char *remote_path) ?

And we could check oflags of disk_fd inside runIO instead of having it as an argument, to remove some clutter.

Downside is for stdin and stdout we need then something special. For example:

runIO(fd, path, -1, "stdio");

where "stdio" alerts runIO that it needs to use STDIN_FILENO if we are writing to the disk, or STDOUT_FILENO if we are reading from the disk.

Wdyt?

Thanks,

Claudio





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux