aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2008-02-05 01:30:35 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-05 12:44:24 -0500
commitc9a3072d13e4b8a6549ecc1db6390a55c7ee2ddf (patch)
tree7b3eee2e8b71d844b27ed6a1c8d852915934e7f9 /arch/um
parent4d18de45fa921600e1b3770c3a7cb106ab48cd9d (diff)
uml: code tidying under arch/um/os-Linux
This patch contains varied fixes and improvements for some files under arch/um/os-Linux/, such as a typo fix in a perror message, a missing argument fix for a printf, some constifying for pointers and so on. [ jdike - made sigprocmask failure return -errno instead of -1 ] Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com> Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/include/os.h12
-rw-r--r--arch/um/os-Linux/file.c14
-rw-r--r--arch/um/os-Linux/main.c12
-rw-r--r--arch/um/os-Linux/mem.c5
-rw-r--r--arch/um/os-Linux/signal.c3
-rw-r--r--arch/um/os-Linux/start_up.c2
6 files changed, 28 insertions, 20 deletions
diff --git a/arch/um/include/os.h b/arch/um/include/os.h
index 6f0d1c741bc..82e5aeae2b8 100644
--- a/arch/um/include/os.h
+++ b/arch/um/include/os.h
@@ -137,24 +137,24 @@ extern int os_set_owner(int fd, int pid);
137extern int os_mode_fd(int fd, int mode); 137extern int os_mode_fd(int fd, int mode);
138 138
139extern int os_seek_file(int fd, unsigned long long offset); 139extern int os_seek_file(int fd, unsigned long long offset);
140extern int os_open_file(char *file, struct openflags flags, int mode); 140extern int os_open_file(const char *file, struct openflags flags, int mode);
141extern int os_read_file(int fd, void *buf, int len); 141extern int os_read_file(int fd, void *buf, int len);
142extern int os_write_file(int fd, const void *buf, int count); 142extern int os_write_file(int fd, const void *buf, int count);
143extern int os_file_size(char *file, unsigned long long *size_out); 143extern int os_file_size(const char *file, unsigned long long *size_out);
144extern int os_file_modtime(char *file, unsigned long *modtime); 144extern int os_file_modtime(const char *file, unsigned long *modtime);
145extern int os_pipe(int *fd, int stream, int close_on_exec); 145extern int os_pipe(int *fd, int stream, int close_on_exec);
146extern int os_set_fd_async(int fd, int owner); 146extern int os_set_fd_async(int fd, int owner);
147extern int os_clear_fd_async(int fd); 147extern int os_clear_fd_async(int fd);
148extern int os_set_fd_block(int fd, int blocking); 148extern int os_set_fd_block(int fd, int blocking);
149extern int os_accept_connection(int fd); 149extern int os_accept_connection(int fd);
150extern int os_create_unix_socket(char *file, int len, int close_on_exec); 150extern int os_create_unix_socket(const char *file, int len, int close_on_exec);
151extern int os_shutdown_socket(int fd, int r, int w); 151extern int os_shutdown_socket(int fd, int r, int w);
152extern void os_close_file(int fd); 152extern void os_close_file(int fd);
153extern int os_rcv_fd(int fd, int *helper_pid_out); 153extern int os_rcv_fd(int fd, int *helper_pid_out);
154extern int create_unix_socket(char *file, int len, int close_on_exec); 154extern int create_unix_socket(char *file, int len, int close_on_exec);
155extern int os_connect_socket(char *name); 155extern int os_connect_socket(const char *name);
156extern int os_file_type(char *file); 156extern int os_file_type(char *file);
157extern int os_file_mode(char *file, struct openflags *mode_out); 157extern int os_file_mode(const char *file, struct openflags *mode_out);
158extern int os_lock_file(int fd, int excl); 158extern int os_lock_file(int fd, int excl);
159extern void os_flush_stdout(void); 159extern void os_flush_stdout(void);
160extern int os_stat_filesystem(char *path, long *bsize_out, 160extern int os_stat_filesystem(char *path, long *bsize_out,
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
index f8346275862..c3bb5ce70c9 100644
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -19,7 +19,7 @@
19#include "user.h" 19#include "user.h"
20#include "kern_util.h" 20#include "kern_util.h"
21 21
22static void copy_stat(struct uml_stat *dst, struct stat64 *src) 22static void copy_stat(struct uml_stat *dst, const struct stat64 *src)
23{ 23{
24 *dst = ((struct uml_stat) { 24 *dst = ((struct uml_stat) {
25 .ust_dev = src->st_dev, /* device */ 25 .ust_dev = src->st_dev, /* device */
@@ -168,7 +168,7 @@ int os_file_type(char *file)
168 else return OS_TYPE_FILE; 168 else return OS_TYPE_FILE;
169} 169}
170 170
171int os_file_mode(char *file, struct openflags *mode_out) 171int os_file_mode(const char *file, struct openflags *mode_out)
172{ 172{
173 int err; 173 int err;
174 174
@@ -189,7 +189,7 @@ int os_file_mode(char *file, struct openflags *mode_out)
189 return err; 189 return err;
190} 190}
191 191
192int os_open_file(char *file, struct openflags flags, int mode) 192int os_open_file(const char *file, struct openflags flags, int mode)
193{ 193{
194 int fd, err, f = 0; 194 int fd, err, f = 0;
195 195
@@ -216,7 +216,7 @@ int os_open_file(char *file, struct openflags flags, int mode)
216 return fd; 216 return fd;
217} 217}
218 218
219int os_connect_socket(char *name) 219int os_connect_socket(const char *name)
220{ 220{
221 struct sockaddr_un sock; 221 struct sockaddr_un sock;
222 int fd, err; 222 int fd, err;
@@ -277,7 +277,7 @@ int os_write_file(int fd, const void *buf, int len)
277 return n; 277 return n;
278} 278}
279 279
280int os_file_size(char *file, unsigned long long *size_out) 280int os_file_size(const char *file, unsigned long long *size_out)
281{ 281{
282 struct uml_stat buf; 282 struct uml_stat buf;
283 int err; 283 int err;
@@ -314,7 +314,7 @@ int os_file_size(char *file, unsigned long long *size_out)
314 return 0; 314 return 0;
315} 315}
316 316
317int os_file_modtime(char *file, unsigned long *modtime) 317int os_file_modtime(const char *file, unsigned long *modtime)
318{ 318{
319 struct uml_stat buf; 319 struct uml_stat buf;
320 int err; 320 int err;
@@ -514,7 +514,7 @@ int os_rcv_fd(int fd, int *helper_pid_out)
514 return new; 514 return new;
515} 515}
516 516
517int os_create_unix_socket(char *file, int len, int close_on_exec) 517int os_create_unix_socket(const char *file, int len, int close_on_exec)
518{ 518{
519 struct sockaddr_un addr; 519 struct sockaddr_un addr;
520 int sock, err; 520 int sock, err;
diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c
index 82c3778627b..de664e7ff31 100644
--- a/arch/um/os-Linux/main.c
+++ b/arch/um/os-Linux/main.c
@@ -73,7 +73,7 @@ static void install_fatal_handler(int sig)
73 action.sa_handler = last_ditch_exit; 73 action.sa_handler = last_ditch_exit;
74 if (sigaction(sig, &action, NULL) < 0) { 74 if (sigaction(sig, &action, NULL) < 0) {
75 printf("failed to install handler for signal %d - errno = %d\n", 75 printf("failed to install handler for signal %d - errno = %d\n",
76 errno); 76 sig, errno);
77 exit(1); 77 exit(1);
78 } 78 }
79} 79}
@@ -92,7 +92,8 @@ static void setup_env_path(void)
92 * just use the default + /usr/lib/uml 92 * just use the default + /usr/lib/uml
93 */ 93 */
94 if (!old_path || (path_len = strlen(old_path)) == 0) { 94 if (!old_path || (path_len = strlen(old_path)) == 0) {
95 putenv("PATH=:/bin:/usr/bin/" UML_LIB_PATH); 95 if (putenv("PATH=:/bin:/usr/bin/" UML_LIB_PATH))
96 perror("couldn't putenv");
96 return; 97 return;
97 } 98 }
98 99
@@ -100,11 +101,14 @@ static void setup_env_path(void)
100 path_len += strlen("PATH=" UML_LIB_PATH) + 1; 101 path_len += strlen("PATH=" UML_LIB_PATH) + 1;
101 new_path = malloc(path_len); 102 new_path = malloc(path_len);
102 if (!new_path) { 103 if (!new_path) {
103 perror("coudn't malloc to set a new PATH"); 104 perror("couldn't malloc to set a new PATH");
104 return; 105 return;
105 } 106 }
106 snprintf(new_path, path_len, "PATH=%s" UML_LIB_PATH, old_path); 107 snprintf(new_path, path_len, "PATH=%s" UML_LIB_PATH, old_path);
107 putenv(new_path); 108 if (putenv(new_path)) {
109 perror("couldn't putenv to set a new PATH");
110 free(new_path);
111 }
108} 112}
109 113
110extern int uml_exitcode; 114extern int uml_exitcode;
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index 436f8d20b20..c3b736adc1d 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -172,13 +172,15 @@ int __init make_tempfile(const char *template, char **out_tempname,
172 172
173 which_tmpdir(); 173 which_tmpdir();
174 tempname = malloc(MAXPATHLEN); 174 tempname = malloc(MAXPATHLEN);
175 if (!tempname)
176 goto out;
175 177
176 find_tempdir(); 178 find_tempdir();
177 if (template[0] != '/') 179 if (template[0] != '/')
178 strcpy(tempname, tempdir); 180 strcpy(tempname, tempdir);
179 else 181 else
180 tempname[0] = '\0'; 182 tempname[0] = '\0';
181 strcat(tempname, template); 183 strncat(tempname, template, MAXPATHLEN-1-strlen(tempname));
182 fd = mkstemp(tempname); 184 fd = mkstemp(tempname);
183 if(fd < 0){ 185 if(fd < 0){
184 fprintf(stderr, "open - cannot create %s: %s\n", tempname, 186 fprintf(stderr, "open - cannot create %s: %s\n", tempname,
@@ -268,6 +270,7 @@ void __init check_tmpexec(void)
268 if(addr == MAP_FAILED){ 270 if(addr == MAP_FAILED){
269 err = errno; 271 err = errno;
270 perror("failed"); 272 perror("failed");
273 close(fd);
271 if(err == EPERM) 274 if(err == EPERM)
272 printf("%s must be not mounted noexec\n",tempdir); 275 printf("%s must be not mounted noexec\n",tempdir);
273 exit(1); 276 exit(1);
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index e9800b0b568..37302e86fda 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -183,7 +183,8 @@ int change_sig(int signal, int on)
183 183
184 sigemptyset(&sigset); 184 sigemptyset(&sigset);
185 sigaddset(&sigset, signal); 185 sigaddset(&sigset, signal);
186 sigprocmask(on ? SIG_UNBLOCK : SIG_BLOCK, &sigset, &old); 186 if (sigprocmask(on ? SIG_UNBLOCK : SIG_BLOCK, &sigset, &old) < 0)
187 return -errno;
187 return !sigismember(&old, signal); 188 return !sigismember(&old, signal);
188} 189}
189 190
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 7b81f6c08a5..c6cf648a51d 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -63,7 +63,7 @@ static int ptrace_child(void)
63 _exit(ret); 63 _exit(ret);
64} 64}
65 65
66static void fatal_perror(char *str) 66static void fatal_perror(const char *str)
67{ 67{
68 perror(str); 68 perror(str);
69 exit(1); 69 exit(1);