Пример #1
2
int cp_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	FF_IOMAN *pIoman = pEnv->pIoman;
	FF_FILE *fSource, *fDest;
	FF_ERROR Error;

	FF_T_INT8 path[FF_MAX_PATH];
	FF_T_UINT8 copybuf[COPY_BUFFER_SIZE];

	FF_T_SINT32	BytesRead;

	//LARGE_INTEGER ticksPerSecond;
	//LARGE_INTEGER start_ticks, end_ticks, cputime;
	float transferRate = 0;

	//QueryPerformanceFrequency(&ticksPerSecond);
	
	if(argc == 3) {
		if(strstr(argv[1], "*") || strstr(argv[2], "*")) {
			return wildcopy(argc, argv, pEnv);
		}
		ProcessPath(path, argv[1], pEnv);

		fSource = FF_Open(pIoman, path, FF_MODE_READ, &Error);

		if(fSource) {
			ProcessPath(path, argv[2], pEnv);

			fDest = FF_Open(pIoman, path, FF_GetModeBits("w"), &Error);
			if(fDest) {
				// Do the copy
				//QueryPerformanceCounter(&start_ticks);   
				//QueryPerformanceCounter(&end_ticks);   
				do{
					BytesRead = FF_Read(fSource, COPY_BUFFER_SIZE, 1, (FF_T_UINT8 *)copybuf);
					FF_Write(fDest, BytesRead, 1, (FF_T_UINT8 *) copybuf);
					//QueryPerformanceCounter(&end_ticks); 
					//cputime.QuadPart = end_ticks.QuadPart - start_ticks.QuadPart;
					//time = ((float)cputime.QuadPart/(float)ticksPerSecond.QuadPart);
					//transferRate = (fSource->FilePointer / time) / 1024;
					//cons_printf("%f% - %10ld Bytes Copied, %f Kb/S\r", ((float)((float)fSource->FilePointer/(float)fSource->Filesize) * 100), fSource->FilePointer, transferRate);
				}while(BytesRead > 0);
				//cons_printf("%f% - %10ld Bytes Copied, %f Kb/S\n", ((float)((float)fSource->FilePointer/(float)fSource->Filesize) * 100), fSource->FilePointer, transferRate);		

				FF_Close(fSource);
				FF_Close(fDest);
			} else {
				FF_Close(fSource);
				cons_printf("Could not open destination file - %s\n", FF_GetErrMessage(Error));
			}

		} else {
			cons_printf("Could not open source file - %s\n", FF_GetErrMessage(Error));
		}
		
	} else {
		cons_printf("Usage: %s [source file] [destination file]\n", argv[0]);
	}
	return 0;
}
Пример #2
0
/**
 *	@public
 *	@brief	Changes the Current Working Directory
 *
 *	To change the directory, we simply check the provided path, if it exists,
 *	then we change the environment's working directory to that path.
 *
 **/
