资源简介
linux的最初版本源码,看看会有收获。

代码片段和文件信息
/* bitmap.c contains the code that handles the inode and block bitmaps */
#include
#include
#include
#define clear_block(addr) \
__asm__(“cld\n\t“ \
“rep\n\t“ \
“stosl“ \
::“a“ (0)“c“ (BLOCK_SIZE/4)“D“ ((long) (addr)):“cx““di“)
#define set_bit(nraddr) ({\
register int res __asm__(“ax“); \
__asm__(“btsl %2%3\n\tsetb %%al“:“=a“ (res):“0“ (0)“r“ (nr)“m“ (*(addr))); \
res;})
#define clear_bit(nraddr) ({\
register int res __asm__(“ax“); \
__asm__(“btrl %2%3\n\tsetnb %%al“:“=a“ (res):“0“ (0)“r“ (nr)“m“ (*(addr))); \
res;})
#define find_first_zero(addr) ({ \
int __res; \
__asm__(“cld\n“ \
“1:\tlodsl\n\t“ \
“notl %%eax\n\t“ \
“bsfl %%eax%%edx\n\t“ \
“je 2f\n\t“ \
“addl %%edx%%ecx\n\t“ \
“jmp 3f\n“ \
“2:\taddl $32%%ecx\n\t“ \
“cmpl $8192%%ecx\n\t“ \
“jl 1b\n“ \
“3:“ \
:“=c“ (__res):“c“ (0)“S“ (addr):“ax““dx““si“); \
__res;})
void free_block(int dev int block)
{
struct super_block * sb;
struct buffer_head * bh;
if (!(sb = get_super(dev)))
panic(“trying to free block on nonexistent device“);
if (block < sb->s_firstdatazone || block >= sb->s_nzones)
panic(“trying to free block not in datazone“);
bh = get_hash_table(devblock);
if (bh) {
if (bh->b_count != 1) {
printk(“trying to free block (%04x:%d) count=%d\n“
devblockbh->b_count);
return;
}
bh->b_dirt=0;
bh->b_uptodate=0;
brelse(bh);
}
block -= sb->s_firstdatazone - 1 ;
if (clear_bit(block&8191sb->s_zmap[block/8192]->b_data)) {
printk(“block (%04x:%d) “devblock+sb->s_firstdatazone-1);
panic(“free_block: bit already cleared“);
}
sb->s_zmap[block/8192]->b_dirt = 1;
}
int new_block(int dev)
{
struct buffer_head * bh;
struct super_block * sb;
int ij;
if (!(sb = get_super(dev)))
panic(“trying to get new block from nonexistant device“);
j = 8192;
for (i=0 ; i<8 ; i++)
if (bh=sb->s_zmap[i])
if ((j=find_first_zero(bh->b_data))<8192)
break;
if (i>=8 || !bh || j>=8192)
return 0;
if (set_bit(jbh->b_data))
panic(“new_block: bit already set“);
bh->b_dirt = 1;
j += i*8192 + sb->s_firstdatazone-1;
if (j >= sb->s_nzones)
return 0;
if (!(bh=getblk(devj)))
panic(“new_block: cannot get block“);
if (bh->b_count != 1)
panic(“new block: count is != 1“);
clear_block(bh->b_data);
bh->b_uptodate = 1;
bh->b_dirt = 1;
brelse(bh);
return j;
}
void free_inode(struct m_inode * inode)
{
struct super_block * sb;
struct buffer_head * bh;
if (!inode)
return;
if (!inode->i_dev) {
memset(inode0sizeof(*inode));
return;
}
if (inode->i_count>1) {
printk(“trying to free inode with count=%d\n“inode->i_count);
panic(“free_inode“);
}
if (inode->i_nlinks)
panic(“trying to free inode with links“);
if (!(sb = get_super(inode->i_dev)))
panic(“trying to free inode on nonexistent device“);
if (inode->i_num < 1 || inode->i_num > sb->s_ninodes)
panic(“trying to free inode 0 or nonexistant inode“);
if (!(bh=sb->s_imap[inode->i_num>>13]))
panic(“nonexiste
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2186 1991-09-17 21:53 060321linuxcode\linuxcode\linux\Makefile
文件 6821 2006-03-19 23:21 060321linuxcode\linuxcode\linux\黑客基地hackba
文件 1710 1991-07-03 01:20 060321linuxcode\linuxcode\linux\tools\build.c
文件 770 1991-09-17 23:15 060321linuxcode\linuxcode\linux\mm\Makefile
文件 7048 1991-09-17 23:07 060321linuxcode\linuxcode\linux\mm\memory.c
文件 448 1991-06-30 02:50 060321linuxcode\linuxcode\linux\mm\page.s
文件 69 1991-09-17 23:24 060321linuxcode\linuxcode\linux\lib\close.c
文件 1140 1991-09-17 23:17 060321linuxcode\linuxcode\linux\lib\ctype.c
文件 67 1991-09-17 23:26 060321linuxcode\linuxcode\linux\lib\dup.c
文件 11 1991-09-17 23:24 060321linuxcode\linuxcode\linux\lib\errno.c
文件 107 1991-09-17 23:26 060321linuxcode\linuxcode\linux\lib\execve.c
文件 992 1991-09-17 23:29 060321linuxcode\linuxcode\linux\lib\Makefile
文件 328 1991-09-17 23:24 060321linuxcode\linuxcode\linux\lib\open.c
文件 65 1991-09-17 23:26 060321linuxcode\linuxcode\linux\lib\setsid.c
文件 114 1991-09-17 23:28 060321linuxcode\linuxcode\linux\lib\string.c
文件 192 1991-09-17 23:26 060321linuxcode\linuxcode\linux\lib\wait.c
文件 98 1991-09-17 23:25 060321linuxcode\linuxcode\linux\lib\write.c
文件 136 1991-09-17 23:23 060321linuxcode\linuxcode\linux\lib\_exit.c
文件 2665 1991-07-09 07:29 060321linuxcode\linuxcode\linux\kernel\asm.s
文件 9524 1991-09-07 23:46 060321linuxcode\linuxcode\linux\kernel\console.c
文件 2915 1991-09-17 23:55 060321linuxcode\linuxcode\linux\kernel\exit.c
文件 3477 1991-09-17 20:30 060321linuxcode\linuxcode\linux\kernel\fork.c
文件 9734 1991-09-17 23:05 060321linuxcode\linuxcode\linux\kernel\hd.c
文件 9497 1991-08-30 05:14 060321linuxcode\linuxcode\linux\kernel\keyboard.s
文件 3843 1991-09-17 23:15 060321linuxcode\linuxcode\linux\kernel\Makefile
文件 1395 1991-08-30 20:09 060321linuxcode\linuxcode\linux\kernel\mktime.c
文件 222 1991-08-19 06:06 060321linuxcode\linuxcode\linux\kernel\panic.c
文件 602 1991-09-17 23:09 060321linuxcode\linuxcode\linux\kernel\printk.c
文件 2653 1991-09-18 00:29 060321linuxcode\linuxcode\linux\kernel\rs_io.s
文件 5155 1991-09-17 21:28 060321linuxcode\linuxcode\linux\kernel\sched.c
............此处省略76个文件信息
相关资源
- uboot到linux logo显示不间断 补丁
- UNIX/LINUX编程实践教程的源码
- Linux任务管理器
- linux应用层的华容道游戏源代码
- ubuntu9.10 可加载内核模块和字符设备驱
- MP3文件ID3v2ID3v2APEv2标签读取
- 操作系统实验——虚存管理实验
- linux下的发包工具sendip
- 尚观培训linux许巍关于c 的笔记和讲义
- 尚观培训linux董亮老师关于数据结构的
- linux 线程池源码 c 版
- linux C 电梯程序练习
- linux下用多进程同步方法解决生产者
- Linux 操作系统实验(全)
- Linux From Scratch 中文手册
- linux 网络实验 ftp程序
- Linux命令大全离线版&在线版
- 操作系统共享内存实验
- dos 下运行Linux 命令--gnu_utils
- linux 0.12内核源代码
- linux简易shell C实现
- linux实验报告及心得体会
- 基于GTK的Linux环境下的简易任务管理器
- linux扫雷游戏代码
- CAN Linux驱动代码
- Linux系统教材
- intel 82579LM 网卡驱动Linux系统版 v1.9.
- SA1110处理器掌上电脑液晶显示器设计
- 基于Linux的串口服务器设计
- Windows下访问LINUX的利器-SSH
评论
共有 条评论