diff options
| author | Tony Luck <tony.luck@intel.com> | 2005-10-20 13:41:44 -0400 |
|---|---|---|
| committer | Tony Luck <tony.luck@intel.com> | 2005-10-20 13:41:44 -0400 |
| commit | 9cec58dc138d6fcad9f447a19c8ff69f6540e667 (patch) | |
| tree | 4fe1cca94fdba8b705c87615bee06d3346f687ce /arch/um/kernel/tempfile.c | |
| parent | 17e5ad6c0ce5a970e2830d0de8bdd60a2f077d38 (diff) | |
| parent | ac9b9c667c2e1194e22ebe0a441ae1c37aaa9b90 (diff) | |
Update from upstream with manual merge of Yasunori Goto's
changes to swiotlb.c made in commit 281dd25cdc0d6903929b79183816d151ea626341
since this file has been moved from arch/ia64/lib/swiotlb.c to
lib/swiotlb.c
Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'arch/um/kernel/tempfile.c')
| -rw-r--r-- | arch/um/kernel/tempfile.c | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/arch/um/kernel/tempfile.c b/arch/um/kernel/tempfile.c deleted file mode 100644 index b1674bc1395d..000000000000 --- a/arch/um/kernel/tempfile.c +++ /dev/null | |||
| @@ -1,82 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
| 3 | * Licensed under the GPL | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include <stdio.h> | ||
| 7 | #include <stdlib.h> | ||
| 8 | #include <unistd.h> | ||
| 9 | #include <string.h> | ||
| 10 | #include <errno.h> | ||
| 11 | #include <sys/param.h> | ||
| 12 | #include "init.h" | ||
| 13 | |||
| 14 | /* Modified from create_mem_file and start_debugger */ | ||
| 15 | static char *tempdir = NULL; | ||
| 16 | |||
| 17 | static void __init find_tempdir(void) | ||
| 18 | { | ||
| 19 | char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL }; | ||
| 20 | int i; | ||
| 21 | char *dir = NULL; | ||
| 22 | |||
| 23 | if(tempdir != NULL) return; /* We've already been called */ | ||
| 24 | for(i = 0; dirs[i]; i++){ | ||
| 25 | dir = getenv(dirs[i]); | ||
| 26 | if((dir != NULL) && (*dir != '\0')) | ||
| 27 | break; | ||
| 28 | } | ||
| 29 | if((dir == NULL) || (*dir == '\0')) | ||
| 30 | dir = "/tmp"; | ||
| 31 | |||
| 32 | tempdir = malloc(strlen(dir) + 2); | ||
| 33 | if(tempdir == NULL){ | ||
| 34 | fprintf(stderr, "Failed to malloc tempdir, " | ||
| 35 | "errno = %d\n", errno); | ||
| 36 | return; | ||
| 37 | } | ||
| 38 | strcpy(tempdir, dir); | ||
| 39 | strcat(tempdir, "/"); | ||
| 40 | } | ||
| 41 | |||
| 42 | int make_tempfile(const char *template, char **out_tempname, int do_unlink) | ||
| 43 | { | ||
| 44 | char tempname[MAXPATHLEN]; | ||
| 45 | int fd; | ||
| 46 | |||
| 47 | find_tempdir(); | ||
| 48 | if (*template != '/') | ||
| 49 | strcpy(tempname, tempdir); | ||
| 50 | else | ||
| 51 | *tempname = 0; | ||
| 52 | strcat(tempname, template); | ||
| 53 | fd = mkstemp(tempname); | ||
| 54 | if(fd < 0){ | ||
| 55 | fprintf(stderr, "open - cannot create %s: %s\n", tempname, | ||
| 56 | strerror(errno)); | ||
| 57 | return -1; | ||
| 58 | } | ||
| 59 | if(do_unlink && (unlink(tempname) < 0)){ | ||
| 60 | perror("unlink"); | ||
| 61 | return -1; | ||
| 62 | } | ||
| 63 | if(out_tempname){ | ||
| 64 | *out_tempname = strdup(tempname); | ||
| 65 | if(*out_tempname == NULL){ | ||
| 66 | perror("strdup"); | ||
| 67 | return -1; | ||
| 68 | } | ||
| 69 | } | ||
| 70 | return(fd); | ||
| 71 | } | ||
| 72 | |||
| 73 | /* | ||
| 74 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
| 75 | * Emacs will notice this stuff at the end of the file and automatically | ||
| 76 | * adjust the settings for this buffer only. This must remain at the end | ||
| 77 | * of the file. | ||
| 78 | * --------------------------------------------------------------------------- | ||
| 79 | * Local variables: | ||
| 80 | * c-file-style: "linux" | ||
| 81 | * End: | ||
| 82 | */ | ||
