Skip to content

Instantly share code, notes, and snippets.

View Aruna-Hewapathirane's full-sized avatar

Aruna Hewapathirane Aruna-Hewapathirane

View GitHub Profile
#!/bin/sh
sudo mkinitcpio -r "$LINUX_DEV_PATH"/modules_install \
-k "$KERNEL_RELEASE" \
-c "$LINUX_DEV_PATH"/mkinitcpio.conf \
-g "$LINUX_DEV_PATH"/initramfs-linux.img
@Aruna-Hewapathirane
Aruna-Hewapathirane / symlink-test.c
Last active August 29, 2015 14:14
symbolic link and readlink system call
man 2 readlink
@Aruna-Hewapathirane
Aruna-Hewapathirane / gist:0de5255e6ce83201fd89
Last active August 29, 2015 14:06
vimrc - first attempt
set nocompatible
set modeline
set modelines=5
set number
set ruler
set laststatus=2
set statusline=%t "tail of the filename
set statusline+=[%{strlen(&fenc)?&fenc:'none'}, "file encoding
set statusline+=%{&ff}> "file format
set statusline+=%h "help file flag
@Aruna-Hewapathirane
Aruna-Hewapathirane / proc-read.c
Last active August 29, 2015 14:05
how to read from an existing proc file ( specifically /proc/<pid>/status )
// compile: gcc -Wall -o proc proc-read.c
// citation: https://bbs.archlinux.org/viewtopic.php?id=96068
#include <stdio.h>
#include <stdlib.h>
#define BUFFER_SIZE 1024
void die(char *x){ perror(x); exit(1); };
int main(int argc, char **argv)
@Aruna-Hewapathirane
Aruna-Hewapathirane / gist:98e92eac307e63b2aa73
Last active August 29, 2015 14:04
Digging into printk internals so I truly *understand* what is going on ..
printk is defined as a function in:
- arch/ia64/kvm/vmm.c, line 84
- kernel/printk/printk.c, line 1677 // This is what we need for kernel module work
1677 asmlinkage __visible int printk(const char *fmt, ...) // char * fmt is a member
1678 { // of structure va_format ( shown below )
1679 va_list args;
1680 int r;
1681
1682 #ifdef CONFIG_KGDB_KDB
@Aruna-Hewapathirane
Aruna-Hewapathirane / printk.h
Last active August 29, 2015 14:04
Why are there *two* printk functions ?
132: int printk(const char *fmt, ...);
167: int printk(const char *s, ...)
168: {
169: return 0;
170: }