📄 namei_1.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 sys_delete(const char * name){ struct m_inode * dir, * inode; struct buffer_head * bh; struct dir_entry * de;
const char * basename;
int namelen;
if (!(dir = dir_namei(name,&namelen,&basename))) return -1; if (!namelen) { iput(dir); return -1; } bh = find_entry(dir,basename,namelen,&de); if (!bh) { iput(dir); return -1; } inode = iget(dir->i_dev, de->inode); if (!inode) { brelse(bh);
iput(dir); return -1; } if (!S_ISREG(inode->i_mode)) { iput(inode);
brelse(bh); iput(dir); return -1; } inode->i_nlinks--; inode->i_mtime = file_datetime;
inode->i_dirt = 1;
iput(inode);
de->inode = 0;
bh->b_dirt = 1;
brelse(bh);
dir->i_mtime = file_datetime;
dir->i_dirt = 1; iput(dir);
return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -