Skip to content

Instantly share code, notes, and snippets.

View masami256's full-sized avatar
😎
😊

Masami Ichikawa masami256

😎
😊
View GitHub Profile
@masami256
masami256 / livetest.c
Created July 16, 2016 02:42
livepatch test module
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/livepatch.h>
#include <linux/seq_file.h>
#include <linux/string.h>
#include <linux/sched.h>
#include <linux/pid_namespace.h>
# Use centos
FROM centos:centos7
MAINTAINER [email protected]
COPY mysql57-community-release-el7-8.noarch.rpm /tmp/
COPY make_netmask.sh /tmp/
RUN ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && \
yum localinstall -y /tmp/mysql57-community-release-el7-8.noarch.rpm && \
yum update -y && \
@masami256
masami256 / pid.stp
Created April 29, 2016 14:10
Show pid in each pid namespaces
#!/usr/bin/env stap
%{
#include <linux/sched.h>
#include <linux/thread_info.h>
#include <linux/pid_namespace.h>
%}
function show_pidtree:long(pn:long) %{
struct task_struct *task;
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sched.h>
#include <sys/types.h>
#include <sys/wait.h>
#define SCHED_LIFO 7
#define GET_CURRENT_POLICY 9999
@masami256
masami256 / Makefile
Last active September 22, 2015 04:03
kmem_cache_alloc_bulk() test
KERNDIR := /lib/modules/`uname -r`/build
BUILD_DIR := $(shell pwd)
VERBOSE = 0
obj-m := bulk_alloc.o
smallmod-objs := bulk_alloc.o
all:
make -C $(KERNDIR) SUBDIRS=$(BUILD_DIR) KBUILD_VERBOSE=$(VERBOSE) modules
#!/usr/bin/env ruby
def read_file(filename)
ret = []
File.open(filename) do |f|
f.each_line do |line|
ret << line.split(',')[1].to_i
end
end
return ret
@masami256
masami256 / emu23.rb
Last active August 29, 2015 16:17
自作エミュレータで学ぶx86アーキテクチャ emu2.3のruby版
#!/usr/bin/env ruby
require 'pp'
class Emulator
@@EAX = 0
@@ECX = 1
@@EDX = 2
@@EBX = 3
@masami256
masami256 / installkernel
Last active August 29, 2015 14:27
install bzImage to /boot, create initramfs, create boot conf for gummiboot
#!/bin/bash
if [ $# != 4 ]; then
echo "usage $0 [vmlinuz name] [bzimage file name] [System.map file name] [output dir]"
exit 1
fi
KERNEL_NAME=$1
BZIMAGE_NAME=$2
SYSTEMMAP_NAME=$3
@masami256
masami256 / print_bps.py
Last active September 1, 2015 09:11
simple traffic measurement
#!/usr/bin/env python
import time
import sys
last_rx = 0
last_tx = 0
first_time = True
def print_bps(iface, line):
@masami256
masami256 / add_extra_func_Test.js
Created May 22, 2015 16:09
Add extra functions to wd
"use strict";
var wd = require("wd");
require('colors');
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
var should = chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;