亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? tfsapi.c

?? 可移到ucos上的文件系統(tǒng)
?? C
字號(hào):
/* tfsapi.c:
 *	This file contains the portion of TFS that provides the function-level
 *	API to the application.  If this is not being used by the application
 *	then it can be omitted from the monitor build.
 *	Note that not all of the api-specific code is here; some of it is in
 *	tfs.c.  This is because the the MicroMonitor uses some of the api itself,
 *	so it cannot be omitted from the TFS package without screwing up some 
 *	other monitor functionality that needs it.
 *
 *	General notice:
 *	This code is part of a boot-monitor package developed as a generic base
 *	platform for embedded system designs.  As such, it is likely to be
 *	distributed to various projects beyond the control of the original
 *	author.  Please notify the author of any enhancements made or bugs found
 *	so that all may benefit from the changes.  In addition, notification back
 *	to the author will allow the new user to pick up changes that may have
 *	been made by other users after this version of the code was distributed.
 *
 *	Author:	Ed Sutter
 *	email:	esutter@lucent.com		(home: lesutter@worldnet.att.net)
 *	phone:	908-582-2351			(home: 908-889-5161)
 */
#include "config.h"
#include "cpu.h"
#include "stddefs.h"
#include "genlib.h"
#include "tfs.h"
#if INCLUDE_TFSAPI

/* tfstruncate():
 *	To support the ability to truncate a file (make it smaller); this
 *	function allows the user to adjust the high-water point of the currently
 *	opened (and assumed to be opened for modification) file and replaces
 *	that with the incoming argument.  This replacement is only done if the
 *	current high-water point is higher than the incoming length.
 *	MONLIB NOTICE: this function is accessible through monlib.c.
 */
int
tfstruncate(int fd, long len)
{
	struct tfsdat *tdat;

	/* Verify valid range of incoming file descriptor. */
	if ((fd < 0) || (fd >= TFS_MAXOPEN))
		return(TFSERR_BADFD);

	tdat = &tfsSlots[fd];

	/* Make sure the file pointed to by the incoming descriptor is active
	 * and that the incoming length is greater than the current high-water
	 * point...
	 */
	if (tdat->offset == -1)
		return(TFSERR_BADFD);
	if (len > tdat->hwp)
		return(TFSERR_BADARG);

	/* Make the adjustment... */
	tdat->hwp = len;
	return(TFS_OKAY);
}

/* tfseof():
 *	Return 1 if at the end of the file, else 0 if not at end; else negative
 *	if error.
 *	MONLIB NOTICE: this function is accessible through monlib.c.
 */
int
tfseof(int fd)
{
	struct tfsdat *tdat;

	/* Verify valid range of incoming file descriptor. */
	if ((fd < 0) || (fd >= TFS_MAXOPEN))
		return(TFSERR_BADARG);

	tdat = &tfsSlots[fd];

	/* Make sure the file pointed to by the incoming descriptor is active. */
	if (tdat->offset == -1)
		return(TFSERR_BADFD);

	if (tdat->offset >= tdat->hdr.filsize)
		return(1);
	else
		return(0);
}

/* tfsread():
 *	Similar to a standard read call to a file.
 *	MONLIB NOTICE: this function is accessible through monlib.c.
 */
int
tfsread(int fd, char *buf, int cnt)
{
	struct tfsdat *tdat;
	uchar *from;

	if (tfsTrace > 1)
		printf("tfsread(%d,0x%lx,%d)\n",fd,(ulong)buf,cnt);

	/* Verify valid range of incoming file descriptor. */
	if ((cnt < 1) || (fd < 0) || (fd >= TFS_MAXOPEN))
		return(TFSERR_BADARG);

	tdat = &tfsSlots[fd];

	/* Make sure the file pointed to by the incoming descriptor is active. */
	if (tdat->offset == -1)
		return(TFSERR_BADFD);

	if (tdat->offset >= tdat->hdr.filsize)
		return(TFSERR_EOF);

	from = (uchar *) tdat->base + tdat->offset;

	/* If request size is within the range of the file and current
	 * then copy the data to the requestors buffer, increment offset 
	 * and return the count.
	 */
	if ((tdat->offset + cnt) <= tdat->hdr.filsize) {
		if (tfsmemcpy(buf, from, cnt,0,0) != 0)
			return(TFSERR_MEMFAIL);
	}
	/* If request size goes beyond the size of the file, then copy
	 * to the end of the file and return that smaller count.
	 */
	else {
		cnt = tdat->hdr.filsize - tdat->offset;
		if (tfsmemcpy(buf, from, cnt, 0, 0) != 0)
			return(TFSERR_MEMFAIL);
	}
	tdat->offset += cnt;
	tdat->wptr += cnt;
	return(cnt);
}

