build: rename files.h to virfile.h

In preparation for a future patch adding new virFile APIs.

* src/util/files.h, src/util/files.c: Move...
* src/util/virfile.h, src/util/virfile.c: ...here, and rename
functions to virFile prefix.  Macro names are intentionally
left alone.
* *.c: All '#include "files.h"' uses changed.
* src/Makefile.am (UTIL_SOURCES): Reflect rename.
* cfg.mk (exclude_file_name_regexp--sc_prohibit_close): Likewise.
* src/libvirt_private.syms: Likewise.
* docs/hacking.html.in: Likewise.
* HACKING: Regenerate.
This commit is contained in:
Eric Blake 2011-07-19 12:32:58 -06:00
parent 5d804ffae4
commit 8e22e08935
86 changed files with 103 additions and 103 deletions

View File

@ -417,7 +417,7 @@ File handling
Usage of the "fdopen()", "close()", "fclose()" APIs is deprecated in libvirt
code base to help avoiding double-closing of files or file descriptors, which
is particulary dangerous in a multi-threaded applications. Instead of these
APIs, use the macros from files.h
APIs, use the macros from virfile.h
- Open a file from a file descriptor:

2
cfg.mk
View File

@ -689,7 +689,7 @@ exclude_file_name_regexp--sc_prohibit_asprintf = \
^(bootstrap.conf$$|src/util/util\.c$$|examples/domain-events/events-c/event-test\.c$$)
exclude_file_name_regexp--sc_prohibit_close = \
(\.p[yl]$$|^docs/|^(src/util/files\.c|src/libvirt\.c)$$)
(\.p[yl]$$|^docs/|^(src/util/virfile\.c|src/libvirt\.c)$$)
exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = \
(^tests/qemuhelpdata/|\.(gif|ico|png)$$)

View File

@ -34,7 +34,7 @@
#include "libvirt_internal.h"
#include "virterror_internal.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_QEMU

View File

@ -506,7 +506,7 @@
Usage of the <code>fdopen()</code>, <code>close()</code>, <code>fclose()</code>
APIs is deprecated in libvirt code base to help avoiding double-closing of files
or file descriptors, which is particulary dangerous in a multi-threaded
applications. Instead of these APIs, use the macros from files.h
applications. Instead of these APIs, use the macros from virfile.h
</p>
<ul>

View File

@ -52,7 +52,6 @@ UTIL_SOURCES = \
util/cgroup.c util/cgroup.h \
util/event.c util/event.h \
util/event_poll.c util/event_poll.h \
util/files.c util/files.h \
util/hash.c util/hash.h \
util/hooks.c util/hooks.h \
util/iptables.c util/iptables.h \
@ -80,6 +79,7 @@ UTIL_SOURCES = \
util/uuid.c util/uuid.h \
util/util.c util/util.h \
util/viraudit.c util/viraudit.h \
util/virfile.c util/virfile.h \
util/xml.c util/xml.h \
util/virterror.c util/virterror_internal.h \
util/virkeycode.c util/virkeycode.h \

View File

@ -46,7 +46,7 @@
#include "nwfilter_conf.h"
#include "ignore-value.h"
#include "storage_file.h"
#include "files.h"
#include "virfile.h"
#include "bitmap.h"
#include "count-one-bits.h"

View File

@ -41,7 +41,7 @@
#include "util.h"
#include "buf.h"
#include "c-ctype.h"
#include "files.h"
#include "virfile.h"
#define MAX_BRIDGE_ID 256
#define VIR_FROM_THIS VIR_FROM_NETWORK

View File

@ -46,7 +46,7 @@
#include "nwfilter_conf.h"
#include "domain_conf.h"
#include "c-ctype.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_NWFILTER

View File

@ -43,7 +43,7 @@
#include "buf.h"
#include "util.h"
#include "memory.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE

View File

@ -35,7 +35,7 @@
#include "xml.h"
#include "virterror_internal.h"
#include "uuid.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE

View File

@ -38,7 +38,7 @@
#include "logging.h"
#include "memory.h"
#include "util.h"
#include "files.h"
#include "virfile.h"
#include "configmake.h"
#define VIR_FROM_THIS VIR_FROM_STREAMS

View File

@ -493,12 +493,6 @@ virFDStreamOpenFile;
virFDStreamCreateFile;
# files.h
virClose;
virFclose;
virFdopen;
# hash.h
virHashAddEntry;
virHashCreate;
@ -1091,6 +1085,12 @@ virAuditOpen;
virAuditSend;
# virfile.h
virFileClose;
virFileFclose;
virFileFdopen;
# virterror_internal.h
virDispatchError;
virErrorMsg;

