[PLUG] Compiling my driver into kernel statically.
kirandivekar at gmail.com
Fri Mar 15 18:01:08 IST 2013
On Tue, Mar 12, 2013 at 12:14 PM, Sagar Padhye <sgr.m.pdy at gmail.com> wrote:
> I have successfully created a dummy procfile with read/write calls. I know
> this is old way of coding & I should use sysfs, but still I did it.
> When I compile this thing as module it works fine - proc file is created,
> read & write works.
> Then I thought of playing around a bit - I kept my code in
> linux-x.x.x/drivers/sagar dir. Added an entry -
> > obj-y += sagar/
> to makefile of drivers dir. Added following makefile to drivers/sagar dir
> $ car /path/to/linux/src/drivers/sagar/Makefile
> obj-y += procfs-2.o
> compiled linux the usual way -> clean, mrproper, bzImage, modules,
> modules_install, copy bzImage to /boot & update-grub (ubuntu) and rebooted
> into new kernel.
> It looks like, the /proc file I was expecting is not created, so I think
> init_module is not called when we link the code statically to the kernel -
> I thought this function would be called by the `init` process. But looks
> like my assumption was wrong. I got none of my printk (INFO) logs in dmesg
> just after startup.
> When I do cat /proc/kallsyms , I can find my variables & functions in there
> as follows
> ffffffff81436800 T cleanup_module
> ffffffff81436830 T init_module
> ffffffff814368d0 T procfile_write
> ffffffff81436910 T procfile_read
> ffffffff819e22c0 b procfs_buffer_size
> ffffffff819e22c8 b my_proc_file
> ffffffff819e22e0 b procfs_buffer
> Still the /proc file I was expecting is not there. Can somebody point me to
> right ans?
First check if your module is able to create a file in /proc, by loading it
dynamically. module_init for all built-in kernle modules get called during
kernel initialization....see thread here for more understanding....
> Kernel used - 18.104.22.168
> Note : I have started reading 'http://lwn.net/Kernel/LDD3/' as pointed by
> Prashant, but I am just dying to get this working. :P
> Pune GNU/Linux Users Group Mailing List
More information about the Plug-mail