aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>2006-04-11 01:53:39 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-04-11 09:18:37 -0400
commit87276f721a9407a4a152b09265dc079f37674672 (patch)
tree5034e88d6ee2769e76374494d5dec19234c8e09e /arch/um
parentd84a19ce52a7b01dc7318ea3a8223dfe44cccb6f (diff)
[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: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Cc: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/os-Linux/mem.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index 6ab372da9657..71bb90a7606d 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -53,33 +53,36 @@ static void __init find_tempdir(void)
53 */ 53 */
54int make_tempfile(const char *template, char **out_tempname, int do_unlink) 54int make_tempfile(const char *template, char **out_tempname, int do_unlink)
55{ 55{
56 char tempname[MAXPATHLEN]; 56 char *tempname;
57 int fd; 57 int fd;
58 58
59 tempname = malloc(MAXPATHLEN);
60
59 find_tempdir(); 61 find_tempdir();
60 if (*template != '/') 62 if (template[0] != '/')
61 strcpy(tempname, tempdir); 63 strcpy(tempname, tempdir);
62 else 64 else
63 *tempname = 0; 65 tempname[0] = '\0';
64 strcat(tempname, template); 66 strcat(tempname, template);
65 fd = mkstemp(tempname); 67 fd = mkstemp(tempname);
66 if(fd < 0){ 68 if(fd < 0){
67 fprintf(stderr, "open - cannot create %s: %s\n", tempname, 69 fprintf(stderr, "open - cannot create %s: %s\n", tempname,
68 strerror(errno)); 70 strerror(errno));
69 return -1; 71 goto out;
70 } 72 }
71 if(do_unlink && (unlink(tempname) < 0)){ 73 if(do_unlink && (unlink(tempname) < 0)){
72 perror("unlink"); 74 perror("unlink");
73 return -1; 75 goto out;
74 } 76 }
75 if(out_tempname){ 77 if(out_tempname){
76 *out_tempname = strdup(tempname); 78 *out_tempname = tempname;
77 if(*out_tempname == NULL){ 79 } else {
78 perror("strdup"); 80 free(tempname);
79 return -1;
80 }
81 } 81 }
82 return(fd); 82 return(fd);
83out:
84 free(tempname);
85 return -1;
83} 86}
84 87
85#define TEMPNAME_TEMPLATE "vm_file-XXXXXX" 88#define TEMPNAME_TEMPLATE "vm_file-XXXXXX"