2018-12-12 13:15:54 +00:00
|
|
|
/*
|
2020-02-20 15:35:16 +00:00
|
|
|
Copyright (c) 2016-2020 Chung, Hyung-Hwan. All rights reserved.
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
2022-06-11 05:32:01 +00:00
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
2018-12-12 13:15:54 +00:00
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
#include <hio-pro.h>
|
|
|
|
#include "hio-prv.h"
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
2019-03-15 05:06:56 +00:00
|
|
|
#include <signal.h>
|
2018-12-12 13:15:54 +00:00
|
|
|
#include <sys/wait.h>
|
2020-05-01 18:01:29 +00:00
|
|
|
#include <sys/uio.h>
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
/* ========================================================================= */
|
|
|
|
|
|
|
|
struct slave_info_t
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_make_t* mi;
|
|
|
|
hio_syshnd_t pfd;
|
2019-01-31 09:16:44 +00:00
|
|
|
int dev_cap;
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_sid_t id;
|
2018-12-12 13:15:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct slave_info_t slave_info_t;
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static hio_dev_pro_slave_t* make_slave (hio_t* hio, slave_info_t* si);
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
/* ========================================================================= */
|
|
|
|
|
|
|
|
struct param_t
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_bch_t* mcmd;
|
|
|
|
hio_bch_t* fixed_argv[4];
|
|
|
|
hio_bch_t** argv;
|
2018-12-12 13:15:54 +00:00
|
|
|
};
|
|
|
|
typedef struct param_t param_t;
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static void free_param (hio_t* hio, param_t* param)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2023-01-11 14:59:41 +00:00
|
|
|
if (param->argv && param->argv != param->fixed_argv)
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_freemem (hio, param->argv);
|
|
|
|
if (param->mcmd) hio_freemem (hio, param->mcmd);
|
|
|
|
HIO_MEMSET (param, 0, HIO_SIZEOF(*param));
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2022-02-15 11:14:10 +00:00
|
|
|
static int make_param (hio_t* hio, const void* cmd, int flags, param_t* param)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
int fcnt = 0;
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_bch_t* mcmd = HIO_NULL;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_MEMSET (param, 0, HIO_SIZEOF(*param));
|
2018-12-12 13:15:54 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (flags & HIO_DEV_PRO_SHELL)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2022-02-15 11:14:10 +00:00
|
|
|
if (flags & HIO_DEV_PRO_UCMD)
|
|
|
|
{
|
|
|
|
mcmd = hio_duputobcstr(hio, cmd, HIO_NULL);
|
|
|
|
if (HIO_UNLIKELY(!mcmd)) goto oops;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mcmd = (hio_bch_t*)cmd;
|
|
|
|
}
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
param->argv = param->fixed_argv;
|
2018-12-16 17:37:59 +00:00
|
|
|
param->argv[0] = "/bin/sh";
|
|
|
|
param->argv[1] = "-c";
|
2018-12-12 13:15:54 +00:00
|
|
|
param->argv[2] = mcmd;
|
2021-07-22 07:30:20 +00:00
|
|
|
param->argv[3] = HIO_NULL;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int i;
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_bch_t** argv;
|
|
|
|
hio_bch_t* mcmdptr;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
2022-02-15 11:14:10 +00:00
|
|
|
mcmd = (flags & HIO_DEV_PRO_UCMD)?
|
|
|
|
hio_duputobcstr(hio, cmd, HIO_NULL):
|
|
|
|
hio_dupbcstr(hio, cmd, HIO_NULL);
|
2022-02-14 15:13:38 +00:00
|
|
|
if (HIO_UNLIKELY(!mcmd)) goto oops;
|
|
|
|
|
2023-01-11 14:59:41 +00:00
|
|
|
fcnt = hio_split_bcstr(mcmd, "", '\"', '\"', '\\');
|
|
|
|
if (fcnt <= 0)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
/* no field or an error */
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (hio, HIO_EINVAL);
|
2018-12-12 13:15:54 +00:00
|
|
|
goto oops;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (fcnt < HIO_COUNTOF(param->fixed_argv))
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
param->argv = param->fixed_argv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
param->argv = hio_allocmem(hio, (fcnt + 1) * HIO_SIZEOF(argv[0]));
|
2022-02-14 15:13:38 +00:00
|
|
|
if (HIO_UNLIKELY(!param->argv)) goto oops;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mcmdptr = mcmd;
|
|
|
|
for (i = 0; i < fcnt; i++)
|
|
|
|
{
|
|
|
|
param->argv[i] = mcmdptr;
|
2018-12-16 17:37:59 +00:00
|
|
|
while (*mcmdptr != '\0') mcmdptr++;
|
2018-12-12 13:15:54 +00:00
|
|
|
mcmdptr++;
|
|
|
|
}
|
2021-07-22 07:30:20 +00:00
|
|
|
param->argv[i] = HIO_NULL;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (mcmd && mcmd != (hio_bch_t*)cmd) param->mcmd = mcmd;
|
2018-12-12 13:15:54 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
oops:
|
2021-07-22 07:30:20 +00:00
|
|
|
if (mcmd && mcmd != cmd) hio_freemem (hio, mcmd);
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static pid_t standard_fork_and_exec (hio_dev_pro_t* dev, int pfds[], hio_dev_pro_make_t* mi, param_t* param)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_t* hio = dev->hio;
|
2018-12-12 13:15:54 +00:00
|
|
|
pid_t pid;
|
|
|
|
|
2020-05-20 10:25:12 +00:00
|
|
|
pid = fork();
|
2023-01-11 14:59:41 +00:00
|
|
|
if (pid == -1)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrwithsyserr (hio, 0, errno);
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pid == 0)
|
|
|
|
{
|
|
|
|
/* slave process */
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_syshnd_t devnull = HIO_SYSHND_INVALID;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
/* TODO: close all uneeded fds */
|
2020-05-20 10:25:12 +00:00
|
|
|
if (mi->on_fork) mi->on_fork (dev, mi->fork_ctx);
|
2018-12-12 13:15:54 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (mi->flags & HIO_DEV_PRO_WRITEIN)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
/* slave should read */
|
|
|
|
close (pfds[1]);
|
2021-07-22 07:30:20 +00:00
|
|
|
pfds[1] = HIO_SYSHND_INVALID;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
/* let the pipe be standard input */
|
2019-01-30 19:07:05 +00:00
|
|
|
if (dup2(pfds[0], 0) <= -1) goto slave_oops;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
close (pfds[0]);
|
2021-07-22 07:30:20 +00:00
|
|
|
pfds[0] = HIO_SYSHND_INVALID;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (mi->flags & HIO_DEV_PRO_READOUT)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
/* slave should write */
|
|
|
|
close (pfds[2]);
|
2021-07-22 07:30:20 +00:00
|
|
|
pfds[2] = HIO_SYSHND_INVALID;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
if (dup2(pfds[3], 1) == -1) goto slave_oops;
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (mi->flags & HIO_DEV_PRO_ERRTOOUT)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
if (dup2(pfds[3], 2) == -1) goto slave_oops;
|
|
|
|
}
|
|
|
|
|
|
|
|
close (pfds[3]);
|
2021-07-22 07:30:20 +00:00
|
|
|
pfds[3] = HIO_SYSHND_INVALID;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (mi->flags & HIO_DEV_PRO_READERR)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
close (pfds[4]);
|
2021-07-22 07:30:20 +00:00
|
|
|
pfds[4] = HIO_SYSHND_INVALID;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
if (dup2(pfds[5], 2) == -1) goto slave_oops;
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (mi->flags & HIO_DEV_PRO_OUTTOERR)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
if (dup2(pfds[5], 1) == -1) goto slave_oops;
|
|
|
|
}
|
|
|
|
|
|
|
|
close (pfds[5]);
|
2021-07-22 07:30:20 +00:00
|
|
|
pfds[5] = HIO_SYSHND_INVALID;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if ((mi->flags & HIO_DEV_PRO_INTONUL) ||
|
|
|
|
(mi->flags & HIO_DEV_PRO_OUTTONUL) ||
|
|
|
|
(mi->flags & HIO_DEV_PRO_ERRTONUL))
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
#if defined(O_LARGEFILE)
|
2020-05-15 06:18:49 +00:00
|
|
|
devnull = open("/dev/null", O_RDWR | O_LARGEFILE, 0);
|
2018-12-12 13:15:54 +00:00
|
|
|
#else
|
2020-05-15 06:18:49 +00:00
|
|
|
devnull = open("/dev/null", O_RDWR, 0);
|
2018-12-12 13:15:54 +00:00
|
|
|
#endif
|
2021-07-22 07:30:20 +00:00
|
|
|
if (devnull == HIO_SYSHND_INVALID) goto slave_oops;
|
2020-05-24 01:18:32 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if ((mi->flags & HIO_DEV_PRO_INTONUL) && dup2(devnull, 0) == -1) goto slave_oops;
|
|
|
|
if ((mi->flags & HIO_DEV_PRO_OUTTONUL) && dup2(devnull, 1) == -1) goto slave_oops;
|
|
|
|
if ((mi->flags & HIO_DEV_PRO_ERRTONUL) && dup2(devnull, 2) == -1) goto slave_oops;
|
2020-05-24 01:18:32 +00:00
|
|
|
|
2023-01-11 14:59:41 +00:00
|
|
|
close (devnull);
|
2021-07-22 07:30:20 +00:00
|
|
|
devnull = HIO_SYSHND_INVALID;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (mi->flags & HIO_DEV_PRO_DROPIN) close (0);
|
|
|
|
if (mi->flags & HIO_DEV_PRO_DROPOUT) close (1);
|
|
|
|
if (mi->flags & HIO_DEV_PRO_DROPERR) close (2);
|
2020-05-24 01:18:32 +00:00
|
|
|
|
2018-12-12 13:15:54 +00:00
|
|
|
execv (param->argv[0], param->argv);
|
|
|
|
|
|
|
|
/* if exec fails, free 'param' parameter which is an inherited pointer */
|
2023-01-11 14:59:41 +00:00
|
|
|
free_param (hio, param);
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
slave_oops:
|
2021-07-22 07:30:20 +00:00
|
|
|
if (devnull != HIO_SYSHND_INVALID) close(devnull);
|
2018-12-12 13:15:54 +00:00
|
|
|
_exit (128);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* parent process */
|
|
|
|
return pid;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int dev_pro_make_master (hio_dev_t* dev, void* ctx)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_t* hio = dev->hio;
|
|
|
|
hio_dev_pro_t* rdev = (hio_dev_pro_t*)dev;
|
|
|
|
hio_dev_pro_make_t* info = (hio_dev_pro_make_t*)ctx;
|
|
|
|
hio_syshnd_t pfds[6] = { HIO_SYSHND_INVALID, HIO_SYSHND_INVALID, HIO_SYSHND_INVALID, HIO_SYSHND_INVALID, HIO_SYSHND_INVALID, HIO_SYSHND_INVALID };
|
2018-12-12 13:15:54 +00:00
|
|
|
int i, minidx = -1, maxidx = -1;
|
|
|
|
param_t param;
|
|
|
|
pid_t pid;
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (info->flags & HIO_DEV_PRO_WRITEIN)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
if (pipe(&pfds[0]) == -1)
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrwithsyserr (hio, 0, errno);
|
2018-12-12 13:15:54 +00:00
|
|
|
goto oops;
|
|
|
|
}
|
|
|
|
minidx = 0; maxidx = 1;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (info->flags & HIO_DEV_PRO_READOUT)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
if (pipe(&pfds[2]) == -1)
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrwithsyserr (hio, 0, errno);
|
2018-12-12 13:15:54 +00:00
|
|
|
goto oops;
|
|
|
|
}
|
|
|
|
if (minidx == -1) minidx = 2;
|
|
|
|
maxidx = 3;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (info->flags & HIO_DEV_PRO_READERR)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
if (pipe(&pfds[4]) == -1)
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrwithsyserr (hio, 0, errno);
|
2018-12-12 13:15:54 +00:00
|
|
|
goto oops;
|
|
|
|
}
|
|
|
|
if (minidx == -1) minidx = 4;
|
|
|
|
maxidx = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (maxidx == -1)
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (hio, HIO_EINVAL);
|
2018-12-12 13:15:54 +00:00
|
|
|
goto oops;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (make_param(hio, info->cmd, info->flags, ¶m) <= -1) goto oops;
|
2018-12-12 13:15:54 +00:00
|
|
|
/* TODO: more advanced fork and exec .. */
|
2020-05-21 10:15:57 +00:00
|
|
|
pid = standard_fork_and_exec(rdev, pfds, info, ¶m);
|
2021-07-22 07:30:20 +00:00
|
|
|
free_param (hio, ¶m);
|
2022-02-14 16:57:17 +00:00
|
|
|
if (pid <= -1) goto oops;
|
|
|
|
|
2018-12-12 13:15:54 +00:00
|
|
|
rdev->child_pid = pid;
|
|
|
|
|
|
|
|
/* this is the parent process */
|
2021-07-22 07:30:20 +00:00
|
|
|
if (info->flags & HIO_DEV_PRO_WRITEIN)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* 012345
|
|
|
|
* rw----
|
|
|
|
* X
|
|
|
|
* WRITE => 1
|
|
|
|
*/
|
|
|
|
close (pfds[0]);
|
2021-07-22 07:30:20 +00:00
|
|
|
pfds[0] = HIO_SYSHND_INVALID;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (hio_makesyshndasync(hio, pfds[1]) <= -1) goto oops;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (info->flags & HIO_DEV_PRO_READOUT)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* 012345
|
|
|
|
* --rw--
|
|
|
|
* X
|
|
|
|
* READ => 2
|
|
|
|
*/
|
|
|
|
close (pfds[3]);
|
2021-07-22 07:30:20 +00:00
|
|
|
pfds[3] = HIO_SYSHND_INVALID;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (hio_makesyshndasync(hio, pfds[2]) <= -1) goto oops;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (info->flags & HIO_DEV_PRO_READERR)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* 012345
|
|
|
|
* ----rw
|
|
|
|
* X
|
|
|
|
* READ => 4
|
|
|
|
*/
|
|
|
|
close (pfds[5]);
|
2021-07-22 07:30:20 +00:00
|
|
|
pfds[5] = HIO_SYSHND_INVALID;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (hio_makesyshndasync(hio, pfds[4]) <= -1) goto oops;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (pfds[1] != HIO_SYSHND_INVALID)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
/* hand over pfds[2] to the first slave device */
|
|
|
|
slave_info_t si;
|
|
|
|
|
|
|
|
si.mi = info;
|
|
|
|
si.pfd = pfds[1];
|
2021-07-22 07:30:20 +00:00
|
|
|
si.dev_cap = HIO_DEV_CAP_OUT | HIO_DEV_CAP_STREAM;
|
|
|
|
si.id = HIO_DEV_PRO_IN;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
pfds[1] = HIO_SYSHND_INVALID;
|
|
|
|
rdev->slave[HIO_DEV_PRO_IN] = make_slave(hio, &si);
|
|
|
|
if (!rdev->slave[HIO_DEV_PRO_IN]) goto oops;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
rdev->slave_count++;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (pfds[2] != HIO_SYSHND_INVALID)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
/* hand over pfds[2] to the first slave device */
|
|
|
|
slave_info_t si;
|
|
|
|
|
|
|
|
si.mi = info;
|
|
|
|
si.pfd = pfds[2];
|
2021-07-22 07:30:20 +00:00
|
|
|
si.dev_cap = HIO_DEV_CAP_IN | HIO_DEV_CAP_STREAM;
|
|
|
|
si.id = HIO_DEV_PRO_OUT;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
pfds[2] = HIO_SYSHND_INVALID;
|
|
|
|
rdev->slave[HIO_DEV_PRO_OUT] = make_slave(hio, &si);
|
|
|
|
if (!rdev->slave[HIO_DEV_PRO_OUT]) goto oops;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
rdev->slave_count++;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (pfds[4] != HIO_SYSHND_INVALID)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
/* hand over pfds[4] to the second slave device */
|
|
|
|
slave_info_t si;
|
|
|
|
|
|
|
|
si.mi = info;
|
|
|
|
si.pfd = pfds[4];
|
2021-07-22 07:30:20 +00:00
|
|
|
si.dev_cap = HIO_DEV_CAP_IN | HIO_DEV_CAP_STREAM;
|
|
|
|
si.id = HIO_DEV_PRO_ERR;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
pfds[4] = HIO_SYSHND_INVALID;
|
|
|
|
rdev->slave[HIO_DEV_PRO_ERR] = make_slave(hio, &si);
|
|
|
|
if (!rdev->slave[HIO_DEV_PRO_ERR]) goto oops;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
rdev->slave_count++;
|
|
|
|
}
|
|
|
|
|
2023-01-11 14:59:41 +00:00
|
|
|
for (i = 0; i < HIO_COUNTOF(rdev->slave); i++)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
if (rdev->slave[i]) rdev->slave[i]->master = rdev;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
rdev->dev_cap = HIO_DEV_CAP_VIRTUAL; /* the master device doesn't perform I/O */
|
2018-12-12 13:15:54 +00:00
|
|
|
rdev->flags = info->flags;
|
|
|
|
rdev->on_read = info->on_read;
|
|
|
|
rdev->on_write = info->on_write;
|
|
|
|
rdev->on_close = info->on_close;
|
2022-06-25 15:34:20 +00:00
|
|
|
|
2023-01-11 14:59:41 +00:00
|
|
|
HIO_DEBUG7 (hio, "PRO(%p) - slave[%d] %p slave[%d] %p slave[%d] %p\n", dev,
|
|
|
|
HIO_DEV_PRO_IN, rdev->slave[HIO_DEV_PRO_IN],
|
2022-06-25 16:00:28 +00:00
|
|
|
HIO_DEV_PRO_OUT, rdev->slave[HIO_DEV_PRO_OUT],
|
|
|
|
HIO_DEV_PRO_ERR, rdev->slave[HIO_DEV_PRO_ERR]);
|
2018-12-12 13:15:54 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
oops:
|
2023-11-16 10:20:50 +00:00
|
|
|
for (i = minidx; i <= maxidx; i++)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
if (pfds[i] != HIO_SYSHND_INVALID) close (pfds[i]);
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2023-01-11 14:59:41 +00:00
|
|
|
if (rdev->mcmd)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_freemem (hio, rdev->mcmd);
|
|
|
|
free_param (hio, ¶m);
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
for (i = HIO_COUNTOF(rdev->slave); i > 0; )
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
i--;
|
|
|
|
if (rdev->slave[i])
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_kill ((hio_dev_t*)rdev->slave[i]);
|
|
|
|
rdev->slave[i] = HIO_NULL;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
rdev->slave_count = 0;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int dev_pro_kill_master (hio_dev_t* dev, int force)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_t* hio = dev->hio;
|
|
|
|
hio_dev_pro_t* rdev = (hio_dev_pro_t*)dev;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
if (rdev->slave_count > 0)
|
|
|
|
{
|
2022-02-14 16:57:17 +00:00
|
|
|
hio_oow_t i;
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
for (i = 0; i < HIO_COUNTOF(rdev->slave); i++)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
if (rdev->slave[i])
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_slave_t* sdev = rdev->slave[i];
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
/* nullify the pointer to the slave device
|
2021-07-22 07:30:20 +00:00
|
|
|
* before calling hio_dev_kill() on the slave device.
|
2018-12-12 13:15:54 +00:00
|
|
|
* the slave device can check this pointer to tell from
|
|
|
|
* self-initiated termination or master-driven termination */
|
2021-07-22 07:30:20 +00:00
|
|
|
rdev->slave[i] = HIO_NULL;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_kill ((hio_dev_t*)sdev);
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rdev->child_pid >= 0)
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
if (!(rdev->flags & HIO_DEV_PRO_FORGET_CHILD))
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
int killed = 0;
|
2022-02-14 16:57:17 +00:00
|
|
|
int status;
|
|
|
|
pid_t wpid;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
await_child:
|
2020-05-15 06:18:49 +00:00
|
|
|
wpid = waitpid(rdev->child_pid, &status, WNOHANG);
|
2018-12-12 13:15:54 +00:00
|
|
|
if (wpid == 0)
|
|
|
|
{
|
|
|
|
if (force && !killed)
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
if (!(rdev->flags & HIO_DEV_PRO_FORGET_DIEHARD_CHILD))
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
kill (rdev->child_pid, SIGKILL);
|
|
|
|
killed = 1;
|
|
|
|
goto await_child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* child process is still alive */
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (hio, HIO_EAGAIN);
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1; /* call me again */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* wpid == rdev->child_pid => full success
|
|
|
|
* wpid == -1 && errno == ECHILD => no such process. it's waitpid()'ed by some other part of the program?
|
|
|
|
* other cases ==> can't really handle properly. forget it by returning success
|
|
|
|
* no need not worry about EINTR because errno can't have the value when WNOHANG is set.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2022-06-25 15:34:20 +00:00
|
|
|
HIO_DEBUG2 (hio, "PRO(%p) - REAPED CHILD %d\n", dev, (int)rdev->child_pid);
|
2018-12-12 13:15:54 +00:00
|
|
|
rdev->child_pid = -1;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (rdev->on_close) rdev->on_close (rdev, HIO_DEV_PRO_MASTER);
|
2018-12-12 13:15:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int dev_pro_make_slave (hio_dev_t* dev, void* ctx)
|
2020-07-31 15:07:28 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_slave_t* rdev = (hio_dev_pro_slave_t*)dev;
|
2020-07-31 15:07:28 +00:00
|
|
|
slave_info_t* si = (slave_info_t*)ctx;
|
|
|
|
|
|
|
|
rdev->dev_cap = si->dev_cap;
|
|
|
|
rdev->id = si->id;
|
|
|
|
rdev->pfd = si->pfd;
|
2021-07-22 07:30:20 +00:00
|
|
|
/* keep rdev->master to HIO_NULL. it's set to the right master
|
2020-07-31 15:07:28 +00:00
|
|
|
* device in dev_pro_make() */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int dev_pro_kill_slave (hio_dev_t* dev, int force)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_t* hio = dev->hio;
|
|
|
|
hio_dev_pro_slave_t* rdev = (hio_dev_pro_slave_t*)dev;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
if (rdev->master)
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_t* master;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
master = rdev->master;
|
2021-07-22 07:30:20 +00:00
|
|
|
rdev->master = HIO_NULL;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
/* indicate EOF */
|
|
|
|
if (master->on_close) master->on_close (master, rdev->id);
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_ASSERT (hio, master->slave_count > 0);
|
2018-12-12 13:15:54 +00:00
|
|
|
master->slave_count--;
|
|
|
|
|
|
|
|
if (master->slave[rdev->id])
|
|
|
|
{
|
2020-05-21 10:15:57 +00:00
|
|
|
/* this call is started by the slave device itself. */
|
2023-01-11 14:59:41 +00:00
|
|
|
if (master->slave_count <= 0)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2020-05-21 10:15:57 +00:00
|
|
|
/* if this is the last slave, kill the master also */
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_kill ((hio_dev_t*)master);
|
2018-12-12 13:15:54 +00:00
|
|
|
/* the master pointer is not valid from this point onwards
|
2021-07-22 07:30:20 +00:00
|
|
|
* as the actual master device object is freed in hio_dev_kill() */
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
2020-05-01 18:56:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* this call is initiated by this slave device itself.
|
2021-07-22 07:30:20 +00:00
|
|
|
* if it were by the master device, it would be HIO_NULL as
|
2020-05-01 18:56:33 +00:00
|
|
|
* nullified by the dev_pro_kill() */
|
2021-07-22 07:30:20 +00:00
|
|
|
master->slave[rdev->id] = HIO_NULL;
|
2020-05-01 18:56:33 +00:00
|
|
|
}
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (rdev->pfd != HIO_SYSHND_INVALID)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
close (rdev->pfd);
|
2021-07-22 07:30:20 +00:00
|
|
|
rdev->pfd = HIO_SYSHND_INVALID;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-31 15:07:28 +00:00
|
|
|
static void dev_pro_fail_before_make_slave (void* ctx)
|
|
|
|
{
|
|
|
|
slave_info_t* si = (slave_info_t*)ctx;
|
|
|
|
close (si->pfd);
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int dev_pro_read_slave (hio_dev_t* dev, void* buf, hio_iolen_t* len, hio_devaddr_t* srcaddr)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_slave_t* pro = (hio_dev_pro_slave_t*)dev;
|
2018-12-12 13:15:54 +00:00
|
|
|
ssize_t x;
|
|
|
|
|
2020-05-21 10:15:57 +00:00
|
|
|
/* the read and write operation happens on different slave devices.
|
2023-01-11 14:59:41 +00:00
|
|
|
* the write EOF indication doesn't affect this device
|
2021-07-22 07:30:20 +00:00
|
|
|
if (HIO_UNLIKELY(pro->pfd == HIO_SYSHND_INVALID))
|
2020-05-19 09:11:39 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (pro->hio, HIO_EBADHND);
|
2020-05-19 09:11:39 +00:00
|
|
|
return -1;
|
2020-05-21 10:15:57 +00:00
|
|
|
}*/
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_ASSERT (pro->hio, pro->pfd != HIO_SYSHND_INVALID); /* use this assertion to check if my claim above is right */
|
2020-05-19 09:11:39 +00:00
|
|
|
|
2019-01-23 09:37:23 +00:00
|
|
|
x = read(pro->pfd, buf, *len);
|
2018-12-12 13:15:54 +00:00
|
|
|
if (x <= -1)
|
|
|
|
{
|
|
|
|
if (errno == EINPROGRESS || errno == EWOULDBLOCK || errno == EAGAIN) return 0; /* no data available */
|
|
|
|
if (errno == EINTR) return 0;
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrwithsyserr (pro->hio, 0, errno);
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*len = x;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int dev_pro_write_slave (hio_dev_t* dev, const void* data, hio_iolen_t* len, const hio_devaddr_t* dstaddr)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_slave_t* pro = (hio_dev_pro_slave_t*)dev;
|
2018-12-12 13:15:54 +00:00
|
|
|
ssize_t x;
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
/* this check is not needed because HIO_DEV_CAP_OUT_CLOSED is set on the device by the core
|
2020-05-21 10:15:57 +00:00
|
|
|
* when EOF indication is successful(return value 1 and *iovcnt 0).
|
2023-01-11 14:59:41 +00:00
|
|
|
* If HIO_DEV_CAP_OUT_CLOSED, the core doesn't invoke the write method
|
2021-07-22 07:30:20 +00:00
|
|
|
if (HIO_UNLIKELY(pro->pfd == HIO_SYSHND_INVALID))
|
2020-05-19 09:11:39 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (pro->hio, HIO_EBADHND);
|
2020-05-19 09:11:39 +00:00
|
|
|
return -1;
|
2020-05-21 10:15:57 +00:00
|
|
|
}*/
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_ASSERT (pro->hio, pro->pfd != HIO_SYSHND_INVALID); /* use this assertion to check if my claim above is right */
|
2020-05-19 09:11:39 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (HIO_UNLIKELY(*len <= 0))
|
2020-05-18 08:59:25 +00:00
|
|
|
{
|
|
|
|
/* this is an EOF indicator */
|
2021-07-22 07:30:20 +00:00
|
|
|
/* It isn't appropriate to call hio_dev_halt(pro) or hio_dev_pro_close(pro->master, HIO_DEV_PRO_IN)
|
2020-05-21 10:15:57 +00:00
|
|
|
* as those functions destroy the device itself */
|
2021-07-22 07:30:20 +00:00
|
|
|
if (HIO_LIKELY(pro->pfd != HIO_SYSHND_INVALID))
|
2020-05-19 09:11:39 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_watch (dev, HIO_DEV_WATCH_STOP, 0);
|
2020-05-19 09:11:39 +00:00
|
|
|
close (pro->pfd);
|
2021-07-22 07:30:20 +00:00
|
|
|
pro->pfd = HIO_SYSHND_INVALID;
|
2020-05-19 09:11:39 +00:00
|
|
|
}
|
2020-05-21 10:15:57 +00:00
|
|
|
return 1; /* indicate that the operation got successful. the core will execute on_write() with the write length of 0. */
|
2020-05-18 08:59:25 +00:00
|
|
|
}
|
|
|
|
|
2020-02-22 18:24:49 +00:00
|
|
|
x = write(pro->pfd, data, *len);
|
2018-12-12 13:15:54 +00:00
|
|
|
if (x <= -1)
|
|
|
|
{
|
|
|
|
if (errno == EINPROGRESS || errno == EWOULDBLOCK || errno == EAGAIN) return 0; /* no data can be written */
|
|
|
|
if (errno == EINTR) return 0;
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrwithsyserr (pro->hio, 0, errno);
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*len = x;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int dev_pro_writev_slave (hio_dev_t* dev, const hio_iovec_t* iov, hio_iolen_t* iovcnt, const hio_devaddr_t* dstaddr)
|
2020-02-22 18:24:49 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_slave_t* pro = (hio_dev_pro_slave_t*)dev;
|
2020-02-22 18:24:49 +00:00
|
|
|
ssize_t x;
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
/* this check is not needed because HIO_DEV_CAP_OUT_CLOSED is set on the device by the core
|
2020-05-21 10:15:57 +00:00
|
|
|
* when EOF indication is successful(return value 1 and *iovcnt 0).
|
2023-01-11 14:59:41 +00:00
|
|
|
* If HIO_DEV_CAP_OUT_CLOSED, the core doesn't invoke the write method
|
2021-07-22 07:30:20 +00:00
|
|
|
if (HIO_UNLIKELY(pro->pfd == HIO_SYSHND_INVALID))
|
2020-05-19 09:11:39 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (pro->hio, HIO_EBADHND);
|
2020-05-19 09:11:39 +00:00
|
|
|
return -1;
|
2020-05-21 10:15:57 +00:00
|
|
|
}*/
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_ASSERT (pro->hio, pro->pfd != HIO_SYSHND_INVALID); /* use this assertion to check if my claim above is right */
|
2020-05-19 09:11:39 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (HIO_UNLIKELY(*iovcnt <= 0))
|
2020-05-18 08:59:25 +00:00
|
|
|
{
|
|
|
|
/* this is an EOF indicator */
|
2021-07-22 07:30:20 +00:00
|
|
|
/* It isn't appropriate to call hio_dev_halt(pro) or hio_dev_pro_close(pro->master, HIO_DEV_PRO_IN)
|
2020-05-21 10:15:57 +00:00
|
|
|
* as those functions destroy the device itself */
|
2021-07-22 07:30:20 +00:00
|
|
|
if (HIO_LIKELY(pro->pfd != HIO_SYSHND_INVALID))
|
2020-05-19 09:11:39 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_watch (dev, HIO_DEV_WATCH_STOP, 0);
|
2020-05-19 09:11:39 +00:00
|
|
|
close (pro->pfd);
|
2021-07-22 07:30:20 +00:00
|
|
|
pro->pfd = HIO_SYSHND_INVALID;
|
2020-05-19 09:11:39 +00:00
|
|
|
}
|
|
|
|
return 1; /* indicate that the operation got successful. the core will execute on_write() with 0. */
|
2020-05-18 08:59:25 +00:00
|
|
|
}
|
|
|
|
|
2020-02-22 18:24:49 +00:00
|
|
|
x = writev(pro->pfd, iov, *iovcnt);
|
|
|
|
if (x <= -1)
|
|
|
|
{
|
|
|
|
if (errno == EINPROGRESS || errno == EWOULDBLOCK || errno == EAGAIN) return 0; /* no data can be written */
|
|
|
|
if (errno == EINTR) return 0;
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrwithsyserr (pro->hio, 0, errno);
|
2020-02-22 18:24:49 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*iovcnt = x;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static hio_syshnd_t dev_pro_getsyshnd (hio_dev_t* dev)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
return HIO_SYSHND_INVALID;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static hio_syshnd_t dev_pro_getsyshnd_slave (hio_dev_t* dev)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_slave_t* pro = (hio_dev_pro_slave_t*)dev;
|
|
|
|
return (hio_syshnd_t)pro->pfd;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int dev_pro_ioctl (hio_dev_t* dev, int cmd, void* arg)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_t* hio = dev->hio;
|
|
|
|
hio_dev_pro_t* rdev = (hio_dev_pro_t*)dev;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
switch (cmd)
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
case HIO_DEV_PRO_CLOSE:
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_sid_t sid = *(hio_dev_pro_sid_t*)arg;
|
2018-12-12 13:15:54 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (sid < HIO_DEV_PRO_IN || sid > HIO_DEV_PRO_ERR)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (hio, HIO_EINVAL);
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rdev->slave[sid])
|
|
|
|
{
|
|
|
|
/* unlike dev_pro_kill_master(), i don't nullify rdev->slave[sid].
|
2023-01-11 14:59:41 +00:00
|
|
|
* so i treat the closing ioctl as if it's a kill request
|
2018-12-12 13:15:54 +00:00
|
|
|
* initiated by the slave device itself. */
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_kill ((hio_dev_t*)rdev->slave[sid]);
|
2020-05-21 10:15:57 +00:00
|
|
|
|
2023-01-11 14:59:41 +00:00
|
|
|
/* if this is the last slave, the master is destroyed as well.
|
2020-05-21 10:15:57 +00:00
|
|
|
* therefore, using rdev is unsafe in the assertion below is unsafe.
|
2021-07-22 07:30:20 +00:00
|
|
|
*HIO_ASSERT (hio, rdev->slave[sid] == HIO_NULL); */
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
2020-05-21 10:15:57 +00:00
|
|
|
|
2018-12-12 13:15:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
case HIO_DEV_PRO_KILL_CHILD:
|
2018-12-12 13:15:54 +00:00
|
|
|
if (rdev->child_pid >= 0)
|
|
|
|
{
|
2020-05-16 19:12:10 +00:00
|
|
|
if (kill(rdev->child_pid, SIGKILL) == -1)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrwithsyserr (hio, 0, errno);
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (hio, HIO_EINVAL);
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-11 14:59:41 +00:00
|
|
|
static hio_dev_mth_t dev_pro_methods =
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
dev_pro_make_master,
|
|
|
|
dev_pro_kill_master,
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_NULL,
|
2018-12-12 13:15:54 +00:00
|
|
|
dev_pro_getsyshnd,
|
2021-07-26 15:19:31 +00:00
|
|
|
HIO_NULL,
|
2021-08-08 07:37:33 +00:00
|
|
|
dev_pro_ioctl,
|
2018-12-12 13:15:54 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_NULL, /* read */
|
|
|
|
HIO_NULL, /* write */
|
|
|
|
HIO_NULL, /* writev */
|
|
|
|
HIO_NULL, /* sendfile */
|
2018-12-12 13:15:54 +00:00
|
|
|
};
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static hio_dev_mth_t dev_pro_methods_slave =
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
dev_pro_make_slave,
|
|
|
|
dev_pro_kill_slave,
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_NULL,
|
2018-12-12 13:15:54 +00:00
|
|
|
dev_pro_getsyshnd_slave,
|
2021-07-26 15:19:31 +00:00
|
|
|
HIO_NULL,
|
2021-08-08 07:37:33 +00:00
|
|
|
dev_pro_ioctl,
|
2018-12-12 13:15:54 +00:00
|
|
|
|
|
|
|
dev_pro_read_slave,
|
|
|
|
dev_pro_write_slave,
|
2020-02-22 18:24:49 +00:00
|
|
|
dev_pro_writev_slave,
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_NULL, /* sendfile */
|
2018-12-12 13:15:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ========================================================================= */
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int pro_ready (hio_dev_t* dev, int events)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
/* virtual device. no I/O */
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (dev->hio, HIO_EINTERN);
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int pro_on_read (hio_dev_t* dev, const void* data, hio_iolen_t len, const hio_devaddr_t* srcaddr)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
/* virtual device. no I/O */
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (dev->hio, HIO_EINTERN);
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int pro_on_write (hio_dev_t* dev, hio_iolen_t wrlen, void* wrctx, const hio_devaddr_t* dstaddr)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
/* virtual device. no I/O */
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (dev->hio, HIO_EINTERN);
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static hio_dev_evcb_t dev_pro_event_callbacks =
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
pro_ready,
|
|
|
|
pro_on_read,
|
|
|
|
pro_on_write
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ========================================================================= */
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int pro_ready_slave (hio_dev_t* dev, int events)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_t* hio = dev->hio;
|
|
|
|
/*hio_dev_pro_t* pro = (hio_dev_pro_t*)dev;*/
|
2018-12-12 13:15:54 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (events & HIO_DEV_EVENT_ERR)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (hio, HIO_EDEVERR);
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
if (events & HIO_DEV_EVENT_HUP)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2023-01-11 14:59:41 +00:00
|
|
|
if (events & (HIO_DEV_EVENT_PRI | HIO_DEV_EVENT_IN | HIO_DEV_EVENT_OUT))
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
/* probably half-open? */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (hio, HIO_EDEVHUP);
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1; /* the device is ok. carry on reading or writing */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int pro_on_read_slave_out (hio_dev_t* dev, const void* data, hio_iolen_t len, const hio_devaddr_t* srcaddr)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_slave_t* pro = (hio_dev_pro_slave_t*)dev;
|
|
|
|
return pro->master->on_read(pro->master, HIO_DEV_PRO_OUT, data, len);
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int pro_on_read_slave_err (hio_dev_t* dev, const void* data, hio_iolen_t len, const hio_devaddr_t* srcaddr)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_slave_t* pro = (hio_dev_pro_slave_t*)dev;
|
|
|
|
return pro->master->on_read(pro->master, HIO_DEV_PRO_ERR, data, len);
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static int pro_on_write_slave (hio_dev_t* dev, hio_iolen_t wrlen, void* wrctx, const hio_devaddr_t* dstaddr)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_slave_t* pro = (hio_dev_pro_slave_t*)dev;
|
2019-01-28 08:13:06 +00:00
|
|
|
return pro->master->on_write(pro->master, wrlen, wrctx);
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static hio_dev_evcb_t dev_pro_event_callbacks_slave_in =
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
pro_ready_slave,
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_NULL,
|
2018-12-12 13:15:54 +00:00
|
|
|
pro_on_write_slave
|
|
|
|
};
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static hio_dev_evcb_t dev_pro_event_callbacks_slave_out =
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
pro_ready_slave,
|
|
|
|
pro_on_read_slave_out,
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_NULL
|
2018-12-12 13:15:54 +00:00
|
|
|
};
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static hio_dev_evcb_t dev_pro_event_callbacks_slave_err =
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
pro_ready_slave,
|
|
|
|
pro_on_read_slave_err,
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_NULL
|
2018-12-12 13:15:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ========================================================================= */
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
static hio_dev_pro_slave_t* make_slave (hio_t* hio, slave_info_t* si)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
switch (si->id)
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
case HIO_DEV_PRO_IN:
|
|
|
|
return (hio_dev_pro_slave_t*)hio_dev_make(
|
2023-01-11 14:59:41 +00:00
|
|
|
hio, HIO_SIZEOF(hio_dev_pro_t),
|
2018-12-12 13:15:54 +00:00
|
|
|
&dev_pro_methods_slave, &dev_pro_event_callbacks_slave_in, si);
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
case HIO_DEV_PRO_OUT:
|
|
|
|
return (hio_dev_pro_slave_t*)hio_dev_make(
|
2023-01-11 14:59:41 +00:00
|
|
|
hio, HIO_SIZEOF(hio_dev_pro_t),
|
2018-12-12 13:15:54 +00:00
|
|
|
&dev_pro_methods_slave, &dev_pro_event_callbacks_slave_out, si);
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
case HIO_DEV_PRO_ERR:
|
|
|
|
return (hio_dev_pro_slave_t*)hio_dev_make(
|
2023-01-11 14:59:41 +00:00
|
|
|
hio, HIO_SIZEOF(hio_dev_pro_t),
|
2018-12-12 13:15:54 +00:00
|
|
|
&dev_pro_methods_slave, &dev_pro_event_callbacks_slave_err, si);
|
|
|
|
|
|
|
|
default:
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (hio, HIO_EINVAL);
|
|
|
|
return HIO_NULL;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_t* hio_dev_pro_make (hio_t* hio, hio_oow_t xtnsize, const hio_dev_pro_make_t* info)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
return (hio_dev_pro_t*)hio_dev_make(
|
2023-01-11 14:59:41 +00:00
|
|
|
hio, HIO_SIZEOF(hio_dev_pro_t) + xtnsize,
|
2018-12-12 13:15:54 +00:00
|
|
|
&dev_pro_methods, &dev_pro_event_callbacks, (void*)info);
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
void hio_dev_pro_kill (hio_dev_pro_t* dev)
|
2019-02-13 10:41:33 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_kill ((hio_dev_t*)dev);
|
2019-02-13 10:41:33 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
void hio_dev_pro_halt (hio_dev_pro_t* dev)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_halt ((hio_dev_t*)dev);
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
int hio_dev_pro_read (hio_dev_pro_t* dev, hio_dev_pro_sid_t sid, int enabled)
|
2019-01-31 09:16:44 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_t* hio = dev->hio;
|
2019-01-31 09:16:44 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_ASSERT (hio, sid == HIO_DEV_PRO_OUT || sid == HIO_DEV_PRO_ERR);
|
2019-01-31 09:16:44 +00:00
|
|
|
|
|
|
|
if (dev->slave[sid])
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
return hio_dev_read((hio_dev_t*)dev->slave[sid], enabled);
|
2019-01-31 09:16:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (dev->hio, HIO_ENOCAPA); /* TODO: is it the right error number? */
|
2019-01-31 09:16:44 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
int hio_dev_pro_timedread (hio_dev_pro_t* dev, hio_dev_pro_sid_t sid, int enabled, const hio_ntime_t* tmout)
|
2019-01-31 09:16:44 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_t* hio = dev->hio;
|
2019-01-31 09:16:44 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_ASSERT (hio, sid == HIO_DEV_PRO_OUT || sid == HIO_DEV_PRO_ERR);
|
2019-01-31 09:16:44 +00:00
|
|
|
|
|
|
|
if (dev->slave[sid])
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
return hio_dev_timedread((hio_dev_t*)dev->slave[sid], enabled, tmout);
|
2019-01-31 09:16:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (hio, HIO_ENOCAPA); /* TODO: is it the right error number? */
|
2019-01-31 09:16:44 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2020-05-21 10:15:57 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
int hio_dev_pro_write (hio_dev_pro_t* dev, const void* data, hio_iolen_t dlen, void* wrctx)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
if (dev->slave[HIO_DEV_PRO_IN])
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
return hio_dev_write((hio_dev_t*)dev->slave[HIO_DEV_PRO_IN], data, dlen, wrctx, HIO_NULL);
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (dev->hio, HIO_ENOCAPA); /* TODO: is it the right error number? */
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
int hio_dev_pro_timedwrite (hio_dev_pro_t* dev, const void* data, hio_iolen_t dlen, const hio_ntime_t* tmout, void* wrctx)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
if (dev->slave[HIO_DEV_PRO_IN])
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
return hio_dev_timedwrite((hio_dev_t*)dev->slave[HIO_DEV_PRO_IN], data, dlen, tmout, wrctx, HIO_NULL);
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_seterrnum (dev->hio, HIO_ENOCAPA); /* TODO: is it the right error number? */
|
2018-12-12 13:15:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
int hio_dev_pro_close (hio_dev_pro_t* dev, hio_dev_pro_sid_t sid)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
return hio_dev_ioctl((hio_dev_t*)dev, HIO_DEV_PRO_CLOSE, &sid);
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
int hio_dev_pro_killchild (hio_dev_pro_t* dev)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
return hio_dev_ioctl((hio_dev_t*)dev, HIO_DEV_PRO_KILL_CHILD, HIO_NULL);
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_pro_t* hio_dev_pro_getdev (hio_dev_pro_t* pro, hio_dev_pro_sid_t sid)
|
2018-12-12 13:15:54 +00:00
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
case HIO_DEV_PRO_IN:
|
2018-12-12 13:15:54 +00:00
|
|
|
return XXX;
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
case HIO_DEV_PRO_OUT:
|
2018-12-12 13:15:54 +00:00
|
|
|
return XXX;
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
case HIO_DEV_PRO_ERR:
|
2018-12-12 13:15:54 +00:00
|
|
|
return XXX;
|
|
|
|
}
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
pro->dev->hio = HIO_EINVAL;
|
|
|
|
return HIO_NULL;
|
2018-12-12 13:15:54 +00:00
|
|
|
}
|
|
|
|
#endif
|