/* tfswrite():
 *	Similar to a standard write call to a file.
 *	MONLIB NOTICE: this function is accessible through monlib.c.
 */
int
tfswrite(int fd, char *buf, int cnt)
{
	struct tfsdat *tdat;

	if (tfsTrace > 1)
		printf("tfswrite(%d,0x%lx,%d)\n", fd,(ulong)buf,cnt);

	/* Verify valid range of incoming file descriptor. */
	if ((cnt < 1) || (fd < 0) || (fd >= TFS_MAXOPEN))
		return(TFSERR_BADARG);

	/* Make sure the file pointed to by the incoming descriptor is active. */
	if (tfsSlots[fd].offset == -1)
		return(TFSERR_BADARG);

	tdat = &tfsSlots[fd];

	/* Make sure file is not opened as read-only */
	if (tdat->flagmode & TFS_RDONLY)
		return(TFSERR_RDONLY);

	if (tfsmemcpy(tdat->wptr,buf,cnt,0,0) != 0)
		return(TFSERR_MEMFAIL);

	tdat->wptr += cnt;
	tdat->offset += cnt;

	/* If new offset is greater than current high-water point, then
	 * adjust the high water point so that it is always reflecting the
	 * highest offset into which the file has had some data written.
	 */
	if (tdat->offset > tdat->hwp)
		tdat->hwp = tdat->offset;

	return(TFS_OKAY);
}

/* tfsseek():
 *	Adjust the current pointer into the specified file.
 *	If file is read-only, then the offset cannot exceed the file size;
 *	otherwise, the only check made to the offset is that it is positive.
 *	MONLIB NOTICE: this function is accessible through monlib.c.
 */
int
tfsseek(int fd, int offset, int whence)
{
	int	o_offset;
	uchar *o_wptr;
	struct tfsdat *tdat;

	if ((fd < 0) || (fd >= TFS_MAXOPEN))
		return(TFSERR_BADARG);

	tdat = &tfsSlots[fd];
	o_offset = tdat->offset;
	o_wptr = tdat->wptr;

	switch (whence) {
		case TFS_BEGIN:
			tdat->offset = offset;
			tdat->wptr = tdat->base+offset;
			break;
		case TFS_CURRENT:
			tdat->offset += offset;
			tdat->wptr += offset;
			break;
		default:
			return(TFSERR_BADARG);
	}

	/* If new offset is less than zero or if the file is read-only and the
	 * new offset is greater than the file size, return EOF...
	 */
	if ((tdat->offset < 0) ||
		((tdat->flagmode & TFS_RDONLY) && (tdat->offset > tdat->hdr.filsize))){
		tdat->offset = o_offset;
		tdat->wptr = o_wptr;
		return(TFSERR_EOF);
	}
	return(TFS_OKAY);
}

/* tfsgetline():
 *	Read into the buffer a block of characters upto the next CR or LF in
 *	the file.  After the CR/LF, or after max-1 chars are loaded, terminate
 *	with a NULL.  Return the number of characters loaded.
 *	At end of file return 0.
 *	MONLIB NOTICE: this function is accessible through monlib.c.
 */
