Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 25476
b: refs/heads/master
c: 87276f7
h: refs/heads/master
v: v3
  • Loading branch information
Paolo 'Blaisorblade' Giarrusso authored and Linus Torvalds committed Apr 11, 2006
1 parent f1c445f commit eb2db1e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d84a19ce52a7b01dc7318ea3a8223dfe44cccb6f
refs/heads/master: 87276f721a9407a4a152b09265dc079f37674672
23 changes: 13 additions & 10 deletions trunk/arch/um/os-Linux/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,36 @@ static void __init find_tempdir(void)
*/
int make_tempfile(const char *template, char **out_tempname, int do_unlink)
{
char tempname[MAXPATHLEN];
char *tempname;
int fd;

tempname = malloc(MAXPATHLEN);

find_tempdir();
if (*template != '/')
if (template[0] != '/')
strcpy(tempname, tempdir);
else
*tempname = 0;
tempname[0] = '\0';
strcat(tempname, template);
fd = mkstemp(tempname);
if(fd < 0){
fprintf(stderr, "open - cannot create %s: %s\n", tempname,
strerror(errno));
return -1;
goto out;
}
if(do_unlink && (unlink(tempname) < 0)){
perror("unlink");
return -1;
goto out;
}
if(out_tempname){
*out_tempname = strdup(tempname);
if(*out_tempname == NULL){
perror("strdup");
return -1;
}
*out_tempname = tempname;
} else {
free(tempname);
}
return(fd);
out:
free(tempname);
return -1;
}

#define TEMPNAME_TEMPLATE "vm_file-XXXXXX"
Expand Down

0 comments on commit eb2db1e

Please sign in to comment.