All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-oe][PATCH V2] ledmon: control hard disk led for RAID arrays
@ 2019-04-10  4:32 Khem Raj
  2019-04-15 11:44 ` Adrian Bunk
  0 siblings, 1 reply; 3+ messages in thread
From: Khem Raj @ 2019-04-10  4:32 UTC (permalink / raw)
  To: openembedded-devel

From: Liwei Song <liwei.song@windriver.com>

Enable LED support for Intel Virtual RAID On CPU.
Fix build with musl

Signed-off-by: Liwei Song <liwei.song@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...ad-of-on_exit-for-musl-compatibility.patch | 53 +++++++++++++++++++
 ...include-sys-select.h-and-sys-types.h.patch | 43 +++++++++++++++
 meta-oe/recipes-bsp/ledmon/ledmon_git.bb      | 34 ++++++++++++
 3 files changed, 130 insertions(+)
 create mode 100644 meta-oe/recipes-bsp/ledmon/ledmon/0001-use-atexit-insead-of-on_exit-for-musl-compatibility.patch
 create mode 100644 meta-oe/recipes-bsp/ledmon/ledmon/0002-include-sys-select.h-and-sys-types.h.patch
 create mode 100644 meta-oe/recipes-bsp/ledmon/ledmon_git.bb

diff --git a/meta-oe/recipes-bsp/ledmon/ledmon/0001-use-atexit-insead-of-on_exit-for-musl-compatibility.patch b/meta-oe/recipes-bsp/ledmon/ledmon/0001-use-atexit-insead-of-on_exit-for-musl-compatibility.patch
new file mode 100644
index 0000000000..de5ce9fc83
--- /dev/null
+++ b/meta-oe/recipes-bsp/ledmon/ledmon/0001-use-atexit-insead-of-on_exit-for-musl-compatibility.patch
@@ -0,0 +1,53 @@
+From 8aba09b743b4e89ef581a679943ce39a5c7fd4a5 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 9 Apr 2019 21:25:21 -0700
+Subject: [PATCH 1/2] use atexit insead of on_exit for musl compatibility
+
+musl does not support on_exit which is used in clean up.
+Instead use atexit with is supported by musl and glibc.
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/ledctl.c | 2 +-
+ src/ledmon.c | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/ledctl.c b/src/ledctl.c
+index 2aa1abc..2c97dcf 100644
+--- a/src/ledctl.c
++++ b/src/ledctl.c
+@@ -689,7 +689,7 @@ int main(int argc, char *argv[])
+ 	status = _init_ledctl_conf();
+ 	if (status != STATUS_SUCCESS)
+ 		return status;
+-	if (on_exit(_ledctl_fini, progname))
++	if (atexit(_ledctl_fini))
+ 		exit(STATUS_ONEXIT_ERROR);
+ 	if (_cmdline_parse(argc, argv))
+ 		exit(STATUS_CMDLINE_ERROR);
+diff --git a/src/ledmon.c b/src/ledmon.c
+index 0ea2583..2333c7c 100644
+--- a/src/ledmon.c
++++ b/src/ledmon.c
+@@ -860,7 +860,7 @@ int main(int argc, char *argv[])
+ 	set_invocation_name(argv[0]);
+ 	openlog(progname, LOG_PID | LOG_PERROR, LOG_DAEMON);
+ 
+-	if (on_exit(_ledmon_status, &terminate))
++	if (atexit(_ledmon_status))
+ 		return STATUS_ONEXIT_ERROR;
+ 
+ 	if (_cmdline_parse_non_daemonise(argc, argv) != STATUS_SUCCESS)
+@@ -930,7 +930,7 @@ int main(int argc, char *argv[])
+ 	}
+ 	_ledmon_setup_signals();
+ 
+-	if (on_exit(_ledmon_fini, progname))
++	if (atexit(_ledmon_fini))
+ 		exit(STATUS_ONEXIT_ERROR);
+ 	list_init(&ledmon_block_list, (item_free_t)block_device_fini);
+ 	sysfs_init();
+-- 
+2.21.0
+
diff --git a/meta-oe/recipes-bsp/ledmon/ledmon/0002-include-sys-select.h-and-sys-types.h.patch b/meta-oe/recipes-bsp/ledmon/ledmon/0002-include-sys-select.h-and-sys-types.h.patch
new file mode 100644
index 0000000000..75bf2b4f5e
--- /dev/null
+++ b/meta-oe/recipes-bsp/ledmon/ledmon/0002-include-sys-select.h-and-sys-types.h.patch
@@ -0,0 +1,43 @@
+From 2ee8796db5019341b774bcb4f7d0944d89e1845b Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 9 Apr 2019 21:26:55 -0700
+Subject: [PATCH 2/2] include sys/select.h and sys/types.h
+
+sys/select.h is needed to provide fd_set definition
+sys/types.h is needed for ssize_t
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/dellssd.c | 1 +
+ src/utils.h   | 1 +
+ 2 files changed, 2 insertions(+)
+
+diff --git a/src/dellssd.c b/src/dellssd.c
+index 7b8d431..e97fe45 100644
+--- a/src/dellssd.c
++++ b/src/dellssd.c
+@@ -27,6 +27,7 @@
+ #include <unistd.h>
+ 
+ #include <sys/ioctl.h>
++#include <sys/select.h>
+ #include <linux/ipmi.h>
+ 
+ #if _HAVE_DMALLOC_H
+diff --git a/src/utils.h b/src/utils.h
+index 720447a..c106529 100644
+--- a/src/utils.h
++++ b/src/utils.h
+@@ -21,6 +21,7 @@
+ #define _UTILS_H_INCLUDED_
+ 
+ #include <getopt.h>
++#include <sys/types.h>
+ #include "config_file.h"
+ #include "stdlib.h"
+ #include "stdint.h"
+-- 
+2.21.0
+
diff --git a/meta-oe/recipes-bsp/ledmon/ledmon_git.bb b/meta-oe/recipes-bsp/ledmon/ledmon_git.bb
new file mode 100644
index 0000000000..4376ad3941
--- /dev/null
+++ b/meta-oe/recipes-bsp/ledmon/ledmon_git.bb
@@ -0,0 +1,34 @@
+SUMMARY = "Intel(R) Enclosure LED Utilities"
+
+DESCRIPTION = "The utilities are designed primarily to be used on storage servers \
+ utilizing MD devices (aka Linux Software RAID) for RAID arrays.\
+"
+HOMEPAGE = "https://github.com/intel/ledmon"
+
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
+"
+
+DEPENDS = "sg3-utils udev"
+
+inherit systemd
+
+SYSTEMD_SERVICE_${PN} = "ledmon.service"
+
+SRC_URI = "git://github.com/intel/ledmon;branch=master \
+           file://0001-use-atexit-insead-of-on_exit-for-musl-compatibility.patch \
+           file://0002-include-sys-select.h-and-sys-types.h.patch \
+          "
+
+SRCREV = "ad1304ca1363d727425a1f23703c523e21feae4f"
+
+COMPATIBLE_HOST = "(i.86|x86_64).*-linux"
+
+S = "${WORKDIR}/git"
+EXTRA_OEMAKE = "CC='${CC}' LDFLAGS='${LDFLAGS}' CFLAGS='${CFLAGS}'"
+
+do_install_append() {
+	install -d ${D}/${systemd_unitdir}/system
+	oe_runmake  DESTDIR=${D}  install
+	oe_runmake  DESTDIR=${D}${systemd_unitdir}/system  install-systemd
+}
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [meta-oe][PATCH V2] ledmon: control hard disk led for RAID arrays
  2019-04-10  4:32 [meta-oe][PATCH V2] ledmon: control hard disk led for RAID arrays Khem Raj
@ 2019-04-15 11:44 ` Adrian Bunk
  2019-04-15 14:29   ` Khem Raj
  0 siblings, 1 reply; 3+ messages in thread
From: Adrian Bunk @ 2019-04-15 11:44 UTC (permalink / raw)
  To: Khem Raj; +Cc: openembedded-devel

On Tue, Apr 09, 2019 at 09:32:44PM -0700, Khem Raj wrote:
>...
> +musl does not support on_exit which is used in clean up.
> +Instead use atexit with is supported by musl and glibc.

The functions have different signatures, and this patch introduces bugs 
for cases that use the parameters of on_exit.

int on_exit(void (*function)(int , void *), void *arg);
int atexit(void (*function)(void));

Example:

>...
> +-	if (on_exit(_ledmon_status, &terminate))
> ++	if (atexit(_ledmon_status))
>...

static void _ledmon_status(int status, void *ignore)
{
        if (*((int *)ignore) != 0)
                log_info("exit status is %s.", strstatus(status));
        else if (status != STATUS_SUCCESS)
                log_error("parent exit status is %s.", strstatus(status));
}

With the bogus atexit change no parameters are passed to _ledmon_status,
and the function uses (and dereferenes) whatever garbage is currently
in the stack/registers where function parameters are expected.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [meta-oe][PATCH V2] ledmon: control hard disk led for RAID arrays
  2019-04-15 11:44 ` Adrian Bunk