View File

@ -34,7 +34,7 @@
#include "logging.h"
#include "virterror_internal.h"
#include "datatypes.h"
#include "files.h"
#include "virfile.h"
#include "memory.h"
#include "uuid.h"
#include "capabilities.h"

View File

@ -36,7 +36,7 @@
#include "virterror_internal.h"
#include "conf.h"
#include "datatypes.h"
#include "files.h"
#include "virfile.h"
#include "memory.h"
#include "uuid.h"
#include "command.h"

View File

@ -41,7 +41,7 @@
#include "virterror_internal.h"
#include "memory.h"
#include "util.h"
#include "files.h"
#include "virfile.h"
#include "md5.h"
#include "conf.h"

View File

@ -53,7 +53,7 @@
#include "memory.h"
#include "veth.h"
#include "uuid.h"
#include "files.h"
#include "virfile.h"
#include "command.h"
#define VIR_FROM_THIS VIR_FROM_LXC

View File

@ -53,7 +53,7 @@
#include "veth.h"
#include "memory.h"
#include "util.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_LXC

View File

@ -49,7 +49,7 @@
#include "uuid.h"
#include "stats_linux.h"
#include "hooks.h"
#include "files.h"
#include "virfile.h"
#include "fdstream.h"
#include "domain_audit.h"
#include "domain_nwfilter.h"

View File

@ -31,7 +31,7 @@
#include "virterror_internal.h"
#include "memory.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#include <dirent.h>
#define VIR_FROM_THIS VIR_FROM_NODEDEV

View File

@ -45,7 +45,7 @@
#include "virterror_internal.h"
#include "count-one-bits.h"
#include "intprops.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_NONE

View File

@ -38,7 +38,7 @@
#include "nwfilter_conf.h"
#include "nwfilter_gentech_driver.h"
#include "nwfilter_ebiptables_driver.h"
#include "files.h"
#include "virfile.h"
#include "command.h"

View File

@ -50,7 +50,7 @@
#include "memory.h"
#include "util.h"
#include "nodeinfo.h"
#include "files.h"
#include "virfile.h"
#include "command.h"
#include "ignore-value.h"

View File

@ -55,7 +55,7 @@
#include "nodeinfo.h"
#include "memory.h"
#include "bridge.h"
#include "files.h"
#include "virfile.h"
#include "logging.h"
#include "command.h"

View File

@ -57,7 +57,7 @@
#include "domain_conf.h"
#include "storage_conf.h"
#include "nodeinfo.h"
#include "files.h"
#include "virfile.h"
#include "interface_conf.h"
#include "phyp_driver.h"

View File

@ -28,7 +28,7 @@
#include "logging.h"
#include "virterror_internal.h"
#include "util.h"
#include "files.h"
#include "virfile.h"
#include "nodeinfo.h"
#include "cpu/cpu.h"
#include "domain_conf.h"

View File

@ -31,7 +31,7 @@
#include "logging.h"
#include "virterror_internal.h"
#include "util.h"
#include "files.h"
#include "virfile.h"
#include "uuid.h"
#include "c-ctype.h"
#include "domain_nwfilter.h"

View File

@ -55,7 +55,7 @@
#include "macvtap.h"
#include "cpu/cpu.h"
#include "domain_nwfilter.h"
#include "files.h"
#include "virfile.h"
#include "configmake.h"
#define VIR_FROM_THIS VIR_FROM_QEMU

View File

@ -33,7 +33,7 @@
#include "cpu/cpu.h"
#include "ignore-value.h"
#include "uuid.h"
#include "files.h"
#include "virfile.h"
#include <sys/time.h>
#include <fcntl.h>

View File

@ -82,7 +82,7 @@
#include "domain_nwfilter.h"
#include "hooks.h"
#include "storage_file.h"
#include "files.h"
#include "virfile.h"
#include "fdstream.h"
#include "configmake.h"
#include "threadpool.h"

View File

@ -36,7 +36,7 @@
#include "virterror_internal.h"
#include "memory.h"
#include "pci.h"
#include "files.h"
#include "virfile.h"
#include "qemu_cgroup.h"
#include "locking/domain_lock.h"

View File

@ -37,7 +37,7 @@
#include "virterror_internal.h"
#include "memory.h"
#include "util.h"
#include "files.h"
#include "virfile.h"
#include "datatypes.h"
#include "fdstream.h"
#include "uuid.h"

View File

@ -35,7 +35,7 @@
#include "virterror_internal.h"
#include "memory.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_QEMU

View File