int
tfsgetline(int fd,char *buf,int max)
{
	int		cnt;
	uchar	*from, *fromtmp;
	struct	tfsdat *tdat;

	max--;

	if (tfsTrace > 1)
		printf("tfsgetline(%d,0x%lx,%d)\n",fd,(ulong)buf,max);

	/* Verify valid range of incoming file descriptor. */
	if ((max < 1) || (fd < 0) || (fd >= TFS_MAXOPEN))
		return(TFSERR_BADARG);

	/* Make sure the file pointed to by the incoming descriptor is active. */
	if (tfsSlots[fd].offset == -1)
		return(TFSERR_BADARG);

	tdat = &tfsSlots[fd];

	if (tdat->offset == -1)
		return(TFSERR_BADFD);

	if (tdat->offset >= tdat->hdr.filsize)
		return(0);

	from = (uchar *) tdat->base + tdat->offset;

	/* Determine the count based on the presence (or lack thereof) of a
	 * carriage return or line feed...
	 */
	for(fromtmp=from,cnt=0;cnt<max && *fromtmp;cnt++,fromtmp++) {
		if ((*fromtmp == '\r') || (*fromtmp == '\n')) {
			cnt++;
			break;
		}
	}

	/* If request size is within the range of the file and current
	 * then copy the data to the requestors buffer, increment offset
	 * and return the count.
	 */
	if ((tdat->offset + cnt) <= tdat->hdr.filsize) {
		if (tfsmemcpy(buf, from, cnt,0,0) != 0)
			return(TFSERR_MEMFAIL);
	}
	/* If request size goes beyond the size of the file, then copy
	 * to the end of the file and return that smaller count.
	 */
	else {
		cnt = tdat->hdr.filsize - tdat->offset;
		if (tfsmemcpy(buf, from, cnt, 0, 0) != 0)
			return(TFSERR_MEMFAIL);
	}
	buf[cnt] = 0;
	tdat->offset += cnt;
	return(cnt);
}

/* tfsipmod():
 *	Modify "in-place" a portion of a file in TFS.
 *	This is a cheap and dirty way to modify a file...
 *	The idea is that a file is created with a lot of writeable flash space
 *	(data = 0xff).  This function can then be called to immediately modify
 *	blocks of space in that flash.  It will not do any tfsunlink/tfsadd, and
 *	it doesn't even require a tfsopen() tfsclose() wrapper.  Its a fast and
 *	efficient way to modify flash in the file system.
 *	Arguments:
 *	name	=	name of the file to be in-place-modified;
 *	buf		=	new data to be written to flash;
 *	offset	=	offset into file into which new data is to be written;
 *	size	=	size of new data (in bytes).
 *	
 *	With offset of -1, set offset to location containing first 0xff value.
 *	MONLIB NOTICE: this function is accessible through monlib.c.
 */
int
tfsipmod(char *name,char *buf,int offset,int size)
{
	TFILE	*fp;
	uchar	*cp;

	fp = tfsstat(name);
	if (!fp)
		return (TFSERR_NOFILE);
	if (!(fp->flags & TFS_IPMOD))
		return(TFSERR_NOTIPMOD);
	
	if (offset == -1) {
		cp = (uchar *)(TFS_BASE(fp));
		for (offset=0;offset<fp->filsize;offset++,cp++) {
			if (*cp == 0xff)
				break;
		}
	}
	else if (offset < -1)
		return(TFSERR_BADARG);
	
	if ((offset + size) > fp->filsize)
		return(TFSERR_WRITEMAX);
	
	if (tfsflashwrite((ulong *)(TFS_BASE(fp))+offset,(ulong *)buf,size) == -1)
		return (TFSERR_FLASHFAILURE);

	tfslog(TFSLOG_IPM,name);
	return(TFS_OKAY);
}

/* tfsopen():
 *	Open a file for reading or creation.  If file is opened for writing,
 *	then the caller must provide a RAM buffer  pointer to be used for
 *	the file storage until it is transferred to flash by tfsclose().
 *	Note that the "buf" pointer is only needed for opening a file for
 *	creation or append (writing).
 *	MONLIB NOTICE: this function is accessible through monlib.c.
 */
