diff --git a/LKMPG-3.16.html b/LKMPG-3.16.html
index 0172894..53aa463 100644
--- a/LKMPG-3.16.html
+++ b/LKMPG-3.16.html
@@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
+
The Linux Kernel Module Programming Guide
@@ -3520,7 +3520,7 @@ DECLARE_WAIT_QUEUE_HEAD(WaitQ);
for (i = 0; i < _NSIG_WORDS && !is_sig; i++)
is_sig =
current->pending.signal.sig[i] & ~current->
- blocked.sig[i];
+ blocked.sig[i];
if (is_sig) {
@@ -3545,8 +3545,8 @@ DECLARE_WAIT_QUEUE_HEAD(WaitQ);
- Already_Open = 1;
- return 0;
+ Already_Open = 1;
+ return 0;
}
@@ -3573,33 +3573,6 @@ DECLARE_WAIT_QUEUE_HEAD(WaitQ);
return 0;
}
-
-
-
-
-
-
-
-
-
-
-
-
-static int module_permission(struct inode *inode, int op, struct nameidata *nd)
-{
-
-
-
-
- if (op == 4 || (op == 2 && current->euid == 0))
- return 0;
-
-
-
-
- return -EACCES;
-}
-
@@ -3611,22 +3584,10 @@ DECLARE_WAIT_QUEUE_HEAD(WaitQ);
static struct file_operations File_Ops_4_Our_Proc_File = {
- .read = module_output,
- .write = module_input,
- .open = module_open,
- .release = module_close,
-};
-
-
-
-
-
-
-
-
-
-static struct inode_operations Inode_Ops_4_Our_Proc_File = {
- .permission = module_permission,
+ .read = module_output,
+ .write = module_input,
+ .open = module_open,
+ .release = module_close,
};
@@ -3639,21 +3600,15 @@ DECLARE_WAIT_QUEUE_HEAD(WaitQ);
int init_module()
{
- Our_Proc_File = create_proc_entry(PROC_ENTRY_FILENAME, 0644, NULL);
-
- if (Our_Proc_File == NULL) {
- remove_proc_entry(PROC_ENTRY_FILENAME, &proc_root);
- printk(KERN_ALERT "Error: Could not initialize /proc/test\n");
+ Our_Proc_File = proc_create(PROC_ENTRY_FILENAME, 0644, NULL, &File_Ops_4_Our_Proc_File);
+ if(Our_Proc_File == NULL)
+ {
+ remove_proc_entry(PROC_ENTRY_FILENAME, NULL);
+ printk(KERN_DEBUG "Error: Could not initialize /proc/%s\n", PROC_ENTRY_FILENAME);
return -ENOMEM;
}
-
- Our_Proc_File->owner = THIS_MODULE;
- Our_Proc_File->proc_iops = &Inode_Ops_4_Our_Proc_File;
- Our_Proc_File->proc_fops = &File_Ops_4_Our_Proc_File;
- Our_Proc_File->mode = S_IFREG | S_IRUGO | S_IWUSR;
- Our_Proc_File->uid = 0;
- Our_Proc_File->gid = 0;
- Our_Proc_File->size = 80;
+ proc_set_size(Our_Proc_File, 80);
+ proc_set_user(Our_Proc_File, GLOBAL_ROOT_UID, GLOBAL_ROOT_GID);
printk(KERN_INFO "/proc/test created\n");
@@ -3668,9 +3623,8 @@ DECLARE_WAIT_QUEUE_HEAD(WaitQ);
void cleanup_module()
{
- remove_proc_entry(PROC_ENTRY_FILENAME, &proc_root);
-
- printk(KERN_INFO "/proc/test removed\n");
+ remove_proc_entry(PROC_ENTRY_FILENAME, NULL);
+ printk(KERN_DEBUG "/proc/%s removed\n", PROC_ENTRY_FILENAME);
}
diff --git a/LKMPG-3.16.org b/LKMPG-3.16.org
index a8f7729..94a0053 100644
--- a/LKMPG-3.16.org
+++ b/LKMPG-3.16.org
@@ -2462,7 +2462,7 @@ static int module_open(struct inode *inode, struct file *file)
for (i = 0; i < _NSIG_WORDS && !is_sig; i++)
is_sig =
current->pending.signal.sig[i] & ~current->
- blocked.sig[i];
+ blocked.sig[i];
if (is_sig) {
/*
@@ -2487,8 +2487,8 @@ static int module_open(struct inode *inode, struct file *file)
/*
* Open the file
*/
- Already_Open = 1;
- return 0; /* Allow the access */
+ Already_Open = 1;
+ return 0; /* Allow the access */
}
/*
@@ -2515,33 +2515,6 @@ int module_close(struct inode *inode, struct file *file)
return 0; /* success */
}
-/*
- * This function decides whether to allow an operation (return zero) or not
- * allow it (return a non-zero which indicates why it is not allowed).
- *
- * The operation can be one of the following values:
- * 0 - Execute (run the "file" - meaningless in our case)
- * 2 - Write (input to the kernel module)
- * 4 - Read (output from the kernel module)
- *
- * This is the real function that checks file permissions. The permissions
- * returned by ls -l are for reference only, and can be overridden here.
- */
-static int module_permission(struct inode *inode, int op, struct nameidata *nd)
-{
- /*
- * We allow everybody to read from our module, but only root (uid 0)
- * may write to it
- */
- if (op == 4 || (op == 2 && current->euid == 0))
- return 0;
-
- /*
- * If it's anything else, access is denied
- */
- return -EACCES;
-}
-
/*
* Structures to register as the /proc file, with pointers to all the relevant
* functions.
@@ -2553,22 +2526,10 @@ static int module_permission(struct inode *inode, int op, struct nameidata *nd)
* means we don't want to deal with something.
*/
static struct file_operations File_Ops_4_Our_Proc_File = {
- .read = module_output, /* "read" from the file */
- .write = module_input, /* "write" to the file */
- .open = module_open, /* called when the /proc file is opened */
- .release = module_close, /* called when it's closed */
-};
-
-/*
- * Inode operations for our proc file. We need it so we'll have somewhere to
- * specify the file operations structure we want to use, and the function we
- * use for permissions. It's also possible to specify functions to be called
- * for anything else which could be done to an inode (although we don't bother,
- * we just put NULL).
- */
-
-static struct inode_operations Inode_Ops_4_Our_Proc_File = {
- .permission = module_permission, /* check for permissions */
+ .read = module_output, /* "read" from the file */
+ .write = module_input, /* "write" to the file */
+ .open = module_open, /* called when the /proc file is opened */
+ .release = module_close, /* called when it's closed */
};
/*
@@ -2581,21 +2542,15 @@ static struct inode_operations Inode_Ops_4_Our_Proc_File = {
int init_module()
{
- Our_Proc_File = create_proc_entry(PROC_ENTRY_FILENAME, 0644, NULL);
-
- if (Our_Proc_File == NULL) {
- remove_proc_entry(PROC_ENTRY_FILENAME, &proc_root);
- printk(KERN_ALERT "Error: Could not initialize /proc/test\n");
+ Our_Proc_File = proc_create(PROC_ENTRY_FILENAME, 0644, NULL, &File_Ops_4_Our_Proc_File);
+ if(Our_Proc_File == NULL)
+ {
+ remove_proc_entry(PROC_ENTRY_FILENAME, NULL);
+ printk(KERN_DEBUG "Error: Could not initialize /proc/%s\n", PROC_ENTRY_FILENAME);
return -ENOMEM;
}
-
- Our_Proc_File->owner = THIS_MODULE;
- Our_Proc_File->proc_iops = &Inode_Ops_4_Our_Proc_File;
- Our_Proc_File->proc_fops = &File_Ops_4_Our_Proc_File;
- Our_Proc_File->mode = S_IFREG | S_IRUGO | S_IWUSR;
- Our_Proc_File->uid = 0;
- Our_Proc_File->gid = 0;
- Our_Proc_File->size = 80;
+ proc_set_size(Our_Proc_File, 80);
+ proc_set_user(Our_Proc_File, GLOBAL_ROOT_UID, GLOBAL_ROOT_GID);
printk(KERN_INFO "/proc/test created\n");
@@ -2610,9 +2565,8 @@ int init_module()
*/
void cleanup_module()
{
- remove_proc_entry(PROC_ENTRY_FILENAME, &proc_root);
-
- printk(KERN_INFO "/proc/test removed\n");
+ remove_proc_entry(PROC_ENTRY_FILENAME, NULL);
+ printk(KERN_DEBUG "/proc/%s removed\n", PROC_ENTRY_FILENAME);
}
#+END_SRC