mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
io: Introduce qio_channel_file_new_dupfd
Add a new helper function for creating a QIOChannelFile channel with a duplicated file descriptor. This saves the calling code from having to do error checking on the dup() call. Suggested-by: "Daniel P. Berrangé" <berrange@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: "Daniel P. Berrangé" <berrange@redhat.com> Link: https://lore.kernel.org/r/20240311233335.17299-2-farosas@suse.de Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
parent
35ac6831d9
commit
4760cedc61
2 changed files with 30 additions and 0 deletions
|
@ -68,6 +68,24 @@ struct QIOChannelFile {
|
|||
QIOChannelFile *
|
||||
qio_channel_file_new_fd(int fd);
|
||||
|
||||
/**
|
||||
* qio_channel_file_new_dupfd:
|
||||
* @fd: the file descriptor
|
||||
* @errp: pointer to initialized error object
|
||||
*
|
||||
* Create a new IO channel object for a file represented by the @fd
|
||||
* parameter. Like qio_channel_file_new_fd(), but the @fd is first
|
||||
* duplicated with dup().
|
||||
*
|
||||
* The channel will own the duplicated file descriptor and will take
|
||||
* responsibility for closing it, the original FD is owned by the
|
||||
* caller.
|
||||
*
|
||||
* Returns: the new channel object
|
||||
*/
|
||||
QIOChannelFile *
|
||||
qio_channel_file_new_dupfd(int fd, Error **errp);
|
||||
|
||||
/**
|
||||
* qio_channel_file_new_path:
|
||||
* @path: the file path
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue