sread.c

来自「阿基米德操作系统的源代码」· C语言 代码 · 共 45 行

C
45
字号

//////////////////////////////////////////////////////////////////////////////////////////
#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"
//////////////////////////////////////////////////////////////////////////////////////////

struct buffer_head * sread(int sector, struct msdos_dir_entry ** res_dir, unsigned char floppy_importflag)
{
	struct buffer_head * temp_bh;
	int					 temp_block;

	*res_dir = NULL;

	temp_block  = sector / 2;
	if (!(temp_bh = bread(0,temp_block,floppy_importflag)))
		return NULL;

	if (sector & 0x01)
		*res_dir = (struct msdos_dir_entry *)(temp_bh->b_data) + 16;
	else
		*res_dir = (struct msdos_dir_entry *)(temp_bh->b_data);
	
	return temp_bh;
}

void srelse(struct buffer_head * buf)
{
	brelse(buf);	
	return;
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?