Commit 87276f72 authored by Paolo 'Blaisorblade' Giarrusso's avatar Paolo 'Blaisorblade' Giarrusso Committed by Linus Torvalds

[PATCH] uml: fix big stack user

Switch this proc from storing 4k of data (a whole path) on the stack to
keeping it on the heap.

Maybe it's not called in process context but only in early boot context (where
in UML you have a normal process stack on the host) but just to be safe, fix
it.

While at it some little readability simplifications.
Signed-off-by: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Cc: Jeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent d84a19ce
...@@ -53,33 +53,36 @@ static void __init find_tempdir(void) ...@@ -53,33 +53,36 @@ static void __init find_tempdir(void)
*/ */
int make_tempfile(const char *template, char **out_tempname, int do_unlink) int make_tempfile(const char *template, char **out_tempname, int do_unlink)
{ {
char tempname[MAXPATHLEN]; char *tempname;
int fd; int fd;
tempname = malloc(MAXPATHLEN);
find_tempdir(); find_tempdir();
if (*template != '/') if (template[0] != '/')
strcpy(tempname, tempdir); strcpy(tempname, tempdir);
else else
*tempname = 0; tempname[0] = '\0';
strcat(tempname, template); strcat(tempname, template);
fd = mkstemp(tempname); fd = mkstemp(tempname);
if(fd < 0){ if(fd < 0){
fprintf(stderr, "open - cannot create %s: %s\n", tempname, fprintf(stderr, "open - cannot create %s: %s\n", tempname,
strerror(errno)); strerror(errno));
return -1; goto out;
} }
if(do_unlink && (unlink(tempname) < 0)){ if(do_unlink && (unlink(tempname) < 0)){
perror("unlink"); perror("unlink");
return -1; goto out;
} }
if(out_tempname){ if(out_tempname){
*out_tempname = strdup(tempname); *out_tempname = tempname;
if(*out_tempname == NULL){ } else {
perror("strdup"); free(tempname);
return -1;
}
} }
return(fd); return(fd);
out:
free(tempname);
return -1;
} }
#define TEMPNAME_TEMPLATE "vm_file-XXXXXX" #define TEMPNAME_TEMPLATE "vm_file-XXXXXX"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment