ioc = QIO_CHANNEL_FILE(object_new(TYPE_QIO_CHANNEL_FILE));
- if (flags & O_WRONLY) {
- ioc->fd = open(path, flags, mode);
- } else {
- ioc->fd = open(path, flags);
- }
+ ioc->fd = qemu_open(path, flags, mode);
if (ioc->fd < 0) {
object_unref(OBJECT(ioc));
error_setg_errno(errp, errno,
{
QIOChannelFile *ioc = QIO_CHANNEL_FILE(obj);
if (ioc->fd != -1) {
- close(ioc->fd);
+ qemu_close(ioc->fd);
ioc->fd = -1;
}
}
{
QIOChannelFile *fioc = QIO_CHANNEL_FILE(ioc);
- if (close(fioc->fd) < 0) {
+ if (qemu_close(fioc->fd) < 0) {
error_setg_errno(errp, errno,
"Unable to close file");
return -1;
}
+ fioc->fd = -1;
return 0;
}