@ -48,7 +48,7 @@
#include "virterror_internal.h"
#include "memory.h"
#include "hooks.h"
#include "files.h"
#include "virfile.h"
#include "util.h"
#include "c-ctype.h"
#include "nodeinfo.h"

View File

@ -43,7 +43,7 @@
#include "qemu_protocol.h"
#include "memory.h"
#include "util.h"
#include "files.h"
#include "virfile.h"
#include "command.h"
#include "intprops.h"

View File

@ -31,7 +31,7 @@
#include "virnetsocket.h"
#include "memory.h"
#include "threads.h"
#include "files.h"
#include "virfile.h"
#include "logging.h"
#include "util.h"
#include "virterror_internal.h"

View File

@ -34,7 +34,7 @@
#include "threads.h"
#include "threadpool.h"
#include "util.h"
#include "files.h"
#include "virfile.h"
#include "event.h"
#if HAVE_AVAHI
# include "virnetservermdns.h"

View File

@ -38,7 +38,7 @@
#include "memory.h"
#include "virterror_internal.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#include "event.h"
#include "threads.h"

View File

@ -40,7 +40,7 @@
#include "util.h"
#include "uuid.h"
#include "virterror_internal.h"
#include "files.h"
#include "virfile.h"
#include "configmake.h"
#define VIR_FROM_THIS VIR_FROM_SECRET

View File

@ -35,7 +35,7 @@
#include "uuid.h"
#include "pci.h"
#include "hostusb.h"
#include "files.h"
#include "virfile.h"
#include "configmake.h"
#include "command.h"

View File

@ -31,7 +31,7 @@
#include "pci.h"
#include "hostusb.h"
#include "storage_file.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_SECURITY

View File

@ -40,7 +40,7 @@
#include "uuid.h"
#include "hostusb.h"
#include "pci.h"
#include "files.h"
#include "virfile.h"
#include "configmake.h"
#define VIR_FROM_THIS VIR_FROM_SECURITY

View File

@ -56,7 +56,7 @@
#include "storage_file.h"
#include "storage_backend.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#include "command.h"
#if WITH_STORAGE_LVM

View File

@ -44,7 +44,7 @@
#include "command.h"
#include "memory.h"
#include "xml.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE

View File

@ -41,7 +41,7 @@
#include "util.h"
#include "memory.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#include "command.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE

View File

@ -37,7 +37,7 @@
#include "command.h"
#include "memory.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE

View File

@ -35,7 +35,7 @@
#include "storage_backend.h"
#include "memory.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE

View File

@ -32,7 +32,7 @@
#include "storage_backend_scsi.h"
#include "memory.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#include "command.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE

View File

@ -45,7 +45,7 @@
#include "memory.h"
#include "storage_backend.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#include "fdstream.h"
#include "configmake.h"

View File

@ -49,7 +49,7 @@
#include "xml.h"
#include "threads.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_TEST

View File

@ -47,7 +47,7 @@
#include "bridge.h"
#include "logging.h"
#include "domain_nwfilter.h"
#include "files.h"
#include "virfile.h"
#include "command.h"
#define VIR_FROM_THIS VIR_FROM_UML

View File

@ -59,7 +59,7 @@
#include "datatypes.h"
#include "logging.h"
#include "domain_nwfilter.h"
#include "files.h"
#include "virfile.h"
#include "fdstream.h"
#include "configmake.h"

View File

@ -24,7 +24,7 @@
#if defined(WITH_BRIDGE)
# include "bridge.h"
# include "files.h"
# include "virfile.h"
# include <stdlib.h>
# include <stdio.h>

View File

@ -31,7 +31,7 @@
#include "memory.h"
#include "cgroup.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#include "hash.h"
#define CGROUP_MAX_VAL 512

View File

@ -38,7 +38,7 @@
#include "virterror_internal.h"
#include "util.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#include "buf.h"
#include "ignore-value.h"
#include "verify.h"

View File

@ -24,7 +24,7 @@
#include "util.h"
#include "c-ctype.h"
#include "memory.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_CONF

View File

@ -44,7 +44,7 @@
#include "memory.h"
#include "virterror_internal.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_NETWORK
#define DNSMASQ_HOSTSFILE_SUFFIX "hostsfile"

View File

@ -36,7 +36,7 @@
#include "event_poll.h"
#include "memory.h"
#include "util.h"
#include "files.h"
#include "virfile.h"
#include "ignore-value.h"
#include "virterror_internal.h"

View File

@ -35,7 +35,7 @@
#include "util.h"
#include "logging.h"
#include "memory.h"
#include "files.h"
#include "virfile.h"
#include "configmake.h"
#include "command.h"

