int smsa_vunmount( void ) { // Free cache smsa_close_cache(); // Begin unmounting, log an error is unsucessful if( smsa_operation( UNMOUNT_DISK, NULL ) == -1 ) { logMessage( LOG_ERROR_LEVEL, "Unmounting disk failed...aborting\n" ); return -1; } return 0; }
int smsa_vunmount( void ) { uint32_t command; //holds the generated "unmount" command. ERROR_SOURCE err = 0; //holds return values of function calls to checkForErrors if ( DEBUG ) printCache( cache_hits, disk_reads); //save the contents of the memory to a file, so that //it can be restored when mount is called again, rather //than setting it to all zeros. If an error occurs in this //function we will not return a 1 since it is not a catastrophic //error, and the virtual memory will still function properly //once mount is called // err = saveDiskToFile(); //generate the op command so that we can use it to call //the smsa_operation function to unmount the disk. Once //again, DONT_CARE is defined as 0. After function call //command will contain the value neccessary to call //smsa_operation in order to unmount the disk err = generateOPCommand ( &command, SMSA_UNMOUNT, DONT_CARE, DONT_CARE, DONT_CARE ); if ( DEBUG ) logMessage ( LOG_INFO_LEVEL, "Sending UNMOUNT Command Across the Network"); //call function with the "mount" op command, //and NULL set as the parameter for the char*, //since we will not use this char* in the mount //function if ( smsa_client_operation ( command, NULL ) ) { logMessage ( LOG_INFO_LEVEL, "_smsa_vunmount:Failed to send UNMOUNT command on the network"); return 1; logMessage ( LOG_INFO_LEVEL, "Successfully Unmounted the Disk" ); //free cache if ( smsa_close_cache() ) logMessage ( LOG_INFO_LEVEL, "_smsa_vunmount:Failed to properly close cache in smsa_close_cache()" ); return 1; } //if checkForErrors finds that err is non-zero, it will return 1. //see smsa_driver.h for error enum definition return ( checkForErrors ( err, "_vumount", DONT_CARE, DONT_CARE, DONT_CARE, DONT_CARE, DONT_CARE, DONT_CARE, DONT_CARE, DONT_CARE ) ); }