student-distrib/fs_module.c
int32_t read_dentry_by_name(const char* fname, dentry_t* dentry){

	int fname_length = strlen(fname);
	//printf("file name length: %d", fname_length);
	if(fname_length > MAX_FILENAME)	//check that file name does not exceed limit
		return -1;

	if(dentry == NULL)						//Make sure pointer is valid
		return -1;

	int i = 0;
	for(i = 0; i < MAX_FILECOUNT; i++){		//loop through all dir. entries and find matching file

		//load file entry at [i]
		dentry_t* f = &(boot_block->entries[i]);

		//if all char in string match, file is found
		//fname_length + 1 to account for terminating 0x0
		if(fname_length < MAX_FILENAME)
			fname_length++;

		//compare strings and copy file info if match
		if(strncmp(fname, f->name, fname_length) == 0){

			*dentry = *f;
			return 0;
		}
	}

	//file not found
	return -1;
}
/*
   read_dentry_by_name
   		DESCRIPTION: Finds dir. entry from given file name
   		INPUTS: fname - name of file to be read
				dentry - pointer to dentery object
		OUTPUT: 0 on success, -1 on failure
		SIDE EFFECTS: dentry object populated with file
 */
read_dentry_by_name
DESCRIPTION: Finds dir. entry from given file name
INPUTS: fname - name of file to be read
dentry - pointer to dentery object
OUTPUT: 0 on success, -1 on failure
SIDE EFFECTS: dentry object populated with file
read_dentry_by_name DESCRIPTION : Finds dir . entry from given file name INPUTS : fname - name of file to be read dentry - pointer to dentery object OUTPUT : 0 on success - 1 on failure SIDE EFFECTS : dentry object populated with file
int32_t read_dentry_by_name(const char* fname, dentry_t* dentry){
	int fname_length = strlen(fname);
	if(fname_length > MAX_FILENAME)	
		return -1;
	if(dentry == NULL)						
		return -1;
	int i = 0;
	for(i = 0; i < MAX_FILECOUNT; i++){		
		dentry_t* f = &(boot_block->entries[i]);
		if(fname_length < MAX_FILENAME)
			fname_length++;
		if(strncmp(fname, f->name, fname_length) == 0){
			*dentry = *f;
			return 0;
		}
	}
	return -1;
}
int32_t read_dentry_by_name ( const char * fname , dentry_t * dentry ) { int fname_length = strlen ( fname ) ; if ( fname_length > MAX_FILENAME ) return -1 ; if ( dentry == NULL ) return -1 ; int i = 0 ; for ( i = 0 ; i < MAX_FILECOUNT ; i ++ ) { dentry_t * f = & ( boot_block -> entries [ i ] ) ; if ( fname_length < MAX_FILENAME ) fname_length ++ ; if ( strncmp ( fname , f -> name , fname_length ) == 0 ) { * dentry = * f ; return 0 ; } } return -1 ; }
read_dentry_by_name
DESCRIPTION: Finds dir.
read_dentry_by_name DESCRIPTION : Finds dir .
//printf("file name length: %d", fname_length); //check that file name does not exceed limit //Make sure pointer is valid //loop through all dir. entries and find matching file //load file entry at [i] //if all char in string match, file is found //fname_length + 1 to account for terminating 0x0 //compare strings and copy file info if match //file not found