int cd_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	FF_IOMAN *pIoman = pEnv->pIoman;
	FF_T_INT8	path[FF_MAX_PATH];

	int i;

	if(argc == 2) {
		ProcessPath(path, argv[1], pEnv);	// Make path absolute if relative.

		ExpandPath(path);	// Remove any relativity from the path (../ or ..\).
		
		if(FF_FindDir(pIoman, path, (FF_T_UINT16) strlen(path))) {	// Check if path is valid.
			i = strlen(path) - 1;	// Path found, change the directory.

			if(i) {
				if(path[i] == '\\' || path[i] == '/') {
					path[i] = '\0';
				}
			}
			strcpy(pEnv->WorkingDir, path);
			//sprintf(pEnv->WorkingDir, path);
		} else {
			cons_printf("Path \"%s\" not found.\n", path);
		}
	} else {
		cons_printf("Usage: %s [path]\n", argv[0]);
	}
	return 0;
}
Пример #3
0
int debug_register_list()
{
	int i;
	for(i=0; roff[i].reg!=0; i++) 
		cons_printf("%s ", roff[i].reg);
	cons_printf("\n");
}
Пример #4
0
/*
	This isn't a command, but rather a simple copy function designed to aid
	wildCard copying.
*/
int filecopy(const char *src, const char *dest, FF_ENVIRONMENT *pEnv) {
	
	FF_IOMAN *pIoman = pEnv->pIoman;
	FF_ERROR Error;

	FF_FILE *fSource, *fDest;

	FF_T_UINT8 copybuf[COPY_BUFFER_SIZE];

	FF_T_SINT32	BytesRead;

	//LARGE_INTEGER ticksPerSecond;
	//LARGE_INTEGER start_ticks, end_ticks, cputime, ostart, oend;
	float transferRate = 0;
	//int ticks;

	//QueryPerformanceFrequency(&ticksPerSecond);
	
	//QueryPerformanceCounter(&ostart); 
	fSource = FF_Open(pIoman, src, FF_MODE_READ, &Error);
	//QueryPerformanceCounter(&oend);
	//ticks = (int) (oend.QuadPart - ostart.QuadPart);
	//cons_printf("Source: Open took %d\n", ticks);
	if(fSource) {
		//QueryPerformanceCounter(&ostart);
		fDest = FF_Open(pIoman, dest, FF_GetModeBits("w"), &Error);
		//QueryPerformanceCounter(&oend);
		//ticks = (int) (oend.QuadPart - ostart.QuadPart);
		//cons_printf("Dest: Open took %d\n", ticks);
		if(fDest) {
			// Do the copy
			//QueryPerformanceCounter(&start_ticks);  
			do{
				BytesRead = FF_Read(fSource, COPY_BUFFER_SIZE, 1, (FF_T_UINT8 *)copybuf);
				FF_Write(fDest, BytesRead, 1, (FF_T_UINT8 *) copybuf);
				//QueryPerformanceCounter(&end_ticks); 
				//cputime.QuadPart = end_ticks.QuadPart - start_ticks.QuadPart;
				//time = ((float)cputime.QuadPart/(float)ticksPerSecond.QuadPart);
				//transferRate = (fSource->FilePointer / time) / 1024;
				cons_printf("%3.0f%% - %10ld Bytes Copied, %7.2f Kb/S\r", ((float)((float)fSource->FilePointer/(float)fSource->Filesize) * 100), fSource->FilePointer, transferRate);
			}while(BytesRead > 0);
			cons_printf("%3.0f%% - %10ld Bytes Copied, %7.2f Kb/S\n", ((float)((float)fSource->FilePointer/(float)fSource->Filesize) * 100), fSource->FilePointer, transferRate);		

			FF_Close(fSource);
			FF_Close(fDest);
		} else {
			FF_Close(fSource);
			cons_printf("Could not open destination file - %s\n", FF_GetErrMessage(Error));
		}

	} else {
		if(Error == FF_ERR_FILE_OBJECT_IS_A_DIR) {
			return FF_ERR_FILE_OBJECT_IS_A_DIR;
		}
		cons_printf("Could not open source file - %s\n", FF_GetErrMessage(Error));
	}
	return 0;
}
Пример #5
0
/**
 *	@brief	Prints the current working directory.
 *
 *	@param	argc	The number of argument strings provided on the command line.
 *	@param	argc	An array of pointers, pointing to strings representing the command line arguments.
 *	@param	pEnv	Pointer to an FF_ENVIRONMENT object.
 *
 **/
int pwd_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	if(argc == 1) {
		cons_printf("Current directory:\n");							// Simply print WorkingDir from pEnv object.
		cons_printf("%s\n", pEnv->WorkingDir);
	} else {
		cons_printf("Usage: %s\n", argv[0]);							// argv[0] is always the name of the command.
	}
	return 0;	
}
void ShowQ(q_t *p)
{
   int i;

   for(i = 0; i < p->count; i++)
      cons_printf( "%d ", p->q[ ( p->head + i) % Q_SIZE ] ) ;

   cons_printf("\n"); 
}
Пример #7
0
/**
 *	@public
 *	@brief	A Special Command Prompt command for FFTerm
 *
 *	FFTerm allows dynamically generated command prompts when a command named
 *	"prompt" is hooked. This is that command, allowing the prompt to include the
 *	the current working directory.
 *
 *	@param	argc	The number of argument strings provided on the command line.
 *	@param	argc	An array of pointers, pointing to strings representing the command line arguments.
 *	@param	pEnv	Pointer to an FF_ENVIRONMENT object.
 *
 **/
int cmd_prompt(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	if(argc) {
		cons_printf("This is the command prompt application. \nIt cannot be executed directly from the command line.\n");
		cons_printf("For more information about FullFAT or the FFTerm software, see:\nwww.worm.me.uk/fullfat/\n");
	} else {
		cons_printf("FullFAT%s>", pEnv->WorkingDir);
	}
	if(argv) {

	}
	return 0;
}
void ShowStatusISR()
{
   int i;
   int j = avail_q.head;
   char *state_names[] = {"AVAIL\0", "READY\0", "RUN\0", "SLEEP\0", "WAIT\0"};
	
	cons_printf("\n");
   for(i=0; i<NUM_PROC; i++)
   {
      cons_printf("pid %i, state %s, tick_count %i, total_tick_count %i \n",
             i, 
             state_names[pcbs[i].state],
             pcbs[i].tick_count,
             pcbs[i].total_tick_count);
   }
	//Added to show pid of each queue. (Jeff)
	
	cons_printf("Available Queue: ");
	for(i=0; i<avail_q.count; i++)
		cons_printf("%i ", avail_q.q[(j++)%Q_SIZE]);
	cons_printf("\n");

	j=ready_q.head;
	cons_printf("Ready Queue: ");
	for(i=0; i<ready_q.count; i++)
		cons_printf("%i ", ready_q.q[(j++)%Q_SIZE]);
	cons_printf("\n");

}
Пример #9
0
/*
	A View command to type out the contents of a file using FullFAT.
*/
int rm_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	
	FF_ERROR	Error;
	FF_DIRENT	mydir;	// Used to detect if its a file or folder.
	FF_T_INT8	path[FF_MAX_PATH];
	FF_T_INT8	realpath[FF_MAX_PATH];
	FF_T_INT8	*pName;
	int i;

	if(argc == 2) {

		ProcessPath(path, argv[1], pEnv);

		for(i = strlen(path); ; i--) {
			if(path[i] == '\\' || path[i] == '/') {
				pName = &path[i + 1];
				break;
			}
		}

		memcpy(realpath, path, i + 1);
		realpath[i+1] = '\0';

		Error = FF_FindFirst(pEnv->pIoman, &mydir, realpath);

		while(!FF_strmatch(mydir.FileName, pName, 0)) {
			Error = FF_FindNext(pEnv->pIoman, &mydir);
			if(Error) {	// File
				cons_printf("File or Folder not found!\n");
				return 0;
			}
		}

		if(mydir.Attrib & FF_FAT_ATTR_DIR) {
			Error = FF_RmDir(pEnv->pIoman, path);
		} else {
			Error = FF_RmFile(pEnv->pIoman, path);
		}

		if(Error) {
			cons_printf("Could not remove file or folder: %s\n", FF_GetErrMessage(Error));
		}


	} else {
		cons_printf("Usage: %s [filename]\n", argv[0]);
	}
	return 0;
}
Пример #10
0
void timer_init(void)
{
	cons_printf("Initialize timer ...............");
	/*
	 * FIXME: for now, just leave the default 18Hz periodic timer.
	 */
	irq_install_handler(TIMER_IRQ, &timer_int_handler);
	irq_enable(TIMER_IRQ);

	/* now that we have a timer interrupt handler installed, we can
	 * enable interrupt handling and preemption */
	int_enable();
	g_preemption = true;
	cons_printf(".... [OK]\n");
}
Пример #11
0
/**
 *	@brief	A simple command for making dirs.
 **/
