易截截图软件、单文件、免安装、纯绿色、仅160KB

linux驱动之mmap实例

// Linux Device Driver Template/Skeleton with mmap
// Kernel Module
#include <linux/module.h>
#include <linux/init.h>
#include <linux/version.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <linux/vmalloc.h>
#include <linux/mman.h>
#include <linux/slab.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
#include <linux/wrapper.h>
#endif
#define SKELETON_MAJOR 240
#define SKELETON_NAME "skeleton"
#define CASE1 1
#define CASE2 2
static unsigned int counter = 0;
static char string [128];
static int data;
//#define USEASCII
#ifdef USEASCII
static char *kmalloc_area = NULL;
static char *kmalloc_ptr = NULL;
#else
static unsigned int *kmalloc_area = NULL;
static unsigned int *kmalloc_ptr = NULL;
#endif
#define LEN (64*1024)
unsigned long virt_addr;
DECLARE_WAIT_QUEUE_HEAD(skeleton_wait);
static int data_not_ready = 0;
// open function - called when the "file" /dev/skeleton is opened in userspace
static int skeleton_open (struct inode *inode, struct file *file) {
 printk("skeleton_openn");
 // we could do some checking on the flags supplied by "open"
 // i.e. O_NONBLOCK
 // -> set some flag to disable interruptible_sleep_on in skeleton_read
 return 0;
}
// close function - called when the "file" /dev/skeleton is closed in userspace 
static int skeleton_release (struct inode *inode, struct file *file) {
 printk("skeleton_releasen");
 return 0;
}
// read function called when from /dev/skeleton is read
static ssize_t skeleton_read (struct file *file, char *buf,
  size_t count, loff_t *ppos) {
 int len, err;
 
 // check if we have data - if not, sleep
 // wake up in interrupt_handler
 while (data_not_ready) {
  interrupt


相关文档:

linux进程后台运行的几种方法


我们经常会碰到这样的问题,用 telnet/ssh 登录了远程的 Linux 服务器,运行了一些耗时较长的任务, 结果却由于网络的不稳定导致任务中途失败。如何让命令提交后不受本地关闭终端窗口/网络断开连接的干扰呢?下面举了一些例子, 您可以针对不同的场景选择不同的方式来处理这个问题。
nohup/setsid/&
场景:
如果只 ......

Linux下忘记MySQL root密码的解决方案

最近实验室内部的mysql的root密码被修改了,需要想办法修改新密码。方法如下:
1, 关闭mysql服务
/etc/init.d/mysqld stop
2,使用–skip-grant-tables选项启动MySQL服务,可以修改/etc/inin.d/mysqld脚本启动位置增加此选项,
vi /etc/init.d/mysqld
在下面运行启动的语句里增加--skip-grant-tables
......

linux 下用C实现‘CAT’的功能

linux
下用C实现‘CAT’的功能
#include<stdio.h>
int main(int argc,char *argv[]){
FILE *file;
char buf[1024],name[20];
int n;
if(argc != 2){
printf("wrong argument\n");
return 1;
}
file=fopen(argv[1],"r");
if(file==NULL){
printf("Cant't open!\n&quo ......

linux上安装python服务器相关工具


1、升级系统
yum check-update
yum update
2、安装一些常用的工具
yum install ntp iptraf sysstat screen subversion wget bzip2 nfs-utils vim-common
3、设置每天自动核准时间
# crontab -e
0 * * * * /usr/sbin/ntpdate 210.72.145.44
:wq
4、安装一些开发包
# yum install make gcc gcc-c++ libjpeg-devel ......

学习linux programming(1)


【1. linux applications 有两种形式】
  i)可执行的文件: 可由计算机直接运行,相当于windows的.exe文件
  ii)Script: collections of instructions for another program. 相当于windows的.bat .cmd文件
 
【2. PATH】
在Linux中,当输入程序名(如Firefox)时,系统会在名为PATH的Shell变量所给 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号