student-distrib/fs_module.c
int32_t directory_read(uint32_t offset, char* buf, uint32_t len){

	//Check for offset overflow
	if(offset >= MAX_FILECOUNT)
		return -1;

	//Check for invalid buffer
	if(buf == NULL)
		return -1;

	//Limit length to max file name length
	if(len > MAX_FILENAME)
		len = MAX_FILENAME;

	//find dir. entry at offset
	dentry_t* f = &(boot_block->entries[offset]);

	//Limit length to file name length
	if(len > strlen(f->name))
		len = strlen(f->name);

	//place file name into buffer
	memcpy((char*)buf, (char*)f->name, len);

	return len;
}
/*
   directory_read
   		DESCRIPTION: reads file directory
   		INPUTS: offset - index for files
				buf - buffer for data
				len - size of buffer
		OUTPUT: 0 on success, -1 on failure
		SIDE EFFECTS: file name is read onto buffer
 */
directory_read
DESCRIPTION: reads file directory
INPUTS: offset - index for files
buf - buffer for data
len - size of buffer
OUTPUT: 0 on success, -1 on failure
SIDE EFFECTS: file name is read onto buffer
directory_read DESCRIPTION : reads file directory INPUTS : offset - index for files buf - buffer for data len - size of buffer OUTPUT : 0 on success - 1 on failure SIDE EFFECTS : file name is read onto buffer
int32_t directory_read(uint32_t offset, char* buf, uint32_t len){
	if(offset >= MAX_FILECOUNT)
		return -1;
	if(buf == NULL)
		return -1;
	if(len > MAX_FILENAME)
		len = MAX_FILENAME;
	dentry_t* f = &(boot_block->entries[offset]);
	if(len > strlen(f->name))
		len = strlen(f->name);
	memcpy((char*)buf, (char*)f->name, len);
	return len;
}
int32_t directory_read ( uint32_t offset , char * buf , uint32_t len ) { if ( offset >= MAX_FILECOUNT ) return -1 ; if ( buf == NULL ) return -1 ; if ( len > MAX_FILENAME ) len = MAX_FILENAME ; dentry_t * f = & ( boot_block -> entries [ offset ] ) ; if ( len > strlen ( f -> name ) ) len = strlen ( f -> name ) ; memcpy ( ( char * ) buf , ( char * ) f -> name , len ) ; return len ; }
directory_read
DESCRIPTION: reads file directory
INPUTS: offset - index for files
buf - buffer for data
len - size of buffer
OUTPUT: 0 on success, -1 on failure
SIDE EFFECTS: file name is read onto buffer
directory_read DESCRIPTION : reads file directory INPUTS : offset - index for files buf - buffer for data len - size of buffer OUTPUT : 0 on success - 1 on failure SIDE EFFECTS : file name is read onto buffer
//Check for offset overflow //Check for invalid buffer //Limit length to max file name length //find dir. entry at offset //Limit length to file name length //place file name into buffer