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