Whamcloud - gitweb
b=2776
[fs/lustre-release.git] / lustre / kernel_patches / patches / bproc-patch-2.4.20
1 $Id: bproc-patch-2.4.20,v 1.6 2004/03/19 01:09:33 zab Exp $
2
3 Index: linux/fs/exec.c
4 ===================================================================
5 --- linux.orig/fs/exec.c        2003-09-03 17:52:00.000000000 -0400
6 +++ linux/fs/exec.c     2003-09-03 17:52:04.000000000 -0400
7 @@ -38,6 +38,7 @@
8  #include <linux/utsname.h>
9  #define __NO_VERSION__
10  #include <linux/module.h>
11 +#include <linux/bproc.h>
12  
13  #include <asm/uaccess.h>
14  #include <asm/pgalloc.h>
15 @@ -953,9 +954,11 @@
16         xa_call_actions (XA_EXEC, XA_KOE, NULL);
17  
18         retval = search_binary_handler(&bprm,regs);
19 -       if (retval >= 0)
20 +       if (retval >= 0) {
21                 /* execve success */
22 +               bproc_hook_im(do_execve,());
23                 return retval;
24 +       }
25  
26  out:
27         /* Something went wrong, return the inode and free the argument pages*/
28 Index: linux/fs/binfmt_script.c
29 ===================================================================
30 --- linux.orig/fs/binfmt_script.c       2002-08-02 20:39:45.000000000 -0400
31 +++ linux/fs/binfmt_script.c    2003-09-03 17:52:04.000000000 -0400
32 @@ -13,6 +13,7 @@
33  #include <linux/init.h>
34  #include <linux/file.h>
35  #include <linux/smp_lock.h>
36 +#include <linux/bproc.h>
37  
38  static int load_script(struct linux_binprm *bprm,struct pt_regs *regs)
39  {
40 @@ -67,7 +68,7 @@
41          * user environment and arguments are stored.
42          */
43         remove_arg_zero(bprm);
44 -       retval = copy_strings_kernel(1, &bprm->filename, bprm);
45 +       retval = copy_strings_kernel(1,bproc_hook_v(&bprm->filename,load_script,(&bprm->filename)), bprm);
46         if (retval < 0) return retval; 
47         bprm->argc++;
48         if (i_arg) {
49 Index: linux/fs/binfmt_elf.c
50 ===================================================================
51 --- linux.orig/fs/binfmt_elf.c  2002-08-02 20:39:45.000000000 -0400
52 +++ linux/fs/binfmt_elf.c       2003-09-03 17:52:04.000000000 -0400
53 @@ -73,7 +73,7 @@
54  #define ELF_PAGEOFFSET(_v) ((_v) & (ELF_MIN_ALIGN-1))
55  #define ELF_PAGEALIGN(_v) (((_v) + ELF_MIN_ALIGN - 1) & ~(ELF_MIN_ALIGN - 1))
56  
57 -static struct linux_binfmt elf_format = {
58 +struct linux_binfmt elf_format = {
59         NULL, THIS_MODULE, load_elf_binary, load_elf_library, elf_core_dump, ELF_EXEC_PAGESIZE
60  };
61  
62 Index: linux/fs/proc/base.c
63 ===================================================================
64 --- linux.orig/fs/proc/base.c   2003-09-03 17:52:00.000000000 -0400
65 +++ linux/fs/proc/base.c        2003-09-03 17:52:04.000000000 -0400
66 @@ -25,6 +25,7 @@
67  #include <linux/string.h>
68  #include <linux/seq_file.h>
69  #include <linux/namespace.h>
70 +#include <linux/bproc.h>
71  
72  /*
73   * For hysterical raisins we keep the same inumbers as in the old procfs.
74 @@ -304,6 +305,7 @@
75         if (!(page = __get_free_page(GFP_KERNEL)))
76                 return -ENOMEM;
77  
78 +       if (bproc_isghost(task)) bproc_hook(refresh_status,(task));
79         length = inode->u.proc_i.op.proc_read(task, (char*)page);
80  
81         if (length < 0) {
82 @@ -976,14 +978,14 @@
83  static int proc_self_readlink(struct dentry *dentry, char *buffer, int buflen)
84  {
85         char tmp[30];
86 -       sprintf(tmp, "%d", current->pid);
87 +       sprintf(tmp, "%d", bproc_hook_imv(current->pid,proc3,()));
88         return vfs_readlink(dentry,buffer,buflen,tmp);
89  }
90  
91  static int proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
92  {
93         char tmp[30];
94 -       sprintf(tmp, "%d", current->pid);
95 +       sprintf(tmp, "%d", bproc_hook_imv(current->pid,proc3,()));
96         return vfs_follow_link(nd,tmp);
97  }      
98  
99 @@ -1031,6 +1033,7 @@
100                         goto out;
101         }
102  
103 +       pid = bproc_hook_imv(pid,proc2,(pid));
104         read_lock(&tasklist_lock);
105         task = find_task_by_pid(pid);
106         if (task)
107 @@ -1082,7 +1085,7 @@
108         index--;
109         read_lock(&tasklist_lock);
110         for_each_task(p) {
111 -               int pid = p->pid;
112 +               int pid = bproc_hook_imv(p->pid,proc1,(p));
113                 if (!pid)
114                         continue;
115                 if (--index >= 0)
116 Index: linux/fs/proc/array.c
117 ===================================================================
118 --- linux.orig/fs/proc/array.c  2002-08-02 20:39:45.000000000 -0400
119 +++ linux/fs/proc/array.c       2003-09-03 17:52:04.000000000 -0400
120 @@ -70,6 +70,7 @@
121  #include <linux/smp.h>
122  #include <linux/signal.h>
123  #include <linux/highmem.h>
124 +#include <linux/bproc.h>
125  
126  #include <asm/uaccess.h>
127  #include <asm/pgtable.h>
128 @@ -130,7 +131,8 @@
129  
130  static inline const char * get_task_state(struct task_struct *tsk)
131  {
132 -       unsigned int state = tsk->state & (TASK_RUNNING |
133 +       unsigned int state = (bproc_hook_v(tsk->state,get_task_state,(tsk)))
134 +                                       & (TASK_RUNNING |
135                                            TASK_INTERRUPTIBLE |
136                                            TASK_UNINTERRUPTIBLE |
137                                            TASK_ZOMBIE |
138 @@ -158,7 +160,8 @@
139                 "Uid:\t%d\t%d\t%d\t%d\n"
140                 "Gid:\t%d\t%d\t%d\t%d\n",
141                 get_task_state(p), p->tgid,
142 -               p->pid, p->pid ? p->p_opptr->pid : 0, 0,
143 +               bproc_hook_imv(p->pid, proc_pid, (p)),
144 +               bproc_hook_imv(p->p_opptr->pid, proc_ppid, (p)), 0,
145                 p->uid, p->euid, p->suid, p->fsuid,
146                 p->gid, p->egid, p->sgid, p->fsgid);
147         read_unlock(&tasklist_lock);    
148 @@ -305,7 +308,7 @@
149         sigset_t sigign, sigcatch;
150         char state;
151         int res;
152 -       pid_t ppid;
153 +       pid_t pid, ppid;
154         struct mm_struct *mm;
155  
156         state = *get_task_state(task);
157 @@ -343,12 +346,14 @@
158         nice = task->nice;
159  
160         read_lock(&tasklist_lock);
161 -       ppid = task->pid ? task->p_opptr->pid : 0;
162 +       pid  = bproc_hook_imv(task->pid, proc_pid, (task)),
163 +       ppid = bproc_hook_imv(task->pid ? task->p_opptr->pid : 0,
164 +                             proc_ppid, (task));
165         read_unlock(&tasklist_lock);
166         res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \
167  %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %lu %lu %ld %lu %lu %lu %lu %lu \
168  %lu %lu %lu %lu %lu %lu %lu %lu %d %d\n",
169 -               task->pid,
170 +               pid,
171                 task->comm,
172                 state,
173                 ppid,
174 Index: linux/kernel/timer.c
175 ===================================================================
176 --- linux.orig/kernel/timer.c   2003-09-03 17:51:01.000000000 -0400
177 +++ linux/kernel/timer.c        2003-09-03 17:52:04.000000000 -0400
178 @@ -22,6 +22,7 @@
179  #include <linux/smp_lock.h>
180  #include <linux/interrupt.h>
181  #include <linux/kernel_stat.h>
182 +#include <linux/bproc.h>
183  
184  #include <asm/uaccess.h>
185  
186 @@ -754,7 +755,7 @@
187   */
188  asmlinkage long sys_getpid(void)
189  {
190 -       return current->tgid;
191 +       return bproc_hook_imv(current->tgid, sys_getpid, ());
192  }
193  
194  /*
195 @@ -788,7 +789,7 @@
196  
197         parent = me->p_opptr;
198         for (;;) {
199 -               pid = parent->pid;
200 +               pid = bproc_hook_imv(parent->pid,sys_getppid,(parent));
201  #if CONFIG_SMP
202  {
203                 struct task_struct *old = parent;
204 Index: linux/kernel/signal.c
205 ===================================================================
206 --- linux.orig/kernel/signal.c  2003-09-03 17:51:01.000000000 -0400
207 +++ linux/kernel/signal.c       2003-09-03 17:52:04.000000000 -0400
208 @@ -16,6 +16,8 @@
209  
210  #include <asm/uaccess.h>
211  
212 +#include <linux/bproc.h>
213 +
214  /*
215   * SLAB caches for signal bits.
216   */
217 @@ -548,6 +550,9 @@
218         if (sig < SIGRTMIN && sigismember(&t->pending.signal, sig))
219                 goto out;
220  
221 +       if (bproc_hook_v(0, send_sig_info, (sig, info, t)))
222 +               goto out;
223 +
224         ret = deliver_signal(sig, info, t);
225  out:
226         spin_unlock_irqrestore(&t->sigmask_lock, flags);
227 @@ -590,6 +595,9 @@
228  kill_pg_info(int sig, struct siginfo *info, pid_t pgrp)
229  {
230         int retval = -EINVAL;
231 +
232 +       if (bproc_hook_imv(0,kill_pg_info, (sig, info, &pgrp, &retval)) == 1)
233 +               return retval;
234         if (pgrp > 0) {
235                 struct task_struct *p;
236  
237 @@ -617,6 +625,7 @@
238  kill_sl_info(int sig, struct siginfo *info, pid_t sess)
239  {
240         int retval = -EINVAL;
241 +       /* XXX bproc: Need ways to deal with session leaders...*/
242         if (sess > 0) {
243                 struct task_struct *p;
244  
245 @@ -640,6 +649,9 @@
246         int error;
247         struct task_struct *p;
248  
249 +       if (bproc_hook_imv(0, kill_proc_info,(sig, info, &pid, &error)) == 1)
250 +               return error;
251 +
252         read_lock(&tasklist_lock);
253         p = find_task_by_pid(pid);
254         error = -ESRCH;
255 @@ -684,6 +696,7 @@
256                 read_unlock(&tasklist_lock);
257                 return count ? retval : -ESRCH;
258         } else if (pid < 0) {
259 +               /* XXX pid masq - do PG stuff. */
260                 return kill_pg_info(sig, info, -pid);
261         } else {
262                 return kill_proc_info(sig, info, pid);
263 @@ -815,6 +828,7 @@
264  EXPORT_SYMBOL(recalc_sigpending);
265  EXPORT_SYMBOL(send_sig);
266  EXPORT_SYMBOL(send_sig_info);
267 +EXPORT_SYMBOL(kill_something_info);
268  EXPORT_SYMBOL(block_all_signals);
269  EXPORT_SYMBOL(unblock_all_signals);
270  
271 Index: linux/kernel/sched.c
272 ===================================================================
273 --- linux.orig/kernel/sched.c   2003-09-03 17:51:05.000000000 -0400
274 +++ linux/kernel/sched.c        2003-09-03 17:52:04.000000000 -0400
275 @@ -30,6 +30,7 @@
276  #include <linux/dump.h>
277  #include <linux/prefetch.h>
278  #include <linux/compiler.h>
279 +#include <linux/bproc.h>
280  
281  #include <asm/uaccess.h>
282  #include <asm/mmu_context.h>
283 @@ -370,6 +371,8 @@
284  
285  inline int wake_up_process(struct task_struct * p)
286  {
287 +       if (p->state == TASK_STOPPED && bproc_ismasq(p))
288 +               bproc_hook(wake_up_process, (p));
289         return try_to_wake_up(p, 0);
290  }
291  
292 Index: linux/kernel/ksyms.c
293 ===================================================================
294 --- linux.orig/kernel/ksyms.c   2003-09-03 17:52:02.000000000 -0400
295 +++ linux/kernel/ksyms.c        2003-09-03 17:52:04.000000000 -0400
296 @@ -68,6 +68,10 @@
297  extern void set_device_ro(kdev_t dev,int flag);
298  
299  extern void *sys_call_table;
300 +extern struct task_struct *child_reaper;
301 +#if defined(CONFIG_BINFMT_ELF)
302 +extern struct linux_binfmt elf_format;
303 +#endif
304  
305  extern struct timezone sys_tz;
306  extern int request_dma(unsigned int dmanr, char * deviceID);
307 @@ -104,9 +108,17 @@
308  EXPORT_SYMBOL(do_munmap);
309  EXPORT_SYMBOL(do_brk);
310  EXPORT_SYMBOL(exit_mm);
311 +EXPORT_SYMBOL(do_exit);
312  EXPORT_SYMBOL(exit_files);
313  EXPORT_SYMBOL(exit_fs);
314  EXPORT_SYMBOL(exit_sighand);
315 +EXPORT_SYMBOL(is_orphaned_pgrp);
316 +EXPORT_SYMBOL(child_reaper);
317 +#if defined(CONFIG_BINFMT_ELF)
318 +EXPORT_SYMBOL(elf_format);
319 +#endif
320 +EXPORT_SYMBOL(alloc_uid);
321 +EXPORT_SYMBOL(free_uid);
322  EXPORT_SYMBOL(copy_fs_struct);
323  EXPORT_SYMBOL_GPL(make_pages_present);
324  
325 @@ -584,6 +596,7 @@
326  EXPORT_SYMBOL(read_ahead);
327  EXPORT_SYMBOL(get_hash_table);
328  EXPORT_SYMBOL(new_inode);
329 +EXPORT_SYMBOL(get_empty_inode);
330  EXPORT_SYMBOL(insert_inode_hash);
331  EXPORT_SYMBOL(remove_inode_hash);
332  EXPORT_SYMBOL(buffer_insert_inode_queue);
333 Index: linux/kernel/fork.c
334 ===================================================================
335 --- linux.orig/kernel/fork.c    2003-09-03 17:52:00.000000000 -0400
336 +++ linux/kernel/fork.c 2003-09-03 17:52:04.000000000 -0400
337 @@ -23,6 +23,8 @@
338  #include <linux/personality.h>
339  #include <linux/compiler.h>
340  
341 +#include <linux/bproc.h>
342 +
343  #include <asm/pgtable.h>
344  #include <asm/pgalloc.h>
345  #include <asm/uaccess.h>
346 @@ -413,6 +415,7 @@
347  
348  static inline int copy_fs(unsigned long clone_flags, struct task_struct * tsk)
349  {
350 +       if (!current->fs) return 0;
351         if (clone_flags & CLONE_FS) {
352                 atomic_inc(&current->fs->count);
353                 return 0;
354 @@ -781,7 +784,8 @@
355          *
356          * Let it rip!
357          */
358 -       retval = p->pid;
359 +       if ((retval = bproc_hook_v(p->pid, do_fork, (p, clone_flags))) < 0)
360 +               goto bad_fork_cleanup_mm;
361         p->tgid = retval;
362         INIT_LIST_HEAD(&p->thread_group);
363  
364 @@ -805,6 +809,7 @@
365         SET_LINKS(p);
366         hash_pid(p);
367         nr_threads++;
368 +       bproc_hook(do_fork_2, (p));
369         write_unlock_irq(&tasklist_lock);
370  
371         if (p->ptrace & PT_PTRACED)
372 @@ -816,6 +821,7 @@
373                 wait_for_completion(&vfork);
374  
375  fork_out:
376 +       bproc_clear_kcall();
377         return retval;
378  
379  bad_fork_cleanup_namespace:
380 Index: linux/kernel/exit.c
381 ===================================================================
382 --- linux.orig/kernel/exit.c    2003-09-03 17:52:00.000000000 -0400
383 +++ linux/kernel/exit.c 2003-09-03 17:52:04.000000000 -0400
384 @@ -22,6 +22,8 @@
385  #include <asm/pgtable.h>
386  #include <asm/mmu_context.h>
387  
388 +#include <linux/bproc.h>
389 +
390  extern void sem_exit (void);
391  extern struct task_struct *child_reaper;
392  
393 @@ -47,6 +49,7 @@
394                 }
395                 task_unlock(p);
396  #endif
397 +               bproc_hook(release,(p));
398                 atomic_dec(&p->user->processes);
399                 free_uid(p->user);
400                 unhash_process(p);
401 @@ -130,7 +133,8 @@
402  
403  int is_orphaned_pgrp(int pgrp)
404  {
405 -       return will_become_orphaned_pgrp(pgrp, 0);
406 +       return bproc_hook_imv(will_become_orphaned_pgrp(pgrp, 0),
407 +                             is_orphaned_pgrp,(pgrp));
408  }
409  
410  static inline int has_stopped_jobs(int pgrp)
411 @@ -170,7 +174,7 @@
412                         p->self_exec_id++;
413  
414                         /* Make sure we're not reparenting to ourselves */
415 -                       p->p_opptr = child_reaper;
416 +                       p->p_opptr = bproc_hook_v(child_reaper, child_reaper, (p));
417  
418                         if (p->pdeath_signal) send_sig(p->pdeath_signal, p, 0);
419                 }
420 @@ -450,6 +454,7 @@
421  #endif
422         __exit_mm(tsk);
423  
424 +       bproc_hook(do_exit, (tsk,code));
425         lock_kernel();
426         sem_exit();
427         __exit_files(tsk);
428 @@ -501,6 +506,7 @@
429  asmlinkage long sys_wait4(pid_t pid,unsigned int * stat_addr, int options, struct rusage * ru)
430  {
431         int flag, retval;
432 +       pid_t orig_pid = pid;
433         DECLARE_WAITQUEUE(wait, current);
434         struct task_struct *tsk;
435  
436 @@ -512,6 +518,9 @@
437         flag = 0;
438         current->state = TASK_INTERRUPTIBLE;
439         read_lock(&tasklist_lock);
440 +       pid = orig_pid;
441 +       if (bproc_hook_imv(0, sys_wait4_1, (&pid, stat_addr, options, ru, &retval)))
442 +               goto end_wait4;         /* handler will unlock tasklist_lock */
443         tsk = current;
444         do {
445                 struct task_struct *p;
446 @@ -535,7 +544,7 @@
447                             && !(options & __WALL))
448                                 continue;
449                         flag = 1;
450 -                       switch (p->state) {
451 +                       switch (bproc_hook_v(p->state,sys_wait4_2,(p))) {
452                         case TASK_STOPPED:
453                                 if (!p->exit_code)
454                                         continue;
455 @@ -547,7 +556,7 @@
456                                         retval = put_user((p->exit_code << 8) | 0x7f, stat_addr);
457                                 if (!retval) {
458                                         p->exit_code = 0;
459 -                                       retval = p->pid;
460 +                                       retval = bproc_hook_imv(p->pid, sys_wait4_3, (p));
461                                 }
462                                 goto end_wait4;
463                         case TASK_ZOMBIE:
464 @@ -559,7 +568,7 @@
465                                         retval = put_user(p->exit_code, stat_addr);
466                                 if (retval)
467                                         goto end_wait4; 
468 -                               retval = p->pid;
469 +                               retval = bproc_hook_imv(p->pid, sys_wait4_3, (p));
470                                 if (p->p_opptr != p->p_pptr) {
471                                         write_lock_irq(&tasklist_lock);
472                                         REMOVE_LINKS(p);
473 @@ -569,6 +578,7 @@
474                                         write_unlock_irq(&tasklist_lock);
475                                 } else
476                                         release_task(p);
477 +                               bproc_hook_im(sys_wait4_4,(retval, options));
478                                 goto end_wait4;
479                         default:
480                                 continue;
481 @@ -593,6 +603,7 @@
482  end_wait4:
483         current->state = TASK_RUNNING;
484         remove_wait_queue(&current->wait_chldexit,&wait);
485 +       bproc_clear_kcall();
486         return retval;
487  }
488  
489 Index: linux/kernel/sys.c
490 ===================================================================
491 --- linux.orig/kernel/sys.c     2003-09-03 17:51:05.000000000 -0400
492 +++ linux/kernel/sys.c  2003-09-03 17:52:04.000000000 -0400
493 @@ -21,6 +21,8 @@
494  #include <asm/uaccess.h>
495  #include <asm/io.h>
496  
497 +#include <linux/bproc.h>
498 +
499  /*
500   * this is where the system-wide overflow UID and GID are defined, for
501   * architectures that now have 32-bit UID/GID but didn't in the past
502 @@ -448,6 +450,7 @@
503         current->fsgid = new_egid;
504         current->egid = new_egid;
505         current->gid = new_rgid;
506 +       bproc_hook_im(set_creds, ());
507         return 0;
508  }
509  
510 @@ -480,6 +483,7 @@
511         }
512         else
513                 return -EPERM;
514 +       bproc_hook_im(set_creds, ());
515         return 0;
516  }
517    
518 @@ -614,6 +618,7 @@
519                 cap_emulate_setxuid(old_ruid, old_euid, old_suid);
520         }
521  
522 +       bproc_hook_im(set_creds, ());
523         return 0;
524  }
525  
526 @@ -658,6 +663,8 @@
527                 cap_emulate_setxuid(old_ruid, old_euid, old_suid);
528         }
529  
530 +       bproc_hook_im(set_creds, ());
531 +       bproc_hook_im(set_creds, ());
532         return 0;
533  }
534  
535 @@ -746,6 +753,7 @@
536                 current->gid = rgid;
537         if (sgid != (gid_t) -1)
538                 current->sgid = sgid;
539 +       bproc_hook_im(set_creds, ());
540         return 0;
541  }
542  
543 @@ -803,6 +811,7 @@
544                 }
545         }
546  
547 +       if (current->fsuid != old_fsuid) bproc_hook_im(set_creds, ());
548         return old_fsuid;
549  }
550  
551 @@ -825,6 +834,8 @@
552                 }
553                 current->fsgid = gid;
554         }
555 +
556 +       if (current->fsgid != old_fsgid) bproc_hook_im(set_creds, ());
557         return old_fsgid;
558  }
559  
560 @@ -860,6 +871,8 @@
561         struct task_struct * p;
562         int err = -EINVAL;
563  
564 +       bproc_hook_imr(sys_setpgid1, (pid, pgid));
565 +
566         if (!pid)
567                 pid = current->pid;
568         if (!pgid)
569 @@ -901,6 +914,7 @@
570  
571  ok_pgid:
572         p->pgrp = pgid;
573 +       if (bproc_isghost(p)) bproc_hook(sys_setpgid2, (p));
574         err = 0;
575  out:
576         /* All paths lead to here, thus we are safe. -DaveM */
577 @@ -910,6 +924,7 @@
578  
579  asmlinkage long sys_getpgid(pid_t pid)
580  {
581 +       bproc_hook_imr(sys_getpgid,(pid));
582         if (!pid) {
583                 return current->pgrp;
584         } else {
585 @@ -930,23 +945,25 @@
586  asmlinkage long sys_getpgrp(void)
587  {
588         /* SMP - assuming writes are word atomic this is fine */
589 -       return current->pgrp;
590 +       return bproc_hook_imv(current->pgrp,sys_getpgrp,());
591  }
592  
593  asmlinkage long sys_getsid(pid_t pid)
594  {
595         if (!pid) {
596 -               return current->session;
597 +               return bproc_hook_imv(current->session,sys_getsid1,());
598         } else {
599                 int retval;
600                 struct task_struct *p;
601 +               if (bproc_hook_imv(0,sys_getsid2, (&pid, &retval))==1)
602 +                       return retval;
603  
604                 read_lock(&tasklist_lock);
605                 p = find_task_by_pid(pid);
606  
607                 retval = -ESRCH;
608                 if(p)
609 -                       retval = p->session;
610 +                       retval = bproc_hook_imv(p->session,sys_getsid3,(p));
611                 read_unlock(&tasklist_lock);
612                 return retval;
613         }
614 @@ -957,6 +974,8 @@
615         struct task_struct * p;
616         int err = -EPERM;
617  
618 +       bproc_hook_imr(sys_setsid,());
619 +
620         read_lock(&tasklist_lock);
621         for_each_task(p) {
622                 if (p->pgrp == current->pid)
623 @@ -1011,6 +1030,7 @@
624         if(copy_from_user(current->groups, grouplist, gidsetsize * sizeof(gid_t)))
625                 return -EFAULT;
626         current->ngroups = gidsetsize;
627 +       bproc_hook_im(set_creds, ());
628         return 0;
629  }
630  
631 Index: linux/kernel/ptrace.c
632 ===================================================================
633 --- linux.orig/kernel/ptrace.c  2003-09-03 17:51:04.000000000 -0400
634 +++ linux/kernel/ptrace.c       2003-09-03 17:52:04.000000000 -0400
635 @@ -12,6 +12,7 @@
636  #include <linux/mm.h>
637  #include <linux/highmem.h>
638  #include <linux/smp_lock.h>
639 +#include <linux/bproc.h>
640  
641  #include <asm/pgtable.h>
642  #include <asm/uaccess.h>
643 @@ -25,8 +26,13 @@
644         if (!(child->ptrace & PT_PTRACED))
645                 return -ESRCH;
646  
647 -       if (child->p_pptr != current)
648 -               return -ESRCH;
649 +       if (child->p_pptr != current &&
650 +           !bproc_hook_v(0,ptrace_slave_call,
651 +                         (PTRACE_DETACH, child, current->bproc.arg)))
652 +               return -ESRCH;
653 +
654 +       if (bproc_isghost(child))
655 +               return 0;
656  
657         if (!kill) {
658                 if (child->state != TASK_STOPPED)
659 @@ -55,6 +61,7 @@
660  
661  int ptrace_attach(struct task_struct *task)
662  {
663 +       long ret;
664         task_lock(task);
665         if (task->pid <= 1)
666                 goto bad;
667 @@ -83,16 +90,22 @@
668                 task->ptrace |= PT_PTRACE_CAP;
669         task_unlock(task);
670  
671 +       ret = 0;
672         write_lock_irq(&tasklist_lock);
673         if (task->p_pptr != current) {
674 +               if (bproc_isghost(current) && !bproc_isghost(task)) ret = 1;
675                 REMOVE_LINKS(task);
676                 task->p_pptr = current;
677                 SET_LINKS(task);
678         }
679 +       if (bproc_ismasq(task))
680 +               bproc_hook(ptrace_attach, (task, current->bproc.arg, &ret));
681         write_unlock_irq(&tasklist_lock);
682 -
683 -       send_sig(SIGSTOP, task, 1);
684 -       return 0;
685 +       if (bproc_isghost(task))
686 +               bproc_hook(ptraceg,(PTRACE_ATTACH, task, 0, 0, &ret, 0));
687 +       else
688 +               send_sig(SIGSTOP, task, 1);
689 +       return ret;
690  
691  bad:
692         task_unlock(task);
693 @@ -101,6 +114,7 @@
694  
695  int ptrace_detach(struct task_struct *child, unsigned int data)
696  {
697 +       long ret = 0;
698         if ((unsigned long) data > _NSIG)
699                 return  -EIO;
700  
701 @@ -111,14 +125,19 @@
702         child->ptrace = 0;
703         child->exit_code = data;
704         write_lock_irq(&tasklist_lock);
705 +       if (bproc_isghost(current) && !bproc_isghost(child) && 
706 +           child->p_pptr != child->p_opptr)
707 +               ret = 1;
708         REMOVE_LINKS(child);
709 +       if (bproc_ismasq(child))
710 +               bproc_hook(ptrace_detach,(child,(long*)&ret));
711         child->p_pptr = child->p_opptr;
712         SET_LINKS(child);
713         write_unlock_irq(&tasklist_lock);
714  
715         /* .. and wake it up. */
716         wake_up_process(child);
717 -       return 0;
718 +       return ret;
719  }
720  
721  /*
722 Index: linux/kernel/Makefile
723 ===================================================================
724 --- linux.orig/kernel/Makefile  2003-09-03 17:51:06.000000000 -0400
725 +++ linux/kernel/Makefile       2003-09-03 17:52:04.000000000 -0400
726 @@ -9,7 +9,7 @@
727  
728  O_TARGET := kernel.o
729  
730 -export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o printk.o
731 +export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o printk.o bproc_hook.o
732  
733  obj-y     = sched.o dma.o fork.o exec_domain.o panic.o printk.o \
734             module.o exit.o itimer.o info.o time.o softirq.o resource.o \
735 @@ -24,6 +24,7 @@
736  obj-$(CONFIG_MODULES) += ksyms.o
737  obj-$(CONFIG_PM) += pm.o
738  obj-$(CONFIG_KALLSYMS) += kallsyms.o
739 +obj-$(CONFIG_BPROC) += bproc_hook.o
740  
741  ifneq ($(CONFIG_IA64),y)
742  # According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
743 Index: linux/kernel/bproc_hook.c
744 ===================================================================
745 --- linux.orig/kernel/bproc_hook.c      2003-09-03 17:52:04.000000000 -0400
746 +++ linux/kernel/bproc_hook.c   2003-09-03 17:52:04.000000000 -0400
747 @@ -0,0 +1,36 @@
748 +/*-------------------------------------------------------------------------
749 + *  bproc_hook.c: Beowulf distributed PID space (bproc) definitions
750 + *
751 + *  Copyright (C) 2000 by Erik Hendriks <hendriks@scyld.com>
752 + *
753 + *  This program is free software; you can redistribute it and/or modify
754 + *  it under the terms of the GNU General Public License as published by
755 + *  the Free Software Foundation; either version 2 of the License, or
756 + *  (at your option) any later version.
757 + *
758 + *  This program is distributed in the hope that it will be useful,
759 + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
760 + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
761 + *  GNU General Public License for more details.
762 + *
763 + *  You should have received a copy of the GNU General Public License
764 + *  along with this program; if not, write to the Free Software
765 + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
766 + *
767 + * $Id: bproc-patch-2.4.20,v 1.6 2004/03/19 01:09:33 zab Exp $
768 + *-----------------------------------------------------------------------*/
769 +#include <linux/kernel.h>
770 +#include <linux/sched.h>
771 +#include <linux/module.h>
772 +
773 +#define bprocdeclhook(ret,func,args) \
774 +        ret (* bproc_hook_ ## func ## _hook) args = 0;\
775 +        EXPORT_SYMBOL( bproc_hook_ ## func ## _hook )
776 +
777 +#include <linux/bproc.h>
778 +
779 +/*
780 + * Local variables:
781 + * c-basic-offset: 4
782 + * End:
783 + */
784 Index: linux/include/linux/sched.h
785 ===================================================================
786 --- linux.orig/include/linux/sched.h    2003-09-03 17:51:06.000000000 -0400
787 +++ linux/include/linux/sched.h 2003-09-03 17:52:04.000000000 -0400
788 @@ -430,6 +430,14 @@
789  
790  /* journalling filesystem info */
791         void *journal_info;
792 +
793 +/* bproc */
794 +       struct {
795 +               long flag;
796 +               long arg;
797 +               struct bproc_masq_proc_t  *masq;
798 +               struct bproc_ghost_proc_t *ghost;
799 +       } bproc;
800  };
801  
802  /*
803 @@ -526,6 +534,7 @@
804      alloc_lock:                SPIN_LOCK_UNLOCKED,                             \
805      exit_actions:       NULL,                                          \
806      journal_info:      NULL,                                           \
807 +    bproc:             {0, 0, 0, 0}                                    \
808  }
809  
810  
811 Index: linux/include/linux/bproc.h
812 ===================================================================
813 --- linux.orig/include/linux/bproc.h    2003-09-03 17:52:04.000000000 -0400
814 +++ linux/include/linux/bproc.h 2003-09-03 17:52:04.000000000 -0400
815 @@ -0,0 +1,155 @@
816 +/*-------------------------------------------------------------------------
817 + *  bproc.h: Beowulf distributed PID space (bproc) definitions
818 + *
819 + *  Copyright (C) 1999-2001 by Erik Hendriks <erik@hendriks.cx>
820 + *
821 + *  This program is free software; you can redistribute it and/or modify
822 + *  it under the terms of the GNU General Public License as published by
823 + *  the Free Software Foundation; either version 2 of the License, or
824 + *  (at your option) any later version.
825 + *
826 + *  This program is distributed in the hope that it will be useful,
827 + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
828 + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
829 + *  GNU General Public License for more details.
830 + *
831 + *  You should have received a copy of the GNU General Public License
832 + *  along with this program; if not, write to the Free Software
833 + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
834 + *
835 + * $Id: bproc-patch-2.4.20,v 1.6 2004/03/19 01:09:33 zab Exp $
836 + *-----------------------------------------------------------------------*/
837 +#ifndef _LINUX_BPROC_H
838 +#define _LINUX_BPROC_H
839 +
840 +#include <linux/config.h>
841 +#include <linux/types.h>
842 +
843 +#ifdef CONFIG_BPROC
844 +
845 +#ifndef bprocdeclhook
846 +/* Function pointers for bproc hooks. */
847 +#define bprocdeclhook(ret,func,args)  extern ret (* bproc_hook_ ## func ## _hook) args
848 +#endif
849 +
850 +struct bproc_ghost_proc_t;
851 +struct task_struct;
852 +struct rusage;
853 +struct siginfo;
854 +
855 +/*----- fs/exec.c -------------------------------------------------------*/
856 +bprocdeclhook(void,  do_execve,       (void));
857 +/*----- fs/binfmt_script.c ----------------------------------------------*/
858 +bprocdeclhook(char**,load_script,     (char **));
859 +/*----- fs/proc/array.c ----------------------------------------------------*/
860 +bprocdeclhook(void,  refresh_status,  (struct task_struct *));
861 +bprocdeclhook(int,   get_task_state,  (struct task_struct *));
862 +bprocdeclhook(int,   proc_pid,        (struct task_struct *));
863 +bprocdeclhook(int,   proc_ppid,       (struct task_struct *));
864 +bprocdeclhook(int,   proc1,           (struct task_struct *));
865 +bprocdeclhook(int,   proc2,           (int));
866 +bprocdeclhook(int,   proc3,           (void));
867 +/*----- kernel/timer.c --------------------------------------------------*/
868 +bprocdeclhook(int,   sys_getpid,      (void));
869 +bprocdeclhook(int,   sys_getppid,     (struct task_struct *));
870 +/*----- kernel/sched.c --------------------------------------------------*/
871 +bprocdeclhook(void,  wake_up_process, (struct task_struct *));
872 +/*----- kernel/exit.c ---------------------------------------------------*/
873 +bprocdeclhook(void,  release,         (struct task_struct *));
874 +bprocdeclhook(int,   is_orphaned_pgrp,(int));
875 +bprocdeclhook(struct task_struct *,child_reaper,(struct task_struct *));
876 +bprocdeclhook(void,  do_exit,         (struct task_struct *, long code));
877 +bprocdeclhook(int,   sys_wait4_1,     (pid_t *, unsigned int *, int,
878 +                                      struct rusage *, int *));
879 +bprocdeclhook(long,  sys_wait4_2,     (struct task_struct *));
880 +bprocdeclhook(int,   sys_wait4_3,     (struct task_struct *));
881 +bprocdeclhook(void,  sys_wait4_4,     (pid_t, int options));
882 +/*----- kernel/fork.c ---------------------------------------------------*/
883 +bprocdeclhook(int,   do_fork,         (struct task_struct *, unsigned long));
884 +bprocdeclhook(void,  do_fork_2,       (struct task_struct *));
885 +/*----- kernel/signal.c -------------------------------------------------*/
886 +bprocdeclhook(int,   send_sig_info,   (int, struct siginfo *,
887 +                                      struct task_struct *));
888 +bprocdeclhook(int,   kill_pg_info,    (int, struct siginfo *, pid_t *, int *));
889 +bprocdeclhook(int,   kill_proc_info,  (int, struct siginfo *, pid_t *, int *));
890 +/*----- kernel/sys.c ----------------------------------------------------*/
891 +bprocdeclhook(int,   sys_setpgid1,    (pid_t, pid_t));
892 +bprocdeclhook(void,  sys_setpgid2,    (struct task_struct *p));
893 +bprocdeclhook(int,   sys_getpgid,     (pid_t pid));
894 +bprocdeclhook(int,   sys_getpgrp,     (void));
895 +bprocdeclhook(int,   sys_getsid1,     (void));
896 +bprocdeclhook(int,   sys_getsid2,     (pid_t *pid, int *error));
897 +bprocdeclhook(int,   sys_getsid3,     (struct task_struct *p));
898 +bprocdeclhook(int,   sys_setsid,      (void));
899 +bprocdeclhook(void,  set_creds,       (void));
900 +/*----- arch/???/kernel/ptrace.c,signal.c -------------------------------*/
901 +bprocdeclhook(void,  stop_notify,     (int));
902 +bprocdeclhook(int,   ptracem,         (long, long *, long, long,
903 +                                      long *, long *));
904 +bprocdeclhook(void,  ptrace_attach,   (struct task_struct *, long, long *));
905 +bprocdeclhook(void,  ptraceg,         (long, struct task_struct *, long,
906 +                                      long, long *, long *));
907 +bprocdeclhook(int,   ptrace_slave_call,(long, struct task_struct *, long));
908 +bprocdeclhook(void,  ptrace_detach,   (struct task_struct *, long *));
909 +bprocdeclhook(int,   sys_execve,      (struct pt_regs *, char *,
910 +                                      char **, char **));
911 +
912 +/* Macro suffixes:
913 + * (none)   = execute this hook if it's present.
914 + * im       = if masq'ed
915 + * nkc      = no kernel call (kcall must be 0 to call hook)
916 + * r        = return the value of this hook
917 + * v        = hook returns a value.
918 + */
919 +#define hookname(func) bproc_hook_ ## func ## _hook
920 +#define bproc_hook(func,args)          do{if(hookname(func))hookname(func)args;}while(0)
921 +#define bproc_hook_im(func,args)       do{if(hookname(func)&&current->bproc.masq)hookname(func)args;}while(0)
922 +#define bproc_hook_imr(func,args)      do{if(hookname(func)&&current->bproc.masq)return hookname(func)args;}while(0)
923 +#define bproc_hook_v(defl,func,args)   ( hookname(func)                      ?hookname(func)args:defl)
924 +#define bproc_hook_imv(defl,func,args) ((hookname(func)&&current->bproc.masq)?hookname(func)args:defl)
925 +
926 +#define bproc_isghost(tsk)             ((tsk)->bproc.ghost != 0)
927 +#define bproc_ismasq(tsk)              ((tsk)->bproc.masq != 0)
928 +#define bproc_set_arg(x)               do{current->bproc.arg=(x);}while(0)
929 +
930 +/* Kernel call weirdness... a kernel call is a call made from the
931 + * kernel which we do not want to be subject to the usual rules for
932 + * PID masquerading.  This is mostly used for drivers which create and
933 + * possibly wait for kernel threads which they create.  These
934 + * functions are called from the relevant places within the kernel
935 + * (like within kernel_thread) to set a flag so that things will be
936 + * handled correctly later on. */
937 +static inline void bproc_no_kcall(void) {
938 +    current->bproc.flag = (current->bproc.flag & ~3) | 2;
939 +}
940 +static inline void bproc_clear_kcall(void) {
941 +    current->bproc.flag &= ~3;
942 +}
943 +static inline void bproc_kcall(void) {
944 +    if (current->bproc.flag & 2)
945 +       bproc_clear_kcall();
946 +    else
947 +       current->bproc.flag |= 1; /* set kernel call flag */
948 +}
949 +
950 +#else
951 +/* Stubs for when hooks are not compiled in */
952 +#define bproc_hook(func,args)          do{}while(0)
953 +#define bproc_hook_im(func,args)       do{}while(0)
954 +#define bproc_hook_imr(func,args)      do{}while(0)
955 +#define bproc_hook_v(defl,func,args)   (defl)
956 +#define bproc_hook_imv(defl,func,args) (defl)
957 +#define bproc_isghost(tsk)             (0)
958 +#define bproc_ismasq(tsk)              (0)
959 +#define bproc_set_arg(x)               do{}while(0)
960 +#define bproc_no_kcall()               do{}while(0)
961 +#define bproc_clear_kcall()            do{}while(0)
962 +#define bproc_kcall()                  do{}while(0)
963 +#endif
964 +#endif
965 +
966 +/*
967 + * Local variables:
968 + * c-basic-offset: 4
969 + * End:
970 + */
971 Index: linux/include/asm-i386/unistd.h
972 ===================================================================
973 --- linux.orig/include/asm-i386/unistd.h        2002-11-28 18:53:15.000000000 -0500
974 +++ linux/include/asm-i386/unistd.h     2003-09-03 17:52:04.000000000 -0400
975 @@ -349,6 +349,7 @@
976  
977  #ifdef __KERNEL_SYSCALLS__
978  
979 +#include <linux/bproc.h>
980  /*
981   * we need this inline - forking from kernel space will result
982   * in NO COPY ON WRITE (!!!), until an execve is executed. This
983 @@ -373,7 +374,16 @@
984  static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
985  static inline _syscall1(int,close,int,fd)
986  static inline _syscall1(int,_exit,int,exitcode)
987 -static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
988 +static inline pid_t waitpid(pid_t pid, int *wait_stat, int options) {
989 +       long __res;
990 +       bproc_kcall();
991 +       __asm__ volatile ("int $0x80"
992 +                         : "=a" (__res)
993 +                         : "0" (__NR_waitpid),"b" ((long)(pid)),"c" ((long)(wait_stat)),
994 +                         "d" ((long)(options)));
995 +       __syscall_return(pid_t,__res);
996 +}
997 +
998  static inline _syscall1(int,delete_module,const char *,name)
999  
1000  static inline pid_t wait(int * wait_stat)
1001 Index: linux/include/asm-alpha/unistd.h
1002 ===================================================================
1003 --- linux.orig/include/asm-alpha/unistd.h       2002-08-02 20:39:45.000000000 -0400
1004 +++ linux/include/asm-alpha/unistd.h    2003-09-03 17:52:04.000000000 -0400
1005 @@ -519,6 +519,7 @@
1006  
1007  #include <linux/string.h>
1008  #include <linux/signal.h>
1009 +#include <linux/bproc.h>
1010  
1011  extern void sys_idle(void);
1012  static inline void idle(void)
1013 @@ -591,11 +592,13 @@
1014  
1015  static inline pid_t waitpid(int pid, int * wait_stat, int flags)
1016  {
1017 +       bproc_kcall();
1018         return sys_wait4(pid, wait_stat, flags, NULL);
1019  }
1020  
1021  static inline pid_t wait(int * wait_stat)
1022  {
1023 +       bproc_kcall();
1024         return waitpid(-1,wait_stat,0);
1025  }
1026  
1027 Index: linux/net/socket.c
1028 ===================================================================
1029 --- linux.orig/net/socket.c     2003-09-03 17:51:05.000000000 -0400
1030 +++ linux/net/socket.c  2003-09-03 17:52:04.000000000 -0400
1031 @@ -111,7 +111,7 @@
1032   *     in the operation structures but are done directly via the socketcall() multiplexor.
1033   */
1034  
1035 -static struct file_operations socket_file_ops = {
1036 +struct file_operations socket_file_ops = {
1037         llseek:         no_llseek,
1038         read:           sock_read,
1039         write:          sock_write,
1040 @@ -298,13 +298,13 @@
1041         return sb;
1042  }
1043  
1044 -static struct vfsmount *sock_mnt;
1045 +struct vfsmount *sock_mnt;
1046  static DECLARE_FSTYPE(sock_fs_type, "sockfs", sockfs_read_super, FS_NOMOUNT);
1047  static int sockfs_delete_dentry(struct dentry *dentry)
1048  {
1049         return 1;
1050  }
1051 -static struct dentry_operations sockfs_dentry_operations = {
1052 +struct dentry_operations sockfs_dentry_operations = {
1053         d_delete:       sockfs_delete_dentry,
1054  };
1055  
1056 Index: linux/net/netsyms.c
1057 ===================================================================
1058 --- linux.orig/net/netsyms.c    2003-09-03 17:52:04.000000000 -0400
1059 +++ linux/net/netsyms.c 2003-09-03 17:52:04.000000000 -0400
1060 @@ -599,4 +599,11 @@
1061  EXPORT_SYMBOL(wireless_send_event);
1062  #endif /* CONFIG_NET_RADIO || CONFIG_NET_PCMCIA_RADIO */
1063  
1064 +extern struct vfsmount *sock_mnt;
1065 +extern struct dentry_operations sockfs_dentry_operations;
1066 +extern struct file_operations socket_file_ops;
1067 +EXPORT_SYMBOL(sock_mnt);
1068 +EXPORT_SYMBOL(sockfs_dentry_operations);
1069 +EXPORT_SYMBOL(socket_file_ops);
1070 +
1071  #endif  /* CONFIG_NET */
1072 Index: linux/arch/i386/config.in
1073 ===================================================================
1074 --- linux.orig/arch/i386/config.in      2003-09-03 17:51:06.000000000 -0400
1075 +++ linux/arch/i386/config.in   2003-09-03 17:52:04.000000000 -0400
1076 @@ -285,6 +285,7 @@
1077  
1078  bool 'System V IPC' CONFIG_SYSVIPC
1079  bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT
1080 +bool 'Beowulf Distributed Process Space' CONFIG_BPROC
1081  bool 'Sysctl support' CONFIG_SYSCTL
1082  if [ "$CONFIG_PROC_FS" = "y" ]; then
1083     choice 'Kernel core (/proc/kcore) format' \
1084 Index: linux/arch/i386/kernel/signal.c
1085 ===================================================================
1086 --- linux.orig/arch/i386/kernel/signal.c        2002-08-02 20:39:42.000000000 -0400
1087 +++ linux/arch/i386/kernel/signal.c     2003-09-03 17:52:04.000000000 -0400
1088 @@ -20,6 +20,7 @@
1089  #include <linux/stddef.h>
1090  #include <linux/tty.h>
1091  #include <linux/personality.h>
1092 +#include <linux/bproc.h>
1093  #include <asm/ucontext.h>
1094  #include <asm/uaccess.h>
1095  #include <asm/i387.h>
1096 @@ -612,6 +613,7 @@
1097                         /* Let the debugger run.  */
1098                         current->exit_code = signr;
1099                         current->state = TASK_STOPPED;
1100 +                       bproc_hook_im(stop_notify,(signr));
1101                         notify_parent(current, SIGCHLD);
1102                         schedule();
1103  
1104 @@ -670,6 +672,7 @@
1105                                 struct signal_struct *sig;
1106                                 current->state = TASK_STOPPED;
1107                                 current->exit_code = signr;
1108 +                               bproc_hook_im(stop_notify,(signr));
1109                                 sig = current->p_pptr->sig;
1110                                 if (sig && !(sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
1111                                         notify_parent(current, SIGCHLD);
1112 Index: linux/arch/i386/kernel/ptrace.c
1113 ===================================================================
1114 --- linux.orig/arch/i386/kernel/ptrace.c        2002-08-02 20:39:42.000000000 -0400
1115 +++ linux/arch/i386/kernel/ptrace.c     2003-09-03 17:52:04.000000000 -0400
1116 @@ -21,6 +21,8 @@
1117  #include <asm/i387.h>
1118  #include <asm/debugreg.h>
1119  
1120 +#include <linux/bproc.h>
1121 +
1122  /*
1123   * does not yet catch signals sent when the child dies.
1124   * in exit.c or in signal.c.
1125 @@ -152,6 +154,15 @@
1126         struct task_struct *child;
1127         struct user * dummy = NULL;
1128         int i, ret;
1129 +       long orig_pid;
1130 +
1131 +       orig_pid = pid;
1132 + retry_ptrace:
1133 +       pid = orig_pid;
1134 +       if (bproc_hook_imv(0, ptracem, (request,&pid,addr,data,(long*)&ret,0))) {
1135 +               if (ret == -ELOOP) goto retry_ptrace;
1136 +               return ret;
1137 +       }
1138  
1139         lock_kernel();
1140         ret = -EPERM;
1141 @@ -178,14 +189,21 @@
1142                 goto out_tsk;
1143  
1144         if (request == PTRACE_ATTACH) {
1145 +               bproc_set_arg(addr);
1146                 ret = ptrace_attach(child);
1147                 goto out_tsk;
1148         }
1149  
1150 +       bproc_set_arg(request == PTRACE_DETACH ? addr : 0);
1151         ret = ptrace_check_attach(child, request == PTRACE_KILL);
1152         if (ret < 0)
1153                 goto out_tsk;
1154  
1155 +       if (bproc_isghost(child)) {
1156 +               bproc_hook(ptraceg, (request,child,addr,data,(long*)&ret,0));
1157 +               goto out_tsk;
1158 +       }
1159 +
1160         switch (request) {
1161         /* when I and D space are separate, these will need to be fixed. */
1162         case PTRACE_PEEKTEXT: /* read word at location addr. */ 
1163 @@ -427,6 +445,7 @@
1164         free_task_struct(child);
1165  out:
1166         unlock_kernel();
1167 +       if (ret == -ELOOP) goto retry_ptrace;
1168         return ret;
1169  }
1170  
1171 @@ -440,6 +459,7 @@
1172         current->exit_code = SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
1173                                         ? 0x80 : 0);
1174         current->state = TASK_STOPPED;
1175 +       bproc_hook_im(stop_notify,(SIGTRAP));
1176         notify_parent(current, SIGCHLD);
1177         schedule();
1178         /*
1179 Index: linux/arch/i386/kernel/process.c
1180 ===================================================================
1181 --- linux.orig/arch/i386/kernel/process.c       2003-09-03 17:51:02.000000000 -0400
1182 +++ linux/arch/i386/kernel/process.c    2003-09-03 17:52:04.000000000 -0400
1183 @@ -33,6 +33,7 @@
1184  #include <linux/reboot.h>
1185  #include <linux/init.h>
1186  #include <linux/mc146818rtc.h>
1187 +#include <linux/bproc.h>
1188  
1189  #include <asm/uaccess.h>
1190  #include <asm/pgtable.h>
1191 @@ -489,6 +490,7 @@
1192  {
1193         long retval, d0;
1194  
1195 +       bproc_kcall();
1196         __asm__ __volatile__(
1197                 "movl %%esp,%%esi\n\t"
1198                 "int $0x80\n\t"         /* Linux/i386 system call */
1199 @@ -789,6 +791,11 @@
1200                 current->ptrace &= ~PT_DTRACE;
1201         putname(filename);
1202  out:
1203 +       if (error == -ENOENT)
1204 +               error = bproc_hook_imv(error, sys_execve,
1205 +                                      (&regs,(char *)regs.ebx,
1206 +                                       (char **)regs.ecx, (char **)regs.edx));
1207 +
1208         return error;
1209  }
1210  
1211 Index: linux/arch/i386/kernel/i386_ksyms.c
1212 ===================================================================
1213 --- linux.orig/arch/i386/kernel/i386_ksyms.c    2003-09-03 17:51:04.000000000 -0400
1214 +++ linux/arch/i386/kernel/i386_ksyms.c 2003-09-03 17:52:04.000000000 -0400
1215 @@ -107,6 +107,11 @@
1216  EXPORT_SYMBOL(__generic_copy_to_user);
1217  EXPORT_SYMBOL(strnlen_user);
1218  
1219 +asmlinkage void ret_from_sys_call(void) __asm__("ret_from_sys_call");
1220 +EXPORT_SYMBOL_NOVERS(ret_from_sys_call);
1221 +asmlinkage void syscall_trace(void);
1222 +EXPORT_SYMBOL(syscall_trace);
1223 +
1224  EXPORT_SYMBOL(pci_alloc_consistent);
1225  EXPORT_SYMBOL(pci_free_consistent);
1226  
1227 Index: linux/arch/alpha/config.in
1228 ===================================================================
1229 --- linux.orig/arch/alpha/config.in     2003-09-03 17:51:04.000000000 -0400
1230 +++ linux/arch/alpha/config.in  2003-09-03 17:52:04.000000000 -0400
1231 @@ -271,6 +271,7 @@
1232  
1233  bool 'Networking support' CONFIG_NET
1234  bool 'System V IPC' CONFIG_SYSVIPC
1235 +bool 'Beowulf Distributed Process Space' CONFIG_BPROC
1236  bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT
1237  bool 'Sysctl support' CONFIG_SYSCTL
1238  if [ "$CONFIG_PROC_FS" = "y" ]; then
1239 Index: linux/arch/alpha/kernel/signal.c
1240 ===================================================================
1241 --- linux.orig/arch/alpha/kernel/signal.c       2002-08-02 20:39:42.000000000 -0400
1242 +++ linux/arch/alpha/kernel/signal.c    2003-09-03 17:52:04.000000000 -0400
1243 @@ -23,6 +23,7 @@
1244  #include <asm/uaccess.h>
1245  #include <asm/sigcontext.h>
1246  #include <asm/ucontext.h>
1247 +#include <linux/bproc.h>
1248  
1249  #include "proto.h"
1250  
1251 @@ -643,6 +644,7 @@
1252                         /* Let the debugger run.  */
1253                         current->exit_code = signr;
1254                         current->state = TASK_STOPPED;
1255 +                       bproc_hook_im(stop_notify,(signr));
1256                         notify_parent(current, SIGCHLD);
1257                         schedule();
1258                         single_stepping |= ptrace_cancel_bpt(current);
1259 @@ -701,6 +703,7 @@
1260                         case SIGSTOP:
1261                                 current->state = TASK_STOPPED;
1262                                 current->exit_code = signr;
1263 +                               bproc_hook_im(stop_notify,(signr));
1264                                 if (!(current->p_pptr->sig->action[SIGCHLD-1]
1265                                       .sa.sa_flags & SA_NOCLDSTOP))
1266                                         notify_parent(current, SIGCHLD);
1267 Index: linux/arch/alpha/kernel/osf_sys.c
1268 ===================================================================
1269 --- linux.orig/arch/alpha/kernel/osf_sys.c      2002-08-02 20:39:42.000000000 -0400
1270 +++ linux/arch/alpha/kernel/osf_sys.c   2003-09-03 17:52:04.000000000 -0400
1271 @@ -33,6 +33,7 @@
1272  #include <linux/file.h>
1273  #include <linux/types.h>
1274  #include <linux/ipc.h>
1275 +#include <linux/bproc.h>
1276  
1277  #include <asm/fpu.h>
1278  #include <asm/io.h>
1279 @@ -219,8 +220,8 @@
1280          * isn't actually going to matter, as if the parent happens
1281          * to change we can happily return either of the pids.
1282          */
1283 -       (&regs)->r20 = tsk->p_opptr->tgid;
1284 -       return tsk->tgid;
1285 +       (&regs)->r20 = bproc_hook_imv(tsk->p_opptr->tgid,sys_getppid,(tsk->p_opptr));
1286 +       return bproc_hook_imv(tsk->tgid,sys_getpid,());
1287  }
1288  
1289  asmlinkage unsigned long osf_mmap(unsigned long addr, unsigned long len,
1290 Index: linux/arch/alpha/kernel/entry.S
1291 ===================================================================
1292 --- linux.orig/arch/alpha/kernel/entry.S        2003-09-03 17:52:01.000000000 -0400
1293 +++ linux/arch/alpha/kernel/entry.S     2003-09-03 17:52:04.000000000 -0400
1294 @@ -212,8 +212,10 @@
1295   * stack buildup, as we can't do system calls from kernel space.
1296   */
1297  .align 3
1298 +.globl  kernel_clone
1299  .ent   kernel_clone
1300  kernel_clone:
1301 +       ldgp    $29,0($27)      /* we can be called from a module */
1302         .frame $30, 0, $26
1303         .prologue 0
1304         subq    $30,6*8,$30
1305 @@ -230,6 +232,23 @@
1306         br      ret_from_sys_call
1307  .end   kernel_clone
1308  
1309 +.align 3
1310 +.globl  ret_to_user_space
1311 +.ent    ret_to_user_space
1312 +ret_to_user_space:     
1313 +       ldgp $29, 0($27)        /* We can jump here from a module */
1314 +       bsr $1, undo_switch_stack
1315 +       lda  $1, 8($31)         /* Set ps = 8 */
1316 +       stq  $1, 0xB8($30)
1317 +
1318 +       /* This tidbit ripped from entSys.  Is this appropriate here ? */
1319 +       blt     $0,syscall_error        /* the call failed */
1320 +       stq     $0,0($30)
1321 +       stq     $31,72($30)             /* a3=0 => no error */
1322 +
1323 +       br ret_from_sys_call
1324 +.end    ret_to_user_space
1325 +       
1326  /*
1327   * arch_kernel_thread(fn, arg, clone_flags)
1328   */
1329 @@ -240,19 +259,24 @@
1330         ldgp    $29,0($27)      /* we can be called from a module */
1331         .frame $30, 4*8, $26
1332         subq    $30,4*8,$30
1333 +       stq     $11,24($30)
1334         stq     $10,16($30)
1335         stq     $9,8($30)
1336 -       lda     $0,CLONE_VM
1337         stq     $26,0($30)
1338         .prologue 1
1339         mov     $16,$9          /* save fn */           
1340         mov     $17,$10         /* save arg */
1341 -       or      $18,$0,$16      /* shuffle flags to front; add CLONE_VM.  */
1342 -       bsr     $26,kernel_clone
1343 +       mov     $18,$11         /* save flags */
1344 +       bsr     $26,bproc_kcall_
1345 +       lda     $0,CLONE_VM
1346 +       or      $11,$0,$16      /* shuffle flags to front; add CLONE_VM.  */
1347 +       jsr     $26,kernel_clone
1348 +       ldgp    $29,0($26)
1349         bne     $20,1f          /* $20 is non-zero in child */
1350         ldq     $26,0($30)
1351         ldq     $9,8($30)
1352         ldq     $10,16($30)
1353 +       ldq     $11,24($30)
1354         addq    $30,4*8,$30
1355         ret     $31,($26),1
1356  /* this is in child: look out as we don't have any stack here.. */
1357 @@ -290,6 +314,7 @@
1358  .end   __kernel_execve
1359  
1360  .align 3
1361 +.globl  do_switch_stack
1362  .ent   do_switch_stack
1363  do_switch_stack:
1364         lda     $30,-SWITCH_STACK_SIZE($30)
1365 @@ -339,6 +364,7 @@
1366  .end do_switch_stack
1367  
1368  .align 3
1369 +.globl  undo_switch_stack
1370  .ent   undo_switch_stack
1371  undo_switch_stack:
1372         ldq     $9,0($30)
1373 @@ -1062,7 +1088,7 @@
1374         .quad alpha_ni_syscall
1375         .quad alpha_ni_syscall
1376         .quad alpha_ni_syscall                  /* 290 */
1377 -       .quad alpha_ni_syscall
1378 +       .quad sys_ni_syscall                    /* bproc: please shut up... */
1379         .quad alpha_ni_syscall
1380         .quad alpha_ni_syscall
1381         .quad alpha_ni_syscall
1382 Index: linux/arch/alpha/kernel/alpha_ksyms.c
1383 ===================================================================
1384 --- linux.orig/arch/alpha/kernel/alpha_ksyms.c  2002-08-02 20:39:42.000000000 -0400
1385 +++ linux/arch/alpha/kernel/alpha_ksyms.c       2003-09-03 17:52:04.000000000 -0400
1386 @@ -164,6 +164,17 @@
1387  EXPORT_SYMBOL(sys_sync);
1388  EXPORT_SYMBOL(sys_wait4);
1389  
1390 +extern void kernel_clone(void);
1391 +extern void ret_to_user_space(void);
1392 +extern void do_switch_stack(void);
1393 +extern void undo_switch_stack(void);
1394 +asmlinkage void syscall_trace(void);
1395 +EXPORT_SYMBOL_NOVERS(kernel_clone);
1396 +EXPORT_SYMBOL_NOVERS(ret_to_user_space);
1397 +EXPORT_SYMBOL_NOVERS(do_switch_stack);
1398 +EXPORT_SYMBOL_NOVERS(undo_switch_stack);
1399 +EXPORT_SYMBOL(syscall_trace);
1400 +
1401  /* Networking helper routines. */
1402  EXPORT_SYMBOL(csum_tcpudp_magic);
1403  EXPORT_SYMBOL(ip_compute_csum);
1404 Index: linux/arch/alpha/kernel/process.c
1405 ===================================================================
1406 --- linux.orig/arch/alpha/kernel/process.c      2001-09-30 15:26:08.000000000 -0400
1407 +++ linux/arch/alpha/kernel/process.c   2003-09-03 17:52:04.000000000 -0400
1408 @@ -30,6 +30,7 @@
1409  #include <linux/reboot.h>
1410  #include <linux/tty.h>
1411  #include <linux/console.h>
1412 +#include <linux/bproc.h>
1413  
1414  #include <asm/reg.h>
1415  #include <asm/uaccess.h>
1416 @@ -430,6 +431,9 @@
1417         error = do_execve(filename, argv, envp, &regs);
1418         putname(filename);
1419  out:
1420 +       if (error == -ENOENT)
1421 +               error = bproc_hook_imv(error, sys_execve,
1422 +                                      (&regs,ufilename,argv,envp));
1423         return error;
1424  }
1425  
1426 @@ -465,3 +469,10 @@
1427         }
1428         return pc;
1429  }
1430 +
1431 +/* This is usually inlined.  It's packaged in a function here so that
1432 + * we can call it from ASM code on this architecture. */
1433 +void bproc_kcall_(void)
1434 +{
1435 +       bproc_kcall();
1436 +}
1437 Index: linux/arch/alpha/kernel/ptrace.c
1438 ===================================================================
1439 --- linux.orig/arch/alpha/kernel/ptrace.c       2001-09-18 20:03:51.000000000 -0400
1440 +++ linux/arch/alpha/kernel/ptrace.c    2003-09-03 17:52:04.000000000 -0400
1441 @@ -13,6 +13,7 @@
1442  #include <linux/ptrace.h>
1443  #include <linux/user.h>
1444  #include <linux/slab.h>
1445 +#include <linux/bproc.h>
1446  
1447  #include <asm/uaccess.h>
1448  #include <asm/pgtable.h>
1449 @@ -248,7 +249,15 @@
1450            int a4, int a5, struct pt_regs regs)
1451  {
1452         struct task_struct *child;
1453 -       long ret;
1454 +       long ret, orig_pid;
1455 +       
1456 +       orig_pid = pid;
1457 + retry_ptrace:
1458 +       pid = orig_pid;
1459 +       if (bproc_hook_imv(0, ptracem, (request,&pid,addr,data,&ret,&regs.r0))) {
1460 +               if (ret == -ELOOP && regs.r0) goto retry_ptrace;
1461 +               return ret;
1462 +       }
1463  
1464         lock_kernel();
1465         DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
1466 @@ -274,6 +283,7 @@
1467         if (!child)
1468                 goto out_notsk;
1469         if (request == PTRACE_ATTACH) {
1470 +               bproc_set_arg(addr);
1471                 ret = ptrace_attach(child);
1472                 goto out;
1473         }
1474 @@ -282,15 +292,20 @@
1475                 DBG(DBG_MEM, ("child not traced\n"));
1476                 goto out;
1477         }
1478 +       if (child->p_pptr != current &&
1479 +           !bproc_hook_v(0,ptrace_slave_call,(request,child,addr))) {
1480 +               DBG(DBG_MEM, ("child not parent of this process\n"));
1481 +               goto out;
1482 +       }
1483 +       if (bproc_isghost(child)) {
1484 +               bproc_hook(ptraceg,(request,child,addr,data,&ret,&regs.r0));
1485 +               goto out;
1486 +       }
1487         if (child->state != TASK_STOPPED) {
1488                 DBG(DBG_MEM, ("child process not stopped\n"));
1489                 if (request != PTRACE_KILL)
1490                         goto out;
1491         }
1492 -       if (child->p_pptr != current) {
1493 -               DBG(DBG_MEM, ("child not parent of this process\n"));
1494 -               goto out;
1495 -       }
1496  
1497         switch (request) {
1498         /* When I and D space are separate, these will need to be fixed.  */
1499 @@ -384,6 +399,7 @@
1500         free_task_struct(child);
1501   out_notsk:
1502         unlock_kernel();
1503 +       if (ret == -ELOOP && regs.r0) goto retry_ptrace;
1504         return ret;
1505  }
1506  
1507 @@ -395,6 +411,7 @@
1508                 return;
1509         current->exit_code = SIGTRAP;
1510         current->state = TASK_STOPPED;
1511 +       bproc_hook_im(stop_notify,(SIGTRAP));
1512         notify_parent(current, SIGCHLD);
1513         schedule();
1514         /*
1515 Index: linux/arch/ppc/config.in
1516 ===================================================================
1517 --- linux.orig/arch/ppc/config.in       2002-11-28 18:53:11.000000000 -0500
1518 +++ linux/arch/ppc/config.in    2003-09-03 17:52:04.000000000 -0400
1519 @@ -162,6 +162,7 @@
1520  bool 'Networking support' CONFIG_NET
1521  bool 'Sysctl support' CONFIG_SYSCTL
1522  bool 'System V IPC' CONFIG_SYSVIPC
1523 +bool 'Beowulf Distributed Process Space' CONFIG_BPROC
1524  bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT
1525  
1526  # only elf supported, a.out is not -- Cort
1527 Index: linux/arch/ppc/kernel/signal.c
1528 ===================================================================
1529 --- linux.orig/arch/ppc/kernel/signal.c 2002-11-28 18:53:11.000000000 -0500
1530 +++ linux/arch/ppc/kernel/signal.c      2003-09-03 17:52:04.000000000 -0400
1531 @@ -29,6 +29,7 @@
1532  #include <linux/unistd.h>
1533  #include <linux/stddef.h>
1534  #include <linux/elf.h>
1535 +#include <linux/bproc.h>
1536  #include <asm/ucontext.h>
1537  #include <asm/uaccess.h>
1538  #include <asm/pgtable.h>
1539 @@ -579,6 +580,7 @@
1540                         /* Let the debugger run.  */
1541                         current->exit_code = signr;
1542                         current->state = TASK_STOPPED;
1543 +                       bproc_hook_im(stop_notify,(signr));
1544                         notify_parent(current, SIGCHLD);
1545                         schedule();
1546  
1547 @@ -636,6 +638,7 @@
1548                         case SIGSTOP:
1549                                 current->state = TASK_STOPPED;
1550                                 current->exit_code = signr;
1551 +                               bproc_hook_im(stop_notify,(signr));
1552                                 if (!(current->p_pptr->sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
1553                                         notify_parent(current, SIGCHLD);
1554                                 schedule();
1555 Index: linux/arch/ppc/kernel/ptrace.c
1556 ===================================================================
1557 --- linux.orig/arch/ppc/kernel/ptrace.c 2002-11-28 18:53:11.000000000 -0500
1558 +++ linux/arch/ppc/kernel/ptrace.c      2003-09-03 17:52:04.000000000 -0400
1559 @@ -27,6 +27,7 @@
1560  #include <linux/errno.h>
1561  #include <linux/ptrace.h>
1562  #include <linux/user.h>
1563 +#include <linux/bproc.h>
1564  
1565  #include <asm/uaccess.h>
1566  #include <asm/page.h>
1567 @@ -161,6 +162,15 @@
1568  {
1569         struct task_struct *child;
1570         int ret = -EPERM;
1571 +       long orig_pid;
1572 +
1573 +       orig_pid = pid;
1574 + retry_ptrace:
1575 +       pid = orig_pid;
1576 +       if (bproc_hook_imv(0, ptracem,(request,&pid,addr,data,(long*)&ret,0))){
1577 +               if (ret == -ELOOP) goto retry_ptrace;
1578 +               return ret;
1579 +       }
1580  
1581         lock_kernel();
1582         if (request == PTRACE_TRACEME) {
1583 @@ -186,14 +196,21 @@
1584                 goto out_tsk;
1585  
1586         if (request == PTRACE_ATTACH) {
1587 +               bproc_set_arg(addr);
1588                 ret = ptrace_attach(child);
1589                 goto out_tsk;
1590         }
1591  
1592 +       bproc_set_arg(request == PTRACE_DETACH ? addr : 0);
1593         ret = ptrace_check_attach(child, request == PTRACE_KILL);
1594         if (ret < 0)
1595                 goto out_tsk;
1596  
1597 +       if (bproc_isghost(child)) {
1598 +               bproc_hook(ptraceg, (request,child,addr,data,(long*)&ret,0));
1599 +               goto out_tsk;
1600 +       }
1601 +
1602         switch (request) {
1603         /* when I and D space are separate, these will need to be fixed. */
1604         case PTRACE_PEEKTEXT: /* read word at location addr. */ 
1605 @@ -342,6 +359,7 @@
1606         free_task_struct(child);
1607  out:
1608         unlock_kernel();
1609 +       if (ret == -ELOOP) goto retry_ptrace;
1610         return ret;
1611  }
1612  
1613 @@ -352,6 +370,7 @@
1614                 return;
1615         current->exit_code = SIGTRAP;
1616         current->state = TASK_STOPPED;
1617 +       bproc_hook_im(stop_notify,(SIGTRAP));
1618         notify_parent(current, SIGCHLD);
1619         schedule();
1620         /*
1621 Index: linux/arch/ppc/kernel/ppc_ksyms.c
1622 ===================================================================
1623 --- linux.orig/arch/ppc/kernel/ppc_ksyms.c      2002-11-28 18:53:11.000000000 -0500
1624 +++ linux/arch/ppc/kernel/ppc_ksyms.c   2003-09-03 17:52:04.000000000 -0400
1625 @@ -366,3 +366,5 @@
1626  EXPORT_SYMBOL_NOVERS(agp_special_page);
1627  #endif /* defined(CONFIG_ALL_PPC) */
1628  
1629 +asmlinkage void ret_from_syscall_1(void) __asm__("ret_from_syscall_1");
1630 +EXPORT_SYMBOL_NOVERS(ret_from_syscall_1);
1631 Index: linux/arch/ppc/kernel/misc.S
1632 ===================================================================
1633 --- linux.orig/arch/ppc/kernel/misc.S   2003-09-03 17:51:02.000000000 -0400
1634 +++ linux/arch/ppc/kernel/misc.S        2003-09-03 17:52:04.000000000 -0400
1635 @@ -901,6 +901,20 @@
1636   *   arch_kernel_thread(fn, arg, flags)
1637   */
1638  _GLOBAL(arch_kernel_thread)
1639 +       stwu    r1,-28(r1)      /* Setup stack frame to save args */
1640 +       mflr    r0
1641 +       stw     r3, 16(r1)
1642 +       stw     r4, 20(r1)
1643 +       stw     r5, 24(r1)
1644 +       stw     r0, 32(r1)
1645 +       bl      bproc_kcall_    /* Call bproc_kcall_ hook */
1646 +       lwz     r0, 32(r1)      /* Restore stack + arguments */
1647 +       lwz     r5, 24(r1)
1648 +       lwz     r4, 20(r1)
1649 +       lwz     r3, 16(r1)
1650 +       mtlr    r0
1651 +       addi    r1,r1,28
1652 +
1653         mr      r6,r3           /* function */
1654         ori     r3,r5,CLONE_VM  /* flags */
1655         li      r0,__NR_clone
1656 @@ -941,7 +955,29 @@
1657  SYSCALL(execve)
1658  SYSCALL(open)
1659  SYSCALL(close)
1660 -SYSCALL(waitpid)
1661 +_GLOBAL(waitpid)
1662 +       stwu    r1,-28(r1)      /* Setup stack frame to save args */
1663 +       mflr    r0
1664 +       stw     r3, 16(r1)
1665 +       stw     r4, 20(r1)
1666 +       stw     r5, 24(r1)
1667 +       stw     r0, 32(r1)
1668 +       bl      bproc_kcall_    /* Call bproc_kcall_ hook */
1669 +       lwz     r0, 32(r1)      /* Restore stack + arguments */
1670 +       lwz     r5, 24(r1)
1671 +       lwz     r4, 20(r1)
1672 +       lwz     r3, 16(r1)
1673 +       mtlr    r0
1674 +       addi    r1,r1,28
1675 +       
1676 +       li      r0,__NR_waitpid
1677 +       sc
1678 +       bnslr
1679 +       lis     r4,errno@ha
1680 +       stw     r3,errno@l(r4)
1681 +       li      r3,-1
1682 +       blr
1683 +
1684  SYSCALL(fork)
1685  SYSCALL(delete_module)
1686  SYSCALL(_exit)
1687 Index: linux/arch/ppc/kernel/process.c
1688 ===================================================================
1689 --- linux.orig/arch/ppc/kernel/process.c        2001-11-26 08:29:17.000000000 -0500
1690 +++ linux/arch/ppc/kernel/process.c     2003-09-03 17:52:04.000000000 -0400
1691 @@ -34,6 +34,7 @@
1692  #include <linux/user.h>
1693  #include <linux/elf.h>
1694  #include <linux/init.h>
1695 +#include <linux/bproc.h>
1696  
1697  #include <asm/pgtable.h>
1698  #include <asm/uaccess.h>
1699 @@ -443,6 +444,10 @@
1700                 current->ptrace &= ~PT_DTRACE;
1701         putname(filename);
1702  out:
1703 +       if (error == -ENOENT)
1704 +               error = bproc_hook_imv(error, sys_execve,
1705 +                                      (regs,(char*)a0,(char**)a1,(char**)a2));
1706 +
1707         return error;
1708  }
1709  
1710 @@ -605,3 +610,10 @@
1711         } while (count++ < 16);
1712         return 0;
1713  }
1714 +
1715 +/* This is usually inlined.  It's packaged in a function here so that
1716 + * we can call it from ASM code on this architecture. */
1717 +void bproc_kcall_(void)
1718 +{
1719 +       bproc_kcall();
1720 +}
1721 Index: linux/fs/inode.c
1722 ===================================================================
1723 --- linux.orig/fs/inode.c       2003-09-03 17:52:00.000000000 -0400
1724 +++ linux/fs/inode.c    2003-09-03 17:52:04.000000000 -0400
1725 @@ -816,6 +816,76 @@
1726         return inode;
1727  }
1728  
1729 +/*
1730 + * This just initializes the inode fields
1731 + * to known values before returning the inode..
1732 + *
1733 + * i_sb, i_ino, i_count, i_state and the lists have
1734 + * been initialized elsewhere..
1735 + */
1736 +static void clean_inode(struct inode *inode)
1737 +{
1738 +       static struct address_space_operations empty_aops;
1739 +       static struct inode_operations empty_iops;
1740 +       static struct file_operations empty_fops;
1741 +       memset(&inode->u, 0, sizeof(inode->u));
1742 +       inode->i_sock = 0;
1743 +       inode->i_op = &empty_iops;
1744 +       inode->i_fop = &empty_fops;
1745 +       inode->i_nlink = 1;
1746 +       atomic_set(&inode->i_writecount, 0);
1747 +       inode->i_size = 0;
1748 +       inode->i_blocks = 0;
1749 +       inode->i_generation = 0;
1750 +       memset(&inode->i_dquot, 0, sizeof(inode->i_dquot));
1751 +       inode->i_pipe = NULL;
1752 +       inode->i_bdev = NULL;
1753 +       inode->i_cdev = NULL;
1754 +       inode->i_data.a_ops = &empty_aops;
1755 +       inode->i_data.host = inode;
1756 +       inode->i_data.gfp_mask = GFP_HIGHUSER;
1757 +       inode->i_mapping = &inode->i_data;
1758 +}
1759 +
1760 +/**
1761 + * get_empty_inode     - obtain an inode
1762 + *
1763 + * This is called by things like the networking layer
1764 + * etc that want to get an inode without any inode
1765 + * number, or filesystems that allocate new inodes with
1766 + * no pre-existing information.
1767 + *
1768 + * On a successful return the inode pointer is returned. On a failure
1769 + * a %NULL pointer is returned. The returned inode is not on any superblock
1770 + * lists.
1771 + */
1772
1773 +struct inode * get_empty_inode(void)
1774 +{
1775 +       static unsigned long last_ino;
1776 +       struct inode * inode;
1777 +
1778 +       spin_lock_prefetch(&inode_lock);
1779 +       
1780 +       inode = (struct inode *) kmem_cache_alloc(inode_cachep, SLAB_KERNEL);
1781 +       if (inode)
1782 +       {
1783 +               spin_lock(&inode_lock);
1784 +               inodes_stat.nr_inodes++;
1785 +               list_add(&inode->i_list, &inode_in_use);
1786 +               inode->i_sb = NULL;
1787 +               inode->i_dev = 0;
1788 +               inode->i_blkbits = 0;
1789 +               inode->i_ino = ++last_ino;
1790 +               inode->i_flags = 0;
1791 +               atomic_set(&inode->i_count, 1);
1792 +               inode->i_state = 0;
1793 +               spin_unlock(&inode_lock);
1794 +               clean_inode(inode);
1795 +       }
1796 +       return inode;
1797 +}
1798 +
1799  /**
1800   *     new_inode       - obtain an inode
1801   *     @sb: superblock
1802 Index: linux/include/linux/fs.h
1803 ===================================================================
1804 --- linux.orig/include/linux/fs.h       2003-09-03 17:52:02.000000000 -0400
1805 +++ linux/include/linux/fs.h    2003-09-03 17:52:04.000000000 -0400
1806 @@ -1440,6 +1440,7 @@
1807  
1808  extern void clear_inode(struct inode *);
1809  extern struct inode *new_inode(struct super_block *sb);
1810 +extern struct inode * get_empty_inode(void);
1811  extern void remove_suid(struct inode *inode);
1812  
1813  extern void insert_inode_hash(struct inode *);
1814 Index: linux/arch/i386/kernel/setup.c
1815 ===================================================================
1816 --- linux.orig/arch/i386/kernel/setup.c 2003-09-03 17:51:01.000000000 -0400
1817 +++ linux/arch/i386/kernel/setup.c      2003-09-03 17:53:05.000000000 -0400
1818 @@ -172,6 +172,8 @@
1819  static u32 disabled_x86_caps[NCAPINTS] __initdata = { 0 };
1820  extern int blk_nohighio;
1821  
1822 +int enable_acpi_smp_table;
1823 +
1824  /*
1825   * This is set up by the setup-routine at boot-time
1826   */