summaryrefslogtreecommitdiffstats
path: root/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/debug.c b/debug.c
index 40ee10c..5c746d1 100644
--- a/debug.c
+++ b/debug.c
@@ -10,6 +10,8 @@
#include <linux/types.h>
#include <linux/errno.h>
+#include <linux/uaccess.h>
+
#include <debug.h>
#include <main.h>
@@ -24,7 +26,7 @@ char kernel_buff[BUFF_LEN] = {'f','o','o','b','a','r','\0'};
int fileprv = 1; /* hmm */
/* struct file, an abstract open file, not on disk, which would be a an inode */
-static ssize_t debugfs_read(struct file *fp, char __user /* userspace */ *ubuff, size_t c, loff_t *pos)
+static ssize_t hello_hello_debugfs_read(struct file *fp, char __user /* userspace */ *ubuff, size_t c, loff_t *pos)
{
/**
* simple_read_from_buffer - copy data from the buffer to user space
@@ -43,7 +45,7 @@ static ssize_t debugfs_read(struct file *fp, char __user /* userspace */ *ubuff,
return simple_read_from_buffer(ubuff, c, pos, kernel_buff, BUFF_LEN);
}
-static ssize_t debugfs_write(struct file *fp, const char __user *ubuff, size_t c, loff_t *pos)
+static ssize_t hello_debugfs_write(struct file *fp, const char __user *ubuff, size_t c, loff_t *pos)
{
/**
* simple_write_to_buffer - copy data from user space to the buffer
@@ -64,14 +66,20 @@ static ssize_t debugfs_write(struct file *fp, const char __user *ubuff, size_t c
return (-EINVAL);
return simple_write_to_buffer(kernel_buff, BUFF_LEN, pos, ubuff, c);
+
+#if 0
+ printk(KERN_INFO "count %lu, offset %u", c, *pos);
+ copy_from_user(kernel_buff + *pos, ubuff, c);
+ return c;
+#endif
}
-int debug_init(struct dentry **dir, struct dentry **file)
+int hello_debugfs_init(struct dentry **dir, struct dentry **file)
{
/* func ptrs that perform various operations on the device, in this case char device, well not even */
struct file_operations fops = {
- .read = debugfs_read,
- .write = debugfs_write
+ .read = hello_hello_debugfs_read,
+ .write = hello_debugfs_write
};
/* omitted fields are initialized to NULL */
@@ -82,12 +90,12 @@ int debug_init(struct dentry **dir, struct dentry **file)
/* regular file, read by user/group/other, write by user */
*file = debugfs_create_file("magic", S_IFREG | S_IRUGO | S_IWUSR, *dir, &fileprv, &fops);
if (!*file)
- printk("debugfs: error creating file\n");
+ printk(KERN_WARNING "[hello] debugfs: error creating file\n");
return 0;
}
-int debug_destroy(struct dentry *dir, struct dentry *file)
+int hello_debugfs_destroy(struct dentry *dir, struct dentry *file)
{
if (file)
debugfs_remove(file);