Added O_TMPFILE support for uwac tempfile generation.
@@ -212,11 +212,11 @@ static int create_tmpfile_cloexec(char* tmpname)
int uwac_create_anonymous_file(off_t size)
{
static const char template[] = "/weston-shared-XXXXXX";
- const char* path;
+ size_t length;
char* name;
+ const char* path;
int fd;
int ret;
- size_t length;
path = getenv("XDG_RUNTIME_DIR");
if (!path)
@@ -225,6 +225,10 @@ int uwac_create_anonymous_file(off_t size)
return -1;
}
+ fd = open(path, O_TMPFILE | O_RDWR | O_EXCL, 0600);
+
+ if (fd < 0)
+ {
length = strlen(path) + sizeof(template);
name = malloc(length);
@@ -234,6 +238,7 @@ int uwac_create_anonymous_file(off_t size)
snprintf(name, length, "%s%s", path, template);
fd = create_tmpfile_cloexec(name);
free(name);
+ }
if (fd < 0)
return -1;
