说明:本文以主要为转载内容,同时加入了我在使用过程中遇到问题对其的修正!!!!!!!!!
先说statfs结构:
#include <sys/vfs.h> /* 或者 <sys/statfs.h> */
int statfs(const char *path, struct statfs *buf);
int fstatfs(int fd, struct statfs *buf);
参数:
path: 位于需要查询信息的文件系统的文件路径名(不是设备名,是挂载点名称)。
fd: 位于需要查询信息的文件系统的文件描述词。
buf:以下结构体的指针变量,用于储存文件系统相关的信息
struct statfs
{
long f_type; /* 文件系统类型 */
long f_bsize; /* 经过优化的传输块大小 */
long f_blocks; /* 文件系统数据块总数 */
long f_bfree; /* 可用块数 */
long f_bavail; /* 非超级用户可获取的块数 */
long &nbs ......
Linux源码安装Subversion
先从subversion的官方网站下载源码,subversion.apache.org
解压开到subversion-xxx 然后configure
然后一般就是找不到某某库的错误,以下说明
1.找不到sqlite3
从sqlite网站上下载sqlite3的源码,然后把sqlite3.c拷贝到 subversion-xxx/sqlite-amalgamation/sqlite3.c
2.找不到apr
从apr.apache.org下载apr-1.3.9.tar.gz和apr-util-1.3.9.tar.gz(1.3.9是写此文时的APR版本)
然后各自解压开configure,make,make install
在subversion-xxx中configure的时候指定--with-apr=/path/to/apr/bin/apr-1-config --with-apr-util=/path/to/apu/bin/apu-1-config
3.找不到zlib
从zlib.net上下载zlib的源代码。
解压开configure,make,make install
在subversion-xxx中configure的时候指定CPPFLAGS=-I/path/to/zlib/include LIBS=-L/path/to/zlib/lib
下边是我自己在configure时用的命令,可做参考
./configure --prefix=$HOME/local --with-apr=$HOME/local/bin/apr-1-config --with-apr-util=$HOME/local/bin/apu-1-config CPPFLAGS=-I$HOME/local/include LIBS=-L$HOME/local/lib
成功 ......
当在Linux下频繁存取文件
后,物理内存会很快被用光,当程序
结束后,内存不会被正常释放,而是一直作为caching。这个问题,貌似有不少人在问,不过都没有看到有什么很好解决
的办法。那么我来谈谈这个问题。
一、通常情况
先来说说free命令
:
引用
[root@server ~]# free -m
total used free shared buffers cached
Mem: 249 163 86 0 10 94
-/+ buffers/cache: 58 191
Swap: 511 0 511
其中:
引用
total 内存总数
used 已经使用的内存数
free 空闲的内存数
shared 多个进程共享的内存总额
buffers Buffer Cache和cached Page Cache 磁盘缓存
的大小
-buffers/cache 的内存数:used – buffers – cached
+buffers/cache 的内存数:free + buffers + cached
可用的memory=free memory+buffers+cached
。
有了这个基础
后,可以得知,我现在used为163MB,free为86MB,buffer和cached分别为10MB,94MB。
那么我们来看看,如果我执行复制文件,内存会发生什么变化.
引用
[root@server ~]# cp -r /etc ~/test/
[root@server ~]# free -m
total used free shared buffers cached
Mem: 249 244 4 0 8 174
-/+ buffers/cache: 62 187
Swa ......
------------------------------------------
本文系本站原创,欢迎转载!
转载请注明出处:http://ericxiao.cublog.cn/
------------------------------------------
一:前言
在键盘驱动代码分析的笔记中,接触到了input子系统.键盘驱动,键盘驱动将检测到的所有按键都上报给了input子系统。Input子系统是所有I/O设备驱动的中间层,为上层提供了一个统一的界面。例如,在终端系统中,我们不需要去管有多少个键盘,多少个鼠标。它只要从input子系统中去取对应的事件(按键,鼠标移位等)就可以了。今天就对input子系统做一个详尽的分析.
下面的代码是基于linux kernel 2.6.25.分析的代码主要位于kernel2.6.25/drivers/input下面.
二:使用input子系统的例子
在内核自带的文档Documentation/input/input-programming.txt中。有一个使用input子系统的例子,并附带相应的说明。以此为例分析如下:
#include <linux/input.h>
#include <linux/module.h>
#include <linux/init.h>
#include <asm/irq.h>
#include <asm/io.h>
&n ......
; break;
}
if (type != EV_SYN)
dev->sync = 0;
if ((disposition & INPUT_PASS_TO_DEVICE) && dev->event)
dev->event(dev, type, code, value);
if (disposition & INPUT_PASS_TO_HANDLERS)
input_pass_event (dev, type, code, value);
}
在这里,我们忽略掉具体事件的处理.到最后,如果该事件需要input dev ......
Linux Input Device 介紹: APIs
jollen 發表於 April 8, 2009 12:18 PM
Linux 的 Input Device 是重要的一個 subsystem,在進行實例介紹前,先大略了解一下相關的 API。
Linux Input Device
input.c是Linux的”input”驅動程式,主要支援鍵盤與滑鼠的輸入;input.c介面有趣的地方是採用了事件(event)的方式來處理輸入,以下是input.c介面重要的資料結構與函數:
* struct input_dev
* void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
* void input_register_device(struct input_dev *);
* void input_unregister_device(struct input_dev *);
* void input_register_handler(struct input_handler *);
* void input_unregister_handler(struct input_handler *);
Linux 的input機制可用來實作「虛擬鍵盤」或「虛擬滑鼠」,只要呼叫input_event()將輸入資料發 ......