Skip to content
Snippets Groups Projects
Commit e2b4fbc7 authored by valentin.acevedoa's avatar valentin.acevedoa
Browse files

master commit

parent fd13f03a
Branches
No related tags found
No related merge requests found
cmd_/home/student/Module.symvers := sed 's/\.ko$$/\.o/' /home/student/modules.order | scripts/mod/modpost -a -o /home/student/Module.symvers -e -i Module.symvers -N -T -
cmd_/home/student/abcd.ko := ld -r -m elf_x86_64 --build-id=sha1 -T scripts/module.lds -o /home/student/abcd.ko /home/student/abcd.o /home/student/abcd.mod.o; true
cmd_/home/student/abcd.mod := { echo /home/student/abcd.o; echo; } > /home/student/abcd.mod
This diff is collapsed.
This diff is collapsed.
cmd_/home/student/modules.order := { echo /home/student/abcd.ko; :; } | awk '!x[$$0]++' - > /home/student/modules.order
Makefile 0 → 100644
obj-m := abcd.o
build:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
sudo insmod abcd.ko
sudo mknod /dev/abcd c 238 0
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
-sudo rmmod abcd.ko
-sudo rm /dev/abcd
abcd.ko 0 → 100644
File added
File added
/home/student/abcd.o
File added
abcd.o 0 → 100644
File added
objects = ex_read ex_write
all: $(objects)
$(objects): %: %.c
$(CC) $(CFLAGS) -o $@ $<
\ No newline at end of file
File added
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
int main(void)
{
char buffer[50] = "";
int file = open("/dev/abcd", O_RDWR);
if(file < 0) {
perror("open");
exit(errno);
}
//Number of chars in file
printf("%d\n", read(file, buffer, 50));
close(file);
return 0;
}
\ No newline at end of file
File added
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
int main(void)
{
char buffer[50] = "";
int file = open("/dev/abcd", O_RDWR);
if(file < 0) {
perror("open");
exit(errno);
}
//Writes into file
write(file, buffer, 50);
close(file);
return 0;
}
/home/student/abcd.ko
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment