Skip to content
Snippets Groups Projects
Commit f9e0469e authored by root's avatar root
Browse files

Feat: still great work for the second part of the TP1

parent 89b61371
Branches
No related tags found
No related merge requests found
build/
linux*
debian*
.hello-1*
*.o
*.cmd
*.ko
*.mod
*.symvers
*.orders
\ No newline at end of file
#!/bin/bash
KERNEL=${1-/home/lipari/Documents/corsi/2023-2024/ASEE/prova/build/kvm/arch/x86/boot/bzImage}
KERNEL=${1-build/kvm/arch/x86/boot/bzImage}
SMP=${2-2}
kvm -smp $SMP -m 1G -boot c --enable-kvm \
-kernel $KERNEL -append "root=/dev/sda1 console=ttyS0 rw" \
-hda debian.qcow \
-net user,hostfwd=tcp::10022-:22 -net nic
-net user,hostfwd=tcp::10022-:22 -net nic \
-serial mon:stdio
lkmpg @ c6b02adc
Subproject commit c6b02adc982382044c86fa11dcaf012fbe78715e
......@@ -4,6 +4,7 @@ obj-m += hello-1.o
obj-m += hello-2.o
obj-m += hello-3.o
obj-m += hello-5.o
obj-m += hello-sysfs.o
PWD := $(CURDIR)
all:
......
/*
* hello-sysfs.c sysfs example
*/
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/kobject.h>
#include <linux/module.h>
#include <linux/string.h>
#include <linux/sysfs.h>
static struct kobject *mymodule;
/* the variable you want to be able to change */
static int myvariable = 0;
static ssize_t myvariable_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", myvariable);
}
static ssize_t myvariable_store(struct kobject *kobj,
struct kobj_attribute *attr, char *buf,
size_t count)
{
sscanf(buf, "%du", &myvariable);
return count;
}
static struct kobj_attribute myvariable_attribute =
__ATTR(myvariable, 0660, myvariable_show, (void *)myvariable_store);
static int __init mymodule_init(void)
{
int error = 0;
pr_info("mymodule: initialised\n");
mymodule = kobject_create_and_add("mymodule", kernel_kobj);
if (!mymodule)
return -ENOMEM;
error = sysfs_create_file(mymodule, &myvariable_attribute.attr);
if (error) {
pr_info("failed to create the myvariable file "
"in /sys/kernel/mymodule\n");
}
return error;
}
static void __exit mymodule_exit(void)
{
pr_info("mymodule: Exit success\n");
kobject_put(mymodule);
}
module_init(mymodule_init);
module_exit(mymodule_exit);
MODULE_LICENSE("GPL");
\ No newline at end of file
#include <linux/module.h>
#define INCLUDE_VERMAGIC
#include <linux/build-salt.h>
#include <linux/elfnote-lto.h>
#include <linux/export-internal.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>
#ifdef CONFIG_UNWINDER_ORC
#include <asm/orc_header.h>
ORC_HEADER;
#endif
BUILD_SALT;
BUILD_LTO_INFO;
MODULE_INFO(vermagic, VERMAGIC_STRING);
MODULE_INFO(name, KBUILD_MODNAME);
__visible struct module __this_module
__section(".gnu.linkonce.this_module") = {
.name = KBUILD_MODNAME,
.init = init_module,
#ifdef CONFIG_MODULE_UNLOAD
.exit = cleanup_module,
#endif
.arch = MODULE_ARCH_INIT,
};
#ifdef CONFIG_RETPOLINE
MODULE_INFO(retpoline, "Y");
#endif
static const struct modversion_info ____versions[]
__used __section("__versions") = {
{ 0x122c3a7e, "_printk" },
{ 0xa6ef1646, "kernel_kobj" },
{ 0x10bd90f2, "kobject_create_and_add" },
{ 0xa3efd5d1, "sysfs_create_file_ns" },
{ 0xecc78457, "kobject_put" },
{ 0xbdfb6dbb, "__fentry__" },
{ 0xbcab6ee6, "sscanf" },
{ 0x5b8239ca, "__x86_return_thunk" },
{ 0x3c3ff9fd, "sprintf" },
{ 0x76800044, "module_layout" },
};
MODULE_INFO(depends, "");
MODULE_INFO(srcversion, "6C30BA4EA53200F485C730C");
......@@ -2,3 +2,4 @@
/root/Desktop/asee/work/hello-1/hello-2.o
/root/Desktop/asee/work/hello-1/hello-3.o
/root/Desktop/asee/work/hello-1/hello-5.o
/root/Desktop/asee/work/hello-1/hello-sysfs.o
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment