您正在查看 "Linux" 分类下的文章
2009-09-24 17:05
gfp_zone函数作用:
根据gfp flag确定选择哪一个zone来分配内存。
static inline enum zone_type gfp_zone(gfp_t flags)
{
enum zone_type z;
int bit = flags & GFP_ZONEMASK; //获取zone相关的flag
z = (GFP_ZONE_TABLE >> (bit * ZONES_SHIFT)) &
((1 << ZONES_SHIFT) - 1);
/*这里用到了GFP_ZONE_TABLE。zone的最大值所占用的bit数位ZONES_SHIFT。flag有各种的组合,0到组合的最大值都分别对应一个zone值,也就是需要占用ZONES_SHIFT bit数。(bit * ZONES_SH |
2008-05-29 10:40
kernel和udev间传递消息,比如add,remove等,是通过netlink进行。 netlink是个通用的机制,传递udev event只是其中一个应用。
由于uevent是广播的,所以写个小程序很容易不会这些事件。
写得比较匆忙,也很丑陋,呵呵。
#include <stdio.h>
#include <sys/socket.h>
#include <linux/netlink.h>
char buf[2048 + 512];
int main()
{
int bufsize = 16 * 1024 * 1024;
struct sockaddr_nl anl;
int r |
2008-05-13 09:25
c中,goto只能用于在本函数中跳转,label的作用域也是本函数。也就是说,不同函数中可以定于名字相同的label。 |
2008-01-22 15:11
现在软驱渐渐淡出了人们的实现,但是redhat兼容的一些linux发行版有时还需要driver disk。
driver disk就是驱动盘,比如说如果你的sata控制器比较新,而你的linux版本比较老不能认出你的硬件,你就必须用driver disk安装linux,就是在redhat安装提示时输入“linux dd”。传统上driver disk都是dd到软盘上使用的,driver disk的image可以从硬件官方网站上down。
没有软驱怎么办?其实redhat的安装程序已经考虑到了。把一个已分区的u盘(通常是指由一个主分区sda1)挂到windows上,然后把driver disk的image copy上去, |
2008-01-13 11:54
The process needs internet connection and configured source.list.
1, Download the source package
#apt-get source packname_packversion-debianversion
2, Patch the source
#cd packname_packversion
Modify the source as you want.
You'd better inscrase the debianversion of the package by modifying debian/changelog, to avoid conflict.
3, Rebuild source package
#dpkg-buildpackage -S -rfakeroot
4, Build binary package
#cd .. && sudo pbuilder build packna |
2007-12-30 20:43
build是在最后生成kernel image的时候被调用的,典型的调用方法是"arch/i386/boot/tools/build -b arch/i386/boot/bootsect arch/i386/boot/setup arch/i386/boot/vmlinux.bin CURRENT > arch/i386/boot/bzImag" 。-b表示是bigkernel
build主要做了如下事情:
1、判断bootsect是否为512字节,offset 510-511处是否为0x55aa。0x55aa是boot sector的标志
2、在bootsect的508、509处分别写入root major和minor,并把bootset输出到stdout
3、把setup pad成512字节对齐,并输出到stdout
4、把vmlinux.bin |
2007-12-24 15:38
msleep在2.6里面变成了schedule_timeout_uninterruptible。
今天看代码才知道,记得以前用2.4的时候msleep就是忙等待。 |
2007-12-24 10:13
Legacy IDE is in compatible mode. A controller that operates in compatible mode emulates a legacy IDE controller, which is a non-standard extension of the ISA-based IDE controller. In compatible mode, the controller requires two ISA-style dedicated IRQs (14 and 15) that cannot be shared with other devices. Because compatible mode requires dedicated resources, the ATA controller for the boot device (which is usually integrated in chipsets on the motherboard) is the only controller on a system t |
2007-12-19 22:08
/*
* These inlines deal with timer wrapping correctly. You are
* strongly encouraged to use them
* 1. Because people otherwise forget
* 2. Because if the timer wrap changes in future you won't have to
* alter your driver code.
*
* time_after(a,b) returns true if the time a is after time b.
*
* Do this with "<0" and ">=0" to only test the sign of the result. A
* good compiler would generate |
2007-12-12 15:50
cp /boot/initrd-xx initrd-xx.gz; gzip -d initrd-xx.gz
mkdir tmp;cd tmp;cpio -i < ../initrd-xx
........ //modify the initrd file system
find | cpio -c -o > ../initrd-xx //must use -c option, or it may not be mounted by kernel
gzip initrd-xx
cp initrd-xx.gz /boot/initrd-xx
ok! |
|
|