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

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

?? tfs.c

?? 可移到ucos上的文件系統(tǒng)
?? C
?? 第 1 頁(yè) / 共 4 頁(yè)
字號(hào):
			if (retval == TFS_OKAY)
				retval = flag;
			break;
		case TFS_FBTOA:
			retval = (long)tfsflagsbtoa(arg1,(char *)arg2);
			if (retval == 0)
				retval = TFSERR_BADARG;
			break;
		case TFS_TELL:
			retval = tfstell(arg1);
			break;
		case TFS_TIMEFUNCS:
			tfsGetLtime = (long(*)(void))arg1;
			tfsGetAtime = (char *(*)(long,char *,int))arg2;
			retval = TFS_OKAY;
			break;
		case TFS_DOCOMMAND:
			if (arg2)
				*(long *)arg2 = (long)tfsDocommand;
			if (arg1)
				tfsDocommand = (void(*)(char *,int))arg1;
			else
				tfsDocommand = docommand;
			retval = TFS_OKAY;
			break;
		default:
			retval = TFSERR_BADARG;
			break;
	}
	return(retval);
}

/* tfsadd():
 *	Add a file to the current list.
 *	If the file already exists AND everything is identical between the
 *	old and the new (flags, info and data), then return and do nothing;
 *	else remove the old file prior to adding the new one.
 *
 *	Note:
 *	At the point when tfsadd is called for a file that currently exists,
 *	the old file must be removed and a new one is put in its place.  This
 *	opens up the possibility of losing the file if a power-hit or reset was
 *	to occur between the point at which the old file was removed and the new
 *	one was put in its place.  To overcome this problem, TFS files have a
 *	flag called TFS_NSTALE.  It is a bit that is normally 1, but cleared
 *	if it becomes stale (hence the name TFS_NSTALE).  A file is
 *	in this mode only for a short time... the time it takes to write the
 *	new file that replaces the file that was made stale.
 *	Now, if a reset occurs after the file is stale, depending on 
 *	whether or not the new file was written, it will either be removed or
 *	used to recreate the original file because the write of the new file
 *	was chopped off by the power hit.  Refer to the function tfsstalecheck()
 *	for details on the recovery after a reset or powerhit.
 *	MONLIB NOTICE: this function is accessible through monlib.c.
 */
