1*49cdfc7eSAndroid Build Coastguard Worker /* 2*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) 2016 Cyril Hrubis <[email protected]> 3*49cdfc7eSAndroid Build Coastguard Worker * 4*49cdfc7eSAndroid Build Coastguard Worker * This program is free software: you can redistribute it and/or modify 5*49cdfc7eSAndroid Build Coastguard Worker * it under the terms of the GNU General Public License as published by 6*49cdfc7eSAndroid Build Coastguard Worker * the Free Software Foundation, either version 2 of the License, or 7*49cdfc7eSAndroid Build Coastguard Worker * (at your option) any later version. 8*49cdfc7eSAndroid Build Coastguard Worker * 9*49cdfc7eSAndroid Build Coastguard Worker * This program is distributed in the hope that it will be useful, 10*49cdfc7eSAndroid Build Coastguard Worker * but WITHOUT ANY WARRANTY; without even the implied warranty of 11*49cdfc7eSAndroid Build Coastguard Worker * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12*49cdfc7eSAndroid Build Coastguard Worker * GNU General Public License for more details. 13*49cdfc7eSAndroid Build Coastguard Worker * 14*49cdfc7eSAndroid Build Coastguard Worker * You should have received a copy of the GNU General Public License 15*49cdfc7eSAndroid Build Coastguard Worker * along with this program. If not, see <http://www.gnu.org/licenses/>. 16*49cdfc7eSAndroid Build Coastguard Worker */ 17*49cdfc7eSAndroid Build Coastguard Worker 18*49cdfc7eSAndroid Build Coastguard Worker #ifndef OLD_TMPDIR_H__ 19*49cdfc7eSAndroid Build Coastguard Worker #define OLD_TMPDIR_H__ 20*49cdfc7eSAndroid Build Coastguard Worker 21*49cdfc7eSAndroid Build Coastguard Worker /* 22*49cdfc7eSAndroid Build Coastguard Worker * Create a unique temporary directory and chdir() to it. It expects the caller 23*49cdfc7eSAndroid Build Coastguard Worker * to have defined/initialized the TCID/TST_TOTAL global variables. 24*49cdfc7eSAndroid Build Coastguard Worker * The TESTDIR global variable will be set to the directory that gets used 25*49cdfc7eSAndroid Build Coastguard Worker * as the testing directory. 26*49cdfc7eSAndroid Build Coastguard Worker * 27*49cdfc7eSAndroid Build Coastguard Worker * NOTE: This function must be called BEFORE any activity that would require 28*49cdfc7eSAndroid Build Coastguard Worker * CLEANUP. If tst_tmpdir() fails, it cleans up afer itself and calls 29*49cdfc7eSAndroid Build Coastguard Worker * tst_exit() (i.e. does not return). 30*49cdfc7eSAndroid Build Coastguard Worker */ 31*49cdfc7eSAndroid Build Coastguard Worker void tst_tmpdir(void); 32*49cdfc7eSAndroid Build Coastguard Worker 33*49cdfc7eSAndroid Build Coastguard Worker /* 34*49cdfc7eSAndroid Build Coastguard Worker * Recursively remove the temporary directory created by tst_tmpdir(). 35*49cdfc7eSAndroid Build Coastguard Worker * This function is intended ONLY as a companion to tst_tmpdir(). 36*49cdfc7eSAndroid Build Coastguard Worker */ 37*49cdfc7eSAndroid Build Coastguard Worker void tst_rmdir(void); 38*49cdfc7eSAndroid Build Coastguard Worker 39*49cdfc7eSAndroid Build Coastguard Worker /* tst_get_tmpdir() 40*49cdfc7eSAndroid Build Coastguard Worker * 41*49cdfc7eSAndroid Build Coastguard Worker * Return a copy of the test temp directory as seen by LTP. This is for 42*49cdfc7eSAndroid Build Coastguard Worker * path-oriented tests like chroot, etc, that may munge the path a bit. 43*49cdfc7eSAndroid Build Coastguard Worker * 44*49cdfc7eSAndroid Build Coastguard Worker * FREE VARIABLE AFTER USE IF IT IS REUSED! 45*49cdfc7eSAndroid Build Coastguard Worker */ 46*49cdfc7eSAndroid Build Coastguard Worker char *tst_get_tmpdir(void); 47*49cdfc7eSAndroid Build Coastguard Worker 48*49cdfc7eSAndroid Build Coastguard Worker /* 49*49cdfc7eSAndroid Build Coastguard Worker * Returns path to the test temporary directory root (TMPDIR). 50*49cdfc7eSAndroid Build Coastguard Worker */ 51*49cdfc7eSAndroid Build Coastguard Worker const char *tst_get_tmpdir_root(void); 52*49cdfc7eSAndroid Build Coastguard Worker 53*49cdfc7eSAndroid Build Coastguard Worker /* 54*49cdfc7eSAndroid Build Coastguard Worker * Returns 1 if temp directory was created. 55*49cdfc7eSAndroid Build Coastguard Worker */ 56*49cdfc7eSAndroid Build Coastguard Worker int tst_tmpdir_created(void); 57*49cdfc7eSAndroid Build Coastguard Worker 58*49cdfc7eSAndroid Build Coastguard Worker /* declared in tst_tmpdir.c */ 59*49cdfc7eSAndroid Build Coastguard Worker const char *tst_get_startwd(void); 60*49cdfc7eSAndroid Build Coastguard Worker 61*49cdfc7eSAndroid Build Coastguard Worker #endif /* OLD_TMPDIR_H__ */ 62