#include <linux/types.h>
#include <linux/netlink.h>
#include <pthread.h>
+#include <limits.h>
#include <sys/mman.h>
#include "memory.h"
return (uevqhp != NULL || servicing_uev);
}
+void
+setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached)
+{
+ if (pthread_attr_init(attr)) {
+ fprintf(stderr, "can't initialize thread attr: %s\n",
+ strerror(errno));
+ exit(1);
+ }
+ if (stacksize < PTHREAD_STACK_MIN)
+ stacksize = PTHREAD_STACK_MIN;
+
+ if (pthread_attr_setstacksize(attr, stacksize)) {
+ fprintf(stderr, "can't set thread stack size to %lu: %s\n",
+ (unsigned long)stacksize, strerror(errno));
+ exit(1);
+ }
+ if (detached && pthread_attr_setdetachstate(attr,
+ PTHREAD_CREATE_DETACHED)) {
+ fprintf(stderr, "can't set thread to detached: %s\n",
+ strerror(errno));
+ exit(1);
+ }
+}
+
static struct uevent * alloc_uevent (void)
{
return (struct uevent *)MALLOC(sizeof(struct uevent));
pthread_mutex_init(uevc_lockp, NULL);
pthread_cond_init(uev_condp, NULL);
- pthread_attr_init(&attr);
- pthread_attr_setstacksize(&attr, 64 * 1024);
+ setup_thread_attr(&attr, 64 * 1024, 0);
pthread_create(&uevq_thr, &attr, uevq_thread, NULL);
/*
-/* environment buffer, the kernel's size in lib/kobject_uevent.c should fit in */
+#ifndef _UEVENT_H
+#define _UEVENT_H
+
+/*
+ * buffer for environment variables, the kernel's size in
+ * lib/kobject_uevent.c should fit in
+*/
#define HOTPLUG_BUFFER_SIZE 1024
#define HOTPLUG_NUM_ENVP 32
#define OBJECT_SIZE 512
int uevent_listen(int (*store_uev)(struct uevent *, void * trigger_data),
void * trigger_data);
int is_uevent_busy(void);
+void setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached);
+
+#endif /* _UEVENT_H */
fclose(fp);
}
-void
-setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached)
-{
- if (pthread_attr_init(attr)) {
- fprintf(stderr, "can't initialize thread attr: %s\n",
- strerror(errno));
- exit(1);
- }
- if (stacksize < PTHREAD_STACK_MIN)
- stacksize = PTHREAD_STACK_MIN;
-
- if (pthread_attr_setstacksize(attr, stacksize)) {
- fprintf(stderr, "can't set thread stack size to %lu: %s\n",
- (unsigned long)stacksize, strerror(errno));
- exit(1);
- }
- if (detached && pthread_attr_setdetachstate(attr,
- PTHREAD_CREATE_DETACHED)) {
- fprintf(stderr, "can't set thread to detached: %s\n",
- strerror(errno));
- exit(1);
- }
-}
-
static int
child (void * param)
{