View File

@ -41,7 +41,7 @@
#include "util.h"
#include "interface.h"
#include "virterror_internal.h"
#include "files.h"
#include "virfile.h"
#include "memory.h"
#include "netlink.h"

View File

@ -35,7 +35,7 @@
#include "util.h"
#include "threads.h"
#include "files.h"
#include "virfile.h"
#include "memory.h"
#include "virterror_internal.h"
#include "configmake.h"

View File

@ -42,7 +42,7 @@
#include "util.h"
#include "buf.h"
#include "threads.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_NONE

View File

@ -64,7 +64,7 @@ VIR_ENUM_IMPL(virMacvtapMode, VIR_MACVTAP_MODE_LAST,
# include "interface.h"
# include "virterror_internal.h"
# include "uuid.h"
# include "files.h"
# include "virfile.h"
# include "netlink.h"
# define VIR_FROM_THIS VIR_FROM_NET

View File

@ -37,7 +37,7 @@
#include "memory.h"
#include "command.h"
#include "virterror_internal.h"
#include "files.h"
#include "virfile.h"
/* avoid compilation breakage on some systems */
#ifndef MODPROBE

View File

@ -25,7 +25,7 @@
# include "util.h"
# include "stats_linux.h"
# include "memory.h"
# include "files.h"
# include "virfile.h"
# define VIR_FROM_THIS VIR_FROM_STATS_LINUX

View File

@ -37,7 +37,7 @@
#include "memory.h"
#include "virterror_internal.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE

View File

@ -73,7 +73,7 @@
#include "memory.h"
#include "threads.h"
#include "verify.h"
#include "files.h"
#include "virfile.h"
#include "command.h"
#include "nonblocking.h"
#include "passfd.h"

View File

@ -39,7 +39,7 @@
#include "virterror_internal.h"
#include "logging.h"
#include "memory.h"
#include "files.h"
#include "virfile.h"
#ifndef ENODATA
# define ENODATA EIO

View File

@ -31,7 +31,7 @@
#include "logging.h"
#include "viraudit.h"
#include "util.h"
#include "files.h"
#include "virfile.h"
#include "memory.h"
/* Provide the macros in case the header file is old.

View File

@ -1,5 +1,5 @@
/*
* files.c: safer file handling
* virfile.c: safer file handling
*
* Copyright (C) 2010-2011 Red Hat, Inc.
* Copyright (C) 2010 IBM Corporation
@ -26,9 +26,9 @@
#include <unistd.h>
#include "files.h"
#include "virfile.h"
int virClose(int *fdptr, bool preserve_errno)
int virFileClose(int *fdptr, bool preserve_errno)
{
int saved_errno;
int rc = 0;
@ -46,7 +46,7 @@ int virClose(int *fdptr, bool preserve_errno)
}
int virFclose(FILE **file, bool preserve_errno)
int virFileFclose(FILE **file, bool preserve_errno)
{
int saved_errno;
int rc = 0;
@ -64,7 +64,7 @@ int virFclose(FILE **file, bool preserve_errno)
}
FILE *virFdopen(int *fdptr, const char *mode)
FILE *virFileFdopen(int *fdptr, const char *mode)
{
FILE *file = NULL;

View File

@ -1,5 +1,5 @@
/*
* files.h: safer file handling
* virfile.h: safer file handling
*
* Copyright (C) 2010-2011 Red Hat, Inc.
* Copyright (C) 2010 IBM Corporation
@ -33,21 +33,21 @@
/* Don't call these directly - use the macros below */
int virClose(int *fdptr, bool preserve_errno) ATTRIBUTE_RETURN_CHECK;
int virFclose(FILE **file, bool preserve_errno) ATTRIBUTE_RETURN_CHECK;
FILE *virFdopen(int *fdptr, const char *mode) ATTRIBUTE_RETURN_CHECK;
int virFileClose(int *fdptr, bool preserve_errno) ATTRIBUTE_RETURN_CHECK;
int virFileFclose(FILE **file, bool preserve_errno) ATTRIBUTE_RETURN_CHECK;
FILE *virFileFdopen(int *fdptr, const char *mode) ATTRIBUTE_RETURN_CHECK;
/* For use on normal paths; caller must check return value,
and failure sets errno per close. */
# define VIR_CLOSE(FD) virClose(&(FD), false)
# define VIR_FCLOSE(FILE) virFclose(&(FILE), false)
# define VIR_CLOSE(FD) virFileClose(&(FD), false)
# define VIR_FCLOSE(FILE) virFileFclose(&(FILE), false)
/* Wrapper around fdopen that consumes fd on success. */
# define VIR_FDOPEN(FD, MODE) virFdopen(&(FD), MODE)
# define VIR_FDOPEN(FD, MODE) virFileFdopen(&(FD), MODE)
/* For use on cleanup paths; errno is unaffected by close,
and no return value to worry about. */
# define VIR_FORCE_CLOSE(FD) ignore_value(virClose(&(FD), true))
# define VIR_FORCE_FCLOSE(FILE) ignore_value(virFclose(&(FILE), true))
# define VIR_FORCE_CLOSE(FD) ignore_value(virFileClose(&(FD), true))
# define VIR_FORCE_FCLOSE(FILE) ignore_value(virFileFclose(&(FILE), true))
#endif /* __VIR_FILES_H */

View File

@ -54,7 +54,7 @@
#include "logging.h"
#include "vbox_driver.h"
#include "configmake.h"
#include "files.h"
#include "virfile.h"
#include "fdstream.h"
/* This one changes from version to version. */

View File

@ -29,7 +29,7 @@
#include "dirname.h"
#include "memory.h"
#include "nodeinfo.h"
#include "files.h"
#include "virfile.h"
#include "uuid.h"
#include "virterror_internal.h"
#include "vmx.h"

View File

@ -26,7 +26,7 @@
#include "internal.h"
#include "virterror_internal.h"
#include "datatypes.h"
#include "files.h"
#include "virfile.h"
#include "memory.h"
#include "uuid.h"
#include "command.h"

View File

@ -27,7 +27,7 @@
# include "util.h"
# include "block_stats.h"
# include "memory.h"
# include "files.h"
# include "virfile.h"
# define VIR_FROM_THIS VIR_FROM_STATS_LINUX

View File

@ -49,7 +49,7 @@
#include "pci.h"
#include "uuid.h"
#include "fdstream.h"
#include "files.h"
#include "virfile.h"
#include "command.h"
#define VIR_FROM_THIS VIR_FROM_XEN

View File

@ -65,7 +65,7 @@
#include "buf.h"
#include "capabilities.h"
#include "memory.h"
#include "files.h"
#include "virfile.h"
#define VIR_FROM_THIS VIR_FROM_XEN

View File

@ -38,7 +38,7 @@
#include "xend_internal.h"
#include "logging.h"
#include "uuid.h"
#include "files.h"
#include "virfile.h"
#include "xm_internal.h" /* for xenXMDomainConfigParse */

View File

@ -45,7 +45,7 @@
#include "xs_internal.h" /* To extract VNC port & Serial console TTY */
#include "memory.h"
#include "count-one-bits.h"
#include "files.h"
#include "virfile.h"
/* required for cpumap_t */
#include <xen/dom0_ops.h>

View File

@ -29,7 +29,7 @@
#include "internal.h"
#include "util.h"
#include "memory.h"
#include "files.h"
#include "virfile.h"
static int envsort(const void *a, const void *b) {

View File

@ -34,7 +34,7 @@
#include "util.h"
#include "memory.h"
#include "command.h"
#include "files.h"
#include "virfile.h"
#ifdef WIN32

View File

@ -9,7 +9,7 @@
#include "internal.h"
#include "nodeinfo.h"
#include "util.h"
#include "files.h"
#include "virfile.h"
#if ! (defined __linux__ && (defined(__x86_64__) || \
defined(__amd64__) || \

View File

@ -47,7 +47,7 @@
((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \
((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0)
#include "files.h"
#include "virfile.h"
static unsigned int testDebug = -1;
static unsigned int testVerbose = -1;

View File

@ -31,7 +31,7 @@
#include "virterror_internal.h"
#include "memory.h"
#include "logging.h"
#include "files.h"
#include "virfile.h"
#include "rpc/virnetsocket.h"

View File

@ -9,7 +9,7 @@
#include "xml.h"
#include "testutils.h"
#include "xen/xen_hypervisor.h"
#include "files.h"
#include "virfile.h"
static int
testCompareFiles(const char *hostmachine, const char *xml_rel,

View File

@ -39,7 +39,7 @@
# include "console.h"
# include "logging.h"
# include "util.h"
# include "files.h"
# include "virfile.h"
# include "memory.h"
# include "virterror_internal.h"

View File

@ -52,7 +52,7 @@
#include "memory.h"
#include "xml.h"
#include "libvirt/libvirt-qemu.h"
#include "files.h"
#include "virfile.h"
#include "event_poll.h"
#include "configmake.h"
#include "threads.h"