int
tfsopen(char *file,long flagmode,char *buf)
{
	register int i;
	int		errno, retval;
	long	fmode;
	TFILE	*fp;
	struct	tfsdat *slot;

	/* See if file exists... */
	fp = tfsstat(file);

	/* If file exists, do a crc32 on the data... */
	if (fp) {
		if (crc32(TFS_BASE(fp),fp->filsize) != fp->filcrc) {
			retval = TFSERR_BADCRC;
			goto done;
		}
	}

	errno = TFS_OKAY;

	fmode = flagmode & (TFS_RDONLY | TFS_APPEND | TFS_CREATE);

	/* This switch verifies...
	 * - that the file exists if TFS_RDONLY or TFS_APPEND
	 * - that the file does not exist if TFS_CREATE
	 */
	switch(fmode) {
	case TFS_RDONLY:	/* Read existing file only, no change to file at all. */
		if (!fp)
			errno = TFSERR_NOFILE;
		else {
			if ((fp->flags & TFS_UNREAD) && (TFS_USRLVL(fp) > getUsrLvl()))
				errno = TFSERR_USERDENIED;
		}
		break;
	case TFS_APPEND:	/* Append to the end of the current file. */
		if (!fp)
			errno = TFSERR_NOFILE;
		else {
			if (TFS_USRLVL(fp) > getUsrLvl())
				errno = TFSERR_USERDENIED;
		}
		break;
	case TFS_CREATE:	/* Create a new file */
		if (fp)
			errno = TFSERR_FILEEXISTS;
		break;
	case (TFS_APPEND|TFS_CREATE):	/* If both mode bits are set, clear one */
		if (fp) {					/* based on the presence of the file. */
			if (TFS_USRLVL(fp) > getUsrLvl())
				errno = TFSERR_USERDENIED;
			fmode = TFS_APPEND;
		}
		else {
			fmode = TFS_CREATE;
		}
		break;
	default:
		errno = TFSERR_BADARG;
		break;
	}

	if (errno != TFS_OKAY) {
		retval = errno;
		goto done;
	}

	slot = tfsSlots;
	for (i=0;i<TFS_MAXOPEN;i++,slot++) {
		if (slot->offset == -1) {
			slot->hwp = 0;
			slot->offset = 0;
			slot->flagmode = fmode;
			if (fmode & TFS_CREATE) {
				strncpy(slot->hdr.name,file,TFSNAMESIZE);
				slot->flagmode |= (flagmode & TFS_FLAGMASK);
				slot->base = (uchar *)buf;
				slot->wptr = (uchar *)buf;
			}
			else if (fmode & TFS_APPEND) {
				slot->hdr = *fp;
				if (tfsmemcpy(buf,(uchar *)(TFS_BASE(fp)),
					fp->filsize,0,0) != 0) {
					retval = TFSERR_MEMFAIL;
					goto done;
				}
				slot->flagmode = fp->flags;
				slot->flagmode |= TFS_APPEND;
				slot->base = (uchar *)buf;
				slot->wptr = (uchar *)buf+fp->filsize;
				slot->hwp = fp->filsize;
				slot->offset = fp->filsize;
			}
			else {
				slot->base = (uchar *) (TFS_BASE(fp));
				slot->wptr = 0;
				slot->hdr = *fp;
			}
			break;
		}
	}
	if (i == TFS_MAXOPEN)
		retval = TFSERR_NOSLOT;
	else
		retval = i;

done:		
	if (tfsTrace > 0)
		printf("tfsopen(%s,0x%lx,0x%lx)=%d\n",file,flagmode,(ulong)buf,retval);

	return(retval);
}

/* tfsclose():
 *	If the file was opened for reading only, then just close out the 
 *	entry in the tfsSlots table.  If the file was opened for creation,
 *	then add it to the tfs list.  Note the additional argument is
 *	only needed for tfsclose() of a newly created file.
 *	info  = additional text describing the file.
 *	MONLIB NOTICE: this function is accessible through monlib.c.
 */
int
tfsclose(int fd,char *info)
{
	int		err;
	struct tfsdat *tdat;

	if (tfsTrace > 0)
		printf("tfsclose(%d,%s)\n",fd,info);

	if ((fd < 0) || (fd >= TFS_MAXOPEN))
		return(TFSERR_BADARG);

	tdat = &tfsSlots[fd];

	if (tdat->offset == -1)
		return(TFSERR_BADFD);

	/* Mark the file as closed by setting the offset to -1.
	 * Note that this is done prior to potentially calling tfsadd() so
	 * that tfsadd() will not think the file is opened and reject the add...
	 */
	tdat->offset = -1;

	/* If the file was opened for creation or append, then add it now. */
	if (tdat->flagmode & (TFS_CREATE | TFS_APPEND)) {
		char	buf[16];

		err = tfsadd(tdat->hdr.name, info, tfsflagsbtoa(tdat->flagmode,buf),
			tdat->base, tdat->hwp);
		if (err != TFS_OKAY) {
			printf("%s: %s\n",tdat->hdr.name,tfserrmsg(err));
			return(err);
		}
	}
	return(TFS_OKAY);
}

