List of commits:
Subject Hash Author Date (UTC)
uevent monitor to ulinux patterns e9e2e03953d3a28e08aeb3a7388b334cda8a8479 Sylvain BERTRAND 2011-12-26 22:38:45
modules properly loaded ac79794945662bad9e97562c479dea5afe455687 Sylvain BERTRAND 2011-12-26 22:08:54
ulinux patterns: insert a kernel module ed879829ce6c44b77bddcd9c106a106261f47301 Sylvain BERTRAND 2011-12-26 21:29:33
ulinux dir_parse pattern 63cc7acc186efc291a76255e97d86e80901174e5 Sylvain BERTRAND 2011-12-26 02:24:55
ulinux improvements and more patterns a458c52301d3a34e8b51794fea7c1cb06c1c34f8 Sylvain BERTRAND 2011-12-22 22:09:06
ulinux patterns:network server 60c167bcd530f95d0a57189035620c3bc80f1e34 Sylvain BERTRAND 2011-12-20 00:39:56
ulinux cleanup and samples 92c893f28ef42f11943c0bf80a037a5b5f34ebef Sylvain BERTRAND 2011-12-16 01:51:22
uevent listener 55657699f291575139858aec466340e7624cd66a Sylvain BERTRAND 2011-12-15 18:01:06
uevent monitor e241bd4db4af8510902a5c606eee0e1e2dbdecda Sylvain BERTRAND 2011-12-13 00:37:45
block signals 91772917669645b5634563d0c06e361c87cf3e84 Sylvain BERTRAND 2011-12-09 17:04:34
initial commit 5310fde2d021e3505f8f1d5d9091726c236967ec Sylvain BERTRAND 2011-12-07 11:29:18
Commit e9e2e03953d3a28e08aeb3a7388b334cda8a8479 - uevent monitor to ulinux patterns
Author: Sylvain BERTRAND
Author date (UTC): 2011-12-26 22:38
Committer name: Sylvain BERTRAND
Committer date (UTC): 2011-12-26 22:38
Parent(s): ac79794945662bad9e97562c479dea5afe455687
Signer:
Signing key:
Signing status: N
Tree: 4a5d53465036da499cad1b4f6d0eba3bafa19fc4
File Lines added Lines deleted
init.c 3 3
makefile 5 14
uevent.h 0 11
uevents.c 10 11
uevents.h 4 3
ulinux/patterns/INDEX 3 0
ulinux/patterns/uevents_monitor/makefile 6 8
ulinux/patterns/uevents_monitor/uevents_monitor.c 2 3
File init.c changed (mode: 100644) (index 98b7f81..9650bdb)
22 22 #endif #endif
23 23
24 24 #include "modules.h" #include "modules.h"
25 #include "uevent.h"
25 #include "uevents.h"
26 26 #include "globals.h" #include "globals.h"
27 27
28 28 #ifdef DEBUG #ifdef DEBUG
 
... ... void _start(void)
53 53 g_dprintf_buf=dprintf_buf; g_dprintf_buf=dprintf_buf;
54 54 # endif # endif
55 55 sigs_setup(); sigs_setup();
56 uevent_setup();
56 uevents_setup();
57 57 modules_load(); modules_load();
58 uevent_recv();
58 uevents_process();
59 59 sysc(exit_group,1,0); sysc(exit_group,1,0);
60 60 } }
File makefile changed (mode: 100644) (index 07787c4..438b68b)
1 1 include conf.mk include conf.mk
2 2
3 .PHONY:all dirs clean am_i_root help uevent_monitor
3 .PHONY:all dirs clean am_i_root help
4 4
5 5 DIRS=\ DIRS=\
6 6 $(S_DIR) \ $(S_DIR) \
 
