*
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
-
//config:config UEVENT
-//config: bool "uevent"
+//config: bool "uevent (3.2 kb)"
//config: default y
//config: select PLATFORM_LINUX
//config: help
-//config: uevent is a netlink listener for kernel uevent notifications
-//config: sent via netlink. It is usually used for dynamic device creation.
+//config: uevent is a netlink listener for kernel uevent notifications
+//config: sent via netlink. It is usually used for dynamic device creation.
//applet:IF_UEVENT(APPLET(uevent, BB_DIR_SBIN, BB_SUID_DROP))
//usage: "\n"" # uevent mdev & mdev -s"
#include "libbb.h"
+#include "common_bufsiz.h"
#include <linux/netlink.h>
#define BUFFER_SIZE 16*1024
-#define env ((char **)&bb_common_bufsiz1)
+#define env ((char **)bb_common_bufsiz1)
+#define INIT_G() do { setup_common_bufsiz(); } while (0)
enum {
- MAX_ENV = COMMON_BUFSIZE / sizeof(env[0]) - 1,
+ MAX_ENV = COMMON_BUFSIZE / sizeof(char*) - 1,
+ /* sizeof(env[0]) instead of sizeof(char*)
+ * makes gcc-6.3.0 emit "strict-aliasing" warning.
+ */
};
#ifndef SO_RCVBUFFORCE
#define SO_RCVBUFFORCE 33
#endif
-static const int RCVBUF = 2 * 1024 * 1024;
+enum { RCVBUF = 2 * 1024 * 1024 };
int uevent_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int uevent_main(int argc UNUSED_PARAM, char **argv)
struct sockaddr_nl sa;
int fd;
+ INIT_G();
+
argv++;
// Subscribe for UEVENT kernel messages
// find /sys -name uevent -exec sh -c 'echo add >"{}"' ';'
//
// SO_RCVBUFFORCE (root only) can go above net.core.rmem_max sysctl
- setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &RCVBUF, sizeof(RCVBUF));
- setsockopt(fd, SOL_SOCKET, SO_RCVBUFFORCE, &RCVBUF, sizeof(RCVBUF));
+ setsockopt_SOL_SOCKET_int(fd, SO_RCVBUF, RCVBUF);
+ setsockopt_SOL_SOCKET_int(fd, SO_RCVBUFFORCE, RCVBUF);
if (0) {
int z;
socklen_t zl = sizeof(z);