📄 buffer_init.c
字号:
//////////////////////////////////////////////////////////////////////////
#include "general.h"
#include "hd_info_struct.h"
#include "dir_entry.h"
#include "msdos_dir_entry.h"
#include "d_inode.h"
#include "m_inode.h"
#include "buffer_head.h"
#include "fat_cache.h"
#include "file.h"
#include "hd_request_struct.h"
#include "super_block.h"
#include "common_head.h"
//////////////////////////////////////////////////////////////////////////
void buffer_init(void)
{
struct buffer_head * temp_start = (struct buffer_head *) BUFFER_START;
void * temp_end = (void *) BUFFER_END;
int temp_i,temp_bufnum;
////////////////////////////////////////////////////////////////
temp_bufnum = (BUFFER_END - BUFFER_START) / (BLOCK_SIZE + 32);
temp_end = temp_end - temp_bufnum * BLOCK_SIZE;
start_buffer = temp_start;
for (temp_i = 0; temp_i < temp_bufnum; temp_i++)
{
temp_start->b_data = (char *) temp_end;
temp_start->b_dev = 0;
temp_start->b_blocknr = 0;
temp_start->b_uptodate = 0;
temp_start->b_dirt = 0;
temp_start->b_count = 0;
temp_start->b_lock = 0;
temp_start->b_prev = NULL;
temp_start->b_next = NULL;
temp_start->b_prev_free = temp_start - 1;
temp_start->b_next_free = temp_start + 1;
temp_start++;
temp_end = temp_end + BLOCK_SIZE;
}
end_buffer = temp_start;
current_buffer = start_buffer;
sys_buffer = start_buffer;
for (temp_i = 0; temp_i < 17; temp_i++)
{
sys_buffer->b_blocknr = temp_i;
sys_buffer->b_uptodate = 0x80;
sys_buffer->b_count = 1;
sys_buffer->b_prev_free = sys_buffer;
sys_buffer->b_next_free = sys_buffer;
sys_buffer++;
}
temp_start--;
sys_buffer->b_prev_free = temp_start;
temp_start->b_next_free = sys_buffer;
free_list = sys_buffer;
nr_buffers = temp_bufnum;
////////////////////////////////////////////////////////////////
for (temp_i = 0 ; temp_i < NR_HASH ; temp_i++)
hash_table[temp_i] = NULL;
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -