コード例 #1
0
void type_file___nextblock (char *command_line)

{
	long block_offset=1;
	char *ptr,buffer [80];

	ptr=parse_word (command_line,buffer);

	if (*ptr!=0) {
		ptr=parse_word (ptr,buffer);
		block_offset*=atol (buffer);
	}

	if (file_info.block_num+block_offset >= file_info.blocks_count) {
		wprintw (command_win,"Error - Block offset out of range\n");wrefresh (command_win);
		return;
	}

	file_info.block_num+=block_offset;
	file_info.global_block_num=file_block_to_global_block (file_info.block_num,&file_info);
	file_info.global_block_offset=file_info.global_block_num*file_system_info.block_size;
	file_info.file_offset=file_info.block_num*file_system_info.block_size;

	low_read (file_info.buffer,file_system_info.block_size,file_info.global_block_offset);

	strcpy (buffer,"show");dispatch (buffer);
}
コード例 #2
0
ファイル: dir_com.c プロジェクト: flwh/Alcatel_OT_985_kernel
struct struct_file_info search_dir_entries (int (*action) (struct struct_file_info *info),int *status)


{
	struct struct_file_info info;						/* Temporary variables used to */
	struct ext2_dir_entry_2 *dir_entry_ptr;					/* contain the current search entries */
	int return_code, next;
	
	info=first_file_info;							/* Start from the first entry - Read it */
	low_read (info.buffer,file_system_info.block_size,info.global_block_offset);
	dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);
	
	while (info.file_offset < info.file_length) {				/* While we haven't reached the end */
		
		*status=return_code=action (&info);				/* Call the client function to test */
										/* the current entry */	
		if (return_code==ABORT || return_code==FOUND)
			return (info);						/* Stop, if so asked */

										/* Pass to the next entry */
										
		dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);

		info.dir_entry_num++;
		next = dir_entry_ptr->rec_len;
		if (!next)
			next = file_system_info.block_size - info.dir_entry_offset;
		info.dir_entry_offset += next;
		info.file_offset += next;

		if (info.file_offset >= info.file_length) break;

		if (info.dir_entry_offset >= file_system_info.block_size) {	/* We crossed a block boundary */
										/* Find the next block, */
			info.block_num++;
			info.global_block_num=file_block_to_global_block (info.block_num,&info);
			info.global_block_offset=info.global_block_num*file_system_info.block_size;
			info.file_offset=info.block_num*file_system_info.block_size;
			info.dir_entry_offset=0;		
										/* read it and update the pointer */
										
			low_read (info.buffer,file_system_info.block_size,info.global_block_offset);
			dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);
			
		}
		
	}
	
	*status=ABORT;return (info);						/* There was no match */
}
コード例 #3
0
ファイル: dir_com.c プロジェクト: 325116067/semc-qsd8x50
struct struct_file_info search_dir_entries (int (*action) (struct struct_file_info *info),int *status)

/*
	This is the main function in this source file. Various actions are implemented using this basic function.

	This routine runs on all directory entries in the current directory.
	For each entry, action is called. We'll act according to the return code of action:
	
		ABORT		-	Current dir entry is returned.
		CONTINUE	-	Continue searching.
		FOUND		-	Current dir entry is returned.
		
	If the last entry is reached, it is returned, along with an ABORT status.
	
	status is updated to the returned code of action.	
*/

{
	struct struct_file_info info;						/* Temporary variables used to */
	struct ext2_dir_entry_2 *dir_entry_ptr;					/* contain the current search entries */
	int return_code, next;
	
	info=first_file_info;							/* Start from the first entry - Read it */
	low_read (info.buffer,file_system_info.block_size,info.global_block_offset);
	dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);
	
	while (info.file_offset < info.file_length) {				/* While we haven't reached the end */
		
		*status=return_code=action (&info);				/* Call the client function to test */
										/* the current entry */	
		if (return_code==ABORT || return_code==FOUND)
			return (info);						/* Stop, if so asked */

										/* Pass to the next entry */
										
		dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);

		info.dir_entry_num++;
		next = dir_entry_ptr->rec_len;
		if (!next)
			next = file_system_info.block_size - info.dir_entry_offset;
		info.dir_entry_offset += next;
		info.file_offset += next;

		if (info.file_offset >= info.file_length) break;

		if (info.dir_entry_offset >= file_system_info.block_size) {	/* We crossed a block boundary */
										/* Find the next block, */
			info.block_num++;
			info.global_block_num=file_block_to_global_block (info.block_num,&info);
			info.global_block_offset=info.global_block_num*file_system_info.block_size;
			info.file_offset=info.block_num*file_system_info.block_size;
			info.dir_entry_offset=0;		
										/* read it and update the pointer */
										
			low_read (info.buffer,file_system_info.block_size,info.global_block_offset);
			dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);
			
		}
		
	}
	
	*status=ABORT;return (info);						/* There was no match */
}