... ... $(CPIO_DIR)/sys
14 14 OBJS=\ OBJS=\
15 15 $(OBJ_DIR)/init.o \ $(OBJ_DIR)/init.o \
16 16 $(OBJ_DIR)/modules.o \ $(OBJ_DIR)/modules.o \
17 $(OBJ_DIR)/uevent.o
17 $(OBJ_DIR)/uevents.o
18 18
19 19 ifdef DEBUG ifdef DEBUG
20 20 ULINUX_DEBUG_OBJS=\ ULINUX_DEBUG_OBJS=\
 
... ... OBJS+= $(ULINUX_DEBUG_OBJS)
26 26 endif endif
27 27
28 28 help: help:
29 @echo "targets are 'all', 'help'(this output), 'clean', 'uevent_monitor'"
29 @echo "targets are 'all', 'help'(this output), 'clean'"
30 30 @echo -e "you can configure the build with the following variables:\\n\ @echo -e "you can configure the build with the following variables:\\n\
31 31 SYSROOT, KERNEL_VERSION, ARCH, MODULES, SCSI_WAIT, CC, LD, CFLAGS, LDFLAGS\\n\ SYSROOT, KERNEL_VERSION, ARCH, MODULES, SCSI_WAIT, CC, LD, CFLAGS, LDFLAGS\\n\
32 32 (you can tune the conf.mk file)" (you can tune the conf.mk file)"
 
... ... $(S_DIR)/modules.s:modules.c modules_list.h
79 79 $(OBJ_DIR)/modules.o:$(S_DIR)/modules.s $(OBJ_DIR)/modules.o:$(S_DIR)/modules.s
80 80 $(AS) $(ASFLAGS) $< -o $@ $(AS) $(ASFLAGS) $< -o $@
81 81
82 $(S_DIR)/uevent.s:uevent.c
82 $(S_DIR)/uevents.s:uevents.c
83 83 $(CC) $(CFLAGS) $< -o $@ $(CC) $(CFLAGS) $< -o $@
84 $(OBJ_DIR)/uevent.o:$(S_DIR)/uevent.s
84 $(OBJ_DIR)/uevents.o:$(S_DIR)/uevents.s
85 85 $(AS) $(ASFLAGS) $< -o $@ $(AS) $(ASFLAGS) $< -o $@
86 86
87 87 $(S_DIR)/init.s:init.c modules.h $(S_DIR)/init.s:init.c modules.h
 
