📄 the_msdos_open.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"
////////////////////////////////////////////////////////////////////////////////////////////////int the_msdos_open(const char * filename,unsigned long flag,unsigned long mode,unsigned char * buf,unsigned long length){ struct m_inode * temp_inode;
struct file * temp_filep; int temp_fd , temp_retval;
unsigned char temp_flag;
unsigned char temp_mode;
temp_flag = flag;
temp_mode = mode;
if (temp_flag & (~(O_APPEND | O_TRUNC | O_EXCL | O_CREAT | O_RDWR)))
return -1;
if (temp_flag & (O_APPEND | O_TRUNC))
temp_flag = temp_flag | O_WRONLY;
for (temp_fd = 0, temp_filep = file_table; temp_fd < NR_FILE; temp_fd++, temp_filep++)
if (!temp_filep->f_count)
break;
if (temp_fd >= NR_FILE)
return -1;
if (!(temp_retval = msdos_open_namei(filename,temp_flag,temp_mode,&temp_inode,buf,length))) return -1; temp_filep->f_inode = temp_inode;
temp_filep->f_pos = 0;
temp_filep->f_flag = temp_flag & (O_APPEND | O_RDWR);
temp_filep->f_count = 1;
return temp_fd;}
int msdos_sys_open(const char * filename,unsigned long flag,unsigned long mode)
{
return the_msdos_open(filename, flag, mode, NULL, 0);
}
int msdos_sys_openEX(const char * filename,unsigned long flag,unsigned long mode,unsigned char * buf,unsigned long length)
{
return the_msdos_open(filename, flag, mode, buf, length);
}
int msdos_sys_create(const char * pathname, unsigned long mode){ return the_msdos_open(pathname, O_CREAT | O_EXCL, mode, NULL, 0);}int msdos_sys_close(int fd){ if ((fd >= NR_FILE) || (file_table[fd].f_count == 0))
return -1; if (--file_table[fd].f_count) return 0; msdos_iput(file_table[fd].f_inode); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -