原创 kobject的使用基本框架

下面是僞代碼  可以根據此框架寫自己的kobject屬性  struct myobject{ int a; int b; struct kobject object; }g_object; struct myattr{

原创 釋放頁__free_one_page()

/*釋放到指定的夥伴系統類型鏈表*/ static inline void __free_one_page(struct page *page, struc

原创 linux內核函數夥伴系統部分expand()

 先看個分配圖在看下面的函數   static inline void expand(struct zone *zone, //內存區域 struct page *page,

原创 內核內存相關圖

原创 如何讓linux下的動態庫so能執行

感覺對自己有用 給點個贊哈 代碼如下 mytest.c #include<stdio.h> #include<stdlib.h> //在elf格式中加入一個節.interp 此節含有 ELF 程序解析器的路徑名 //如果動態庫不包括

原创 linux內核sort()排序的使用

函數原型 void sort(void *base,            size_t num,            size_t size,           int (*cmp_func)(const void *, const

原创 2.4內核動態模塊基本使用方式

 module.c #define MODULE //一定要定義此宏 #include <linux/kmod.h> #include <linux/module.h> #include <linux/init.h> #inclu

原创 系統調用nice()的內核之路

調用過程 nice()->sys_nice() 函數原型 int nice(int inc); SYSCALL_DEFINE1(nice, int, increment) sys_nice()分析 SYSCALL_DEFINE1(nic

原创 linux 如何隱藏 /proc/目錄下的文件(version 2.6 其他版本沒適配)

 只爲研究而用  禁止用於非法行爲!!!!! /* *通過加載此模塊 來將/proc目錄下的文件進行隱藏 * 使用方式 insmod xx.ko hidestr='xxxx' * */ #include <linux/kmod.h

原创 c語言實現定時器時間輪

本代碼是在根據內核中的時間輪代碼進行改造 適用於應用層,若發現問題 歡迎指正 /* *毫秒定時器 採用多級時間輪方式 借鑑linux內核中的實現 *支持的範圍爲1 ~ 2^32 毫秒(大約有49天) *若設置的定時器超過最大

原创 同步IO、異步IO、阻塞IO、非阻塞IO之間的聯繫與區別

轉自 https://www.cnblogs.com/euphie/p/6376508.html POSIX 同步IO、異步IO、阻塞IO、非阻塞IO,這幾個詞常見於各種各樣的與網絡相關的文章之中,往往不同上下文中它們的意思是不一樣的,以

原创 linux c將緩存字符串進行編碼轉換

#include <stdio.h> #include <stdlib.h> #include <iconv.h> #include <unistd.h> #include <sys/types.h> #include <sys/st

原创 create_workqueue和create_singlethread_workqueue【轉】

本文轉載自:http://bgutech.blog.163.com/blog/static/18261124320116181119889/ 1. 什麼是workqueue Linux中的Workqueue機制就是爲了簡化內核線程的創建。

原创 內核模塊在/sys/module/xx/產生自己的配置文件

 下面代碼會產生/sys/module/xxx/security/testhello 配置文件 #include <linux/kmod.h> #include <linux/module.h> #include <linux/init

原创 linux c編程實現vsftpd是否支持匿名賬戶

#include <stdio.h> #include <stdlib.h> #include <sys/types.h> /* See NOTES */ #include <sys/socket.h> #includ