int mkdir_cmd(int argc, char **argv, FF_ENVIRONMENT *pEv) {
	
	FF_T_INT8	path[FF_MAX_PATH];
	FF_ERROR	Error;

	if(argc == 2) {
		ProcessPath(path, argv[1], pEv);
		Error = FF_MkDir(pEv->pIoman, path);
		if(Error) {
			cons_printf("Could not mkdir - %s\n", FF_GetErrMessage(Error));
		}
	} else {
		cons_printf("Usage: %s [path]\n", argv[0]);
	}
	return 0;
}
Пример #12
0
////////////phase 4
void MsgSndISR(int msg_addr)
{
	int msg_q_id;
	int freed_pid;
	msg_t *incoming_msg_ptr, *dst_msg_ptr; 
	
	incoming_msg_ptr = (msg_t *) msg_addr; 
	msg_q_id = incoming_msg_ptr->recipient;
	incoming_msg_ptr->OS_clock = OS_clock;
	incoming_msg_ptr->sender = running_pid;

	if(msg_q[msg_q_id].wait_q.len == 0)
	{
		MsgEnQ(incoming_msg_ptr, &msg_q[msg_q_id]);
	}	
	else
	{
		freed_pid = DeQ(&(msg_q[msg_q_id].wait_q));
		EnQ(freed_pid, &ready_q);
		pcb[freed_pid].state = READY;
		dst_msg_ptr = (msg_t *) pcb[freed_pid].TF_ptr->eax;
		*dst_msg_ptr = *incoming_msg_ptr;
		cons_printf("MsgSndISR: FREEING process # %d !\n", freed_pid);
	}
			
}
Пример #13
0
void search_similar_pattern(int count)
{
	u8 *block = malloc (config.block_size);
	/* backup basic block */
	radare_read(0);
	memcpy (block, config.block, config.block_size);
	radare_controlc ();
	radare_read (1); // read next block
	while (!config.interrupted && config.seek<config.size) {
		int diff = memcmpdiff(config.block, block, config.block_size);
		int equal = config.block_size-diff;
// equal sera un numero petit quan diff sigui gran
// quan equal sigui gran diff sera petit
		if (equal >= count) { //count > equal) {
		//if (count > equal) {
			cons_printf("0x%08llx %d/%d\n", config.seek, equal, config.block_size);
			cons_flush();
			radare_read(1);
		} else {
			config.seek += 1; // skip diff bytes can be faster ??
			//config.seek += diff; // skip diff bytes can be faster ??
			int ret = radare_read(0);
			if (ret<config.block_size)break;
		}
	}
	radare_controlc_end ();
	free (block);
}
Пример #14
0
void
openttymonlog(void)
{
	int	fd, ret;
	char	logfile[MAXPATHLEN];
	extern	char	*Tag;

	/* the log file resides in /var/saf/pmtag/ */
	(void) snprintf(logfile, sizeof (logfile), "%s%s/%s", LOGDIR, Tag,
	    LOGFILE);

	Logfp = NULL;
	(void)close(0);
	if ((fd = open(logfile, O_WRONLY|O_CREAT|O_APPEND,0444)) != -1) 
		if ((ret = fcntl(fd, F_DUPFD, 3)) == 3) {
			/* set close-on-exec flag */
			if (fcntl(ret, F_SETFD, FD_CLOEXEC) == 0) {
				Logfp = fdopen(ret, "a+");
			}
		}
	if (!Logfp) {
		cons_printf("ttymon cannot create log file \"%s\": %s\n",
		    logfile, strerror(errno));
		exit(1);
	}
	log(" ");
	log("********** ttymon starting **********");

#ifdef	DEBUG
	log("fd(log)\t = %d", fileno(Logfp));
#endif
}
Пример #15
0
void PrintDriver(){
	int i, code;
	char *p;
	msg_t msg;
	msg.recipient = 2;

	printing_semaphore = SemGet(0);

	outportb(LPT1_BASE+LPT_CONTROL, PC_SLCTIN);
	code = inportb(LPT1_BASE+LPT_STATUS);
	for(i=0; i<50; i++)IO_DELAY();
	outportb(LPT1_BASE+LPT_CONTROL, PC_INIT|PC_SLCTIN|PC_IRQEN);
	Sleep(1);
	for(;;){
		MsgRcv(&msg);
		cons_printf("PrintDriver (PID %d) now prints...\n",GetPid());
		p = msg.data;
		
		while(*p){
			SemWait(printing_semaphore);
			outportb(LPT1_BASE+LPT_DATA, *p);
			code = inportb(LPT1_BASE+LPT_CONTROL);
			outportb(LPT1_BASE+LPT_CONTROL, code|PC_STROBE);
			for(i=0; i<50; i++)IO_DELAY();
			outportb(LPT1_BASE+LPT_CONTROL, code);
			
			p++;
		}
	}
}
Пример #16
0
void InitProc(){
	
	int i;
	msg_t msg;
	msg.recipient = 2;
	MyStrcpy(msg.data,"Hello World! Team Null\n"); 
	while(1){
		cons_printf("0 ");
		for(i=0; i<1666668; i++)IO_DELAY();
		if(cons_kbhit()){
			char key = cons_getchar();
			switch(key)
			{
				case('p'):
					MsgSnd(&msg);
					break;
				case('b'):
					breakpoint();
					break;
				case('x'):
					exit(0);
			}	
		}
	}
}
Пример #17
0
int debug_lib(const char *arg)
{
	if (arg[0]!=' ')
		cons_printf("Usage: !lib /path/to/lib.so\n");
	else debug_lib_load(arg+1);
	return 0;
}
Пример #18
0
/**
 *	@public
 *	@brief	A Standardised Dirent Print for FullFAT
 *
 *	Prints a Directory Entry, using a mix of styles found in Windows and Linux.
 *
 *	@param	pDirent		A pointer to an FF_DIRENT object as populated by the FF_FindFirst() or FF_FindNext() functions.
 **/
