add chdir
[snitchaser:mainline.git] / oldcode / checkpoint / rt_sigprocmask.c
1
2 #include "syscalls.h"
3 #ifdef IN_INJECTOR
4 # include "injector.h"
5 #endif
6
7 #include "libwrapper/signal_defs.h"
8
9 #ifndef SYSCALL_PRINTER
10
11 int SCOPE
12 post_rt_sigprocmask(const struct syscall_regs * regs)
13 {
14         write_eax(regs);
15         if (regs->eax == 0) {
16                 int how = regs->ebx;
17                 int set = regs->ecx;
18                 int oset = regs->edx;
19                 int sigsetsize = regs->esi;
20                 write_obj(sigsetsize);
21                 if (sigsetsize != sizeof(k_sigset_t)) {
22                         INJ_WARNING("sigsetsize %d != %d\n",
23                                         sigsetsize, sizeof(k_sigset_t));
24                         return 0;
25                 }
26
27                 if (set) {
28                         k_sigset_t mask;
29                         __dup_mem(&mask, set, sigsetsize);
30
31                         sigdelsetmask(&mask, sigmask(SIGKILL)|sigmask(SIGSTOP));
32                         if (how == SIG_BLOCK) {
33                                 sigorsets(&state_vector.sigmask,
34                                         &state_vector.sigmask,
35                                         &mask);
36                         } else if (how == SIG_UNBLOCK) {
37                                 signandsets(&state_vector.sigmask,
38                                         &state_vector.sigmask,
39                                         &mask);
40                         } else {
41                                 /*  SIG_SETMASK */
42                                 state_vector.sigmask = mask;
43                         }
44                 }
45                 
46                 write_obj(oset);
47                 if (oset) {
48                         if (set == 0) {
49                                 k_sigset_t mask;
50                                 __dup_mem(&mask, oset, sigsetsize);
51                                 state_vector.sigmask = mask;
52                         }
53                         write_mem(oset, sigsetsize);
54                 }
55         }
56         return 0;
57 }
58
59 int SCOPE
60 replay_rt_sigprocmask(const struct syscall_regs * regs)
61 {
62         int32_t ret = read_int32();
63         if (ret == 0) {
64                 int sigsetsize = read_int32();
65                 ASSERT(sigsetsize == regs->esi, regs, "");
66                 if (sigsetsize == sizeof(k_sigset_t)) {
67                         int oset = read_int32();
68                         ASSERT(oset == regs->edx, regs, "");
69                         if (oset)
70                                 read_mem(oset, sigsetsize);
71                 }
72         }
73         return ret;
74 }
75 #else
76
77 void
78 output_rt_sigprocmask(int nr)
79 {
80         int32_t ret = read_eax();
81         if (ret == 0) {
82                 int sigsetsize;
83                 read_obj(sigsetsize);
84                 if (sigsetsize == sizeof(k_sigset_t)) {
85                         int32_t oset;
86                         read_obj(oset);
87                         if (oset)
88                                 skip(sigsetsize);
89                 }
90         }
91         printf("rt_sigprocmask:\t%d\n", ret);
92 }
93 #endif
94