1 /* SPDX-License-Identifier: Apache-2.0 */ 2 /* Copyright (C) 2018 IBM Corp. */ 3 4 #ifndef MBOX_TEST_UTILS_H 5 #define MBOX_TEST_UTILS_H 6 7 #include <linux/limits.h> 8 9 struct tmpf { 10 int fd; 11 char path[PATH_MAX]; 12 }; 13 14 /** 15 * Initialise a tmpf instance for use, creating a temporary file. 16 * 17 * @tmpf: A context to initialise with the provided template 18 * @template_str: A file basename in mkstemp(3) template form 19 * 20 * Returns 0 on success, or -1 on error with errno set appropriately 21 */ 22 int tmpf_init(struct tmpf *tmpf, const char *template_str); 23 24 /** 25 * Destroy a tmpf instance, closing the file descriptor and removing the 26 * temporary file. 27 */ 28 void tmpf_destroy(struct tmpf *tmpf); 29 30 #endif /* MBOX_TEST_UTILS_H */ 31