⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filedes.h

📁 T-kernel 的extension源代码
💻 H
字号:
/* *---------------------------------------------------------------------- *    T-Kernel / Standard Extension * *    Copyright (C) 2006 by Ken Sakamura. All rights reserved. *    T-Kernel / Standard Extension is distributed  *      under the T-License for T-Kernel / Standard Extension. *---------------------------------------------------------------------- * *    Version:   1.00.00 *    Released by T-Engine Forum(http://www.t-engine.org) at 2006/8/11. * *---------------------------------------------------------------------- *//* *	filedes.h (file) * *	File management *	Define the file descriptor. */#ifndef _FM_FILEDES_H_#define _FM_FILEDES_H_#include "fsinfo.h"#include "cmdpkt.h"/* The maximum number of files that can be opened at a time in the whole system. */#define	MaxOpenFile	( fmInfo.maxOpenFile )/* * File descriptor * *	fs == NULL shows that the entry is free. */typedef struct FD {	QUEUE		q;	FsInfo		*fs;		/* Supported file systems */	PINFO		*pinfo;		/* Owner process */	OFCB		*ofcb;		/* Open file */	UW		omode;		/* Open mode */	RCB		*crcb;		/* Current record */	QUEUE		mcbq;		/* Queue of the record map information */	FmCmdPkt	*waitReq;	/* Indeterminate wait request */} FD;/* * File descriptor table *	(Array that has MaxOpenFile entries) */typedef FD	FDT[/*MaxOpenFile*/];#define	SizeOfFDT	( MaxOpenFile * sizeof(FD) )/* * File descriptor table management information */typedef struct FDTInfo {	FastLock	lock;		/* For exclusive access */	FDT		*fdt;		/* First address of FDT */	QUEUE		freeFD;		/* Free list */} FDTInfo;#include "fminfo.h"/* * Lock at the file descriptor access */#define	LockFD()	Lock(&fmInfo.fdtInfo.lock)#define UnlockFD()	Unlock(&fmInfo.fdtInfo.lock)#define	LOCK_FD(exp)	{ LockFD(); exp; UnlockFD(); }/* * The file descriptor number starts from 1. */#define	checkFDno(no)	( (UW)((no) - 1) < (UW)MaxOpenFile )#define	getFDp(no)	( &(*fmInfo.fdtInfo.fdt)[(no) - 1] )#define	getFDno(fd)	( ((fd) - getFDp(1)) + 1 )/* * TRUE when some records of the file are mapped with fd. * (Note) One mapped with fd that is opened from other are not included. */#define	isMapRecords(fd)	( !isQueEmpty(&(fd)->mcbq) )IMPORT ER	fmInitFileDescriptorTable( void );IMPORT void	fmDeleteFileDescriptorTable( void );IMPORT FD*	fmGetFD( W no, PINFO *pinfo );IMPORT FD*	fmpOpenFD( PINFO *pinfo, UW omode, OFCB *ofcb, ER *err );IMPORT void	fmpCloseFD( FD *fd );IMPORT ER	fmpCheckFileOpenMode( FD *fd, UW omode );IMPORT void	fmpMoveCurRecord( FD *fd, RCB *new );#endif

⌨️ 快捷键说明

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