This commit is contained in:
Jolan Rathelot 2024-04-15 13:24:34 +02:00
parent 2f8b9a1e37
commit c2114de992
4 changed files with 17 additions and 5 deletions

5
.idea/workspace.xml generated
View File

@ -16,7 +16,9 @@
<configurations />
</component>
<component name="ChangeListManager">
<list default="true" id="2686ebbf-1c6c-4484-bb57-dec59a208d53" name="Changes" comment="" />
<list default="true" id="2686ebbf-1c6c-4484-bb57-dec59a208d53" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@ -153,6 +155,7 @@
<workItem from="1710410734122" duration="3818000" />
<workItem from="1710428742857" duration="5381000" />
<workItem from="1710488169055" duration="12511000" />
<workItem from="1713174090163" duration="3761000" />
</task>
<task id="LOCAL-00001" summary="Removed Rust code, added misc device and irq handle. Began work on correctly formatting print msg and logging files.">
<option name="closed" value="true" />

View File

@ -6,12 +6,12 @@ all: driver_and_interrupts.ko
driver_and_interrupts.ko: $(SRC)
$(MAKE) -C $(KDIR) M=$$PWD LLVM=1
install: modprobe rules_install
install: modprobe rule_install
modules_install: driver_and_interrupts.ko
module_install: driver_and_interrupts.ko
$(MAKE) -C $(KDIR) M=$$PWD LLVM=1 modules_install
rules_install: modules_install 99-Hotload-Keyboard.rules driver_and_interrupts.ko
rule_install: module_install 99-Hotload-Keyboard.rules driver_and_interrupts.ko
cp -v 99-Hotload-Keyboard.rules /etc/udev/rules.d/
udevadm control --reload-rules
udevadm trigger
@ -19,7 +19,7 @@ rules_install: modules_install 99-Hotload-Keyboard.rules driver_and_interrupts.k
clean:
$(MAKE) -C $(KDIR) M=$$PWD LLVM=1 clean
modprobe: modules_install
modprobe: module_install
modprobe driver_and_interrupts
rmmod:

View File

@ -56,10 +56,14 @@ static void __exit m_exit(void) {
struct linked_list_node *ptr, *tmp;
misc_deregister(&device);
size_t len = 0;
list_for_each_entry_safe(ptr, tmp, &keyboard_log, list){
len++;
list_del(&ptr->list);
kfree(ptr);
}
printk(KERN_INFO "Captured %zu Keyboard inputs", len);
free_irq(1,&key_logger);
mutex_destroy(&lock);
printk(KERN_INFO "Drivers and Interrupts (exit)\n");

View File

@ -45,6 +45,10 @@ ssize_t read_keyboard_misc_device(struct file *file, char __user *buf, size_t co
char min = (tmp->when.tv_sec - (sys_tz.tz_minuteswest * 60)) / 60 % 60;
char hour = (tmp->when.tv_sec - (sys_tz.tz_minuteswest * 60)) / 60 / 60 % 24;
char *buffer = kmalloc(sizeof(char) * tmp->size, GFP_KERNEL);
if (!buffer) {
mutex_unlock(&lock);
return -ENOMEM;
}
memset(buffer, 0, tmp->size);
snprintf(buffer, tmp->size, "%02d:%02d:%02d \"%s\"", hour, min, sec, tmp->key.key_name);
if (tmp->key.ascii_value) {
@ -58,6 +62,7 @@ ssize_t read_keyboard_misc_device(struct file *file, char __user *buf, size_t co
if (copy_to_user(buf + user_offset, buffer + node_offset, tmp->size - node_offset)) {
kfree(buffer);
mutex_unlock(&lock);
return -EFAULT;
}
kfree(buffer);