static void FF_PrintDir(FF_DIRENT *pDirent) {
	unsigned char attr[5] = { '-','-','-','-', '\0' };	// String of Attribute Flags.
	if(pDirent->Attrib & FF_FAT_ATTR_READONLY)
			attr[0] = 'R';
	if(pDirent->Attrib & FF_FAT_ATTR_HIDDEN)
			attr[1] = 'H';
	if(pDirent->Attrib & FF_FAT_ATTR_SYSTEM)
			attr[2] = 'S';
	if(pDirent->Attrib & FF_FAT_ATTR_DIR)
			attr[3] = 'D';
#ifdef FF_TIME_SUPPORT	// Different Print formats dependent on if Time support is built-in.
	cons_printf("%02d.%02d.%02d  %02d:%02d  %s  %12lu  %s\n", pDirent->CreateTime.Day, pDirent->CreateTime.Month, pDirent->CreateTime.Year, pDirent->CreateTime.Hour, pDirent->CreateTime.Minute, attr, pDirent->Filesize, pDirent->FileName);
#else
	cons_printf(" %s %12lu    %s\n", attr, pDirent->Filesize, pDirent->FileName);
#endif
}
Пример #19
0
void TimerISR() {
   	//just return if running PID is -1 (not any valid PID)
	
	if(running_pid == -1){
		cons_printf("PANIC MESSAGE: RUNNING PID = -1\n");
		return;
	
	}else{
		//in PCB, upcount both runtime and total_runtime of running process

		pcb[running_pid].runtime = pcb[running_pid].runtime+1;
		pcb[running_pid].total_runtime = pcb[running_pid].total_runtime+1;
	
		if(pcb[running_pid].runtime== TIME_LIMIT){ // If runtime has reached TIME_LIMIT
			// Reset runtime
			// Change the state to READY
			// queue to ready_q
			// Set pid to -1

			pcb[running_pid].runtime = 0;
			pcb[running_pid].state = READY;
			EnQ(running_pid, &ready_q);
			running_pid = -1;
			Scheduler();
		}	
	}
}
Пример #20
0
/**
 *	@brief	A simple command for Killing all test threads and exiting the console.
 *			This command sends the kill signal to FFTerm.
 **/
int exit_cmd(int argc, char **argv) {
	if(argc) {
		//KillAllThreads();
		return FFT_KILL_CONSOLE;
	}
	cons_printf("Error in the %s command\n", argv[0]);
	return -1;
}
void IdleProc() {
   int i;

   while(1) {
      cons_printf("0 ");
      for(i=0;i<166600;i++)IO_DELAY();
   }
}
Пример #22
0
/**
 *	@brief	A simple command for displaying the date.
 *			This command tests FullFAT time support is working.
 **/
int date_cmd(int argc, char **argv) {
#ifdef FF_TIME_SUPPORT
	FF_SYSTEMTIME Time;
#endif

	if(argc == 1) {
#ifdef FF_TIME_SUPPORT
		FF_GetSystemTime(&Time);
		cons_printf("The current date is: %02d.%02d.%02d\n\n", Time.Day, Time.Month, Time.Year);
#else
		cons_printf("Date Support not built. Rebuild FullFAT with FF_TIME_SUPPORT enabled.\n");
#endif

	} else {
		cons_printf("Usage: %s\n", argv[0]);
	}
	return 0;
}
Пример #23
0
/**
 *	@brief	A simple command for displaying the time.
 *			This command tests FullFAT time support is working.
 **/
