aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r--arch/um/os-Linux/file.c19
-rw-r--r--arch/um/os-Linux/mem.c17
-rw-r--r--arch/um/os-Linux/signal.c16
-rw-r--r--arch/um/os-Linux/skas/process.c7
-rw-r--r--arch/um/os-Linux/start_up.c2
5 files changed, 47 insertions, 14 deletions
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
index 26e0164895e4..2db18cbbb0ea 100644
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -264,6 +264,15 @@ int os_read_file(int fd, void *buf, int len)
264 return n; 264 return n;
265} 265}
266 266
267int os_pread_file(int fd, void *buf, int len, unsigned long long offset)
268{
269 int n = pread(fd, buf, len, offset);
270
271 if (n < 0)
272 return -errno;
273 return n;
274}
275
267int os_write_file(int fd, const void *buf, int len) 276int os_write_file(int fd, const void *buf, int len)
268{ 277{
269 int n = write(fd, (void *) buf, len); 278 int n = write(fd, (void *) buf, len);
@@ -282,6 +291,16 @@ int os_sync_file(int fd)
282 return n; 291 return n;
283} 292}
284 293
294int os_pwrite_file(int fd, const void *buf, int len, unsigned long long offset)
295{
296 int n = pwrite(fd, (void *) buf, len, offset);
297
298 if (n < 0)
299 return -errno;
300 return n;
301}
302
303
285int os_file_size(const char *file, unsigned long long *size_out) 304int os_file_size(const char *file, unsigned long long *size_out)
286{ 305{
287 struct uml_stat buf; 306 struct uml_stat buf;
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index 897e9ad0c108..8b1767668515 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -106,6 +106,17 @@ static int __init make_tempfile(const char *template)
106 } 106 }
107 } 107 }
108 108
109#ifdef O_TMPFILE
110 fd = open(tempdir, O_CLOEXEC | O_RDWR | O_EXCL | O_TMPFILE, 0700);
111 /*
112 * If the running system does not support O_TMPFILE flag then retry
113 * without it.
114 */
115 if (fd != -1 || (errno != EINVAL && errno != EISDIR &&
116 errno != EOPNOTSUPP))
117 return fd;
118#endif
119
109 tempname = malloc(strlen(tempdir) + strlen(template) + 1); 120 tempname = malloc(strlen(tempdir) + strlen(template) + 1);
110 if (tempname == NULL) 121 if (tempname == NULL)
111 return -1; 122 return -1;
@@ -142,12 +153,6 @@ static int __init create_tmp_file(unsigned long long len)
142 if (fd < 0) 153 if (fd < 0)
143 exit(1); 154 exit(1);
144 155
145 err = fchmod(fd, 0777);
146 if (err < 0) {
147 perror("fchmod");
148 exit(1);
149 }
150
151 /* 156 /*
152 * Seek to len - 1 because writing a character there will 157 * Seek to len - 1 because writing a character there will
153 * increase the file size by one byte, to the desired length. 158 * increase the file size by one byte, to the desired length.
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index c211153ca69a..7801666514ed 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -62,6 +62,7 @@ static void sig_handler_common(int sig, struct siginfo *si, mcontext_t *mc)
62 62
63static int signals_enabled; 63static int signals_enabled;
64static unsigned int signals_pending; 64static unsigned int signals_pending;
65static unsigned int signals_active = 0;
65 66
66void sig_handler(int sig, struct siginfo *si, mcontext_t *mc) 67void sig_handler(int sig, struct siginfo *si, mcontext_t *mc)
67{ 68{
@@ -101,7 +102,12 @@ void timer_alarm_handler(int sig, struct siginfo *unused_si, mcontext_t *mc)
101 102
102 block_signals(); 103 block_signals();
103 104
105 signals_active |= SIGALRM_MASK;
106
104 timer_real_alarm_handler(mc); 107 timer_real_alarm_handler(mc);
108
109 signals_active &= ~SIGALRM_MASK;
110
105 set_signals(enabled); 111 set_signals(enabled);
106} 112}
107 113
@@ -286,8 +292,16 @@ void unblock_signals(void)
286 if (save_pending & SIGIO_MASK) 292 if (save_pending & SIGIO_MASK)
287 sig_handler_common(SIGIO, NULL, NULL); 293 sig_handler_common(SIGIO, NULL, NULL);
288 294
289 if (save_pending & SIGALRM_MASK) 295 /* Do not reenter the handler */
296
297 if ((save_pending & SIGALRM_MASK) && (!(signals_active & SIGALRM_MASK)))
290 timer_real_alarm_handler(NULL); 298 timer_real_alarm_handler(NULL);
299
300 /* Rerun the loop only if there is still pending SIGIO and not in TIMER handler */
301
302 if (!(signals_pending & SIGIO_MASK) && (signals_active & SIGALRM_MASK))
303 return;
304
291 } 305 }
292} 306}
293 307
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index b856c66ebd3a..23025d645160 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -172,13 +172,6 @@ static void handle_trap(int pid, struct uml_pt_regs *regs,
172 handle_syscall(regs); 172 handle_syscall(regs);
173} 173}
174 174
175int get_syscall(struct uml_pt_regs *regs)
176{
177 UPT_SYSCALL_NR(regs) = PT_SYSCALL_NR(regs->gp);
178
179 return UPT_SYSCALL_NR(regs);
180}
181
182extern char __syscall_stub_start[]; 175extern char __syscall_stub_start[];
183 176
184static int userspace_tramp(void *stack) 177static int userspace_tramp(void *stack)
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 47f1ff056a54..22a358ef1b0c 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -94,6 +94,8 @@ static int start_ptraced_child(void)
94{ 94{
95 int pid, n, status; 95 int pid, n, status;
96 96
97 fflush(stdout);
98
97 pid = fork(); 99 pid = fork();
98 if (pid == 0) 100 if (pid == 0)
99 ptrace_child(); 101 ptrace_child();