... ... clean:
99 99 -rm -f ulinux/arch -rm -f ulinux/arch
100 100 -rm -Rf $(BUILD_DIR) -rm -Rf $(BUILD_DIR)
101 101 -rm -f modules_list.h -rm -f modules_list.h
102
103 #===============================================================================
104 $(BUILD_DIR)/uevent_monitor:uevent_monitor.c $(ULINUX_DEBUG_OBJS)
105 $(CC) $(CFLAGS) -fverbose-asm -S $< -o $(S_DIR)/uevent_monitor.s
106 $(AS) $(S_DIR)/uevent_monitor.s -o $(OBJ_DIR)/uevent_monitor.o
107 $(LD) $(LDFLAGS) $(OBJ_DIR)/uevent_monitor.o $(ULINUX_DEBUG_OBJS) --output $@
108
109 uevent_monitor:dirs ulinux/arch $(BUILD_DIR)/uevent_monitor
110 #===============================================================================
File uevent.h deleted (index ddd67fe..0000000)
1 #ifndef UEVENT_H
2 #define UEVENT_H
3 //******************************************************************************
4 //*this code is protected by the GNU affero GPLv3
5 //*author:Sylvain BERTRAND <sylvain.bertrand AT gmail dot com>
6 //* <digital.ragnarok AT gmail dot com>
7 //******************************************************************************
8 void uevent_setup(void);
9 void uevent_recv(void);
10 //void uevent_recv_thread_start(void);
11 #endif
File uevents.c renamed from uevent.c (similarity 86%) (mode: 100644) (index 4306e6f..c7ab039)
26 26 static k_i ep_fd=-1; static k_i ep_fd=-1;
27 27 static k_i s=-1; static k_i s=-1;
28 28
29 void uevent_setup(void)
29 void uevents_setup(void)
30 30 { {
31 31 OUTC(PRE "setting up uevent..."); OUTC(PRE "setting up uevent...");
32 32 ep_fd=(k_i)sysc(epoll_create1,1,0); ep_fd=(k_i)sysc(epoll_create1,1,0);
33 33 if(K_ISERR(ep_fd)){ if(K_ISERR(ep_fd)){
34 OUT("ERROR:unable to create epoll fd (%d)\n",ep_fd);
34 OUT("ERROR(%d):unable to create epoll fd\n",ep_fd);
35 35 sysc(exit_group,1,-1); sysc(exit_group,1,-1);
36 36 } }
37 37
 
... ... void uevent_setup(void)
40 40 s=(k_i)sysc(socket,3,K_PF_NETLINK,K_SOCK_RAW|K_SOCK_NONBLOCK, s=(k_i)sysc(socket,3,K_PF_NETLINK,K_SOCK_RAW|K_SOCK_NONBLOCK,
41 41 K_NETLINK_KOBJECT_UEVENT); K_NETLINK_KOBJECT_UEVENT);
42 42 if(K_ISERR(s)){ if(K_ISERR(s)){
43 OUT("ERROR:unable to create uevent netlink socket:%d\n",s);
43 OUT("ERROR(%d):unable to create uevent netlink socket\n",s);
44 44 sysc(exit_group,1,-1); sysc(exit_group,1,-1);
45 45 } }
46 46
47 47 //---------------------------------------------------------------------------- //----------------------------------------------------------------------------
48 48
49 k_i recv_buf_sz=128*1024*1024;
49 k_i recv_buf_sz=128*1024;//128k for kernel buffering
50 50 k_l r=sysc(setsockopt,5,s,K_SOL_SOCKET,K_SO_RCVBUFFORCE,&recv_buf_sz, k_l r=sysc(setsockopt,5,s,K_SOL_SOCKET,K_SO_RCVBUFFORCE,&recv_buf_sz,
51 51 sizeof(recv_buf_sz)); sizeof(recv_buf_sz));
52 52 if(K_ISERR(r)){ if(K_ISERR(r)){
53 OUT("ERROR:unable to force the size of the socket buffer:%ld\n",r);
53 OUT("ERROR(%ld):unable to force the size of the socket buffer\n",r);
54 54 sysc(exit_group,1,-1); sysc(exit_group,1,-1);
55 55 } }
56 56
 
... ... void uevent_setup(void)
60 60 struct k_sockaddr_nl addr={K_AF_NETLINK,0,0,1}; struct k_sockaddr_nl addr={K_AF_NETLINK,0,0,1};
61 61 r=sysc(bind,3,s,&addr,sizeof(addr)); r=sysc(bind,3,s,&addr,sizeof(addr));
62 62 if(K_ISERR(r)){ if(K_ISERR(r)){
63 OUT("ERROR:unable to bind address to uevent netlink socket:%ld\n",r);
63 OUT("ERROR(%ld):unable to bind address to uevent netlink socket\n",r);
64 64 sysc(exit_group,1,-1); sysc(exit_group,1,-1);
65 65 } }
66 66
 
... ... void uevent_setup(void)
72 72 ep_evt.data.fd=s; ep_evt.data.fd=s;
73 73 r=sysc(epoll_ctl,4,ep_fd,K_EPOLL_CTL_ADD,s,&ep_evt); r=sysc(epoll_ctl,4,ep_fd,K_EPOLL_CTL_ADD,s,&ep_evt);
74 74 if(K_ISERR(r)){ if(K_ISERR(r)){
75 OUT("ERROR:unable to register uevent netlink socket to epoll (%ld)\n",
76 r);
75 OUT("ERROR(%ld):unable to register uevent netlink socket to epoll\n",r);
77 76 sysc(exit_group,1,-1); sysc(exit_group,1,-1);
78 77 } }
79 78 OUTC("done\n"); OUTC("done\n");
 
... ... static void uevent_msg(k_i s)
98 97 r=sysc(recvmsg,3,s,&msg,0); r=sysc(recvmsg,3,s,&msg,0);
99 98 }while(r==-K_EINTR); }while(r==-K_EINTR);
100 99 if(K_ISERR(r)){ if(K_ISERR(r)){
101 OUT("ERROR:unable to receive the uevent(%ld)\n",r);
100 OUT("ERROR(%ld):unable to receive the uevent\n",r);
102 101 sysc(exit_group,1,-1); sysc(exit_group,1,-1);
103 102 } }
104 103 if(msg.flgs&K_MSG_TRUNC){ if(msg.flgs&K_MSG_TRUNC){
 
... ... static void uevent_msg(k_i s)
116 115 OUTC("\n"); OUTC("\n");
117 116 } }
118 117
119 void uevent_recv(void)
118 void uevents_process(void)
120 119 { {
121 OUTC(PRE "receiving uevent...\n");
120 OUTC(PRE "processing uevents...\n");
122 121 while(1){ while(1){
123 122 k_l r; k_l r;
124 123 static struct k_epoll_event evts[1];//uevent netlink event static struct k_epoll_event evts[1];//uevent netlink event
File uevents.h copied from file modules.h (similarity 79%) (mode: 100644) (index f5e162a..5832804)
1 #ifndef MODULES_H
2 #define MODULES_H
1 #ifndef UEVENTS_H
2 #define UEVENTS_H
3 3 //****************************************************************************** //******************************************************************************
4 4 //*this code is protected by the GNU affero GPLv3 //*this code is protected by the GNU affero GPLv3
5 5 //*author:Sylvain BERTRAND <sylvain.bertrand AT gmail dot com> //*author:Sylvain BERTRAND <sylvain.bertrand AT gmail dot com>
6 6 //* <digital.ragnarok AT gmail dot com> //* <digital.ragnarok AT gmail dot com>
7 7 //****************************************************************************** //******************************************************************************
8 void modules_load(void);
8 void uevents_setup(void);
9 void uevents_process(void);
9 10 #endif #endif
File ulinux/patterns/INDEX changed (mode: 100644) (index c97a4c0..65b0da7)
... ... o network_server
17 17
18 18 o thread o thread
19 19 create a thread create a thread
20
21 o uevents_monitor
22 monitor uevents from the kernel
File ulinux/patterns/uevents_monitor/makefile copied from file ulinux/patterns/args/makefile (similarity 68%) (mode: 100644) (index 09250c7..dc6eeb9)
2 2
3 3 ARCH?=$(shell uname -m | sed -e s/i.86/i386/ -e s/parisc64/parisc/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/sh.*/sh/) ARCH?=$(shell uname -m | sed -e s/i.86/i386/ -e s/parisc64/parisc/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/sh.*/sh/)
4 4
5 args:args.c ../../../ulinux/arch
5 uevents_monitor:uevents_monitor.c ../../../ulinux/arch
6 6 gcc -Wall -Wextra -std=gnu99 -O3 -march=native -fverbose-asm -I../../.. -S \ gcc -Wall -Wextra -std=gnu99 -O3 -march=native -fverbose-asm -I../../.. -S \
7 7 ../../arch/utils/mem.c -o mem.s ../../arch/utils/mem.c -o mem.s
8 8 as mem.s -o mem.o as mem.s -o mem.o
 
... ... args:args.c ../../../ulinux/arch
12 12 gcc -Wall -Wextra -std=gnu99 -O3 -march=native -fverbose-asm -I../../.. -S \ gcc -Wall -Wextra -std=gnu99 -O3 -march=native -fverbose-asm -I../../.. -S \
13 13 ../../utils/ascii/string/string.c -o string.s ../../utils/ascii/string/string.c -o string.s
14 14 as string.s -o string.o as string.s -o string.o
15 as ../../arch/args.s -o arch_args.o
16 15 gcc -Wall -Wextra -std=gnu99 -O3 -march=native -fverbose-asm -I../../.. -S \ gcc -Wall -Wextra -std=gnu99 -O3 -march=native -fverbose-asm -I../../.. -S \
17 args.c -o args.s
18 as args.s -o args.o
19 ld -O -nostdlib -Bstatic --strip-all args.o arch_args.o string.o mem.o vsprintf.o --output args
16 uevents_monitor.c -o uevents_monitor.s
17 as uevents_monitor.s -o uevents_monitor.o
18 ld -O -nostdlib -Bstatic --strip-all uevents_monitor.o string.o mem.o vsprintf.o --output uevents_monitor
20 19
21 20 ../../../ulinux/arch: ../../../ulinux/arch:
22 21 ln -s archs/$(ARCH) ../../../ulinux/arch ln -s archs/$(ARCH) ../../../ulinux/arch
23 22
24 23 clean: clean:
25 -rm -f ../../../ulinux/arch args.s args.o args \
24 -rm -f ../../../ulinux/arch uevents_monitor.s uevents_monitor.o uevents_monitor \
26 25 mem.s mem.o \ mem.s mem.o \
27 26 string.s string.o \ string.s string.o \
28 vsprintf.s vsprintf.o \
29 arch_args.o
27 vsprintf.s vsprintf.o
File ulinux/patterns/uevents_monitor/uevents_monitor.c renamed from uevent_monitor.c (similarity 97%) (mode: 100644) (index 18603bc..ddd0ccd)
3 3 //*author:Sylvain BERTRAND <sylvain.bertrand AT gmail dot com> //*author:Sylvain BERTRAND <sylvain.bertrand AT gmail dot com>
4 4 //* <digital.ragnarok AT gmail dot com> //* <digital.ragnarok AT gmail dot com>
5 5 //****************************************************************************** //******************************************************************************
6 #include <stdarg.h>
6 7 #include <ulinux/compiler_types.h> #include <ulinux/compiler_types.h>
7 8 #include <ulinux/sysc.h> #include <ulinux/sysc.h>
8 9 #include <ulinux/types.h> #include <ulinux/types.h>
 
16 17 #include <ulinux/socket/msg.h> #include <ulinux/socket/msg.h>
17 18 #include <ulinux/socket/netlink.h> #include <ulinux/socket/netlink.h>
18 19 #include <ulinux/epoll.h> #include <ulinux/epoll.h>
19 #include <stdarg.h>
20 20 #include <ulinux/utils/ascii/string/vsprintf.h> #include <ulinux/utils/ascii/string/vsprintf.h>
21 21 #include <ulinux/utils/mem.h> #include <ulinux/utils/mem.h>
22 22
23 23 //XXX:what udev does in extra //XXX:what udev does in extra
24 // - it force overides the kernel socket buffer size to 128 MB (then 256 MB)
25 24 // - it checks on socket credential // - it checks on socket credential
26 25 // - it checks the netlink sender is 0 (kernel) // - it checks the netlink sender is 0 (kernel)
27 26 // - it uses the socket filter // - it uses the socket filter
 
... ... void _start(void)
95 94
96 95 //why that big (stolen from udev)? //why that big (stolen from udev)?
97 96 //moreover it can be skipped most of the time //moreover it can be skipped most of the time
98 //must be priviledge
97 //must be priviledged
99 98 k_i recv_buf_sz=128*1024*1024; k_i recv_buf_sz=128*1024*1024;
100 99 k_l r=sysc(setsockopt,5,s,K_SOL_SOCKET,K_SO_RCVBUFFORCE,&recv_buf_sz, k_l r=sysc(setsockopt,5,s,K_SOL_SOCKET,K_SO_RCVBUFFORCE,&recv_buf_sz,
101 100 sizeof(recv_buf_sz)); sizeof(recv_buf_sz));
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/sylware/cinitramfs

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/sylware/cinitramfs

Clone this repository using git:
git clone git://git.rocketgit.com/user/sylware/cinitramfs

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main