1/* 2 * Copyright (c) 2014-2016 Cyril Hrubis <chrubis@suse.cz> 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18#ifndef OLD_DEVICE_H__ 19#define OLD_DEVICE_H__ 20 21/* 22 * Returns filesystem type to be used for the testing. Unless your test is 23 * designed for specific filesystem you should use this function to the tested 24 * filesystem. 25 * 26 * If TST_DEV_FS_TYPE is set the function returns it's content, 27 * otherwise default fs type hardcoded in the library is returned. 28 */ 29const char *tst_dev_fs_type(void); 30 31/* 32 * Acquires test device. 33 * 34 * Can be used only once, i.e. you cannot get two different devices. 35 * 36 * Looks for LTP_DEV env variable first (which may be passed by the test 37 * driver or by a user) and returns just it's value if found. 38 * 39 * Otherwise creates a temp file and loop device. 40 * 41 * Note that you have to call tst_tmpdir() beforehand. 42 * 43 * Returns path to the device or NULL if it cannot be created. 44 * Call tst_release_device() when you're done. 45 */ 46const char *tst_acquire_device_(void (cleanup_fn)(void), unsigned int size); 47 48const char *tst_acquire_device__(unsigned int size); 49 50static inline const char *tst_acquire_device(void (cleanup_fn)(void)) 51{ 52 return tst_acquire_device_(cleanup_fn, 0); 53} 54 55/* 56 * Acquire a loop device with specified temp filename. This function allows 57 * you to acquire multiple devices at the same time. LTP_DEV is ignored. 58 * If you call this function directly, use tst_detach_device() to release 59 * the devices. tst_release_device() will not work correctly. 60 * 61 * The return value points to a static buffer and additional calls of 62 * tst_acquire_loop_device() or tst_acquire_device() will overwrite it. 63 */ 64const char *tst_acquire_loop_device(unsigned int size, const char *filename); 65 66/* 67 * @dev: device path returned by the tst_acquire_device() 68 */ 69int tst_release_device(const char *dev); 70 71/* 72 * Cleanup function for tst_acquire_loop_device(). If you have acquired 73 * a device using tst_acquire_device(), use tst_release_device() instead. 74 * @dev: device path returned by the tst_acquire_loop_device() 75 */ 76int tst_detach_device(const char *dev); 77 78/* 79 * Just like umount() but retries several times on failure. 80 * @path: Path to umount 81 */ 82int tst_umount(const char *path); 83 84#endif /* OLD_DEVICE_H__ */ 85