diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index ccb04baad..934f582ed 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -15,6 +15,7 @@ barbie BINDIR blkid bmarzins +Bsymbolic cciss CFLAGS cgroups diff --git a/NEWS.md b/NEWS.md index cb0639def..69acda47c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,19 +1,29 @@ # multipath-tools Release Notes -## multipath-tools 0.9.x (in preparation) +## multipath-tools 0.10.0, 2024/08 ### User-Visible Changes -* Add hardware defaults for Huawei storage arrays and XSG1 vendors +* The `multipathd show daemon` command now shows `(reconfigure pending)` + if a reconfiguration has been triggered but not finished yet. ### Other major changes +* Refactored the path checker loop. Paths are now checked for each multipath + map in turn, rather than walking linearly through the list of paths. Paths + for different multipath maps will be checked at different time offsets in + the `polling_interval` time span, which distributes the load caused by + path checking more evenly over time. * Refactored a significant part of the libmultipath / libdevmapper interface. All functions that retrieve information about DM maps have been converted to use just one worker function, libmp_mapinfo(). This reduces code size while providing more flexibility and efficiency (less device-mapper ioctls). Also, cleanup attributes are used consistently in the libdevmapper-related code. -* Made map removal more efficient by avoiding unnecessary recursion. +* Renamed public functions, variables, and macros to comply with the + glibc [policy for reserved names](https://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html). + For backward compatibility reasons, the exported functions from `libmpathcmd` + and `libmpathpersist` that start with double underscore are kept as weak + symbols. Fixes [#91](https://github.com/opensvc/multipath-tools/issues/91). ### Bug fixes @@ -23,17 +33,35 @@ 0.9.9). * Fixed old mpathpersist bug leading to the error message "configured reservation key doesn't match: 0x0" when `reservation_key` was configured in the - multipaths section of `multipath.conf`. + multipaths section of `multipath.conf` + (Fixes [#92](https://github.com/opensvc/multipath-tools/issues/92)). +* Fixed output of `multipath -t` and `multipath -T` for the options + `force_sync` and `retrigger_tries`. + (Fixes [#88](https://github.com/opensvc/multipath-tools/pull/88)) +* Fixed adding maps by WWID in CLI (command `add map $WWID`). ### Other +* Removed hardcoded paths and make them configurable instead. + This should improve compatibility e.g. with NixOS. +* Improved handling of paths with changed WWIDs. +* Improved synchronization between kernel state and multipathd's internal + state. +* Made map removal more efficient by avoiding unnecessary recursion. +* Added hardware defaults for Huawei storage arrays and XSG1 vendors. * Use `-fexceptions` during compilation to make sure cleanup code is executed when threads are cancelled +* Use `weak` attribute for `get_multipath_config()` and + `put_multipath_config()` in order to enable linking with + `-Bsymbolic-non-weak-functions` + (Fixes [#86](https://github.com/opensvc/multipath-tools/pull/86)). * Fixed CI for ARM/v7 -* Remove hardcoded paths and make them configurable instead. - This should improve compatibility e.g. with NixOS. * Fixed directio CI test for real devices, run more "real" tests in CI * Fixed minor issues detected by coverity. +* Fixed a minor bug in the config file parser + (Fixes [#93](https://github.com/opensvc/multipath-tools/pull/93)). +* Minor documentation fixes + (Fixes [#87](https://github.com/opensvc/multipath-tools/pull/87)). ## multipath-tools 0.9.9, 2024/05 @@ -128,8 +156,8 @@ versions earlier than 0.9.9. See "Other major changes" below. had been sent before. * Error messages sent from multipathd to the command line client have been improved. The user will now see messages like "map or partition in use" or - "device not found" instead of just "fail". - + "device not found" instead of just "fail". + ### Other Major Changes * multipathd now tracks the queueing mode of maps in its internal features @@ -144,7 +172,7 @@ versions earlier than 0.9.9. See "Other major changes" below. * A segmentation fault in the 0.9.7 autoresize code has been fixed. * Fixed a bug introduced in 0.9.6 that had caused map reloads being omitted - when path priorities changed. + when path priorities changed. * Fixed compilation with gcc 14. (Fixes [#80](https://github.com/opensvc/multipath-tools/issues/80)) * Minor fixes for issues detected by coverity. * Spelling fixes and other minor fixes. @@ -166,7 +194,7 @@ versions earlier than 0.9.9. See "Other major changes" below. * Added `max_retries` config option to limit SCSI retries. * Added `auto_resize` config option to enable resizing multipath maps automatically. * Added support for handling FPIN-Li events for FC-NVMe. - + ### Other Major Changes * Rework of alias selection code: @@ -219,7 +247,7 @@ and the directio checker (fixes * Fix handling of `dev_loss_tmo` in cases where it wasn't explicitly configured. * Syntax fixes in udev rules (Fixes [#69](https://github.com/opensvc/multipath-tools/pull/69)). - + ### Other * Adapt HITACHI/OPEN- config to work with alua and multibus. @@ -228,7 +256,7 @@ and the directio checker (fixes ## multipath-tools 0.9.5, 2023/04 ### User-Visible Changes - + * Always use directio path checker for Linux TCM (LIO) targets (Fixes [#54](https://github.com/opensvc/multipath-tools/issues/54). * `multipath -u` now checks if path devices are already in use diff --git a/create-config.mk b/create-config.mk index 0abbb3af4..8bd2c20ce 100644 --- a/create-config.mk +++ b/create-config.mk @@ -163,8 +163,8 @@ all: $(TOPDIR)/config.mk $(multipathdir)/autoconfig.h: @echo creating $@ - @echo '#ifndef _AUTOCONFIG_H' >$@ - @echo '#define _AUTOCONFIG_H' >>$@ + @echo '#ifndef AUTOCONFIG_H_INCLUDED' >$@ + @echo '#define AUTOCONFIG_H_INCLUDED' >>$@ @for x in $(DEFINES); do echo "#define $$x" >>$@; done @echo '#endif' >>$@ diff --git a/kpartx/byteorder.h b/kpartx/byteorder.h index 199c66bee..75990a859 100644 --- a/kpartx/byteorder.h +++ b/kpartx/byteorder.h @@ -1,5 +1,5 @@ -#ifndef BYTEORDER_H_INCLUDED -#define BYTEORDER_H_INCLUDED +#ifndef KPARTX_BYTEORDER_H_INCLUDED +#define KPARTX_BYTEORDER_H_INCLUDED #ifdef __linux__ # include @@ -26,4 +26,4 @@ # error unsupported #endif -#endif /* BYTEORDER_H_INCLUDED */ +#endif /* KPARTX_BYTEORDER_H_INCLUDED */ diff --git a/kpartx/crc32.h b/kpartx/crc32.h index a4505b842..abbadbbe6 100644 --- a/kpartx/crc32.h +++ b/kpartx/crc32.h @@ -1,8 +1,8 @@ /* * crc32.h */ -#ifndef _CRC32_H -#define _CRC32_H +#ifndef CRC32_H_INCLUDED +#define CRC32_H_INCLUDED #include #include @@ -16,4 +16,4 @@ extern uint32_t crc32_be(uint32_t crc, unsigned char const *p, size_t len); #define ether_crc_le(length, data) crc32_le(~0, data, length) #define ether_crc(length, data) crc32_be(~0, data, length) -#endif /* _CRC32_H */ +#endif /* CRC32_H_INCLUDED */ diff --git a/kpartx/dasd.h b/kpartx/dasd.h index 8ad5d6202..481ad79ee 100644 --- a/kpartx/dasd.h +++ b/kpartx/dasd.h @@ -22,8 +22,8 @@ * along with this program. If not, see . */ -#ifndef _DASD_H -#define _DASD_H +#ifndef DASD_H_INCLUDED +#define DASD_H_INCLUDED typedef struct ttr { @@ -289,4 +289,4 @@ cchhb2blk (cchhb_t *ptr, struct hd_geometry *geo) ptr->b; } -#endif /* _DASD_H */ +#endif /* DASD_H_INCLUDED */ diff --git a/kpartx/devmapper.c b/kpartx/devmapper.c index bf078388a..d49c6806a 100644 --- a/kpartx/devmapper.c +++ b/kpartx/devmapper.c @@ -13,16 +13,16 @@ #include "devmapper.h" #include "kpartx.h" -#define _UUID_PREFIX "part" -#define UUID_PREFIX _UUID_PREFIX "%d-" -#define _UUID_PREFIX_LEN (sizeof(_UUID_PREFIX) - 1) -#define MAX_PREFIX_LEN (_UUID_PREFIX_LEN + 4) +#define UUID_PREFIX_ "part" +#define UUID_PREFIX UUID_PREFIX_ "%d-" +#define UUID_PREFIX_LEN (sizeof(UUID_PREFIX_) - 1) +#define MAX_PREFIX_LEN (UUID_PREFIX_LEN + 4) #define PARAMS_SIZE 1024 #ifdef LIBDM_API_COOKIE -# define __DM_API_COOKIE_UNUSED__ /* empty */ +# define DM_API_COOKIE_UNUSED__ /* empty */ #else -# define __DM_API_COOKIE_UNUSED__ __attribute__((unused)) +# define DM_API_COOKIE_UNUSED__ __attribute__((unused)) #endif int dm_prereq(char * str, uint32_t x, uint32_t y, uint32_t z) @@ -60,7 +60,7 @@ int dm_prereq(char * str, uint32_t x, uint32_t y, uint32_t z) return r; } -int dm_simplecmd(int task, const char *name, int no_flush, __DM_API_COOKIE_UNUSED__ uint16_t udev_flags) +int dm_simplecmd(int task, const char *name, int no_flush, DM_API_COOKIE_UNUSED__ uint16_t udev_flags) { int r = 0; #ifdef LIBDM_API_COOKIE @@ -496,12 +496,12 @@ dm_compare_uuid(const char *mapuuid, const char *partname) if (!partuuid) return 1; - if (!strncmp(partuuid, _UUID_PREFIX, _UUID_PREFIX_LEN)) { - char *p = partuuid + _UUID_PREFIX_LEN; + if (!strncmp(partuuid, UUID_PREFIX_, UUID_PREFIX_LEN)) { + char *p = partuuid + UUID_PREFIX_LEN; /* skip partition number */ while (isdigit(*p)) p++; - if (p != partuuid + _UUID_PREFIX_LEN && *p == '-' && + if (p != partuuid + UUID_PREFIX_LEN && *p == '-' && !strcmp(mapuuid, p + 1)) r = 0; } diff --git a/kpartx/devmapper.h b/kpartx/devmapper.h index 701bdf6e6..e4db86213 100644 --- a/kpartx/devmapper.h +++ b/kpartx/devmapper.h @@ -1,5 +1,5 @@ -#ifndef _KPARTX_DEVMAPPER_H -#define _KPARTX_DEVMAPPER_H +#ifndef KPARTX_DEVMAPPER_H_INCLUDED +#define KPARTX_DEVMAPPER_H_INCLUDED #ifdef DM_SUBSYSTEM_UDEV_FLAG0 #define MPATH_UDEV_RELOAD_FLAG DM_SUBSYSTEM_UDEV_FLAG0 @@ -36,4 +36,4 @@ int dm_find_part(const char *parent, const char *delim, int part, char *nondm_create_uuid(dev_t devt); int nondm_parse_uuid(const char *uuid, unsigned int *major, unsigned int *minor); -#endif /* _KPARTX_DEVMAPPER_H */ +#endif /* KPARTX_DEVMAPPER_H_INCLUDED */ diff --git a/kpartx/dos.h b/kpartx/dos.h index f45e7f688..678cddc5c 100644 --- a/kpartx/dos.h +++ b/kpartx/dos.h @@ -10,4 +10,4 @@ struct partition { unsigned int nr_sects; } __attribute__((packed)); -#endif /* DOS_H_INCLUDED */ +#endif /* DOS_H_INCLUDED */ diff --git a/kpartx/efi.h b/kpartx/efi.h index af5660aa1..10af0e719 100644 --- a/kpartx/efi.h +++ b/kpartx/efi.h @@ -17,8 +17,8 @@ along with this program. If not, see . */ -#ifndef EFI_H -#define EFI_H +#ifndef EFI_H_INCLUDED +#define EFI_H_INCLUDED /* * Extensible Firmware Interface @@ -54,4 +54,4 @@ efi_guidcmp(efi_guid_t left, efi_guid_t right) typedef uint16_t efi_char16_t; /* UNICODE character */ -#endif /* EFI_H */ +#endif /* EFI_H_INCLUDED */ diff --git a/kpartx/gpt.h b/kpartx/gpt.h index 4e1b49aa7..b35320ff3 100644 --- a/kpartx/gpt.h +++ b/kpartx/gpt.h @@ -21,8 +21,8 @@ along with this program. If not, see . */ -#ifndef _GPT_H -#define _GPT_H +#ifndef GPT_H_INCLUDED +#define GPT_H_INCLUDED #include diff --git a/kpartx/kpartx.h b/kpartx/kpartx.h index 727632c1e..8a210304d 100644 --- a/kpartx/kpartx.h +++ b/kpartx/kpartx.h @@ -1,5 +1,5 @@ -#ifndef _KPARTX_H -#define _KPARTX_H +#ifndef KPARTX_H_INCLUDED +#define KPARTX_H_INCLUDED #include #include @@ -70,4 +70,4 @@ four2int(unsigned char *p) { return p[0] + (p[1]<<8) + (p[2]<<16) + (p[3]<<24); } -#endif /* _KPARTX_H */ +#endif /* KPARTX_H_INCLUDED */ diff --git a/kpartx/lopart.h b/kpartx/lopart.h index c73ab2367..7cdcfe7d0 100644 --- a/kpartx/lopart.h +++ b/kpartx/lopart.h @@ -1,4 +1,7 @@ +#ifndef LOPART_H_INCLUDED +#define LOPART_H_INCLUDED extern int verbose; extern int set_loop (char **, const char *, int, int *); extern int del_loop (const char *); extern char * find_loop_by_file (const char *); +#endif diff --git a/kpartx/mac.h b/kpartx/mac.h index 55c3ec927..253fd0dd0 100644 --- a/kpartx/mac.h +++ b/kpartx/mac.h @@ -1,5 +1,5 @@ -#ifndef MAC_H -#define MAC_H +#ifndef MAC_H_INCLUDED +#define MAC_H_INCLUDED #include diff --git a/kpartx/xstrncpy.h b/kpartx/xstrncpy.h index 05c8fa26f..cb87aaac8 100644 --- a/kpartx/xstrncpy.h +++ b/kpartx/xstrncpy.h @@ -1 +1,4 @@ +#ifndef XSTRNCPY_H_INCLUDED +#define XSTRNCPY_H_INCLUDED extern void xstrncpy(char *dest, const char *src, size_t n); +#endif diff --git a/libdmmp/libdmmp.c b/libdmmp/libdmmp.c index fcfba06ed..8b9686a69 100644 --- a/libdmmp/libdmmp.c +++ b/libdmmp/libdmmp.c @@ -35,19 +35,19 @@ #include "libdmmp/libdmmp.h" #include "libdmmp_private.h" -#define _DEFAULT_UXSOCK_TIMEOUT 60000 +#define DEFAULT_UXSOCK_TIMEOUT 60000 /* ^ 60 seconds. On system with 10k sdX, dmmp_mpath_array_get() * only take 3.5 seconds, so this default value should be OK for most users. */ -#define _DMMP_IPC_SHOW_JSON_CMD "show maps json" -#define _DMMP_JSON_MAJOR_KEY "major_version" -#define _DMMP_JSON_MAJOR_VERSION 0 -#define _DMMP_JSON_MAPS_KEY "maps" -#define _ERRNO_STR_BUFF_SIZE 256 -#define _IPC_MAX_CMD_LEN 512 -/* ^ Was _MAX_CMD_LEN in ./libmultipath/uxsock.h */ -#define _LAST_ERR_MSG_BUFF_SIZE 1024 +#define DMMP_IPC_SHOW_JSON_CMD "show maps json" +#define DMMP_JSON_MAJOR_KEY "major_version" +#define DMMP_JSON_MAJOR_VERSION 0 +#define DMMP_JSON_MAPS_KEY "maps" +#define ERRNO_STR_BUFF_SIZE 256 +#define IPC_MAX_CMD_LEN 512 +/* ^ Was MAX_CMD_LEN in ./libmultipath/uxsock.h */ +#define LAST_ERR_MSG_BUFF_SIZE 1024 struct dmmp_context { void (*log_func)(struct dmmp_context *ctx, int priority, @@ -56,7 +56,7 @@ struct dmmp_context { int log_priority; void *userdata; unsigned int tmo; - char last_err_msg[_LAST_ERR_MSG_BUFF_SIZE]; + char last_err_msg[LAST_ERR_MSG_BUFF_SIZE]; }; /* @@ -86,9 +86,9 @@ _dmmp_getter_func_gen(dmmp_last_error_msg, struct dmmp_context, ctx, last_err_msg, const char *); _dmmp_array_free_func_gen(dmmp_mpath_array_free, struct dmmp_mpath, - _dmmp_mpath_free); + dmmp_mpath_free); -void _dmmp_log(struct dmmp_context *ctx, int priority, const char *file, +void dmmp_log(struct dmmp_context *ctx, int priority, const char *file, int line, const char *func_name, const char *format, ...) { va_list args; @@ -99,7 +99,7 @@ void _dmmp_log(struct dmmp_context *ctx, int priority, const char *file, va_start(args, format); ctx->log_func(ctx, priority, file, line, func_name, format, args); if (priority == DMMP_LOG_PRIORITY_ERROR) - vsnprintf(ctx->last_err_msg, _LAST_ERR_MSG_BUFF_SIZE, + vsnprintf(ctx->last_err_msg, LAST_ERR_MSG_BUFF_SIZE, format, args); va_end(args); } @@ -113,11 +113,11 @@ struct dmmp_context *dmmp_context_new(void) if (ctx == NULL) return NULL; - ctx->log_func = _dmmp_log_stderr; + ctx->log_func = dmmp_log_stderr; ctx->log_priority = DMMP_LOG_PRIORITY_DEFAULT; ctx->userdata = NULL; - ctx->tmo = _DEFAULT_UXSOCK_TIMEOUT; - memset(ctx->last_err_msg, 0, _LAST_ERR_MSG_BUFF_SIZE); + ctx->tmo = DEFAULT_UXSOCK_TIMEOUT; + memset(ctx->last_err_msg, 0, LAST_ERR_MSG_BUFF_SIZE); return ctx; } @@ -180,7 +180,7 @@ int dmmp_mpath_array_get(struct dmmp_context *ctx, _good(_ipc_connect(ctx, &ipc_fd), rc, out); - _good(_process_cmd(ctx, ipc_fd, _DMMP_IPC_SHOW_JSON_CMD, &j_str), + _good(_process_cmd(ctx, ipc_fd, DMMP_IPC_SHOW_JSON_CMD, &j_str), rc, out); _debug(ctx, "Got json output from multipathd: '%s'", j_str); @@ -202,20 +202,20 @@ int dmmp_mpath_array_get(struct dmmp_context *ctx, } _json_obj_get_value(ctx, j_obj, cur_json_major_version, - _DMMP_JSON_MAJOR_KEY, json_type_int, + DMMP_JSON_MAJOR_KEY, json_type_int, json_object_get_int, rc, out); - if (cur_json_major_version != _DMMP_JSON_MAJOR_VERSION) { + if (cur_json_major_version != DMMP_JSON_MAJOR_VERSION) { rc = DMMP_ERR_INCOMPATIBLE; _error(ctx, "Incompatible multipathd JSON major version %d, " "should be %d", cur_json_major_version, - _DMMP_JSON_MAJOR_VERSION); + DMMP_JSON_MAJOR_VERSION); goto out; } _debug(ctx, "multipathd JSON major version(%d) check pass", - _DMMP_JSON_MAJOR_VERSION); + DMMP_JSON_MAJOR_VERSION); - _json_obj_get_value(ctx, j_obj, ar_maps, _DMMP_JSON_MAPS_KEY, + _json_obj_get_value(ctx, j_obj, ar_maps, DMMP_JSON_MAPS_KEY, json_type_array, json_object_get_array, rc, out); if (ar_maps == NULL) { @@ -250,10 +250,10 @@ int dmmp_mpath_array_get(struct dmmp_context *ctx, goto out; } - dmmp_mp = _dmmp_mpath_new(); + dmmp_mp = dmmp_mpath_new(); _dmmp_alloc_null_check(ctx, dmmp_mp, rc, out); (*dmmp_mps)[i] = dmmp_mp; - _good(_dmmp_mpath_update(ctx, dmmp_mp, j_obj_map), rc, out); + _good(dmmp_mpath_update(ctx, dmmp_mp, j_obj_map), rc, out); } out: @@ -279,7 +279,7 @@ static int _process_cmd(struct dmmp_context *ctx, int fd, const char *cmd, { int errno_save = 0; int rc = DMMP_OK; - char errno_str_buff[_ERRNO_STR_BUFF_SIZE]; + char errno_str_buff[ERRNO_STR_BUFF_SIZE]; struct timespec start_ts; struct timespec cur_ts; unsigned int ipc_tmo = 0; @@ -300,7 +300,7 @@ static int _process_cmd(struct dmmp_context *ctx, int fd, const char *cmd, ipc_tmo = ctx->tmo; if (ctx->tmo == 0) - ipc_tmo = _DEFAULT_UXSOCK_TIMEOUT; + ipc_tmo = DEFAULT_UXSOCK_TIMEOUT; invoke: _debug(ctx, "Invoking IPC command '%s' with IPC tmo %u milliseconds", @@ -308,8 +308,8 @@ static int _process_cmd(struct dmmp_context *ctx, int fd, const char *cmd, flag_check_tmo = false; if (mpath_process_cmd(fd, cmd, output, ipc_tmo) != 0) { errno_save = errno; - memset(errno_str_buff, 0, _ERRNO_STR_BUFF_SIZE); - strerror_r(errno_save, errno_str_buff, _ERRNO_STR_BUFF_SIZE); + memset(errno_str_buff, 0, ERRNO_STR_BUFF_SIZE); + strerror_r(errno_save, errno_str_buff, ERRNO_STR_BUFF_SIZE); if (errno_save == ETIMEDOUT) { flag_check_tmo = true; } else { @@ -397,7 +397,7 @@ static int _ipc_connect(struct dmmp_context *ctx, int *fd) { int rc = DMMP_OK; int errno_save = 0; - char errno_str_buff[_ERRNO_STR_BUFF_SIZE]; + char errno_str_buff[ERRNO_STR_BUFF_SIZE]; assert(ctx != NULL); assert(fd != NULL); @@ -407,8 +407,8 @@ static int _ipc_connect(struct dmmp_context *ctx, int *fd) *fd = mpath_connect(); if (*fd == -1) { errno_save = errno; - memset(errno_str_buff, 0, _ERRNO_STR_BUFF_SIZE); - strerror_r(errno_save, errno_str_buff, _ERRNO_STR_BUFF_SIZE); + memset(errno_str_buff, 0, ERRNO_STR_BUFF_SIZE); + strerror_r(errno_save, errno_str_buff, ERRNO_STR_BUFF_SIZE); if (errno_save == ECONNREFUSED) { rc = DMMP_ERR_NO_DAEMON; _error(ctx, "Socket connection refuse. " @@ -426,14 +426,14 @@ int dmmp_flush_mpath(struct dmmp_context *ctx, const char *mpath_name) { int rc = DMMP_OK; int ipc_fd = -1; - char cmd[_IPC_MAX_CMD_LEN]; + char cmd[IPC_MAX_CMD_LEN]; char *output = NULL; assert(ctx != NULL); assert(mpath_name != NULL); - snprintf(cmd, _IPC_MAX_CMD_LEN, "del map %s", mpath_name); - if (strlen(cmd) == _IPC_MAX_CMD_LEN - 1) { + snprintf(cmd, IPC_MAX_CMD_LEN, "del map %s", mpath_name); + if (strlen(cmd) == IPC_MAX_CMD_LEN - 1) { rc = DMMP_ERR_INVALID_ARGUMENT; _error(ctx, "Invalid mpath name %s", mpath_name); goto out; @@ -461,9 +461,9 @@ int dmmp_reconfig(struct dmmp_context *ctx) int rc = DMMP_OK; int ipc_fd = -1; char *output = NULL; - char cmd[_IPC_MAX_CMD_LEN]; + char cmd[IPC_MAX_CMD_LEN]; - snprintf(cmd, _IPC_MAX_CMD_LEN, "%s", "reconfigure"); + snprintf(cmd, IPC_MAX_CMD_LEN, "%s", "reconfigure"); _good(_ipc_connect(ctx, &ipc_fd), rc, out); _good(_process_cmd(ctx, ipc_fd, cmd, &output), rc, out); diff --git a/libdmmp/libdmmp/libdmmp.h b/libdmmp/libdmmp/libdmmp.h index 6e6610d4a..25cd42ec8 100644 --- a/libdmmp/libdmmp/libdmmp.h +++ b/libdmmp/libdmmp/libdmmp.h @@ -19,8 +19,8 @@ */ -#ifndef _LIB_DMMP_H_ -#define _LIB_DMMP_H_ +#ifndef LIBDMMP_H_INCLUDED +#define LIBDMMP_H_INCLUDED #include #include @@ -732,4 +732,4 @@ DMMP_DLL_EXPORT const char *dmmp_last_error_msg(struct dmmp_context *ctx); } /* End of extern "C" */ #endif -#endif /* End of _LIB_DMMP_H_ */ +#endif /* End of LIBDMMP_H_INCLUDED */ diff --git a/libdmmp/libdmmp_misc.c b/libdmmp/libdmmp_misc.c index 69b5a2028..92bbf8d32 100644 --- a/libdmmp/libdmmp_misc.c +++ b/libdmmp/libdmmp_misc.c @@ -30,8 +30,8 @@ #include "libdmmp/libdmmp.h" #include "libdmmp_private.h" -#define _DMMP_LOG_STRERR_ALIGN_WIDTH 80 -/* ^ Only used in _dmmp_log_stderr() for pretty log output. +#define DMMP_LOG_STRERR_ALIGN_WIDTH 80 +/* ^ Only used in dmmp_log_stderr() for pretty log output. * When provided log message is less than 80 bytes, fill it with space, then * print code file name, function name, line after the 80th bytes. */ @@ -62,7 +62,7 @@ static const struct _num_str_conv _DMMP_PRI_CONV[] = { }; _dmmp_str_func_gen(dmmp_log_priority_str, int, priority, _DMMP_PRI_CONV); -void _dmmp_log_stderr(struct dmmp_context *ctx, int priority, +void dmmp_log_stderr(struct dmmp_context *ctx, int priority, const char *file, int line, const char *func_name, const char *format, va_list args) { @@ -81,9 +81,9 @@ void _dmmp_log_stderr(struct dmmp_context *ctx, int priority, * bypass clang static analyzer about unused ctx argument warning */ - if (printed_bytes < _DMMP_LOG_STRERR_ALIGN_WIDTH) { + if (printed_bytes < DMMP_LOG_STRERR_ALIGN_WIDTH) { fprintf(stderr, "%*s # %s:%s():%d\n", - _DMMP_LOG_STRERR_ALIGN_WIDTH - printed_bytes, "", file, + DMMP_LOG_STRERR_ALIGN_WIDTH - printed_bytes, "", file, func_name, line); } else { fprintf(stderr, " # %s:%s():%d\n", file, func_name, line); diff --git a/libdmmp/libdmmp_mp.c b/libdmmp/libdmmp_mp.c index bc48d0e35..1be8ba1aa 100644 --- a/libdmmp/libdmmp_mp.c +++ b/libdmmp/libdmmp_mp.c @@ -44,7 +44,7 @@ _dmmp_getter_func_gen(dmmp_mpath_wwid_get, struct dmmp_mpath, dmmp_mp, _dmmp_getter_func_gen(dmmp_mpath_kdev_name_get, struct dmmp_mpath, dmmp_mp, kdev_name, const char *); -struct dmmp_mpath *_dmmp_mpath_new(void) +struct dmmp_mpath *dmmp_mpath_new(void) { struct dmmp_mpath *dmmp_mp = NULL; @@ -59,7 +59,7 @@ struct dmmp_mpath *_dmmp_mpath_new(void) return dmmp_mp; } -int _dmmp_mpath_update(struct dmmp_context *ctx, struct dmmp_mpath *dmmp_mp, +int dmmp_mpath_update(struct dmmp_context *ctx, struct dmmp_mpath *dmmp_mp, json_object *j_obj_map) { int rc = DMMP_OK; @@ -113,10 +113,10 @@ int _dmmp_mpath_update(struct dmmp_context *ctx, struct dmmp_mpath *dmmp_mp, dmmp_mp->dmmp_pgs[i] = NULL; for (i = 0; i < dmmp_mp->dmmp_pg_count; ++i) { - dmmp_pg = _dmmp_path_group_new(); + dmmp_pg = dmmp_path_group_new(); _dmmp_alloc_null_check(ctx, dmmp_pg, rc, out); dmmp_mp->dmmp_pgs[i] = dmmp_pg; - _good(_dmmp_path_group_update(ctx, dmmp_pg, + _good(dmmp_path_group_update(ctx, dmmp_pg, array_list_get_idx(ar_pgs, i)), rc, out); } @@ -126,11 +126,11 @@ int _dmmp_mpath_update(struct dmmp_context *ctx, struct dmmp_mpath *dmmp_mp, out: if (rc != DMMP_OK) - _dmmp_mpath_free(dmmp_mp); + dmmp_mpath_free(dmmp_mp); return rc; } -void _dmmp_mpath_free(struct dmmp_mpath *dmmp_mp) +void dmmp_mpath_free(struct dmmp_mpath *dmmp_mp) { if (dmmp_mp == NULL) return ; diff --git a/libdmmp/libdmmp_path.c b/libdmmp/libdmmp_path.c index 21714b156..96a96f4aa 100644 --- a/libdmmp/libdmmp_path.c +++ b/libdmmp/libdmmp_path.c @@ -27,17 +27,17 @@ #include "libdmmp/libdmmp.h" #include "libdmmp_private.h" -#define _DMMP_SHOW_PS_INDEX_BLK_NAME 0 -#define _DMMP_SHOW_PS_INDEX_STATUS 1 -#define _DMMP_SHOW_PS_INDEX_WWID 2 -#define _DMMP_SHOW_PS_INDEX_PGID 3 +#define DMMP_SHOW_PS_INDEX_BLK_NAME 0 +#define DMMP_SHOW_PS_INDEX_STATUS 1 +#define DMMP_SHOW_PS_INDEX_WWID 2 +#define DMMP_SHOW_PS_INDEX_PGID 3 struct dmmp_path { char *blk_name; uint32_t status; }; -static const struct _num_str_conv _DMMP_PATH_STATUS_CONV[] = { +static const struct _num_str_conv DMMP_PATH_STATUS_CONV[] = { {DMMP_PATH_STATUS_UNKNOWN, "undef"}, {DMMP_PATH_STATUS_UP, "ready"}, {DMMP_PATH_STATUS_DOWN, "faulty"}, @@ -49,17 +49,17 @@ static const struct _num_str_conv _DMMP_PATH_STATUS_CONV[] = { }; _dmmp_str_func_gen(dmmp_path_status_str, uint32_t, path_status, - _DMMP_PATH_STATUS_CONV); + DMMP_PATH_STATUS_CONV); _dmmp_str_conv_func_gen(_dmmp_path_status_str_conv, ctx, path_status_str, uint32_t, DMMP_PATH_STATUS_UNKNOWN, - _DMMP_PATH_STATUS_CONV); + DMMP_PATH_STATUS_CONV); _dmmp_getter_func_gen(dmmp_path_blk_name_get, struct dmmp_path, dmmp_p, blk_name, const char *); _dmmp_getter_func_gen(dmmp_path_status_get, struct dmmp_path, dmmp_p, status, uint32_t); -struct dmmp_path *_dmmp_path_new(void) +struct dmmp_path *dmmp_path_new(void) { struct dmmp_path *dmmp_p = NULL; @@ -72,7 +72,7 @@ struct dmmp_path *_dmmp_path_new(void) return dmmp_p; } -int _dmmp_path_update(struct dmmp_context *ctx, struct dmmp_path *dmmp_p, +int dmmp_path_update(struct dmmp_context *ctx, struct dmmp_path *dmmp_p, json_object *j_obj_p) { int rc = DMMP_OK; @@ -102,11 +102,11 @@ int _dmmp_path_update(struct dmmp_context *ctx, struct dmmp_path *dmmp_p, out: if (rc != DMMP_OK) - _dmmp_path_free(dmmp_p); + dmmp_path_free(dmmp_p); return rc; } -void _dmmp_path_free(struct dmmp_path *dmmp_p) +void dmmp_path_free(struct dmmp_path *dmmp_p) { if (dmmp_p == NULL) return; diff --git a/libdmmp/libdmmp_pg.c b/libdmmp/libdmmp_pg.c index 5149161cd..68f1917f7 100644 --- a/libdmmp/libdmmp_pg.c +++ b/libdmmp/libdmmp_pg.c @@ -28,12 +28,12 @@ #include "libdmmp/libdmmp.h" #include "libdmmp_private.h" -#define _DMMP_SHOW_PGS_CMD "show groups raw format %w|%g|%p|%t|%s" -#define _DMMP_SHOW_PG_INDEX_WWID 0 -#define _DMMP_SHOW_PG_INDEX_PG_ID 1 -#define _DMMP_SHOW_PG_INDEX_PRI 2 -#define _DMMP_SHOW_PG_INDEX_STATUS 3 -#define _DMMP_SHOW_PG_INDEX_SELECTOR 4 +#define DMMP_SHOW_PGS_CMD "show groups raw format %w|%g|%p|%t|%s" +#define DMMP_SHOW_PG_INDEX_WWID 0 +#define DMMP_SHOW_PG_INDEX_PG_ID 1 +#define DMMP_SHOW_PG_INDEX_PRI 2 +#define DMMP_SHOW_PG_INDEX_STATUS 3 +#define DMMP_SHOW_PG_INDEX_SELECTOR 4 struct dmmp_path_group { uint32_t id; @@ -45,7 +45,7 @@ struct dmmp_path_group { struct dmmp_path **dmmp_ps; }; -static const struct _num_str_conv _DMMP_PATH_GROUP_STATUS_CONV[] = { +static const struct _num_str_conv DMMP_PATH_GROUP_STATUS_CONV[] = { {DMMP_PATH_GROUP_STATUS_UNKNOWN, "undef"}, {DMMP_PATH_GROUP_STATUS_ACTIVE, "active"}, {DMMP_PATH_GROUP_STATUS_DISABLED, "disabled"}, @@ -53,10 +53,10 @@ static const struct _num_str_conv _DMMP_PATH_GROUP_STATUS_CONV[] = { }; _dmmp_str_func_gen(dmmp_path_group_status_str, uint32_t, pg_status, - _DMMP_PATH_GROUP_STATUS_CONV); + DMMP_PATH_GROUP_STATUS_CONV); _dmmp_str_conv_func_gen(_dmmp_path_group_status_str_conv, ctx, pg_status_str, uint32_t, DMMP_PATH_GROUP_STATUS_UNKNOWN, - _DMMP_PATH_GROUP_STATUS_CONV); + DMMP_PATH_GROUP_STATUS_CONV); _dmmp_getter_func_gen(dmmp_path_group_id_get, struct dmmp_path_group, dmmp_pg, id, uint32_t); @@ -67,10 +67,10 @@ _dmmp_getter_func_gen(dmmp_path_group_priority_get, struct dmmp_path_group, _dmmp_getter_func_gen(dmmp_path_group_selector_get, struct dmmp_path_group, dmmp_pg, selector, const char *); _dmmp_array_free_func_gen(_dmmp_path_group_array_free, struct dmmp_path_group, - _dmmp_path_group_free); + dmmp_path_group_free); -struct dmmp_path_group *_dmmp_path_group_new(void) +struct dmmp_path_group *dmmp_path_group_new(void) { struct dmmp_path_group *dmmp_pg = NULL; @@ -78,7 +78,7 @@ struct dmmp_path_group *_dmmp_path_group_new(void) malloc(sizeof(struct dmmp_path_group)); if (dmmp_pg != NULL) { - dmmp_pg->id = _DMMP_PATH_GROUP_ID_UNKNOWN; + dmmp_pg->id = DMMP_PATH_GROUP_ID_UNKNOWN; dmmp_pg->status = DMMP_PATH_GROUP_STATUS_UNKNOWN; dmmp_pg->priority = 0; dmmp_pg->selector = NULL; @@ -87,7 +87,7 @@ struct dmmp_path_group *_dmmp_path_group_new(void) } return dmmp_pg; } -int _dmmp_path_group_update(struct dmmp_context *ctx, +int dmmp_path_group_update(struct dmmp_context *ctx, struct dmmp_path_group *dmmp_pg, json_object *j_obj_pg) { @@ -127,10 +127,10 @@ int _dmmp_path_group_update(struct dmmp_context *ctx, dmmp_pg->id = id; - if (dmmp_pg->id == _DMMP_PATH_GROUP_ID_UNKNOWN) { + if (dmmp_pg->id == DMMP_PATH_GROUP_ID_UNKNOWN) { rc = DMMP_ERR_BUG; _error(ctx, "BUG: Got unknown(%d) path group ID", - _DMMP_PATH_GROUP_ID_UNKNOWN); + DMMP_PATH_GROUP_ID_UNKNOWN); goto out; } @@ -157,10 +157,10 @@ int _dmmp_path_group_update(struct dmmp_context *ctx, dmmp_pg->dmmp_ps[i] = NULL; for (i = 0; i < dmmp_pg->dmmp_p_count; ++i) { - dmmp_p = _dmmp_path_new(); + dmmp_p = dmmp_path_new(); _dmmp_alloc_null_check(ctx, dmmp_p, rc, out); dmmp_pg->dmmp_ps[i] = dmmp_p; - _good(_dmmp_path_update(ctx, dmmp_p, + _good(dmmp_path_update(ctx, dmmp_p, array_list_get_idx(ar_ps, i)), rc, out); } @@ -173,11 +173,11 @@ int _dmmp_path_group_update(struct dmmp_context *ctx, out: if (rc != DMMP_OK) - _dmmp_path_group_free(dmmp_pg); + dmmp_path_group_free(dmmp_pg); return rc; } -void _dmmp_path_group_free(struct dmmp_path_group *dmmp_pg) +void dmmp_path_group_free(struct dmmp_path_group *dmmp_pg) { uint32_t i = 0; @@ -188,7 +188,7 @@ void _dmmp_path_group_free(struct dmmp_path_group *dmmp_pg) if (dmmp_pg->dmmp_ps != NULL) { for (i = 0; i < dmmp_pg->dmmp_p_count; ++i) { - _dmmp_path_free(dmmp_pg->dmmp_ps[i]); + dmmp_path_free(dmmp_pg->dmmp_ps[i]); } free(dmmp_pg->dmmp_ps); } diff --git a/libdmmp/libdmmp_private.h b/libdmmp/libdmmp_private.h index b1a6ddeae..d154146ce 100644 --- a/libdmmp/libdmmp_private.h +++ b/libdmmp/libdmmp_private.h @@ -18,8 +18,8 @@ * Todd Gill */ -#ifndef _LIB_DMMP_PRIVATE_H_ -#define _LIB_DMMP_PRIVATE_H_ +#ifndef LIBDMMP_PRIVATE_H_INCLUDED +#define LIBDMMP_PRIVATE_H_INCLUDED /* * Notes: @@ -46,7 +46,7 @@ extern "C" { goto out; \ } while(0) -#define _DMMP_PATH_GROUP_ID_UNKNOWN 0 +#define DMMP_PATH_GROUP_ID_UNKNOWN 0 struct DMMP_DLL_LOCAL _num_str_conv; struct _num_str_conv { @@ -110,33 +110,33 @@ do { \ DMMP_DLL_LOCAL int _dmmp_ipc_exec(struct dmmp_context *ctx, const char *cmd, char **output); -DMMP_DLL_LOCAL struct dmmp_mpath *_dmmp_mpath_new(void); -DMMP_DLL_LOCAL struct dmmp_path_group *_dmmp_path_group_new(void); -DMMP_DLL_LOCAL struct dmmp_path *_dmmp_path_new(void); +DMMP_DLL_LOCAL struct dmmp_mpath *dmmp_mpath_new(void); +DMMP_DLL_LOCAL struct dmmp_path_group *dmmp_path_group_new(void); +DMMP_DLL_LOCAL struct dmmp_path *dmmp_path_new(void); -DMMP_DLL_LOCAL int _dmmp_mpath_update(struct dmmp_context *ctx, +DMMP_DLL_LOCAL int dmmp_mpath_update(struct dmmp_context *ctx, struct dmmp_mpath *dmmp_mp, json_object *j_obj_map); -DMMP_DLL_LOCAL int _dmmp_path_group_update(struct dmmp_context *ctx, +DMMP_DLL_LOCAL int dmmp_path_group_update(struct dmmp_context *ctx, struct dmmp_path_group *dmmp_pg, json_object *j_obj_pg); -DMMP_DLL_LOCAL int _dmmp_path_update(struct dmmp_context *ctx, +DMMP_DLL_LOCAL int dmmp_path_update(struct dmmp_context *ctx, struct dmmp_path *dmmp_p, json_object *j_obj_p); -DMMP_DLL_LOCAL void _dmmp_mpath_free(struct dmmp_mpath *dmmp_mp); -DMMP_DLL_LOCAL void _dmmp_path_group_free(struct dmmp_path_group *dmmp_pg); +DMMP_DLL_LOCAL void dmmp_mpath_free(struct dmmp_mpath *dmmp_mp); +DMMP_DLL_LOCAL void dmmp_path_group_free(struct dmmp_path_group *dmmp_pg); DMMP_DLL_LOCAL void _dmmp_path_group_array_free (struct dmmp_path_group **dmmp_pgs, uint32_t dmmp_pg_count); -DMMP_DLL_LOCAL void _dmmp_path_free(struct dmmp_path *dmmp_p); -DMMP_DLL_LOCAL void _dmmp_log(struct dmmp_context *ctx, int priority, +DMMP_DLL_LOCAL void dmmp_path_free(struct dmmp_path *dmmp_p); +DMMP_DLL_LOCAL void dmmp_log(struct dmmp_context *ctx, int priority, const char *file, int line, const char *func_name, const char *format, ...) __attribute__((format(printf, 6, 7))); DMMP_DLL_LOCAL void _dmmp_log_err_str(struct dmmp_context *ctx, int rc); -DMMP_DLL_LOCAL void _dmmp_log_stderr(struct dmmp_context *ctx, int priority, +DMMP_DLL_LOCAL void dmmp_log_stderr(struct dmmp_context *ctx, int priority, const char *file, int line, const char *func_name, const char *format, va_list args) @@ -146,7 +146,7 @@ DMMP_DLL_LOCAL void _dmmp_log_stderr(struct dmmp_context *ctx, int priority, #define _dmmp_log_cond(ctx, prio, arg...) \ do { \ if (dmmp_context_log_priority_get(ctx) >= prio) \ - _dmmp_log(ctx, prio, __FILE__, __LINE__, __FUNCTION__, \ + dmmp_log(ctx, prio, __FILE__, __LINE__, __FUNCTION__, \ ## arg); \ } while (0) @@ -209,4 +209,4 @@ DMMP_DLL_LOCAL void _dmmp_log_stderr(struct dmmp_context *ctx, int priority, } /* End of extern "C" */ #endif -#endif /* End of _LIB_DMMP_PRIVATE_H_ */ +#endif /* End of LIBDMMP_PRIVATE_H_INCLUDED */ diff --git a/libmpathcmd/libmpathcmd.version b/libmpathcmd/libmpathcmd.version index f1006280a..81bdb2b7d 100644 --- a/libmpathcmd/libmpathcmd.version +++ b/libmpathcmd/libmpathcmd.version @@ -10,16 +10,20 @@ * * See libmultipath.version for general policy about version numbers. */ + LIBMPATHCMD_1.0.0 { global: - __mpath_connect; mpath_connect; + __mpath_connect; mpath_disconnect; mpath_process_cmd; mpath_recv_reply; mpath_recv_reply_len; mpath_recv_reply_data; mpath_send_cmd; -local: - *; }; + +LIBMPATHCMD_1.1.0 { +global: + mpath_connect__; +} LIBMPATHCMD_1.0.0; diff --git a/libmpathcmd/mpath_cmd.c b/libmpathcmd/mpath_cmd.c index d7c3371e7..a38e8b612 100644 --- a/libmpathcmd/mpath_cmd.c +++ b/libmpathcmd/mpath_cmd.c @@ -94,7 +94,7 @@ static size_t write_all(int fd, const void *buf, size_t len) /* * connect to a unix domain socket */ -int __mpath_connect(int nonblocking) +int mpath_connect__(int nonblocking) { int fd; size_t len; @@ -133,12 +133,15 @@ int __mpath_connect(int nonblocking) return fd; } +extern int __mpath_connect(int) + __attribute__((weak, alias("mpath_connect__"))); + /* * connect to a unix domain socket */ int mpath_connect(void) { - return __mpath_connect(0); + return mpath_connect__(0); } int mpath_disconnect(int fd) diff --git a/libmpathcmd/mpath_cmd.h b/libmpathcmd/mpath_cmd.h index 0c293c718..bf30c1ebb 100644 --- a/libmpathcmd/mpath_cmd.h +++ b/libmpathcmd/mpath_cmd.h @@ -17,8 +17,8 @@ * along with this program. If not, see . */ -#ifndef LIB_MPATH_CMD_H -#define LIB_MPATH_CMD_H +#ifndef MPATH_CMD_H_INCLUDED +#define MPATH_CMD_H_INCLUDED /* * This should be sufficient for json output for >10000 maps, @@ -47,7 +47,7 @@ extern "C" { * RETURNS: * A file descriptor on success. -1 on failure (with errno set). */ -int __mpath_connect(int nonblocking); +int mpath_connect__(int nonblocking); /* * DESCRIPTION: @@ -141,4 +141,4 @@ int mpath_recv_reply_data(int fd, char *reply, size_t len, #ifdef __cplusplus } #endif -#endif /* LIB_MPATH_CMD_H */ +#endif /* MPATH_CMD_H_INCLUDED */ diff --git a/libmpathpersist/libmpathpersist.version b/libmpathpersist/libmpathpersist.version index a8c6aae77..c7ddafb72 100644 --- a/libmpathpersist/libmpathpersist.version +++ b/libmpathpersist/libmpathpersist.version @@ -10,9 +10,9 @@ * * See libmultipath.version for general policy about version numbers. */ +/* Previous API for backward compatibility */ LIBMPATHPERSIST_2.1.0 { global: - /* public API as defined in mpath_persist.h */ libmpathpersist_exit; libmpathpersist_init; mpath_lib_exit; @@ -24,9 +24,16 @@ global: mpath_persistent_reserve_init_vecs; __mpath_persistent_reserve_out; mpath_persistent_reserve_out; -local: *; +local: + *; }; +LIBMPATHPERSIST_2.2.0 { +global: + mpath_persistent_reserve_in__; + mpath_persistent_reserve_out__; +} LIBMPATHPERSIST_2.1.0; + __LIBMPATHPERSIST_INT_1.0.0 { /* Internal use by multipath-tools */ dumpHex; diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c index 6cfcddee5..f5267ebf1 100644 --- a/libmpathpersist/mpath_persist.c +++ b/libmpathpersist/mpath_persist.c @@ -74,7 +74,7 @@ int libmpathpersist_exit(void) static vector curmp; static vector pathvec; -static void __mpath_persistent_reserve_free_vecs(vector curmp, vector pathvec) +static void mpath_persistent_reserve_free_vecs__(vector curmp, vector pathvec) { free_multipathvec(curmp, KEEP_PATHS); free_pathvec(pathvec, FREE_PATHS); @@ -82,11 +82,11 @@ static void __mpath_persistent_reserve_free_vecs(vector curmp, vector pathvec) void mpath_persistent_reserve_free_vecs(void) { - __mpath_persistent_reserve_free_vecs(curmp, pathvec); + mpath_persistent_reserve_free_vecs__(curmp, pathvec); curmp = pathvec = NULL; } -static int __mpath_persistent_reserve_init_vecs(vector *curmp_p, +static int mpath_persistent_reserve_init_vecs__(vector *curmp_p, vector *pathvec_p, int verbose) { libmp_verbosity = verbose; @@ -110,25 +110,27 @@ static int __mpath_persistent_reserve_init_vecs(vector *curmp_p, return MPATH_PR_SUCCESS; err: - __mpath_persistent_reserve_free_vecs(*curmp_p, *pathvec_p); + mpath_persistent_reserve_free_vecs__(*curmp_p, *pathvec_p); *curmp_p = *pathvec_p = NULL; return MPATH_PR_DMMP_ERROR; } int mpath_persistent_reserve_init_vecs(int verbose) { - return __mpath_persistent_reserve_init_vecs(&curmp, &pathvec, verbose); + return mpath_persistent_reserve_init_vecs__(&curmp, &pathvec, verbose); } -int __mpath_persistent_reserve_in (int fd, int rq_servact, +int mpath_persistent_reserve_in__(int fd, int rq_servact, struct prin_resp *resp, int noisy) { return do_mpath_persistent_reserve_in(curmp, pathvec, fd, rq_servact, resp, noisy); } +extern int __mpath_persistent_reserve_in(int, int, struct prin_resp *, int) + __attribute__((weak, alias("mpath_persistent_reserve_in__"))); -int __mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope, +int mpath_persistent_reserve_out__( int fd, int rq_servact, int rq_scope, unsigned int rq_type, struct prout_param_descriptor *paramp, int noisy) { return do_mpath_persistent_reserve_out(curmp, pathvec, fd, rq_servact, @@ -136,18 +138,22 @@ int __mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope, noisy); } +extern int __mpath_persistent_reserve_out(int, int, int, unsigned int, + struct prout_param_descriptor *, int) + __attribute__((weak, alias("mpath_persistent_reserve_out__"))); + int mpath_persistent_reserve_in (int fd, int rq_servact, struct prin_resp *resp, int noisy, int verbose) { vector curmp = NULL, pathvec; - int ret = __mpath_persistent_reserve_init_vecs(&curmp, &pathvec, + int ret = mpath_persistent_reserve_init_vecs__(&curmp, &pathvec, verbose); if (ret != MPATH_PR_SUCCESS) return ret; ret = do_mpath_persistent_reserve_in(curmp, pathvec, fd, rq_servact, resp, noisy); - __mpath_persistent_reserve_free_vecs(curmp, pathvec); + mpath_persistent_reserve_free_vecs__(curmp, pathvec); return ret; } @@ -155,13 +161,13 @@ int mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope, unsigned int rq_type, struct prout_param_descriptor *paramp, int noisy, int verbose) { vector curmp = NULL, pathvec; - int ret = __mpath_persistent_reserve_init_vecs(&curmp, &pathvec, + int ret = mpath_persistent_reserve_init_vecs__(&curmp, &pathvec, verbose); if (ret != MPATH_PR_SUCCESS) return ret; ret = do_mpath_persistent_reserve_out(curmp, pathvec, fd, rq_servact, rq_scope, rq_type, paramp, noisy); - __mpath_persistent_reserve_free_vecs(curmp, pathvec); + mpath_persistent_reserve_free_vecs__(curmp, pathvec); return ret; } diff --git a/libmpathpersist/mpath_persist.h b/libmpathpersist/mpath_persist.h index 0046f1206..d94205f08 100644 --- a/libmpathpersist/mpath_persist.h +++ b/libmpathpersist/mpath_persist.h @@ -1,8 +1,7 @@ /* version - 1.0 */ -#ifndef MPATH_PERSIST_LIB_H -#define MPATH_PERSIST_LIB_H - +#ifndef MPATH_PERSIST_H_INCLUDED +#define MPATH_PERSIST_H_INCLUDED #ifdef __cplusplus extern "C" { @@ -81,12 +80,8 @@ extern "C" { #define MPATH_WWUI_DEVICE_NAME 0x00 /* World wide unique initiator device name */ #define MPATH_WWUI_PORT_IDENTIFIER 0x40 /* World wide unique initiator port identifier */ - - extern unsigned int mpath_mx_alloc_len; - - struct prin_readdescr { uint32_t prgeneration; @@ -183,7 +178,7 @@ struct prout_param_descriptor { /* PROUT parameter descriptor */ * * RETURNS: 0->Success, 1->Failed. */ -extern int libmpathpersist_init (void); +int libmpathpersist_init(void); /* * DESCRIPTION : @@ -197,7 +192,7 @@ extern int libmpathpersist_init (void); * * RETURNS: struct config ->Success, NULL->Failed. */ -extern struct config * mpath_lib_init (void); +struct config *mpath_lib_init(void); /* @@ -209,7 +204,7 @@ extern struct config * mpath_lib_init (void); * * RETURNS: 0->Success, 1->Failed. */ -extern int mpath_lib_exit (struct config *conf); +int mpath_lib_exit(struct config *conf); /* * DESCRIPTION : @@ -221,7 +216,7 @@ extern int mpath_lib_exit (struct config *conf); * * RETURNS: 0->Success, 1->Failed. */ -extern int libmpathpersist_exit (void); +int libmpathpersist_exit(void); /* @@ -241,8 +236,8 @@ extern int libmpathpersist_exit (void); * above in RETURN_STATUS. * */ -extern int mpath_persistent_reserve_in (int fd, int rq_servact, struct prin_resp *resp, - int noisy, int verbose); +int mpath_persistent_reserve_in(int fd, int rq_servact, struct prin_resp *resp, + int noisy, int verbose); /* * DESCRIPTION : @@ -254,8 +249,8 @@ extern int mpath_persistent_reserve_in (int fd, int rq_servact, struct prin_resp * RESTRICTIONS: * This function uses static internal variables, and is not thread-safe. */ -extern int __mpath_persistent_reserve_in(int fd, int rq_servact, - struct prin_resp *resp, int noisy); +int mpath_persistent_reserve_in__(int fd, int rq_servact, + struct prin_resp *resp, int noisy); /* * DESCRIPTION : @@ -279,9 +274,10 @@ extern int __mpath_persistent_reserve_in(int fd, int rq_servact, * RETURNS: MPATH_PR_SUCCESS if PR command successful else returns any of the status specified * above in RETURN_STATUS. */ -extern int mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope, - unsigned int rq_type, struct prout_param_descriptor *paramp, int noisy, - int verbose); +int mpath_persistent_reserve_out(int fd, int rq_servact, int rq_scope, + unsigned int rq_type, + struct prout_param_descriptor *paramp, + int noisy, int verbose); /* * DESCRIPTION : * This function is like mpath_persistent_reserve_out(), except that it @@ -292,15 +288,16 @@ extern int mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope, * RESTRICTIONS: * This function uses static internal variables, and is not thread-safe. */ -extern int __mpath_persistent_reserve_out( int fd, int rq_servact, int rq_scope, - unsigned int rq_type, struct prout_param_descriptor *paramp, - int noisy); +int mpath_persistent_reserve_out__(int fd, int rq_servact, int rq_scope, + unsigned int rq_type, + struct prout_param_descriptor *paramp, + int noisy); /* * DESCRIPTION : * This function allocates data structures and performs basic initialization and - * device discovery for later calls of __mpath_persistent_reserve_in() or - * __mpath_persistent_reserve_out(). + * device discovery for later calls of mpath_persistent_reserve_in__() or + * mpath_persistent_reserve_out__(). * @verbose: Set verbosity level. Input argument. value:0 to 3. 0->disabled, 3->Max verbose * * RESTRICTIONS: @@ -326,4 +323,4 @@ void mpath_persistent_reserve_free_vecs(void); } #endif -#endif /*MPATH_PERSIST_LIB_H*/ +#endif /* MPATH_PERSIST_H_INCLUDED */ diff --git a/libmpathpersist/mpath_persist_int.h b/libmpathpersist/mpath_persist_int.h index 31457535a..7819823c8 100644 --- a/libmpathpersist/mpath_persist_int.h +++ b/libmpathpersist/mpath_persist_int.h @@ -1,5 +1,5 @@ -#ifndef _MPATH_PERSIST_INT_H -#define _MPATH_PERSIST_INT_H +#ifndef MPATH_PERSIST_INT_H_INCLUDED +#define MPATH_PERSIST_INT_H_INCLUDED /* * This header file contains symbols that are used by multipath-tools @@ -22,4 +22,4 @@ int prout_do_scsi_ioctl( char * dev, int rq_servact, int rq_scope, void dumpHex(const char* , int len, int no_ascii); int update_map_pr(struct multipath *mpp); -#endif /* _MPATH_PERSIST_INT_H */ +#endif /* MPATH_PERSIST_INT_H_INCLUDED */ diff --git a/libmpathpersist/mpath_pr_ioctl.h b/libmpathpersist/mpath_pr_ioctl.h index 625490f78..b1d9be1a8 100644 --- a/libmpathpersist/mpath_pr_ioctl.h +++ b/libmpathpersist/mpath_pr_ioctl.h @@ -1,3 +1,6 @@ +#ifndef MPATH_PR_IOCTL_H_INCLUDED +#define MPATH_PR_IOCTL_H_INCLUDED + #define MPATH_XFER_HOST_DEV 0 /*data transfer from initiator to target */ #define MPATH_XFER_DEV_HOST 1 /*data transfer from target to initiator */ #define MPATH_XFER_NONE 2 /*no data transfer */ @@ -107,3 +110,5 @@ typedef struct SenseData /* Driver status */ #define DRIVER_OK 0x00 + +#endif diff --git a/libmpathpersist/mpathpr.h b/libmpathpersist/mpathpr.h index 39a7d8ed0..cc1a5673c 100644 --- a/libmpathpersist/mpathpr.h +++ b/libmpathpersist/mpathpr.h @@ -1,5 +1,5 @@ -#ifndef MPATHPR_H -#define MPATHPR_H +#ifndef MPATHPR_H_INCLUDED +#define MPATHPR_H_INCLUDED /* * This header file contains symbols that are only used by diff --git a/libmpathutil/debug.h b/libmpathutil/debug.h index 705a5d733..c2a2f6e60 100644 --- a/libmpathutil/debug.h +++ b/libmpathutil/debug.h @@ -1,5 +1,5 @@ -#ifndef _DEBUG_H -#define _DEBUG_H +#ifndef DEBUG_H_INCLUDED +#define DEBUG_H_INCLUDED void dlog (int prio, const char *fmt, ...) __attribute__((format(printf, 2, 3))); @@ -29,4 +29,4 @@ enum { if (__p <= MAX_VERBOSITY && __p <= libmp_verbosity) \ dlog(__p, fmt "\n", ##args); \ } while (0) -#endif /* _DEBUG_H */ +#endif /* DEBUG_H_INCLUDED */ diff --git a/libmpathutil/globals.c b/libmpathutil/globals.c index 0f6033e07..4d913496f 100644 --- a/libmpathutil/globals.c +++ b/libmpathutil/globals.c @@ -2,10 +2,10 @@ #include #include "globals.h" -struct config *get_multipath_config(void) +__attribute__((weak)) struct config *get_multipath_config(void) { return NULL; } -void put_multipath_config(void *p __attribute__((unused))) +__attribute__((weak)) void put_multipath_config(void *p __attribute__((unused))) {} diff --git a/libmpathutil/globals.h b/libmpathutil/globals.h index a4d4d4e26..fbb140167 100644 --- a/libmpathutil/globals.h +++ b/libmpathutil/globals.h @@ -1,5 +1,5 @@ -#ifndef _GLOBALS_H -#define _GLOBALS_H +#ifndef GLOBALS_H_INCLUDED +#define GLOBALS_H_INCLUDED struct config; diff --git a/libmpathutil/libmpathutil.version b/libmpathutil/libmpathutil.version index cb0523167..fb92f7282 100644 --- a/libmpathutil/libmpathutil.version +++ b/libmpathutil/libmpathutil.version @@ -43,98 +43,86 @@ LIBMPATHCOMMON_1.0.0 { put_multipath_config; }; -/* symbols referenced by multipath and multipathd */ -LIBMULTIPATH_16.0.0 { +LIBMPATHUTIL_4.0 { global: + alloc_bitfield; alloc_strvec; append_strbuf_str; + append_strbuf_str__; + append_strbuf_quoted; + basenamecpy; cleanup_charp; + cleanup_fclose; + cleanup_fd_ptr; + cleanup_free_ptr; cleanup_mutex; cleanup_ucharp; + cleanup_udev_device; + cleanup_vector; + cleanup_vector_free; convert_dev; dlog; + filepresent; fill_strbuf; + find_keyword; find_slot; + free_keywords; free_scandir_result; free_strvec; + get_linux_version_code; get_monotonic_time; + get_strbuf_buf__; get_next_string; get_strbuf_len; get_strbuf_str; + get_word; + install_keyword__; + install_sublevel; + install_sublevel_end; is_quote; + keyword_alloc; + log_bitfield_overflow__; + libmp_basename; + libmp_strlcat; + libmp_strlcpy; libmp_verbosity; + log_safe; log_thread_reset; log_thread_start; log_thread_stop; logsink; + msort; normalize_timespec; + parse_devt; print_strbuf; + process_file; pthread_cond_init_mono; recv_packet; reset_strbuf; + safe_write; send_packet; set_max_fds; + set_value; setup_thread_attr; strchop; - strlcpy; + should_exit; + snprint_keyword; + steal_strbuf_str; timespeccmp; timespecsub; truncate_strbuf; + validate_config_strvec; ux_socket_listen; vector_alloc; vector_alloc_slot; vector_del_slot; + vector_find_or_add_slot; vector_free; + vector_insert_slot; + vector_move_up; vector_reset; vector_set_slot; - + vector_sort; local: *; }; - -/* symbols referenced internally by libmultipath */ -LIBMPATHUTIL_2.0 { - alloc_bitfield; - __append_strbuf_str; - append_strbuf_quoted; - basenamecpy; - cleanup_fd_ptr; - cleanup_free_ptr; - cleanup_vector_free; - cleanup_fclose; - filepresent; - find_keyword; - free_keywords; - get_linux_version_code; - __get_strbuf_buf; - get_word; - _install_keyword; - install_sublevel; - install_sublevel_end; - keyword_alloc; - _log_bitfield_overflow; - log_safe; - msort; - parse_devt; - process_file; - safe_write; - set_value; - should_exit; - snprint_keyword; - steal_strbuf_str; - strlcat; - validate_config_strvec; - vector_find_or_add_slot; - vector_insert_slot; - vector_move_up; - vector_sort; -}; - -LIBMPATHUTIL_2.1 { - libmp_basename; -}; - -LIBMPATHUTIL_2.2 { - cleanup_udev_device; - cleanup_vector; -}; diff --git a/libmpathutil/log.h b/libmpathutil/log.h index fa224e4dd..e3d269c4f 100644 --- a/libmpathutil/log.h +++ b/libmpathutil/log.h @@ -1,5 +1,5 @@ -#ifndef LOG_H -#define LOG_H +#ifndef LOG_H_INCLUDED +#define LOG_H_INCLUDED #define DEFAULT_AREA_SIZE 16384 #define MAX_MSG_SIZE 256 @@ -40,4 +40,4 @@ int log_dequeue (void *); void log_syslog (void *); void dump_logmsg (void *); -#endif /* LOG_H */ +#endif /* LOG_H_INCLUDED */ diff --git a/libmpathutil/log_pthread.c b/libmpathutil/log_pthread.c index 69b441bf6..f30eb7ed1 100644 --- a/libmpathutil/log_pthread.c +++ b/libmpathutil/log_pthread.c @@ -60,7 +60,7 @@ static void flush_logqueue (void) } while (empty == 0); } -static void cleanup_log_thread(__attribute((unused)) void *arg) +static void cleanup_log_thread(__attribute__((unused)) void *arg) { logdbg(stderr, "log thread exiting"); pthread_mutex_lock(&logev_lock); diff --git a/libmpathutil/log_pthread.h b/libmpathutil/log_pthread.h index 810ac9201..dea57b876 100644 --- a/libmpathutil/log_pthread.h +++ b/libmpathutil/log_pthread.h @@ -1,5 +1,5 @@ -#ifndef _LOG_PTHREAD_H -#define _LOG_PTHREAD_H +#ifndef LOG_PTHREAD_H_INCLUDED +#define LOG_PTHREAD_H_INCLUDED #include @@ -9,4 +9,4 @@ void log_thread_start(pthread_attr_t *attr); void log_thread_reset (void); void log_thread_stop(void); -#endif /* _LOG_PTHREAD_H */ +#endif /* LOG_PTHREAD_H_INCLUDED */ diff --git a/libmpathutil/msort.h b/libmpathutil/msort.h index caef9b6b7..edfa4388c 100644 --- a/libmpathutil/msort.h +++ b/libmpathutil/msort.h @@ -1,5 +1,5 @@ -#ifndef __MSORT_H -#define __MSORT_H +#ifndef MSORT_H_INCLUDED +#define MSORT_H_INCLUDED typedef int(*__compar_fn_t)(const void *, const void *); void msort (void *b, size_t n, size_t s, __compar_fn_t cmp); diff --git a/libmpathutil/parser.c b/libmpathutil/parser.c index 29b212ce3..b1db433f4 100644 --- a/libmpathutil/parser.c +++ b/libmpathutil/parser.c @@ -70,7 +70,7 @@ install_sublevel_end(void) } int -_install_keyword(vector keywords, char *string, +install_keyword__(vector keywords, char *string, handler_fn *handler, print_fn *print, int unique) @@ -167,7 +167,7 @@ snprint_keyword(struct strbuf *buff, const char *fmt, struct keyword *kw, goto out; } if (f != fmt && - (r = __append_strbuf_str(&sbuf, fmt, f - fmt)) < 0) + (r = append_strbuf_str__(&sbuf, fmt, f - fmt)) < 0) goto out; fmt = f + 1; switch(*fmt) { @@ -191,7 +191,7 @@ snprint_keyword(struct strbuf *buff, const char *fmt, struct keyword *kw, } while (*fmt++); out: if (r >= 0) - r = __append_strbuf_str(buff, get_strbuf_str(&sbuf), + r = append_strbuf_str__(buff, get_strbuf_str(&sbuf), get_strbuf_len(&sbuf)); return r; } @@ -406,8 +406,7 @@ int is_sublevel_keyword(char *str) { return (strcmp(str, "defaults") == 0 || strcmp(str, "blacklist") == 0 || - strcmp(str, "blacklist_exceptions") == 0 || - strcmp(str, "devices") == 0 || strcmp(str, "devices") == 0 || + strcmp(str, "blacklist_exceptions") == 0 || strcmp(str, "devices") == 0 || strcmp(str, "device") == 0 || strcmp(str, "multipaths") == 0 || strcmp(str, "multipath") == 0); } diff --git a/libmpathutil/parser.h b/libmpathutil/parser.h index 9d9d948d5..179aeca8d 100644 --- a/libmpathutil/parser.h +++ b/libmpathutil/parser.h @@ -20,8 +20,8 @@ * 2 of the License, or (at your option) any later version. */ -#ifndef _PARSER_H -#define _PARSER_H +#ifndef PARSER_H_INCLUDED +#define PARSER_H_INCLUDED /* system includes */ #include @@ -63,22 +63,22 @@ struct keyword { for (i = 0; i < (k)->sub->allocated && ((p) = (k)->sub->slot[i]); i++) /* Prototypes */ -extern int keyword_alloc(vector keywords, char *string, handler_fn *handler, - print_fn *print, int unique); +int keyword_alloc(vector keywords, char *string, handler_fn *handler, + print_fn *print, int unique); #define install_keyword_root(str, h) keyword_alloc(keywords, str, h, NULL, 1) -extern void install_sublevel(void); -extern void install_sublevel_end(void); +void install_sublevel(void); +void install_sublevel_end(void); -extern int _install_keyword(vector keywords, char *string, handler_fn *handler, - print_fn *print, int unique); -#define install_keyword(str, vec, pri) _install_keyword(keywords, str, vec, pri, 1) -#define install_keyword_multi(str, vec, pri) _install_keyword(keywords, str, vec, pri, 0) -extern void dump_keywords(vector keydump, int level); -extern void free_keywords(vector keywords); -extern vector alloc_strvec(char *string); -extern void *set_value(vector strvec); -extern int process_file(struct config *conf, const char *conf_file); -extern struct keyword * find_keyword(vector keywords, vector v, char * name); +int install_keyword__(vector keywords, char *string, handler_fn *handler, + print_fn *print, int unique); +#define install_keyword(str, vec, pri) install_keyword__(keywords, str, vec, pri, 1) +#define install_keyword_multi(str, vec, pri) install_keyword__(keywords, str, vec, pri, 0) +void dump_keywords(vector keydump, int level); +void free_keywords(vector keywords); +vector alloc_strvec(char *string); +void *set_value(vector strvec); +int process_file(struct config *conf, const char *conf_file); +struct keyword * find_keyword(vector keywords, vector v, char * name); int snprint_keyword(struct strbuf *buff, const char *fmt, struct keyword *kw, const void *data); bool is_quote(const char* token); diff --git a/libmpathutil/strbuf.c b/libmpathutil/strbuf.c index e23b65e80..491a343aa 100644 --- a/libmpathutil/strbuf.c +++ b/libmpathutil/strbuf.c @@ -15,7 +15,7 @@ static const char empty_str[] = ""; -char *__get_strbuf_buf(struct strbuf *buf) +char *get_strbuf_buf__(struct strbuf *buf) { return buf->buf; } @@ -110,7 +110,7 @@ static int expand_strbuf(struct strbuf *buf, int addsz) return 0; } -int __append_strbuf_str(struct strbuf *buf, const char *str, int slen) +int append_strbuf_str__(struct strbuf *buf, const char *str, int slen) { int ret; @@ -135,7 +135,7 @@ int append_strbuf_str(struct strbuf *buf, const char *str) if (slen > INT_MAX) return -ERANGE; - return __append_strbuf_str(buf, str, slen); + return append_strbuf_str__(buf, str, slen); } int fill_strbuf(struct strbuf *buf, char c, int slen) @@ -196,17 +196,30 @@ int print_strbuf(struct strbuf *buf, const char *fmt, ...) { va_list ap; int ret; - char *tail; + size_t space = buf->size - buf->offs; va_start(ap, fmt); - ret = vasprintf(&tail, fmt, ap); + ret = vsnprintf(buf->buf + buf->offs, space, fmt, ap); va_end(ap); if (ret < 0) - return -ENOMEM; + return ret; + else if ((size_t)ret < space) { + buf->offs += ret; + return ret; + } + + ret = expand_strbuf(buf, ret); + if (ret < 0) + return ret; + + space = buf->size - buf->offs; + va_start(ap, fmt); + ret = vsnprintf(buf->buf + buf->offs, space, fmt, ap); + va_end(ap); - ret = __append_strbuf_str(buf, tail, ret); + if (ret >= 0) + buf->offs += ret; - free(tail); return ret; } diff --git a/libmpathutil/strbuf.h b/libmpathutil/strbuf.h index ae863417e..790dc233c 100644 --- a/libmpathutil/strbuf.h +++ b/libmpathutil/strbuf.h @@ -2,8 +2,8 @@ * Copyright (c) 2021 SUSE LLC * SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _STRBUF_H -#define _STRBUF_H +#ifndef STRBUF_H_INCLUDED +#define STRBUF_H_INCLUDED #include #include @@ -66,7 +66,7 @@ struct strbuf *new_strbuf(void); * If @strbuf was never written to, the function returns NULL. * The return value of this function must not be free()d. */ -char *__get_strbuf_buf(struct strbuf *buf); +char *get_strbuf_buf__(struct strbuf *buf); /** * get_strbuf_str(): retrieve string from strbuf @@ -112,7 +112,7 @@ size_t get_strbuf_len(const struct strbuf *buf); int truncate_strbuf(struct strbuf *buf, size_t offs); /** - * __append_strbuf_str(): append string of known length + * append_strbuf_str__(): append string of known length * @param buf: the struct strbuf to write to * @param str: the string to append, not necessarily 0-terminated * @param slen: max number of characters to append, must be non-negative @@ -123,7 +123,7 @@ int truncate_strbuf(struct strbuf *buf, size_t offs); * 0-bytes possibly contained in the first @slen characters are copied into * the output. If the function returns an error, @strbuf is unchanged. */ -int __append_strbuf_str(struct strbuf *buf, const char *str, int slen); +int append_strbuf_str__(struct strbuf *buf, const char *str, int slen); /** * append_strbuf_str(): append string diff --git a/libmpathutil/time-util.h b/libmpathutil/time-util.h index 4a80ebd32..dfffe4b1c 100644 --- a/libmpathutil/time-util.h +++ b/libmpathutil/time-util.h @@ -1,5 +1,5 @@ -#ifndef _TIME_UTIL_H_ -#define _TIME_UTIL_H_ +#ifndef TIME_UTIL_H_INCLUDED +#define TIME_UTIL_H_INCLUDED #include @@ -12,4 +12,4 @@ void timespecsub(const struct timespec *a, const struct timespec *b, struct timespec *res); int timespeccmp(const struct timespec *a, const struct timespec *b); -#endif /* _TIME_UTIL_H_ */ +#endif /* TIME_UTIL_H_INCLUDED */ diff --git a/libmpathutil/util.c b/libmpathutil/util.c index 9c422f1f0..125597427 100644 --- a/libmpathutil/util.c +++ b/libmpathutil/util.c @@ -121,7 +121,7 @@ get_word (const char *sentence, char **word) return skip + len; } -size_t strlcpy(char * restrict dst, const char * restrict src, size_t size) +size_t libmp_strlcpy(char * restrict dst, const char * restrict src, size_t size) { size_t bytes = 0; char ch; @@ -138,7 +138,7 @@ size_t strlcpy(char * restrict dst, const char * restrict src, size_t size) return bytes; } -size_t strlcat(char * restrict dst, const char * restrict src, size_t size) +size_t libmp_strlcat(char * restrict dst, const char * restrict src, size_t size) { size_t bytes = 0; char ch; @@ -354,7 +354,7 @@ struct bitfield *alloc_bitfield(unsigned int maxbit) return bf; } -void _log_bitfield_overflow(const char *f, unsigned int bit, unsigned int len) +void log_bitfield_overflow__(const char *f, unsigned int bit, unsigned int len) { condlog(0, "%s: bitfield overflow: %u >= %u", f, bit, len); } diff --git a/libmpathutil/util.h b/libmpathutil/util.h index c19f74974..b1772e3f7 100644 --- a/libmpathutil/util.h +++ b/libmpathutil/util.h @@ -1,5 +1,5 @@ -#ifndef _UTIL_H -#define _UTIL_H +#ifndef UTIL_H_INCLUDED +#define UTIL_H_INCLUDED #include #include @@ -12,6 +12,10 @@ #include #include +#ifndef __GLIBC_PREREQ +#define __GLIBC_PREREQ(x, y) 0 +#endif + size_t strchop(char *); const char *libmp_basename(const char *filename); @@ -22,8 +26,12 @@ int basenamecpy (const char *src, char *dst, size_t size); int filepresent (const char *run); char *get_next_string(char **temp, const char *split_char); int get_word (const char * sentence, char ** word); -size_t strlcpy(char * restrict dst, const char * restrict src, size_t size); -size_t strlcat(char * restrict dst, const char * restrict src, size_t size); +size_t libmp_strlcpy(char * restrict dst, const char * restrict src, size_t size); +size_t libmp_strlcat(char * restrict dst, const char * restrict src, size_t size); +#if defined(__GLIBC__) && ! (__GLIBC_PREREQ(2, 38)) +#define strlcpy(dst, src, size) libmp_strlcpy(dst, src, size) +#define strlcat(dst, src, size) libmp_strlcat(dst, src, size) +#endif dev_t parse_devt(const char *dev_t); char *convert_dev(char *dev, int is_path_device); void setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached); @@ -62,9 +70,6 @@ struct scandir_result { }; void free_scandir_result(struct scandir_result *); -#ifndef __GLIBC_PREREQ -#define __GLIBC_PREREQ(x, y) 0 -#endif /* * ffsll() is also available on glibc < 2.27 if _GNU_SOURCE is defined. * But relying on that would require that every program using this header file @@ -98,9 +103,9 @@ struct bitfield { struct bitfield *alloc_bitfield(unsigned int maxbit); -void _log_bitfield_overflow(const char *f, unsigned int bit, unsigned int len); +void log_bitfield_overflow__(const char *f, unsigned int bit, unsigned int len); #define log_bitfield_overflow(bit, len) \ - _log_bitfield_overflow(__func__, bit, len) + log_bitfield_overflow__(__func__, bit, len) static inline bool is_bit_set_in_bitfield(unsigned int bit, const struct bitfield *bf) @@ -142,4 +147,4 @@ void cleanup_charp(char **p); void cleanup_ucharp(unsigned char **p); void cleanup_udev_device(struct udev_device **udd); -#endif /* _UTIL_H */ +#endif /* UTIL_H_INCLUDED */ diff --git a/libmpathutil/uxsock.h b/libmpathutil/uxsock.h index e3d28cf5f..1726a9604 100644 --- a/libmpathutil/uxsock.h +++ b/libmpathutil/uxsock.h @@ -1,7 +1,10 @@ /* some prototypes */ +#ifndef UXSOCK_H_INCLUDED +#define UXSOCK_H_INCLUDED + int ux_socket_listen(const char *name); int send_packet(int fd, const char *buf); int recv_packet(int fd, char **buf, unsigned int timeout); -#define _MAX_CMD_LEN 512 - +#define MAX_CMD_LEN 512 +#endif diff --git a/libmpathutil/vector.c b/libmpathutil/vector.c index 7c3ce43d4..5392b3793 100644 --- a/libmpathutil/vector.c +++ b/libmpathutil/vector.c @@ -30,7 +30,7 @@ vector vector_alloc(void) { - vector v = (vector) calloc(1, sizeof (struct _vector)); + vector v = (vector) calloc(1, sizeof (struct vector_s)); return v; } diff --git a/libmpathutil/vector.h b/libmpathutil/vector.h index a41f15740..8c5617ba1 100644 --- a/libmpathutil/vector.h +++ b/libmpathutil/vector.h @@ -20,17 +20,17 @@ * 2 of the License, or (at your option) any later version. */ -#ifndef _VECTOR_H -#define _VECTOR_H +#ifndef VECTOR_H_INCLUDED +#define VECTOR_H_INCLUDED #include /* vector definition */ -struct _vector { +struct vector_s { int allocated; void **slot; }; -typedef struct _vector *vector; +typedef struct vector_s *vector; #define VECTOR_DEFAULT_SIZE 1 #define VECTOR_SIZE(V) ((V) ? ((V)->allocated) / VECTOR_DEFAULT_SIZE : 0) @@ -53,7 +53,7 @@ typedef struct _vector *vector; */ #define vector_convert(new, vec, type, conv) \ ({ \ - const struct _vector *__v = (vec); \ + const struct vector_s *__v = (vec); \ vector __t = (new); \ type *__j; \ int __i; \ diff --git a/libmpathvalid/mpath_valid.h b/libmpathvalid/mpath_valid.h index 636f16343..de165a2d4 100644 --- a/libmpathvalid/mpath_valid.h +++ b/libmpathvalid/mpath_valid.h @@ -17,8 +17,8 @@ * along with this program. If not, see . */ -#ifndef LIB_MPATH_VALID_H -#define LIB_MPATH_VALID_H +#ifndef MPATH_VALID_H_INCLUDED +#define MPATH_VALID_H_INCLUDED #ifdef __cplusplus extern "C" { @@ -152,4 +152,4 @@ int mpathvalid_is_path(const char *name, unsigned int mode, char **wwid, #ifdef __cplusplus } #endif -#endif /* LIB_PATH_VALID_H */ +#endif /* MPATH_VALID_H_INCLUDED */ diff --git a/libmultipath/alias.c b/libmultipath/alias.c index c4eb5d8d3..ea6c7b4fc 100644 --- a/libmultipath/alias.c +++ b/libmultipath/alias.c @@ -70,7 +70,7 @@ struct binding { * Perhaps one day we'll implement this more efficiently, thus use * an abstract type. */ -typedef struct _vector Bindings; +typedef struct vector_s Bindings; /* Protect global_bindings */ static pthread_mutex_t bindings_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -242,7 +242,7 @@ static int write_bindings_file(const Bindings *bindings, int fd, int i; size_t len; - if (__append_strbuf_str(&content, BINDINGS_FILE_HEADER, + if (append_strbuf_str__(&content, BINDINGS_FILE_HEADER, sizeof(BINDINGS_FILE_HEADER) - 1) == -1) return -1; diff --git a/libmultipath/alias.h b/libmultipath/alias.h index 629e8d566..eb3c15b8a 100644 --- a/libmultipath/alias.h +++ b/libmultipath/alias.h @@ -1,5 +1,5 @@ -#ifndef _ALIAS_H -#define _ALIAS_H +#ifndef ALIAS_H_INCLUDED +#define ALIAS_H_INCLUDED int valid_alias(const char *alias); int get_user_friendly_wwid(const char *alias, char *buff); @@ -11,4 +11,4 @@ int check_alias_settings(const struct config *); void cleanup_bindings(void); struct inotify_event; void handle_bindings_file_inotify(const struct inotify_event *event); -#endif /* _ALIAS_H */ +#endif /* ALIAS_H_INCLUDED */ diff --git a/libmultipath/blacklist.c b/libmultipath/blacklist.c index 75100b207..17e1b54a3 100644 --- a/libmultipath/blacklist.c +++ b/libmultipath/blacklist.c @@ -141,7 +141,7 @@ int set_ble_device(vector blist, const char *vendor, const char *product, int or } static int -match_reglist (const struct _vector *blist, const char *str) +match_reglist (const struct vector_s *blist, const char *str) { int i; struct blentry * ble; @@ -154,7 +154,7 @@ match_reglist (const struct _vector *blist, const char *str) } static int -match_reglist_device (const struct _vector *blist, const char *vendor, +match_reglist_device (const struct vector_s *blist, const char *vendor, const char * product) { int i; @@ -175,7 +175,7 @@ match_reglist_device (const struct _vector *blist, const char *vendor, } static int -find_blacklist_device (const struct _vector *blist, const char *vendor, +find_blacklist_device (const struct vector_s *blist, const char *vendor, const char *product) { int i; @@ -316,7 +316,7 @@ log_filter (const char *dev, const char *vendor, const char *product, } int -filter_device (const struct _vector *blist, const struct _vector *elist, +filter_device (const struct vector_s *blist, const struct vector_s *elist, const char *vendor, const char * product, const char *dev) { int r = MATCH_NOTHING; @@ -333,7 +333,7 @@ filter_device (const struct _vector *blist, const struct _vector *elist, } int -filter_devnode (const struct _vector *blist, const struct _vector *elist, +filter_devnode (const struct vector_s *blist, const struct vector_s *elist, const char *dev) { int r = MATCH_NOTHING; @@ -350,7 +350,7 @@ filter_devnode (const struct _vector *blist, const struct _vector *elist, } int -filter_wwid (const struct _vector *blist, const struct _vector *elist, +filter_wwid (const struct vector_s *blist, const struct vector_s *elist, const char *wwid, const char *dev) { int r = MATCH_NOTHING; @@ -367,7 +367,7 @@ filter_wwid (const struct _vector *blist, const struct _vector *elist, } int -filter_protocol(const struct _vector *blist, const struct _vector *elist, +filter_protocol(const struct vector_s *blist, const struct vector_s *elist, const struct path *pp) { STRBUF_ON_STACK(buf); diff --git a/libmultipath/blacklist.h b/libmultipath/blacklist.h index dde5cea45..f32b58299 100644 --- a/libmultipath/blacklist.h +++ b/libmultipath/blacklist.h @@ -1,5 +1,5 @@ -#ifndef _BLACKLIST_H -#define _BLACKLIST_H +#ifndef BLACKLIST_H_INCLUDED +#define BLACKLIST_H_INCLUDED #include #include @@ -36,16 +36,16 @@ struct blentry_device { int setup_default_blist (struct config *); int alloc_ble_device (vector); -int filter_devnode (const struct _vector *, const struct _vector *, +int filter_devnode (const struct vector_s *, const struct vector_s *, const char *); -int filter_wwid (const struct _vector *, const struct _vector *, +int filter_wwid (const struct vector_s *, const struct vector_s *, const char *, const char *); -int filter_device (const struct _vector *, const struct _vector *, +int filter_device (const struct vector_s *, const struct vector_s *, const char *, const char *, const char *); int filter_path (const struct config *, const struct path *); int filter_property(const struct config *, struct udev_device *, int, const char*); -int filter_protocol(const struct _vector *, const struct _vector *, +int filter_protocol(const struct vector_s *, const struct vector_s *, const struct path *); int store_ble (vector, const char *, int); int set_ble_device (vector, const char *, const char *, int); @@ -54,4 +54,4 @@ void free_blacklist_device (vector); void merge_blacklist(vector); void merge_blacklist_device(vector); -#endif /* _BLACKLIST_H */ +#endif /* BLACKLIST_H_INCLUDED */ diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h index ea1e8af62..102351f6d 100644 --- a/libmultipath/checkers.h +++ b/libmultipath/checkers.h @@ -1,5 +1,5 @@ -#ifndef _CHECKERS_H -#define _CHECKERS_H +#ifndef CHECKERS_H_INCLUDED +#define CHECKERS_H_INCLUDED #include #include "list.h" @@ -194,9 +194,9 @@ void *libcheck_thread(struct checker_context *ctx); * message IDs. * Message IDs available to checkers start at CHECKER_FIRST_MSG. * The msgtable array is 0-based, i.e. msgtable[0] is the message - * for msgid == __CHECKER_FIRST_MSG. + * for msgid == CHECKER_FIRST_MSG. * The table ends with a NULL element. */ extern const char *libcheck_msgtable[]; -#endif /* _CHECKERS_H */ +#endif /* CHECKERS_H_INCLUDED */ diff --git a/libmultipath/checkers/cciss.h b/libmultipath/checkers/cciss.h index cf2094656..19450c2b8 100644 --- a/libmultipath/checkers/cciss.h +++ b/libmultipath/checkers/cciss.h @@ -1,5 +1,5 @@ -#ifndef CCISS_H -#define CCISS_H +#ifndef CCISS_H_INCLUDED +#define CCISS_H_INCLUDED #include #include @@ -42,7 +42,7 @@ #pragma pack(1) //Command List Structure -typedef union _SCSI3Addr_struct { +typedef union { struct { BYTE Dev; BYTE Bus:6; @@ -61,27 +61,27 @@ typedef union _SCSI3Addr_struct { } LogUnit; } SCSI3Addr_struct; -typedef struct _PhysDevAddr_struct { +typedef struct { DWORD TargetId:24; DWORD Bus:6; DWORD Mode:2; SCSI3Addr_struct Target[2]; //2 level target device addr } PhysDevAddr_struct; -typedef struct _LogDevAddr_struct { +typedef struct { DWORD VolId:30; DWORD Mode:2; BYTE reserved[4]; } LogDevAddr_struct; -typedef union _LUNAddr_struct { +typedef union { BYTE LunAddrBytes[8]; SCSI3Addr_struct SCSI3Lun[4]; PhysDevAddr_struct PhysDev; LogDevAddr_struct LogDev; } LUNAddr_struct; -typedef struct _RequestBlock_struct { +typedef struct { BYTE CDBLen; struct { BYTE Type:3; @@ -92,7 +92,7 @@ typedef struct _RequestBlock_struct { BYTE CDB[16]; } RequestBlock_struct; -typedef union _MoreErrInfo_struct{ +typedef union { struct { BYTE Reserved[3]; BYTE Type; @@ -106,7 +106,7 @@ typedef union _MoreErrInfo_struct{ } Invalid_Cmd; } MoreErrInfo_struct; -typedef struct _ErrorInfo_struct { +typedef struct { BYTE ScsiStatus; BYTE SenseLen; HWORD CommandStatus; @@ -117,7 +117,7 @@ typedef struct _ErrorInfo_struct { #pragma pack() -typedef struct _IOCTL_Command_struct { +typedef struct { LUNAddr_struct LUN_info; RequestBlock_struct Request; ErrorInfo_struct error_info; @@ -125,7 +125,7 @@ typedef struct _IOCTL_Command_struct { BYTE *buf; } IOCTL_Command_struct; -typedef struct _LogvolInfo_struct{ +typedef struct { __u32 LunID; int num_opens; /* number of opens on the logical volume */ int num_parts; /* number of partitions configured on logvol */ diff --git a/libmultipath/checkers/directio.c b/libmultipath/checkers/directio.c index 12b8be494..8e87878b6 100644 --- a/libmultipath/checkers/directio.c +++ b/libmultipath/checkers/directio.c @@ -49,11 +49,11 @@ enum { MSG_DIRECTIO_BLOCKSIZE, }; -#define _IDX(x) (MSG_DIRECTIO_##x - CHECKER_FIRST_MSGID) +#define IDX_(x) (MSG_DIRECTIO_##x - CHECKER_FIRST_MSGID) const char *libcheck_msgtable[] = { - [_IDX(UNKNOWN)] = " is not available", - [_IDX(PENDING)] = " is waiting on aio", - [_IDX(BLOCKSIZE)] = " cannot get blocksize, set default", + [IDX_(UNKNOWN)] = " is not available", + [IDX_(PENDING)] = " is waiting on aio", + [IDX_(BLOCKSIZE)] = " cannot get blocksize, set default", NULL, }; diff --git a/libmultipath/checkers/directio.h b/libmultipath/checkers/directio.h index 1865b1fcd..15b3da497 100644 --- a/libmultipath/checkers/directio.h +++ b/libmultipath/checkers/directio.h @@ -1,8 +1,8 @@ -#ifndef _DIRECTIO_H -#define _DIRECTIO_H +#ifndef DIRECTIO_H_INCLUDED +#define DIRECTIO_H_INCLUDED int directio (struct checker *); int directio_init (struct checker *); void directio_free (struct checker *); -#endif /* _DIRECTIO_H */ +#endif /* DIRECTIO_H_INCLUDED */ diff --git a/libmultipath/checkers/emc_clariion.c b/libmultipath/checkers/emc_clariion.c index 04635b5c7..bf0baabc0 100644 --- a/libmultipath/checkers/emc_clariion.c +++ b/libmultipath/checkers/emc_clariion.c @@ -57,20 +57,20 @@ enum { MSG_CLARIION_PASSIVE_GOOD, }; -#define _IDX(x) (MSG_CLARIION_ ## x - CHECKER_FIRST_MSGID) +#define IDX_(x) (MSG_CLARIION_ ## x - CHECKER_FIRST_MSGID) const char *libcheck_msgtable[] = { - [_IDX(QUERY_FAILED)] = ": sending query command failed", - [_IDX(QUERY_ERROR)] = ": query command indicates error", - [_IDX(PATH_CONFIG)] = + [IDX_(QUERY_FAILED)] = ": sending query command failed", + [IDX_(QUERY_ERROR)] = ": query command indicates error", + [IDX_(PATH_CONFIG)] = ": Path not correctly configured for failover", - [_IDX(UNIT_REPORT)] = + [IDX_(UNIT_REPORT)] = ": Path unit report page in unknown format", - [_IDX(PATH_NOT_AVAIL)] = + [IDX_(PATH_NOT_AVAIL)] = ": Path not available for normal operations", - [_IDX(LUN_UNBOUND)] = ": Logical Unit is unbound or LUNZ", - [_IDX(WWN_CHANGED)] = ": Logical Unit WWN has changed", - [_IDX(READ_ERROR)] = ": Read error", - [_IDX(PASSIVE_GOOD)] = ": Active path is healthy", + [IDX_(LUN_UNBOUND)] = ": Logical Unit is unbound or LUNZ", + [IDX_(WWN_CHANGED)] = ": Logical Unit WWN has changed", + [IDX_(READ_ERROR)] = ": Read error", + [IDX_(PASSIVE_GOOD)] = ": Active path is healthy", NULL, }; diff --git a/libmultipath/checkers/emc_clariion.h b/libmultipath/checkers/emc_clariion.h index a1018a666..ee85dd530 100644 --- a/libmultipath/checkers/emc_clariion.h +++ b/libmultipath/checkers/emc_clariion.h @@ -1,8 +1,8 @@ -#ifndef _EMC_CLARIION_H -#define _EMC_CLARIION_H +#ifndef EMC_CLARIION_H_INCLUDED +#define EMC_CLARIION_H_INCLUDED int emc_clariion (struct checker *); int emc_clariion_init (struct checker *); void emc_clariion_free (struct checker *); -#endif /* _EMC_CLARIION_H */ +#endif /* EMC_CLARIION_H_INCLUDED */ diff --git a/libmultipath/checkers/hp_sw.h b/libmultipath/checkers/hp_sw.h index 3be0d8eab..058935135 100644 --- a/libmultipath/checkers/hp_sw.h +++ b/libmultipath/checkers/hp_sw.h @@ -1,8 +1,8 @@ -#ifndef _HP_SW_H -#define _HP_SW_H +#ifndef HP_SW_H_INCLUDED +#define HP_SW_H_INCLUDED int hp_sw (struct checker *); int hp_sw_init (struct checker *); void hp_sw_free (struct checker *); -#endif /* _HP_SW_H */ +#endif /* HP_SW_H_INCLUDED */ diff --git a/libmultipath/checkers/rdac.c b/libmultipath/checkers/rdac.c index 9a3860fd2..87b8872a1 100644 --- a/libmultipath/checkers/rdac.c +++ b/libmultipath/checkers/rdac.c @@ -234,19 +234,19 @@ enum { RDAC_MSGID_INQUIRY_FAILED, }; -#define _IDX(x) (RDAC_MSGID_##x - CHECKER_FIRST_MSGID) +#define IDX_(x) (RDAC_MSGID_##x - CHECKER_FIRST_MSGID) const char *libcheck_msgtable[] = { - [_IDX(NOT_CONN)] = MSG_RDAC_DOWN_TYPE("lun not connected"), - [_IDX(IN_STARTUP)] = MSG_RDAC_DOWN_TYPE("ctlr is in startup sequence"), - [_IDX(NON_RESPONSIVE)] = + [IDX_(NOT_CONN)] = MSG_RDAC_DOWN_TYPE("lun not connected"), + [IDX_(IN_STARTUP)] = MSG_RDAC_DOWN_TYPE("ctlr is in startup sequence"), + [IDX_(NON_RESPONSIVE)] = MSG_RDAC_DOWN_TYPE("non-responsive to queries"), - [_IDX(IN_RESET)] = MSG_RDAC_DOWN_TYPE("ctlr held in reset"), - [_IDX(FW_DOWNLOADING)] = + [IDX_(IN_RESET)] = MSG_RDAC_DOWN_TYPE("ctlr held in reset"), + [IDX_(FW_DOWNLOADING)] = MSG_RDAC_DOWN_TYPE("ctlr firmware downloading"), - [_IDX(QUIESCED)] = MSG_RDAC_DOWN_TYPE("ctlr quiesced by admin request"), - [_IDX(SERVICE_MODE)] = MSG_RDAC_DOWN_TYPE("ctlr is in service mode"), - [_IDX(UNAVAILABLE)] = MSG_RDAC_DOWN_TYPE("ctlr is unavailable"), - [_IDX(INQUIRY_FAILED)] = MSG_RDAC_DOWN_TYPE("inquiry failed"), + [IDX_(QUIESCED)] = MSG_RDAC_DOWN_TYPE("ctlr quiesced by admin request"), + [IDX_(SERVICE_MODE)] = MSG_RDAC_DOWN_TYPE("ctlr is in service mode"), + [IDX_(UNAVAILABLE)] = MSG_RDAC_DOWN_TYPE("ctlr is unavailable"), + [IDX_(INQUIRY_FAILED)] = MSG_RDAC_DOWN_TYPE("inquiry failed"), NULL, }; diff --git a/libmultipath/checkers/rdac.h b/libmultipath/checkers/rdac.h index d7bf8124b..5a92b285c 100644 --- a/libmultipath/checkers/rdac.h +++ b/libmultipath/checkers/rdac.h @@ -1,8 +1,8 @@ -#ifndef _RDAC_H -#define _RDAC_H +#ifndef RDAC_H_INCLUDED +#define RDAC_H_INCLUDED int rdac(struct checker *); int rdac_init(struct checker *); void rdac_free(struct checker *); -#endif /* _RDAC_H */ +#endif /* RDAC_H_INCLUDED */ diff --git a/libmultipath/checkers/readsector0.h b/libmultipath/checkers/readsector0.h index 0f5d65438..486613d4e 100644 --- a/libmultipath/checkers/readsector0.h +++ b/libmultipath/checkers/readsector0.h @@ -1,8 +1,8 @@ -#ifndef _READSECTOR0_H -#define _READSECTOR0_H +#ifndef READSECTOR0_H_INCLUDED +#define READSECTOR0_H_INCLUDED int readsector0 (struct checker *); int readsector0_init (struct checker *); void readsector0_free (struct checker *); -#endif /* _READSECTOR0_H */ +#endif /* READSECTOR0_H_INCLUDED */ diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c index 2800446d6..a2905af58 100644 --- a/libmultipath/checkers/tur.c +++ b/libmultipath/checkers/tur.c @@ -35,12 +35,12 @@ enum { MSG_TUR_TRANSITIONING, }; -#define _IDX(x) (MSG_ ## x - CHECKER_FIRST_MSGID) +#define IDX_(x) (MSG_ ## x - CHECKER_FIRST_MSGID) const char *libcheck_msgtable[] = { - [_IDX(TUR_RUNNING)] = " still running", - [_IDX(TUR_TIMEOUT)] = " timed out", - [_IDX(TUR_FAILED)] = " failed to initialize", - [_IDX(TUR_TRANSITIONING)] = " reports path is transitioning", + [IDX_(TUR_RUNNING)] = " still running", + [IDX_(TUR_TIMEOUT)] = " timed out", + [IDX_(TUR_FAILED)] = " failed to initialize", + [IDX_(TUR_TRANSITIONING)] = " reports path is transitioning", NULL, }; diff --git a/libmultipath/checkers/tur.h b/libmultipath/checkers/tur.h index a2e8c8883..62a47d126 100644 --- a/libmultipath/checkers/tur.h +++ b/libmultipath/checkers/tur.h @@ -1,8 +1,8 @@ -#ifndef _TUR_H -#define _TUR_H +#ifndef TUR_H_INCLUDED +#define TUR_H_INCLUDED int tur (struct checker *); int tur_init (struct checker *); void tur_free (struct checker *); -#endif /* _TUR_H */ +#endif /* TUR_H_INCLUDED */ diff --git a/libmultipath/config.c b/libmultipath/config.c index 7aa568c38..a59d4d31f 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -72,17 +72,17 @@ void libmultipath_exit(void) pthread_once(&_exit_once, _libmultipath_exit); } -static struct config __internal_config; +static struct config internal_config; struct config *libmp_get_multipath_config(void) { - if (!__internal_config.hwtable) + if (!internal_config.hwtable) /* not initialized */ return NULL; - return &__internal_config; + return &internal_config; } struct config *get_multipath_config(void) - __attribute__((alias("libmp_get_multipath_config"))); + __attribute__((weak, alias("libmp_get_multipath_config"))); void libmp_put_multipath_config(void *conf __attribute__((unused))) { @@ -90,7 +90,7 @@ void libmp_put_multipath_config(void *conf __attribute__((unused))) } void put_multipath_config(void *conf) - __attribute__((alias("libmp_put_multipath_config"))); + __attribute__((weak, alias("libmp_put_multipath_config"))); static int hwe_strmatch (const struct hwentry *hwe1, const struct hwentry *hwe2) @@ -114,7 +114,7 @@ hwe_strmatch (const struct hwentry *hwe1, const struct hwentry *hwe2) } static struct hwentry * -find_hwe_strmatch (const struct _vector *hwtable, const struct hwentry *hwe) +find_hwe_strmatch (const struct vector_s *hwtable, const struct hwentry *hwe) { int i; struct hwentry *tmp, *ret = NULL; @@ -179,7 +179,7 @@ static void _log_match(const char *fn, const struct hwentry *h, #define log_match(h, v, p, r) _log_match(__func__, (h), (v), (p), (r)) int -find_hwe (const struct _vector *hwtable, +find_hwe (const struct vector_s *hwtable, const char * vendor, const char * product, const char * revision, vector result) { @@ -222,7 +222,7 @@ struct mpentry *find_mpe(vector mptable, char *wwid) return NULL; } -const char *get_mpe_wwid(const struct _vector *mptable, const char *alias) +const char *get_mpe_wwid(const struct vector_s *mptable, const char *alias) { int i; struct mpentry * mpe; @@ -735,7 +735,7 @@ static void _uninit_config(struct config *conf) int i; if (!conf) - conf = &__internal_config; + conf = &internal_config; if (conf->selector) free(conf->selector); @@ -792,14 +792,14 @@ static void _uninit_config(struct config *conf) void uninit_config(void) { - _uninit_config(&__internal_config); + _uninit_config(&internal_config); } void free_config(struct config *conf) { if (!conf) return; - else if (conf == &__internal_config) { + else if (conf == &internal_config) { condlog(0, "ERROR: %s called for internal config. Use uninit_config() instead", __func__); return; @@ -880,29 +880,29 @@ static void set_max_checkint_from_watchdog(struct config *conf) } #endif -static int _init_config (const char *file, struct config *conf); +static int init_config__ (const char *file, struct config *conf); int init_config(const char *file) { - return _init_config(file, &__internal_config); + return init_config__(file, &internal_config); } struct config *load_config(const char *file) { struct config *conf = alloc_config(); - if (conf && !_init_config(file, conf)) + if (conf && !init_config__(file, conf)) return conf; free(conf); return NULL; } -int _init_config (const char *file, struct config *conf) +int init_config__ (const char *file, struct config *conf) { if (!conf) - conf = &__internal_config; + conf = &internal_config; /* * Processing the config file will overwrite conf->verbosity if set @@ -1090,7 +1090,7 @@ int _init_config (const char *file, struct config *conf) const char *get_uid_attribute_by_attrs(const struct config *conf, const char *path_dev) { - const struct _vector *uid_attrs = &conf->uid_attrs; + const struct vector_s *uid_attrs = &conf->uid_attrs; int j; char *att, *col; diff --git a/libmultipath/config.h b/libmultipath/config.h index 800c0ca9c..94cdf252f 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -1,5 +1,5 @@ -#ifndef _CONFIG_H -#define _CONFIG_H +#ifndef CONFIG_H_INCLUDED +#define CONFIG_H_INCLUDED #include #include @@ -206,7 +206,7 @@ struct config { int auto_resize; char * selector; - struct _vector uid_attrs; + struct vector_s uid_attrs; char * uid_attribute; char * features; char * hwhandler; @@ -286,11 +286,11 @@ int libmultipath_init(void); */ void libmultipath_exit(void); -int find_hwe (const struct _vector *hwtable, +int find_hwe (const struct vector_s *hwtable, const char * vendor, const char * product, const char *revision, vector result); struct mpentry * find_mpe (vector mptable, char * wwid); -const char *get_mpe_wwid (const struct _vector *mptable, const char *alias); +const char *get_mpe_wwid (const struct vector_s *mptable, const char *alias); struct hwentry * alloc_hwe (void); struct mpentry * alloc_mpe (void); diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 81e742ee6..4bc9e59ce 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -631,7 +631,7 @@ select_reload_action(struct multipath *mpp, const char *reason) condlog(3, "%s: set ACT_RELOAD (%s)", mpp->alias, reason); } -void select_action (struct multipath *mpp, const struct _vector *curmp, +void select_action (struct multipath *mpp, const struct vector_s *curmp, int force_reload) { struct multipath * cmpp; diff --git a/libmultipath/configure.h b/libmultipath/configure.h index 9d935db3f..f98a3b21e 100644 --- a/libmultipath/configure.h +++ b/libmultipath/configure.h @@ -1,3 +1,6 @@ +#ifndef CONFIGURE_H_INCLUDED +#define CONFIGURE_H_INCLUDED + /* * configurator actions */ @@ -50,7 +53,7 @@ enum { struct vectors; int setup_map (struct multipath * mpp, char **params, struct vectors *vecs); -void select_action (struct multipath *mpp, const struct _vector *curmp, +void select_action (struct multipath *mpp, const struct vector_s *curmp, int force_reload); int domap (struct multipath * mpp, char * params, int is_daemon); int reinstate_paths (struct multipath *mpp); @@ -63,3 +66,4 @@ void trigger_paths_udev_change(struct multipath *mpp, bool is_mpath); void trigger_partitions_udev_change(struct udev_device *dev, const char *action, int len); int check_daemon(void); +#endif diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h index 74bab222a..47cffd3bd 100644 --- a/libmultipath/defaults.h +++ b/libmultipath/defaults.h @@ -1,5 +1,6 @@ -#ifndef _DEFAULTS_H -#define _DEFAULTS_H +#ifndef DEFAULTS_H_INCLUDED +#define DEFAULTS_H_INCLUDED + #include #include @@ -78,4 +79,4 @@ static inline char *set_default(char *str) return strdup(str); } extern const char *const default_partition_delim; -#endif /* _DEFAULTS_H */ +#endif /* DEFAULTS_H_INCLUDED */ diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 0347a17c7..c497c2250 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -45,9 +45,9 @@ static int dm_conf_verbosity; #ifdef LIBDM_API_DEFERRED static int dm_cancel_remove_partmaps(const char * mapname); -#define __DR_UNUSED__ /* empty */ +#define DR_UNUSED__ /* empty */ #else -#define __DR_UNUSED__ __attribute__((unused)) +#define DR_UNUSED__ __attribute__((unused)) #endif static int dm_remove_partmaps (const char *mapname, int flags); @@ -86,10 +86,10 @@ const char *dmp_errstr(int rc) [DMP_OK] = "success", [DMP_NOT_FOUND] = "not found", [DMP_NO_MATCH] = "target type mismatch", - [__DMP_LAST__] = "**invalid**", + [DMP_LAST__] = "**invalid**", }; - if (rc < 0 || rc > __DMP_LAST__) - rc = __DMP_LAST__; + if (rc < 0 || rc > DMP_LAST__) + rc = DMP_LAST__; return str[rc]; } @@ -624,7 +624,7 @@ has_dm_info(const struct multipath *mpp) static int libmp_set_map_identifier(int flags, mapid_t id, struct dm_task *dmt) { - switch (flags & __DM_MAP_BY_MASK) { + switch (flags & DM_MAP_BY_MASK__) { case DM_MAP_BY_UUID: if (!id.str || !(*id.str)) return 0; @@ -682,7 +682,7 @@ static int libmp_mapinfo__(int flags, mapid_t id, mapinfo_t info, const char *ma */ if (info.target && !info.status) ioctl_nr = DM_DEVICE_TABLE; - else if (info.status || info.size || flags & __MAPINFO_TGT_TYPE) + else if (info.status || info.size || flags & MAPINFO_TGT_TYPE__) ioctl_nr = DM_DEVICE_STATUS; else ioctl_nr = DM_DEVICE_INFO; @@ -715,7 +715,7 @@ static int libmp_mapinfo__(int flags, mapid_t id, mapinfo_t info, const char *ma return DMP_NOT_FOUND; } - if (info.target || info.status || info.size || flags & __MAPINFO_TGT_TYPE) { + if (info.target || info.status || info.size || flags & MAPINFO_TGT_TYPE__) { if (dm_get_next_target(dmt, NULL, &start, &length, &target_type, ¶ms) != NULL) { condlog(2, "%s: map %s has multiple targets", fname__, map_id); @@ -725,7 +725,7 @@ static int libmp_mapinfo__(int flags, mapid_t id, mapinfo_t info, const char *ma condlog(2, "%s: map %s has no targets", fname__, map_id); return DMP_NOT_FOUND; } - if (flags & __MAPINFO_TGT_TYPE) { + if (flags & MAPINFO_TGT_TYPE__) { const char *tgt_type = flags & MAPINFO_MPATH_ONLY ? TGT_MPATH : TGT_PART; if (strcmp(target_type, tgt_type)) { @@ -797,7 +797,7 @@ static int libmp_mapinfo__(int flags, mapid_t id, mapinfo_t info, const char *ma /* Helper: format a string describing the map for log messages */ static const char* libmp_map_identifier(int flags, mapid_t id, char buf[BLK_DEV_SIZE]) { - switch (flags & __DM_MAP_BY_MASK) { + switch (flags & DM_MAP_BY_MASK__) { case DM_MAP_BY_NAME: case DM_MAP_BY_UUID: return id.str; @@ -965,7 +965,7 @@ int mpath_in_use(const char *name) return 0; } -int _dm_flush_map (const char *mapname, int flags, int retries) +int dm_flush_map__ (const char *mapname, int flags, int retries) { int r; int queue_if_no_path = 0; @@ -1041,7 +1041,7 @@ int _dm_flush_map (const char *mapname, int flags, int retries) } int -dm_flush_map_nopaths(const char *mapname, int deferred_remove __DR_UNUSED__) +dm_flush_map_nopaths(const char *mapname, int deferred_remove DR_UNUSED__) { int flags = DMFL_NEED_SYNC; @@ -1050,7 +1050,7 @@ dm_flush_map_nopaths(const char *mapname, int deferred_remove __DR_UNUSED__) deferred_remove == DEFERRED_REMOVE_IN_PROGRESS) ? DMFL_DEFERRED : 0); #endif - return _dm_flush_map(mapname, flags, 0); + return dm_flush_map__(mapname, flags, 0); } int dm_flush_maps(int retries) @@ -1196,7 +1196,7 @@ dm_disablegroup(const char * mapname, int index) static int dm_get_multipath(const char *name, struct multipath **pmpp) { - struct multipath __attribute((cleanup(cleanup_multipath))) *mpp = NULL; + struct multipath __attribute__((cleanup(cleanup_multipath))) *mpp = NULL; char uuid[DM_UUID_LEN]; int rc; diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index a26dc1e5d..ba05e0a1a 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -1,5 +1,6 @@ -#ifndef _DEVMAPPER_H -#define _DEVMAPPER_H +#ifndef DEVMAPPER_H_INCLUDED +#define DEVMAPPER_H_INCLUDED + #include #include #include "autoconfig.h" @@ -34,15 +35,15 @@ enum { DMP_OK, DMP_NOT_FOUND, DMP_NO_MATCH, - __DMP_LAST__, + DMP_LAST__, }; const char* dmp_errstr(int rc); /** - * enum mapinfo_flags: input flags for libmp_mapinfo() + * input flags for libmp_mapinfo() */ -enum __mapinfo_flags { +enum { /** DM_MAP_BY_NAME: identify map by device-mapper name from @name */ DM_MAP_BY_NAME = 0, /** DM_MAP_BY_UUID: identify map by device-mapper UUID from @uuid */ @@ -51,12 +52,12 @@ enum __mapinfo_flags { DM_MAP_BY_DEV, /** DM_MAP_BY_DEVT: identify map by a dev_t */ DM_MAP_BY_DEVT, - __DM_MAP_BY_MASK = (1 << 8) - 1, + DM_MAP_BY_MASK__ = (1 << 8) - 1, /* Fail if target type is not multipath */ MAPINFO_MPATH_ONLY = (1 << 8), /* Fail if target type is not "partition" (linear) */ MAPINFO_PART_ONLY = (1 << 9), - __MAPINFO_TGT_TYPE = (MAPINFO_MPATH_ONLY | MAPINFO_PART_ONLY), + MAPINFO_TGT_TYPE__ = (MAPINFO_MPATH_ONLY | MAPINFO_PART_ONLY), /* Fail if the UUID doesn't match the multipath UUID format */ MAPINFO_CHECK_UUID = (1 << 10), }; @@ -91,7 +92,7 @@ typedef struct libmp_map_info { /** * libmp_mapinfo(): obtain information about a map from the kernel - * @param flags: see __mapinfo_flags above. + * @param flags: see enum values above. * Exactly one of DM_MAP_BY_NAME, DM_MAP_BY_UUID, and DM_MAP_BY_DEV must be set. * @param id: string or major/minor to identify the map to query * @param info: output parameters, see above. Non-NULL elements will be filled in. @@ -160,11 +161,11 @@ enum { DMFL_NO_FLUSH = 1 << 3, }; -int _dm_flush_map (const char *mapname, int flags, int retries); -#define dm_flush_map(mapname) _dm_flush_map(mapname, DMFL_NEED_SYNC, 0) -#define dm_flush_map_nosync(mapname) _dm_flush_map(mapname, DMFL_NONE, 0) +int dm_flush_map__ (const char *mapname, int flags, int retries); +#define dm_flush_map(mapname) dm_flush_map__(mapname, DMFL_NEED_SYNC, 0) +#define dm_flush_map_nosync(mapname) dm_flush_map__(mapname, DMFL_NONE, 0) #define dm_suspend_and_flush_map(mapname, retries) \ - _dm_flush_map(mapname, DMFL_NEED_SYNC|DMFL_SUSPEND, retries) + dm_flush_map__(mapname, DMFL_NEED_SYNC|DMFL_SUSPEND, retries) int dm_flush_map_nopaths(const char * mapname, int deferred_remove); int dm_cancel_deferred_remove(struct multipath *mpp); int dm_flush_maps (int retries); @@ -210,4 +211,4 @@ int libmp_dm_task_run(struct dm_task *dmt); condlog(lvl, "%s: libdm task=%d error: %s", __func__, \ cmd, strerror(dm_task_get_errno(dmt))) \ -#endif /* _DEVMAPPER_H */ +#endif /* DEVMAPPER_H_INCLUDED */ diff --git a/libmultipath/dict.c b/libmultipath/dict.c index 546103f29..a06a6138a 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -568,7 +568,7 @@ def_find_multipaths_handler(struct config *conf, vector strvec, if (!buff) return 1; - for (i = FIND_MULTIPATHS_OFF; i < __FIND_MULTIPATHS_LAST; i++) { + for (i = FIND_MULTIPATHS_OFF; i < FIND_MULTIPATHS_LAST__; i++) { if (find_multipaths_optvals[i] != NULL && !strcmp(buff, find_multipaths_optvals[i])) { conf->find_multipaths = i; @@ -576,7 +576,7 @@ def_find_multipaths_handler(struct config *conf, vector strvec, } } - if (i >= __FIND_MULTIPATHS_LAST) { + if (i >= FIND_MULTIPATHS_LAST__) { if (strcmp(buff, "no") == 0 || strcmp(buff, "0") == 0) conf->find_multipaths = FIND_MULTIPATHS_OFF; else if (strcmp(buff, "yes") == 0 || strcmp(buff, "1") == 0) diff --git a/libmultipath/dict.h b/libmultipath/dict.h index e17945379..97c91c8e8 100644 --- a/libmultipath/dict.h +++ b/libmultipath/dict.h @@ -1,10 +1,7 @@ -#ifndef _DICT_H -#define _DICT_H +#ifndef DICT_H_INCLUDED +#define DICT_H_INCLUDED -#ifndef _VECTOR_H #include "vector.h" -#endif - #include "byteorder.h" struct strbuf; @@ -19,4 +16,4 @@ int print_dev_loss(struct strbuf *buff, unsigned long v); int print_off_int_undef(struct strbuf *buff, long v); int print_auto_resize(struct strbuf *buff, long v); int print_flush_on_last_del(struct strbuf *buff, long v); -#endif /* _DICT_H */ +#endif /* DICT_H_INCLUDED */ diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 380e0e959..e94705bf2 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -1336,14 +1336,14 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, vpd += 4; len = vpd_len - 4; - if ((err = __append_strbuf_str(&buf, (const char *)vpd, len)) < 0) + if ((err = append_strbuf_str__(&buf, (const char *)vpd, len)) < 0) return err; /* The input is 0-padded, make sure the length is correct */ truncate_strbuf(&buf, strlen(get_strbuf_str(&buf))); len = get_strbuf_len(&buf); if (type != '8') { - char *buffer = __get_strbuf_buf(&buf); + char *buffer = get_strbuf_buf__(&buf); for (i = 0; i < len; ++i) buffer[i] = tolower(buffer[i]); @@ -1357,7 +1357,7 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, return err; while (vpd && (p = memchr(vpd, ' ', vpd_len))) { p_len = p - vpd; - if ((err = __append_strbuf_str(&buf, (const char *)vpd, + if ((err = append_strbuf_str__(&buf, (const char *)vpd, p_len)) < 0) return err; vpd = p; @@ -1370,7 +1370,7 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, return err; } if (vpd_len > 0) { - if ((err = __append_strbuf_str(&buf, (const char *)vpd, + if ((err = append_strbuf_str__(&buf, (const char *)vpd, vpd_len)) < 0) return err; } @@ -1523,7 +1523,7 @@ get_vpd_sgio (int fd, int pg, int vend_id, char * str, int maxlen) } static int -scsi_sysfs_pathinfo (struct path *pp, const struct _vector *hwtable) +scsi_sysfs_pathinfo (struct path *pp, const struct vector_s *hwtable) { struct udev_device *parent; const char *attr_path = NULL; @@ -1594,7 +1594,7 @@ scsi_sysfs_pathinfo (struct path *pp, const struct _vector *hwtable) } static int -nvme_sysfs_pathinfo (struct path *pp, const struct _vector *hwtable) +nvme_sysfs_pathinfo (struct path *pp, const struct vector_s *hwtable) { struct udev_device *parent; const char *attr_path = NULL; @@ -1653,7 +1653,7 @@ nvme_sysfs_pathinfo (struct path *pp, const struct _vector *hwtable) } static int -ccw_sysfs_pathinfo (struct path *pp, const struct _vector *hwtable) +ccw_sysfs_pathinfo (struct path *pp, const struct vector_s *hwtable) { struct udev_device *parent; char attr_buff[NAME_SIZE]; @@ -1714,7 +1714,7 @@ ccw_sysfs_pathinfo (struct path *pp, const struct _vector *hwtable) } static int -cciss_sysfs_pathinfo (struct path *pp, const struct _vector *hwtable) +cciss_sysfs_pathinfo (struct path *pp, const struct vector_s *hwtable) { const char * attr_path = NULL; struct udev_device *parent; @@ -1872,7 +1872,7 @@ path_offline (struct path * pp) } static int -sysfs_pathinfo(struct path *pp, const struct _vector *hwtable) +sysfs_pathinfo(struct path *pp, const struct vector_s *hwtable) { int r = common_sysfs_pathinfo(pp); diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h index acd517928..c93abf1c2 100644 --- a/libmultipath/discovery.h +++ b/libmultipath/discovery.h @@ -1,5 +1,5 @@ -#ifndef DISCOVERY_H -#define DISCOVERY_H +#ifndef DISCOVERY_H_INCLUDED +#define DISCOVERY_H_INCLUDED #define SYSFS_PATH_SIZE 255 #define INQUIRY_CMDLEN 6 @@ -62,26 +62,26 @@ bool is_vpd_page_supported(int fd, int pg); * discovery bitmask */ enum discovery_mode { - __DI_SYSFS, - __DI_SERIAL, - __DI_CHECKER, - __DI_PRIO, - __DI_WWID, - __DI_BLACKLIST, - __DI_NOIO, - __DI_NOFALLBACK, + DI_SYSFS__, + DI_SERIAL__, + DI_CHECKER__, + DI_PRIO__, + DI_WWID__, + DI_BLACKLIST__, + DI_NOIO__, + DI_NOFALLBACK__, }; -#define DI_SYSFS (1 << __DI_SYSFS) -#define DI_SERIAL (1 << __DI_SERIAL) -#define DI_CHECKER (1 << __DI_CHECKER) -#define DI_PRIO (1 << __DI_PRIO) -#define DI_WWID (1 << __DI_WWID) -#define DI_BLACKLIST (1 << __DI_BLACKLIST) -#define DI_NOIO (1 << __DI_NOIO) /* Avoid IO on the device */ -#define DI_NOFALLBACK (1 << __DI_NOFALLBACK) /* do not allow wwid fallback */ +#define DI_SYSFS (1 << DI_SYSFS__) +#define DI_SERIAL (1 << DI_SERIAL__) +#define DI_CHECKER (1 << DI_CHECKER__) +#define DI_PRIO (1 << DI_PRIO__) +#define DI_WWID (1 << DI_WWID__) +#define DI_BLACKLIST (1 << DI_BLACKLIST__) +#define DI_NOIO (1 << DI_NOIO__) /* Avoid IO on the device */ +#define DI_NOFALLBACK (1 << DI_NOFALLBACK__) /* do not allow wwid fallback */ #define DI_ALL (DI_SYSFS | DI_SERIAL | DI_CHECKER | DI_PRIO | \ DI_WWID) -#endif /* DISCOVERY_H */ +#endif /* DISCOVERY_H_INCLUDED */ diff --git a/libmultipath/dm-generic.c b/libmultipath/dm-generic.c index 1b42fa0bc..e49f9bbf5 100644 --- a/libmultipath/dm-generic.c +++ b/libmultipath/dm-generic.c @@ -24,7 +24,7 @@ #include "config.h" #include "print.h" -static const struct _vector* +static const struct vector_s* dm_mp_get_pgs(const struct gen_multipath *gmp) { return vector_convert(NULL, gen_multipath_to_dm(gmp)->pg, @@ -33,12 +33,12 @@ dm_mp_get_pgs(const struct gen_multipath *gmp) static void dm_mp_rel_pgs(__attribute__((unused)) const struct gen_multipath *gmp, - const struct _vector* v) + const struct vector_s* v) { vector_free_const(v); } -static const struct _vector* +static const struct vector_s* dm_pg_get_paths(const struct gen_pathgroup *gpg) { return vector_convert(NULL, gen_pathgroup_to_dm(gpg)->paths, @@ -47,7 +47,7 @@ dm_pg_get_paths(const struct gen_pathgroup *gpg) static void dm_mp_rel_paths(__attribute__((unused)) const struct gen_pathgroup *gpg, - const struct _vector* v) + const struct vector_s* v) { vector_free_const(v); } diff --git a/libmultipath/dm-generic.h b/libmultipath/dm-generic.h index 986429f52..9055ce1ce 100644 --- a/libmultipath/dm-generic.h +++ b/libmultipath/dm-generic.h @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef _DM_GENERIC_H -#define _DM_GENERIC_H +#ifndef DM_GENERIC_H_INCLUDED +#define DM_GENERIC_H_INCLUDED #include "generic.h" #include "list.h" /* for container_of */ #include "structs.h" @@ -36,4 +36,4 @@ extern const struct gen_multipath_ops dm_gen_multipath_ops; extern const struct gen_pathgroup_ops dm_gen_pathgroup_ops; extern const struct gen_path_ops dm_gen_path_ops; -#endif /* _DM_GENERIC_H */ +#endif /* DM_GENERIC_H_INCLUDED */ diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c index 3d85e6eea..1d0506df8 100644 --- a/libmultipath/dmparser.c +++ b/libmultipath/dmparser.c @@ -117,7 +117,7 @@ int assemble_map(struct multipath *mp, char **params) * Call update_pathvec_from_dm() after this function to make sure * all data structures are in a sane state. */ -int disassemble_map(const struct _vector *pathvec, +int disassemble_map(const struct vector_s *pathvec, const char *params, struct multipath *mpp) { char * word; diff --git a/libmultipath/dmparser.h b/libmultipath/dmparser.h index 666ae74ed..181967b82 100644 --- a/libmultipath/dmparser.h +++ b/libmultipath/dmparser.h @@ -1,3 +1,8 @@ +#ifndef DMPARSER_H_INCLUDED +#define DMPARSER_H_INCLUDED + int assemble_map (struct multipath *, char **); -int disassemble_map (const struct _vector *, const char *, struct multipath *); +int disassemble_map (const struct vector_s *, const char *, struct multipath *); int disassemble_status (const char *, struct multipath *); + +#endif diff --git a/libmultipath/file.h b/libmultipath/file.h index 3c75c9050..57b517f66 100644 --- a/libmultipath/file.h +++ b/libmultipath/file.h @@ -2,8 +2,8 @@ * Copyright (c) 2010 Benjamin Marzinski, Redhat */ -#ifndef _FILE_H -#define _FILE_H +#ifndef FILE_H_INCLUDED +#define FILE_H_INCLUDED #include @@ -11,4 +11,4 @@ int ensure_directories_exist(const char *str, mode_t dir_mode); int open_file(const char *file, int *can_write, const char *header); -#endif /* _FILE_H */ +#endif /* FILE_H_INCLUDED */ diff --git a/libmultipath/foreign.c b/libmultipath/foreign.c index d01a5ef0c..28d1b1158 100644 --- a/libmultipath/foreign.c +++ b/libmultipath/foreign.c @@ -84,7 +84,7 @@ static void free_foreign(struct foreign *fgn) free(fgn); } -void _cleanup_foreign(void) +void cleanup_foreign__(void) { struct foreign *fgn; int i; @@ -103,7 +103,7 @@ void _cleanup_foreign(void) void cleanup_foreign(void) { wrlock_foreigns(); - _cleanup_foreign(); + cleanup_foreign__(); unlock_foreigns(NULL); } @@ -164,7 +164,7 @@ static int _init_foreign(const char *enable) r = -errno; condlog(1, "%s: error scanning foreign multipath libraries: %m", __func__); - _cleanup_foreign(); + cleanup_foreign__(); goto out_free_pre; } @@ -451,14 +451,14 @@ void foreign_path_layout(fieldwidth_t *width) pthread_cleanup_push(unlock_foreigns, NULL); vector_foreach_slot(foreigns, fgn, i) { - const struct _vector *vec; + const struct vector_s *vec; fgn->lock(fgn->context); pthread_cleanup_push(fgn->unlock, fgn->context); vec = fgn->get_paths(fgn->context); if (vec != NULL) { - _get_path_layout(vec, LAYOUT_RESET_NOT, width); + get_path_layout__(vec, LAYOUT_RESET_NOT, width); } fgn->release_paths(fgn->context, vec); @@ -482,14 +482,14 @@ void foreign_multipath_layout(fieldwidth_t *width) pthread_cleanup_push(unlock_foreigns, NULL); vector_foreach_slot(foreigns, fgn, i) { - const struct _vector *vec; + const struct vector_s *vec; fgn->lock(fgn->context); pthread_cleanup_push(fgn->unlock, fgn->context); vec = fgn->get_multipaths(fgn->context); if (vec != NULL) { - _get_multipath_layout(vec, LAYOUT_RESET_NOT, width); + get_multipath_layout__(vec, LAYOUT_RESET_NOT, width); } fgn->release_multipaths(fgn->context, vec); @@ -499,7 +499,7 @@ void foreign_multipath_layout(fieldwidth_t *width) pthread_cleanup_pop(1); } -static int __snprint_foreign_topology(struct strbuf *buf, int verbosity, +static int snprint_foreign_topology__(struct strbuf *buf, int verbosity, const fieldwidth_t *width) { struct foreign *fgn; @@ -507,7 +507,7 @@ static int __snprint_foreign_topology(struct strbuf *buf, int verbosity, size_t initial_len = get_strbuf_len(buf); vector_foreach_slot(foreigns, fgn, i) { - const struct _vector *vec; + const struct vector_s *vec; const struct gen_multipath *gm; int j; @@ -517,7 +517,7 @@ static int __snprint_foreign_topology(struct strbuf *buf, int verbosity, vec = fgn->get_multipaths(fgn->context); if (vec != NULL) { vector_foreach_slot(vec, gm, j) { - if (_snprint_multipath_topology( + if (snprint_multipath_topology__( gm, buf, verbosity, width) < 0) break; } @@ -540,7 +540,7 @@ int snprint_foreign_topology(struct strbuf *buf, int verbosity, return 0; } pthread_cleanup_push(unlock_foreigns, NULL); - rc = __snprint_foreign_topology(buf, verbosity, width); + rc = snprint_foreign_topology__(buf, verbosity, width); pthread_cleanup_pop(1); return rc; } @@ -561,16 +561,16 @@ void print_foreign_topology(int verbosity) } pthread_cleanup_push(unlock_foreigns, NULL); vector_foreach_slot(foreigns, fgn, i) { - const struct _vector *vec; + const struct vector_s *vec; fgn->lock(fgn->context); pthread_cleanup_push(fgn->unlock, fgn->context); vec = fgn->get_paths(fgn->context); - _get_multipath_layout(vec, LAYOUT_RESET_NOT, width); + get_multipath_layout__(vec, LAYOUT_RESET_NOT, width); fgn->release_paths(fgn->context, vec); pthread_cleanup_pop(1); } - __snprint_foreign_topology(&buf, verbosity, width); + snprint_foreign_topology__(&buf, verbosity, width); pthread_cleanup_pop(1); printf("%s", get_strbuf_str(&buf)); } @@ -590,7 +590,7 @@ int snprint_foreign_paths(struct strbuf *buf, const char *style, pthread_cleanup_push(unlock_foreigns, NULL); vector_foreach_slot(foreigns, fgn, i) { - const struct _vector *vec; + const struct vector_s *vec; const struct gen_path *gp; int j, ret = 0; @@ -600,7 +600,7 @@ int snprint_foreign_paths(struct strbuf *buf, const char *style, vec = fgn->get_paths(fgn->context); if (vec != NULL) { vector_foreach_slot(vec, gp, j) { - ret = _snprint_path(gp, buf, style, width); + ret = snprint_path__(gp, buf, style, width); if (ret < 0) break; } @@ -630,7 +630,7 @@ int snprint_foreign_multipaths(struct strbuf *buf, const char *style, pthread_cleanup_push(unlock_foreigns, NULL); vector_foreach_slot(foreigns, fgn, i) { - const struct _vector *vec; + const struct vector_s *vec; const struct gen_multipath *gm; int j, ret = 0; @@ -640,7 +640,7 @@ int snprint_foreign_multipaths(struct strbuf *buf, const char *style, vec = fgn->get_multipaths(fgn->context); if (vec != NULL) { vector_foreach_slot(vec, gm, j) { - ret = _snprint_multipath(gm, buf, + ret = snprint_multipath__(gm, buf, style, width); if (ret < 0) break; diff --git a/libmultipath/foreign.h b/libmultipath/foreign.h index b9cdb36e7..485fb2d85 100644 --- a/libmultipath/foreign.h +++ b/libmultipath/foreign.h @@ -14,8 +14,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef _FOREIGN_H -#define _FOREIGN_H +#ifndef FOREIGN_H_INCLUDED +#define FOREIGN_H_INCLUDED + #include #include #define LIBMP_FOREIGN_API ((1 << 8) | 2) @@ -31,7 +32,7 @@ enum foreign_retcode { FOREIGN_UNCLAIMED, FOREIGN_NODEV, FOREIGN_ERR, - __LAST_FOREIGN_RETCODE, + LAST_FOREIGN_RETCODE__, }; /** @@ -154,7 +155,7 @@ struct foreign { * @returns a vector of "struct gen_multipath*" with the map devices * belonging to this library (see generic.h). */ - const struct _vector* (*get_multipaths)(const struct context *); + const struct vector_s* (*get_multipaths)(const struct context *); /** * method: release_multipaths(context, mpvec) @@ -164,7 +165,7 @@ struct foreign { * @param[in] mpvec the vector allocated with get_multipaths() */ void (*release_multipaths)(const struct context *ctx, - const struct _vector* mpvec); + const struct vector_s* mpvec); /** * method: get_paths @@ -175,7 +176,7 @@ struct foreign { * @returns a vector of "struct gen_path*" with the path devices * belonging to this library (see generic.h) */ - const struct _vector* (*get_paths)(const struct context *); + const struct vector_s* (*get_paths)(const struct context *); /** * release data structures obtained with get_multipaths (if any) @@ -184,7 +185,7 @@ struct foreign { * @param[in] ppvec the vector allocated with get_paths() */ void (*release_paths)(const struct context *ctx, - const struct _vector* ppvec); + const struct vector_s* ppvec); void *handle; struct context *context; @@ -270,7 +271,7 @@ void foreign_multipath_layout(fieldwidth_t *width); * '\0' - terminated. * @param buf: output buffer * @param verbosity: verbosity level - * @param width: an array of field widths, initialized by _get_path_layout() + * @param width: an array of field widths, initialized by get_path_layout__() * @returns: number of printed characters excluding trailing '\0'. */ int snprint_foreign_topology(struct strbuf *buf, int verbosity, @@ -320,4 +321,4 @@ is_claimed_by_foreign(struct udev_device *ud) return (rc == FOREIGN_CLAIMED || rc == FOREIGN_OK); } -#endif /* _FOREIGN_H */ +#endif /* FOREIGN_H_INCLUDED */ diff --git a/libmultipath/foreign/nvme.c b/libmultipath/foreign/nvme.c index 6f2d8800c..0b7f4eabd 100644 --- a/libmultipath/foreign/nvme.c +++ b/libmultipath/foreign/nvme.c @@ -45,7 +45,7 @@ const char *THIS; struct nvme_map; struct nvme_pathgroup { struct gen_pathgroup gen; - struct _vector pathvec; + struct vector_s pathvec; }; struct nvme_path { @@ -66,7 +66,7 @@ struct nvme_map { struct udev_device *udev; struct udev_device *subsys; dev_t devt; - struct _vector pgvec; + struct vector_s pgvec; int nr_live; int ana_supported; }; @@ -114,7 +114,7 @@ static void cleanup_nvme_map(struct nvme_map *map) free(map); } -static const struct _vector* +static const struct vector_s* nvme_mp_get_pgs(const struct gen_multipath *gmp) { const struct nvme_map *nvme = const_gen_mp_to_nvme(gmp); @@ -124,7 +124,7 @@ nvme_mp_get_pgs(const struct gen_multipath *gmp) { static void nvme_mp_rel_pgs(__attribute__((unused)) const struct gen_multipath *gmp, - __attribute__((unused)) const struct _vector *v) + __attribute__((unused)) const struct vector_s *v) { /* empty */ } @@ -201,7 +201,7 @@ static int snprint_nvme_map(const struct gen_multipath *gmp, return append_strbuf_str(buff, N_A); } -static const struct _vector* +static const struct vector_s* nvme_pg_get_paths(const struct gen_pathgroup *gpg) { const struct nvme_pathgroup *gp = const_gen_pg_to_nvme(gpg); @@ -211,7 +211,7 @@ nvme_pg_get_paths(const struct gen_pathgroup *gpg) { static void nvme_pg_rel_paths(__attribute__((unused)) const struct gen_pathgroup *gpg, - __attribute__((unused)) const struct _vector *v) + __attribute__((unused)) const struct vector_s *v) { /* empty */ } @@ -891,7 +891,7 @@ int delete(struct context *ctx, struct udev_device *ud) return rc; } -void _check(struct context *ctx) +void check__(struct context *ctx) { struct gen_multipath *gm; int i; @@ -908,7 +908,7 @@ void check(struct context *ctx) condlog(4, "%s called for \"%s\"", __func__, THIS); lock(ctx); pthread_cleanup_push(unlock, ctx); - _check(ctx); + check__(ctx); pthread_cleanup_pop(1); return; } @@ -916,14 +916,14 @@ void check(struct context *ctx) /* * It's safe to pass our internal pointer, this is only used under the lock. */ -const struct _vector *get_multipaths(const struct context *ctx) +const struct vector_s *get_multipaths(const struct context *ctx) { condlog(5, "%s called for \"%s\"", __func__, THIS); return ctx->mpvec; } void release_multipaths(__attribute__((unused)) const struct context *ctx, - __attribute__((unused)) const struct _vector *mpvec) + __attribute__((unused)) const struct vector_s *mpvec) { condlog(5, "%s called for \"%s\"", __func__, THIS); /* NOP */ @@ -932,7 +932,7 @@ void release_multipaths(__attribute__((unused)) const struct context *ctx, /* * It's safe to pass our internal pointer, this is only used under the lock. */ -const struct _vector * get_paths(const struct context *ctx) +const struct vector_s * get_paths(const struct context *ctx) { vector paths = NULL; const struct gen_multipath *gm; @@ -948,25 +948,25 @@ const struct _vector * get_paths(const struct context *ctx) } void release_paths(__attribute__((unused)) const struct context *ctx, - const struct _vector *mpvec) + const struct vector_s *mpvec) { condlog(5, "%s called for \"%s\"", __func__, THIS); vector_free_const(mpvec); } /* compile-time check whether all methods are present and correctly typed */ -#define _METHOD_INIT(x) .x = x +#define METHOD_INIT(x) .x = x static struct foreign __methods __attribute__((unused)) = { - _METHOD_INIT(init), - _METHOD_INIT(cleanup), - _METHOD_INIT(change), - _METHOD_INIT(delete), - _METHOD_INIT(delete_all), - _METHOD_INIT(check), - _METHOD_INIT(lock), - _METHOD_INIT(unlock), - _METHOD_INIT(get_multipaths), - _METHOD_INIT(release_multipaths), - _METHOD_INIT(get_paths), - _METHOD_INIT(release_paths), + METHOD_INIT(init), + METHOD_INIT(cleanup), + METHOD_INIT(change), + METHOD_INIT(delete), + METHOD_INIT(delete_all), + METHOD_INIT(check), + METHOD_INIT(lock), + METHOD_INIT(unlock), + METHOD_INIT(get_multipaths), + METHOD_INIT(release_multipaths), + METHOD_INIT(get_paths), + METHOD_INIT(release_paths), }; diff --git a/libmultipath/generic.h b/libmultipath/generic.h index e89848f37..2e4673bea 100644 --- a/libmultipath/generic.h +++ b/libmultipath/generic.h @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef _GENERIC_H -#define _GENERIC_H +#ifndef GENERIC_H_INCLUDED +#define GENERIC_H_INCLUDED #include "vector.h" /* @@ -43,7 +43,7 @@ struct gen_multipath_ops { * @param gmp: generic multipath object to act on * @returns a vector of const struct gen_pathgroup* */ - const struct _vector* (*get_pathgroups)(const struct gen_multipath*); + const struct vector_s* (*get_pathgroups)(const struct gen_multipath*); /** * method: rel_pathgroups(gmp, v) * free data allocated by get_pathgroups(), if any @@ -51,7 +51,7 @@ struct gen_multipath_ops { * @param v the value returned by get_pathgroups() */ void (*rel_pathgroups)(const struct gen_multipath*, - const struct _vector*); + const struct vector_s*); /** * method: snprint(gmp, buf, len, wildcard) * prints the property of the multipath map matching @@ -89,14 +89,14 @@ struct gen_pathgroup_ops { * @param gpg: generic pathgroup object to act on * @returns a vector of const struct gen_path* */ - const struct _vector* (*get_paths)(const struct gen_pathgroup*); + const struct vector_s* (*get_paths)(const struct gen_pathgroup*); /** * method: rel_paths(gpg, v) * free data allocated by get_paths(), if any * @param gmp: generic pathgroup object to act on * @param v the value returned by get_paths() */ - void (*rel_paths)(const struct gen_pathgroup*, const struct _vector*); + void (*rel_paths)(const struct gen_pathgroup*, const struct vector_s*); /** * Method snprint() * see gen_multipath_ops->snprint() above @@ -138,4 +138,4 @@ struct gen_path { int generic_style(const struct gen_multipath*, struct strbuf *buf, int verbosity); -#endif /* _GENERIC_H */ +#endif /* GENERIC_H_INCLUDED */ diff --git a/libmultipath/hwtable.h b/libmultipath/hwtable.h index 13c570119..737e821c7 100644 --- a/libmultipath/hwtable.h +++ b/libmultipath/hwtable.h @@ -1,6 +1,6 @@ -#ifndef _HWTABLE_H -#define _HWTABLE_H +#ifndef HWTABLE_H_INCLUDED +#define HWTABLE_H_INCLUDED int setup_default_hwtable (vector hw); -#endif /* _HWTABLE_H */ +#endif /* HWTABLE_H_INCLUDED */ diff --git a/libmultipath/io_err_stat.c b/libmultipath/io_err_stat.c index 1c5944517..4996c0b04 100644 --- a/libmultipath/io_err_stat.c +++ b/libmultipath/io_err_stat.c @@ -619,9 +619,9 @@ static void process_async_ios_event(int timeout_nsecs, char *dev) static void service_paths(void) { - struct _vector _pathvec = { .allocated = 0 }; + struct vector_s _pathvec = { .allocated = 0 }; /* avoid gcc warnings that &_pathvec will never be NULL in vector ops */ - struct _vector * const tmp_pathvec = &_pathvec; + struct vector_s * const tmp_pathvec = &_pathvec; struct io_err_stat_path *pp; int i; diff --git a/libmultipath/io_err_stat.h b/libmultipath/io_err_stat.h index 53d6d7deb..8dc298b50 100644 --- a/libmultipath/io_err_stat.h +++ b/libmultipath/io_err_stat.h @@ -1,5 +1,5 @@ -#ifndef _IO_ERR_STAT_H -#define _IO_ERR_STAT_H +#ifndef IO_ERR_STAT_H_INCLUDED +#define IO_ERR_STAT_H_INCLUDED #include "vector.h" #include "lock.h" @@ -12,4 +12,4 @@ void stop_io_err_stat_thread(void); int io_err_stat_handle_pathfail(struct path *path); int need_io_err_check(struct path *pp); -#endif /* _IO_ERR_STAT_H */ +#endif /* IO_ERR_STAT_H_INCLUDED */ diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version index 0ec45271a..21d48da6a 100644 --- a/libmultipath/libmultipath.version +++ b/libmultipath/libmultipath.version @@ -43,7 +43,7 @@ LIBMPATHCOMMON_1.0.0 { put_multipath_config; }; -LIBMULTIPATH_25.0.0 { +LIBMULTIPATH_26.0.0 { global: /* symbols referenced by multipath and multipathd */ add_foreign; @@ -74,7 +74,8 @@ global: dm_cancel_deferred_remove; dm_enablegroup; dm_fail_path; - _dm_flush_map; + dm_find_map_by_wwid; + dm_flush_map__; dm_flush_map_nopaths; dm_flush_maps; dm_geteventnr; @@ -148,7 +149,7 @@ global: path_offline; print_all_paths; print_foreign_topology; - _print_multipath_topology; + print_multipath_topology__; reinstate_paths; remember_wwid; remove_feature; @@ -172,18 +173,18 @@ global: should_multipath; skip_libmp_dm_init; snprint_blacklist_report; - __snprint_config; + snprint_config__; snprint_config; snprint_devices; snprint_foreign_multipaths; snprint_foreign_paths; snprint_foreign_topology; - _snprint_multipath; + snprint_multipath__; snprint_multipath_header; snprint_multipath_map_json; - _snprint_multipath_topology; + snprint_multipath_topology__; snprint_multipath_topology_json; - _snprint_path; + snprint_path__; snprint_path_header; snprint_status; snprint_wildcards; @@ -241,8 +242,3 @@ global: local: *; }; - -LIBMULTIPATH_25.1.0 { -global: - dm_find_map_by_wwid; -} LIBMULTIPATH_25.0.0; diff --git a/libmultipath/libsg.h b/libmultipath/libsg.h index 3994f458c..76eb30d47 100644 --- a/libmultipath/libsg.h +++ b/libmultipath/libsg.h @@ -1,9 +1,9 @@ -#ifndef _LIBSG_H -#define _LIBSG_H +#ifndef LIBSG_H_INCLUDED +#define LIBSG_H_INCLUDED #define SENSE_BUFF_LEN 32 int sg_read (int sg_fd, unsigned char * buff, int buff_len, unsigned char * sense, int sense_len, unsigned int timeout); -#endif /* _LIBSG_H */ +#endif /* LIBSG_H_INCLUDED */ diff --git a/libmultipath/list.h b/libmultipath/list.h index 248f72bc4..8f485209e 100644 --- a/libmultipath/list.h +++ b/libmultipath/list.h @@ -5,8 +5,8 @@ * */ -#ifndef _LIST_H -#define _LIST_H +#ifndef LIST_H_INCLUDED +#define LIST_H_INCLUDED #include @@ -415,4 +415,4 @@ static inline struct list_head *list_pop(struct list_head *head) &pos->member != (to); \ pos = n, n = list_entry(n->member.prev, typeof(*n), member)) -#endif /* _LIST_H */ +#endif /* LIST_H_INCLUDED */ diff --git a/libmultipath/lock.c b/libmultipath/lock.c index 93b48dbbd..4d18d82cd 100644 --- a/libmultipath/lock.c +++ b/libmultipath/lock.c @@ -5,7 +5,7 @@ void cleanup_lock (void * data) struct mutex_lock *lock = data; wakeup_fn *fn = lock->wakeup; - __unlock(lock); + unlock__(lock); if (fn) fn(); } @@ -14,5 +14,5 @@ void set_wakeup_fn(struct mutex_lock *lck, wakeup_fn *fn) { lock(lck); lck->wakeup = fn; - __unlock(lck); + unlock__(lck); } diff --git a/libmultipath/lock.h b/libmultipath/lock.h index ac80d1d85..38473a8cd 100644 --- a/libmultipath/lock.h +++ b/libmultipath/lock.h @@ -1,5 +1,5 @@ -#ifndef _LOCK_H -#define _LOCK_H +#ifndef LOCK_H_INCLUDED +#define LOCK_H_INCLUDED #include #include @@ -50,7 +50,7 @@ static inline int timedlock(struct mutex_lock *a, struct timespec *tmo) return pthread_mutex_timedlock(&a->mutex, tmo); } -static inline void __unlock(struct mutex_lock *a) +static inline void unlock__(struct mutex_lock *a) { pthread_mutex_unlock(&a->mutex); } @@ -65,4 +65,4 @@ static inline bool lock_has_waiters(struct mutex_lock *a) void cleanup_lock (void * data); void set_wakeup_fn(struct mutex_lock *lock, wakeup_fn *fn); -#endif /* _LOCK_H */ +#endif /* LOCK_H_INCLUDED */ diff --git a/libmultipath/nvme-lib.c b/libmultipath/nvme-lib.c index f30e7698e..0c2be4f63 100644 --- a/libmultipath/nvme-lib.c +++ b/libmultipath/nvme-lib.c @@ -1,6 +1,6 @@ #include /* avoid inclusion of standard API */ -#define _NVME_LIB_C 1 +#define NVME_LIB_C 1 #include "nvme-lib.h" #include "nvme-ioctl.c" #include "debug.h" diff --git a/libmultipath/nvme-lib.h b/libmultipath/nvme-lib.h index 448dd9939..6aa9bd223 100644 --- a/libmultipath/nvme-lib.h +++ b/libmultipath/nvme-lib.h @@ -1,5 +1,5 @@ -#ifndef NVME_LIB_H -#define NVME_LIB_H +#ifndef NVME_LIB_H_INCLUDED +#define NVME_LIB_H_INCLUDED #include "nvme.h" @@ -16,7 +16,7 @@ int libmp_nvme_ana_log(int fd, void *ana_log, size_t ana_log_len, int rgo); */ int nvme_id_ctrl_ana(int fd, struct nvme_id_ctrl *ctrl); -#ifndef _NVME_LIB_C +#ifndef NVME_LIB_C /* * In all files except nvme-lib.c, the nvme functions can be called * by their usual name. @@ -36,4 +36,4 @@ int nvme_id_ctrl_ana(int fd, struct nvme_id_ctrl *ctrl); #undef le64_to_cpu #endif -#endif /* NVME_LIB_H */ +#endif /* NVME_LIB_H_INCLUDED */ diff --git a/libmultipath/nvme/argconfig.h b/libmultipath/nvme/argconfig.h index adb192b6a..e6c544534 100644 --- a/libmultipath/nvme/argconfig.h +++ b/libmultipath/nvme/argconfig.h @@ -30,8 +30,8 @@ // //////////////////////////////////////////////////////////////////////// -#ifndef argconfig_H -#define argconfig_H +#ifndef NVME_ARGCONFIG_H_INCLUDED +#define NVME_ARGCONFIG_H_INCLUDED #include #include diff --git a/libmultipath/nvme/json.h b/libmultipath/nvme/json.h index c4ea53160..70df52851 100644 --- a/libmultipath/nvme/json.h +++ b/libmultipath/nvme/json.h @@ -1,5 +1,5 @@ -#ifndef __JSON__H -#define __JSON__H +#ifndef NVME_JSON_H_INCLUDED +#define NVME_JSON_H_INCLUDED struct json_object; struct json_array; diff --git a/libmultipath/nvme/linux/nvme.h b/libmultipath/nvme/linux/nvme.h index 9fc2ae7fa..f0cb29055 100644 --- a/libmultipath/nvme/linux/nvme.h +++ b/libmultipath/nvme/linux/nvme.h @@ -12,8 +12,8 @@ * more details. */ -#ifndef _LINUX_NVME_H -#define _LINUX_NVME_H +#ifndef LINUX_NVME_H_INCLUDED +#define LINUX_NVME_H_INCLUDED #include #include @@ -1525,4 +1525,4 @@ struct nvme_completion { #define NVME_MINOR(ver) (((ver) >> 8) & 0xff) #define NVME_TERTIARY(ver) ((ver) & 0xff) -#endif /* _LINUX_NVME_H */ +#endif /* LINUX_NVME_H_INCLUDED */ diff --git a/libmultipath/nvme/linux/nvme_ioctl.h b/libmultipath/nvme/linux/nvme_ioctl.h index d25a53225..3f6623c89 100644 --- a/libmultipath/nvme/linux/nvme_ioctl.h +++ b/libmultipath/nvme/linux/nvme_ioctl.h @@ -12,8 +12,8 @@ * more details. */ -#ifndef _UAPI_LINUX_NVME_IOCTL_H -#define _UAPI_LINUX_NVME_IOCTL_H +#ifndef LINUX_NVME_IOCTL_H_INCLUDED +#define LINUX_NVME_IOCTL_H_INCLUDED #include #include @@ -64,4 +64,4 @@ struct nvme_passthru_cmd { #define NVME_IOCTL_SUBSYS_RESET _IO('N', 0x45) #define NVME_IOCTL_RESCAN _IO('N', 0x46) -#endif /* _UAPI_LINUX_NVME_IOCTL_H */ +#endif /* LINUX_NVME_IOCTL_H_INCLUDED */ diff --git a/libmultipath/nvme/nvme-ioctl.h b/libmultipath/nvme/nvme-ioctl.h index 565f7648e..246f02e0a 100644 --- a/libmultipath/nvme/nvme-ioctl.h +++ b/libmultipath/nvme/nvme-ioctl.h @@ -1,5 +1,5 @@ -#ifndef _NVME_LIB_H -#define _NVME_LIB_H +#ifndef NVME_NVME_IOCTL_H_INCLUDED +#define NVME_NVME_IOCTL_H_INCLUDED #include #include @@ -155,4 +155,4 @@ int nvme_sanitize(int fd, __u8 sanact, __u8 ause, __u8 owpass, __u8 oipbp, int nvme_self_test_start(int fd, __u32 nsid, __u32 cdw10); int nvme_self_test_log(int fd, struct nvme_self_test_log *self_test_log); int nvme_virtual_mgmt(int fd, __u32 cdw10, __u32 cdw11, __u32 *result); -#endif /* _NVME_LIB_H */ +#endif /* NVME_NVME_IOCTL_H_INCLUDED */ diff --git a/libmultipath/nvme/nvme.h b/libmultipath/nvme/nvme.h index 57f82a311..019bce1bf 100644 --- a/libmultipath/nvme/nvme.h +++ b/libmultipath/nvme/nvme.h @@ -12,8 +12,8 @@ * more details. */ -#ifndef _NVME_H -#define _NVME_H +#ifndef NVME_NVME_H_INCLUDED +#define NVME_NVME_H_INCLUDED #include #include @@ -237,4 +237,4 @@ static inline bool is_64bit_reg(__u32 offset) return false; } -#endif /* _NVME_H */ +#endif /* NVME_NVME_H_INCLUDED */ diff --git a/libmultipath/nvme/plugin.h b/libmultipath/nvme/plugin.h index 91079fbec..6f12946b2 100644 --- a/libmultipath/nvme/plugin.h +++ b/libmultipath/nvme/plugin.h @@ -1,5 +1,5 @@ -#ifndef PLUGIN_H -#define PLUGIN_H +#ifndef NVME_PLUGIN_H_INCLUDED +#define NVME_PLUGIN_H_INCLUDED #include diff --git a/libmultipath/pgpolicies.h b/libmultipath/pgpolicies.h index 9e4ddda25..c1983e18f 100644 --- a/libmultipath/pgpolicies.h +++ b/libmultipath/pgpolicies.h @@ -1,11 +1,5 @@ -#ifndef _PGPOLICIES_H -#define _PGPOLICIES_H - -#if 0 -#ifndef _MAIN_H -#include "main.h" -#endif -#endif +#ifndef PGPOLICIES_H_INCLUDED +#define PGPOLICIES_H_INCLUDED #define POLICY_NAME_SIZE 32 diff --git a/libmultipath/print.c b/libmultipath/print.c index b7af91379..e536c5c09 100644 --- a/libmultipath/print.c +++ b/libmultipath/print.c @@ -575,7 +575,7 @@ static int snprint_initialized(struct strbuf *buff, const struct path * pp) }; const char *str; - if (pp->initialized < INIT_NEW || pp->initialized >= __INIT_LAST) + if (pp->initialized < INIT_NEW || pp->initialized >= INIT_LAST__) str = "undef"; else str = init_state_name[pp->initialized]; @@ -924,7 +924,7 @@ void get_path_layout(vector pathvec, int header, fieldwidth_t *width) { vector gpvec = vector_convert(NULL, pathvec, struct path, dm_path_to_gen); - _get_path_layout(gpvec, + get_path_layout__(gpvec, header ? LAYOUT_RESET_HEADER : LAYOUT_RESET_ZERO, width); vector_free(gpvec); @@ -946,7 +946,7 @@ reset_width(fieldwidth_t *width, enum layout_reset reset, const char *header) } } -void _get_path_layout (const struct _vector *gpvec, enum layout_reset reset, +void get_path_layout__ (const struct vector_s *gpvec, enum layout_reset reset, fieldwidth_t *width) { unsigned int i, j; @@ -980,14 +980,14 @@ fieldwidth_t *alloc_multipath_layout(void) { void get_multipath_layout (vector mpvec, int header, fieldwidth_t *width) { vector gmvec = vector_convert(NULL, mpvec, struct multipath, dm_multipath_to_gen); - _get_multipath_layout(gmvec, + get_multipath_layout__(gmvec, header ? LAYOUT_RESET_HEADER : LAYOUT_RESET_ZERO, width); vector_free(gmvec); } void -_get_multipath_layout (const struct _vector *gmvec, enum layout_reset reset, +get_multipath_layout__ (const struct vector_s *gmvec, enum layout_reset reset, fieldwidth_t *width) { unsigned int i, j; @@ -1090,7 +1090,7 @@ int snprint_multipath_header(struct strbuf *line, const char *format, for (f = strchr(format, '%'); f; f = strchr(++format, '%')) { int iwc; - if ((rc = __append_strbuf_str(line, format, f - format)) < 0) + if ((rc = append_strbuf_str__(line, format, f - format)) < 0) return rc; format = f + 1; @@ -1110,7 +1110,7 @@ int snprint_multipath_header(struct strbuf *line, const char *format, return get_strbuf_len(line) - initial_len; } -int _snprint_multipath(const struct gen_multipath *gmp, +int snprint_multipath__(const struct gen_multipath *gmp, struct strbuf *line, const char *format, const fieldwidth_t *width) { @@ -1121,7 +1121,7 @@ int _snprint_multipath(const struct gen_multipath *gmp, for (f = strchr(format, '%'); f; f = strchr(++format, '%')) { int iwc; - if ((rc = __append_strbuf_str(line, format, f - format)) < 0) + if ((rc = append_strbuf_str__(line, format, f - format)) < 0) return rc; format = f + 1; @@ -1151,7 +1151,7 @@ int snprint_path_header(struct strbuf *line, const char *format, for (f = strchr(format, '%'); f; f = strchr(++format, '%')) { int iwc; - if ((rc = __append_strbuf_str(line, format, f - format)) < 0) + if ((rc = append_strbuf_str__(line, format, f - format)) < 0) return rc; format = f + 1; @@ -1171,7 +1171,7 @@ int snprint_path_header(struct strbuf *line, const char *format, return get_strbuf_len(line) - initial_len; } -int _snprint_path(const struct gen_path *gp, struct strbuf *line, +int snprint_path__(const struct gen_path *gp, struct strbuf *line, const char *format, const fieldwidth_t *width) { int initial_len = get_strbuf_len(line); @@ -1181,7 +1181,7 @@ int _snprint_path(const struct gen_path *gp, struct strbuf *line, for (f = strchr(format, '%'); f; f = strchr(++format, '%')) { int iwc; - if ((rc = __append_strbuf_str(line, format, f - format)) < 0) + if ((rc = append_strbuf_str__(line, format, f - format)) < 0) return rc; format = f + 1; @@ -1200,7 +1200,7 @@ int _snprint_path(const struct gen_path *gp, struct strbuf *line, return get_strbuf_len(line) - initial_len; } -int _snprint_pathgroup(const struct gen_pathgroup *ggp, struct strbuf *line, +int snprint_pathgroup__(const struct gen_pathgroup *ggp, struct strbuf *line, const char *format) { int initial_len = get_strbuf_len(line); @@ -1208,7 +1208,7 @@ int _snprint_pathgroup(const struct gen_pathgroup *ggp, struct strbuf *line, int rc; for (f = strchr(format, '%'); f; f = strchr(++format, '%')) { - if ((rc = __append_strbuf_str(line, format, f - format)) < 0) + if ((rc = append_strbuf_str__(line, format, f - format)) < 0) return rc; format = f + 1; @@ -1223,14 +1223,14 @@ int _snprint_pathgroup(const struct gen_pathgroup *ggp, struct strbuf *line, } #define snprint_pathgroup(line, fmt, pgp) \ - _snprint_pathgroup(dm_pathgroup_to_gen(pgp), line, fmt) + snprint_pathgroup__(dm_pathgroup_to_gen(pgp), line, fmt) -void _print_multipath_topology(const struct gen_multipath *gmp, int verbosity) +void print_multipath_topology__(const struct gen_multipath *gmp, int verbosity) { STRBUF_ON_STACK(buff); fieldwidth_t *p_width __attribute__((cleanup(cleanup_ucharp))) = NULL; const struct gen_pathgroup *gpg; - const struct _vector *pgvec, *pathvec; + const struct vector_s *pgvec, *pathvec; int j; p_width = alloc_path_layout(); @@ -1241,13 +1241,13 @@ void _print_multipath_topology(const struct gen_multipath *gmp, int verbosity) pathvec = gpg->ops->get_paths(gpg); if (pathvec == NULL) continue; - _get_path_layout(pathvec, LAYOUT_RESET_NOT, p_width); + get_path_layout__(pathvec, LAYOUT_RESET_NOT, p_width); gpg->ops->rel_paths(gpg, pathvec); } gmp->ops->rel_pathgroups(gmp, pgvec); } - _snprint_multipath_topology(gmp, &buff, verbosity, p_width); + snprint_multipath_topology__(gmp, &buff, verbosity, p_width); printf("%s", get_strbuf_str(&buff)); } @@ -1266,12 +1266,12 @@ int snprint_multipath_style(const struct gen_multipath *gmp, need_wwid ? " (%w)" : "", " %d %s"); } -int _snprint_multipath_topology(const struct gen_multipath *gmp, +int snprint_multipath_topology__(const struct gen_multipath *gmp, struct strbuf *buff, int verbosity, const fieldwidth_t *p_width) { int j, i, rc; - const struct _vector *pgvec; + const struct vector_s *pgvec; const struct gen_pathgroup *gpg; STRBUF_ON_STACK(style); size_t initial_len = get_strbuf_len(buff); @@ -1284,7 +1284,7 @@ int _snprint_multipath_topology(const struct gen_multipath *gmp, return -ENOMEM; if (verbosity == 1) - return _snprint_multipath(gmp, buff, "%n", width); + return snprint_multipath__(gmp, buff, "%n", width); if(isatty(1) && (rc = print_strbuf(&style, "%c[%dm", 0x1B, 1)) < 0) /* bold on */ @@ -1295,8 +1295,8 @@ int _snprint_multipath_topology(const struct gen_multipath *gmp, (rc = print_strbuf(&style, "%c[%dm", 0x1B, 0)) < 0) /* bold off */ return rc; - if ((rc = _snprint_multipath(gmp, buff, get_strbuf_str(&style), width)) < 0 - || (rc = _snprint_multipath(gmp, buff, PRINT_MAP_PROPS, width)) < 0) + if ((rc = snprint_multipath__(gmp, buff, get_strbuf_str(&style), width)) < 0 + || (rc = snprint_multipath__(gmp, buff, PRINT_MAP_PROPS, width)) < 0) return rc; pgvec = gmp->ops->get_pathgroups(gmp); @@ -1304,13 +1304,13 @@ int _snprint_multipath_topology(const struct gen_multipath *gmp, goto out; vector_foreach_slot (pgvec, gpg, j) { - const struct _vector *pathvec; + const struct vector_s *pathvec; struct gen_path *gp; bool last_group = j + 1 == VECTOR_SIZE(pgvec); if ((rc = print_strbuf(buff, "%c-+- ", last_group ? '`' : '|')) < 0 || - (rc = _snprint_pathgroup(gpg, buff, PRINT_PG_INDENT)) < 0) + (rc = snprint_pathgroup__(gpg, buff, PRINT_PG_INDENT)) < 0) return rc; pathvec = gpg->ops->get_paths(gpg); @@ -1322,7 +1322,7 @@ int _snprint_multipath_topology(const struct gen_multipath *gmp, last_group ? ' ' : '|', i + 1 == VECTOR_SIZE(pathvec) ? '`': '|')) < 0 || - (rc = _snprint_path(gp, buff, + (rc = snprint_path__(gp, buff, PRINT_PATH_INDENT, p_width)) < 0) return rc; } @@ -1482,7 +1482,7 @@ snprint_pcentry (const struct config *conf, struct strbuf *buff, static int snprint_pctable (const struct config *conf, struct strbuf *buff, - const struct _vector *pctable) + const struct vector_s *pctable) { int i, rc; struct pcentry *pce; @@ -1526,7 +1526,7 @@ snprint_hwentry (const struct config *conf, } static int snprint_hwtable(const struct config *conf, struct strbuf *buff, - const struct _vector *hwtable) + const struct vector_s *hwtable) { int i, rc; struct hwentry * hwe; @@ -1552,7 +1552,7 @@ static int snprint_hwtable(const struct config *conf, struct strbuf *buff, static int snprint_mpentry (const struct config *conf, struct strbuf *buff, - const struct mpentry * mpe, const struct _vector *mpvec) + const struct mpentry * mpe, const struct vector_s *mpvec) { int i, rc; struct keyword * kw; @@ -1587,7 +1587,7 @@ snprint_mpentry (const struct config *conf, struct strbuf *buff, } static int snprint_mptable(const struct config *conf, struct strbuf *buff, - const struct _vector *mpvec) + const struct vector_s *mpvec) { int i, rc; struct mpentry * mpe; @@ -1908,8 +1908,8 @@ static int snprint_blacklist_except(const struct config *conf, return get_strbuf_len(buff) - initial_len; } -int __snprint_config(const struct config *conf, struct strbuf *buff, - const struct _vector *hwtable, const struct _vector *mpvec) +int snprint_config__(const struct config *conf, struct strbuf *buff, + const struct vector_s *hwtable, const struct vector_s *mpvec) { int rc; @@ -1930,11 +1930,11 @@ int __snprint_config(const struct config *conf, struct strbuf *buff, } char *snprint_config(const struct config *conf, int *len, - const struct _vector *hwtable, const struct _vector *mpvec) + const struct vector_s *hwtable, const struct vector_s *mpvec) { STRBUF_ON_STACK(buff); char *reply; - int rc = __snprint_config(conf, &buff, hwtable, mpvec); + int rc = snprint_config__(conf, &buff, hwtable, mpvec); if (rc < 0) return NULL; diff --git a/libmultipath/print.h b/libmultipath/print.h index 52f5b2566..489f1e7a5 100644 --- a/libmultipath/print.h +++ b/libmultipath/print.h @@ -1,5 +1,5 @@ -#ifndef _PRINT_H -#define _PRINT_H +#ifndef PRINT_H_INCLUDED +#define PRINT_H_INCLUDED #include "dm-generic.h" #define PRINT_PATH_CHECKER "%i %d %D %p %t %T %o %C" @@ -17,34 +17,34 @@ enum layout_reset { /* fieldwidth_t is defined in generic.h */ fieldwidth_t *alloc_path_layout(void); -void _get_path_layout (const struct _vector *gpvec, enum layout_reset, +void get_path_layout__ (const struct vector_s *gpvec, enum layout_reset, fieldwidth_t *width); void get_path_layout (vector pathvec, int header, fieldwidth_t *width); fieldwidth_t *alloc_multipath_layout(void); -void _get_multipath_layout (const struct _vector *gmvec, enum layout_reset, +void get_multipath_layout__ (const struct vector_s *gmvec, enum layout_reset, fieldwidth_t *width); void get_multipath_layout (vector mpvec, int header, fieldwidth_t *width); int snprint_path_header(struct strbuf *, const char *, const fieldwidth_t *); int snprint_multipath_header(struct strbuf *, const char *, const fieldwidth_t *); -int _snprint_path (const struct gen_path *, struct strbuf *, const char *, +int snprint_path__ (const struct gen_path *, struct strbuf *, const char *, const fieldwidth_t *); #define snprint_path(buf, fmt, pp, w) \ - _snprint_path(dm_path_to_gen(pp), buf, fmt, w) -int _snprint_multipath (const struct gen_multipath *, struct strbuf *, + snprint_path__(dm_path_to_gen(pp), buf, fmt, w) +int snprint_multipath__ (const struct gen_multipath *, struct strbuf *, const char *, const fieldwidth_t *); #define snprint_multipath(buf, fmt, mp, w) \ - _snprint_multipath(dm_multipath_to_gen(mp), buf, fmt, w) -int _snprint_multipath_topology (const struct gen_multipath *, struct strbuf *, + snprint_multipath__(dm_multipath_to_gen(mp), buf, fmt, w) +int snprint_multipath_topology__ (const struct gen_multipath *, struct strbuf *, int verbosity, const fieldwidth_t *); #define snprint_multipath_topology(buf, mpp, v, w) \ - _snprint_multipath_topology (dm_multipath_to_gen(mpp), buf, v, w) + snprint_multipath_topology__ (dm_multipath_to_gen(mpp), buf, v, w) int snprint_multipath_topology_json(struct strbuf *, const struct vectors *vecs); -int __snprint_config(const struct config *conf, struct strbuf *buff, - const struct _vector *hwtable, const struct _vector *mpvec); +int snprint_config__(const struct config *conf, struct strbuf *buff, + const struct vector_s *hwtable, const struct vector_s *mpvec); char *snprint_config(const struct config *conf, int *len, - const struct _vector *hwtable, - const struct _vector *mpvec); + const struct vector_s *hwtable, + const struct vector_s *mpvec); int snprint_multipath_map_json(struct strbuf *, const struct multipath *mpp); int snprint_blacklist_report(struct config *, struct strbuf *); int snprint_wildcards(struct strbuf *); @@ -58,10 +58,10 @@ int snprint_tgt_wwpn(struct strbuf *, const struct path *); #define PROTOCOL_BUF_SIZE sizeof("scsi:unspec") int snprint_path_protocol(struct strbuf *, const struct path *); -void _print_multipath_topology (const struct gen_multipath * gmp, +void print_multipath_topology__ (const struct gen_multipath * gmp, int verbosity); #define print_multipath_topology(mpp, v) \ - _print_multipath_topology(dm_multipath_to_gen(mpp), v) + print_multipath_topology__(dm_multipath_to_gen(mpp), v) void print_all_paths (vector pathvec, int banner); @@ -73,4 +73,4 @@ int snprint_multipath_attr(const struct gen_multipath* gm, struct strbuf *buf, char wildcard); int snprint_multipath_style(const struct gen_multipath *gmp, struct strbuf *style, int verbosity); -#endif /* _PRINT_H */ +#endif /* PRINT_H_INCLUDED */ diff --git a/libmultipath/prio.h b/libmultipath/prio.h index 318d26088..119b75f25 100644 --- a/libmultipath/prio.h +++ b/libmultipath/prio.h @@ -1,5 +1,5 @@ -#ifndef _PRIO_H -#define _PRIO_H +#ifndef PRIO_H_INCLUDED +#define PRIO_H_INCLUDED /* * knowing about path struct gives flexibility to prioritizers @@ -67,4 +67,4 @@ int prio_set_args (struct prio *, const char *); /* The only function exported by prioritizer dynamic libraries (.so) */ int getprio(struct path *, char *); -#endif /* _PRIO_H */ +#endif /* PRIO_H_INCLUDED */ diff --git a/libmultipath/prioritizers/alua.h b/libmultipath/prioritizers/alua.h index 78a3d1554..88fd6af4e 100644 --- a/libmultipath/prioritizers/alua.h +++ b/libmultipath/prioritizers/alua.h @@ -1,5 +1,5 @@ -#ifndef _ALUA_H -#define _ALUA_H +#ifndef ALUA_H_INCLUDED +#define ALUA_H_INCLUDED #include "alua_rtpg.h" diff --git a/libmultipath/prioritizers/alua_rtpg.c b/libmultipath/prioritizers/alua_rtpg.c index dd2224c42..e53f44751 100644 --- a/libmultipath/prioritizers/alua_rtpg.c +++ b/libmultipath/prioritizers/alua_rtpg.c @@ -21,7 +21,6 @@ #include #include -#define __user #include #include "../structs.h" diff --git a/libmultipath/prioritizers/alua_rtpg.h b/libmultipath/prioritizers/alua_rtpg.h index c5f9a8f94..ff6ec0ef0 100644 --- a/libmultipath/prioritizers/alua_rtpg.h +++ b/libmultipath/prioritizers/alua_rtpg.h @@ -12,8 +12,8 @@ * * This file is released under the GPL. */ -#ifndef __RTPG_H__ -#define __RTPG_H__ +#ifndef ALUA_RTPG_H_INCLUDED +#define ALUA_RTPG_H_INCLUDED #include "alua_spc3.h" #define RTPG_SUCCESS 0 @@ -26,4 +26,4 @@ int get_target_port_group_support(const struct path *pp); int get_target_port_group(const struct path *pp); int get_asymmetric_access_state(const struct path *pp, unsigned int tpg); -#endif /* __RTPG_H__ */ +#endif /* ALUA_RTPG_H_INCLUDED */ diff --git a/libmultipath/prioritizers/alua_spc3.h b/libmultipath/prioritizers/alua_spc3.h index e1a6c0711..6011c4d6b 100644 --- a/libmultipath/prioritizers/alua_spc3.h +++ b/libmultipath/prioritizers/alua_spc3.h @@ -12,8 +12,8 @@ * * This file is released under the GPL. */ -#ifndef __SPC3_H__ -#define __SPC3_H__ +#ifndef ALUA_SPC3_H_INCLUDED +#define ALUA_SPC3_H_INCLUDED #include "../unaligned.h" /*============================================================================= @@ -323,4 +323,4 @@ struct rtpg_data { ) \ ) -#endif /* __SPC3_H__ */ +#endif /* ALUA_SPC3_H_INCLUDED */ diff --git a/libmultipath/prioritizers/ontap.c b/libmultipath/prioritizers/ontap.c index 117886ea7..90eaf2748 100644 --- a/libmultipath/prioritizers/ontap.c +++ b/libmultipath/prioritizers/ontap.c @@ -23,6 +23,7 @@ #include "prio.h" #include "structs.h" #include "unaligned.h" +#include "strbuf.h" #define INQUIRY_CMD 0x12 #define INQUIRY_CMDLEN 6 @@ -35,32 +36,29 @@ static void dump_cdb(unsigned char *cdb, int size) { int i; - char buf[10*5+1]; - char * p = &buf[0]; + STRBUF_ON_STACK(buf); - condlog(0, "- SCSI CDB: "); - for (i=0; imasked_status, io_hdr->host_status, io_hdr->driver_status); if (io_hdr->sb_len_wr > 0) { - condlog(0, "- SCSI sense data: "); - for (i=0; isb_len_wr; i++) { - p += snprintf(p, 128*(io_hdr->sb_len_wr-i), "0x%02x ", - io_hdr->sbp[i]); + for (i = 0; i < io_hdr->sb_len_wr; i++) { + if (print_strbuf(&buf, "0x%02x ", io_hdr->sbp[i]) < 0) + return; } - condlog(0, "%s", buf); + condlog(0, "- SCSI sense data: %s", get_strbuf_str(&buf)); } } diff --git a/libmultipath/prioritizers/weightedpath.h b/libmultipath/prioritizers/weightedpath.h index a1b268fe4..a8030fdf0 100644 --- a/libmultipath/prioritizers/weightedpath.h +++ b/libmultipath/prioritizers/weightedpath.h @@ -1,5 +1,5 @@ -#ifndef _WEIGHTED_PATH_H -#define _WEIGHTED_PATH_H +#ifndef WEIGHTEDPATH_H_INCLUDED +#define WEIGHTEDPATH_H_INCLUDED #define PRIO_WEIGHTED_PATH "weightedpath" #define HBTL "hbtl" diff --git a/libmultipath/prkey.h b/libmultipath/prkey.h index 43afd5e42..a89a617bd 100644 --- a/libmultipath/prkey.h +++ b/libmultipath/prkey.h @@ -1,5 +1,5 @@ -#ifndef _PRKEY_H -#define _PRKEY_H +#ifndef PRKEY_H_INCLUDED +#define PRKEY_H_INCLUDED #include "structs.h" #include @@ -20,4 +20,4 @@ int set_prkey(struct config *conf, struct multipath *mpp, uint64_t prkey, uint8_t sa_flags); int get_prkey(struct multipath *mpp, uint64_t *prkey, uint8_t *sa_flags); -#endif /* _PRKEY_H */ +#endif /* PRKEY_H_INCLUDED */ diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index 509afda13..0f479d687 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -48,7 +48,7 @@ do { \ } \ } while(0) -#define __do_set_from_vec(type, var, src, dest) \ +#define do_set_from_vec__(type, var, src, dest) \ ({ \ type *_p; \ bool _found = false; \ @@ -64,11 +64,11 @@ do { \ _found; \ }) -#define __do_set_from_hwe(var, src, dest) \ - __do_set_from_vec(struct hwentry, var, (src)->hwe, dest) +#define do_set_from_hwe__(var, src, dest) \ + do_set_from_vec__(struct hwentry, var, (src)->hwe, dest) #define do_set_from_hwe(var, src, dest, msg) \ - if (src->hwe && __do_set_from_hwe(var, src, dest)) { \ + if (src->hwe && do_set_from_hwe__(var, src, dest)) { \ origin = msg; \ goto out; \ } @@ -675,7 +675,7 @@ check_rdac(struct path * pp) if (pp->bus != SYSFS_BUS_SCSI) return 0; /* Avoid checking 0xc9 if this is likely not an RDAC array */ - if (!__do_set_from_hwe(checker_name, pp, checker_name) && + if (!do_set_from_hwe__(checker_name, pp, checker_name) && !is_vpd_page_supported(pp->fd, 0xC9)) return 0; if (checker_name && strcmp(checker_name, RDAC)) diff --git a/libmultipath/propsel.h b/libmultipath/propsel.h index cf854eb03..5efde567c 100644 --- a/libmultipath/propsel.h +++ b/libmultipath/propsel.h @@ -1,3 +1,5 @@ +#ifndef PROPSEL_H_INCLUDED +#define PROPSEL_H_INCLUDED int select_rr_weight (struct config *conf, struct multipath * mp); int select_pgfailback (struct config *conf, struct multipath * mp); int select_detect_pgpolicy (struct config *conf, struct multipath * mp); @@ -42,3 +44,4 @@ void reconcile_features_with_options(const char *id, char **features, int *retain_hwhandler, int *skip_kpartx); int select_all_tg_pt (struct config *conf, struct multipath * mp); int select_vpd_vendor_id (struct path *pp); +#endif diff --git a/libmultipath/sg_include.h b/libmultipath/sg_include.h index 750a13add..443819b28 100644 --- a/libmultipath/sg_include.h +++ b/libmultipath/sg_include.h @@ -1,4 +1,5 @@ -#define __user +#ifndef SG_INCLUDE_H_INCLUDED +#define SG_INCLUDE_H_INCLUDED #include #ifndef DID_OK @@ -23,3 +24,4 @@ * retry or fail IO */ #define DID_TRANSPORT_FAILFAST 0x0f /* Transport class fastfailed the io */ #endif +#endif diff --git a/libmultipath/structs.c b/libmultipath/structs.c index 232b42304..61c8f32c3 100644 --- a/libmultipath/structs.c +++ b/libmultipath/structs.c @@ -433,7 +433,7 @@ store_adaptergroup(vector adapters, struct adapter_group * agp) } struct multipath * -find_mp_by_minor (const struct _vector *mpvec, unsigned int minor) +find_mp_by_minor (const struct vector_s *mpvec, unsigned int minor) { int i; struct multipath * mpp; @@ -452,7 +452,7 @@ find_mp_by_minor (const struct _vector *mpvec, unsigned int minor) } struct multipath * -find_mp_by_wwid (const struct _vector *mpvec, const char * wwid) +find_mp_by_wwid (const struct vector_s *mpvec, const char * wwid) { int i; struct multipath * mpp; @@ -468,7 +468,7 @@ find_mp_by_wwid (const struct _vector *mpvec, const char * wwid) } struct multipath * -find_mp_by_alias (const struct _vector *mpvec, const char * alias) +find_mp_by_alias (const struct vector_s *mpvec, const char * alias) { int i; size_t len; @@ -491,7 +491,7 @@ find_mp_by_alias (const struct _vector *mpvec, const char * alias) } struct multipath * -find_mp_by_str (const struct _vector *mpvec, const char * str) +find_mp_by_str (const struct vector_s *mpvec, const char * str) { int minor; char dummy; @@ -510,7 +510,7 @@ find_mp_by_str (const struct _vector *mpvec, const char * str) } struct path * -find_path_by_dev (const struct _vector *pathvec, const char *dev) +find_path_by_dev (const struct vector_s *pathvec, const char *dev) { int i; struct path * pp; @@ -527,7 +527,7 @@ find_path_by_dev (const struct _vector *pathvec, const char *dev) } struct path * -find_path_by_devt (const struct _vector *pathvec, const char * dev_t) +find_path_by_devt (const struct vector_s *pathvec, const char * dev_t) { int i; struct path * pp; diff --git a/libmultipath/structs.h b/libmultipath/structs.h index 91509881c..074faca6f 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -1,5 +1,5 @@ -#ifndef _STRUCTS_H -#define _STRUCTS_H +#ifndef STRUCTS_H_INCLUDED +#define STRUCTS_H_INCLUDED #include #include @@ -99,7 +99,7 @@ enum find_multipaths_states { FIND_MULTIPATHS_GREEDY, FIND_MULTIPATHS_SMART, FIND_MULTIPATHS_STRICT, - __FIND_MULTIPATHS_LAST, + FIND_MULTIPATHS_LAST__, }; enum marginal_pathgroups_mode { @@ -258,7 +258,7 @@ enum initialized_states { * change uevent is received. */ INIT_PARTIAL, - __INIT_LAST, + INIT_LAST__, }; enum prkey_sources { @@ -564,14 +564,14 @@ int store_hostgroup(vector hostgroupvec, struct host_group *hgp); int store_path (vector pathvec, struct path * pp); int add_pathgroup(struct multipath*, struct pathgroup *); -struct multipath * find_mp_by_alias (const struct _vector *mp, const char *alias); -struct multipath * find_mp_by_wwid (const struct _vector *mp, const char *wwid); -struct multipath * find_mp_by_str (const struct _vector *mp, const char *wwid); -struct multipath * find_mp_by_minor (const struct _vector *mp, +struct multipath * find_mp_by_alias (const struct vector_s *mp, const char *alias); +struct multipath * find_mp_by_wwid (const struct vector_s *mp, const char *wwid); +struct multipath * find_mp_by_str (const struct vector_s *mp, const char *wwid); +struct multipath * find_mp_by_minor (const struct vector_s *mp, unsigned int minor); -struct path * find_path_by_devt (const struct _vector *pathvec, const char *devt); -struct path * find_path_by_dev (const struct _vector *pathvec, const char *dev); +struct path * find_path_by_devt (const struct vector_s *pathvec, const char *devt); +struct path * find_path_by_dev (const struct vector_s *pathvec, const char *dev); struct path * first_path (const struct multipath *mpp); struct path *mp_find_path_by_devt(const struct multipath *mpp, const char *devt); @@ -584,4 +584,4 @@ int pathcmp (const struct pathgroup *, const struct pathgroup *); int add_feature (char **, const char *); int remove_feature (char **, const char *); -#endif /* _STRUCTS_H */ +#endif /* STRUCTS_H_INCLUDED */ diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index 50b17e665..5df495b3e 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -891,7 +891,7 @@ void update_queue_mode_add_path(struct multipath *mpp) condlog(2, "%s: remaining active paths: %d", mpp->alias, active); } -vector get_used_hwes(const struct _vector *pathvec) +vector get_used_hwes(const struct vector_s *pathvec) { int i, j; struct path *pp; diff --git a/libmultipath/structs_vec.h b/libmultipath/structs_vec.h index 01f5dc421..03bf8ee16 100644 --- a/libmultipath/structs_vec.h +++ b/libmultipath/structs_vec.h @@ -1,5 +1,5 @@ -#ifndef _STRUCTS_VEC_H -#define _STRUCTS_VEC_H +#ifndef STRUCTS_VEC_H_INCLUDED +#define STRUCTS_VEC_H_INCLUDED #include "vector.h" #include "config.h" @@ -37,6 +37,6 @@ int update_multipath_table__ (struct multipath *mpp, vector pathvec, int flags, const char *params, const char *status); int update_multipath_table (struct multipath *mpp, vector pathvec, int flags); int update_multipath_status (struct multipath *mpp); -vector get_used_hwes(const struct _vector *pathvec); +vector get_used_hwes(const struct vector_s *pathvec); -#endif /* _STRUCTS_VEC_H */ +#endif /* STRUCTS_VEC_H_INCLUDED */ diff --git a/libmultipath/switchgroup.h b/libmultipath/switchgroup.h index 9365e2e2e..e499b92ac 100644 --- a/libmultipath/switchgroup.h +++ b/libmultipath/switchgroup.h @@ -1,2 +1,7 @@ +#ifndef SWITCHGROUP_H_INCLUDED +#define SWITCHGROUP_H_INCLUDED + void path_group_prio_update (struct pathgroup * pgp); int select_path_group (struct multipath * mpp); + +#endif diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c index afe9de914..b2c1ce024 100644 --- a/libmultipath/sysfs.c +++ b/libmultipath/sysfs.c @@ -45,7 +45,7 @@ * as libudev lacks the capability to update an attribute value. * So for modified attributes we need to implement our own function. */ -static ssize_t __sysfs_attr_get_value(struct udev_device *dev, const char *attr_name, +static ssize_t sysfs_attr_get_value__(struct udev_device *dev, const char *attr_name, char *value, size_t value_len, bool binary) { const char *syspath; @@ -100,13 +100,13 @@ static ssize_t __sysfs_attr_get_value(struct udev_device *dev, const char *attr_ ssize_t sysfs_attr_get_value(struct udev_device *dev, const char *attr_name, char *value, size_t value_len) { - return __sysfs_attr_get_value(dev, attr_name, value, value_len, false); + return sysfs_attr_get_value__(dev, attr_name, value, value_len, false); } ssize_t sysfs_bin_attr_get_value(struct udev_device *dev, const char *attr_name, unsigned char *value, size_t value_len) { - return __sysfs_attr_get_value(dev, attr_name, (char *)value, + return sysfs_attr_get_value__(dev, attr_name, (char *)value, value_len, true); } diff --git a/libmultipath/sysfs.h b/libmultipath/sysfs.h index 3be3f665e..45f24c379 100644 --- a/libmultipath/sysfs.h +++ b/libmultipath/sysfs.h @@ -2,8 +2,8 @@ * sysfs.h */ -#ifndef _LIBMULTIPATH_SYSFS_H -#define _LIBMULTIPATH_SYSFS_H +#ifndef SYSFS_H_INCLUDED +#define SYSFS_H_INCLUDED #include #include "strbuf.h" diff --git a/libmultipath/uevent.h b/libmultipath/uevent.h index 53a7ca29c..69296789f 100644 --- a/libmultipath/uevent.h +++ b/libmultipath/uevent.h @@ -1,5 +1,5 @@ -#ifndef _UEVENT_H -#define _UEVENT_H +#ifndef UEVENT_H_INCLUDED +#define UEVENT_H_INCLUDED /* * buffer for environment variables, the kernel's size in @@ -69,4 +69,4 @@ static inline char *uevent_get_dm_action(const struct uevent *uev) return uevent_get_dm_str(uev, "DM_ACTION"); } -#endif /* _UEVENT_H */ +#endif /* UEVENT_H_INCLUDED */ diff --git a/libmultipath/unaligned.h b/libmultipath/unaligned.h index b9eaa7cbc..ea8b4a977 100644 --- a/libmultipath/unaligned.h +++ b/libmultipath/unaligned.h @@ -1,5 +1,5 @@ -#ifndef _UNALIGNED_H_ -#define _UNALIGNED_H_ +#ifndef UNALIGNED_H_INCLUDED +#define UNALIGNED_H_INCLUDED #include @@ -51,4 +51,4 @@ static inline void put_unaligned_be64(uint64_t val, void *ptr) put_unaligned_be32(val, p + 4); } -#endif /* _UNALIGNED_H_ */ +#endif /* UNALIGNED_H_INCLUDED */ diff --git a/libmultipath/valid.c b/libmultipath/valid.c index b7e0cc9b6..f23ee6b27 100644 --- a/libmultipath/valid.c +++ b/libmultipath/valid.c @@ -120,7 +120,7 @@ static int check_holders(const char *syspath) return sr.n; } -static int check_all_holders(const struct _vector *parts) +static int check_all_holders(const struct vector_s *parts) { char syspath[PATH_MAX]; const char *sysname; @@ -168,7 +168,7 @@ static void cleanup_cache(void *arg) * check if any of the partitions in the vector is referenced in the table. * Note that mnt_table_find_srcpath() also resolves mounts by symlinks. */ -static int check_mnt_table(const struct _vector *parts, +static int check_mnt_table(const struct vector_s *parts, struct libmnt_table *tbl, const char *table_name) { @@ -188,7 +188,7 @@ static int check_mnt_table(const struct _vector *parts, return 0; } -static int check_mountinfo(const struct _vector *parts) +static int check_mountinfo(const struct vector_s *parts) { static const char mountinfo[] = "/proc/self/mountinfo"; struct libmnt_table *tbl; @@ -223,7 +223,7 @@ static int check_mountinfo(const struct _vector *parts) } #ifdef LIBMOUNT_SUPPORTS_SWAP -static int check_swaps(const struct _vector *parts) +static int check_swaps(const struct vector_s *parts) { struct libmnt_table *tbl; struct libmnt_cache *cache; @@ -248,7 +248,7 @@ static int check_swaps(const struct _vector *parts) return used; } #else -static int check_swaps(const struct _vector *parts __attribute__((unused))) +static int check_swaps(const struct vector_s *parts __attribute__((unused))) { return 0; } @@ -302,7 +302,7 @@ is_path_valid(const char *name, struct config *conf, struct path *pp, return PATH_IS_ERROR; if (conf->find_multipaths <= FIND_MULTIPATHS_UNDEF || - conf->find_multipaths >= __FIND_MULTIPATHS_LAST) + conf->find_multipaths >= FIND_MULTIPATHS_LAST__) return PATH_IS_ERROR; if (safe_sprintf(pp->dev, "%s", name)) @@ -315,7 +315,7 @@ is_path_valid(const char *name, struct config *conf, struct path *pp, } if (check_multipathd) { - fd = __mpath_connect(1); + fd = mpath_connect__(1); if (fd < 0) { if (errno != EAGAIN) { condlog(3, "multipathd not running"); diff --git a/libmultipath/valid.h b/libmultipath/valid.h index 731e6eff6..96ba5545e 100644 --- a/libmultipath/valid.h +++ b/libmultipath/valid.h @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef _VALID_H -#define _VALID_H +#ifndef VALID_H_INCLUDED +#define VALID_H_INCLUDED /* * PATH_IS_VALID_NO_CHECK is returned when multipath should claim @@ -39,4 +39,4 @@ enum is_path_valid_result { int is_path_valid(const char *name, struct config *conf, struct path *pp, bool check_multipathd); -#endif /* _VALID_D */ +#endif /* VALID_H_INCLUDED */ diff --git a/libmultipath/version.h b/libmultipath/version.h index 271d8e74e..8ad403ef4 100644 --- a/libmultipath/version.h +++ b/libmultipath/version.h @@ -17,12 +17,12 @@ * * Copyright (c) 2006 Christophe Varoqui */ -#ifndef _VERSION_H -#define _VERSION_H +#ifndef VERSION_H_INCLUDED +#define VERSION_H_INCLUDED -#define VERSION_CODE 0x000909 +#define VERSION_CODE 0x000A00 /* MMDDYY, in hex */ -#define DATE_CODE 0x050318 +#define DATE_CODE 0x080F18 #define PROG "multipath-tools" @@ -35,4 +35,4 @@ MULTIPATH_VERSION(VERSION_CODE), \ MULTIPATH_VERSION(DATE_CODE) -#endif /* _VERSION_H */ +#endif /* VERSION_H_INCLUDED */ diff --git a/libmultipath/wwids.h b/libmultipath/wwids.h index 0c6ee54d5..ee47ad9fa 100644 --- a/libmultipath/wwids.h +++ b/libmultipath/wwids.h @@ -2,8 +2,8 @@ * Copyright (c) 2010 Benjamin Marzinski, Redhat */ -#ifndef _WWIDS_H -#define _WWIDS_H +#ifndef WWIDS_H_INCLUDED +#define WWIDS_H_INCLUDED #define WWIDS_FILE_HEADER \ "# Multipath wwids, Version : 1.0\n" \ @@ -29,4 +29,4 @@ enum { int is_failed_wwid(const char *wwid); int mark_failed_wwid(const char *wwid); int unmark_failed_wwid(const char *wwid); -#endif /* _WWIDS_H */ +#endif /* WWIDS_H_INCLUDED */ diff --git a/mpathpersist/main.c b/mpathpersist/main.c index b6617902f..efb46b95e 100644 --- a/mpathpersist/main.c +++ b/mpathpersist/main.c @@ -505,7 +505,7 @@ static int handle_args(int argc, char * argv[], int nline) goto out_fd; } - ret = __mpath_persistent_reserve_in (fd, prin_sa, resp, noisy); + ret = mpath_persistent_reserve_in__(fd, prin_sa, resp, noisy); if (ret != MPATH_PR_SUCCESS ) { fprintf (stderr, "Persistent Reserve IN command failed\n"); @@ -575,8 +575,8 @@ static int handle_args(int argc, char * argv[], int nline) } /* PROUT commands other than 'register and move' */ - ret = __mpath_persistent_reserve_out (fd, prout_sa, 0, prout_type, - paramp, noisy); + ret = mpath_persistent_reserve_out__(fd, prout_sa, 0, prout_type, + paramp, noisy); free_prout_param_descriptor(paramp); } diff --git a/mpathpersist/main.h b/mpathpersist/main.h index bfbb82e29..fc0bb2664 100644 --- a/mpathpersist/main.h +++ b/mpathpersist/main.h @@ -1,3 +1,6 @@ +#ifndef MPATHPERSIST_MAIN_H_INCLUDED +#define MPATHPERSIST_MAIN_H_INCLUDED + static struct option long_options[] = { {"verbose", 1, NULL, 'v'}, {"clear", 0, NULL, 'C'}, @@ -28,3 +31,4 @@ static struct option long_options[] = { }; static void usage(void); +#endif diff --git a/multipath/main.c b/multipath/main.c index 4b19d2ea8..28e3a0555 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -853,8 +853,6 @@ main (int argc, char *argv[]) if (atexit(uninit_config)) condlog(1, "failed to register cleanup handler for config: %m"); conf = get_multipath_config(); - conf->retrigger_tries = 0; - conf->force_sync = 1; if (atexit(cleanup_vecs)) condlog(1, "failed to register cleanup handler for vecs: %m"); if (atexit(cleanup_bindings)) @@ -1001,6 +999,11 @@ main (int argc, char *argv[]) libmp_udev_set_sync_support(1); + if (cmd != CMD_DUMP_CONFIG) { + conf->retrigger_tries = 0; + conf->force_sync = 1; + } + if ((cmd == CMD_LIST_SHORT || cmd == CMD_LIST_LONG) && enable_foreign) conf->enable_foreign = strdup(""); diff --git a/multipath/multipath.conf.5.in b/multipath/multipath.conf.5.in index 3834e1344..95bd6424e 100644 --- a/multipath/multipath.conf.5.in +++ b/multipath/multipath.conf.5.in @@ -6,7 +6,7 @@ .\" Update the date below if you make any significant change. .\" ---------------------------------------------------------------------------- . -.TH MULTIPATH.CONF 5 2024-04-25 Linux +.TH MULTIPATH.CONF 5 2024-08-15 Linux . . .\" ---------------------------------------------------------------------------- @@ -220,7 +220,7 @@ The default is: \fBservice-time 0\fR . .TP .B path_grouping_policy -The default path grouping policy to apply to unspecified +(Hardware-dependent) The default path grouping policy to apply to unspecified multipaths. Possible values are: .RS .TP 12 @@ -533,7 +533,8 @@ second, until \fIchecker_timeout\fR seconds have elapsed. Possible values are: deprecated, please use \fItur\fR or \fIdirectio\fR instead. .TP .I tur -Issue a \fITEST UNIT READY\fR command to the device. +(Hardware-dependent) +Issue a \fITEST UNIT READY\fR command to a SCSI device. .TP .I emc_clariion (Hardware-dependent) diff --git a/multipathd/cli.c b/multipathd/cli.c index 0c89b7cd9..34588290d 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -114,7 +114,7 @@ find_handler (uint32_t fp) } int -__set_handler_callback (uint32_t fp, cli_handler *fn, bool locked) +set_handler_callback__ (uint32_t fp, cli_handler *fn, bool locked) { struct handler *h; @@ -335,7 +335,7 @@ int get_cmdvec (char *cmd, vector *v, bool allow_incomplete) return r; } -uint32_t fingerprint(const struct _vector *vec) +uint32_t fingerprint(const struct vector_s *vec) { int i; uint32_t fp = 0; @@ -352,7 +352,7 @@ uint32_t fingerprint(const struct _vector *vec) return fp; } -struct handler *find_handler_for_cmdvec(const struct _vector *v) +struct handler *find_handler_for_cmdvec(const struct vector_s *v) { return find_handler(fingerprint(v)); } diff --git a/multipathd/cli.h b/multipathd/cli.h index c6b79c9d8..9fa501451 100644 --- a/multipathd/cli.h +++ b/multipathd/cli.h @@ -1,5 +1,5 @@ -#ifndef _CLI_H_ -#define _CLI_H_ +#ifndef CLI_H_INCLUDED +#define CLI_H_INCLUDED #include @@ -137,12 +137,12 @@ struct handler { }; int alloc_handlers (void); -int __set_handler_callback (uint32_t fp, cli_handler *fn, bool locked); -#define set_handler_callback(fp, fn) __set_handler_callback(fp, fn, true) -#define set_unlocked_handler_callback(fp, fn) __set_handler_callback(fp, fn, false) +int set_handler_callback__ (uint32_t fp, cli_handler *fn, bool locked); +#define set_handler_callback(fp, fn) set_handler_callback__(fp, fn, true) +#define set_unlocked_handler_callback(fp, fn) set_handler_callback__(fp, fn, false) int get_cmdvec (char *cmd, vector *v, bool allow_incomplete); -struct handler *find_handler_for_cmdvec(const struct _vector *v); +struct handler *find_handler_for_cmdvec(const struct vector_s *v); void genhelp_handler (const char *cmd, int error, struct strbuf *reply); int load_keys (void); @@ -152,9 +152,9 @@ void free_keys (vector vec); void free_handlers (void); int cli_init (void); void cli_exit(void); -uint32_t fingerprint(const struct _vector *vec); +uint32_t fingerprint(const struct vector_s *vec); vector get_keys(void); vector get_handlers(void); struct key *find_key (const char * str); -#endif /* _CLI_H_ */ +#endif /* CLI_H_INCLUDED */ diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 9e8165b14..baff27555 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -33,7 +33,7 @@ #include "cli_handlers.h" static struct path * -find_path_by_str(const struct _vector *pathvec, const char *str, +find_path_by_str(const struct vector_s *pathvec, const char *str, const char *action_str) { struct path *pp; @@ -157,15 +157,15 @@ show_map_json (struct strbuf *reply, struct multipath * mpp, } static int -show_config (struct strbuf *reply, const struct _vector *hwtable, - const struct _vector *mpvec) +show_config (struct strbuf *reply, const struct vector_s *hwtable, + const struct vector_s *mpvec) { struct config *conf; int rc; conf = get_multipath_config(); pthread_cleanup_push(put_multipath_config, conf); - rc = __snprint_config(conf, reply, hwtable, mpvec); + rc = snprint_config__(conf, reply, hwtable, mpvec); pthread_cleanup_pop(1); if (rc < 0) return 1; @@ -342,8 +342,15 @@ show_status (struct strbuf *reply, struct vectors *vecs) static int show_daemon (struct strbuf *reply) { - if (print_strbuf(reply, "pid %d %s\n", - daemon_pid, daemon_status()) < 0) + const char *status; + bool pending_reconfig; + + status = daemon_status(&pending_reconfig); + if (status == NULL) + return 1; + if (print_strbuf(reply, "pid %d %s%s\n", + daemon_pid, status, + pending_reconfig ? " (pending reconfigure)" : "") < 0) return 1; return 0; diff --git a/multipathd/cli_handlers.h b/multipathd/cli_handlers.h index 7eaf847e2..2303d8a9b 100644 --- a/multipathd/cli_handlers.h +++ b/multipathd/cli_handlers.h @@ -1,5 +1,5 @@ -#ifndef _CLI_HANDLERS_H -#define _CLI_HANDLERS_H +#ifndef CLI_HANDLERS_H_INCLUDED +#define CLI_HANDLERS_H_INCLUDED void init_handler_callbacks(void); diff --git a/multipathd/dmevents.c b/multipathd/dmevents.c index af1e12e71..7a78b8f74 100644 --- a/multipathd/dmevents.c +++ b/multipathd/dmevents.c @@ -202,7 +202,7 @@ static int dm_get_events(void) return -1; } -/* You must call __setup_multipath() after calling this function, to +/* You must call setup_multipath() after calling this function, to * deal with any events that came in before the device was added */ int watch_dmevents(char *name) { diff --git a/multipathd/dmevents.h b/multipathd/dmevents.h index 012fbad9c..debb3da0f 100644 --- a/multipathd/dmevents.h +++ b/multipathd/dmevents.h @@ -1,5 +1,5 @@ -#ifndef _DMEVENTS_H -#define _DMEVENTS_H +#ifndef DMEVENTS_H_INCLUDED +#define DMEVENTS_H_INCLUDED #include "structs_vec.h" @@ -10,4 +10,4 @@ int watch_dmevents(char *name); void unwatch_all_dmevents(void); void *wait_dmevents (void *unused); -#endif /* _DMEVENTS_H */ +#endif /* DMEVENTS_H_INCLUDED */ diff --git a/multipathd/fpin.h b/multipathd/fpin.h index 3c374441a..981140a7c 100644 --- a/multipathd/fpin.h +++ b/multipathd/fpin.h @@ -1,5 +1,5 @@ -#ifndef __FPIN_H__ -#define __FPIN_H__ +#ifndef FPIN_H_INCLUDED +#define FPIN_H_INCLUDED #include "autoconfig.h" #ifdef FPIN_EVENT_HANDLER diff --git a/multipathd/init_unwinder.h b/multipathd/init_unwinder.h index ada09f827..edaa8bec8 100644 --- a/multipathd/init_unwinder.h +++ b/multipathd/init_unwinder.h @@ -1,5 +1,5 @@ -#ifndef _INIT_UNWINDER_H -#define _INIT_UNWINDER_H 1 +#ifndef INIT_UNWINDER_H_INCLUDED +#define INIT_UNWINDER_H_INCLUDED /* * init_unwinder(): make sure unwinder symbols are loaded diff --git a/multipathd/main.c b/multipathd/main.c index daec9e934..1b7fd04f1 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -131,7 +131,9 @@ static int poll_dmevents = 1; /* Don't access this variable without holding config_lock */ static enum daemon_status running_state = DAEMON_INIT; /* Don't access this variable without holding config_lock */ -static bool __delayed_reconfig; +static bool delayed_reconfig; +/* Don't access this variable without holding config_lock */ +static enum force_reload_types reconfigure_pending = FORCE_RELOAD_NONE; pid_t daemon_pid; static pthread_mutex_t config_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t config_cond; @@ -142,19 +144,21 @@ static bool check_thr_started, uevent_thr_started, uxlsnr_thr_started, fpin_consumer_thr_started; static int pid_fd = -1; -static inline enum daemon_status get_running_state(void) +static inline enum daemon_status get_running_state(bool *pending_reconfig) { enum daemon_status st; pthread_mutex_lock(&config_lock); st = running_state; + if (pending_reconfig != NULL) + *pending_reconfig = (reconfigure_pending != FORCE_RELOAD_NONE); pthread_mutex_unlock(&config_lock); return st; } int should_exit(void) { - return get_running_state() == DAEMON_SHUTDOWN; + return get_running_state(NULL) == DAEMON_SHUTDOWN; } /* @@ -179,9 +183,9 @@ static const char *daemon_status_msg[DAEMON_STATUS_SIZE] = { }; const char * -daemon_status(void) +daemon_status(bool *pending_reconfig) { - int status = get_running_state(); + int status = get_running_state(pending_reconfig); if (status < DAEMON_INIT || status >= DAEMON_STATUS_SIZE) return NULL; @@ -239,7 +243,7 @@ static void config_cleanup(__attribute__((unused)) void *arg) pthread_mutex_unlock(&config_lock); } -#define __wait_for_state_change(condition, ms) \ +#define wait_for_state_change__(condition, ms) \ ({ \ struct timespec tmo; \ int rc = 0; \ @@ -271,17 +275,14 @@ enum daemon_status wait_for_state_change_if(enum daemon_status oldstate, pthread_mutex_lock(&config_lock); pthread_cleanup_push(config_cleanup, NULL); - __wait_for_state_change(running_state == oldstate, ms); + wait_for_state_change__(running_state == oldstate, ms); st = running_state; pthread_cleanup_pop(1); return st; } -/* Don't access this variable without holding config_lock */ -static enum force_reload_types reconfigure_pending = FORCE_RELOAD_NONE; - /* must be called with config_lock held */ -static void __post_config_state(enum daemon_status state) +static void post_config_state__(enum daemon_status state) { if (state != running_state && running_state != DAEMON_SHUTDOWN) { enum daemon_status old_state = running_state; @@ -298,7 +299,7 @@ void post_config_state(enum daemon_status state) { pthread_mutex_lock(&config_lock); pthread_cleanup_push(config_cleanup, NULL); - __post_config_state(state); + post_config_state__(state); pthread_cleanup_pop(1); } @@ -307,15 +308,15 @@ static bool unblock_reconfigure(void) bool was_delayed; pthread_mutex_lock(&config_lock); - was_delayed = __delayed_reconfig; + was_delayed = delayed_reconfig; if (was_delayed) { - __delayed_reconfig = false; + delayed_reconfig = false; /* * In IDLE state, make sure child() is woken up * Otherwise it will wake up when state switches to IDLE */ if (running_state == DAEMON_IDLE) - __post_config_state(DAEMON_CONFIGURE); + post_config_state__(DAEMON_CONFIGURE); } pthread_mutex_unlock(&config_lock); if (was_delayed) @@ -349,7 +350,7 @@ void schedule_reconfigure(enum force_reload_types requested_type) break; case DAEMON_IDLE: reconfigure_pending = type; - __post_config_state(DAEMON_CONFIGURE); + post_config_state__(DAEMON_CONFIGURE); break; case DAEMON_CONFIGURE: case DAEMON_RUNNING: @@ -377,7 +378,7 @@ static enum daemon_status set_config_state(enum daemon_status state) } if (rc == 0 && running_state == DAEMON_IDLE && state != DAEMON_IDLE) - __post_config_state(state); + post_config_state__(state); st = running_state; pthread_cleanup_pop(1); @@ -1219,7 +1220,7 @@ int ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map) { struct multipath * mpp; - char *params __attribute((cleanup(cleanup_charp))) = NULL; + char *params __attribute__((cleanup(cleanup_charp))) = NULL; int retries = 3; int start_waiter = 0; int ret; @@ -3139,8 +3140,8 @@ void rcu_free_config(struct rcu_head *head) free_config(conf); } -static bool reconfigure_check_uid_attrs(const struct _vector *old_attrs, - const struct _vector *new_attrs) +static bool reconfigure_check_uid_attrs(const struct vector_s *old_attrs, + const struct vector_s *new_attrs) { int i; char *old; @@ -3748,17 +3749,17 @@ child (__attribute__((unused)) void *param) /* * Check if another reconfigure request was scheduled * while we last ran reconfigure(). - * We have to test __delayed_reconfig here + * We have to test delayed_reconfig here * to avoid a busy loop */ (reconfigure_pending == FORCE_RELOAD_NONE - || __delayed_reconfig)) + || delayed_reconfig)) pthread_cond_wait(&config_cond, &config_lock); if (running_state != DAEMON_CONFIGURE && running_state != DAEMON_SHUTDOWN) /* This sets running_state to DAEMON_CONFIGURE */ - __post_config_state(DAEMON_CONFIGURE); + post_config_state__(DAEMON_CONFIGURE); state = running_state; pthread_cleanup_pop(1); if (state == DAEMON_SHUTDOWN) @@ -3775,13 +3776,13 @@ child (__attribute__((unused)) void *param) reload_type = reconfigure_pending == FORCE_RELOAD_YES ? FORCE_RELOAD_YES : FORCE_RELOAD_WEAK; reconfigure_pending = FORCE_RELOAD_NONE; - __delayed_reconfig = false; + delayed_reconfig = false; pthread_mutex_unlock(&config_lock); rc = reconfigure(vecs, reload_type); } else { pthread_mutex_lock(&config_lock); - __delayed_reconfig = true; + delayed_reconfig = true; pthread_mutex_unlock(&config_lock); condlog(3, "delaying reconfigure()"); } diff --git a/multipathd/main.h b/multipathd/main.h index 7aa93ca3c..c94362e4b 100644 --- a/multipathd/main.h +++ b/multipathd/main.h @@ -1,5 +1,5 @@ -#ifndef MAIN_H -#define MAIN_H +#ifndef MAIN_H_INCLUDED +#define MAIN_H_INCLUDED #define MAPGCINT 5 @@ -31,7 +31,7 @@ extern pid_t daemon_pid; extern int uxsock_timeout; void exit_daemon(void); -const char * daemon_status(void); +const char *daemon_status(bool *pending_reconfig); enum daemon_status wait_for_state_change_if(enum daemon_status oldstate, unsigned long ms); void schedule_reconfigure(enum force_reload_types requested_type); @@ -52,4 +52,4 @@ bool check_path_wwid_change(struct path *pp); int finish_path_init(struct path *pp, struct vectors * vecs); int resize_map(struct multipath *mpp, unsigned long long size, struct vectors *vecs); -#endif /* MAIN_H */ +#endif /* MAIN_H_INCLUDED */ diff --git a/multipathd/pidfile.h b/multipathd/pidfile.h index d308892e9..fae5774f6 100644 --- a/multipathd/pidfile.h +++ b/multipathd/pidfile.h @@ -1 +1,5 @@ +#ifndef PIDFILE_H_INCLUDED +#define PIDFILE_H_INCLUDED int pidfile_create(const char *pidFile, pid_t pid); +#endif + diff --git a/multipathd/uxclnt.h b/multipathd/uxclnt.h index 8e2cdcea8..dd66c528f 100644 --- a/multipathd/uxclnt.h +++ b/multipathd/uxclnt.h @@ -1 +1,6 @@ +#ifndef UXCLNT_H_INCLUDED +#define UXCLNT_H_INCLUDED + int uxclnt(char * inbuf, unsigned int timeout); + +#endif diff --git a/multipathd/uxlsnr.c b/multipathd/uxlsnr.c index 185e0a0ad..d74bb3555 100644 --- a/multipathd/uxlsnr.c +++ b/multipathd/uxlsnr.c @@ -59,7 +59,7 @@ struct client { int fd; vector cmdvec; /* NUL byte at end */ - char cmd[_MAX_CMD_LEN + 1]; + char cmd[MAX_CMD_LEN + 1]; struct strbuf reply; struct handler *handler; size_t cmd_len, len; @@ -477,7 +477,7 @@ static int client_state_machine(struct client *c, struct vectors *vecs, condlog(1, "%s: cli[%d]: failed to receive reply len: %zd", __func__, c->fd, n); c->error = -ECONNRESET; - } else if (len <= 0 || len > _MAX_CMD_LEN) { + } else if (len <= 0 || len > MAX_CMD_LEN) { condlog(1, "%s: cli[%d]: invalid command length (%zu bytes)", __func__, c->fd, len); c->error = -ECONNRESET; @@ -527,7 +527,7 @@ static int client_state_machine(struct client *c, struct vectors *vecs, case CLT_LOCKED_WORK: if (trylock(&vecs->lock) == 0) { /* don't use cleanup_lock(), lest we wakeup ourselves */ - pthread_cleanup_push_cast(__unlock, &vecs->lock); + pthread_cleanup_push_cast(unlock__, &vecs->lock); c->error = execute_handler(c, vecs); check_for_locked_work(c); pthread_cleanup_pop(1); diff --git a/multipathd/uxlsnr.h b/multipathd/uxlsnr.h index 3e45930bd..a14a66787 100644 --- a/multipathd/uxlsnr.h +++ b/multipathd/uxlsnr.h @@ -1,5 +1,5 @@ -#ifndef _UXLSNR_H -#define _UXLSNR_H +#ifndef UXLSNR_H_INCLUDED +#define UXLSNR_H_INCLUDED #include diff --git a/multipathd/waiter.c b/multipathd/waiter.c index 1dd93c5b2..f251c5002 100644 --- a/multipathd/waiter.c +++ b/multipathd/waiter.c @@ -56,7 +56,7 @@ void stop_waiter_thread (struct multipath *mpp) mpp->alias); return; } - /* Don't cancel yourself. __setup_multipath is called by + /* Don't cancel yourself. setup_multipath is called by by the waiter thread, and may remove a multipath device */ if (pthread_equal(mpp->waiter, pthread_self())) return; diff --git a/multipathd/waiter.h b/multipathd/waiter.h index 28e0f6d55..7b02272a5 100644 --- a/multipathd/waiter.h +++ b/multipathd/waiter.h @@ -1,5 +1,5 @@ -#ifndef _WAITER_H -#define _WAITER_H +#ifndef WAITER_H_INCLUDED +#define WAITER_H_INCLUDED extern pthread_attr_t waiter_attr; @@ -14,4 +14,4 @@ struct event_thread { void stop_waiter_thread (struct multipath *mpp); int start_waiter_thread (struct multipath *mpp, struct vectors *vecs); -#endif /* _WAITER_H */ +#endif /* WAITER_H_INCLUDED */ diff --git a/tests/alias.c b/tests/alias.c index a95b30817..163d9a7d5 100644 --- a/tests/alias.c +++ b/tests/alias.c @@ -25,7 +25,7 @@ #define MPATH_ID_INT_MAX_p1 "fxshrxx" #endif -static int __set_errno(int err) +static int set_errno__(int err) { if (err >= 0) { errno = 0; @@ -63,12 +63,12 @@ ssize_t __wrap_write(int fd, const void *buf, size_t count) start = strstr(start, binding); check_expected(count); assert_ptr_not_equal(start, NULL); - return __set_errno(mock_type(int)); + return set_errno__(mock_type(int)); } int __wrap_rename(const char *old, const char *new) { - return __set_errno(mock_type(int)); + return set_errno__(mock_type(int)); } int WRAP_FUNC(mkstemp)(char *template) @@ -134,7 +134,7 @@ int __wrap_pthread_mutex_unlock(pthread_mutex_t *mutex) #define TEST_FPTR ((FILE *) 0xaffe) /* strbuf wrapper for the old format_devname() */ -static int __format_devname(char *name, int id, size_t len, const char *prefix) +static int format_devname__(char *name, int id, size_t len, const char *prefix) { STRBUF_ON_STACK(buf); @@ -151,7 +151,7 @@ static void fd_mpatha(void **state) char buf[32]; int rc; - rc = __format_devname(buf, 1, sizeof(buf), "FOO"); + rc = format_devname__(buf, 1, sizeof(buf), "FOO"); assert_int_equal(rc, 4); assert_string_equal(buf, "FOOa"); } @@ -162,7 +162,7 @@ static void fd_mpathz(void **state) char buf[5]; int rc; - rc = __format_devname(buf, 26, sizeof(buf), "FOO"); + rc = format_devname__(buf, 26, sizeof(buf), "FOO"); assert_int_equal(rc, 4); assert_string_equal(buf, "FOOz"); } @@ -172,7 +172,7 @@ static void fd_mpathaa(void **state) char buf[32]; int rc; - rc = __format_devname(buf, 26 + 1, sizeof(buf), "FOO"); + rc = format_devname__(buf, 26 + 1, sizeof(buf), "FOO"); assert_int_equal(rc, 5); assert_string_equal(buf, "FOOaa"); } @@ -182,7 +182,7 @@ static void fd_mpathzz(void **state) char buf[32]; int rc; - rc = __format_devname(buf, 26*26 + 26, sizeof(buf), "FOO"); + rc = format_devname__(buf, 26*26 + 26, sizeof(buf), "FOO"); assert_int_equal(rc, 5); assert_string_equal(buf, "FOOzz"); } @@ -192,7 +192,7 @@ static void fd_mpathaaa(void **state) char buf[32]; int rc; - rc = __format_devname(buf, 26*26 + 27, sizeof(buf), "FOO"); + rc = format_devname__(buf, 26*26 + 27, sizeof(buf), "FOO"); assert_int_equal(rc, 6); assert_string_equal(buf, "FOOaaa"); } @@ -202,7 +202,7 @@ static void fd_mpathzzz(void **state) char buf[32]; int rc; - rc = __format_devname(buf, 26*26*26 + 26*26 + 26, sizeof(buf), "FOO"); + rc = format_devname__(buf, 26*26*26 + 26*26 + 26, sizeof(buf), "FOO"); assert_int_equal(rc, 6); assert_string_equal(buf, "FOOzzz"); } @@ -212,7 +212,7 @@ static void fd_mpathaaaa(void **state) char buf[32]; int rc; - rc = __format_devname(buf, 26*26*26 + 26*26 + 27, sizeof(buf), "FOO"); + rc = format_devname__(buf, 26*26*26 + 26*26 + 27, sizeof(buf), "FOO"); assert_int_equal(rc, 7); assert_string_equal(buf, "FOOaaaa"); } @@ -222,7 +222,7 @@ static void fd_mpathzzzz(void **state) char buf[32]; int rc; - rc = __format_devname(buf, 26*26*26*26 + 26*26*26 + 26*26 + 26, + rc = format_devname__(buf, 26*26*26*26 + 26*26*26 + 26*26 + 26, sizeof(buf), "FOO"); assert_int_equal(rc, 7); assert_string_equal(buf, "FOOzzzz"); @@ -234,7 +234,7 @@ static void fd_mpath_max(void **state) char buf[32]; int rc; - rc = __format_devname(buf, INT_MAX, sizeof(buf), ""); + rc = format_devname__(buf, INT_MAX, sizeof(buf), ""); assert_int_equal(rc, strlen(MPATH_ID_INT_MAX)); assert_string_equal(buf, MPATH_ID_INT_MAX); } @@ -245,7 +245,7 @@ static void fd_mpath_max1(void **state) char buf[32]; int rc; - rc = __format_devname(buf, INT_MIN, sizeof(buf), ""); + rc = format_devname__(buf, INT_MIN, sizeof(buf), ""); assert_int_equal(rc, -1); } @@ -254,7 +254,7 @@ static void fd_mpath_short(void **state) char buf[4]; int rc; - rc = __format_devname(buf, 1, sizeof(buf), "FOO"); + rc = format_devname__(buf, 1, sizeof(buf), "FOO"); assert_int_equal(rc, -1); } @@ -263,7 +263,7 @@ static void fd_mpath_short1(void **state) char buf[5]; int rc; - rc = __format_devname(buf, 27, sizeof(buf), "FOO"); + rc = format_devname__(buf, 27, sizeof(buf), "FOO"); assert_int_equal(rc, -1); } @@ -388,7 +388,7 @@ static void sd_fd_many(void **state) int rc, i; for (i = 1; i < 5000; i++) { - rc = __format_devname(buf, i, sizeof(buf), "MPATH"); + rc = format_devname__(buf, i, sizeof(buf), "MPATH"); assert_in_range(rc, 6, 8); rc = scan_devname(buf, "MPATH"); assert_int_equal(rc, i); @@ -403,7 +403,7 @@ static void sd_fd_random(void **state) srandom(1); for (i = 1; i < 1000; i++) { n = random() & 0xffff; - rc = __format_devname(buf, n, sizeof(buf), "MPATH"); + rc = format_devname__(buf, n, sizeof(buf), "MPATH"); assert_in_range(rc, 6, 9); rc = scan_devname(buf, "MPATH"); assert_int_equal(rc, n); @@ -483,7 +483,7 @@ static void mock_self_alias(const char *alias, const char *wwid) expect_condlog(3, USED_STR(alias, wwid)); \ } while(0) -static void __mock_bindings_file(const char *content, bool conflict_ok) +static void mock_bindings_file__(const char *content, bool conflict_ok) { char *cnt __attribute__((cleanup(cleanup_charp))) = NULL; char *token, *savep = NULL; @@ -509,7 +509,7 @@ static void __mock_bindings_file(const char *content, bool conflict_ok) } static void mock_bindings_file(const char *content) { - return __mock_bindings_file(content, false); + return mock_bindings_file__(content, false); } static int teardown_bindings(void **state) @@ -1438,6 +1438,7 @@ static void gufa_empty_new_rw(void **state) { mock_bindings_file(""); mock_unused_alias("MPATHa"); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, NOMATCH_WWID_STR("WWID0")); mock_allocate_binding("MPATHa", "WWID0"); @@ -1451,6 +1452,7 @@ static void gufa_empty_new_ro_1(void **state) { mock_bindings_file(""); mock_unused_alias("MPATHa"); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, NOMATCH_WWID_STR("WWID0")); mock_allocate_binding_err("MPATHa", "WWID0", -EROFS, "Read-only file system"); @@ -1462,6 +1464,7 @@ static void gufa_empty_new_ro_2(void **state) { char *alias; mock_bindings_file(""); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, NOMATCH_WWID_STR("WWID0")); mock_unused_alias("MPATHa"); @@ -1473,6 +1476,7 @@ static void gufa_match_a_unused(void **state) { char *alias; mock_bindings_file("MPATHa WWID0"); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, FOUND_STR("MPATHa", "WWID0")); mock_unused_alias("MPATHa"); expect_condlog(3, EXISTING_STR("MPATHa", "WWID0")); @@ -1486,6 +1490,7 @@ static void gufa_match_a_self(void **state) { char *alias; mock_bindings_file("MPATHa WWID0"); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, FOUND_STR("MPATHa", "WWID0")); mock_self_alias("MPATHa", "WWID0"); expect_condlog(3, EXISTING_STR("MPATHa", "WWID0")); @@ -1500,6 +1505,7 @@ static void gufa_match_a_used(void **state) { mock_bindings_file("MPATHa WWID0"); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, FOUND_STR("MPATHa", "WWID0")); mock_used_alias("MPATHa", "WWID0"); @@ -1514,6 +1520,7 @@ static void gufa_nomatch_a_c(void **state) { mock_bindings_file(bindings); mock_unused_alias("MPATHb"); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, NOMATCH_WWID_STR("WWID1")); mock_allocate_binding_len("MPATHb", "WWID1", strlen(bindings)); @@ -1530,6 +1537,7 @@ static void gufa_nomatch_c_a(void **state) { mock_bindings_file(bindings); mock_unused_alias("MPATHb"); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, NOMATCH_WWID_STR("WWID1")); mock_allocate_binding_len("MPATHb", "WWID1", sizeof(bindings) - 1); @@ -1545,6 +1553,7 @@ static void gufa_nomatch_c_b(void **state) { "MPATHb WWID1\n"); mock_bindings_file(bindings); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, NOMATCH_WWID_STR("WWID0")); mock_unused_alias("MPATHa"); @@ -1561,6 +1570,7 @@ static void gufa_nomatch_c_b_used(void **state) { "MPATHb WWID1\n"); mock_bindings_file(bindings); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, NOMATCH_WWID_STR("WWID4")); mock_used_alias("MPATHa", "WWID4"); mock_unused_alias("MPATHd"); @@ -1579,6 +1589,7 @@ static void gufa_nomatch_b_f_a(void **state) { "MPATHa WWID0\n"); mock_bindings_file(bindings); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, NOMATCH_WWID_STR("WWID7")); mock_unused_alias("MPATHc"); @@ -1595,6 +1606,7 @@ static void gufa_nomatch_b_aa_a(void **state) { fill_bindings(&buf, 0, 26); mock_bindings_file(get_strbuf_str(&buf)); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, NOMATCH_WWID_STR("WWID28")); mock_unused_alias("MPATHab"); mock_allocate_binding_len("MPATHab", "WWID28", get_strbuf_len(&buf)); @@ -1611,6 +1623,7 @@ static void gufa_nomatch_b_f_a_sorted(void **state) { "MPATHa WWID0\n"); mock_bindings_file(bindings); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, NOMATCH_WWID_STR("WWID7")); mock_unused_alias("MPATHc"); @@ -1626,6 +1639,7 @@ static void gufa_old_empty(void **state) { /* rlookup_binding for ALIAS */ mock_bindings_file(""); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, NOMATCH_STR("MPATHz")); expect_condlog(3, NOMATCH_WWID_STR("WWID0")); @@ -1642,6 +1656,7 @@ static void gufa_old_match(void **state) { mock_bindings_file("MPATHb WWID1\n" "MPATHz WWID0"); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, FOUND_ALIAS_STR("MPATHz", "WWID0")); alias = get_user_friendly_alias("WWID0", "MPATHz", "MPATH", false); @@ -1654,6 +1669,7 @@ static void gufa_old_match_other(void **state) { static const char bindings[] = "MPATHz WWID9\n"; mock_bindings_file(bindings); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, FOUND_ALIAS_STR("MPATHz", "WWID9")); expect_condlog(0, REUSE_STR("MPATHz", "WWID9")); expect_condlog(3, NOMATCH_WWID_STR("WWID0")); @@ -1671,6 +1687,7 @@ static void gufa_old_match_other_used(void **state) { static const char bindings[] = "MPATHz WWID9\n"; mock_bindings_file(bindings); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, FOUND_ALIAS_STR("MPATHz", "WWID9")); expect_condlog(0, REUSE_STR("MPATHz", "WWID9")); expect_condlog(3, NOMATCH_WWID_STR("WWID0")); @@ -1689,6 +1706,7 @@ static void gufa_old_match_other_wwidmatch(void **state) { "MPATHc WWID2"); mock_bindings_file(bindings); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, FOUND_ALIAS_STR("MPATHz", "WWID9")); expect_condlog(0, REUSE_STR("MPATHz", "WWID9")); expect_condlog(3, FOUND_STR("MPATHc", "WWID2")); @@ -1706,6 +1724,7 @@ static void gufa_old_match_other_wwidmatch_used(void **state) { "MPATHc WWID2"); mock_bindings_file(bindings); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, FOUND_ALIAS_STR("MPATHz", "WWID9")); expect_condlog(0, REUSE_STR("MPATHz", "WWID9")); expect_condlog(3, FOUND_STR("MPATHc", "WWID2")); @@ -1720,6 +1739,7 @@ static void gufa_old_nomatch_wwidmatch(void **state) { static const char bindings[] = "MPATHa WWID0"; mock_bindings_file(bindings); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, NOMATCH_STR("MPATHz")); expect_condlog(3, FOUND_STR("MPATHa", "WWID0")); mock_unused_alias("MPATHa"); @@ -1735,6 +1755,7 @@ static void gufa_old_nomatch_wwidmatch_used(void **state) { static const char bindings[] = "MPATHa WWID0"; mock_bindings_file(bindings); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, NOMATCH_STR("MPATHz")); expect_condlog(3, FOUND_STR("MPATHa", "WWID0")); mock_used_alias("MPATHa", "WWID0"); @@ -1748,6 +1769,7 @@ static void gufa_old_nomatch_nowwidmatch(void **state) { static const char bindings[] = "MPATHb WWID1\n"; mock_bindings_file(bindings); + expect_condlog(4, "_read_bindings_file: bindings are unchanged"); expect_condlog(3, NOMATCH_STR("MPATHz")); expect_condlog(3, NOMATCH_WWID_STR("WWID0")); @@ -1896,7 +1918,7 @@ static void order_test(int n, const struct random_aliases ra[], bool conflict_ok for (j = 0; j < n; j++) fill_bindings_random(&buf, ra[j].start, ra[j].end, ra[j].prefix); - __mock_bindings_file(get_strbuf_str(&buf), conflict_ok); + mock_bindings_file__(get_strbuf_str(&buf), conflict_ok); for (j = 0; j < n; j++) { bdg = VECTOR_SLOT(bindings, 0); diff --git a/tests/mpathvalid.c b/tests/mpathvalid.c index df66ed6ae..134dfc9d6 100644 --- a/tests/mpathvalid.c +++ b/tests/mpathvalid.c @@ -130,7 +130,7 @@ void make_config_file(int findmp) char buf[64]; assert_true(findmp > FIND_MULTIPATHS_UNDEF && - findmp < __FIND_MULTIPATHS_LAST); + findmp < FIND_MULTIPATHS_LAST__); r = snprintf(buf, sizeof(buf), "defaults {\nfind_multipaths %s\n}\n", find_multipaths_optvals[findmp]); diff --git a/tests/strbuf.c b/tests/strbuf.c index f8554da56..1cc161898 100644 --- a/tests/strbuf.c +++ b/tests/strbuf.c @@ -78,7 +78,7 @@ static void test_strbuf_00(void **state) assert_string_equal(p, ""); free(p); - assert_int_equal(__append_strbuf_str(&buf, "x", 0), 0); + assert_int_equal(append_strbuf_str__(&buf, "x", 0), 0); /* appending a 0-length string allocates memory */ assert_in_range(buf.size, 1, SIZE_MAX); assert_int_equal(buf.offs, 0); @@ -181,9 +181,9 @@ static void test_strbuf_nul(void **state) STRBUF_ON_STACK(buf); char greet[] = "hello, sir!"; - assert_int_equal(__append_strbuf_str(&buf, greet, 6), 6); + assert_int_equal(append_strbuf_str__(&buf, greet, 6), 6); assert_string_equal(get_strbuf_str(&buf), "hello,"); - assert_int_equal(__append_strbuf_str(&buf, greet, 6), 6); + assert_int_equal(append_strbuf_str__(&buf, greet, 6), 6); assert_string_equal(get_strbuf_str(&buf), "hello,hello,"); /* overwrite comma with NUL; append_strbuf_str() stops at NUL byte */ @@ -196,14 +196,14 @@ static void test_strbuf_nul(void **state) assert_int_equal(get_strbuf_len(&buf), 10); assert_string_equal(get_strbuf_str(&buf), "hellohello"); - /* __append_strbuf_str() appends full memory, including NUL bytes */ + /* append_strbuf_str__() appends full memory, including NUL bytes */ reset_strbuf(&buf); - assert_int_equal(__append_strbuf_str(&buf, greet, sizeof(greet) - 1), + assert_int_equal(append_strbuf_str__(&buf, greet, sizeof(greet) - 1), sizeof(greet) - 1); assert_int_equal(get_strbuf_len(&buf), sizeof(greet) - 1); assert_string_equal(get_strbuf_str(&buf), "hello"); assert_string_equal(get_strbuf_str(&buf) + get_strbuf_len(&buf) - 5, " sir!"); - assert_int_equal(__append_strbuf_str(&buf, greet, sizeof(greet) - 1), + assert_int_equal(append_strbuf_str__(&buf, greet, sizeof(greet) - 1), sizeof(greet) - 1); assert_string_equal(get_strbuf_str(&buf), "hello"); assert_int_equal(get_strbuf_len(&buf), 2 * (sizeof(greet) - 1)); @@ -279,6 +279,71 @@ static void test_print_strbuf(void **state) assert_int_equal(print_strbuf(&buf, "%d%% of %d is %0.2f", 5, 100, 0.05), 17); assert_string_equal(get_strbuf_str(&buf), "5% of 100 is 0.05"); + +} + +/* length of string is not a divisor of chunk size */ +static void test_print_strbuf_2(void **state) +{ + STRBUF_ON_STACK(buf); + const char sentence[] = "This sentence has forty-seven (47) characters. "; + const char *s; + const int repeat = 100; + int i; + + for (i = 0; i < repeat; i++) + assert_int_equal(print_strbuf(&buf, "%s", sentence), + sizeof(sentence) - 1); + + s = get_strbuf_str(&buf); + condlog(3, "%s", s); + assert_int_equal(strlen(s), repeat * (sizeof(sentence) - 1)); + for (i = 0; i < repeat; i++) + assert_int_equal(strncmp(s + i * (sizeof(sentence) - 1), + sentence, sizeof(sentence) - 1), 0); +} + +/* length of string is divisor of chunk size */ +static void test_print_strbuf_3(void **state) +{ + STRBUF_ON_STACK(buf); + const char sentence[] = "This sentence has 32 characters."; + const char *s; + const int repeat = 100; + int i; + + for (i = 0; i < repeat; i++) + assert_int_equal(print_strbuf(&buf, "%s", sentence), + sizeof(sentence) - 1); + + s = get_strbuf_str(&buf); + condlog(3, "%s", s); + assert_int_equal(strlen(s), repeat * (sizeof(sentence) - 1)); + for (i = 0; i < repeat; i++) + assert_int_equal(strncmp(s + i * (sizeof(sentence) - 1), + sentence, sizeof(sentence) - 1), 0); +} + +static void test_print_strbuf_4(void **state) +{ + STRBUF_ON_STACK(buf); + const char sentence[] = "This sentence has a lot of characters, " + "which makes it hopefully longer than the chunk size given by " + "the constant \"BUF_CHUNK\" in libmpathutil/strbuf.c. "; + const char *s; + const int repeat = 100; + int i; + + for (i = 0; i < repeat; i++) + assert_int_equal(print_strbuf(&buf, "%s", sentence), + sizeof(sentence) - 1); + + s = get_strbuf_str(&buf); + condlog(3, "%s", s); + assert_int_equal(strlen(s), repeat * (sizeof(sentence) - 1)); + for (i = 0; i < repeat; i++) + assert_int_equal(strncmp(s + i * (sizeof(sentence) - 1), + sentence, sizeof(sentence) - 1), 0); } static void test_truncate_strbuf(void **state) @@ -394,6 +459,9 @@ static int test_strbuf(void) cmocka_unit_test(test_strbuf_quoted), cmocka_unit_test(test_strbuf_escaped), cmocka_unit_test(test_print_strbuf), + cmocka_unit_test(test_print_strbuf_2), + cmocka_unit_test(test_print_strbuf_3), + cmocka_unit_test(test_print_strbuf_4), cmocka_unit_test(test_truncate_strbuf), cmocka_unit_test(test_fill_strbuf), }; diff --git a/tests/sysfs.c b/tests/sysfs.c index c623d1bb7..6dfa9f3f5 100644 --- a/tests/sysfs.c +++ b/tests/sysfs.c @@ -90,7 +90,7 @@ static int teardown(void **state) static void expect_sagv_invalid(void) { - expect_condlog(1, "__sysfs_attr_get_value: invalid parameters"); + expect_condlog(1, "sysfs_attr_get_value__: invalid parameters"); } static void test_sagv_invalid(void **state) @@ -132,12 +132,12 @@ static void test_sagv_invalid(void **state) static void test_sagv_bad_udev(void **state) { will_return(__wrap_udev_device_get_syspath, NULL); - expect_condlog(3, "__sysfs_attr_get_value: invalid udevice"); + expect_condlog(3, "sysfs_attr_get_value__: invalid udevice"); assert_int_equal(sysfs_attr_get_value((void *)state, (void *)state, (void *)state, 1), -EINVAL); will_return(__wrap_udev_device_get_syspath, NULL); - expect_condlog(3, "__sysfs_attr_get_value: invalid udevice"); + expect_condlog(3, "sysfs_attr_get_value__: invalid udevice"); assert_int_equal(sysfs_bin_attr_get_value((void *)state, (void *)state, (void *)state, 1), -EINVAL); } @@ -151,11 +151,11 @@ static void test_sagv_bad_snprintf(void **state) longstr[sizeof(longstr) - 1] = '\0'; will_return(__wrap_udev_device_get_syspath, "/foo"); - expect_condlog(3, "__sysfs_attr_get_value: devpath overflow"); + expect_condlog(3, "sysfs_attr_get_value__: devpath overflow"); assert_int_equal(sysfs_attr_get_value((void *)state, longstr, buf, sizeof(buf)), -EOVERFLOW); will_return(__wrap_udev_device_get_syspath, "/foo"); - expect_condlog(3, "__sysfs_attr_get_value: devpath overflow"); + expect_condlog(3, "sysfs_attr_get_value__: devpath overflow"); assert_int_equal(sysfs_bin_attr_get_value((void *)state, longstr, (unsigned char *)buf, sizeof(buf)), -EOVERFLOW); @@ -171,7 +171,7 @@ static void test_sagv_open_fail(void **state) expect_value(WRAP_OPEN, flags, O_RDONLY); errno = ENOENT; wrap_will_return(WRAP_OPEN, -1); - expect_condlog(3, "__sysfs_attr_get_value: attribute '/foo/bar' cannot be opened"); + expect_condlog(3, "sysfs_attr_get_value__: attribute '/foo/bar' cannot be opened"); assert_int_equal(sysfs_attr_get_value((void *)state, "bar", buf, sizeof(buf)), -ENOENT); } @@ -190,7 +190,7 @@ static void test_sagv_read_fail(void **state) errno = EISDIR; will_return(__wrap_read, -1); will_return(__wrap_read, NULL); - expect_condlog(3, "__sysfs_attr_get_value: read from /foo/bar failed:"); + expect_condlog(3, "sysfs_attr_get_value__: read from /foo/bar failed:"); will_return(__wrap_close, 0); assert_int_equal(sysfs_attr_get_value((void *)state, "bar", buf, sizeof(buf)), -EISDIR); @@ -205,7 +205,7 @@ static void test_sagv_read_fail(void **state) errno = EPERM; will_return(__wrap_read, -1); will_return(__wrap_read, NULL); - expect_condlog(3, "__sysfs_attr_get_value: read from /foo/baz failed:"); + expect_condlog(3, "sysfs_attr_get_value__: read from /foo/baz failed:"); will_return(__wrap_close, 0); assert_int_equal(sysfs_bin_attr_get_value((void *)state, "baz", (unsigned char *)buf, sizeof(buf)), @@ -235,7 +235,7 @@ static void _test_sagv_read(void **state, unsigned int bufsz) if (bufsz <= sizeof(input) - 1) { n = bufsz; trunc = 1; - expect_condlog(3, "__sysfs_attr_get_value: overflow reading from /foo/bar"); + expect_condlog(3, "sysfs_attr_get_value__: overflow reading from /foo/bar"); } else { n = sizeof(input) - 1; trunc = 0; @@ -311,7 +311,7 @@ static void _test_sagv_read_zeroes(void **state, unsigned int bufsz) if (bufsz <= sizeof(input) - 1) { n = bufsz; - expect_condlog(3, "__sysfs_attr_get_value: overflow reading from /foo/bar"); + expect_condlog(3, "sysfs_attr_get_value__: overflow reading from /foo/bar"); } else n = 0; diff --git a/tests/test-lib.c b/tests/test-lib.c index 88f35e947..99becccde 100644 --- a/tests/test-lib.c +++ b/tests/test-lib.c @@ -367,7 +367,7 @@ void mock_store_pathinfo(int mask, const struct mocked_path *mp) mock_pathinfo(mask, mp); } -struct path *__mock_path(vector pathvec, +struct path *mock_path__(vector pathvec, const char *vnd, const char *prd, const char *rev, const char *wwid, const char *dev, @@ -395,7 +395,7 @@ struct path *__mock_path(vector pathvec, } -struct multipath *__mock_multipath(struct vectors *vecs, struct path *pp) +struct multipath *mock_multipath__(struct vectors *vecs, struct path *pp) { struct multipath *mp; struct config *conf; diff --git a/tests/test-lib.h b/tests/test-lib.h index efd03a7e4..ff548342c 100644 --- a/tests/test-lib.h +++ b/tests/test-lib.h @@ -1,5 +1,5 @@ -#ifndef __LIB_H -#define __LIB_H +#ifndef TEST_LIB_H_INCLUDED +#define TEST_LIB_H_INCLUDED extern const int default_mask; extern const char default_devnode[]; @@ -40,29 +40,29 @@ struct mocked_path *mocked_path_from_path(struct mocked_path *mp, void mock_pathinfo(int mask, const struct mocked_path *mp); void mock_store_pathinfo(int mask, const struct mocked_path *mp); -struct path *__mock_path(vector pathvec, +struct path *mock_path__(vector pathvec, const char *vnd, const char *prd, const char *rev, const char *wwid, const char *dev, unsigned int flags, int mask); #define mock_path(v, p) \ - __mock_path(hwt->vecs->pathvec, (v), (p), "0", NULL, NULL, \ + mock_path__(hwt->vecs->pathvec, (v), (p), "0", NULL, NULL, \ 0, default_mask) #define mock_path_flags(v, p, f) \ - __mock_path(hwt->vecs->pathvec, (v), (p), "0", NULL, NULL, \ + mock_path__(hwt->vecs->pathvec, (v), (p), "0", NULL, NULL, \ (f), default_mask) #define mock_path_blacklisted(v, p) \ - __mock_path(hwt->vecs->pathvec, (v), (p), "0", NULL, NULL, \ + mock_path__(hwt->vecs->pathvec, (v), (p), "0", NULL, NULL, \ BL_BY_DEVICE, default_mask) #define mock_path_wwid(v, p, w) \ - __mock_path(hwt->vecs->pathvec, (v), (p), "0", (w), NULL, \ + mock_path__(hwt->vecs->pathvec, (v), (p), "0", (w), NULL, \ 0, default_mask) #define mock_path_wwid_flags(v, p, w, f) \ - __mock_path(hwt->vecs->pathvec, (v), (p), "0", (w), \ + mock_path__(hwt->vecs->pathvec, (v), (p), "0", (w), \ NULL, (f), default_mask) -struct multipath *__mock_multipath(struct vectors *vecs, struct path *pp); -#define mock_multipath(pp) __mock_multipath(hwt->vecs, (pp)) +struct multipath *mock_multipath__(struct vectors *vecs, struct path *pp); +#define mock_multipath(pp) mock_multipath__(hwt->vecs, (pp)) #endif diff --git a/tests/test-log.h b/tests/test-log.h index 6d22cd233..48c0c1758 100644 --- a/tests/test-log.h +++ b/tests/test-log.h @@ -1,5 +1,5 @@ -#ifndef _TEST_LOG_H -#define _TEST_LOG_H +#ifndef TEST_LOG_H_INCLUDED +#define TEST_LOG_H_INCLUDED __attribute__((format(printf, 2, 0))) void __wrap_dlog (int prio, const char * fmt, ...); diff --git a/tests/valid.c b/tests/valid.c index ecaeb4677..c5a1eac02 100644 --- a/tests/valid.c +++ b/tests/valid.c @@ -52,7 +52,7 @@ bool __wrap_sysfs_is_multipathed(struct path *pp, bool set_wwid) return is_multipathed; } -int __wrap___mpath_connect(int nonblocking) +int __wrap_mpath_connect__(int nonblocking) { bool connected = mock_type(bool); assert_int_equal(nonblocking, 1); @@ -106,14 +106,14 @@ const char *__wrap_udev_device_get_sysname(struct udev_device *udev_device) } /* called from pathinfo() */ -int __wrap_filter_devnode(struct config *conf, const struct _vector *elist, +int __wrap_filter_devnode(struct config *conf, const struct vector_s *elist, const char *vendor, const char * product, const char *dev) { return mock_type(int); } /* called from pathinfo() */ -int __wrap_filter_device(const struct _vector *blist, const struct _vector *elist, +int __wrap_filter_device(const struct vector_s *blist, const struct vector_s *elist, const char *vendor, const char * product, const char *dev) { return mock_type(int); @@ -223,10 +223,10 @@ static void setup_passing(char *name, char *wwid, unsigned int check_multipathd, if (stage == STAGE_IS_MULTIPATHED) return; if (check_multipathd == CHECK_MPATHD_RUNNING) - will_return(__wrap___mpath_connect, true); + will_return(__wrap_mpath_connect__, true); else if (check_multipathd == CHECK_MPATHD_EAGAIN) { - will_return(__wrap___mpath_connect, false); - will_return(__wrap___mpath_connect, EAGAIN); + will_return(__wrap_mpath_connect__, false); + will_return(__wrap_mpath_connect__, EAGAIN); } /* nothing for CHECK_MPATHD_SKIP */ @@ -332,8 +332,8 @@ static void test_check_multipathd(void **state) conf.find_multipaths = FIND_MULTIPATHS_STRICT; /* test failed check to see if multipathd is active */ will_return(__wrap_sysfs_is_multipathed, false); - will_return(__wrap___mpath_connect, false); - will_return(__wrap___mpath_connect, ECONNREFUSED); + will_return(__wrap_mpath_connect__, false); + will_return(__wrap_mpath_connect__, ECONNREFUSED); assert_int_equal(is_path_valid(name, &conf, &pp, true), PATH_IS_NOT_VALID); diff --git a/tests/wrap64.h b/tests/wrap64.h index af6cc2ba5..fe985a714 100644 --- a/tests/wrap64.h +++ b/tests/wrap64.h @@ -1,5 +1,5 @@ -#ifndef _WRAP64_H -#define _WRAP64_H 1 +#ifndef WRAP64_H_INCLUDED +#define WRAP64_H_INCLUDED #include #include /* The following include is required for LIBAIO_REDIRECT */