int
tfsadd(char *name, char *info, char *flags, uchar *src, int size)
{
	TDEV	*tdp;
	TFILE	*fp, tf;
	ulong	endoftfsflash, nextfileaddr, state_table_overhead;
	int		ftot, cleanupcount, err, stale, ssize;

	if (tfsTrace > 0)
		printf("tfsadd(%s,%s,%s,0x%lx,%d)\n", name,info,flags,(ulong)src,size);

	if ((size <= 0) || (!name))
		return(TFSERR_BADARG);

	if ((strlen(name) > TFSNAMESIZE) ||
		((info) && (strlen(info) > TFSINFOSIZE)))
		return(TFSERR_NAMETOOBIG);

	/* If the file is currently opened, then don't allow the add... */
	if (tfsFileIsOpened(name))
		return(TFSERR_FILEINUSE);

	stale = 0;
	cleanupcount = 0;

	/* Establish the device that is to be used for the incoming file
	 * addition request...  The device used depends on the prefix of
	 * the incoming file name.  If the incoming prefix doesn't match
	 * any of the devices in the table, then place the file in the
	 * first device in the table (assumed to be the default).
	 */
	for(tdp=tfsDeviceTbl;tdp->start != TFSEOT;tdp++) {
		if (!strncmp(name,tdp->prefix,strlen(tdp->prefix)))
			break;
	}
	if (tdp->start == TFSEOT)
		tdp = tfsDeviceTbl;

tryagain:
	fp = (TFILE *)tdp->start;

	/* Find end of current storage: */
	ftot = 0;
	while (fp) {
		if (fp->hdrsize == ERASED16)
			break;
		if (TFS_FILEEXISTS(fp)) {
			ftot++;
			if (fp->flags & TFS_NSTALE) {
				if (!strcmp(TFS_NAME(fp),name)) {
					/* If file of the same name exists AND it is identical to
					 * the new file to be added, then return TFS_OKAY and be
					 * done; otherwise, remove the old one and continue.
					 */
					if (!tfscompare(fp,name,info,flags,src,size))
						return(TFS_OKAY);
					
					/* If a file of the same name exists but is different than
					 * the new file, make the current file stale, then after 
					 * the new file is added we will delete the stale one.
					 */
					stale = 1;
					err = tfsmakeStale(fp);
					if (err == TFS_OKAY)
						goto tryagain;
					else
						return(err);
				}
			}
		}
		fp = nextfp(fp,tdp);
	}
	if (!fp)	/* If fp is 0, then nextfp() (above) detected corruption. */
		return(TFSERR_CORRUPT);

	/* Calculate location of next file (on mod16 address).  This will be 
	 * initially used to see if we have enough space left in flash to store
	 * the current request; then, if yes, it will become part of the new
	 * file's header.
	 */
	nextfileaddr = ((ulong)(fp+1)) + size;
	if (nextfileaddr & 0xf)
		nextfileaddr = (nextfileaddr | 0xf) + 1;
	
	/* Make sure that the space is available for writing to flash...
	 * Remember that the end of useable flash space must take into
	 * account the fact that some space must be left over for the
	 * defragmentation state tables.  Also, the total space needed for
	 * state tables cannot exceed the size of the sector that will contain
	 * those tables.  
	 */
	state_table_overhead = ((ftot+1) * sizeof(struct defraghdr)) +
		(tdp->sectorcount * sizeof(long));

	if (addrtosector((uchar *)(tdp->end),0,&ssize,0) < 0)
		return(TFSERR_MEMFAIL);

	if (state_table_overhead >= (ulong)ssize)
		return(TFSERR_FLASHFULL);

	endoftfsflash = (tdp->end + 1) - state_table_overhead;

	if ((nextfileaddr >= endoftfsflash) ||
		(!tfsSpaceErased((uchar *)fp,size+TFSHDRSIZ))) {
		if (!cleanupcount) {
			err = tfsautoclean(0,0,0,0,tdp,0,0);
			if (err != TFS_OKAY) {
				printf("tfsadd autoclean failed: %s\n",
					(char *)tfsctrl(TFS_ERRMSG,err,0));
				return(err);
			}
			cleanupcount++;
			goto tryagain;
		}
		else
			return(TFSERR_FLASHFULL);
	}

	memset((char *)&tf,0,TFSHDRSIZ);

	/* Copy name and info data to header. */
	strcpy(tf.name, name);
	if (info)
		strcpy(tf.info, info);
	tf.hdrsize = TFSHDRSIZ;
	tf.hdrvrsn = TFSHDRVERSION;
	tf.filsize = size;
	if ((flags == (char *)0) || (*flags == 0))
		tf.flags = 0;
	else {
		err = tfsflagsatob(flags,&tf.flags);
		if (err != TFS_OKAY)
			return(err);
	}
	tf.flags |= (TFS_ACTIVE | TFS_NSTALE);
	if (!(tf.flags & TFS_IPMOD))
		tf.filcrc = crc32(src, size);
	else
		tf.filcrc = ERASED32;

	tf.modtime = tfsGetLtime();
	tf.next = 0;
	tf.hdrcrc = 0;
	tf.hdrcrc = crc32((uchar *)&tf,TFSHDRSIZ);
	tf.next = (TFILE *)nextfileaddr;

	/* Now copy the file and header to flash.
	 * Note1: the header is copied AFTER the file has been
	 * successfully copied.  If the header was written successfully,
	 * then the data write failed, the header would be incorrectly
	 * pointing to an invalid file. To avoid this, simply write the
	 * data first.
	 * Note2: if the file is in-place-modifiable, then there is no
	 * file data to be written to the flash.  It will be left as all FFs
	 * so that the flash can be modified by tfsipmod() later.
	 */

	/* Write the file to flash if not TFS_IPMOD: */
	if (!(tf.flags & TFS_IPMOD)) {
		if (tfsflashwrite((ulong *)(fp+1),(ulong *)src,size) == -1)
			return(TFSERR_FLASHFAILURE);
	}

	/* Write the file header to flash: */
	if (tfsflashwrite((ulong *)fp,(ulong *)(&tf),TFSHDRSIZ) == -1)
		return(TFSERR_FLASHFAILURE);

	/* Double check the CRC now that it is in flash. */
	if (!(tf.flags & TFS_IPMOD)) {
		if (crc32((uchar *)(fp+1), size) != tf.filcrc)
			return(TFSERR_BADCRC);
	}

	/* If the add was a file that previously existed, then the stale flag
	 * will be set and the old file needs to be deleted...
	 */
	if (stale) {
		err = _tfsunlink(name);
		if (err != TFS_OKAY)
			printf("%s: %s\n",name,tfserrmsg(err));
	}

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

/* tfsunlink():
 *	Delete a file from the current list of files. Note that there
 *	is no attempt to de-fragment the flash; it simply nulls out the flags
 *	field of the file.  If successful return 0; else return error number.
 *	MONLIB NOTICE: this function is accessible through monlib.c.
 */
int
tfsunlink(char *name)
{
	if (tfsTrace > 0)
		printf("tfsunlink(%s)\n",name);

	/* If the file is currently opened, then don't allow the deletion... */
	if (tfsFileIsOpened(name))
		return(TFSERR_FILEINUSE);
	return(_tfsunlink(name));
}

int
_tfsunlink(char *name)
{
	TFILE *fp;
	ulong flags_marked_deleted;

	if (tfsTrace > 0)
		printf("_tfsunlink(%s)\n",name);

	fp = tfsstat(name);
	if (!fp)
		return(TFSERR_NOFILE);

	if (TFS_USRLVL(fp) > getUsrLvl())
		return(TFSERR_USERDENIED);

	flags_marked_deleted = fp->flags & ~TFS_ACTIVE;
	if (tfsflashwrite(&fp->flags,&flags_marked_deleted,sizeof(long)) < 0)
		return(TFSERR_FLASHFAILURE);

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

/* tfsrun():
 *	Run the named file.  Based on the file flags, the file is either
 *	executed as a COFF/ELF file with all relocation data in the file
 *	or run as a simple script of monitor commands.
 *	MONLIB NOTICE: this function is accessible through monlib.c.
 */

int
tfsrun(char **arglist,int verbose)
{
	int		i;
	TFILE	*fp;
	char	namebak[TFSNAMESIZE+8], *name;

	name = arglist[0];
	fp = tfsstat(name);
	if (!fp)
		return(TFSERR_NOFILE);

	if (TFS_USRLVL(fp) > getUsrLvl())
		return(TFSERR_USERDENIED);

	/* Store away the argument list so that it is accessible by the script
	 * or executable application about to be run:
	 */
	for(i=0;arglist[i];i++)
		putargv(i,arglist[i]);
	putargv(i,(char *)0);

	/* If the incoming named file doesn't exist, and that incoming name is
	 * the TFS_RCFILE string, then try TFS_RCFILE.bak as an alternative.
	 * This allows the user to copy TFS_RCFILE to TFS_RCFILE.bak, then
	 * delete/reload TFS_RCFILE.  Note that usually TFS_RCFILE is "monrc".
	 */
	if (!fp) {
		if (!strcmp(name,TFS_RCFILE)) {
			sprintf(namebak,"%s.bak",TFS_RCFILE);
			fp = tfsstat(namebak);
			if (!fp)
				return(TFSERR_NOFILE);
			name = namebak;
			printf("Running %s...\n",namebak);
		}
		else
			return (TFSERR_NOFILE);
	}

	/* Executable file can be script or binary... */
	if (!(fp->flags & (TFS_EXEC|TFS_EBIN)))
		return(TFSERR_NOTEXEC);

	if (!(fp->flags & TFS_IPMOD)) {
		if (crc32(TFS_BASE(fp), fp->filsize) != fp->filcrc)
			return(TFSERR_BADCRC);
	}
	/* Machine code or script... */
	if (fp->flags & TFS_EBIN)
		return(tfsexec(fp,verbose));
	else
		return(tfsscript(fp,verbose));
}

/* tfsnext():
 *	Called to retrieve the "next" file in the tfs list.  If
 *	incoming argument is NULL then return the first file in the list.  If no
 *	more files, return NULL; else return the tfshdr structure pointer to the
 *	next (or first) file in the tfs.
 *	MONLIB NOTICE: this function is accessible through monlib.c.
 */
TFILE *
tfsnext(TFILE *fp)
{
	TDEV	*tdp;
	TFILE *fpnext;

	if (!fp) {
		tdp = tfsDeviceTbl;
		fpnext = (TFILE *) tfsDeviceTbl[0].start;
	}
	else {
		tdp = gettfsdev(fp);
		fpnext = nextfp(fp,0);
	}

	while(tdp->start != TFSEOT) {
		while(validtfshdr(fpnext)) {
			if (TFS_FILEEXISTS(fpnext))
				return (fpnext);
			fpnext = nextfp(fpnext,0);
		}
		tdp++;
		fpnext = (TFILE *)tdp->start;
	}
	return ((TFILE *) 0);
}

/* tfsstat():
 *	Steps through the list of files until it finds the specified
 *	filename or reaches the end of the list.  If found, a pointer to that
 *	file's structure is returned; else return 0.
 *	MONLIB NOTICE: this function is accessible through monlib.c.
 */
TFILE *
tfsstat(char *name)
{
	TDEV	*tdp;
	TFILE	*fp;

	if (tfsTrace > 0)
		printf("tfsstat(%s)\n",name);

	for(tdp=tfsDeviceTbl;tdp->start != TFSEOT;tdp++) {
		fp = (TFILE *) tdp->start;
		while(validtfshdr(fp)) {
			if (TFS_FILEEXISTS(fp) && (strcmp(name, fp->name) == 0))
				return(fp);
			fp = nextfp(fp,tdp);
		}
	}
	return ((TFILE *) 0);
}

/* tfsfstat():
 * Very similar in purpose to tfsstat().  This version is provided to the 
 * API as a "defrag-safe" version of tfsstat()...
 * If tfsstat() is called (returning a pointer into TFS memory space), then
 * a defragmentation occurs, that pointer is stale; hence, the need for 
 * an alternative that will load the content of the TFILE structure into
 * an application-supplied block of memory (usually a pointer to a local
 * TFILE structure).  Using tfsfstat avoids this because if a defrag occurs,
 * it does not affect the content of the locally stored TFILE structure.
 * NOTE:
 * addition of this function to the TFS API was due to the fact that
 * I did not consider the above described condition when first adding
 * tfsstat() to the TFS API.  In general, tfsfstat() should be considered
 * a replacement for all tfsstat() situations that will dereference the
 * pointer.
 * NOTE1:
 * The return value is similar to standard "stat"... Return 0 if
 * successful, else -1.
 */
int
tfsfstat(char *name, TFILE *apptfp)
{
	TFILE	*tfp;
	int		otrace;

	otrace = tfsTrace;

	if (tfsTrace > 0) {
		tfsTrace = 0;
		printf("tfsfstat(%s)\n",name);
	}

	tfp = tfsstat(name);
	tfsTrace = otrace;
	
	if (!tfp)
		return(-1);
	*apptfp = *tfp;
	return(0);
}

int
showTfsError(int errno, char *msg)
{
	if (msg)
		printf("%s: %s\n",msg,tfserrmsg(errno));
	else
		printf("%s\n",tfserrmsg(errno));
	return(errno);
}

void
exitscript(char *ignored)
{
	ScriptExitFlag = EXIT_SCRIPT;
}

char *ExitHelp[] = {
	"Exit a script",
	"-[r]",
	"Options:",
	" -r   remove script after exit",
	0,
};

int
Exit(int argc, char *argv[])
{
	ScriptExitFlag = EXIT_SCRIPT;
	if ((argc == 2) && (!strcmp(argv[1],"-r")))
		ScriptExitFlag |= REMOVE_SCRIPT;
	return(0);
}

#else	/* INCLUDE_TFS */

char *
tfserrmsg(int errno)
{
	return(0);
}
int
tfsinit(void)
{
	return(TFSERR_NOTAVAILABLE);
}

int
tfsfstat(char *name, TFILE *apptfp)
{
	return(TFSERR_NOTAVAILABLE);
}

TFILE *
tfsstat(char *name)
{
	return ((TFILE *) 0);
}

TFILE *
tfsnext(TFILE *fp)
{
	return ((TFILE *) 0);
}

int
tfsrun(char **arglist,int verbose)
{
	return(TFSERR_NOTAVAILABLE);
}

int
tfsunlink(char *name)
{
	return(TFSERR_NOTAVAILABLE);
}

int
tfsadd(char *name, char *info, char *flags, uchar *src, int size)
{
	return(TFSERR_NOTAVAILABLE);
}

long
tfsctrl(int rqst,long arg1,long arg2)
{
	return(TFSERR_NOTAVAILABLE);
}

#endif	/* INCLUDE_TFS else */

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人黄色777网| 成人美女视频在线看| 国产亚洲欧美一级| 在线亚洲一区观看| 国产老女人精品毛片久久| 亚洲国产欧美一区二区三区丁香婷| 欧美成人a视频| 精品视频一区三区九区| 粉嫩高潮美女一区二区三区| 日本网站在线观看一区二区三区 | 蜜桃一区二区三区在线观看| 国产精品欧美精品| 精品国产1区二区| 欧美日韩亚洲丝袜制服| 91丨九色丨蝌蚪丨老版| 国产伦精品一区二区三区免费迷 | 亚洲免费在线视频| 久久久亚洲精华液精华液精华液| 欧美二区三区的天堂| 99精品国产热久久91蜜凸| 国产成人综合在线播放| 久久国产视频网| 日韩电影在线免费观看| 一区二区三区不卡视频在线观看| 国产精品欧美综合在线| 欧美mv日韩mv国产网站app| 欧美日韩国产片| 91成人免费在线| 91老司机福利 在线| 99综合电影在线视频| 国产成人精品aa毛片| 国产乱码精品一区二区三区忘忧草 | 国产乱码精品一区二区三区五月婷| 奇米亚洲午夜久久精品| 天堂蜜桃一区二区三区| 亚洲第一主播视频| 香蕉久久一区二区不卡无毒影院| 亚洲综合免费观看高清完整版在线| 国产精品日日摸夜夜摸av| 中文字幕精品在线不卡| 国产视频视频一区| 中文字幕巨乱亚洲| 国产欧美日韩激情| 国产精品免费av| 亚洲欧美在线aaa| 亚洲色图在线播放| 艳妇臀荡乳欲伦亚洲一区| 悠悠色在线精品| 亚洲国产综合色| 一区二区三区免费看视频| 亚洲免费观看高清| 亚洲激情男女视频| 亚洲图片欧美一区| 国产乱子轮精品视频| 国产福利电影一区二区三区| 粉嫩高潮美女一区二区三区| 99久久国产免费看| 欧美图区在线视频| 欧美日韩色综合| 日韩视频免费观看高清在线视频| 精品少妇一区二区三区| 亚洲国产精品成人综合色在线婷婷| 日本一二三不卡| 亚洲精品视频免费看| 亚洲尤物视频在线| 日韩黄色免费电影| 国产麻豆精品久久一二三| 91在线视频18| 欧美理论在线播放| 精品国产免费人成电影在线观看四季| 国产亚洲欧美一级| 一二三区精品视频| 久久成人av少妇免费| 成人性色生活片| 欧美日韩一区二区在线观看| 精品久久免费看| 亚洲天堂成人网| 免费在线欧美视频| 成人国产免费视频| 欧美乱熟臀69xxxxxx| 久久久久久久久97黄色工厂| 1024精品合集| 久久精品99久久久| 99国产精品久久久久久久久久久| 欧美美女网站色| 国产调教视频一区| 午夜精品免费在线| 成人免费毛片高清视频| 欧美日本国产一区| 国产精品少妇自拍| 欧美aaaaa成人免费观看视频| 成人免费视频国产在线观看| 欧美日韩国产大片| 国产精品无人区| www.在线欧美| 7777精品伊人久久久大香线蕉超级流畅 | 中文字幕欧美一| 日本免费新一区视频| 97成人超碰视| 精品91自产拍在线观看一区| 亚洲综合av网| 成人中文字幕在线| 欧美mv日韩mv国产网站| 亚洲123区在线观看| 大白屁股一区二区视频| 欧美一区二区在线免费播放| ㊣最新国产の精品bt伙计久久| 精品一区二区三区久久久| 欧美私模裸体表演在线观看| 国产精品久久久久久久久动漫 | 中文字幕一区在线| 国内精品免费**视频| 欧美日韩亚洲丝袜制服| 国产精品久久久久一区| 国产一区欧美一区| 欧美一区二区三区男人的天堂| 一区二区三区中文字幕精品精品| 国产成人免费网站| 精品成人私密视频| 久久国产麻豆精品| 欧美一个色资源| 亚洲成人动漫精品| 91国偷自产一区二区开放时间 | 亚洲图片你懂的| 国产·精品毛片| 欧美精品一区二区三区蜜桃 | 狠狠色综合日日| 欧美一级国产精品| 高清在线成人网| 久久久高清一区二区三区| 麻豆免费精品视频| 日韩一区二区免费在线观看| 视频一区在线视频| 欧美巨大另类极品videosbest| 亚洲国产aⅴ成人精品无吗| 色婷婷国产精品综合在线观看| 国产精品国产三级国产有无不卡| 国产精品77777| 欧美激情资源网| 懂色av一区二区夜夜嗨| 国产精品美女久久久久久2018| 成人午夜电影小说| **性色生活片久久毛片| 91首页免费视频| 一级精品视频在线观看宜春院| 91在线观看美女| 亚洲综合视频网| 欧美日韩国产高清一区二区| 奇米综合一区二区三区精品视频| 日韩精品中文字幕一区二区三区| 久久66热偷产精品| 国产日韩欧美亚洲| www.欧美日韩国产在线| 一区二区三区在线观看国产| 欧美日韩亚洲综合一区| 日本美女一区二区三区| www激情久久| 9i在线看片成人免费| 亚洲永久免费av| 欧美一区二区高清| 国产精品自拍av| ...av二区三区久久精品| 欧美亚洲综合另类| 青青草一区二区三区| 久久精品欧美一区二区三区不卡 | 午夜av电影一区| 欧美va日韩va| av影院午夜一区| 亚洲成在线观看| 久久影院午夜论| 91欧美一区二区| 日本亚洲视频在线| 国产欧美一区二区三区在线看蜜臀| 97久久精品人人做人人爽| 亚洲va韩国va欧美va精品| 日韩免费视频线观看| 成人av免费在线观看| 亚洲 欧美综合在线网络| 久久久美女毛片| 一本一本大道香蕉久在线精品| 成人h动漫精品一区二区| 亚洲超丰满肉感bbw| 精品国产乱码久久久久久1区2区 | 欧美mv日韩mv国产网站app| 日av在线不卡| 日韩一区二区麻豆国产| 国产福利一区二区三区视频在线| 国产精品毛片无遮挡高清| 欧美日韩小视频| www.av精品| 蜜桃一区二区三区在线| 最新日韩av在线| 久久五月婷婷丁香社区| 欧洲另类一二三四区| 激情偷乱视频一区二区三区| 亚洲精品国产成人久久av盗摄| 精品国产伦一区二区三区免费| 欧美性猛片aaaaaaa做受| 国产成人自拍网| 美女网站在线免费欧美精品|