<commit_before>#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/proc_fs.h>
#include <asm/uaccess.h>

#define MAJOR_NUMBER 61

/* forward declaration */
int onebyte_open(struct inode *inode, struct file *filep);
int onebyte_release(struct inode *inode, struct file *filep);
ssize_t onebyte_read(struct file * filep, char *buf, size_t count, loff_t *f_pos);
ssize_t onebyte_write(struct file * filep, const char *buf, size_t count, loff_t *f_pos);
static void onebyte_exit(void);

/* definition of file_operation structure */
struct file_operations onebyte_fops = {
	read:	onebyte_read,
	write:	onebyte_write,
	open:	onebyte_open,
	release: onebyte_release
};

char *onebyte_data = NULL;

int onebyte_open(struct inode *inode, struct file *filep)
{
	return 0; // always successful
}

int onebyte_release(struct inode *inode, struct file *filep)
{
	return 0; // always successful
}

ssize_t onebyte_read(struct file * filep, char *buf, size_t count, loff_t *f_pos)
{
	if (*f_pos == 0) {
		copy_to_user(buf, onebyte_data, 1);
		*f_pos += 1;
		return 1;
	} else {
		return 0;
	}
/*	int error_count = 0;
	*buf = 'x';
	printk(KERN_INFO "DevOne: Data %c \n", filep->private_data);
	
	error_count = copy_to_user(buf, onebyte_data, 1);
	if (error_count==0)
	{
		printk(KERN_INFO "DevOne: Sent %d characters to the user\n", 1);
		printk(KERN_INFO "DevOne: Sent %c to the user\n", *buf);
		return 0;
	}
	else {
		printk(KERN_ERR "DevOne: Failed to send %c chracters to the user\n", *onebyte_data);
		return -EFAULT;
	}*/
}

ssize_t onebyte_write(struct file * filep, const char *buf, size_t count, loff_t *f_pos)
{
	/* please complete the function on your own */
	printk(KERN_INFO "DevOne: Data %c \n", filep->private_data);
	printk(KERN_INFO "DevOne: Data %c \n", *buf);
}

static int onebyte_init(void)
{
	int result;<commit_msg>added write operation<commit_after>#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/proc_fs.h>
#include <asm/uaccess.h>

#define MAJOR_NUMBER 61

/* forward declaration */
int onebyte_open(struct inode *inode, struct file *filep);
int onebyte_release(struct inode *inode, struct file *filep);
ssize_t onebyte_read(struct file * filep, char *buf, size_t count, loff_t *f_pos);
ssize_t onebyte_write(struct file * filep, const char *buf, size_t count, loff_t *f_pos);
static void onebyte_exit(void);

/* definition of file_operation structure */
struct file_operations onebyte_fops = {
	read:	onebyte_read,
	write:	onebyte_write,
	open:	onebyte_open,
	release: onebyte_release
};

char *onebyte_data = NULL;

int onebyte_open(struct inode *inode, struct file *filep)
{
	return 0; // always successful
}

int onebyte_release(struct inode *inode, struct file *filep)
{
	return 0; // always successful
}

ssize_t onebyte_read(struct file * filep, char *buf, size_t count, loff_t *f_pos)
{
	if (*f_pos == 0) {
		copy_to_user(buf, onebyte_data, 1);
		*f_pos += 1;
		printk(KERN_INFO "DevOne: Sent %c to the user\n", *buf);
		return 1;
	} else {
		return 0;
	}
/*	int error_count = 0;
	*buf = 'x';
	printk(KERN_INFO "DevOne: Data %c \n", filep->private_data);
	
	error_count = copy_to_user(buf, onebyte_data, 1);
	if (error_count==0)
	{
		printk(KERN_INFO "DevOne: Sent %d characters to the user\n", 1);
		return 0;
	}
	else {
		printk(KERN_ERR "DevOne: Failed to send %c chracters to the user\n", *onebyte_data);
		return -EFAULT;
	}*/
}

ssize_t onebyte_write(struct file * filep, const char *buf, size_t count, loff_t *f_pos)
{
	/* please complete the function on your own */
	printk(KERN_INFO "DevOne: Data %c \n", *buf);
	if (*f_pos == 0) {
		copy_from_user(onebyte_data, buf, 1);
		*f_pos+=1;
		return 1;
	}
	else {
		return -ENOSPC;
	}
}

static int onebyte_init(void)
{
	int result;
{'fraction_non_alphanumeric': 0.13370193515958784, 'fraction_numerical': 0.008042221663734606, 'mean_word_length': 4.718390804597701, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6108565', 'n_tokens_mistral': 1600, 'n_tokens_neox': 1537, 'n_words': 425}