Skip to content

Instantly share code, notes, and snippets.

@satishba
satishba / readOption.c
Last active March 18, 2020 18:20
Example for get_option
#include <linux/module.h>
#include <linux/kernel.h>
#include<linux/sched.h>
int pint=-1;
static __init int getargs(char *str){
int ret;
ret=get_option(&str,&pint);
@satishba
satishba / makefile
Created March 16, 2020 11:41
Makefile
ifneq ($(KERNELRELEASE),)
obj-m := proc_read_fifo1.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
@satishba
satishba / proc_read_fifo.c
Last active March 16, 2020 14:56
Proc Entry to show usage of kfifo
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include<linux/sched.h>
#include <asm/uaccess.h>
#include<linux/slab.h>
#include<linux/kfifo.h>
#define FIFO_SIZE 32
@satishba
satishba / proc_read_time.c
Last active March 16, 2020 11:02
Proc entry for to show use of sche_clock
/*Tested on kernel 5.3*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include<linux/sched.h>
#include <asm/uaccess.h>
#include<linux/sched/clock.h>
#include<linux/slab.h>
/*Code to show usage of hllist . Tested in kernel 5.3*/
#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/list.h>
#include<linux/slab.h>
struct k_list {
struct hlist_node test_list;
int temp;
import curses as cur
from curses import wrapper
import locale
import sys, termios, atexit
from select import select
import curses as cur
from curses import wrapper
import time
import datetime
import random
@satishba
satishba / linked_list_is_first.c
Created December 20, 2019 12:09
Code to show usage of link_is_first function
/*Code to show usage of list_is_first . Tested in kernel 5.3*/
#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/list.h>
#include<linux/slab.h>
struct k_list {
struct list_head test_list;
int temp;
@satishba
satishba / linked_list_del.c
Created December 17, 2019 11:27
Example code to show usage of list_del function
/*Code to show usage of list_del . Tested in kernel 5.3*/
#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/list.h>
#include<linux/slab.h>
struct k_list {
struct list_head test_list;
int temp;
@satishba
satishba / matrix_terminal.py
Created December 13, 2019 17:34
Script to create a matrix like scrolling animation on the terminal
import sys, termios, atexit
from select import select
import curses as cur
from curses import wrapper
import time
import datetime
import random
# save the terminal settings
fd = sys.stdin.fileno()
@satishba
satishba / PY0101EN-2.1_notebook_quizz_list_tuplesv4.ipynb
Created March 27, 2019 06:53
Created on Cognitive Class Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.