@ 2019-04-15 14:29   ` Khem Raj
  0 siblings, 0 replies; 3+ messages in thread
From: Khem Raj @ 2019-04-15 14:29 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: openembedded-devel

On Mon, Apr 15, 2019 at 4:44 AM Adrian Bunk <bunk@stusta.de> wrote:

> On Tue, Apr 09, 2019 at 09:32:44PM -0700, Khem Raj wrote:
> >...
> > +musl does not support on_exit which is used in clean up.
> > +Instead use atexit with is supported by musl and glibc.
>
> The functions have different signatures, and this patch introduces bugs
> for cases that use the parameters of on_exit.
>
> int on_exit(void (*function)(int , void *), void *arg);
> int atexit(void (*function)(void));
>
> Example:
>
> >...
> > +-    if (on_exit(_ledmon_status, &terminate))
> > ++    if (atexit(_ledmon_status))
> >...
>
> static void _ledmon_status(int status, void *ignore)
> {
>         if (*((int *)ignore) != 0)
>                 log_info("exit status is %s.", strstatus(status));
>         else if (status != STATUS_SUCCESS)
>                 log_error("parent exit status is %s.", strstatus(status));
> }
>
> With the bogus atexit change no parameters are passed to _ledmon_status,
> and the function uses (and dereferenes) whatever garbage is currently
> in the stack/registers where function parameters are expected.


Thanks for looking into it and This is correct somehow I overlooked it i
will send a follow up to not rely on arguments for on_exit

>
>
> cu
> Adrian
>
> --
>
>        "Is there not promise of rain?" Ling Tan asked suddenly out
>         of the darkness. There had been need of rain for many days.
>        "Only a promise," Lao Er said.
>                                        Pearl S. Buck - Dragon Seed
>
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-15 14:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-10  4:32 [meta-oe][PATCH V2] ledmon: control hard disk led for RAID arrays Khem Raj
2019-04-15 11:44 ` Adrian Bunk
2019-04-15 14:29   ` Khem Raj

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.