|
发表于 2004-2-28 11:44:36
|
显示全部楼层
在mkinitrd脚本中这一段:
dd if=/dev/zero of=$IMAGE bs=1k count=$IMAGESIZE 2> /dev/null || exit 1
LODEV=$(echo findlodev | /sbin/nash --quiet)
if [ -z "$LODEV" ]; then
rm -rf $MNTIMAGE $MNTPOINT $IMAGE
echo "All of your loopback devices are in use." >&2
exit 1
fi
losetup ${LODEV} $IMAGE || exit 1
其中LODEV=$(echo findlodev | /sbin/nash --quiet)就是找一个loopback设备,比如/dev/loop0(0到255),其中nash.c中关于findlodev指令:
for (devNum = 0; devNum < 256; devNum++) {
sprintf(devName, "/dev/loop%s%d", separator, devNum);
if ((fd = open(devName, O_RDONLY)) < 0) return 0;
if (ioctl(fd, LOOP_GET_STATUS, &loopInfo)) {
close(fd);
printf("%s\n", devName);
return 0;
}
close(fd);
}
有兴趣的话可以自己研究一下:
mkinitrd脚本
Documentation/initrd.txt
Documentation/ramdisk.txt |
|