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 */
29 const 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 */
45 const char *tst_acquire_device_(void (cleanup_fn)(void), unsigned int size);
46
47 const char *tst_acquire_device__(unsigned int size);
48
tst_acquire_device(void (cleanup_fn)(void))49 static inline const char *tst_acquire_device(void (cleanup_fn)(void))
50 {
51 return tst_acquire_device_(cleanup_fn, 0);
52 }
53
54 /*
55 * @dev: device path returned by the tst_acquire_device()
56 */
57 int tst_release_device(const char *dev);
58
59 /*
60 * Just like umount() but retries several times on failure.
61 * @path: Path to umount
62 */
63 int tst_umount(const char *path);
64
65 #endif /* OLD_DEVICE_H__ */
66