int time_cmd(int argc, char **argv) {
#ifdef FF_TIME_SUPPORT
	FF_SYSTEMTIME Time;
#endif

	if(argc == 1) {
#ifdef FF_TIME_SUPPORT
		FF_GetSystemTime(&Time);
		cons_printf("The current time is: %02d:%02d:%02d\n\n", Time.Hour, Time.Minute, Time.Second);
#else
		cons_printf("Time Support not built. Rebuild FullFAT with FF_TIME_SUPPORT enabled.\n");
#endif

	} else {
		cons_printf("Usage: %s\n", argv[0]);
	}
	return 0;
}
Пример #24
0
int main (void)
{
	int i;

	i = 128;
	printf("%d Hello world %d \nECS", i, 2 * i);
	cons_printf("--> Hello world <--\nCPE/CSC");
	return 0;
}
Пример #25
0
void
openlog()
{
	if ((Lfp = fopen(LOGFILE, "a+")) == NULL) {
		cons_printf("SAC: could not open logfile %s: %s\n",
		    LOGFILE, strerror(errno));
		exit(1);
	}

	/*
	 * lock logfile to indicate presence
	 */
	if (lockf(fileno(Lfp), F_LOCK, 0) < 0) {
		cons_printf("SAC: could not lock logfile %s:%s\n",
		    LOGFILE, strerror(errno));
		exit(1);
	}
}
Пример #26
0
static int radare_tsearch_callback(struct _tokenizer *t, int i, ut64 where)
{
	char flag_name[128];
	ut64 off = config.seek;

	if (align != 0 && where%align != 0)
		return 1;

	if (search_count && nhit >= search_count)
		return 1;

	nhit++;
	radare_flag_name (flag_name, i, nhit);

	radare_seek(where, SEEK_SET);
	radare_read(0);
	if (search_flag)
		flag_set(flag_name, where, 0);

	if (search_cmdhit && search_cmdhit[0]!='\0') {
		char *cmdhit = strdup(search_cmdhit);
		radare_seek(where, SEEK_SET);
		setenv("KEYWORD", search_last_keyword, 1); // XXX this is not last-keyword!! must array this!
		radare_cmd(cmdhit, 0);
		free(cmdhit);
		radare_controlc();
	}

	if (search_verbose) {
		u8 *ptr = config.block; //+(where-config.seek)-3;
		cons_printf("%03d  0x%08llx  %s ", nhit, where, flag_name);
		for(i=0;i<20;i++) {
			if (is_printable(ptr[i]))
				cons_printf("%c", ptr[i]);
		}
		cons_printf("\n");
	} 
	//D { fprintf(stderr, "\r%d\n", nhit); fflush(stderr); }

	fflush(stdout);
	config.seek = off;

	return 0;
}
Пример #27
0
int move_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	FF_T_INT8	src[FF_MAX_PATH];
	FF_T_INT8	dest[FF_MAX_PATH];
	FF_ERROR	Error;

	if(argc == 3) {
		ProcessPath(src, argv[1], pEnv);
		ProcessPath(dest, argv[2], pEnv);

		Error = FF_Move(pEnv->pIoman, src, dest);
		if(Error) {
			cons_printf("Error: %s\n", FF_GetErrMessage(Error));
		}
	} else {
		cons_printf("Usage: %s [Source Path] [Destination Path]\n", argv[0]);
	}

	return 0;
}
Пример #28
0
int main(void)
{
	long i;
	
	i = 128;
	printf( "%d Hello world %d \nECS", i, 2 * i);
	cons_printf( "--> Hello world <--\nCPE/CSC" );	/* target printf */
	return 0;
	/* end main()*/
}
Пример #29
0
/**
 *	@public
 *	@brief	MD5 Data Hashing function.
 *
 *	Generates and displays an MD5 hash of a file. This is really useful when
 *	verify files for their integrity. We used MD5 extensively while stabilising
 *	the read and write functionality of FullFAT.
 *
 **/
int md5_cmd(int argc, char **argv, FF_ENVIRONMENT *pEnv) {
	FF_IOMAN	*pIoman = pEnv->pIoman;
	FF_T_INT8	path[FF_MAX_PATH];
	FF_T_UINT8	readBuf[8192];
	FF_FILE		*fSource;
	FF_ERROR	Error;

	int			len;
	md5_state_t state;
	md5_byte_t	digest[16];
	int			di;
	
	if(argc == 2) {
		
		ProcessPath(path, argv[1], pEnv);

		fSource = FF_Open(pIoman, path, FF_MODE_READ, &Error);

		if(fSource) {
			md5_init(&state);
			do {
				len = FF_Read(fSource, 1, 8192, readBuf);
				md5_append(&state, (const md5_byte_t *)readBuf, len);
			} while(len);
			
			md5_finish(&state, digest);

			for (di = 0; di < 16; ++di)
				cons_printf("%02x", digest[di]);

			cons_printf ("\n");

			FF_Close(fSource);
		} else {
			cons_printf("Could not open file - %s\n", FF_GetErrMessage(Error));
		}
	} else {
		cons_printf("Usage: %s [filename]\n", argv[0]);
	}

	return 0;
}
Пример #30
0
void
opendebug()
{
	FILE *fp;	/* scratch file pointer for problems */

	if ((Dfp = fopen(DBGFILE, "a+")) == NULL) {
		cons_printf("SAC: could not open debugfile %s: %s\n",
		    DBGFILE, strerror(errno));
		exit(1);
	}
}