📄 msdos_smap.c
字号:
///////////////////////////////////////////////////////////////////////////////////////////
#include "general.h"
#include "s_isdirreg.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"
///////////////////////////////////////////////////////////////////////////////////////////
int get_cluster(struct m_inode * inode,int cluster,int flag){ int temp_fatno, temp_lastno, temp_count; if (!(temp_fatno = inode->i_zone[0]) && flag)
{
temp_fatno = new_cluster();
if (temp_fatno > 0)
{
if S_MSDOS_ISREG(inode->i_mode)
inode->i_mtime = file_datetime;
inode->i_zone[0] = temp_fatno;
inode->i_dirt = 1;
}
}
if (temp_fatno <= 0)
return 0; if (!cluster)
return temp_fatno;
temp_count = 0; for (cache_lookup(inode,cluster,&temp_count,&temp_fatno); temp_count < cluster; temp_count++)
{
temp_lastno = temp_fatno;
temp_fatno = fat_access(temp_fatno,-1);
if (!temp_fatno)
return 0;
if ((temp_fatno == -1) && flag)
{
temp_fatno = new_cluster();
if (temp_fatno > 0)
{
fat_access(temp_lastno,temp_fatno);
if S_MSDOS_ISREG(inode->i_mode)
{
inode->i_mtime = file_datetime;
inode->i_dirt = 1;
}
}
}
if (temp_fatno <= 0)
return 0; } cache_add(inode,cluster,temp_fatno); return temp_fatno;}int msdos_smap(struct m_inode * inode,int sector,int flag)
{
if (inode->i_num == MSDOS_ROOT_INO)
{
if (sector >= 14)
return 0;
return sector + 19;
}
if (!(sector = get_cluster(inode,sector,flag)))
return 0;
return sector + 31;
}
int fat_free(struct m_inode * inode,int skip){ int temp_fatno, temp_lastno; if (!(temp_fatno = inode->i_zone[0]))
return 0;
temp_lastno = 0;
while (skip--) { temp_lastno = temp_fatno;
temp_fatno = fat_access(temp_fatno,-1);
if (!temp_fatno)
return -1;
if (temp_fatno == -1)
return 0; }
if (temp_lastno) fat_access(temp_lastno,0xfff); else { inode->i_zone[0] = 0;
inode->i_dirt = 1; }
if S_MSDOS_ISREG(inode->i_mode)
{
inode->i_mtime = file_datetime;
inode->i_dirt = 1;
}
cache_inval_inode(inode);
while (temp_fatno != -1)
{
temp_fatno = fat_access(temp_fatno,0);
if (!temp_fatno)
return -1;
}
return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -