Hi,here is my dummy module code#include <linux/kernel.h>
#include <linux/module.h>
#include<linux/sched.h>
#ifdef CONFIG_PROC_FS
#include <linux/proc_fs.h>
#include <linux/sysctl.h>
#endif
unsigned int status;
enum { STATUS_ENTRY=555,
MYMOD_DIR_ENTRY,
MYMOD_FS_DIR_ENTRY
};
/* Creating the /proc/sys tree
* * fs -> my_mod -> {status}
* */
struct ctl_table inner_mymod_ctl_table[] = {
{
STATUS_ENTRY,"status",&status,sizeof(int),
0666,NULL,&proc_dointvec,NULL
},
{0}
};
struct ctl_table mymod_ctl_table[] = {
{
MYMOD_DIR_ENTRY,"my_mod",0,0,0,inner_mymod_ctl_table
},
{0}
};struct ctl_table fs_mymod_ctl_table[] = {
{
MYMOD_FS_DIR_ENTRY,"fs",0,0,0,mymod_ctl_table
},
{0}
};static struct ctl_table_header *inner_mymod_ctl_header;
static struct ctl_table_header *mymod_ctl_header;
static struct ctl_table_header *fs_mymod_ctl_header;/* Initialize the module */
int init_module()
{
printk("Hello, world - this is the kernel speaking\n");#ifdef CONFIG_PROC_FS
/* Entry for /proc/sys/fs/my_mod/status */
if(!(fs_mymod_ctl_header = register_sysctl_table((struct ctl_table *)fs_mymod_ctl_table,0)))
printk(KERN_INFO "Unable to create register_sysctl: /proc/sys/ variables ");
#endif
return 0;
}/* Cleanup - undid whatever init_module did */
void cleanup_module()
{
printk("Short is the life of a kernel module\n");
if(fs_mymod_ctl_header)
unregister_sysctl_table((struct ctl_table_header *)fs_mymod_ctl_header);}
On 12/13/05, Arjan van de Ven < arjan@xxxxxxxxxxxxx > wrote:On Tue, 2005-12-13 at 21:07 +0900, Adil Mujeeb wrote:
> Hi Could you please tell me how to set that?
> BTW the proc entry has read permission to everyone.
is easiest to do if you post your code or, better, a URL to the full
source code...
>
Hi,
i hav got the solution,
After successfull call to register_sysctl_table add the following statement
fs_mymod_ctl_header->ctl_table->child->child->de->owner = THIS_MODULE
Now if any process has opend the proc entry and u r rmmoding the module it wont let u to unload the module.
Rgds,
Adil
On 12/14/05, Adil Mujeeb <mujeeb.adil@xxxxxxxxx> wrote: