/* * Turn off all swapfiles previously turned on */ static int clean_swap(void) { int j; char filename[FILENAME_MAX]; for (j = 0; j < swapfiles; j++) { if (snprintf(filename, sizeof(filename), "swapfile%02d", j + 2) < 0) { tst_resm(TWARN, "sprintf() failed to create filename"); tst_resm(TWARN, "Failed to turn off swap files. System" " reboot after execution of LTP test" " suite is recommended"); return -1; } if (check_and_swapoff(filename) != 0) { tst_resm(TWARN, "Failed to turn off swap file %s.", filename); return -1; } } for (j = 0; j < testfiles; j++) { if (check_and_swapoff(swap_testfiles[j].filename) != 0) { tst_resm(TWARN, "Failed to turn off swap file %s.", swap_testfiles[j].filename); return -1; } } return 0; }
/*************************************************************** * clean_swap() - clearing all turned on swapfiles ***************************************************************/ int clean_swap() { int j; /* loop counter */ char filename[15]; for (j = 0; j < swapfiles; j++) { if (sprintf(filename, "swapfile%02d", j + 2) < 0) { tst_resm(TWARN, "sprintf() failed to create filename"); tst_resm(TWARN, "Failed to turn off swap files. System" " reboot after execution of LTP test" " suite is recommended"); return -1; } if (check_and_swapoff(filename) != 0) { tst_resm(TWARN, "Failed to turn off swap file %s.", filename); return -1; } } for (j = 0; j < testfiles; j++) { if (check_and_swapoff(swap_testfiles[j].filename) != 0) { tst_resm(TWARN, "Failed to turn off swap file %s.", swap_testfiles[j].filename); return -1; } } return 0; }