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

[Nbd] Transforming stdin and stdout pair into a socket

    Hello all!

    Today I've played around with NBD (Network Block Disk), and
qemu-nbd (a NBD client that exports QEMU disks as NBD's).

    My problem is the following: both NBD kernel module and qemu-nbd
implementation expect to use a socket in order to communicate.
    This means that in order to securely tunnel the connection over
SSH (OpenSSH), I need an intermediary process that creates a socket
and forwards all input / output between this socket and stdin / stdout
(which are in fact pipes received from OpenSSH).

    My question is: can I somehow make the pair of stdin / stdout seem
as a socket to the Linux syscalls (read and write)? (I would have to
make stdin / stdout pair look like a single file descriptor.) (This
would eliminate the intermediate process that just pipes data, and
thus reduce the overhead.)

    Just to be clear: I know how to trick an application to have it's
stdin and stdout be an opened socket (by using dup syscall). But in
this case I need to trick the Linux kernel into thinking that stdin /
stdout pair is a socket (or a single file descriptor).

    Thank you,
    Ciprian Craciun.

Reply to: