From ee13240e60a02836426140d384e363be5d8f8bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Fri, 8 Nov 2019 18:09:56 +0400 Subject: osdep: add qemu_unlink() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Daniel P. Berrangé --- util/osdep.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'util/osdep.c') diff --git a/util/osdep.c b/util/osdep.c index 3f04326..f7d0605 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -371,6 +371,21 @@ int qemu_close(int 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. * * Return the number of bytes transferred. -- cgit v1.1