#else /* INCLUDE_TFSAPI */

int
tfstruncate(int fd, long len)
{
	return(TFSERR_NOTAVAILABLE);
}

int
tfseof(int fd)
{
	return(TFSERR_NOTAVAILABLE);
}

int
tfsread(int fd, char *buf, int cnt)
{
	return(TFSERR_NOTAVAILABLE);
}

int
tfswrite(int fd, char *buf, int cnt)
{
	return(TFSERR_NOTAVAILABLE);
}

int
tfsseek(int fd, int offset, int whence)
{
	return(TFSERR_NOTAVAILABLE);
}

int
tfsopen(char *file,long flagmode,char *buf)
{
	return(TFSERR_NOTAVAILABLE);
}

int
tfsclose(int fd,char *info)
{
	return(TFSERR_NOTAVAILABLE);
}

int
tfsgetline(int fd,char *buf,int max)
{
	return(TFSERR_NOTAVAILABLE);
}

int
tfsipmod(char *name,char *buf,int offset,int size)
{
	return(TFSERR_NOTAVAILABLE);
}

#endif	/* INCLUDE_TFSAPI else */

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产wwwccc36天堂| 日韩午夜在线影院| 中文在线一区二区| 99国产精品久久| 亚洲成a人v欧美综合天堂下载| 欧美一区二区三区在线观看视频| 国产91精品一区二区麻豆亚洲| 久久97超碰色| 久久午夜电影网| 色偷偷一区二区三区| 美女视频一区二区三区| 亚洲欧美日韩久久| 精品久久久久久久一区二区蜜臀| 91天堂素人约啪| 激情欧美一区二区| 亚洲成人综合视频| 日韩在线一区二区三区| 亚洲精品中文字幕在线观看| 久久久久青草大香线综合精品| 欧美日韩一区不卡| 成人毛片视频在线观看| 激情丁香综合五月| 国产a级毛片一区| 91在线码无精品| 欧美最猛黑人xxxxx猛交| 成人激情综合网站| 国产伦理精品不卡| 久久国产精品第一页| 丝袜a∨在线一区二区三区不卡| 日韩黄色免费电影| 狠狠色狠狠色综合日日91app| 国产精品中文字幕一区二区三区| 蜜桃视频一区二区三区| 国产在线不卡视频| 久久久久久久久99精品| 91久久线看在观草草青青| 久久精品国产99国产精品| 国产大陆精品国产| 国产精品99久久久久久有的能看| 99视频在线精品| jizz一区二区| 欧美精品乱码久久久久久| 色婷婷亚洲一区二区三区| 欧美久久久久久久久久| 久久免费国产精品| 一区2区3区在线看| 亚洲精选一二三| 日本aⅴ免费视频一区二区三区| 视频一区二区三区在线| 国产成人午夜高潮毛片| 欧美视频一区二区三区在线观看| 欧美无砖专区一中文字| 2020国产精品久久精品美国| 亚洲精品va在线观看| 久久国产免费看| 91电影在线观看| 国产日韩欧美精品综合| 国产欧美一区二区精品性| 亚洲一区二区不卡免费| 91在线一区二区| 日韩欧美电影一二三| 久久伊人蜜桃av一区二区| 一区av在线播放| 成人一道本在线| 日韩视频一区二区| 亚洲图片一区二区| 成人综合在线视频| 日韩视频一区二区三区在线播放| 亚洲人成精品久久久久| 国产美女精品人人做人人爽| 69堂国产成人免费视频| 精品国产一区二区三区忘忧草| 久久一二三国产| 丝袜美腿亚洲一区| 欧美亚洲免费在线一区| 欧美激情资源网| 国产一区二区视频在线| 制服丝袜av成人在线看| 一区二区三区四区高清精品免费观看| 国产不卡高清在线观看视频| 日韩免费性生活视频播放| 午夜欧美大尺度福利影院在线看| 久久97超碰色| 日韩视频在线一区二区| 欧美日韩美女一区二区| 欧美一级久久久久久久大片| 亚洲综合视频网| 91日韩一区二区三区| 国产欧美视频在线观看| 极品少妇xxxx精品少妇偷拍 | 在线一区二区三区做爰视频网站| 国产亚洲精品福利| 亚洲一区在线观看免费| 成人av资源在线观看| 国产欧美精品在线观看| 国产成人精品www牛牛影视| www成人在线观看| 久久99精品久久久久久| 91精品国产91久久综合桃花| 五月天精品一区二区三区| 欧美日韩亚洲国产综合| 亚洲一区二区av电影| 欧美体内she精高潮| 亚洲一区二区三区四区五区中文| 91官网在线观看| 亚洲一区二区四区蜜桃| 欧美视频三区在线播放| 午夜久久久影院| 91精品久久久久久久91蜜桃| 丝袜美腿亚洲综合| 欧美一级久久久| 精品综合免费视频观看| 久久久久国产精品免费免费搜索| 国产福利视频一区二区三区| 国产拍揄自揄精品视频麻豆| 成人av小说网| 亚洲乱码国产乱码精品精小说| 91成人看片片| 日日夜夜一区二区| 精品国产免费视频| 成人性生交大片免费看视频在线| 国产精品久久久久久久久图文区| 麻豆一区二区三区| 欧美精品一区二区不卡 | 91精品国产综合久久国产大片| 日本欧洲一区二区| 日本韩国视频一区二区| 一个色在线综合| 日韩一区二区视频在线观看| 国产一区视频网站| 中文字幕在线不卡视频| 国产精品1区2区3区| 中文字幕在线免费不卡| 欧美三级视频在线播放| 紧缚捆绑精品一区二区| 中文字幕日韩一区二区| 精品视频免费在线| 国产老肥熟一区二区三区| 中文字幕一区二区三区在线不卡| 欧美主播一区二区三区| 久久99精品国产| 亚洲免费av网站| 日韩一卡二卡三卡国产欧美| 国产成人亚洲综合色影视| 亚洲精品欧美二区三区中文字幕| 51精品久久久久久久蜜臀| 高潮精品一区videoshd| 亚洲高清免费在线| 国产亚洲污的网站| 精品视频1区2区3区| 国产成人精品免费| 午夜伊人狠狠久久| 国产精品沙发午睡系列990531| 国产91精品在线观看| 性感美女极品91精品| 中文成人av在线| 欧美一三区三区四区免费在线看| 成人天堂资源www在线| 日韩成人伦理电影在线观看| 国产精品人妖ts系列视频| 正在播放亚洲一区| 99精品偷自拍| 国产一区二区不卡| 亚洲 欧美综合在线网络| 中文幕一区二区三区久久蜜桃| 日韩亚洲欧美一区| 欧美视频日韩视频| 成人av在线影院| 极品销魂美女一区二区三区| 香蕉成人啪国产精品视频综合网| 欧美国产一区视频在线观看| 日韩三级电影网址| 精品视频在线看| 99久久综合狠狠综合久久| 经典一区二区三区| 日韩成人免费在线| 亚洲一区二区三区四区在线免费观看 | 欧美午夜不卡视频| a级高清视频欧美日韩| 久久99热狠狠色一区二区| 亚洲成va人在线观看| 亚洲人xxxx| 中文字幕一区二区三区四区| 久久久精品免费网站| 精品国产123| 日韩女优av电影| 欧美一级视频精品观看| 欧美三级欧美一级| 在线观看视频一区| 色综合色综合色综合| 成人福利视频网站| 国产成人av网站| 国产中文字幕精品| 久久99久久99精品免视看婷婷| 午夜精品成人在线| 亚洲成人免费视频| 国产精品美女久久久久久久久| 欧美一级夜夜爽| 欧美日本在线播放| 欧美日韩三级一区|