aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux/process.c
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-10-16 04:27:00 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:43:05 -0400
commitba180fd437156f7fd8cfb2fdd021d949eeef08d6 (patch)
treeb9f38b9cdd7a5b1aacf00341d1948314663c5871 /arch/um/os-Linux/process.c
parent77bf4400319db9d2a8af6b00c2be6faa0f3d07cb (diff)
uml: style fixes pass 3
Formatting changes in the files which have been changed in the course of folding foo_skas functions into their callers. These include: copyright updates header file trimming style fixes adding severity to printks These changes should be entirely non-functional. 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/os-Linux/process.c')
-rw-r--r--arch/um/os-Linux/process.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c
index a955e9bcd04d..b2e0d8c4258c 100644
--- a/arch/um/os-Linux/process.c
+++ b/arch/um/os-Linux/process.c
@@ -1,27 +1,23 @@
1/* 1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@addtoit.com) 2 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include <unistd.h>
7#include <stdio.h> 6#include <stdio.h>
7#include <unistd.h>
8#include <errno.h> 8#include <errno.h>
9#include <signal.h> 9#include <signal.h>
10#include <sys/mman.h> 10#include <sys/mman.h>
11#include <sys/ptrace.h>
11#include <sys/wait.h> 12#include <sys/wait.h>
12#include <sys/mman.h> 13#include <asm/unistd.h>
13#include <sys/syscall.h> 14#include "init.h"
14#include "ptrace_user.h" 15#include "kern_constants.h"
16#include "longjmp.h"
15#include "os.h" 17#include "os.h"
16#include "user.h"
17#include "process.h" 18#include "process.h"
18#include "irq_user.h"
19#include "kern_util.h"
20#include "longjmp.h"
21#include "skas_ptrace.h" 19#include "skas_ptrace.h"
22#include "kern_constants.h" 20#include "user.h"
23#include "uml-config.h"
24#include "init.h"
25 21
26#define ARBITRARY_ADDR -1 22#define ARBITRARY_ADDR -1
27#define FAILURE_PID -1 23#define FAILURE_PID -1
@@ -37,24 +33,25 @@ unsigned long os_process_pc(int pid)
37 33
38 sprintf(proc_stat, "/proc/%d/stat", pid); 34 sprintf(proc_stat, "/proc/%d/stat", pid);
39 fd = os_open_file(proc_stat, of_read(OPENFLAGS()), 0); 35 fd = os_open_file(proc_stat, of_read(OPENFLAGS()), 0);
40 if(fd < 0){ 36 if (fd < 0) {
41 printk("os_process_pc - couldn't open '%s', err = %d\n", 37 printk(UM_KERN_ERR "os_process_pc - couldn't open '%s', "
42 proc_stat, -fd); 38 "err = %d\n", proc_stat, -fd);
43 return ARBITRARY_ADDR; 39 return ARBITRARY_ADDR;
44 } 40 }
45 CATCH_EINTR(err = read(fd, buf, sizeof(buf))); 41 CATCH_EINTR(err = read(fd, buf, sizeof(buf)));
46 if(err < 0){ 42 if (err < 0) {
47 printk("os_process_pc - couldn't read '%s', err = %d\n", 43 printk(UM_KERN_ERR "os_process_pc - couldn't read '%s', "
48 proc_stat, errno); 44 "err = %d\n", proc_stat, errno);
49 os_close_file(fd); 45 os_close_file(fd);
50 return ARBITRARY_ADDR; 46 return ARBITRARY_ADDR;
51 } 47 }
52 os_close_file(fd); 48 os_close_file(fd);
53 pc = ARBITRARY_ADDR; 49 pc = ARBITRARY_ADDR;
54 if(sscanf(buf, "%*d " COMM_SCANF " %*c %*d %*d %*d %*d %*d %*d %*d " 50 if (sscanf(buf, "%*d " COMM_SCANF " %*c %*d %*d %*d %*d %*d %*d %*d "
55 "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d " 51 "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d "
56 "%*d %*d %*d %*d %*d %lu", &pc) != 1){ 52 "%*d %*d %*d %*d %*d %lu", &pc) != 1) {
57 printk("os_process_pc - couldn't find pc in '%s'\n", buf); 53 printk(UM_KERN_ERR "os_process_pc - couldn't find pc in '%s'\n",
54 buf);
58 } 55 }
59 return pc; 56 return pc;
60} 57}
@@ -65,28 +62,29 @@ int os_process_parent(int pid)
65 char data[256]; 62 char data[256];
66 int parent, n, fd; 63 int parent, n, fd;
67 64
68 if(pid == -1) 65 if (pid == -1)
69 return -1; 66 return -1;
70 67
71 snprintf(stat, sizeof(stat), "/proc/%d/stat", pid); 68 snprintf(stat, sizeof(stat), "/proc/%d/stat", pid);
72 fd = os_open_file(stat, of_read(OPENFLAGS()), 0); 69 fd = os_open_file(stat, of_read(OPENFLAGS()), 0);
73 if(fd < 0){ 70 if (fd < 0) {
74 printk("Couldn't open '%s', err = %d\n", stat, -fd); 71 printk(UM_KERN_ERR "Couldn't open '%s', err = %d\n", stat, -fd);
75 return FAILURE_PID; 72 return FAILURE_PID;
76 } 73 }
77 74
78 CATCH_EINTR(n = read(fd, data, sizeof(data))); 75 CATCH_EINTR(n = read(fd, data, sizeof(data)));
79 os_close_file(fd); 76 os_close_file(fd);
80 77
81 if(n < 0){ 78 if (n < 0) {
82 printk("Couldn't read '%s', err = %d\n", stat, errno); 79 printk(UM_KERN_ERR "Couldn't read '%s', err = %d\n", stat,
80 errno);
83 return FAILURE_PID; 81 return FAILURE_PID;
84 } 82 }
85 83
86 parent = FAILURE_PID; 84 parent = FAILURE_PID;
87 n = sscanf(data, "%*d " COMM_SCANF " %*c %d", &parent); 85 n = sscanf(data, "%*d " COMM_SCANF " %*c %d", &parent);
88 if(n != 1) 86 if (n != 1)
89 printk("Failed to scan '%s'\n", data); 87 printk(UM_KERN_ERR "Failed to scan '%s'\n", data);
90 88
91 return parent; 89 return parent;
92} 90}
@@ -99,9 +97,8 @@ void os_stop_process(int pid)
99void os_kill_process(int pid, int reap_child) 97void os_kill_process(int pid, int reap_child)
100{ 98{
101 kill(pid, SIGKILL); 99 kill(pid, SIGKILL);
102 if(reap_child) 100 if (reap_child)
103 CATCH_EINTR(waitpid(pid, NULL, 0)); 101 CATCH_EINTR(waitpid(pid, NULL, 0));
104
105} 102}
106 103
107/* This is here uniquely to have access to the userspace errno, i.e. the one 104/* This is here uniquely to have access to the userspace errno, i.e. the one
@@ -129,7 +126,7 @@ void os_kill_ptraced_process(int pid, int reap_child)
129 kill(pid, SIGKILL); 126 kill(pid, SIGKILL);
130 ptrace(PTRACE_KILL, pid); 127 ptrace(PTRACE_KILL, pid);
131 ptrace(PTRACE_CONT, pid); 128 ptrace(PTRACE_CONT, pid);
132 if(reap_child) 129 if (reap_child)
133 CATCH_EINTR(waitpid(pid, NULL, 0)); 130 CATCH_EINTR(waitpid(pid, NULL, 0));
134} 131}
135 132
@@ -153,34 +150,35 @@ int os_map_memory(void *virt, int fd, unsigned long long off, unsigned long len,
153 void *loc; 150 void *loc;
154 int prot; 151 int prot;
155 152
156 prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) | 153 prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) |
157 (x ? PROT_EXEC : 0); 154 (x ? PROT_EXEC : 0);
158 155
159 loc = mmap64((void *) virt, len, prot, MAP_SHARED | MAP_FIXED, 156 loc = mmap64((void *) virt, len, prot, MAP_SHARED | MAP_FIXED,
160 fd, off); 157 fd, off);
161 if(loc == MAP_FAILED) 158 if (loc == MAP_FAILED)
162 return -errno; 159 return -errno;
163 return 0; 160 return 0;
164} 161}
165 162
166int os_protect_memory(void *addr, unsigned long len, int r, int w, int x) 163int os_protect_memory(void *addr, unsigned long len, int r, int w, int x)
167{ 164{
168 int prot = ((r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) | 165 int prot = ((r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) |
169 (x ? PROT_EXEC : 0)); 166 (x ? PROT_EXEC : 0));
170 167
171 if(mprotect(addr, len, prot) < 0) 168 if (mprotect(addr, len, prot) < 0)
172 return -errno; 169 return -errno;
173 return 0; 170
171 return 0;
174} 172}
175 173
176int os_unmap_memory(void *addr, int len) 174int os_unmap_memory(void *addr, int len)
177{ 175{
178 int err; 176 int err;
179 177
180 err = munmap(addr, len); 178 err = munmap(addr, len);
181 if(err < 0) 179 if (err < 0)
182 return -errno; 180 return -errno;
183 return 0; 181 return 0;
184} 182}
185 183
186#ifndef MADV_REMOVE 184#ifndef MADV_REMOVE
@@ -192,7 +190,7 @@ int os_drop_memory(void *addr, int length)
192 int err; 190 int err;
193 191
194 err = madvise(addr, length, MADV_REMOVE); 192 err = madvise(addr, length, MADV_REMOVE);
195 if(err < 0) 193 if (err < 0)
196 err = -errno; 194 err = -errno;
197 return err; 195 return err;
198} 196}
@@ -202,22 +200,24 @@ int __init can_drop_memory(void)
202 void *addr; 200 void *addr;
203 int fd, ok = 0; 201 int fd, ok = 0;
204 202
205 printk("Checking host MADV_REMOVE support..."); 203 printk(UM_KERN_INFO "Checking host MADV_REMOVE support...");
206 fd = create_mem_file(UM_KERN_PAGE_SIZE); 204 fd = create_mem_file(UM_KERN_PAGE_SIZE);
207 if(fd < 0){ 205 if (fd < 0) {
208 printk("Creating test memory file failed, err = %d\n", -fd); 206 printk(UM_KERN_ERR "Creating test memory file failed, "
207 "err = %d\n", -fd);
209 goto out; 208 goto out;
210 } 209 }
211 210
212 addr = mmap64(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, 211 addr = mmap64(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE,
213 MAP_SHARED, fd, 0); 212 MAP_SHARED, fd, 0);
214 if(addr == MAP_FAILED){ 213 if (addr == MAP_FAILED) {
215 printk("Mapping test memory file failed, err = %d\n", -errno); 214 printk(UM_KERN_ERR "Mapping test memory file failed, "
215 "err = %d\n", -errno);
216 goto out_close; 216 goto out_close;
217 } 217 }
218 218
219 if(madvise(addr, UM_KERN_PAGE_SIZE, MADV_REMOVE) != 0){ 219 if (madvise(addr, UM_KERN_PAGE_SIZE, MADV_REMOVE) != 0) {
220 printk("MADV_REMOVE failed, err = %d\n", -errno); 220 printk(UM_KERN_ERR "MADV_REMOVE failed, err = %d\n", -errno);
221 goto out_unmap; 221 goto out_unmap;
222 } 222 }
223 223
@@ -256,7 +256,7 @@ int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr)
256 256
257 *jmp_ptr = &buf; 257 *jmp_ptr = &buf;
258 n = UML_SETJMP(&buf); 258 n = UML_SETJMP(&buf);
259 if(n != 0) 259 if (n != 0)
260 return n; 260 return n;
261 (*fn)(arg); 261 (*fn)(arg);
262 return 0; 262 return 0;