[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 20/25] osdep: add qemu_unlink()
From: |
Marc-André Lureau |
Subject: |
[PATCH v6 20/25] osdep: add qemu_unlink() |
Date: |
Fri, 8 Nov 2019 19:01:18 +0400 |
Add a helper function to match qemu_open() which may return files
under the /dev/fdset prefix. Those shouldn't be removed, since it's
only a qemu namespace.
Signed-off-by: Marc-André Lureau <address@hidden>
---
include/qemu/osdep.h | 1 +
util/osdep.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 0f97d68586..9bd3dcfd13 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -462,6 +462,7 @@ int qemu_mprotect_none(void *addr, size_t size);
int qemu_open(const char *name, int flags, ...);
int qemu_close(int fd);
+int qemu_unlink(const char *name);
#ifndef _WIN32
int qemu_dup(int fd);
#endif
diff --git a/util/osdep.c b/util/osdep.c
index 3f04326040..f7d06050f7 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -370,6 +370,21 @@ int qemu_close(int fd)
return close(fd);
}
+/*
+ * Delete a file from the filesystem, unless the filename is /dev/fdset/...
+ *
+ * Returns: On success, zero is returned. On error, -1 is returned,
+ * and errno is set appropriately.
+ */
+int qemu_unlink(const char *name)
+{
+ if (g_str_has_prefix(name, "/dev/fdset/")) {
+ return 0;
+ }
+
+ return unlink(name);
+}
+
/*
* A variant of write(2) which handles partial write.
*
--
2.24.0
- [PATCH v6 10/25] QmpSession: keep a queue of pending commands, (continued)
- [PATCH v6 10/25] QmpSession: keep a queue of pending commands, Marc-André Lureau, 2019/11/08
- [PATCH v6 11/25] QmpSession: return orderly, Marc-André Lureau, 2019/11/08
- [PATCH v6 12/25] qmp: introduce asynchronous command type, Marc-André Lureau, 2019/11/08
- [PATCH v6 14/25] qmp: add qmp_return_is_cancelled(), Marc-André Lureau, 2019/11/08
- [PATCH v6 13/25] scripts: learn 'async' qapi commands, Marc-André Lureau, 2019/11/08
- [PATCH v6 15/25] console: add graphic_hw_update_done(), Marc-André Lureau, 2019/11/08
- [PATCH v6 16/25] ppm-save: pass opened fd, Marc-André Lureau, 2019/11/08
- [PATCH v6 17/25] ui: add pixman image g_autoptr support, Marc-André Lureau, 2019/11/08
- [PATCH v6 18/25] object: add g_autoptr support, Marc-André Lureau, 2019/11/08
- [PATCH v6 19/25] screendump: replace FILE with QIOChannel and fix close()/qemu_close(), Marc-André Lureau, 2019/11/08
- [PATCH v6 20/25] osdep: add qemu_unlink(),
Marc-André Lureau <=
- [PATCH v6 21/25] screendump: use qemu_unlink(), Marc-André Lureau, 2019/11/08
- [PATCH v6 22/25] console: make screendump asynchronous, Marc-André Lureau, 2019/11/08
- [PATCH v6 23/25] monitor: start making qmp_human_monitor_command() asynchronous, Marc-André Lureau, 2019/11/08
- [PATCH v6 24/25] monitor: teach HMP about asynchronous commands, Marc-André Lureau, 2019/11/08
- [PATCH v6 25/25] hmp: call the asynchronous QMP screendump to fix outdated/glitches, Marc-André Lureau, 2019/11/08