pc-dimm: move actual plug/unplug of a memory region to MemoryDevice
[qemu/ar7.git] / include / io / channel-file.h
blobebfe54ec70febc0d0a864f56769ee975b1b2cf59
1 /*
2 * QEMU I/O channels files driver
4 * Copyright (c) 2015 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #ifndef QIO_CHANNEL_FILE_H
22 #define QIO_CHANNEL_FILE_H
24 #include "io/channel.h"
26 #define TYPE_QIO_CHANNEL_FILE "qio-channel-file"
27 #define QIO_CHANNEL_FILE(obj) \
28 OBJECT_CHECK(QIOChannelFile, (obj), TYPE_QIO_CHANNEL_FILE)
30 typedef struct QIOChannelFile QIOChannelFile;
32 /**
33 * QIOChannelFile:
35 * The QIOChannelFile object provides a channel implementation
36 * that is able to perform I/O on block devices, character
37 * devices, FIFOs, pipes and plain files. While it is technically
38 * able to work on sockets too on the UNIX platform, this is not
39 * portable to Windows and lacks some extra sockets specific
40 * functionality. So the QIOChannelSocket object is recommended
41 * for that use case.
45 struct QIOChannelFile {
46 QIOChannel parent;
47 int fd;
51 /**
52 * qio_channel_file_new_fd:
53 * @fd: the file descriptor
55 * Create a new IO channel object for a file represented
56 * by the @fd parameter. @fd can be associated with a
57 * block device, character device, fifo, pipe, or a
58 * regular file. For sockets, the QIOChannelSocket class
59 * should be used instead, as this provides greater
60 * functionality and cross platform portability.
62 * The channel will own the passed in file descriptor
63 * and will take responsibility for closing it, so the
64 * caller must not close it. If appropriate the caller
65 * should dup() its FD before opening the channel.
67 * Returns: the new channel object
69 QIOChannelFile *
70 qio_channel_file_new_fd(int fd);
72 /**
73 * qio_channel_file_new_path:
74 * @path: the file path
75 * @flags: the open flags (O_RDONLY|O_WRONLY|O_RDWR, etc)
76 * @mode: the file creation mode if O_CREAT is set in @flags
77 * @errp: pointer to initialized error object
79 * Create a new IO channel object for a file represented
80 * by the @path parameter. @path can point to any
81 * type of file on which sequential I/O can be
82 * performed, whether it be a plain file, character
83 * device or block device.
85 * Returns: the new channel object
87 QIOChannelFile *
88 qio_channel_file_new_path(const char *path,
89 int flags,
90 mode_t mode,
91 Error **errp);
93 #endif /* QIO_CHANNEL_FILE_H */