1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (c) 2021 Joerg Vehlow <lkml@jv-coder.de> 4 */ 5 6 #include <stdlib.h> 7 #include <stdio.h> 8 #include <limits.h> 9 10 #define PTS_GET_TMP_FILENAME(target, prefix) \ 11 snprintf(target, sizeof(target), \ 12 "%s/" prefix "_pid-%d", pts_get_tmpdir(), getpid()); 13 pts_get_tmpdir(void)14static inline const char *pts_get_tmpdir(void) 15 { 16 const char *tmpdir_env; 17 tmpdir_env = getenv("TMPDIR"); 18 return tmpdir_env ? tmpdir_env : "/tmp"; 19 } 20