From: JinWang An Date: Fri, 13 Jan 2023 06:40:26 +0000 (+0900) Subject: Imported Upstream version 0.9.3 X-Git-Tag: upstream/0.9.3^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=22b6be2d87882e9106bf946aed522d699faceb85;p=platform%2Fupstream%2Fmultipath-tools.git Imported Upstream version 0.9.3 --- diff --git a/Makefile.inc b/Makefile.inc index 5602506..4d843ce 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -89,9 +89,9 @@ modulesloaddir = $(prefix)/$(SYSTEMDPATH)/modules-load.d multipathdir = $(TOPDIR)/libmultipath daemondir = $(TOPDIR)/multipathd mpathutildir = $(TOPDIR)/libmpathutil -man8dir = $(prefix)/usr/share/man/man8 -man5dir = $(prefix)/usr/share/man/man5 -man3dir = $(prefix)/usr/share/man/man3 +man8dir = $(prefix)/share/man/man8 +man5dir = $(prefix)/share/man/man5 +man3dir = $(prefix)/share/man/man3 syslibdir = $(prefix)/$(LIB) usrlibdir = $(usr_prefix)/$(LIB) libdir = $(prefix)/$(LIB)/multipath @@ -102,7 +102,7 @@ mpathvaliddir = $(TOPDIR)/libmpathvalid thirdpartydir = $(TOPDIR)/third-party libdmmpdir = $(TOPDIR)/libdmmp nvmedir = $(TOPDIR)/libmultipath/nvme -includedir = $(prefix)/usr/include +includedir = $(prefix)/include pkgconfdir = $(usrlibdir)/pkgconfig plugindir := $(prefix)/$(LIB)/multipath configdir := $(prefix)/etc/multipath/conf.d diff --git a/libmpathutil/globals.c b/libmpathutil/globals.c index 0c9a5ba..0f6033e 100644 --- a/libmpathutil/globals.c +++ b/libmpathutil/globals.c @@ -2,11 +2,10 @@ #include #include "globals.h" -struct udev __attribute__((weak)) *udev; -struct config __attribute__((weak)) *get_multipath_config(void) +struct config *get_multipath_config(void) { return NULL; } -void __attribute__((weak)) put_multipath_config(void *p __attribute__((unused))) +void put_multipath_config(void *p __attribute__((unused))) {} diff --git a/libmpathutil/globals.h b/libmpathutil/globals.h index fab507e..a4d4d4e 100644 --- a/libmpathutil/globals.h +++ b/libmpathutil/globals.h @@ -3,25 +3,6 @@ struct config; -/** - * extern variable: udev - * - * A &struct udev instance used by libmultipath. libmultipath expects - * a valid, initialized &struct udev in this variable. - * An application can define this variable itself, in which case - * the applications's instance will take precedence. - * The application can initialize and destroy this variable by - * calling libmultipath_init() and libmultipath_exit(), respectively, - * whether or not it defines the variable itself. - * An application can initialize udev with udev_new() before calling - * libmultipath_init(), e.g. if it has to make libudev calls before - * libmultipath calls. If an application wants to keep using the - * udev variable after calling libmultipath_exit(), it should have taken - * an additional reference on it beforehand. This is the case e.g. - * after initializing udev with udev_new(). - */ -extern struct udev *udev; - /* * libmultipath provides default implementations of * get_multipath_config() and put_multipath_config(). diff --git a/libmpathutil/libmpathutil.version b/libmpathutil/libmpathutil.version index 95b169d..1238fc9 100644 --- a/libmpathutil/libmpathutil.version +++ b/libmpathutil/libmpathutil.version @@ -31,6 +31,18 @@ * The new version inherits the previous ones. */ +/* + * Symbols exported by both libmpathutil and libmultipath + * libmpathutil exports just dummy symbols, intended to be overriden + * by those in libmultipath. + * CAUTION - the version in libmpathutil.version and libmultipath.version + * must be THE SAME, otherwise the overriding will fail! + */ +LIBMPATHCOMMON_1.0.0 { + get_multipath_config; + put_multipath_config; +}; + /* symbols referenced by multipath and multipathd */ LIBMULTIPATH_16.0.0 { global: @@ -46,7 +58,6 @@ global: free_scandir_result; free_strvec; get_monotonic_time; - get_multipath_config; get_next_string; get_strbuf_len; get_strbuf_str; @@ -59,7 +70,6 @@ global: normalize_timespec; print_strbuf; pthread_cond_init_mono; - put_multipath_config; recv_packet; reset_strbuf; send_packet; @@ -70,7 +80,6 @@ global: timespeccmp; timespecsub; truncate_strbuf; - udev; ux_socket_listen; vector_alloc; vector_alloc_slot; @@ -90,7 +99,6 @@ LIBMPATHUTIL_1.0 { append_strbuf_quoted; basenamecpy; cleanup_free_ptr; - devt2devname; filepresent; find_keyword; free_keywords; diff --git a/libmpathutil/util.c b/libmpathutil/util.c index 6692ac2..9662e1e 100644 --- a/libmpathutil/util.c +++ b/libmpathutil/util.c @@ -163,32 +163,6 @@ size_t strlcat(char * restrict dst, const char * restrict src, size_t size) return bytes; } -int devt2devname(char *devname, int devname_len, const char *devt) -{ - struct udev_device *u_dev; - const char * dev_name; - int r; - - if (!devname || !devname_len || !devt) - return 1; - - u_dev = udev_device_new_from_devnum(udev, 'b', parse_devt(devt)); - if (!u_dev) { - condlog(0, "\"%s\": invalid major/minor numbers, not found in sysfs", devt); - return 1; - } - - dev_name = udev_device_get_sysname(u_dev); - if (!dev_name) { - udev_device_unref(u_dev); - return 1; - } - r = strlcpy(devname, dev_name, devname_len); - udev_device_unref(u_dev); - - return !(r < devname_len); -} - /* This function returns a pointer inside of the supplied pathname string. * If is_path_device is true, it may also modify the supplied string */ char *convert_dev(char *name, int is_path_device) diff --git a/libmpathutil/util.h b/libmpathutil/util.h index 7e34c56..75e20fd 100644 --- a/libmpathutil/util.h +++ b/libmpathutil/util.h @@ -18,7 +18,6 @@ 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); -int devt2devname (char *, int, const char *); 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); diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version index 3d86ecb..faef2a2 100644 --- a/libmultipath/libmultipath.version +++ b/libmultipath/libmultipath.version @@ -31,6 +31,18 @@ * The new version inherits the previous ones. */ +/* + * Symbols exported by both libmpathutil and libmultipath + * libmpathutil exports just dummy symbols, intended to be overriden + * by those in libmultipath. + * CAUTION - the version in libmpathutil.version and libmultipath.version + * must be THE SAME, otherwise the overriding will fail! + */ +LIBMPATHCOMMON_1.0.0 { + get_multipath_config; + put_multipath_config; +}; + LIBMULTIPATH_17.0.0 { global: /* symbols referenced by multipath and multipathd */ @@ -98,7 +110,6 @@ global: free_multipathvec; free_path; free_pathvec; - get_multipath_config; get_multipath_layout; get_path_layout; get_pgpolicy_id; @@ -122,7 +133,6 @@ global: libmp_dm_task_run; libmp_put_multipath_config; libmp_udev_set_sync_support; - libmp_verbosity; libmultipath_exit; libmultipath_init; load_config; @@ -137,7 +147,6 @@ global: print_all_paths; print_foreign_topology; _print_multipath_topology; - put_multipath_config; reinstate_paths; remember_wwid; remove_map; diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c index afde849..c45296a 100644 --- a/libmultipath/sysfs.c +++ b/libmultipath/sysfs.c @@ -38,6 +38,7 @@ #include "util.h" #include "debug.h" #include "devmapper.h" +#include "config.h" /* * When we modify an attribute value we cannot rely on libudev for now, @@ -181,6 +182,32 @@ sysfs_get_size (struct path *pp, unsigned long long * size) return 0; } +int devt2devname(char *devname, int devname_len, const char *devt) +{ + struct udev_device *u_dev; + const char * dev_name; + int r; + + if (!devname || !devname_len || !devt) + return 1; + + u_dev = udev_device_new_from_devnum(udev, 'b', parse_devt(devt)); + if (!u_dev) { + condlog(0, "\"%s\": invalid major/minor numbers, not found in sysfs", devt); + return 1; + } + + dev_name = udev_device_get_sysname(u_dev); + if (!dev_name) { + udev_device_unref(u_dev); + return 1; + } + r = strlcpy(devname, dev_name, devname_len); + udev_device_unref(u_dev); + + return !(r < devname_len); +} + int sysfs_check_holders(char * check_devt, char * new_devt) { unsigned int major, new_minor, table_minor; diff --git a/libmultipath/sysfs.h b/libmultipath/sysfs.h index 799f68e..2db86bd 100644 --- a/libmultipath/sysfs.h +++ b/libmultipath/sysfs.h @@ -7,6 +7,7 @@ #include #include "strbuf.h" +int devt2devname (char *, int, const char *); ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name, const char * value, size_t value_len); ssize_t sysfs_attr_get_value(struct udev_device *dev, const char *attr_name, diff --git a/libmultipath/version.h b/libmultipath/version.h index b5df67b..cc9a5ac 100644 --- a/libmultipath/version.h +++ b/libmultipath/version.h @@ -20,9 +20,9 @@ #ifndef _VERSION_H #define _VERSION_H -#define VERSION_CODE 0x000902 +#define VERSION_CODE 0x000903 /* MMDDYY, in hex */ -#define DATE_CODE 0x0A1816 +#define DATE_CODE 0x0A1A16 #define PROG "multipath-tools" diff --git a/tests/devt.c b/tests/devt.c index 0ad100a..aafee38 100644 --- a/tests/devt.c +++ b/tests/devt.c @@ -19,6 +19,9 @@ #include "util.h" #include "debug.h" +struct path; +#include "sysfs.h" + #include "globals.c" static bool sys_dev_block_exists(void)