static dev_t devnum;
static struct cdev *dev;
+static const char default_greeting[] = "Hello, World!\n";
+
+struct hello_buffer {
+ size_t len;
+ char buffer[0];
+};
static int hello_open(struct inode *ino, struct file *fp)
{
- printk(KERN_DEBUG "Hello, World!\n");
+ struct hello_buffer *hello = kmalloc(sizeof(*hello) + 4000, GFP_KERNEL);
+ if (!hello)
+ return -ENOMEM;
+ hello->private_data = hello;
return 0;
}
return 0;
}
+static int hello_release(struct inode *ino, struct file *fp)
+{
+ kfree(fp->private_data);
+ return 0;
+}
+
static const struct file_operations hello_fops = {
.owner = THIS_MODULE,
.open = hello_open,
+ .release = hello_release,
.read = hello_read,
};