]> git.pld-linux.org Git - packages/kernel.git/blob - linuxabi-2.6.16-0.patch
- updated to 2.6.29.2 (builds and works --without apparmor --without grsecurity)
[packages/kernel.git] / linuxabi-2.6.16-0.patch
1 diff -Nur kernel-source-2.6.16.orig/abi/cxenix/Makefile kernel-source-2.6.16/abi/cxenix/Makefile
2 --- kernel-source-2.6.16.orig/abi/cxenix/Makefile       1970-01-01 10:00:00.000000000 +1000
3 +++ kernel-source-2.6.16/abi/cxenix/Makefile    2006-04-27 18:50:24.000000000 +1000
4 @@ -0,0 +1,7 @@
5 +
6 +abi-cxenix-objs        := sysent.o misc.o stubs.o signal.o pathconf.o utsname.o
7 +
8 +obj-$(CONFIG_ABI_SCO)  += abi-cxenix.o
9 +
10 +abi-cxenix.o: $(abi-cxenix-objs)
11 +       $(LD) -r -o $@ $(abi-cxenix-objs)
12 diff -Nur kernel-source-2.6.16.orig/abi/cxenix/misc.c kernel-source-2.6.16/abi/cxenix/misc.c
13 --- kernel-source-2.6.16.orig/abi/cxenix/misc.c 1970-01-01 10:00:00.000000000 +1000
14 +++ kernel-source-2.6.16/abi/cxenix/misc.c      2006-04-27 18:50:24.000000000 +1000
15 @@ -0,0 +1,294 @@
16 +/*
17 + * misc.c - misc cxenix() subcalls
18 + *
19 + * Copyright (c) 1993,1994 Drew Sullivan
20 + * Copyright (c) 1994-1996 Mike Jagdis
21 + */
22 +
23 +#ident "%W% %G%"
24 +
25 +#include <linux/types.h>
26 +#include <linux/module.h>
27 +#include <linux/errno.h>
28 +#include <linux/kernel.h>
29 +#include <linux/unistd.h>
30 +#include <linux/ptrace.h>
31 +#include <linux/fcntl.h>
32 +#include <linux/time.h>
33 +#include <linux/signal.h>
34 +#include <linux/syscalls.h>
35 +#include <linux/termios.h>
36 +#include <asm/uaccess.h>
37 +
38 +#include <abi/util/trace.h>
39 +#include <abi/util/sysent.h>
40 +#include <abi/svr4/sigaction.h>
41 +
42 +
43 +struct timeb {
44 +       time_t  time;
45 +       u_short millitm;
46 +       short   timezone;
47 +       short   dstflag;
48 +};
49 +
50 +enum {
51 +       XF_UNLCK =      0,
52 +       XF_WRLCK =      1,
53 +       XF_RDLCK =      3,
54 +};
55 +
56 +struct ibcs_flock {
57 +       short l_type;
58 +       short l_whence;
59 +       off_t l_start;
60 +       off_t l_len;
61 +       short l_sysid;
62 +       short l_pid;
63 +};
64 +
65 +
66 +/*
67 + * locking() requires mandatory locking. Processes that attempt to
68 + * read or write a region locked with locking() are required to block.
69 + * You need to build a kernel with mandatory locking support and set
70 + * the permissions on the required file to setgid, no group execute.
71 + */
72 +int
73 +xnx_locking(int fd, int mode, unsigned long size)
74 +{
75 +       struct flock fl;
76 +       mm_segment_t old_fs;
77 +       int error;
78 +
79 +       if ((mode < 0 || mode > 7) && mode != 20) {
80 +#if defined(CONFIG_ABI_TRACE)
81 +               abi_trace(ABI_TRACE_API,
82 +                               "unsupported locking() mode=0x%x\n", mode);
83 +#endif
84 +               return -EINVAL;
85 +       }
86 +
87 +       /*
88 +        * Modes 5, 6 & 7 are very like the fcntl mechanism but
89 +        * we can't just punt to that because the type values are
90 +        * different.
91 +        */
92 +       if (mode > 4 && mode < 8) {
93 +               struct ibcs_flock *ifl = (struct ibcs_flock *)size;
94 +               short t;
95 +
96 +               if (!access_ok(VERIFY_READ, ifl, sizeof(*ifl)))
97 +                       return -EFAULT;
98 +
99 +               get_user(t, &ifl->l_type);
100 +               switch (t) {
101 +                       case XF_UNLCK:  t = F_UNLCK; break;
102 +                       case XF_WRLCK:  t = F_WRLCK; break;
103 +                       case XF_RDLCK:  t = F_RDLCK; break;
104 +                       default:        return -EINVAL;
105 +               }
106 +               put_user(t, &ifl->l_type);
107 +
108 +               error = sys_fcntl(fd, mode, (u_long)ifl);
109 +
110 +               get_user(t, &ifl->l_type);
111 +               switch (t) {
112 +                       case F_UNLCK:   t = XF_UNLCK; break;
113 +                       case F_WRLCK:   t = XF_WRLCK; break;
114 +                       case F_RDLCK:   t = XF_RDLCK; break;
115 +               }
116 +               put_user(t, &ifl->l_type);
117 +
118 +               get_user(t, &ifl->l_sysid);
119 +               put_user(t, &ifl->l_pid);
120 +               put_user(0, &ifl->l_sysid);
121 +               return error;
122 +       }
123 +
124 +       fl.l_type = (mode == 0 ? F_UNLCK
125 +                       : ((mode <= 2 || mode == 20) ? F_WRLCK
126 +                       : F_RDLCK));
127 +       fl.l_whence = 1;
128 +       fl.l_start = 0;
129 +       fl.l_len = size;
130 +
131 +       old_fs = get_fs();
132 +       set_fs (get_ds());
133 +       error = sys_fcntl(fd, (mode == 5) ? F_GETLK
134 +                       : (!(mode % 2) ? F_SETLK : F_SETLKW), (u_long)&fl);
135 +       set_fs(old_fs);
136 +       return error;
137 +}
138 +
139 +
140 +/* Check if input is available */
141 +int
142 +xnx_rdchk(int fd)
143 +{
144 +       int error, nbytes;
145 +       mm_segment_t old_fs;
146 +
147 +       old_fs = get_fs();
148 +       set_fs (get_ds());
149 +       error = sys_ioctl(fd, FIONREAD, (long)&nbytes);
150 +       set_fs(old_fs);
151 +
152 +       if (error < 0) return error;
153 +       return nbytes ? 1 : 0;
154 +}
155 +
156 +/*
157 + * Linux has a stub sys_ftime. Perhaps this should be there? On the other
158 + * hand it's an old call that probably shouldn't be used by most modern
159 + * applications so perhaps it's better here where it needn't bloat the
160 + * base kernel.
161 + */
162 +int
163 +xnx_ftime(struct timeb *tp)
164 +{
165 +       struct timeval tv;
166 +       struct timezone tz;
167 +       int error;
168 +       mm_segment_t old_fs;
169 +
170 +       if (!access_ok(VERIFY_WRITE, tp, sizeof(struct timeb)))
171 +               return -EFAULT;
172 +
173 +       old_fs = get_fs();
174 +       set_fs (get_ds());
175 +       error = sys_gettimeofday(&tv, &tz);
176 +       set_fs(old_fs);
177 +       if (error)
178 +               return error;
179 +
180 +       put_user(tv.tv_sec, &tp->time);
181 +       put_user((unsigned short)(tv.tv_usec/1000), &tp->millitm);
182 +       put_user((short)tz.tz_minuteswest, &tp->timezone);
183 +       put_user((short)tz.tz_dsttime, &tp->dstflag);
184 +
185 +       return 0;
186 +}
187 +
188 +#define USE_NEW_NAP_CODE
189 +
190 +#ifndef USE_NEW_NAP_CODE
191 +static __inline __sighandler_t
192 +sigaction(int sig, __sighandler_t handler)
193 +{
194 +       struct k_sigaction *k = &current->sighand->action[sig-1];
195 +       __sighandler_t old_handler;
196 +
197 +       spin_lock(&current->sighand->siglock);
198 +       old_handler = k->sa.sa_handler;
199 +       k->sa.sa_handler = handler;
200 +       spin_unlock(&current->sighand->siglock);
201 +
202 +       return old_handler;
203 +}
204 +#endif
205 +
206 +/* go to sleep for period milliseconds */
207 +/* - returns either an EINTR error or returns the elapsed time */
208 +/* Note:
209 +   for SCO OpenServer 5.0.6 the original nap was fixed so that it
210 +   no longer waits a minimum of 2 tick (20ms)
211 +   but fewer time with a 10 ms granularity */
212 +long
213 +xnx_nap(long period)
214 +{
215 +#ifdef USE_NEW_NAP_CODE
216 +       // Hz means the number of jiffies per second.
217 +       // the below code needs HZ to be 1 <= HZ <= 1000
218 +       // in order to work correctly in any case.
219 +#if HZ > 1000
220 +#error this code only works with HZ <= 1000
221 +#endif
222 +       struct timeval tv1, tv2;
223 +       struct timezone tz;
224 +       mm_segment_t oldfs;
225 +       long period_s; // seconds part
226 +       long period_ms_hz; // milli seconds part, scaled to a base of HZ
227 +       long period_j; // jiffies
228 +
229 +       if (!period)
230 +               return 0; // zereo request, zero reply
231 +
232 +       oldfs = get_fs();
233 +       set_fs(get_ds());
234 +       sys_gettimeofday(&tv1, &tz);
235 +
236 +       period_s = period / 1000;
237 +       period_ms_hz = (period - period_s * 1000) * HZ;
238 +       period_j = period_s * HZ + period_ms_hz / 1000;
239 +       // take care of rounding errors, round up
240 +       if (period > period_j * (1000 / HZ)) period_j++;
241 +
242 +       set_current_state(TASK_INTERRUPTIBLE);
243 +       schedule_timeout (period_j);
244 +
245 +       sys_gettimeofday(&tv2, &tz);
246 +       set_fs(oldfs);
247 +
248 +       if (signal_pending(current))
249 +               return -EINTR; // interrupted
250 +       return (tv2.tv_sec - tv1.tv_sec) * 1000
251 +               + (tv2.tv_usec - tv1.tv_usec + 500) / 1000;
252 +#else
253 +       __sighandler_t old_handler;
254 +       struct itimerval it;
255 +       struct timeval tv1, tv2;
256 +       struct timezone tz;
257 +       mm_segment_t oldfs;
258 +
259 +       if (!period)
260 +               return 0;
261 +
262 +       it.it_interval.tv_sec = 0;
263 +       it.it_interval.tv_usec = 0;
264 +       it.it_value.tv_sec = 0;
265 +       it.it_value.tv_usec = period * 1000;
266 +
267 +       oldfs = get_fs();
268 +       set_fs(get_ds());
269 +
270 +       sys_gettimeofday(&tv1, &tz);
271 +       old_handler = sigaction(SIGALRM, SIG_DFL); // SIG_DFL -> terminate
272 +       sys_setitimer(ITIMER_REAL, &it, NULL);
273 +       sys_pause();
274 +       sigaction(SIGALRM, old_handler);
275 +       sys_gettimeofday(&tv2, &tz);
276 +       set_fs(oldfs);
277 +
278 +       deactivate_signal(current, SIGALRM);
279 +
280 +       if (signal_pending(current))
281 +               return -EINTR;
282 +       return ((tv2.tv_sec - tv1.tv_sec) * 1000000
283 +                       + (tv2.tv_usec - tv1.tv_usec)) / 1000;
284 +#endif
285 +}
286 +
287 +/*
288 + * eaccess() checks access to the given path using the effective
289 + * uid/gid rather than the real uid/gid.
290 + */
291 +int
292 +xnx_eaccess(char *path, int mode)
293 +{
294 +       uid_t           ouid;
295 +       gid_t           ogid;
296 +       int             err;
297 +
298 +       ouid = current->uid;
299 +       ogid = current->gid;
300 +       current->uid = current->euid;
301 +       current->gid = current->egid;
302 +
303 +       err = sys_access(path, mode);
304 +
305 +       current->uid = ouid;
306 +       current->gid = ogid;
307 +
308 +       return err;
309 +}
310 diff -Nur kernel-source-2.6.16.orig/abi/cxenix/pathconf.c kernel-source-2.6.16/abi/cxenix/pathconf.c
311 --- kernel-source-2.6.16.orig/abi/cxenix/pathconf.c     1970-01-01 10:00:00.000000000 +1000
312 +++ kernel-source-2.6.16/abi/cxenix/pathconf.c  2006-04-27 18:50:24.000000000 +1000
313 @@ -0,0 +1,140 @@
314 +/*
315 + * pathconf.c - support for xenix pathconf
316 + *
317 + * Copyright (c) 1993,1994 Drew Sullivan
318 + * Copyright (c) 1994-1996 Mike Jagdis
319 + */
320 +
321 +#ident "%W% %G%"
322 +
323 +#include <linux/errno.h>
324 +#include <linux/fs.h>
325 +#include <linux/slab.h>
326 +#include <linux/sched.h>
327 +#include <linux/unistd.h>
328 +#include <linux/syscalls.h>
329 +#include <linux/statfs.h>
330 +#include <asm/uaccess.h>
331 +
332 +
333 +enum {
334 +       _PC_LINK_MAX =          0,
335 +       _PC_MAX_CANON =         1,
336 +       _PC_MAX_INPUT =         2,
337 +       _PC_NAME_MAX =          3,
338 +       _PC_PATH_MAX =          4,
339 +       _PC_PIPE_BUF =          5,
340 +       _PC_CHOWN_RESTRICTED =  6,
341 +       _PC_NO_TRUNC =          7,
342 +       _PC_VDISABLE =          8,
343 +};
344 +
345 +static int
346 +xnx_name_max(char *path)
347 +{
348 +       struct statfs           stf;
349 +       mm_segment_t            fs;
350 +       char                    *p;
351 +       int                     error;
352 +
353 +       p = getname(path);
354 +       if (IS_ERR(p))
355 +               return PTR_ERR(p);
356 +
357 +       fs = get_fs();
358 +       set_fs(get_ds());
359 +       error = sys_statfs(p, &stf);
360 +       set_fs(fs);
361 +
362 +       putname(p);
363 +       if (error)
364 +               return (error);
365 +       return (stf.f_namelen);
366 +}
367 +
368 +int
369 +xnx_pathconf(char *path, int name)
370 +{
371 +       switch (name) {
372 +       case _PC_LINK_MAX:
373 +               /*
374 +                * Although Linux headers define values on a per
375 +                * filesystem basis there is no way to access
376 +                * these without hard coding fs information here
377 +                * so for now we use a bogus value.
378 +                */
379 +               return LINK_MAX;
380 +       case _PC_MAX_CANON:
381 +               return MAX_CANON;
382 +       case _PC_MAX_INPUT:
383 +               return MAX_INPUT;
384 +       case _PC_PATH_MAX:
385 +               return PATH_MAX;
386 +       case _PC_PIPE_BUF:
387 +               return PIPE_BUF;
388 +       case _PC_CHOWN_RESTRICTED:
389 +               /*
390 +                * We should really think about this and tell
391 +                * the truth.
392 +                */
393 +               return 0;
394 +       case _PC_NO_TRUNC:
395 +               /* Not sure... It could be fs dependent? */
396 +               return 1;
397 +       case _PC_VDISABLE:
398 +               return 1;
399 +       case _PC_NAME_MAX:
400 +               return xnx_name_max(path);
401 +       }
402 +       return -EINVAL;
403 +}
404 +
405 +int
406 +xnx_fpathconf(int fildes, int name)
407 +{
408 +       switch (name) {
409 +       case _PC_LINK_MAX:
410 +               /*
411 +                * Although Linux headers define values on a per
412 +                * filesystem basis there is no way to access
413 +                * these without hard coding fs information here
414 +                * so for now we use a bogus value.
415 +                */
416 +               return LINK_MAX;
417 +       case _PC_MAX_CANON:
418 +               return MAX_CANON;
419 +       case _PC_MAX_INPUT:
420 +               return MAX_INPUT;
421 +       case _PC_PATH_MAX:
422 +               return PATH_MAX;
423 +       case _PC_PIPE_BUF:
424 +               return PIPE_BUF;
425 +       case _PC_CHOWN_RESTRICTED:
426 +               /*
427 +                * We should really think about this and tell
428 +                * the truth.
429 +                */
430 +               return 0;
431 +       case _PC_NO_TRUNC:
432 +               /* Not sure... It could be fs dependent? */
433 +               return 1;
434 +       case _PC_VDISABLE:
435 +               return 1;
436 +       case _PC_NAME_MAX:
437 +               {
438 +                       struct statfs buf;
439 +                       int error;
440 +                       mm_segment_t old_fs;
441 +
442 +                       old_fs = get_fs();
443 +                       set_fs (get_ds());
444 +                       error = sys_fstatfs(fildes, &buf);
445 +                       set_fs(old_fs);
446 +                       if (!error)
447 +                               return buf.f_namelen;
448 +                       return error;
449 +               }
450 +       }
451 +
452 +       return -EINVAL;
453 +}
454 diff -Nur kernel-source-2.6.16.orig/abi/cxenix/signal.c kernel-source-2.6.16/abi/cxenix/signal.c
455 --- kernel-source-2.6.16.orig/abi/cxenix/signal.c       1970-01-01 10:00:00.000000000 +1000
456 +++ kernel-source-2.6.16/abi/cxenix/signal.c    2006-04-27 18:50:24.000000000 +1000
457 @@ -0,0 +1,88 @@
458 +#ident "%W% %G%"
459 +
460 +#include <linux/module.h>
461 +#include <linux/kernel.h>
462 +#include <linux/personality.h>
463 +#include <linux/sched.h>
464 +#define __KERNEL_SYSCALLS__
465 +#include <linux/unistd.h>
466 +#include <asm/uaccess.h>
467 +
468 +#include <abi/cxenix/signal.h>
469 +#include <abi/signal.h>
470 +
471 +#include <abi/util/map.h>
472 +#include <abi/util/sysent.h>
473 +
474 +
475 +int
476 +xnx_sigaction(int sco_signum, const struct sco_sigaction *action,
477 +               struct sco_sigaction *oldaction)
478 +{
479 +       struct sco_sigaction    new_sa, old_sa;
480 +       struct sigaction        nsa, osa;
481 +       mm_segment_t            fs;
482 +       int                     error, signo;
483 +
484 +       if (sco_signum >= NSIGNALS)
485 +               return -EINVAL;
486 +       signo = current_thread_info()->exec_domain->signal_map[sco_signum];
487 +
488 +       if (oldaction) {
489 +               if (!access_ok(VERIFY_WRITE, oldaction,
490 +                               sizeof(struct sco_sigaction)))
491 +                       return -EFAULT;
492 +       }
493 +
494 +       if (action) {
495 +               error = copy_from_user(&new_sa, action,
496 +                               sizeof(struct sco_sigaction));
497 +               if (error)
498 +                       return -EFAULT;
499 +               nsa.sa_restorer = NULL;
500 +               nsa.sa_handler = new_sa.sa_handler;
501 +               nsa.sa_mask = map_sigvec_to_kernel(new_sa.sa_mask,
502 +                       current_thread_info()->exec_domain->signal_map);
503 +               nsa.sa_flags = SA_NOMASK;
504 +               if (new_sa.sa_flags & SCO_SA_NOCLDSTOP)
505 +                       nsa.sa_flags |= SA_NOCLDSTOP;
506 +       }
507 +
508 +       fs = get_fs();
509 +       set_fs(get_ds());
510 +       error = sys_rt_sigaction(signo, action ? &nsa : NULL,
511 +                       oldaction ? &osa : NULL, sizeof(sigset_t));
512 +       set_fs(fs);
513 +
514 +       if (error || !oldaction)
515 +               return (error);
516 +
517 +       old_sa.sa_handler = osa.sa_handler;
518 +       old_sa.sa_mask = map_sigvec_from_kernel(osa.sa_mask,
519 +                       current_thread_info()->exec_domain->signal_invmap);
520 +       old_sa.sa_flags = 0;
521 +       if (osa.sa_flags & SA_NOCLDSTOP)
522 +               old_sa.sa_flags |= SCO_SA_NOCLDSTOP;
523 +
524 +       if (copy_to_user(oldaction, &old_sa, sizeof(struct sco_sigaction)))
525 +               return -EFAULT;
526 +       return 0;
527 +}
528 +
529 +int
530 +xnx_sigpending(u_long *setp)
531 +{
532 +       sigset_t                lxpending;
533 +       u_long                  pending;
534 +
535 +       spin_lock_irq(&current->sighand->siglock);
536 +       sigandsets(&lxpending, &current->blocked, &current->pending.signal);
537 +       spin_unlock_irq(&current->sighand->siglock);
538 +
539 +       pending = map_sigvec_from_kernel(lxpending,
540 +                       current_thread_info()->exec_domain->signal_invmap);
541 +
542 +       if (copy_to_user(setp, &pending, sizeof(u_long)))
543 +               return -EFAULT;
544 +       return 0;
545 +}
546 diff -Nur kernel-source-2.6.16.orig/abi/cxenix/stubs.c kernel-source-2.6.16/abi/cxenix/stubs.c
547 --- kernel-source-2.6.16.orig/abi/cxenix/stubs.c        1970-01-01 10:00:00.000000000 +1000
548 +++ kernel-source-2.6.16/abi/cxenix/stubs.c     2006-04-27 18:50:24.000000000 +1000
549 @@ -0,0 +1,123 @@
550 +/*
551 + * stubs.c - stubs for unimplemented cxenix subcalls
552 + *
553 + * Copyright (c) 1993,1994 Drew Sullivan.
554 + * Copyright (c) 1994-1996 Mike Jagdis.
555 + */
556 +
557 +#ident "%W% %G%"
558 +
559 +#include <linux/errno.h>
560 +#include <linux/types.h>
561 +#include <linux/ptrace.h>
562 +
563 +#include <abi/cxenix/sysent.h>
564 +
565 +
566 +int
567 +xnx_creatsem(char *sem_name, int mode)
568 +{
569 +       return -EPERM;
570 +}
571 +
572 +int
573 +xnx_opensem(char *sem_name)
574 +{
575 +       return -EPERM;
576 +}
577 +
578 +int
579 +xnx_sigsem(int sem_num)
580 +{
581 +       return -EPERM;
582 +}
583 +
584 +int
585 +xnx_waitsem(int sem_num)
586 +{
587 +       return -EPERM;
588 +}
589 +
590 +int
591 +xnx_nbwaitsem(int sem_num)
592 +{
593 +       return -EPERM;
594 +}
595 +
596 +
597 +int
598 +xnx_sdget(char *path, int flags, long size, int mode)
599 +{
600 +       return -EPERM;
601 +}
602 +
603 +int
604 +xnx_sdfree(char* addr)
605 +{
606 +       return -EPERM;
607 +}
608 +
609 +int
610 +xnx_sdenter(char *addr, int flags)
611 +{
612 +       return -EPERM;
613 +}
614 +
615 +int
616 +xnx_sdleave(char *addr)
617 +{
618 +       return -EPERM;
619 +}
620 +
621 +int
622 +xnx_sdgetv(char *addr)
623 +{
624 +       return -EPERM;
625 +}
626 +
627 +int
628 +xnx_sdwaitv(char *addr, int vnum)
629 +{
630 +       return -EPERM;
631 +}
632 +
633 +
634 +/*
635 + * This allows processes to be allowed to exceed available swap. The man
636 + * page isn't too clear  - it seems to suggest Xenix supports physical
637 + * memory > swap but this doesn't make sense to me? It almost certainly
638 + * isn't useful for Linux to actually do anything with this - just lie.
639 + */
640 +enum {
641 +       XNX_PRHUGEX =   1,
642 +       XNX_PRNORMEX =  2,
643 +};
644 +
645 +int
646 +xnx_proctl(int pid, int command, char *arg)
647 +{
648 +       return 0;
649 +}
650 +
651 +int
652 +xnx_execseg(excode_t oldaddr, unsigned size)
653 +{
654 +       return -EPERM;
655 +}
656 +
657 +
658 +int
659 +xnx_unexecseg(excode_t addr)
660 +{
661 +       return -EPERM;
662 +}
663 +
664 +/*
665 + * This allows running adb without executing any programs, but disassembly
666 + * will work fine with that lie.
667 + */
668 +int
669 +xnx_paccess(int pid, int cmd, int offset, int count, char *ptr)
670 +{
671 +       return 0;
672 +}
673 diff -Nur kernel-source-2.6.16.orig/abi/cxenix/sysent.c kernel-source-2.6.16/abi/cxenix/sysent.c
674 --- kernel-source-2.6.16.orig/abi/cxenix/sysent.c       1970-01-01 10:00:00.000000000 +1000
675 +++ kernel-source-2.6.16/abi/cxenix/sysent.c    2006-04-27 18:50:24.000000000 +1000
676 @@ -0,0 +1,96 @@
677 +#ident "%W% %G%"
678 +
679 +#include <linux/module.h>
680 +#include <linux/kernel.h>
681 +#include <linux/personality.h>
682 +#include <linux/sched.h>
683 +#include <linux/ptrace.h>
684 +#include <linux/syscalls.h>
685 +#include <asm/uaccess.h>
686 +
687 +#include <abi/svr4/sysent.h>
688 +#include <abi/cxenix/sysent.h>
689 +
690 +#include <abi/util/errno.h>
691 +#include <abi/util/sysent.h>
692 +
693 +
694 +MODULE_DESCRIPTION("Xenix/OpenServer cxenix call support");
695 +MODULE_AUTHOR("Christoph Hellwig, partially taken from iBCS");
696 +MODULE_LICENSE("GPL");
697 +
698 +
699 +static struct sysent cxenix_table[] = {
700 +/*   0 */      { 0,                    Ukn,    "syscall",      ""      },
701 +/*   1 */      { xnx_locking,          3,      "locking",      "ddd"   },
702 +/*   2 */      { xnx_creatsem,         2,      "creatsem",     "sd"    },
703 +/*   3 */      { xnx_opensem,          1,      "opensem",      "s"     },
704 +/*   4 */      { xnx_sigsem,           1,      "sigsem",       "d"     },
705 +/*   5 */      { xnx_waitsem,          1,      "waitsem",      "d"     },
706 +/*   6 */      { xnx_nbwaitsem,        1,      "nbwaitsem",    "d"     },
707 +/*   7 */      { xnx_rdchk,            1,      "rdchk",        "d"     },
708 +/*   8 */      { 0,                    Ukn,    "stkgro",       ""      },
709 +/*   9 */      { 0,                    Ukn,    "?",            ""      },
710 +/*  10 */      { sys_ftruncate,        2,      "chsize",       "dd"    },
711 +/*  11 */      { xnx_ftime,            1,      "ftime",        "x"     },
712 +/*  12 */      { xnx_nap,              1,      "nap",          "d"     },
713 +/*  13 */      { xnx_sdget,            4,      "sdget",        "sddd"  },
714 +/*  14 */      { xnx_sdfree,           1,      "sdfree",       "x"     },
715 +/*  15 */      { xnx_sdenter,          2,      "sdenter",      "xd"    },
716 +/*  16 */      { xnx_sdleave,          1,      "sdleave",       "x"    },
717 +/*  17 */      { xnx_sdgetv,           1,      "sdgetv",       "x"     },
718 +/*  18 */      { xnx_sdwaitv,          2,      "sdwaitv",      "xd"    },
719 +/*  19 */      { 0,                    Ukn,    "brkctl",       ""      },
720 +/*  20 */      { 0,                    Ukn,    "?",            ""      },
721 +/*  21 */      { 0,                    2,      "sco-getcwd?",  "dx"    },
722 +/*  22 */      { 0,                    Ukn,    "?",            ""      },
723 +/*  23 */      { 0,                    Ukn,    "?",            ""      },
724 +/*  24 */      { 0,                    Ukn,    "?",            ""      },
725 +/*  25 */      { 0,                    Ukn,    "?",            ""      },
726 +/*  26 */      { 0,                    Ukn,    "?",            ""      },
727 +/*  27 */      { 0,                    Ukn,    "?",            ""      },
728 +/*  28 */      { 0,                    Ukn,    "?",            ""      },
729 +/*  29 */      { 0,                    Ukn,    "?",            ""      },
730 +/*  30 */      { 0,                    Ukn,    "?",            ""      },
731 +/*  31 */      { 0,                    Ukn,    "?",            ""      },
732 +/*  32 */      { xnx_proctl,           3,      "proctl",       "ddx"   },
733 +/*  33 */      { xnx_execseg,          2,      "execseg",      "xd"    },
734 +/*  34 */      { xnx_unexecseg,        1,      "unexecseg",    "x"     },
735 +/*  35 */      { 0,                    Ukn,    "?",            ""      },
736 +/*  36 */      { sys_select,           5,      "select",       "dxxxx" },
737 +/*  37 */      { xnx_eaccess,          2,      "eaccess",      "so"    },
738 +/*  38 */      { xnx_paccess,          5,      "paccess",      "dddds" },
739 +/*  39 */      { xnx_sigaction,        3,      "sigaction",    "dxx"   },
740 +/*  40 */      { abi_sigprocmask,      3,      "sigprocmask",  "dxx"   },
741 +/*  41 */      { xnx_sigpending,       1,      "sigpending",   "x"     },
742 +/*  42 */      { abi_sigsuspend,       Spl,    "sigsuspend",   "x"     },
743 +/*  43 */      { sys_getgroups16,      2,      "getgroups",    "dx"    },
744 +/*  44 */      { sys_setgroups16,      2,      "setgroups",    "dx"    },
745 +/*  45 */      { ibcs_sysconf,         1,      "sysconf",      "d"     },
746 +/*  46 */      { xnx_pathconf,         2,      "pathconf",     "sd"    },
747 +/*  47 */      { xnx_fpathconf,        2,      "fpathconf",    "dd"    },
748 +/*  48 */      { sys_rename,           2,      "rename",       "ss"    },
749 +/*  49 */      { 0,                    Ukn,    "?",            ""      },
750 +/*  50 */      { xnx_utsname,          1,      "utsname",      "x"     },
751 +/*  51 */      { 0,                    Ukn,    "?",            ""      },
752 +/*  52 */      { 0,                    Ukn,    "?",            ""      },
753 +/*  53 */      { 0,                    Ukn,    "?",            ""      },
754 +/*  54 */      { 0,                    Ukn,    "?",            ""      },
755 +/*  55 */      { sys_getitimer,        2,      "getitimer",    "dx"    },
756 +/*  56 */      { sys_setitimer,        3,      "setitimer",    "dxx"   }
757 +};
758 +
759 +
760 +void cxenix(struct pt_regs *regs)
761 +{
762 +       int sysno = regs->eax >> 8;
763 +
764 +       if (sysno >= ARRAY_SIZE(cxenix_table))
765 +               set_error(regs, iABI_errors(-EINVAL));
766 +       else
767 +               lcall7_dispatch(regs, &cxenix_table[sysno], 1);
768 +}
769 +
770 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
771 +EXPORT_SYMBOL(cxenix);
772 +#endif
773 diff -Nur kernel-source-2.6.16.orig/abi/cxenix/utsname.c kernel-source-2.6.16/abi/cxenix/utsname.c
774 --- kernel-source-2.6.16.orig/abi/cxenix/utsname.c      1970-01-01 10:00:00.000000000 +1000
775 +++ kernel-source-2.6.16/abi/cxenix/utsname.c   2006-04-27 18:50:24.000000000 +1000
776 @@ -0,0 +1,122 @@
777 +/*
778 + * utsname.c - support for the utsname subcall of cxenix
779 + *
780 + * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
781 + */
782 +
783 +#ident "%W% %G%"
784 +
785 +#include <linux/mm.h>
786 +#include <linux/sched.h>
787 +#include <linux/personality.h>
788 +#include <linux/utsname.h>
789 +#include <linux/eisa.h>
790 +#include <asm/uaccess.h>
791 +
792 +
793 +static char    sco_serial[10] = "public";
794 +
795 +struct xnx_utsname {
796 +       char    sysname[9];
797 +       char    nodename[9];
798 +       char    release[16];
799 +       char    kernelid[20];
800 +       char    machine[9];
801 +       char    bustype[9];
802 +       char    sysserial[10];
803 +       u_short sysorigin;
804 +       u_short sysoem;
805 +       char    numusers[9];
806 +       u_short numcpu;
807 +};
808 +
809 +// this function and macro design is from arch/sparc64/solaris/misc.c
810 +static int __set_utsfield(char __user *to, int to_size,
811 +                       const char *from, int from_size,
812 +                       int dotchop)
813 +{
814 +       int len = min(from_size, to_size);
815 +       int off;
816 +
817 +       if (copy_to_user(to, from, len))
818 +               return -EFAULT;
819 +
820 +       off = len < to_size? len: len - 1;
821 +       if (dotchop) {
822 +               const char *p = strnchr(from, len, '.');
823 +               if (p) off =  p - from;
824 +       }
825 +
826 +       if (__put_user('\0', to + off))
827 +               return -EFAULT;
828 +
829 +       return 0;
830 +}
831 +
832 +#define set_utsfield(to, from, dotchop) \
833 +       __set_utsfield((to), sizeof(to), \
834 +               (from), sizeof(from), \
835 +               (dotchop))
836 +
837 +static int __set_utsvalue(void __user *to, int to_size,
838 +       const void *from, int from_size)
839 +{
840 +       int len = min(from_size, to_size);
841 +
842 +       if (copy_to_user(to, from, len))
843 +               return -EFAULT;
844 +
845 +       return 0;
846 +}
847 +
848 +#define set_utsvalue(to, from) \
849 +  __set_utsvalue((to), sizeof(*to), \
850 +    (from), sizeof(*from))
851 +
852 +int
853 +xnx_utsname(u_long addr)
854 +{
855 +       struct xnx_utsname      *utp = (struct xnx_utsname *)addr;
856 +       unsigned short usvalue;
857 +       long lvalue;
858 +       int error=0;
859 +
860 +       /*
861 +        * This shouldn't be invoked by anything that isn't running
862 +        * in the SCO personality. I can envisage a program that uses
863 +        * this to test if utp is running on SCO or not. It probably
864 +        * won't happen but let's make sure utp doesn't anyway...
865 +        */
866 +       if (!is_cur_personality(PER_SCOSVR3))
867 +               return -ENOSYS;
868 +
869 +       down_read(&uts_sem);
870 +       if (access_ok(VERIFY_WRITE, utp, sizeof (struct xnx_utsname))) {
871 +               if (abi_fake_utsname) {
872 +                       error |= set_utsfield(utp->sysname, "SCO_SV", 0);
873 +                       error |= set_utsfield(utp->nodename, system_utsname.nodename, 1);
874 +                       error |= set_utsfield(utp->release, "3.2v5.0.0\0", 0);
875 +               } else {
876 +                       error |= set_utsfield(utp->sysname, system_utsname.nodename, 1);
877 +                       error |= set_utsfield(utp->nodename, system_utsname.nodename, 1);
878 +                       error |= set_utsfield(utp->release, system_utsname.release, 0);
879 +               }
880 +               error |= set_utsfield(utp->kernelid, system_utsname.version, 0);
881 +               error |= set_utsfield(utp->machine, system_utsname.machine, 0);
882 +               if (EISA_bus) {
883 +                       error |= set_utsfield(utp->bustype, "EISA", 0);
884 +               } else {
885 +                       error |= set_utsfield(utp->bustype, "ISA", 0);
886 +               }
887 +               error |= set_utsfield(utp->sysserial, sco_serial, 0);
888 +               usvalue = 0xffff;
889 +               error |= set_utsvalue(&utp->sysorigin, &usvalue);
890 +               error |= set_utsvalue(&utp->sysoem, &usvalue);
891 +               error |= set_utsfield(utp->numusers, "unlim", 0);
892 +               lvalue = 1;
893 +               error |= set_utsvalue(&utp->numcpu, &lvalue);
894 +       }
895 +       up_read(&uts_sem);
896 +
897 +       return (error);
898 +}
899 diff -Nur kernel-source-2.6.16.orig/abi/ibcs/Makefile kernel-source-2.6.16/abi/ibcs/Makefile
900 --- kernel-source-2.6.16.orig/abi/ibcs/Makefile 1970-01-01 10:00:00.000000000 +1000
901 +++ kernel-source-2.6.16/abi/ibcs/Makefile      2006-04-27 18:50:24.000000000 +1000
902 @@ -0,0 +1,7 @@
903 +
904 +abi-ibcs-objs  := sysent.o
905 +
906 +obj-$(CONFIG_ABI_IBCS)         += abi-ibcs.o
907 +
908 +abi-ibcs.o: $(abi-ibcs-objs)
909 +       $(LD) -r -o $@ $(abi-ibcs-objs)
910 diff -Nur kernel-source-2.6.16.orig/abi/ibcs/sysent.c kernel-source-2.6.16/abi/ibcs/sysent.c
911 --- kernel-source-2.6.16.orig/abi/ibcs/sysent.c 1970-01-01 10:00:00.000000000 +1000
912 +++ kernel-source-2.6.16/abi/ibcs/sysent.c      2006-04-27 18:50:24.000000000 +1000
913 @@ -0,0 +1,412 @@
914 +/*
915 + * Copyright (c) 2001 Christoph Hellwig.
916 + * All rights reserved.
917 + *
918 + * This program is free software; you can redistribute it and/or modify
919 + * it under the terms of the GNU General Public License as published by
920 + * the Free Software Foundation; either version 2 of the License, or
921 + * (at your option) any later version.
922 + *
923 + * This program is distributed in the hope that it will be useful,
924 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
925 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
926 + * GNU General Public License for more details.
927 + *
928 + * You should have received a copy of the GNU General Public License
929 + * along with this program; if not, write to the Free Software
930 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
931 + */
932 +
933 +#ident "%W% %G%"
934 +
935 +/*
936 + * SVR4 personality switch.
937 + */
938 +#include <linux/config.h>
939 +#include <linux/kernel.h>
940 +#include <linux/module.h>
941 +#include <linux/init.h>
942 +#include <linux/personality.h>
943 +#include <linux/syscalls.h>
944 +#include <linux/socket.h>
945 +#include <linux/highuid.h>
946 +#include <linux/net.h>
947 +#include <asm/uaccess.h>
948 +
949 +#include <abi/svr4/sysent.h>
950 +#include <abi/signal.h>
951 +
952 +#include <abi/util/errno.h>
953 +#include <abi/util/sysent.h>
954 +#include <abi/util/socket.h>
955 +
956 +MODULE_DESCRIPTION("iBCS2/iABI4 personality");
957 +MODULE_AUTHOR("Christoph Hellwig, partially taken from iBCS");
958 +MODULE_LICENSE("GPL");
959 +
960 +
961 +/*
962 + * We could remove some of the long identity mapped runs but at the
963 + * expense of extra comparisons for each mapping at run time...
964 + */
965 +static u_char ibcs_err_table[] = {
966 +/*   0 -   9 */   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,
967 +/*  10 -  19 */  10,  11,  12,  13,  14,  15,  16,  17,  18,  19,
968 +/*  20 -  29 */  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
969 +/*  30 -  39 */  30,  31,  32,  33,  34,  45,  78,  46,  89,  93,
970 +/*  40 -  49 */  90,  90,  35,  36,  37,  38,  39,  40,  41,  42,
971 +/*  50 -  59 */  43,  44,  50,  51,  52,  53,  54,  55,  56,  57,
972 +/*  60 -  69 */  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,
973 +/*  70 -  79 */  70,  71,  74,  76,  77,  79,  80,  81,  82,  83,
974 +/*  80 -  89 */  84,  85,  86,  87,  88,  91,  92,  94,  95,  96,
975 +/*  90 -  99 */  97,  98,  99, 120, 121, 122, 123, 124, 125, 126,
976 +/* 100 - 109 */ 127, 128, 129, 130, 131, 132, 133, 134, 143, 144,
977 +/* 110 - 119 */ 145, 146, 147, 148, 149, 150,  22, 135, 137, 138,
978 +/* 120 - 122 */ 139, 140,  28
979 +};
980 +
981 +/*
982 + * Map Linux RESTART* values (512,513,514) to EINTR
983 + */
984 +static u_char lnx_err_table[] = {
985 +/* 512 - 514 */ EINTR, EINTR, EINTR
986 +};
987 +
988 +struct map_segment ibcs_err_map[] = {
989 +       { 0,    0+sizeof(ibcs_err_table)-1,     ibcs_err_table },
990 +       { 512,  512+sizeof(lnx_err_table)-1,    lnx_err_table },
991 +       { -1 }
992 +};
993 +
994 +static long linux_to_ibcs_signals[NSIGNALS+1] = {
995 +/*  0 -  3 */  0,              IBCS_SIGHUP,    IBCS_SIGINT,    IBCS_SIGQUIT,
996 +/*  4 -  7 */  IBCS_SIGILL,    IBCS_SIGTRAP,   IBCS_SIGABRT,   -1,
997 +/*  8 - 11 */  IBCS_SIGFPE,    IBCS_SIGKILL,   IBCS_SIGUSR1,   IBCS_SIGSEGV,
998 +/* 12 - 15 */  IBCS_SIGUSR2,   IBCS_SIGPIPE,   IBCS_SIGALRM,   IBCS_SIGTERM,
999 +/* 16 - 19 */  IBCS_SIGSEGV,   IBCS_SIGCHLD,   IBCS_SIGCONT,   IBCS_SIGSTOP,
1000 +/* 20 - 23 */  IBCS_SIGTSTP,   IBCS_SIGTTIN,   IBCS_SIGTTOU,   IBCS_SIGURG,
1001 +/* 24 - 27 */  IBCS_SIGGXCPU,  IBCS_SIGGXFSZ,  IBCS_SIGVTALRM, IBCS_SIGPROF,
1002 +/* 28 - 31 */  IBCS_SIGWINCH,  IBCS_SIGIO,     IBCS_SIGPWR,    -1,
1003 +/*     32 */   -1
1004 +};
1005 +
1006 +static long ibcs_to_linux_signals[NSIGNALS+1] = {
1007 +/*  0 -  3 */  0,              SIGHUP,         SIGINT,         SIGQUIT,
1008 +/*  4 -  7 */  SIGILL,         SIGTRAP,        SIGIOT,         SIGUNUSED,
1009 +/*  8 - 11 */  SIGFPE,         SIGKILL,        SIGUNUSED,      SIGSEGV,
1010 +/* 12 - 15 */  SIGUNUSED,      SIGPIPE,        SIGALRM,        SIGTERM,
1011 +/* 16 - 19 */  SIGUSR1,        SIGUSR2,        SIGCHLD,        SIGPWR,
1012 +/* 20 - 23 */  SIGWINCH,       SIGURG,         SIGPOLL,        SIGSTOP,
1013 +/* 24 - 27 */  SIGTSTP,        SIGCONT,        SIGTTIN,        SIGTTOU,
1014 +/* 28 - 31 */  SIGVTALRM,      SIGPROF,        SIGXCPU,        SIGXFSZ,
1015 +/*     32 */   -1
1016 +};
1017 +
1018 +static char ibcs_socktype[] = {
1019 +       SOCK_STREAM,
1020 +       SOCK_DGRAM,
1021 +       0,
1022 +       SOCK_RAW,
1023 +       SOCK_RDM,
1024 +       SOCK_SEQPACKET
1025 +};
1026 +
1027 +static struct map_segment ibcs_socktype_map[] = {
1028 +       { 1, 6, ibcs_socktype },
1029 +       { -1 }
1030 +};
1031 +
1032 +static struct map_segment ibcs_sockopt_map[] =  {
1033 +       { 0x0001, 0x0001, (char *)SO_DEBUG },
1034 +       { 0x0002, 0x0002, (char *)__SO_ACCEPTCON },
1035 +       { 0x0004, 0x0004, (char *)SO_REUSEADDR },
1036 +       { 0x0008, 0x0008, (char *)SO_KEEPALIVE },
1037 +       { 0x0010, 0x0010, (char *)SO_DONTROUTE },
1038 +       { 0x0020, 0x0020, (char *)SO_BROADCAST },
1039 +       { 0x0040, 0x0040, (char *)SO_USELOOPBACK },
1040 +       { 0x0080, 0x0080, (char *)SO_LINGER },
1041 +       { 0x0100, 0x0100, (char *)SO_OOBINLINE },
1042 +       { 0x0200, 0x0200, (char *)SO_ORDREL },
1043 +       { 0x0400, 0x0400, (char *)SO_IMASOCKET },
1044 +       { 0x1001, 0x1001, (char *)SO_SNDBUF },
1045 +       { 0x1002, 0x1002, (char *)SO_RCVBUF },
1046 +       { 0x1003, 0x1003, (char *)SO_SNDLOWAT },
1047 +       { 0x1004, 0x1004, (char *)SO_RCVLOWAT },
1048 +       { 0x1005, 0x1005, (char *)SO_SNDTIMEO },
1049 +       { 0x1006, 0x1006, (char *)SO_RCVTIMEO },
1050 +       { 0x1007, 0x1007, (char *)SO_ERROR },
1051 +       { 0x1008, 0x1008, (char *)SO_TYPE },
1052 +       { 0x1009, 0x1009, (char *)SO_PROTOTYPE },
1053 +       { -1 }
1054 +};
1055 +
1056 +static struct map_segment ibcs_af_map[] =  {
1057 +       { 0, 2, NULL },
1058 +       { -1 }
1059 +};
1060 +
1061 +
1062 +static struct sysent ibcs_syscall_table[] = {
1063 +   { abi_syscall,      Fast,   "syscall",      ""      }, /*    0 */
1064 +   { sys_exit,         1,      "exit",         "d"     }, /*    1 */
1065 +   { abi_fork,         Spl,    "fork",         ""      }, /*    2 */
1066 +   { abi_read,         3,      "read",         "dpd"   }, /*    3 */
1067 +   { sys_write,                3,      "write",        "dpd"   }, /*    4 */
1068 +   { svr4_open,                3,      "open",         "soo"   }, /*    5 */
1069 +   { sys_close,                1,      "close",        "d"     }, /*    6 */
1070 +   { abi_wait,         Spl,    "wait",         "xxx"   }, /*    7 */
1071 +   { sys_creat,                2,      "creat",        "so"    }, /*    8 */
1072 +   { sys_link,         2,      "link",         "ss"    }, /*    9 */
1073 +   { sys_unlink,       1,      "unlink",       "s"     }, /*   10 */
1074 +   { abi_exec,         Spl,    "exec",         "sxx"   }, /*   11 */
1075 +   { sys_chdir,                1,      "chdir",        "s"     }, /*   12 */
1076 +   { abi_time,         0,      "time",         ""      }, /*   13 */
1077 +   { svr4_mknod,       3,      "mknod",        "soo"   }, /*   14 */
1078 +   { sys_chmod,                2,      "chmod",        "so"    }, /*   15 */
1079 +   { sys_chown,                3,      "chown",        "sdd"   }, /*   16 */
1080 +   { abi_brk,          1,      "brk/break",    "x"     }, /*   17 */
1081 +   { svr4_stat,                2,      "stat",         "sp"    }, /*   18 */
1082 +   { sys_lseek,                3,      "seek/lseek",   "ddd"   }, /*   19 */
1083 +   { abi_getpid,       Spl,    "getpid",       ""      }, /*   20 */
1084 +   { 0,                        Ukn,    "mount",        ""      }, /*   21 */
1085 +   { sys_umount,       1,      "umount",       "s"     }, /*   22 */
1086 +   { sys_setuid,       1,      "setuid",       "d"     }, /*   23 */
1087 +   { abi_getuid,       Spl,    "getuid",       ""      }, /*   24 */
1088 +   { sys_stime,                1,      "stime",        "d"     }, /*   25 */
1089 +   { 0,                        Ukn,    "ptrace",       ""      }, /*   26 */
1090 +   { sys_alarm,                1,      "alarm",        "d"     }, /*   27 */
1091 +   { svr4_fstat,       2,      "fstat",        "dp"    }, /*   28 */
1092 +   { sys_pause,                0,      "pause",        ""      }, /*   29 */
1093 +   { sys_utime,                2,      "utime",        "xx"    }, /*   30 */
1094 +   { 0,                        Ukn,    "stty",         ""      }, /*   31 */
1095 +   { 0,                        Ukn,    "gtty",         ""      }, /*   32 */
1096 +   { sys_access,       2,      "access",       "so"    }, /*   33 */
1097 +   { sys_nice,         1,      "nice",         "d"     }, /*   34 */
1098 +   { svr4_statfs,      4,      "statfs",       "spdd"  }, /*   35 */
1099 +   { sys_sync,         0,      "sync",         ""      }, /*   36 */
1100 +   { abi_kill,         2,      "kill",         "dd"    }, /*   37 */
1101 +   { svr4_fstatfs,     4,      "fstatfs",      "dpdd"  }, /*   38 */
1102 +   { abi_procids,      Spl,    "procids",      "d"     }, /*   39 */
1103 +   { 0,                        Ukn,    "cxenix",       ""      }, /*   40 */
1104 +   { sys_dup,          1,      "dup",          "d"     }, /*   41 */
1105 +   { abi_pipe,         Spl,    "pipe",         ""      }, /*   42 */
1106 +   { sys_times,                1,      "times",        "p"     }, /*   43 */
1107 +   { 0,                        Ukn,    "prof",         ""      }, /*   44 */
1108 +   { 0,                        Ukn,    "lock/plock",   ""      }, /*   45 */
1109 +   { sys_setgid,       1,      "setgid",       "d"     }, /*   46 */
1110 +   { abi_getgid,       Spl,    "getgid",       ""      }, /*   47 */
1111 +   { abi_sigfunc,      Fast,   "sigfunc",      "xxx"   }, /*   48 */
1112 +   { svr4_msgsys,      Spl,    "msgsys",       "dxddd" }, /*   49 */
1113 +   { svr4_sysi86,      3,      "sysi86",       "d"     }, /*   50 */
1114 +   { sys_acct,         1,      "acct/sysacct", "x"     }, /*   51 */
1115 +   { svr4_shmsys,      Fast,   "shmsys",       "ddxo"  }, /*   52 */
1116 +   { svr4_semsys,      Spl,    "semsys",       "dddx"  }, /*   53 */
1117 +   { svr4_ioctl,       Spl,    "ioctl",        "dxx"   }, /*   54 */
1118 +   { 0,                        3,      "uadmin",       "xxx"   }, /*   55 */
1119 +   { 0,                        Ukn,    "?",            ""      }, /*   56 */
1120 +   { v7_utsname,       1,      "utsys",        "x"     }, /*   57 */
1121 +   { sys_fsync,                1,      "fsync",        "d"     }, /*   58 */
1122 +   { abi_exec,         Spl,    "execv",        "spp"   }, /*   59 */
1123 +   { sys_umask,                1,      "umask",        "o"     }, /*   60 */
1124 +   { sys_chroot,       1,      "chroot",       "s"     }, /*   61 */
1125 +   { svr4_fcntl,       3,      "fcntl",        "dxx"   }, /*   62 */
1126 +   { svr4_ulimit,      2,      "ulimit",       "xx"    }, /*   63 */
1127 +   { 0,                        Ukn,    "?",            ""      }, /*   64 */
1128 +   { 0,                        Ukn,    "?",            ""      }, /*   65 */
1129 +   { 0,                        Ukn,    "?",            ""      }, /*   66 */
1130 +   { 0,                        Ukn,    "?",            ""      }, /*   67 */
1131 +   { 0,                        Ukn,    "?",            ""      }, /*   68 */
1132 +   { 0,                        Ukn,    "?",            ""      }, /*   69 */
1133 +   { 0,                        Ukn,    "advfs",        ""      }, /*   70 */
1134 +   { 0,                        Ukn,    "unadvfs",      ""      }, /*   71 */
1135 +   { 0,                        Ukn,    "rmount",       ""      }, /*   72 */
1136 +   { 0,                        Ukn,    "rumount",      ""      }, /*   73 */
1137 +   { 0,                        Ukn,    "rfstart",      ""      }, /*   74 */
1138 +   { 0,                        Ukn,    "?",            ""      }, /*   75 */
1139 +   { 0,                        Ukn,    "rdebug",       ""      }, /*   76 */
1140 +   { 0,                        Ukn,    "rfstop",       ""      }, /*   77 */
1141 +   { 0,                        Ukn,    "rfsys",        ""      }, /*   78 */
1142 +   { sys_rmdir,                1,      "rmdir",        "s"     }, /*   79 */
1143 +   { abi_mkdir,                2,      "mkdir",        "so"    }, /*   80 */
1144 +   { svr4_getdents,    3,      "getdents",     "dxd"   }, /*   81 */
1145 +   { 0,                        Ukn,    "libattach",    ""      }, /*   82 */
1146 +   { 0,                        Ukn,    "libdetach",    ""      }, /*   83 */
1147 +   { svr4_sysfs,       3,      "sysfs",        "dxx"   }, /*   84 */
1148 +   { svr4_getmsg,      Spl,    "getmsg",       "dxxx"  }, /*   85 */
1149 +   { svr4_putmsg,      Spl,    "putmsg",       "dxxd"  }, /*   86 */
1150 +   { sys_poll,         3,      "poll",         "xdd"   }, /*   87 */
1151 +   { svr4_lstat,       2,      "lstat",        "sp"    }, /*   88 */
1152 +   { sys_symlink,      2,      "symlink",      "ss"    }, /*   89 */
1153 +   { sys_readlink,     3,      "readlink",     "spd"   }, /*   90 */
1154 +   { sys_setgroups,    2,      "setgroups",    "dp"    }, /*   91 */
1155 +   { sys_getgroups,    2,      "getgroups",    "dp"    }, /*   92 */
1156 +   { sys_fchmod,       2,      "fchmod",       "do"    }, /*   93 */
1157 +   { sys_fchown,       3,      "fchown",       "ddd"   }, /*   94 */
1158 +   { abi_sigprocmask,  3,      "sigprocmask",  "dxx"   }, /*   95 */
1159 +   { abi_sigsuspend,   Spl,    "sigsuspend",   "x"     }, /*   96 */
1160 +   { 0,                        2,      "sigaltstack",  "xx"    }, /*   97 */
1161 +   { abi_sigaction,    3,      "sigaction",    "dxx"   }, /*   98 */
1162 +   { svr4_sigpending,  2,      "sigpending",   "dp"    }, /*   99 */
1163 +   { svr4_context,     Spl,    "context",      ""      }, /*   100 */
1164 +   { 0,                        Ukn,    "evsys",        ""      }, /*   101 */
1165 +   { 0,                        Ukn,    "evtrapret",    ""      }, /*   102 */
1166 +   { svr4_statvfs,     2,      "statvfs",      "sp"    }, /*   103 */
1167 +   { svr4_fstatvfs,    2,      "fstatvfs",     "dp"    }, /*   104 */
1168 +   { 0,                        Ukn,    "sysisc",       ""      }, /*   105 */
1169 +   { 0,                        Ukn,    "nfssys",       ""      }, /*   106 */
1170 +   { 0,                        4,      "waitid",       "ddxd"  }, /*   107 */
1171 +   { 0,                        3,      "sigsendsys",   "ddd"   }, /*   108 */
1172 +   { svr4_hrtsys,      Spl,    "hrtsys",       "xxx"   }, /*   109 */
1173 +   { 0,                        3,      "acancel",      "dxd"   }, /*   110 */
1174 +   { 0,                        Ukn,    "async",        ""      }, /*   111 */
1175 +   { 0,                        Ukn,    "priocntlsys",  ""      }, /*   112 */
1176 +   { svr4_pathconf,    2,      "pathconf",     "sd"    }, /*   113 */
1177 +   { 0,                        3,      "mincore",      "xdx"   }, /*   114 */
1178 +   { svr4_mmap,                6,      "mmap",         "xxxxdx"},/*   115 */
1179 +   { sys_mprotect,     3,      "mprotect",     "xdx"   },/*   116 */
1180 +   { sys_munmap,       2,      "munmap",       "xd"    },/*   117 */
1181 +   { svr4_fpathconf,   2,      "fpathconf",    "dd"    }, /*   118 */
1182 +   { abi_fork,         Spl,    "vfork",        ""      }, /*   119 */
1183 +   { sys_fchdir,       1,      "fchdir",       "d"     }, /*   120 */
1184 +   { sys_readv,                3,      "readv",        "dxd"   }, /*   121 */
1185 +   { sys_writev,       3,      "writev",       "dxd"   }, /*   122 */
1186 +   { svr4_xstat,       3,      "xstat",        "dsx"   }, /*   123 */
1187 +   { svr4_lxstat,      3,      "lxstat",       "dsx"   }, /*   124 */
1188 +   { svr4_fxstat,      3,      "fxstat",       "ddx"   }, /*   125 */
1189 +   { svr4_xmknod,      4,      "xmknod",       "dsox"  }, /*   126 */
1190 +   { 0,                        Ukn,    "syslocal",     "d"     }, /*   127 */
1191 +   { svr4_getrlimit,   2,      "setrlimit",    "dx"    }, /*   128 */
1192 +   { svr4_setrlimit,   2,      "getrlimit",    "dx"    }, /*   129 */
1193 +   { 0,                        3,      "lchown",       "sdd"   }, /*   130 */
1194 +   { 0,                        Ukn,    "memcntl",      ""      }, /*   131 */
1195 +#if defined(CONFIG_ABI_XTI)
1196 +   { svr4_getpmsg,     5,      "getpmsg",      "dxxxx" }, /*   132 */
1197 +   { svr4_putpmsg,     5,      "putpmsg",      "dxxdd" }, /*   133 */
1198 +#else
1199 +   { 0,                        5,      "getpmsg",      "dxxxx" }, /*   132 */
1200 +   { 0,                        5,      "putpmsg",      "dxxdd" }, /*   133 */
1201 +#endif
1202 +   { sys_rename,       2,      "rename",       "ss"    }, /*   134 */
1203 +   { abi_utsname,      1,      "uname",        "x"     }, /*   135 */
1204 +   { svr4_setegid,     1,      "setegid",      "d"     }, /*   136 */
1205 +   { svr4_sysconfig,   1,      "sysconfig",    "d"     }, /*   137 */
1206 +   { 0,                        Ukn,    "adjtime",      ""      }, /*   138 */
1207 +   { svr4_sysinfo,     3,      "systeminfo",   "dsd"   }, /*   139 */
1208 +   { socksys_syscall,  1,      "socksys",      "x"     }, /*   140 */
1209 +   { svr4_seteuid,     1,      "seteuid",      "d"     }, /*   141 */
1210 +   { 0,                        Ukn,    "?",            ""      }, /*   142 */
1211 +   { 0,                        Ukn,    "?",            ""      }, /*   143 */
1212 +   { 0,                        2,      "secsys",       "dx"    }, /*   144 */
1213 +   { 0,                        4,      "filepriv",     "sdxd"  }, /*   145 */
1214 +   { 0,                        3,      "procpriv",     "dxd"   }, /*   146 */
1215 +   { 0,                        3,      "devstat",      "sdx"   }, /*   147 */
1216 +   { 0,                        5,      "aclipc",       "ddddx" }, /*   148 */
1217 +   { 0,                        3,      "fdevstat",     "ddx"   }, /*   149 */
1218 +   { 0,                        3,      "flvlfile",     "ddx"   }, /*   150 */
1219 +   { 0,                        3,      "lvlfile",      "sdx"   }, /*   151 */
1220 +   { 0,                        Ukn,    "?",            ""      }, /*   152 */
1221 +   { 0,                        2,      "lvlequal",     "xx"    }, /*   153 */
1222 +   { 0,                        2,      "lvlproc",      "dx"    }, /*   154 */
1223 +   { 0,                        Ukn,    "?",            ""      }, /*   155 */
1224 +   { 0,                        4,      "lvlipc",       "dddx"  }, /*   156 */
1225 +   { 0,                        4,      "acl",          "sddx"  }, /*   157 */
1226 +   { 0,                        Ukn,    "auditevt",     ""      }, /*   158 */
1227 +   { 0,                        Ukn,    "auditctl",     ""      }, /*   159 */
1228 +   { 0,                        Ukn,    "auditdmp",     ""      }, /*   160 */
1229 +   { 0,                        Ukn,    "auditlog",     ""      }, /*   161 */
1230 +   { 0,                        Ukn,    "auditbuf",     ""      }, /*   162 */
1231 +   { 0,                        2,      "lvldom",       "xx"    }, /*   163 */
1232 +   { 0,                        Ukn,    "lvlvfs",       ""      }, /*   164 */
1233 +   { 0,                        2,      "mkmld",        "so"    }, /*   165 */
1234 +   { 0,                        Ukn,    "mlddone",      ""      }, /*   166 */
1235 +   { 0,                        2,      "secadvise",    "xx"    }, /*   167 */
1236 +   { 0,                        Ukn,    "online",       ""      }, /*   168 */
1237 +   { sys_setitimer,    3,      "setitimer",    "dxx"   }, /*   169 */
1238 +   { sys_getitimer,    2,      "getitimer",    "dx"    }, /*   170 */
1239 +   { sys_gettimeofday, 2,      "gettimeofday", "xx"    }, /*   171 */
1240 +   { sys_settimeofday, 2,      "settimeofday", "xx"    }, /*   172 */
1241 +   { 0,                        Ukn,    "lwpcreate",    ""      }, /*   173 */
1242 +   { 0,                        Ukn,    "lwpexit",      ""      }, /*   174 */
1243 +   { 0,                        Ukn,    "lwpwait",      ""      }, /*   175 */
1244 +   { 0,                        Ukn,    "lwpself",      ""      }, /*   176 */
1245 +   { 0,                        Ukn,    "lwpinfo",      ""      }, /*   177 */
1246 +   { 0,                        Ukn,    "lwpprivate",   ""      }, /*   178 */
1247 +   { 0,                        Ukn,    "processorbind",""      }, /*   179 */
1248 +   { 0,                        Ukn,    "processorexbind",""    }, /*   180 */
1249 +   { 0,                        Ukn,    "",             ""      }, /*   181 */
1250 +   { 0,                        Ukn,    "sync_mailbox", ""      }, /*   182 */
1251 +   { 0,                        Ukn,    "prepblock",    ""      }, /*   183 */
1252 +   { 0,                        Ukn,    "block",        ""      }, /*   184 */
1253 +   { 0,                        Ukn,    "rdblock",      ""      }, /*   185 */
1254 +   { 0,                        Ukn,    "unblock",      ""      }, /*   186 */
1255 +   { 0,                        Ukn,    "cancelblock",  ""      }, /*   187 */
1256 +   { 0,                        Ukn,    "?",            ""      }, /*   188 */
1257 +   { 0,                        Ukn,    "pread",        ""      }, /*   189 */
1258 +   { 0,                        Ukn,    "pwrite",       ""      }, /*   190 */
1259 +   { sys_truncate,     2,      "truncate",     "sd"    }, /*   191 */
1260 +   { sys_ftruncate,    2,      "ftruncate",    "dd"    }, /*   192 */
1261 +   { 0,                        Ukn,    "lwpkill",      ""      }, /*   193 */
1262 +   { 0,                        Ukn,    "sigwait",      ""      }, /*   194 */
1263 +   { 0,                        Ukn,    "fork1",        ""      }, /*   195 */
1264 +   { 0,                        Ukn,    "forkall",      ""      }, /*   196 */
1265 +   { 0,                        Ukn,    "modload",      ""      }, /*   197 */
1266 +   { 0,                        Ukn,    "moduload",     ""      }, /*   198 */
1267 +   { 0,                        Ukn,    "modpath",      ""      }, /*   199 */
1268 +   { 0,                        Ukn,    "modstat",      ""      }, /*   200 */
1269 +   { 0,                        Ukn,    "modadm",       ""      }, /*   201 */
1270 +   { 0,                        Ukn,    "getksym",      ""      }, /*   202 */
1271 +   { 0,                        Ukn,    "lwpsuspend",   ""      }, /*   203 */
1272 +   { 0,                        Ukn,    "lwpcontinue",  ""      }, /*   204 */
1273 +   { 0,                        Ukn,    "?",            ""      }, /*   205 */
1274 +   { 0,                        Ukn,    "?",            ""      }, /*   206 */
1275 +   { 0,                        Ukn,    "?",            ""      }, /*   207 */
1276 +   { 0,                        Ukn,    "?",            ""      },
1277 +   { 0,                        Ukn,    "?",            ""      },
1278 +   { 0,                        Ukn,    "?",            ""      },
1279 +   { 0,                        Ukn,    "?",            ""      },
1280 +   { 0,                        Ukn,    "?",            ""      },
1281 +   { 0,                        Ukn,    "?",            ""      },
1282 +   { 0,                        Ukn,    "?",            ""      },
1283 +   { 0,                        Ukn,    "?",            ""      }
1284 +};
1285 +
1286 +static void
1287 +ibcs_lcall7(int segment, struct pt_regs *regs)
1288 +{
1289 +       int sysno = regs->eax & 0xff;
1290 +
1291 +       if (sysno >= ARRAY_SIZE(ibcs_syscall_table))
1292 +               set_error(regs, iABI_errors(-EINVAL));
1293 +       else
1294 +               lcall7_dispatch(regs, &ibcs_syscall_table[regs->eax & 0xff], 1);
1295 +}
1296 +
1297 +static struct exec_domain ibcs_exec_domain = {
1298 +       name:           "iBCS2/iABI4",
1299 +       handler:        ibcs_lcall7,
1300 +       pers_low:       1 /* PER_SVR4 */,
1301 +       pers_high:      2 /* PER_SVR3 */,
1302 +       signal_map:     ibcs_to_linux_signals,
1303 +       signal_invmap:  linux_to_ibcs_signals,
1304 +       err_map:        ibcs_err_map,
1305 +       socktype_map:   ibcs_socktype_map,
1306 +       sockopt_map:    ibcs_sockopt_map,
1307 +       af_map:         ibcs_af_map,
1308 +       module:         THIS_MODULE
1309 +};
1310 +
1311 +static int __init
1312 +ibcs_init(void)
1313 +{
1314 +       return register_exec_domain(&ibcs_exec_domain);
1315 +}
1316 +
1317 +
1318 +static void __exit
1319 +ibcs_exit(void)
1320 +{
1321 +       unregister_exec_domain(&ibcs_exec_domain);
1322 +}
1323 +
1324 +module_init(ibcs_init);
1325 +module_exit(ibcs_exit);
1326 diff -Nur kernel-source-2.6.16.orig/abi/isc/Makefile kernel-source-2.6.16/abi/isc/Makefile
1327 --- kernel-source-2.6.16.orig/abi/isc/Makefile  1970-01-01 10:00:00.000000000 +1000
1328 +++ kernel-source-2.6.16/abi/isc/Makefile       2006-04-27 18:50:24.000000000 +1000
1329 @@ -0,0 +1,7 @@
1330 +
1331 +abi-isc-objs   := sysent.o
1332 +
1333 +obj-$(CONFIG_ABI_ISC)          += abi-isc.o
1334 +
1335 +abi-isc.o: $(abi-isc-objs)
1336 +       $(LD) -r -o $@ $(abi-isc-objs)
1337 diff -Nur kernel-source-2.6.16.orig/abi/isc/sysent.c kernel-source-2.6.16/abi/isc/sysent.c
1338 --- kernel-source-2.6.16.orig/abi/isc/sysent.c  1970-01-01 10:00:00.000000000 +1000
1339 +++ kernel-source-2.6.16/abi/isc/sysent.c       2006-04-27 18:50:24.000000000 +1000
1340 @@ -0,0 +1,460 @@
1341 +/*
1342 + * Copyright (c) 2001 Christoph Hellwig.
1343 + * All rights reserved.
1344 + *
1345 + * This program is free software; you can redistribute it and/or modify
1346 + * it under the terms of the GNU General Public License as published by
1347 + * the Free Software Foundation; either version 2 of the License, or
1348 + * (at your option) any later version.
1349 + *
1350 + * This program is distributed in the hope that it will be useful,
1351 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1352 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1353 + * GNU General Public License for more details.
1354 + *
1355 + * You should have received a copy of the GNU General Public License
1356 + * along with this program; if not, write to the Free Software
1357 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1358 + */
1359 +
1360 +#ident "%W% %G%"
1361 +
1362 +/*
1363 + * ISC personality switch.
1364 + */
1365 +#include <linux/config.h>
1366 +#include <linux/kernel.h>
1367 +#include <linux/module.h>
1368 +#include <linux/init.h>
1369 +#include <linux/personality.h>
1370 +#include <linux/syscalls.h>
1371 +#include <linux/socket.h>
1372 +#include <linux/net.h>
1373 +#include <asm/uaccess.h>
1374 +
1375 +#include <abi/svr4/sysent.h>
1376 +#include <abi/signal.h>
1377 +
1378 +#include <abi/util/errno.h>
1379 +#include <abi/util/sysent.h>
1380 +#include <abi/util/socket.h>
1381 +
1382 +MODULE_DESCRIPTION("ISC personality");
1383 +MODULE_AUTHOR("Christoph Hellwig, partially taken from iBCS");
1384 +MODULE_LICENSE("GPL");
1385 +
1386 +
1387 +/* forward */
1388 +static int isc_setostype(int);
1389 +
1390 +/*
1391 + * We could remove some of the long identity mapped runs but at the
1392 + * expense of extra comparisons for each mapping at run time...
1393 + */
1394 +static u_char isc_err_table[] = {
1395 +/*   0 -   9 */   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,
1396 +/*  10 -  19 */  10,  11,  12,  13,  14,  15,  16,  17,  18,  19,
1397 +/*  20 -  29 */  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
1398 +/*  30 -  39 */  30,  31,  32,  33,  34,  45,  78,  46,  89,  93,
1399 +/*  40 -  49 */  90,  90,  35,  36,  37,  38,  39,  40,  41,  42,
1400 +/*  50 -  59 */  43,  44,  50,  51,  52,  53,  54,  55,  56,  57,
1401 +/*  60 -  69 */  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,
1402 +/*  70 -  79 */  70,  71,  74,  76,  77,  79,  80,  81,  82,  83,
1403 +/*  80 -  89 */  84,  85,  86,  87,  88,  91,  92,  94,  95,  96,
1404 +/*  90 -  99 */  97,  98,  99, 120, 121, 122, 123, 124, 125, 126,
1405 +/* 100 - 109 */ 127, 128, 129, 130, 131, 132, 133, 134, 143, 144,
1406 +/* 110 - 119 */ 145, 146, 147, 148, 149, 150,  22, 135, 137, 138,
1407 +/* 120 - 122 */ 139, 140,  28
1408 +};
1409 +
1410 +/*
1411 + * Map Linux RESTART* values (512,513,514) to EINTR
1412 + */
1413 +static u_char lnx_err_table[] = {
1414 +/* 512 - 514 */ EINTR, EINTR, EINTR
1415 +};
1416 +
1417 +struct map_segment isc_err_map[] = {
1418 +       { 0,    0+sizeof(isc_err_table)-1,      isc_err_table },
1419 +       { 512,  512+sizeof(lnx_err_table)-1,    lnx_err_table },
1420 +       { -1 }
1421 +};
1422 +
1423 +/*
1424 + * ISC's error mapping is a little different.
1425 + */
1426 +static long linux_to_isc_signals[NSIGNALS+1] = {
1427 +/*  0 -  3 */  0,              IBCS_SIGHUP,    IBCS_SIGINT,    IBCS_SIGQUIT,
1428 +/*  4 -  7 */  IBCS_SIGILL,    IBCS_SIGTRAP,   IBCS_SIGABRT,   -1,
1429 +/*  8 - 11 */  IBCS_SIGFPE,    IBCS_SIGKILL,   IBCS_SIGUSR1,   IBCS_SIGSEGV,
1430 +/* 12 - 15 */  IBCS_SIGUSR2,   IBCS_SIGPIPE,   IBCS_SIGALRM,   IBCS_SIGTERM,
1431 +/* 16 - 19 */  IBCS_SIGSEGV,   IBCS_SIGCHLD,   ISC_SIGCONT,    ISC_SIGSTOP,
1432 +/* 20 - 23 */  ISC_SIGTSTP,    IBCS_SIGTTIN,   IBCS_SIGTTOU,   IBCS_SIGUSR1,
1433 +/* 24 - 27 */  IBCS_SIGGXCPU,  IBCS_SIGGXFSZ,  IBCS_SIGVTALRM, IBCS_SIGPROF,
1434 +/* 28 - 31 */  IBCS_SIGWINCH,  IBCS_SIGIO,     IBCS_SIGPWR,    -1,
1435 +/*     32 */   -1
1436 +};
1437 +
1438 +static long isc_to_linux_signals[NSIGNALS+1] = {
1439 +/*  0 -  3 */  0,              SIGHUP,         SIGINT,         SIGQUIT,
1440 +/*  4 -  7 */  SIGILL,         SIGTRAP,        SIGIOT,         SIGUNUSED,
1441 +/*  8 - 11 */  SIGFPE,         SIGKILL,        SIGUNUSED,      SIGSEGV,
1442 +/* 12 - 15 */  SIGUNUSED,      SIGPIPE,        SIGALRM,        SIGTERM,
1443 +/* 16 - 19 */  SIGUSR1,        SIGUSR2,        SIGCHLD,        SIGPWR,
1444 +/* 20 - 23 */  SIGWINCH,       -1,             SIGPOLL,        SIGCONT,
1445 +/* 24 - 27 */  SIGSTOP,        SIGTSTP,        SIGTTIN,        SIGTTOU,
1446 +/* 28 - 31 */  SIGVTALRM,      SIGPROF,        SIGXCPU,        SIGXFSZ,
1447 +/*     32 */   -1
1448 +};
1449 +
1450 +static char isc_socktype[] = {
1451 +       SOCK_STREAM,
1452 +       SOCK_DGRAM,
1453 +       0,
1454 +       SOCK_RAW,
1455 +       SOCK_RDM,
1456 +       SOCK_SEQPACKET
1457 +};
1458 +
1459 +static struct map_segment isc_socktype_map[] = {
1460 +       { 1, 6, isc_socktype },
1461 +       { -1 }
1462 +};
1463 +
1464 +static struct map_segment isc_sockopt_map[] =  {
1465 +       { 0x0001, 0x0001, (char *)SO_DEBUG },
1466 +       { 0x0002, 0x0002, (char *)__SO_ACCEPTCON },
1467 +       { 0x0004, 0x0004, (char *)SO_REUSEADDR },
1468 +       { 0x0008, 0x0008, (char *)SO_KEEPALIVE },
1469 +       { 0x0010, 0x0010, (char *)SO_DONTROUTE },
1470 +       { 0x0020, 0x0020, (char *)SO_BROADCAST },
1471 +       { 0x0040, 0x0040, (char *)SO_USELOOPBACK },
1472 +       { 0x0080, 0x0080, (char *)SO_LINGER },
1473 +       { 0x0100, 0x0100, (char *)SO_OOBINLINE },
1474 +       { 0x0200, 0x0200, (char *)SO_ORDREL },
1475 +       { 0x0400, 0x0400, (char *)SO_IMASOCKET },
1476 +       { 0x1001, 0x1001, (char *)SO_SNDBUF },
1477 +       { 0x1002, 0x1002, (char *)SO_RCVBUF },
1478 +       { 0x1003, 0x1003, (char *)SO_SNDLOWAT },
1479 +       { 0x1004, 0x1004, (char *)SO_RCVLOWAT },
1480 +       { 0x1005, 0x1005, (char *)SO_SNDTIMEO },
1481 +       { 0x1006, 0x1006, (char *)SO_RCVTIMEO },
1482 +       { 0x1007, 0x1007, (char *)SO_ERROR },
1483 +       { 0x1008, 0x1008, (char *)SO_TYPE },
1484 +       { 0x1009, 0x1009, (char *)SO_PROTOTYPE },
1485 +       { -1 }
1486 +};
1487 +
1488 +static struct map_segment isc_af_map[] =  {
1489 +       { 0, 2, NULL },
1490 +       { -1 }
1491 +};
1492 +
1493 +
1494 +static struct sysent sysisc_table[] = {
1495 +/*   0 */      { 0,                    Ukn,    "sysisc0",      ""      },
1496 +/*   1 */      { isc_setostype,        1,      "setostype",    "d"     },
1497 +/*   2 */      { sys_rename,           2,      "rename",       "ss"    },
1498 +/*   3 */      { abi_sigaction,        3,      "sigaction",    "dxx"   },
1499 +/*   4 */      { abi_sigprocmask,      3,      "sicprocmask",  "dxx"   },
1500 +/*   5 */      { 0,                    1,      "sigpending",   "x"     },
1501 +/*   6 */      { sys_getgroups16,      2,      "getgroups",    "dp"    },
1502 +/*   7 */      { sys_setgroups16,      2,      "setgroups",    "dp"    },
1503 +/*   8 */      { 0,                    Ukn,    "pathconf",     ""      },
1504 +/*   9 */      { 0,                    Ukn,    "fpathconf",    ""      },
1505 +/*  10 */      { ibcs_sysconf,         1,      "sysconf",      "d"     },
1506 +/*  11 */      { sys_waitpid,          3,      "waitpid",      "dxx"   },
1507 +/*  12 */      { sys_setsid,           0,      "setsid",       ""      },
1508 +/*  13 */      { sys_setpgid,          2,      "setpgid",      "dd"    },
1509 +/*  14 */      { 0,                    Ukn,    "adduser",      ""      },
1510 +/*  15 */      { 0,                    Ukn,    "setuser",      ""      },
1511 +/*  16 */      { 0,                    Ukn,    "sysisc16",     ""      },
1512 +/*  17 */      { abi_sigsuspend,       Spl,    "sigsuspend",   "x"     },
1513 +/*  18 */      { sys_symlink,          2,      "symlink",      "ss"    },
1514 +/*  19 */      { sys_readlink,         3,      "readlink",     "spd"   },
1515 +/*  20 */      { 0,                    Ukn,    "getmajor",     ""      }
1516 +};
1517 +
1518 +static void
1519 +isc_sysisc(struct pt_regs *regs)
1520 +{
1521 +       int sysno;
1522 +
1523 +       __get_user(sysno, ((unsigned long *)regs->esp)+1);
1524 +
1525 +       if (sysno >= ARRAY_SIZE(sysisc_table))
1526 +               set_error(regs, iABI_errors(-EINVAL));
1527 +       else
1528 +               lcall7_dispatch(regs, &sysisc_table[sysno], 2);
1529 +}
1530 +
1531 +static int
1532 +isc_setostype(int arg1)
1533 +{
1534 +        return 0;
1535 +}
1536 +
1537 +static struct sysent isc_syscall_table[] = {
1538 +   { abi_syscall,      Fast,   "syscall",      ""      }, /*    0 */
1539 +   { sys_exit,         1,      "exit",         "d"     }, /*    1 */
1540 +   { abi_fork,         Spl,    "fork",         ""      }, /*    2 */
1541 +   { abi_read,         3,      "read",         "dpd"   }, /*    3 */
1542 +   { sys_write,                3,      "write",        "dpd"   }, /*    4 */
1543 +   { svr4_open,                3,      "open",         "soo"   }, /*    5 */
1544 +   { sys_close,                1,      "close",        "d"     }, /*    6 */
1545 +   { abi_wait,         Spl,    "wait",         "xxx"   }, /*    7 */
1546 +   { sys_creat,                2,      "creat",        "so"    }, /*    8 */
1547 +   { sys_link,         2,      "link",         "ss"    }, /*    9 */
1548 +   { sys_unlink,       1,      "unlink",       "s"     }, /*   10 */
1549 +   { abi_exec,         Spl,    "exec",         "sxx"   }, /*   11 */
1550 +   { sys_chdir,                1,      "chdir",        "s"     }, /*   12 */
1551 +   { abi_time,         0,      "time",         ""      }, /*   13 */
1552 +   { svr4_mknod,       3,      "mknod",        "soo"   }, /*   14 */
1553 +   { sys_chmod,                2,      "chmod",        "so"    }, /*   15 */
1554 +   { sys_chown,                3,      "chown",        "sdd"   }, /*   16 */
1555 +   { abi_brk,          1,      "brk/break",    "x"     }, /*   17 */
1556 +   { svr4_stat,                2,      "stat",         "sp"    }, /*   18 */
1557 +   { sys_lseek,                3,      "seek/lseek",   "ddd"   }, /*   19 */
1558 +   { abi_getpid,       Spl,    "getpid",       ""      }, /*   20 */
1559 +   { 0,                        Ukn,    "mount",        ""      }, /*   21 */
1560 +   { sys_umount,       1,      "umount",       "s"     }, /*   22 */
1561 +   { sys_setuid,       1,      "setuid",       "d"     }, /*   23 */
1562 +   { abi_getuid,       Spl,    "getuid",       ""      }, /*   24 */
1563 +   { sys_stime,                1,      "stime",        "d"     }, /*   25 */
1564 +   { 0,                        Ukn,    "ptrace",       ""      }, /*   26 */
1565 +   { sys_alarm,                1,      "alarm",        "d"     }, /*   27 */
1566 +   { svr4_fstat,       2,      "fstat",        "dp"    }, /*   28 */
1567 +   { sys_pause,                0,      "pause",        ""      }, /*   29 */
1568 +   { sys_utime,                2,      "utime",        "xx"    }, /*   30 */
1569 +   { 0,                        Ukn,    "stty",         ""      }, /*   31 */
1570 +   { 0,                        Ukn,    "gtty",         ""      }, /*   32 */
1571 +   { sys_access,       2,      "access",       "so"    }, /*   33 */
1572 +   { sys_nice,         1,      "nice",         "d"     }, /*   34 */
1573 +   { svr4_statfs,      4,      "statfs",       "spdd"  }, /*   35 */
1574 +   { sys_sync,         0,      "sync",         ""      }, /*   36 */
1575 +   { abi_kill,         2,      "kill",         "dd"    }, /*   37 */
1576 +   { svr4_fstatfs,     4,      "fstatfs",      "dpdd"  }, /*   38 */
1577 +   { abi_procids,      Spl,    "procids",      "d"     }, /*   39 */
1578 +   { 0,                        Ukn,    "cxenix",       ""      }, /*   40 */
1579 +   { sys_dup,          1,      "dup",          "d"     }, /*   41 */
1580 +   { abi_pipe,         Spl,    "pipe",         ""      }, /*   42 */
1581 +   { sys_times,                1,      "times",        "p"     }, /*   43 */
1582 +   { 0,                        Ukn,    "prof",         ""      }, /*   44 */
1583 +   { 0,                        Ukn,    "lock/plock",   ""      }, /*   45 */
1584 +   { sys_setgid,       1,      "setgid",       "d"     }, /*   46 */
1585 +   { abi_getgid,       Spl,    "getgid",       ""      }, /*   47 */
1586 +   { abi_sigfunc,      Fast,   "sigfunc",      "xxx"   }, /*   48 */
1587 +   { svr4_msgsys,      Spl,    "msgsys",       "dxddd" }, /*   49 */
1588 +   { svr4_sysi86,      3,      "sysi86",       "d"     }, /*   50 */
1589 +   { sys_acct,         1,      "acct/sysacct", "x"     }, /*   51 */
1590 +   { svr4_shmsys,      Fast,   "shmsys",       "ddxo"  }, /*   52 */
1591 +   { svr4_semsys,      Spl,    "semsys",       "dddx"  }, /*   53 */
1592 +   { svr4_ioctl,       Spl,    "ioctl",        "dxx"   }, /*   54 */
1593 +   { 0,                        3,      "uadmin",       "xxx"   }, /*   55 */
1594 +   { 0,                        Ukn,    "?",            ""      }, /*   56 */
1595 +   { v7_utsname,       1,      "utsys",        "x"     }, /*   57 */
1596 +   { sys_fsync,                1,      "fsync",        "d"     }, /*   58 */
1597 +   { abi_exec,         Spl,    "execv",        "spp"   }, /*   59 */
1598 +   { sys_umask,                1,      "umask",        "o"     }, /*   60 */
1599 +   { sys_chroot,       1,      "chroot",       "s"     }, /*   61 */
1600 +   { svr4_fcntl,       3,      "fcntl",        "dxx"   }, /*   62 */
1601 +   { svr4_ulimit,      2,      "ulimit",       "xx"    }, /*   63 */
1602 +   { 0,                        Ukn,    "?",            ""      }, /*   64 */
1603 +   { 0,                        Ukn,    "?",            ""      }, /*   65 */
1604 +   { 0,                        Ukn,    "?",            ""      }, /*   66 */
1605 +   { 0,                        Ukn,    "?",            ""      }, /*   67 */
1606 +   { 0,                        Ukn,    "?",            ""      }, /*   68 */
1607 +   { 0,                        Ukn,    "?",            ""      }, /*   69 */
1608 +   { 0,                        Ukn,    "advfs",        ""      }, /*   70 */
1609 +   { 0,                        Ukn,    "unadvfs",      ""      }, /*   71 */
1610 +   { 0,                        Ukn,    "rmount",       ""      }, /*   72 */
1611 +   { 0,                        Ukn,    "rumount",      ""      }, /*   73 */
1612 +   { 0,                        Ukn,    "rfstart",      ""      }, /*   74 */
1613 +   { 0,                        Ukn,    "?",            ""      }, /*   75 */
1614 +   { 0,                        Ukn,    "rdebug",       ""      }, /*   76 */
1615 +   { 0,                        Ukn,    "rfstop",       ""      }, /*   77 */
1616 +   { 0,                        Ukn,    "rfsys",        ""      }, /*   78 */
1617 +   { sys_rmdir,                1,      "rmdir",        "s"     }, /*   79 */
1618 +   { abi_mkdir,                2,      "mkdir",        "so"    }, /*   80 */
1619 +   { svr4_getdents,    3,      "getdents",     "dxd"   }, /*   81 */
1620 +   { 0,                        Ukn,    "libattach",    ""      }, /*   82 */
1621 +   { 0,                        Ukn,    "libdetach",    ""      }, /*   83 */
1622 +   { svr4_sysfs,       3,      "sysfs",        "dxx"   }, /*   84 */
1623 +   { svr4_getmsg,      Spl,    "getmsg",       "dxxx"  }, /*   85 */
1624 +   { svr4_putmsg,      Spl,    "putmsg",       "dxxd"  }, /*   86 */
1625 +   { sys_poll,         3,      "poll",         "xdd"   }, /*   87 */
1626 +   { svr4_lstat,       2,      "lstat",        "sp"    }, /*   88 */
1627 +   { sys_symlink,      2,      "symlink",      "ss"    }, /*   89 */
1628 +   { sys_readlink,     3,      "readlink",     "spd"   }, /*   90 */
1629 +   { sys_setgroups,    2,      "setgroups",    "dp"    }, /*   91 */
1630 +   { sys_getgroups,    2,      "getgroups",    "dp"    }, /*   92 */
1631 +   { sys_fchmod,       2,      "fchmod",       "do"    }, /*   93 */
1632 +   { sys_fchown,       3,      "fchown",       "ddd"   }, /*   94 */
1633 +   { abi_sigprocmask,  3,      "sigprocmask",  "dxx"   }, /*   95 */
1634 +   { abi_sigsuspend,   Spl,    "sigsuspend",   "x"     }, /*   96 */
1635 +   { 0,                        2,      "sigaltstack",  "xx"    }, /*   97 */
1636 +   { abi_sigaction,    3,      "sigaction",    "dxx"   }, /*   98 */
1637 +   { svr4_sigpending,  2,      "sigpending",   "dp"    }, /*   99 */
1638 +   { svr4_context,     Spl,    "context",      ""      }, /*   100 */
1639 +   { 0,                        Ukn,    "evsys",        ""      }, /*   101 */
1640 +   { 0,                        Ukn,    "evtrapret",    ""      }, /*   102 */
1641 +   { svr4_statvfs,     2,      "statvfs",      "sp"    }, /*   103 */
1642 +   { svr4_fstatvfs,    2,      "fstatvfs",     "dp"    }, /*   104 */
1643 +   { isc_sysisc,       Fast,   "sysisc",       ""      }, /*   105 */
1644 +   { 0,                        Ukn,    "nfssys",       ""      }, /*   106 */
1645 +   { 0,                        4,      "waitid",       "ddxd"  }, /*   107 */
1646 +   { 0,                        3,      "sigsendsys",   "ddd"   }, /*   108 */
1647 +   { svr4_hrtsys,      Spl,    "hrtsys",       "xxx"   }, /*   109 */
1648 +   { 0,                        3,      "acancel",      "dxd"   }, /*   110 */
1649 +   { 0,                        Ukn,    "async",        ""      }, /*   111 */
1650 +   { 0,                        Ukn,    "priocntlsys",  ""      }, /*   112 */
1651 +   { svr4_pathconf,    2,      "pathconf",     "sd"    }, /*   113 */
1652 +   { 0,                        3,      "mincore",      "xdx"   }, /*   114 */
1653 +   { svr4_mmap,                6,      "mmap",         "xxxxdx"},/*   115 */
1654 +   { sys_mprotect,     3,      "mprotect",     "xdx"   },/*   116 */
1655 +   { sys_munmap,       2,      "munmap",       "xd"    },/*   117 */
1656 +   { svr4_fpathconf,   2,      "fpathconf",    "dd"    }, /*   118 */
1657 +   { abi_fork,         Spl,    "vfork",        ""      }, /*   119 */
1658 +   { sys_fchdir,       1,      "fchdir",       "d"     }, /*   120 */
1659 +   { sys_readv,                3,      "readv",        "dxd"   }, /*   121 */
1660 +   { sys_writev,       3,      "writev",       "dxd"   }, /*   122 */
1661 +   { svr4_xstat,       3,      "xstat",        "dsx"   }, /*   123 */
1662 +   { svr4_lxstat,      3,      "lxstat",       "dsx"   }, /*   124 */
1663 +   { svr4_fxstat,      3,      "fxstat",       "ddx"   }, /*   125 */
1664 +   { svr4_xmknod,      4,      "xmknod",       "dsox"  }, /*   126 */
1665 +   { 0,                        Ukn,    "syslocal",     "d"     }, /*   127 */
1666 +   { svr4_getrlimit,   2,      "setrlimit",    "dx"    }, /*   128 */
1667 +   { svr4_setrlimit,   2,      "getrlimit",    "dx"    }, /*   129 */
1668 +   { 0,                        3,      "lchown",       "sdd"   }, /*   130 */
1669 +   { 0,                        Ukn,    "memcntl",      ""      }, /*   131 */
1670 +#if defined(CONFIG_ABI_XTI)
1671 +   { svr4_getpmsg,     5,      "getpmsg",      "dxxxx" }, /*   132 */
1672 +   { svr4_putpmsg,     5,      "putpmsg",      "dxxdd" }, /*   133 */
1673 +#else
1674 +   { 0,                        5,      "getpmsg",      "dxxxx" }, /*   132 */
1675 +   { 0,                        5,      "putpmsg",      "dxxdd" }, /*   133 */
1676 +#endif
1677 +   { sys_rename,       2,      "rename",       "ss"    }, /*   134 */
1678 +   { abi_utsname,      1,      "uname",        "x"     }, /*   135 */
1679 +   { svr4_setegid,     1,      "setegid",      "d"     }, /*   136 */
1680 +   { svr4_sysconfig,   1,      "sysconfig",    "d"     }, /*   137 */
1681 +   { 0,                        Ukn,    "adjtime",      ""      }, /*   138 */
1682 +   { svr4_sysinfo,     3,      "systeminfo",   "dsd"   }, /*   139 */
1683 +   { socksys_syscall,  1,      "socksys",      "x"     }, /*   140 */
1684 +   { svr4_seteuid,     1,      "seteuid",      "d"     }, /*   141 */
1685 +   { 0,                        Ukn,    "?",            ""      }, /*   142 */
1686 +   { 0,                        Ukn,    "?",            ""      }, /*   143 */
1687 +   { 0,                        2,      "secsys",       "dx"    }, /*   144 */
1688 +   { 0,                        4,      "filepriv",     "sdxd"  }, /*   145 */
1689 +   { 0,                        3,      "procpriv",     "dxd"   }, /*   146 */
1690 +   { 0,                        3,      "devstat",      "sdx"   }, /*   147 */
1691 +   { 0,                        5,      "aclipc",       "ddddx" }, /*   148 */
1692 +   { 0,                        3,      "fdevstat",     "ddx"   }, /*   149 */
1693 +   { 0,                        3,      "flvlfile",     "ddx"   }, /*   150 */
1694 +   { 0,                        3,      "lvlfile",      "sdx"   }, /*   151 */
1695 +   { 0,                        Ukn,    "?",            ""      }, /*   152 */
1696 +   { 0,                        2,      "lvlequal",     "xx"    }, /*   153 */
1697 +   { 0,                        2,      "lvlproc",      "dx"    }, /*   154 */
1698 +   { 0,                        Ukn,    "?",            ""      }, /*   155 */
1699 +   { 0,                        4,      "lvlipc",       "dddx"  }, /*   156 */
1700 +   { 0,                        4,      "acl",          "sddx"  }, /*   157 */
1701 +   { 0,                        Ukn,    "auditevt",     ""      }, /*   158 */
1702 +   { 0,                        Ukn,    "auditctl",     ""      }, /*   159 */
1703 +   { 0,                        Ukn,    "auditdmp",     ""      }, /*   160 */
1704 +   { 0,                        Ukn,    "auditlog",     ""      }, /*   161 */
1705 +   { 0,                        Ukn,    "auditbuf",     ""      }, /*   162 */
1706 +   { 0,                        2,      "lvldom",       "xx"    }, /*   163 */
1707 +   { 0,                        Ukn,    "lvlvfs",       ""      }, /*   164 */
1708 +   { 0,                        2,      "mkmld",        "so"    }, /*   165 */
1709 +   { 0,                        Ukn,    "mlddone",      ""      }, /*   166 */
1710 +   { 0,                        2,      "secadvise",    "xx"    }, /*   167 */
1711 +   { 0,                        Ukn,    "online",       ""      }, /*   168 */
1712 +   { sys_setitimer,    3,      "setitimer",    "dxx"   }, /*   169 */
1713 +   { sys_getitimer,    2,      "getitimer",    "dx"    }, /*   170 */
1714 +   { sys_gettimeofday, 2,      "gettimeofday", "xx"    }, /*   171 */
1715 +   { sys_settimeofday, 2,      "settimeofday", "xx"    }, /*   172 */
1716 +   { 0,                        Ukn,    "lwpcreate",    ""      }, /*   173 */
1717 +   { 0,                        Ukn,    "lwpexit",      ""      }, /*   174 */
1718 +   { 0,                        Ukn,    "lwpwait",      ""      }, /*   175 */
1719 +   { 0,                        Ukn,    "lwpself",      ""      }, /*   176 */
1720 +   { 0,                        Ukn,    "lwpinfo",      ""      }, /*   177 */
1721 +   { 0,                        Ukn,    "lwpprivate",   ""      }, /*   178 */
1722 +   { 0,                        Ukn,    "processorbind",""      }, /*   179 */
1723 +   { 0,                        Ukn,    "processorexbind",""    }, /*   180 */
1724 +   { 0,                        Ukn,    "",             ""      }, /*   181 */
1725 +   { 0,                        Ukn,    "sync_mailbox", ""      }, /*   182 */
1726 +   { 0,                        Ukn,    "prepblock",    ""      }, /*   183 */
1727 +   { 0,                        Ukn,    "block",        ""      }, /*   184 */
1728 +   { 0,                        Ukn,    "rdblock",      ""      }, /*   185 */
1729 +   { 0,                        Ukn,    "unblock",      ""      }, /*   186 */
1730 +   { 0,                        Ukn,    "cancelblock",  ""      }, /*   187 */
1731 +   { 0,                        Ukn,    "?",            ""      }, /*   188 */
1732 +   { 0,                        Ukn,    "pread",        ""      }, /*   189 */
1733 +   { 0,                        Ukn,    "pwrite",       ""      }, /*   190 */
1734 +   { sys_truncate,     2,      "truncate",     "sd"    }, /*   191 */
1735 +   { sys_ftruncate,    2,      "ftruncate",    "dd"    }, /*   192 */
1736 +   { 0,                        Ukn,    "lwpkill",      ""      }, /*   193 */
1737 +   { 0,                        Ukn,    "sigwait",      ""      }, /*   194 */
1738 +   { 0,                        Ukn,    "fork1",        ""      }, /*   195 */
1739 +   { 0,                        Ukn,    "forkall",      ""      }, /*   196 */
1740 +   { 0,                        Ukn,    "modload",      ""      }, /*   197 */
1741 +   { 0,                        Ukn,    "moduload",     ""      }, /*   198 */
1742 +   { 0,                        Ukn,    "modpath",      ""      }, /*   199 */
1743 +   { 0,                        Ukn,    "modstat",      ""      }, /*   200 */
1744 +   { 0,                        Ukn,    "modadm",       ""      }, /*   201 */
1745 +   { 0,                        Ukn,    "getksym",      ""      }, /*   202 */
1746 +   { 0,                        Ukn,    "lwpsuspend",   ""      }, /*   203 */
1747 +   { 0,                        Ukn,    "lwpcontinue",  ""      }, /*   204 */
1748 +   { 0,                        Ukn,    "?",            ""      }, /*   205 */
1749 +   { 0,                        Ukn,    "?",            ""      }, /*   206 */
1750 +   { 0,                        Ukn,    "?",            ""      }, /*   207 */
1751 +   { 0,                        Ukn,    "?",            ""      },
1752 +   { 0,                        Ukn,    "?",            ""      },
1753 +   { 0,                        Ukn,    "?",            ""      },
1754 +   { 0,                        Ukn,    "?",            ""      },
1755 +   { 0,                        Ukn,    "?",            ""      },
1756 +   { 0,                        Ukn,    "?",            ""      },
1757 +   { 0,                        Ukn,    "?",            ""      },
1758 +   { 0,                        Ukn,    "?",            ""      }
1759 +};
1760 +
1761 +static void
1762 +isc_lcall7(int segment, struct pt_regs *regs)
1763 +{
1764 +       int sysno = regs->eax & 0xff;
1765 +
1766 +       if (sysno >= ARRAY_SIZE(isc_syscall_table))
1767 +               set_error(regs, iABI_errors(-EINVAL));
1768 +       else
1769 +               lcall7_dispatch(regs, &isc_syscall_table[sysno], 1);
1770 +}
1771 +
1772 +static struct exec_domain isc_exec_domain = {
1773 +       name:           "ISC",
1774 +       handler:        isc_lcall7,
1775 +       pers_low:       5 /* PER_ISCR4 */,
1776 +       pers_high:      5 /* PER_ISCR4 */,
1777 +       signal_map:     isc_to_linux_signals,
1778 +       signal_invmap:  linux_to_isc_signals,
1779 +       err_map:        isc_err_map,
1780 +       socktype_map:   isc_socktype_map,
1781 +       sockopt_map:    isc_sockopt_map,
1782 +       af_map:         isc_af_map,
1783 +       module:         THIS_MODULE
1784 +};
1785 +
1786 +static int __init
1787 +isc_init(void)
1788 +{
1789 +       return register_exec_domain(&isc_exec_domain);
1790 +}
1791 +
1792 +
1793 +static void __exit
1794 +isc_exit(void)
1795 +{
1796 +       unregister_exec_domain(&isc_exec_domain);
1797 +}
1798 +
1799 +module_init(isc_init);
1800 +module_exit(isc_exit);
1801 diff -Nur kernel-source-2.6.16.orig/abi/Kconfig kernel-source-2.6.16/abi/Kconfig
1802 --- kernel-source-2.6.16.orig/abi/Kconfig       1970-01-01 10:00:00.000000000 +1000
1803 +++ kernel-source-2.6.16/abi/Kconfig    2006-04-27 18:50:24.000000000 +1000
1804 @@ -0,0 +1,166 @@
1805 +#
1806 +# Linux-ABI configuration
1807 +#
1808 +
1809 +# this file gets source'ed into the kernel file formats menu entry
1810 +# via ./fs/Kconfig.binfmt
1811 +
1812 +config ABI
1813 +        bool "Extended Linux-ABI support (alien binarys and syscalls)"
1814 +       depends on X86=y
1815 +        default n
1816 +        help
1817 +          Support for a few alien syscall interfaces. This allows you to run
1818 +          a binary that got build for other Unix compatible platforms.
1819 +
1820 +
1821 +config ABI_SVR4
1822 +        tristate "SVR3/SVR4 family syscall support for x86 binarys"
1823 +       depends on X86=y
1824 +        depends on ABI
1825 +        default n
1826 +
1827 +
1828 +comment "SVR3/SVR4 based syscall support for x86: (please check one or more)"
1829 +        depends on ABI_SVR4
1830 +
1831 +config ABI_IBCS
1832 +        tristate "iBCS2/iABI4 syscall support"
1833 +        depends on ABI_SVR4
1834 +
1835 +config ABI_ISC
1836 +        tristate "ISC syscall support"
1837 +        depends on ABI_SVR4
1838 +
1839 +config ABI_SCO
1840 +        tristate "SCO OpenServer 5/SCO Unix 3.x/Xenix syscall support"
1841 +        depends on ABI_SVR4
1842 +
1843 +config ABI_SOLARIS
1844 +        tristate "Solaris 2.x syscall support"
1845 +        depends on ABI_SVR4
1846 +
1847 +config ABI_UW7
1848 +        tristate "UnixWare 7.x syscall support"
1849 +        depends on ABI_SVR4
1850 +
1851 +config ABI_WYSE
1852 +        tristate "Wyse V/386 syscall support"
1853 +        depends on ABI_SVR4
1854 +
1855 +
1856 +comment "SVR3/SVR4 related binary format support for x86:"
1857 +        depends on ABI_SVR4
1858 +
1859 +config BINFMT_COFF
1860 +        tristate "COFF binary support (SVR3)"
1861 +        depends on ABI_SVR4
1862 +
1863 +config BINFMT_XOUT
1864 +        tristate "x.out binary support (Xenix)"
1865 +        depends on ABI_SVR4
1866 +
1867 +config BINFMT_XOUT_X286
1868 +        bool "x.out segmented binary support (Xenix/80286)"
1869 +        depends on BINFMT_XOUT
1870 +
1871 +
1872 +config ABI_LATE_PROBING
1873 +        bool
1874 +        prompt "Late probing of personality trough syscall handler"
1875 +        depends on ABI
1876 +        default y
1877 +        help
1878 +          There is a minor general uncertainty on identification of binary
1879 +          formats. It might happen that  statically linked SVr4 binary could
1880 +          be falsely assigned to a Linux personality. Solaris/x86 binarys
1881 +          are another sample for a falsely assigned Linux personality.
1882 +          If this option is set the lcall handler for Linux will switch
1883 +          to SVr4 personality as soon as lcall 0x07 is used, or it will
1884 +          switch to Solaris personality when lcall 0x27 is used.
1885 +          Since this on-the-fly personality switching is a one way path
1886 +          a malicious program might make use of exactly that ability.
1887 +          For system consistency reasons personality detection should go
1888 +          that way. The better solution is to improve the personality
1889 +          detection code at load time in contrast to runtime detection.
1890 +          At present load time probing is not perfect, so better say yes.
1891 +
1892 +config ABI_TRACE
1893 +        bool
1894 +        prompt "Include prints for syscall tracking via ABI_TRACE ioctl"
1895 +        depends on ABI
1896 +        default y
1897 +        help
1898 +          This option allows to control the inclusion of code that prints
1899 +          kernel messages for tracking special syscalls events like errors.
1900 +          Typically this messages further have to be enabled via the
1901 +          ABI_TRACE ioctl. This option will not remove the ioctl interface
1902 +          but will only remove the backend coding which produces the prints.
1903 +          You can disable thise option if you want to reduce the kernel size
1904 +          or have other concerns, e.g. code size or possible message floods.
1905 +
1906 +# --- internal options, values will get derived from prior settings ---
1907 +
1908 +# the abi-util (./abi/util) codebase
1909 +# does currently only contain code for the ABI_TRACE coding
1910 +# and has to be present as soon as the SVR4 code is present.
1911 +config ABI_UTIL
1912 +        tristate
1913 +        depends on ABI_TRACE
1914 +        default y if ABI_SVR4=y
1915 +        default m if ABI_SVR4=m
1916 +        default n
1917 +
1918 +config ABI_SPX
1919 +        bool
1920 +        depends on ABI!=n
1921 +        default y
1922 +
1923 +config ABI_XTI
1924 +        bool
1925 +        depends on ABI!=n
1926 +        default y
1927 +
1928 +config ABI_TLI_OPTMGMT
1929 +        bool
1930 +        depends on ABI!=n
1931 +        default y
1932 +
1933 +config ABI_XTI_OPTMGMT
1934 +        bool
1935 +        depends on ABI!=n
1936 +        default n
1937 +
1938 +# there are syscall interfaces which do get statically linked
1939 +config ABI_SYSCALL_STATICS
1940 +        bool
1941 +        default y if ABI_UW7=y || ABI_SOLARIS=y || ABI_IBCS=y || ABI_ISC=y || ABI_SCO=y || ABI_WYSE=y
1942 +        default n
1943 +
1944 +# there are syscall interfaces which do get build as module
1945 +config ABI_SYSCALL_MODULES
1946 +        bool
1947 +        default y if ABI_UW7=m || ABI_SOLARIS=m || ABI_IBCS=m || ABI_ISC=m || ABI_SCO=m || ABI_WYSE=m
1948 +        default n
1949 +
1950 +# the LCALL7 code for SVR4 family support must _not_ be a module
1951 +# when there is at least a single, statically bound syscall driver.
1952 +# if there are only modules, then the LCALL code can be a module as well.
1953 +# if there is no module at all then we dont need the LCALL7 code.
1954 +config ABI_LCALL7
1955 +        tristate
1956 +        default y if ABI_SYSCALL_STATICS=y
1957 +        default m if ABI_SYSCALL_MODULES=y
1958 +        default n
1959 +
1960 +# notes:
1961 +# * only a static SVR4 core coding will allow static syscall drivers,
1962 +# * setting a syscall driver to modules will be the only way to allow
1963 +#   this single module to plug into SVR4 core coding.
1964 +# * there is no generic "register my entrypoints" request for modules
1965 +#   in the curent codebase. (this might be a TODO)
1966 +# * the exported LCALL7 syms will only be usefull to syscall driver modules.
1967 +# * LCALL7 is only usefull if there are syscall drivers (static or module).
1968 +# * an "empty" SVR4 might be usefull for debugging and non-x86 targets.
1969 +
1970 +### EOF ###
1971 diff -Nur kernel-source-2.6.16.orig/abi/Makefile kernel-source-2.6.16/abi/Makefile
1972 --- kernel-source-2.6.16.orig/abi/Makefile      1970-01-01 10:00:00.000000000 +1000
1973 +++ kernel-source-2.6.16/abi/Makefile   2006-04-27 18:50:24.000000000 +1000
1974 @@ -0,0 +1,8 @@
1975 +obj-$(CONFIG_ABI)               += util/
1976 +obj-$(CONFIG_ABI_SVR4)          += svr4/
1977 +obj-$(CONFIG_ABI_SCO)           += sco/ cxenix/
1978 +obj-$(CONFIG_ABI_WYSE)          += wyse/
1979 +obj-$(CONFIG_ABI_UW7)           += uw7/
1980 +obj-$(CONFIG_ABI_SOLARIS)       += solaris/
1981 +obj-$(CONFIG_ABI_IBCS)          += ibcs/
1982 +obj-$(CONFIG_ABI_ISC)           += isc/
1983 diff -Nur kernel-source-2.6.16.orig/abi/sco/ioctl.c kernel-source-2.6.16/abi/sco/ioctl.c
1984 --- kernel-source-2.6.16.orig/abi/sco/ioctl.c   1970-01-01 10:00:00.000000000 +1000
1985 +++ kernel-source-2.6.16/abi/sco/ioctl.c        2006-04-27 18:50:24.000000000 +1000
1986 @@ -0,0 +1,184 @@
1987 +/*
1988 + * ioctl.c - SCO Unix ioctl(2) switch
1989 + *
1990 + * Copyright (C) 1991, 1992  Linus Torvalds
1991 + *
1992 + * Written by Drew Sullivan.
1993 + * Rewritten by Mike Jagdis.
1994 + */
1995 +
1996 +#ident "%W% %G%"
1997 +
1998 +#include <linux/config.h>
1999 +#include <linux/errno.h>
2000 +#include <linux/kernel.h>
2001 +#include <linux/ptrace.h>
2002 +#include <asm/uaccess.h>
2003 +
2004 +#include <asm/abi_machdep.h>
2005 +#include <abi/sco/ioctl.h>
2006 +#include <abi/svr4/ioctl.h>
2007 +
2008 +
2009 +/*
2010 + * do_ioctl() is a meta mapper, that is
2011 + * it looks up the class of the ioctl and then
2012 + * dispatchs to lower level routines to handle the
2013 + * mapping of the actual ioctls
2014 + */
2015 +static int
2016 +do_ioctl(struct pt_regs *regs, int fd, unsigned long ioctl_num, void *arg)
2017 +{
2018 +       unsigned int class = ioctl_num >> 8;
2019 +       char class_str[4];
2020 +
2021 +       switch (class) {
2022 +
2023 +       /*
2024 +        * SCO ioctls on the pseudo NFS device probably.
2025 +        */
2026 +       case 0:
2027 +               return abi_ioctl_socksys(fd, ioctl_num, arg);
2028 +
2029 +       /*
2030 +        * SCO console keyboard stuff?
2031 +        */
2032 +       case 'A':
2033 +               return -EINVAL;
2034 +
2035 +       case 'm':
2036 +               return sco_tape_ioctl(fd, ioctl_num, arg);
2037 +
2038 +       case 't':
2039 +               return bsd_ioctl_termios(fd, ioctl_num, arg);
2040 +
2041 +       case 'f':
2042 +               return svr4_fil_ioctl(fd, ioctl_num, arg);
2043 +
2044 +       /*
2045 +        * Xenix ioctl compatibility.
2046 +        */
2047 +       case 'T':
2048 +               return svr4_term_ioctl(fd, ioctl_num & 0xFF, arg);
2049 +
2050 +       case ('i' << 16) | ('X' << 8):  /* iBCS2 POSIX */
2051 +       case 'x':                       /* Pre-iBCS2 POSIX */
2052 +               return sco_term_ioctl(fd, ioctl_num & 0xFF, arg);
2053 +
2054 +       case 'C':
2055 +       case 'c':
2056 +               return svr4_console_ioctl(fd, ioctl_num, arg);
2057 +
2058 +       case ('i' << 16) | ('C' << 8):  /* iBCS2 POSIX */
2059 +               return svr4_video_ioctl(fd, ioctl_num & 0xFF, arg);
2060 +
2061 +       /*
2062 +        * These aren't implemented and are never likely to be as they
2063 +        * are specific to drivers for obscure hardware. (For those
2064 +        * that don't know they're the JERQ ioctls. Says it all
2065 +        * really!)
2066 +        */
2067 +       case 'j':
2068 +               return -EINVAL;
2069 +
2070 +       /*
2071 +        * The 'S' set could also be display mode switch
2072 +        * ioctls in a SCO 3.2.x x<4 environment. It should
2073 +        * depend on the descriptor they are applied to.
2074 +        * According to ISC the Xenix STREAMS ioctls had the
2075 +        * high bit set on the command to differentiate them
2076 +        * from mode switch ioctls. Yuk, yuk, yuk...
2077 +        */
2078 +       case 'S':
2079 +               return svr4_stream_ioctl(regs, fd, ioctl_num & 0x7F, arg);
2080 +
2081 +       /*
2082 +        * These are STREAMS socket module ioctls.
2083 +        */
2084 +       case 'I':
2085 +#if defined(CONFIG_ABI_XTI)
2086 +               return svr4_sockmod_ioctl(fd, ioctl_num & 0xFF, arg);
2087 +#else
2088 +               return -EINVAL;
2089 +#endif
2090 +
2091 +       /*
2092 +        * These are SCO <vtkd.h> ioctls - see vtkd.h
2093 +        */
2094 +       case 'v':
2095 +       case 'K':
2096 +               return sco_vtkbd_ioctl(fd, ioctl_num, arg);
2097 +
2098 +       /*
2099 +        * SCO channel mapping. I can't find any documentation
2100 +        * for this. These are the LD?MAP ioctls defined in
2101 +        * sys/termio.h and sys/emap.h. They are used by mapchan.
2102 +        */
2103 +       case 'D':
2104 +               return -EINVAL;
2105 +       }
2106 +
2107 +       /*
2108 +        * If we haven't handled it yet it must be a BSD style ioctl
2109 +        * with a (possible) argument description in the high word of
2110 +        * the opcode.
2111 +        */
2112 +       switch (class & 0xff) {
2113 +
2114 +       /*
2115 +        * From SVR4 as specified in sys/iocomm.h.
2116 +        */
2117 +       case 'f':
2118 +               return svr4_fil_ioctl(fd, ioctl_num, arg);
2119 +
2120 +       /*
2121 +        * BSD or V7 terminal ioctls.
2122 +        */
2123 +       case 't':
2124 +               return bsd_ioctl_termios(fd, ioctl_num, arg);
2125 +
2126 +       /*
2127 +        * SVR3 streams based socket TCP/IP ioctls.
2128 +        *
2129 +        * These are handed over to the standard ioctl
2130 +        * handler since /dev/socksys is an emulated device
2131 +        * and front ends any sockets created through it.
2132 +        * Note that 'S' ioctls without the BSDish argument
2133 +        * type in the high bytes are STREAMS ioctls and 'I'
2134 +        * ioctls without the BSDish type in the high bytes
2135 +        * are the STREAMS socket module ioctls. (see above).
2136 +        */
2137 +       case 'S':
2138 +       case 'R':
2139 +       case 'I':
2140 +               return abi_ioctl_socksys(fd, ioctl_num, arg);
2141 +       }
2142 +
2143 +       /*
2144 +        * If nothing has handled it yet someone may have to do some
2145 +        * more work...
2146 +        */
2147 +       class_str[0] = class & 0xFF0000 ? (char)((class >> 16) & 0xFF) : '.';
2148 +       class_str[1] = class & 0x00FF00 ? (char)((class >>  8) & 0xFF) : '.';
2149 +       class_str[2] = class & 0x0000FF ? (char)((class      ) & 0xFF) : '.';
2150 +       class_str[3] = 0;
2151 +
2152 +       printk(KERN_DEBUG "sco: ioctl(%d, %lx[%s], 0x%p) unsupported\n",
2153 +               fd, ioctl_num, class_str, arg);
2154 +
2155 +       return -EINVAL;
2156 +}
2157 +
2158 +int
2159 +sco_ioctl(struct pt_regs *regs)
2160 +{
2161 +       u_int                   num;
2162 +       int                     fd;
2163 +       caddr_t                 data;
2164 +
2165 +       fd = (int)get_syscall_parameter(regs, 0);
2166 +       num = (u_int)get_syscall_parameter(regs, 1);
2167 +       data = (caddr_t)get_syscall_parameter(regs, 2);
2168 +
2169 +       return do_ioctl(regs, fd, num, data);
2170 +}
2171 diff -Nur kernel-source-2.6.16.orig/abi/sco/Makefile kernel-source-2.6.16/abi/sco/Makefile
2172 --- kernel-source-2.6.16.orig/abi/sco/Makefile  1970-01-01 10:00:00.000000000 +1000
2173 +++ kernel-source-2.6.16/abi/sco/Makefile       2006-04-27 18:50:24.000000000 +1000
2174 @@ -0,0 +1,12 @@
2175 +
2176 +abi-sco-objs   := sysent.o misc.o mmap.o ptrace.o secureware.o \
2177 +                  stat.o statvfs.o
2178 +
2179 +# various ioctl emulation stuff
2180 +abi-sco-objs   += ioctl.o termios.o tapeio.o vtkbd.o
2181 +
2182 +
2183 +obj-$(CONFIG_ABI_SCO)          += abi-sco.o
2184 +
2185 +abi-sco.o: $(abi-sco-objs)
2186 +       $(LD) -r -o $@ $(abi-sco-objs)
2187 diff -Nur kernel-source-2.6.16.orig/abi/sco/misc.c kernel-source-2.6.16/abi/sco/misc.c
2188 --- kernel-source-2.6.16.orig/abi/sco/misc.c    1970-01-01 10:00:00.000000000 +1000
2189 +++ kernel-source-2.6.16/abi/sco/misc.c 2006-04-27 18:50:24.000000000 +1000
2190 @@ -0,0 +1,98 @@
2191 +/*
2192 + * Copyright (c) 2001 Christoph Hellwig.
2193 + * All rights reserved.
2194 + *
2195 + * This program is free software; you can redistribute it and/or modify
2196 + * it under the terms of the GNU General Public License as published by
2197 + * the Free Software Foundation; either version 2 of the License, or
2198 + * (at your option) any later version.
2199 + *
2200 + * This program is distributed in the hope that it will be useful,
2201 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2202 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2203 + * GNU General Public License for more details.
2204 + *
2205 + * You should have received a copy of the GNU General Public License
2206 + * along with this program; if not, write to the Free Software
2207 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2208 + */
2209 +
2210 +#ident "%W% %G%"
2211 +
2212 +/*
2213 + * Misc SCO syscalls.
2214 + */
2215 +#include <linux/errno.h>
2216 +#include <linux/sched.h>
2217 +#include <linux/file.h>
2218 +#include <linux/types.h>
2219 +#include <linux/spinlock.h>
2220 +#include <linux/stat.h>
2221 +#include <linux/syscalls.h>
2222 +#include <linux/fs.h>
2223 +#include <asm/uaccess.h>
2224 +
2225 +#include <abi/svr4/sysent.h>
2226 +
2227 +
2228 +int
2229 +sco_lseek(int fd, u_long offset, int whence)
2230 +{
2231 +       int                     error;
2232 +
2233 +       error = sys_lseek(fd, offset, whence);
2234 +       if (error == -ESPIPE) {
2235 +               struct file     *fp = fget(fd);
2236 +               struct inode    *ip;
2237 +
2238 +               if (fp == NULL)
2239 +                       goto out;
2240 +               ip = fp->f_dentry->d_inode;
2241 +               if (ip && (S_ISCHR(ip->i_mode) || S_ISBLK(ip->i_mode)))
2242 +                       error = 0;
2243 +               fput(fp);
2244 +       }
2245 +out:
2246 +       return (error);
2247 +}
2248 +
2249 +int
2250 +sco_fcntl(int fd, u_int cmd, u_long arg)
2251 +{
2252 +       /*
2253 +        * This could be SCO's get highest fd open if the fd we
2254 +        * are called on is -1 otherwise it could be F_CHKFL.
2255 +        */
2256 +       if (fd == -1 && cmd == 8) {
2257 +               struct files_struct *files = current->files;
2258 +               int rval;
2259 +
2260 +                /* compare to ./fs/open.c: get_unused_fd */
2261 +               spin_lock(&files->file_lock);
2262 +               rval = find_first_zero_bit(files_fdtable(files)->open_fds->fds_bits, files_fdtable(files)->max_fdset);
2263 +               spin_unlock(&files->file_lock);
2264 +
2265 +               return rval;
2266 +       }
2267 +
2268 +       return svr4_fcntl(fd, cmd, arg);
2269 +}
2270 +
2271 +int
2272 +sco_sysi86(int cmd, void *arg1, int arg2)
2273 +{
2274 +       switch (cmd) {
2275 +       case 114 /*SI86GETFEATURES*/ :
2276 +               /*
2277 +                * No, I don't know what these feature flags actually
2278 +                * _mean_. This vector just matches SCO OS 5.0.0.
2279 +                */
2280 +#define OSR5_FEATURES  "\001\001\001\001\001\001\001\001\002\001\001\001"
2281 +               arg2 = max(arg2, 12);
2282 +               if (copy_to_user(arg1, OSR5_FEATURES, arg2))
2283 +                       return -EFAULT;
2284 +               return arg2;
2285 +       default:
2286 +               return svr4_sysi86(cmd, arg1, arg2);
2287 +       }
2288 +}
2289 diff -Nur kernel-source-2.6.16.orig/abi/sco/mmap.c kernel-source-2.6.16/abi/sco/mmap.c
2290 --- kernel-source-2.6.16.orig/abi/sco/mmap.c    1970-01-01 10:00:00.000000000 +1000
2291 +++ kernel-source-2.6.16/abi/sco/mmap.c 2006-04-27 18:50:24.000000000 +1000
2292 @@ -0,0 +1,65 @@
2293 +/*
2294 + * Copyright (c) 2001 Caldera Deutschland GmbH.
2295 + * All rights reserved.
2296 + *
2297 + * This program is free software; you can redistribute it and/or modify
2298 + * it under the terms of the GNU General Public License as published by
2299 + * the Free Software Foundation; either version 2 of the License, or
2300 + * (at your option) any later version.
2301 + *
2302 + * This program is distributed in the hope that it will be useful,
2303 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2304 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2305 + * GNU General Public License for more details.
2306 + *
2307 + * You should have received a copy of the GNU General Public License
2308 + * along with this program; if not, write to the Free Software
2309 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2310 + */
2311 +
2312 +#ident "%W% %G%"
2313 +
2314 +/*
2315 + * Support for mmap on SCO OpenServer 5.
2316 + */
2317 +#include <linux/mm.h>
2318 +#include <linux/errno.h>
2319 +#include <linux/file.h>
2320 +#include <linux/mman.h>
2321 +#include <asm/uaccess.h>
2322 +
2323 +#include <abi/sco/mman.h>
2324 +#include <abi/sco/types.h>
2325 +
2326 +#include <abi/util/trace.h>
2327 +
2328 +
2329 +int
2330 +sco_mmap(u_long addr, size_t len, int prot, int flags, int fd, sco_off_t off)
2331 +{
2332 +       struct file *file;
2333 +       u_long mapaddr;
2334 +
2335 +       if (flags & SCO_MAP_UNIMPL) {
2336 +#if defined(CONFIG_ABI_TRACE)
2337 +               abi_trace(ABI_TRACE_UNIMPL,
2338 +                   "unsupported mmap flags: 0x%x\n", flags & SCO_MAP_UNIMPL);
2339 +#endif
2340 +               flags &= ~SCO_MAP_UNIMPL;
2341 +       }
2342 +
2343 +       file = fget(fd);
2344 +       if (!file)
2345 +               return -EBADF;
2346 +
2347 +       flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
2348 +       down_write(&current->mm->mmap_sem);
2349 +       mapaddr = do_mmap(file, addr, len, prot, flags | MAP_FIXED, off);
2350 +       up_write(&current->mm->mmap_sem);
2351 +
2352 +       fput(file);
2353 +
2354 +       if (mapaddr == addr)
2355 +               return 0;
2356 +       return mapaddr;
2357 +}
2358 diff -Nur kernel-source-2.6.16.orig/abi/sco/ptrace.c kernel-source-2.6.16/abi/sco/ptrace.c
2359 --- kernel-source-2.6.16.orig/abi/sco/ptrace.c  1970-01-01 10:00:00.000000000 +1000
2360 +++ kernel-source-2.6.16/abi/sco/ptrace.c       2006-04-27 18:50:24.000000000 +1000
2361 @@ -0,0 +1,112 @@
2362 +/*
2363 + * ptrace.c - SCO OpenServer ptrace(2) support.
2364 + *
2365 + * Copyright (c) 1995 Mike Jagdis (jaggy@purplet.demon.co.uk)
2366 + */
2367 +
2368 +#ident "%W% %G%"
2369 +
2370 +/*
2371 + * This file is nearly identical to abi/wyse/ptrace.c, please keep it in sync.
2372 + */
2373 +#include <linux/module.h>
2374 +#include <linux/errno.h>
2375 +#include <linux/sched.h>
2376 +#include <linux/kernel.h>
2377 +#include <linux/mm.h>
2378 +#include <linux/personality.h>
2379 +#include <linux/user.h>
2380 +#define __KERNEL_SYSCALLS__
2381 +#include <linux/unistd.h>
2382 +#include <linux/ptrace.h>
2383 +
2384 +#include <asm/uaccess.h>
2385 +
2386 +#include <abi/signal.h>
2387 +#include <abi/util/trace.h>
2388 +
2389 +
2390 +#define NREGS  19
2391 +#define U(X)   ((unsigned long)&((struct user *)0)->X)
2392 +
2393 +static unsigned long sco_to_linux_reg[NREGS] = {
2394 +       U(regs.gs),     U(regs.fs),     U(regs.es),     U(regs.ds),
2395 +       U(regs.edi),    U(regs.esi),
2396 +       U(regs.ebp),
2397 +       U(regs.esp      /* ESP */),
2398 +       U(regs.ebx),    U(regs.edx),    U(regs.ecx),    U(regs.eax),
2399 +       U(signal        /* Trap */),
2400 +       U(reserved      /* ERR */),
2401 +       U(regs.eip),    U(regs.cs),     U(regs.eflags),
2402 +       U(regs.esp),    U(regs.ss)
2403 +};
2404 +
2405 +#if defined(CONFIG_ABI_TRACE)
2406 +static const char *regnam[] = {
2407 +       "EBX", "ECX", "EDX", "ESI", "EDI", "EBP", "EAX",
2408 +       "DS", "ES", "FS", "GS", "ORIG_EAX", "EIP", "CS",
2409 +       "EFL", "UESP", "SS"
2410 +};
2411 +#endif
2412 +
2413 +int
2414 +sco_ptrace(int req, int pid, u_long addr, u_long data)
2415 +{
2416 +       u_long                  res;
2417 +
2418 +       /*
2419 +        * Slight variations between iBCS and Linux codes.
2420 +        */
2421 +       if (req == PTRACE_ATTACH)
2422 +               req = 10;
2423 +       else if (req == PTRACE_DETACH)
2424 +               req = 11;
2425 +
2426 +       if (req == 3 || req == 6) {
2427 +               /* get offset of u_ar0 */
2428 +               if (addr == 0x1200)
2429 +                       return 0x4000;
2430 +
2431 +               /* remap access to the registers. */
2432 +               if ((addr & 0xff00) == 0x4000) { /* Registers */
2433 +                       addr = (addr & 0xff) >> 2;
2434 +                       if (addr > NREGS)
2435 +                               return -EIO;
2436 +                       addr = sco_to_linux_reg[addr];
2437 +                       if (addr == -1)
2438 +                               return -EIO;
2439 +               }
2440 +       }
2441 +
2442 +       if (req == 7 && data > 0) {
2443 +               if (data > NSIGNALS)
2444 +                       return -EIO;
2445 +               data = current_thread_info()->exec_domain->signal_map[data];
2446 +       }
2447 +
2448 +       if (req == 1 || req == 2 || req == 3) {
2449 +               mm_segment_t    old_fs = get_fs();
2450 +               int             error;
2451 +
2452 +               set_fs(get_ds());
2453 +               error = sys_ptrace(req, pid, addr, (long)&res);
2454 +               set_fs(old_fs);
2455 +
2456 +               if (error)
2457 +                       return (error);
2458 +       }
2459 +
2460 +#if defined(CONFIG_ABI_TRACE)
2461 +       if (req == 3 || req == 6) {
2462 +               abi_trace(ABI_TRACE_API, "%ld [%s] = 0x%08lx\n",
2463 +                       addr >> 2, (addr >> 2) < ARRAY_SIZE(regnam) ?
2464 +                               regnam[addr >> 2] : "???",
2465 +                       req == 3 ? res : data);
2466 +       }
2467 +#endif
2468 +
2469 +       if (req == 1 || req == 2 || req == 3)
2470 +               return (res);
2471 +
2472 +       return sys_ptrace(req, pid, addr, data);
2473 +}
2474 diff -Nur kernel-source-2.6.16.orig/abi/sco/secureware.c kernel-source-2.6.16/abi/sco/secureware.c
2475 --- kernel-source-2.6.16.orig/abi/sco/secureware.c      1970-01-01 10:00:00.000000000 +1000
2476 +++ kernel-source-2.6.16/abi/sco/secureware.c   2006-04-27 18:50:24.000000000 +1000
2477 @@ -0,0 +1,63 @@
2478 +/*
2479 + * Copyright (c) 1994 Mike Jagdis.
2480 + * All rights reserved.
2481 + *
2482 + * This program is free software; you can redistribute it and/or modify
2483 + * it under the terms of the GNU General Public License as published by
2484 + * the Free Software Foundation; either version 2 of the License, or
2485 + * (at your option) any later version.
2486 + *
2487 + * This program is distributed in the hope that it will be useful,
2488 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2489 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2490 + * GNU General Public License for more details.
2491 + *
2492 + * You should have received a copy of the GNU General Public License
2493 + * along with this program; if not, write to the Free Software
2494 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2495 + */
2496 +
2497 +#ident "%W% %G%"
2498 +
2499 +#include <linux/errno.h>
2500 +#include <linux/kernel.h>
2501 +#include <linux/sched.h>
2502 +
2503 +/*
2504 + * SecureWare, Inc. provided the C2 security subsystem used on SCO Unix.
2505 + * This is not that package. This does not even attempt to emulate
2506 + * that package. This emulates just enough of the "obvious" bits to
2507 + * allow some programs to get a bit further. It is not useful to
2508 + * try to implement C2 security in an emulator. Nor is it particularly
2509 + * useful to run SCO's secure admin programs on Linux anyway...
2510 + */
2511 +enum {
2512 +       SW_GETLUID =    0x01,
2513 +       SW_SETLUID =    0x02,
2514 +};
2515 +
2516 +int
2517 +sw_security(int cmd, void *p1, void *p2, void *p3, void *p4, void *p5)
2518 +{
2519 +       switch (cmd) {
2520 +       case SW_GETLUID:
2521 +               /*
2522 +                * We want the login user id. We don't have it
2523 +                * specifically so we'll just use the real uid
2524 +                * instead - it should be good enough.
2525 +                */
2526 +               return (current->uid);
2527 +       case SW_SETLUID:
2528 +               /*
2529 +                * Strictly we should only be able to call setluid()
2530 +                * once but we can't enforce that. We have the choice
2531 +                * between having it always succeed or always fail.
2532 +                * Since setluid() should only ever be invoked by
2533 +                * things like login processes we always fail it.
2534 +                */
2535 +               return -EPERM;
2536 +       }
2537 +
2538 +       printk(KERN_ERR "%s: unsupported security call cmd=%d\n", __FILE__, cmd);
2539 +       return -EINVAL;
2540 +}
2541 diff -Nur kernel-source-2.6.16.orig/abi/sco/stat.c kernel-source-2.6.16/abi/sco/stat.c
2542 --- kernel-source-2.6.16.orig/abi/sco/stat.c    1970-01-01 10:00:00.000000000 +1000
2543 +++ kernel-source-2.6.16/abi/sco/stat.c 2006-04-27 18:50:24.000000000 +1000
2544 @@ -0,0 +1,145 @@
2545 +/*
2546 + * Copyright (c) 2001 Caldera Deutschland GmbH.
2547 + * All rights reserved.
2548 + *
2549 + * This program is free software; you can redistribute it and/or modify
2550 + * it under the terms of the GNU General Public License as published by
2551 + * the Free Software Foundation; either version 2 of the License, or
2552 + * (at your option) any later version.
2553 + *
2554 + * This program is distributed in the hope that it will be useful,
2555 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2556 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2557 + * GNU General Public License for more details.
2558 + *
2559 + * You should have received a copy of the GNU General Public License
2560 + * aint32_t with this program; if not, write to the Free Software
2561 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2562 + */
2563 +
2564 +#ident "%W% %G%"
2565 +
2566 +/*
2567 + * SCO OpenServer xstat/fxstat/lxstat support.
2568 + */
2569 +#include <linux/kernel.h>
2570 +#include <linux/fs.h>
2571 +#include <linux/sched.h>
2572 +#include <linux/file.h>
2573 +#include <linux/string.h>
2574 +#include <asm/uaccess.h>
2575 +
2576 +#include <abi/sco/types.h>
2577 +#include <abi/sco/stat.h>
2578 +#include <abi/svr4/stat.h>
2579 +
2580 +#include <abi/util/trace.h>
2581 +#include <abi/util/stat.h>
2582 +
2583 +
2584 +enum {SVR4_stat = 1, SCO_xstat = 51};
2585 +
2586 +static int
2587 +report_sco_xstat(struct kstat *stp, struct sco_xstat *bufp)
2588 +{
2589 +       struct sco_xstat buf;
2590 +
2591 +       memset(&buf, 0, sizeof(struct sco_xstat));
2592 +
2593 +       buf.st_dev      = linux_to_sco_dev_t(stp->dev);
2594 +       buf.st_ino      = linux_to_sco_ino_t(stp->ino);
2595 +       buf.st_mode     = stp->mode;
2596 +       buf.st_nlink    = stp->nlink;
2597 +       buf.st_uid      = linux_to_sco_uid_t(stp->uid);
2598 +       buf.st_gid      = linux_to_sco_gid_t(stp->gid);
2599 +       buf.st_rdev     = linux_to_sco_dev_t(stp->rdev);
2600 +
2601 +       if (stp->size > MAX_NON_LFS)
2602 +               return -EOVERFLOW;      /* XXX: what to return for SCO?? */
2603 +
2604 +       buf.st_size     = stp->size;
2605 +
2606 +       buf.st_atime    = stp->atime.tv_sec;
2607 +       buf.st_mtime    = stp->mtime.tv_sec;
2608 +       buf.st_ctime    = stp->ctime.tv_sec;
2609 +
2610 +       buf.st_blksize  = stp->blksize;
2611 +       buf.st_blocks   = stp->blocks;
2612 +
2613 +       strcpy(buf.st_fstype, "ext2");
2614 +
2615 +       buf.st_sco_flags = 0; /* 1 if remote */
2616 +
2617 +       if (copy_to_user(bufp, &buf, sizeof(struct sco_xstat)))
2618 +               return -EFAULT;
2619 +       return 0;
2620 +}
2621 +
2622 +int
2623 +sco_xstat(int vers, char *filename, void *bufp)
2624 +{
2625 +       struct kstat st;
2626 +       int error;
2627 +
2628 +       error = vfs_stat(filename, &st);
2629 +       if (error)
2630 +               return error;
2631 +
2632 +       switch (vers) {
2633 +       case SVR4_stat:
2634 +               return report_svr4_stat(&st, bufp);
2635 +       case SCO_xstat:
2636 +               return report_sco_xstat(&st, bufp);
2637 +       }
2638 +
2639 +#if defined(CONFIG_ABI_TRACE)
2640 +       abi_trace(ABI_TRACE_API, "xstat version %d not supported\n", vers);
2641 +#endif
2642 +       return -EINVAL;
2643 +}
2644 +
2645 +int
2646 +sco_lxstat(int vers, char *filename, void *bufp)
2647 +{
2648 +       struct kstat st;
2649 +       int error;
2650 +
2651 +       error = vfs_lstat(filename, &st);
2652 +       if (error)
2653 +               return error;
2654 +
2655 +       switch (vers) {
2656 +       case SVR4_stat:
2657 +               return report_svr4_stat(&st, bufp);
2658 +       case SCO_xstat:
2659 +               return report_sco_xstat(&st, bufp);
2660 +       }
2661 +
2662 +#if defined(CONFIG_ABI_TRACE)
2663 +       abi_trace(ABI_TRACE_API, "lxstat version %d not supported\n", vers);
2664 +#endif
2665 +       return -EINVAL;
2666 +}
2667 +
2668 +int
2669 +sco_fxstat(int vers, int fd, void *bufp)
2670 +{
2671 +       struct kstat st;
2672 +       int error;
2673 +
2674 +       error = vfs_fstat(fd, &st);
2675 +       if (error)
2676 +               return error;
2677 +
2678 +       switch (vers) {
2679 +       case SVR4_stat:
2680 +               return report_svr4_stat(&st, bufp);
2681 +       case SCO_xstat:
2682 +               return report_sco_xstat(&st, bufp);
2683 +       }
2684 +
2685 +#if defined(CONFIG_ABI_TRACE)
2686 +       abi_trace(ABI_TRACE_API, "fxstat version %d not supported\n", vers);
2687 +#endif
2688 +       return -EINVAL;
2689 +}
2690 diff -Nur kernel-source-2.6.16.orig/abi/sco/statvfs.c kernel-source-2.6.16/abi/sco/statvfs.c
2691 --- kernel-source-2.6.16.orig/abi/sco/statvfs.c 1970-01-01 10:00:00.000000000 +1000
2692 +++ kernel-source-2.6.16/abi/sco/statvfs.c      2006-04-27 18:50:24.000000000 +1000
2693 @@ -0,0 +1,115 @@
2694 +/*
2695 + * Copyright (c) 2001 Caldera Deutschland GmbH.
2696 + * Copyright (c) 2001 Christoph Hellwig.
2697 + * All rights reserved.
2698 + *
2699 + * This program is free software; you can redistribute it and/or modify
2700 + * it under the terms of the GNU General Public License as published by
2701 + * the Free Software Foundation; either version 2 of the License, or
2702 + * (at your option) any later version.
2703 + *
2704 + * This program is distributed in the hope that it will be useful,
2705 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2706 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2707 + * GNU General Public License for more details.
2708 + *
2709 + * You should have received a copy of the GNU General Public License
2710 + * along with this program; if not, write to the Free Software
2711 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2712 + */
2713 +
2714 +#ident "%W% %G%"
2715 +
2716 +/*
2717 + * SCO OpenServer statvfs/fstatvfs support.
2718 + */
2719 +#include <linux/kernel.h>
2720 +#include <linux/fs.h>
2721 +#include <linux/sched.h>
2722 +#include <linux/file.h>
2723 +#include <linux/string.h>
2724 +#include <linux/vfs.h>
2725 +#include <linux/mount.h>
2726 +#include <linux/namei.h>
2727 +#include <asm/uaccess.h>
2728 +
2729 +#include <abi/sco/types.h>
2730 +
2731 +
2732 +static int
2733 +report_statvfs(struct vfsmount *mnt, struct inode *ip, struct sco_statvfs *bufp)
2734 +{
2735 +       struct sco_statvfs buf;
2736 +       struct kstatfs s;
2737 +       int error;
2738 +
2739 +       error = vfs_statfs(mnt->mnt_sb, &s);
2740 +       if (error)
2741 +               return error;
2742 +
2743 +       memset(&buf, 0, sizeof(struct sco_statvfs));
2744 +
2745 +       buf.f_bsize     = s.f_bsize;
2746 +       buf.f_frsize    = s.f_bsize;
2747 +       buf.f_blocks    = s.f_blocks;
2748 +       buf.f_bfree     = s.f_bfree;
2749 +       buf.f_bavail    = s.f_bavail;
2750 +       buf.f_files     = s.f_files;
2751 +       buf.f_free      = s.f_ffree;
2752 +       buf.f_favail    = s.f_ffree; /* SCO addition in the middle! */
2753 +       buf.f_sid       = ip->i_sb->s_dev;
2754 +
2755 +       /*
2756 +        * Get the name of the filesystem.
2757 +        *
2758 +        * Sadly, some code "in the wild" actually checks the name
2759 +        * against a hard coded list to see if it is a "real" fs or not.
2760 +        *
2761 +        * I believe Informix Dynamic Server for SCO is one such.
2762 +        */
2763 +       if (strncmp(ip->i_sb->s_type->name, "ext2", 4) == 0)
2764 +               strcpy(buf.f_basetype, "HTFS");
2765 +       else
2766 +               strcpy(buf.f_basetype, ip->i_sb->s_type->name);
2767 +
2768 +       /* Check for a few flags statvfs wants but statfs doesn't have. */
2769 +       if (IS_RDONLY(ip))
2770 +               buf.f_flag |= 1;
2771 +       if (mnt->mnt_flags & MNT_NOSUID)
2772 +               buf.f_flag |= 2;
2773 +
2774 +       buf.f_namemax   = s.f_namelen;
2775 +
2776 +       if (copy_to_user(bufp, &buf, sizeof(struct sco_statvfs)))
2777 +               return -EFAULT;
2778 +       return 0;
2779 +}
2780 +
2781 +int
2782 +sco_statvfs(char *filename, struct sco_statvfs *bufp)
2783 +{
2784 +       struct nameidata nd;
2785 +       int error;
2786 +
2787 +       error = user_path_walk(filename, &nd);
2788 +       if (!error) {
2789 +               error = report_statvfs(nd.mnt, nd.dentry->d_inode, bufp);
2790 +               path_release(&nd);
2791 +       }
2792 +       return error;
2793 +}
2794 +
2795 +int
2796 +sco_fstatvfs(int fd, struct sco_statvfs *bufp)
2797 +{
2798 +       struct file *fp;
2799 +       int error = -EBADF;
2800 +
2801 +       fp = fget(fd);
2802 +       if (fp) {
2803 +               error = report_statvfs(fp->f_vfsmnt,
2804 +                               fp->f_dentry->d_inode, bufp);
2805 +               fput(fp);
2806 +       }
2807 +       return error;
2808 +}
2809 diff -Nur kernel-source-2.6.16.orig/abi/sco/sysent.c kernel-source-2.6.16/abi/sco/sysent.c
2810 --- kernel-source-2.6.16.orig/abi/sco/sysent.c  1970-01-01 10:00:00.000000000 +1000
2811 +++ kernel-source-2.6.16/abi/sco/sysent.c       2006-04-27 18:50:24.000000000 +1000
2812 @@ -0,0 +1,457 @@
2813 +/*
2814 + * Copyright (c) 2001 Christoph Hellwig.
2815 + * All rights reserved.
2816 + *
2817 + * This program is free software; you can redistribute it and/or modify
2818 + * it under the terms of the GNU General Public License as published by
2819 + * the Free Software Foundation; either version 2 of the License, or
2820 + * (at your option) any later version.
2821 + *
2822 + * This program is distributed in the hope that it will be useful,
2823 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2824 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2825 + * GNU General Public License for more details.
2826 + *
2827 + * You should have received a copy of the GNU General Public License
2828 + * along with this program; if not, write to the Free Software
2829 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2830 + */
2831 +
2832 +#ident "%W% %G%"
2833 +
2834 +/*
2835 + * SCO Unix 3.x personality switch
2836 + */
2837 +#include <linux/kernel.h>
2838 +#include <linux/module.h>
2839 +#include <linux/init.h>
2840 +#include <linux/personality.h>
2841 +#include <linux/types.h>
2842 +#include <linux/syscalls.h>
2843 +#include <linux/socket.h>
2844 +#include <linux/net.h>
2845 +#include <asm/uaccess.h>
2846 +
2847 +#include <abi/sco/signal.h>
2848 +#include <abi/sco/sysent.h>
2849 +#include <abi/svr4/sysent.h>
2850 +#include <abi/cxenix/sysent.h>
2851 +
2852 +#include <abi/signal.h>
2853 +
2854 +#include <abi/util/errno.h>
2855 +#include <abi/util/map.h>
2856 +#include <abi/util/sysent.h>
2857 +#include <abi/util/socket.h>
2858 +
2859 +
2860 +MODULE_DESCRIPTION("OpenServer/Xenix personality");
2861 +MODULE_AUTHOR("Christoph Hellwig, partially taken from iBCS");
2862 +MODULE_LICENSE("GPL");
2863 +
2864 +
2865 +static u_char sco_err_table[] = {
2866 +/*   0 -   9 */   0,   1,   2,    3,   4,   5,   6,   7,   8,   9,
2867 +/*  10 -  19 */   10,  11,  12,  13,  14,  15,  16,  17,  18,  19,
2868 +/*  20 -  29 */   20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
2869 +/*  30 -  39 */   30,  31,  32,  33,  34,  45,  78,  46,  89, 145,
2870 +/*  40 -  49 */  150,  90,  35,  36,  37,  38,  39,  40,  41,  42,
2871 +/*  50 -  59 */   43,  44,  50,  51,  52,  53,  54,  55,  56,  57,
2872 +/*  60 -  69 */   60,  61,  62,  63,  64,  65,  66,  67,  68,  69,
2873 +/*  70 -  79 */   70,  71,  74,  76,  77,  79,  80,  81,  82,  83,
2874 +/*  80 -  89 */   84,  85,  86,  87,  88, 152, 153,  22,  93,  94,
2875 +/*  90 -  99 */   95,  96, 118,  97,  98,  99, 100, 101, 102, 103,
2876 +/* 100 - 109 */  104, 105, 106, 107, 108,  63, 110, 111, 112, 113,
2877 +/* 110 - 119 */  114, 115, 116, 117,  92,  91, 151, 135, 137, 138,
2878 +/* 120 - 122 */  139, 140, 28
2879 +};
2880 +
2881 +/*
2882 + * Map Linux RESTART* values (512,513,514) to EINTR
2883 + */
2884 +static u_char lnx_err_table[] = {
2885 +/* 512 - 514 */        EINTR, EINTR, EINTR
2886 +};
2887 +
2888 +static struct map_segment sco_err_map[] = {
2889 +       { 0,    0+sizeof(sco_err_table)-1,      sco_err_table },
2890 +       { 512,  512+sizeof(lnx_err_table)-1,    lnx_err_table },
2891 +       { -1 }
2892 +};
2893 +
2894 +/* XXX: move to signal.h */
2895 +#define SCO__SIGSTKFLT SCO_SIGTERM /* Stack fault */
2896 +
2897 +static long linux_to_sco_signals[NSIGNALS + 1] = {
2898 +/*  0 -  3 */  0,              SCO_SIGHUP,     SCO_SIGINT,     SCO_SIGQUIT,
2899 +/*  4 -  7 */  SCO_SIGILL,     SCO_SIGTRAP,    SCO_SIGABRT,    SCO_SIGBUS,
2900 +/*  8 - 11 */  SCO_SIGFPE,     SCO_SIGKILL,    SCO_SIGUSR1,    SCO_SIGSEGV,
2901 +/* 12 - 15 */  SCO_SIGUSR2,    SCO_SIGPIPE,    SCO_SIGALRM,    SCO_SIGTERM,
2902 +/* 16 - 19 */  SCO__SIGSTKFLT, SCO_SIGCLD,     SCO_SIGCONT,    SCO_SIGSTOP,
2903 +/* 20 - 23 */  SCO_SIGTSTP,    SCO_SIGTTIN,    SCO_SIGTTOU,    SCO_SIGURG,
2904 +/* 24 - 27 */  SCO_SIGXCPU,    SCO_SIGXFSZ,    SCO_SIGVTALRM,  SCO_SIGPROF,
2905 +/* 28 - 31 */  SCO_SIGWINCH,   SCO_SIGPOLL,    SCO_SIGPWR,     SCO_SIGSYS,
2906 +/*      32 */  -1
2907 +};
2908 +
2909 +static long linux_to_xenix_signals[NSIGNALS+1] = {
2910 +/*  0 -  3 */  0,              IBCS_SIGHUP,    IBCS_SIGINT,    IBCS_SIGQUIT,
2911 +/*  4 -  7 */  IBCS_SIGILL,    IBCS_SIGTRAP,   IBCS_SIGABRT,   -1,
2912 +/*  8 - 11 */  IBCS_SIGFPE,    IBCS_SIGKILL,   IBCS_SIGUSR1,   IBCS_SIGSEGV,
2913 +/* 12 - 15 */  IBCS_SIGUSR2,   IBCS_SIGPIPE,   IBCS_SIGALRM,   IBCS_SIGTERM,
2914 +/* 16 - 19 */  IBCS_SIGSEGV,   IBCS_SIGCHLD,   IBCS_SIGCONT,   IBCS_SIGSTOP,
2915 +/* 20 - 23 */  IBCS_SIGTSTP,   IBCS_SIGTTIN,   IBCS_SIGTTOU,   IBCS_SIGUSR1,
2916 +/* 24 - 27 */  IBCS_SIGGXCPU,  IBCS_SIGGXFSZ,  IBCS_SIGVTALRM, IBCS_SIGPROF,
2917 +/* 28 - 31 */  IBCS_SIGWINCH,  20 /*SIGIO*/,   IBCS_SIGPWR,    -1,
2918 +/*      32 */  -1
2919 +};
2920 +
2921 +static long sco_to_linux_signals[NSIGNALS+1] = {
2922 +/*  0 -  3 */  0,              SIGHUP,         SIGINT,         SIGQUIT,
2923 +/*  4 -  7 */  SIGILL,         SIGTRAP,        SIGIOT,         SIGABRT,
2924 +/*  8 - 11 */  SIGFPE,         SIGKILL,        SIGBUS,         SIGSEGV,
2925 +/* 12 - 15 */  SIGSYS,         SIGPIPE,        SIGALRM,        SIGTERM,
2926 +/* 16 - 19 */  SIGUSR1,        SIGUSR2,        SIGCHLD,        SIGPWR,
2927 +/* 20 - 23 */  SIGWINCH,       SIGURG,         SIGPOLL,        SIGSTOP,
2928 +/* 24 - 27 */  SIGTSTP,        SIGCONT,        SIGTTIN,        SIGTTOU,
2929 +/* 28 - 31 */  SIGVTALRM,      SIGPROF,        SIGXCPU,        SIGXFSZ,
2930 +/*      32 */  -1
2931 +};
2932 +
2933 +static long xenix_to_linux_signals[NSIGNALS+1] = {
2934 +/*  0 -  3 */  0,              SIGHUP,         SIGINT,         SIGQUIT,
2935 +/*  4 -  7 */  SIGILL,         SIGTRAP,        SIGIOT,         SIGUNUSED,
2936 +/*  8 - 11 */  SIGFPE,         SIGKILL,        SIGUNUSED,      SIGSEGV,
2937 +/* 12 - 15 */  SIGUNUSED,      SIGPIPE,        SIGALRM,        SIGTERM,
2938 +/* 16 - 19 */  SIGUSR1,        SIGUSR2,        SIGCHLD,        SIGPWR,
2939 +/* 20 - 23 */  SIGPOLL,        -1,             -1,             -1,
2940 +/* 24 - 27 */  -1,             -1,             -1,             -1,
2941 +/* 28 - 31 */  -1,             -1,             -1,             -1,
2942 +/*      32 */  -1
2943 +};
2944 +
2945 +static char sco_socktype[] = {
2946 +       SOCK_STREAM,
2947 +       SOCK_DGRAM,
2948 +       0,
2949 +       SOCK_RAW,
2950 +       SOCK_RDM,
2951 +       SOCK_SEQPACKET
2952 +};
2953 +
2954 +static struct map_segment sco_socktype_map[] = {
2955 +       { 1, 6, sco_socktype },
2956 +       { -1 }
2957 +};
2958 +
2959 +static struct map_segment sco_sockopt_map[] =  {
2960 +       { 0x0001, 0x0001, (char *)SO_DEBUG },
2961 +       { 0x0002, 0x0002, (char *)__SO_ACCEPTCON },
2962 +       { 0x0004, 0x0004, (char *)SO_REUSEADDR },
2963 +       { 0x0008, 0x0008, (char *)SO_KEEPALIVE },
2964 +       { 0x0010, 0x0010, (char *)SO_DONTROUTE },
2965 +       { 0x0020, 0x0020, (char *)SO_BROADCAST },
2966 +       { 0x0040, 0x0040, (char *)SO_USELOOPBACK },
2967 +       { 0x0080, 0x0080, (char *)SO_LINGER },
2968 +       { 0x0100, 0x0100, (char *)SO_OOBINLINE },
2969 +       { 0x0200, 0x0200, (char *)SO_ORDREL },
2970 +       { 0x0400, 0x0400, (char *)SO_IMASOCKET },
2971 +       { 0x1001, 0x1001, (char *)SO_SNDBUF },
2972 +       { 0x1002, 0x1002, (char *)SO_RCVBUF },
2973 +       { 0x1003, 0x1003, (char *)SO_SNDLOWAT },
2974 +       { 0x1004, 0x1004, (char *)SO_RCVLOWAT },
2975 +       { 0x1005, 0x1005, (char *)SO_SNDTIMEO },
2976 +       { 0x1006, 0x1006, (char *)SO_RCVTIMEO },
2977 +       { 0x1007, 0x1007, (char *)SO_ERROR },
2978 +       { 0x1008, 0x1008, (char *)SO_TYPE },
2979 +       { 0x1009, 0x1009, (char *)SO_PROTOTYPE },
2980 +       { -1 }
2981 +};
2982 +
2983 +/*
2984 + * The first three entries (AF_UNSPEC, AF_UNIX and AF_INET)
2985 + * are identity mapped. All others aren't available under
2986 + * Linux, nor are Linux's AF_AX25 and AF_IPX available from
2987 + * SCO as far as I know.
2988 + */
2989 +static struct map_segment sco_af_map[] =  {
2990 +       { 0, 2, NULL },
2991 +       { -1 }
2992 +};
2993 +
2994 +
2995 +static struct sysent sco_syscall_table[] = {
2996 +/*   0 */      { abi_syscall,          Fast,   "syscall",      ""      },
2997 +/*   1 */      { sys_exit,             1,      "exit",         "d"     },
2998 +/*   2 */      { abi_fork,             Spl,    "fork",         ""      },
2999 +/*   3 */      { abi_read,             3,      "read",         "dpd"   },
3000 +/*   4 */      { sys_write,            3,      "write",        "dpd"   },
3001 +/*   5 */      { svr4_open,            3,      "open",         "soo"   },
3002 +/*   6 */      { sys_close,            1,      "close",        "d"     },
3003 +/*   7 */      { abi_wait,             Spl,    "wait",         "xxx"   },
3004 +/*   8 */      { sys_creat,            2,      "creat",        "so"    },
3005 +/*   9 */      { sys_link,             2,      "link",         "ss"    },
3006 +/*  10 */      { sys_unlink,           1,      "unlink",       "s"     },
3007 +/*  11 */      { abi_exec,             Spl,    "exec",         "sxx"   },
3008 +/*  12 */      { sys_chdir,            1,      "chdir",        "s"     },
3009 +/*  13 */      { abi_time,             0,      "time",         ""      },
3010 +/*  14 */      { svr4_mknod,           3,      "mknod",        "soo"   },
3011 +/*  15 */      { sys_chmod,            2,      "chmod",        "so"    },
3012 +/*  16 */      { sys_chown,            3,      "chown",        "sdd"   },
3013 +/*  17 */      { abi_brk,              1,      "brk/break",    "x"     },
3014 +/*  18 */      { svr4_stat,            2,      "stat",         "sp"    },
3015 +/*  19 */      { sco_lseek,            3,      "seek/lseek",   "ddd"   },
3016 +/*  20 */      { abi_getpid,           Spl,    "getpid",       ""      },
3017 +/*  21 */      { 0,                    Ukn,    "mount",        ""      },
3018 +/*  22 */      { sys_umount,           1,      "umount",       "s"     },
3019 +/*  23 */      { sys_setuid,           1,      "setuid",       "d"     },
3020 +/*  24 */      { abi_getuid,           Spl,    "getuid",       ""      },
3021 +/*  25 */      { sys_stime,            1,      "stime",        "d"     },
3022 +/*  26 */      { sco_ptrace,           4,      "ptrace",       "xdxx"  },
3023 +/*  27 */      { sys_alarm,            1,      "alarm",        "d"     },
3024 +/*  28 */      { svr4_fstat,           2,      "fstat",        "dp"    },
3025 +/*  29 */      { sys_pause,            0,      "pause",        ""      },
3026 +/*  30 */      { sys_utime,            2,      "utime",        "xx"    },
3027 +/*  31 */      { 0,                    Ukn,    "stty",         ""      },
3028 +/*  32 */      { 0,                    Ukn,    "gtty",         ""      },
3029 +/*  33 */      { sys_access,           2,      "access",       "so"    },
3030 +/*  34 */      { sys_nice,             1,      "nice",         "d"     },
3031 +/*  35 */      { svr4_statfs,          4,      "statfs",       "spdd"  },
3032 +/*  36 */      { sys_sync,             0,      "sync",         ""      },
3033 +/*  37 */      { abi_kill,             2,      "kill",         "dd"    },
3034 +/*  38 */      { svr4_fstatfs,         4,      "fstatfs",      "dpdd"  },
3035 +/*  39 */      { abi_procids,          Spl,    "procids",      "d"     },
3036 +/*  40 */      { cxenix,               Fast,   "cxenix",       ""      },
3037 +/*  41 */      { sys_dup,              1,      "dup",          "d"     },
3038 +/*  42 */      { abi_pipe,             Spl,    "pipe",         ""      },
3039 +/*  43 */      { sys_times,            1,      "times",        "p"     },
3040 +/*  44 */      { 0     ,               Ukn,    "prof",         ""      },
3041 +/*  45 */      { 0,                    Ukn,    "lock/plock",   ""      },
3042 +/*  46 */      { sys_setgid,           1,      "setgid",       "d"     },
3043 +/*  47 */      { abi_getgid,           Spl,    "getgid",       ""      },
3044 +/*  48 */      { abi_sigfunc,          Fast,   "sigfunc",      "xxx"   },
3045 +/*  49 */      { svr4_msgsys,          Spl,    "msgsys",       "dxddd" },
3046 +/*  50 */      { sco_sysi86,           3,      "sysi86/sys3b", "d"     },
3047 +/*  51 */      { sys_acct,             1,      "acct/sysacct", "x"     },
3048 +/*  52 */      { svr4_shmsys,          Fast,   "shmsys",       "ddxo"  },
3049 +/*  53 */      { svr4_semsys,          Spl,    "semsys",       "dddx"  },
3050 +/*  54 */      { sco_ioctl,            Spl,    "ioctl",        "dxx"   },
3051 +/*  55 */      { 0,                    3,      "uadmin",       "xxx"   },
3052 +/*  56 */      { 0,                    Ukn,    "?",            ""      },
3053 +/*  57 */      { v7_utsname,           1,      "utsys",        "x"     },
3054 +/*  58 */      { sys_fsync,            1,      "fsync",        "d"     },
3055 +/*  59 */      { abi_exec,             Spl,    "execv",        "spp"   },
3056 +/*  60 */      { sys_umask,            1,      "umask",        "o"     },
3057 +/*  61 */      { sys_chroot,           1,      "chroot",       "s"     },
3058 +/*  62 */      { sco_fcntl,            3,      "fcntl",        "dxx"   },
3059 +/*  63 */      { svr4_ulimit,          2,      "ulimit",       "xx"    },
3060 +/*  64 */      { 0,                    Ukn,    "?",            ""      },
3061 +/*  65 */      { 0,                    Ukn,    "?",            ""      },
3062 +/*  66 */      { 0,                    Ukn,    "?",            ""      },
3063 +/*  67 */      { 0,                    Ukn,    "?",            ""      },
3064 +/*  68 */      { 0,                    Ukn,    "?",            ""      },
3065 +/*  69 */      { 0,                    Ukn,    "?",            ""      },
3066 +/*  70 */      { 0,                    Ukn,    "advfs",        ""      },
3067 +/*  71 */      { 0,                    Ukn,    "unadvfs",      ""      },
3068 +/*  72 */      { 0,                    Ukn,    "rmount",       ""      },
3069 +/*  73 */      { 0,                    Ukn,    "rumount",      ""      },
3070 +/*  74 */      { 0,                    Ukn,    "rfstart",      ""      },
3071 +/*  75 */      { 0,                    Ukn,    "?",            ""      },
3072 +/*  76 */      { 0,                    Ukn,    "rdebug",       ""      },
3073 +/*  77 */      { 0,                    Ukn,    "rfstop",       ""      },
3074 +/*  78 */      { 0,                    Ukn,    "rfsys",        ""      },
3075 +/*  79 */      { sys_rmdir,            1,      "rmdir",        "s"     },
3076 +/*  80 */      { abi_mkdir,            2,      "mkdir",        "so"    },
3077 +/*  81 */      { svr4_getdents,        3,      "getdents",     "dxd"   },
3078 +/*  82 */      { 0,                    Ukn,    "libattach",    ""      },
3079 +/*  83 */      { 0,                    Ukn,    "libdetach",    ""      },
3080 +/*  84 */      { svr4_sysfs,           3,      "sysfs",        "dxx"   },
3081 +/*  85 */      { svr4_getmsg,          Spl,    "getmsg",       "dxxx"  },
3082 +/*  86 */      { svr4_putmsg,          Spl,    "putmsg",       "dxxd"  },
3083 +/*  87 */      { sys_poll,             3,      "poll",         "xdd"   },
3084 +/*  88 */      { 0,                    Ukn,    "nosys88",      ""      },
3085 +/*  89 */      { sw_security,          6,      "security",     "dxxxxx"},
3086 +/*  90 */      { sys_symlink,          2,      "symlink",      "ss"    },
3087 +/*  91 */      { svr4_lstat,           2,      "lstat",        "sp"    },
3088 +/*  92 */      { sys_readlink,         3,      "readlink",     "spd"   },
3089 +
3090 +       /*
3091 +        * Ok, this is where the good-old SCO calls end.
3092 +        * Everything from here onwards is OSR5-specific.
3093 +        *
3094 +        * In fact OSR5 documents only the following calls:
3095 +        *
3096 +        *   o readv (121)
3097 +        *   o writev (122)
3098 +        *   o xstat (123)
3099 +        *   o lxstat (124)
3100 +        *   o fxstat (125)
3101 +        *   o clocal (127)
3102 +        *   o gettimeofday (171)
3103 +        *   o settimeofday (172)
3104 +        *
3105 +        * Everything else is guesswork (from AVR4/iABI4), even though
3106 +        * the OSR5 ELF libs use at least some of those... (e.g. mmap).
3107 +        */
3108 +
3109 +/*  93 */      { 0,                    Ukn,    "?",            ""      },
3110 +/*  94 */      { 0,                    Ukn,    "?",            ""      },
3111 +/*  95 */      { abi_sigprocmask,      3,      "sigprocmask",  "dxx"   },
3112 +/*  96 */      { abi_sigsuspend,       Spl,    "sigsuspend",   "x"     },
3113 +/*  97 */      { 0,                    2,      "sigaltstack",  "xx"    },
3114 +/*  98 */      { abi_sigaction,        3,      "sigaction",    "dxx"   },
3115 +/*  99 */      { svr4_sigpending,      2,      "sigpending",   "dp"    },
3116 +/* 100 */      { svr4_context,         Spl,    "context",      ""      },
3117 +/* 101 */      { 0,                    Ukn,    "evsys",        ""      },
3118 +/* 102 */      { 0,                    Ukn,    "evtrapret",    ""      },
3119 +/* 103 */      { sco_statvfs,          2,      "statvfs",      "sp"    },
3120 +/* 104 */      { sco_fstatvfs,         2,      "fstatvfs",     "dp"    },
3121 +/* 105 */      { 0,                    Ukn,    "unimp (sysisc)",""     },
3122 +/* 106 */      { 0,                    Ukn,    "nfssys",       ""      },
3123 +/* 107 */      { 0,                    4,      "waitid",       "ddxd"  },
3124 +/* 108 */      { 0,                    3,      "sigsendsys",   "ddd"   },
3125 +/* 109 */      { svr4_hrtsys,          Spl,    "hrtsys",       "xxx"   },
3126 +/* 110 */      { 0,                    3,      "acancel",      "dxd"   },
3127 +/* 111 */      { 0,                    Ukn,    "async",        ""      },
3128 +/* 112 */      { 0,                    Ukn,    "priocntlsys",  ""      },
3129 +/* 113 */      { svr4_pathconf,        2,      "pathconf",     "sd"    },
3130 +/* 114 */      { sys_mincore,          3,      "mincore",      "xdx"   },
3131 +/* 115 */      { sco_mmap,             6,      "mmap",         "xxxxdx"},
3132 +/* 116 */      { sys_mprotect,         3,      "mprotect",     "xdx"   },
3133 +/* 117 */      { sys_munmap,           2,      "munmap",       "xd"    },
3134 +/* 118 */      { svr4_fpathconf,       2,      "fpathconf",    "dd"    },
3135 +/* 119 */      { abi_fork,             Spl,    "vfork",        ""      },
3136 +/* 120 */      { sys_fchdir,           1,      "fchdir",       "d"     },
3137 +/* 121 */      { sys_readv,            3,      "readv",        "dxd"   },
3138 +/* 122 */      { sys_writev,           3,      "writev",       "dxd"   },
3139 +/* 123 */      { sco_xstat,            3,      "xstat",        "dsx"   },
3140 +/* 124 */      { sco_lxstat,           3,      "lxstat",       "dsx"   },
3141 +/* 125 */      { sco_fxstat,           3,      "fxstat",       "ddx"   },
3142 +/* 126 */      { svr4_xmknod,          4,      "xmknod",       "dsox"  },
3143 +/* 127 */      { 0,                    Ukn,    "syslocal",     "d"     },
3144 +/* 128 */      { svr4_getrlimit,       2,      "setrlimit",    "dx"    },
3145 +/* 129 */      { svr4_setrlimit,       2,      "getrlimit",    "dx"    },
3146 +/* 130 */      { 0,                    Ukn,    "?",            ""      },
3147 +/* 131 */      { 0,                    Ukn,    "?",            ""      },
3148 +/* 132 */      { 0,                    Ukn,    "?",            ""      },
3149 +/* 133 */      { 0,                    Ukn,    "?",            ""      },
3150 +/* 134 */      { 0,                    Ukn,    "?",            ""      },
3151 +/* 135 */      { 0,                    Ukn,    "?",            ""      },
3152 +/* 136 */      { 0,                    Ukn,    "?",            ""      },
3153 +/* 137 */      { 0,                    Ukn,    "?",            ""      },
3154 +/* 138 */      { 0,                    Ukn,    "?",            ""      },
3155 +/* 139 */      { 0,                    Ukn,    "?",            ""      },
3156 +/* 140 */      { socksys_syscall,      1,      "socksys",      "x"     },
3157 +/* 141 */      { 0,                    Ukn,    "?",            ""      },
3158 +/* 142 */      { 0,                    Ukn,    "?",            ""      },
3159 +/* 143 */      { 0,                    Ukn,    "?",            ""      },
3160 +
3161 +       /*
3162 +        * The next three are used when an OSR5 app is launched by
3163 +        * a UnixWare libc.
3164 +        *
3165 +        * These aren't supported by the UW7 personality either, but
3166 +        * adding the names here makes the traces look saner.
3167 +        */
3168 +
3169 +/* 144 */      { 0,                    2,      "uw7-secsys",   "dx"    },
3170 +/* 145 */      { 0,                    4,      "uw7-filepriv", "sdxd"  },
3171 +/* 146 */      { 0,                    3,      "uw7-procpriv", "dxd"   },
3172 +
3173 +/* 147 */      { 0,                    Ukn,    "?",            ""      },
3174 +/* 148 */      { 0,                    Ukn,    "?",            ""      },
3175 +/* 149 */      { 0,                    Ukn,    "?",            ""      },
3176 +/* 150 */      { 0,                    Ukn,    "?",            ""      },
3177 +/* 151 */      { 0,                    Ukn,    "?",            ""      },
3178 +/* 152 */      { 0,                    Ukn,    "?",            ""      },
3179 +/* 153 */      { 0,                    Ukn,    "?",            ""      },
3180 +/* 154 */      { 0,                    Ukn,    "?",            ""      },
3181 +/* 155 */      { 0,                    Ukn,    "?",            ""      },
3182 +/* 156 */      { 0,                    Ukn,    "?",            ""      },
3183 +/* 157 */      { 0,                    Ukn,    "?",            ""      },
3184 +/* 158 */      { 0,                    Ukn,    "?",            ""      },
3185 +/* 159 */      { 0,                    Ukn,    "?",            ""      },
3186 +/* 160 */      { 0,                    Ukn,    "?",            ""      },
3187 +/* 161 */      { 0,                    Ukn,    "?",            ""      },
3188 +/* 162 */      { 0,                    Ukn,    "?",            ""      },
3189 +/* 163 */      { 0,                    Ukn,    "?",            ""      },
3190 +/* 164 */      { 0,                    Ukn,    "?",            ""      },
3191 +/* 165 */      { 0,                    Ukn,    "?",            ""      },
3192 +/* 166 */      { 0,                    Ukn,    "?",            ""      },
3193 +/* 167 */      { 0,                    Ukn,    "?",            ""      },
3194 +/* 168 */      { 0,                    Ukn,    "?",            ""      },
3195 +/* 169 */      { 0,                    Ukn,    "?",            ""      },
3196 +/* 170 */      { 0,                    Ukn,    "?",            ""      },
3197 +/* 171 */      { sys_gettimeofday,     2,      "gettimeofday",  "xx"   },
3198 +/* 172 */      { sys_settimeofday,     2,      "settimeofday",  "xx"   },
3199 +};
3200 +
3201 +static void
3202 +sco_lcall7(int segment, struct pt_regs *regs)
3203 +{
3204 +       int sysno = regs->eax & 0xff;
3205 +
3206 +       if (sysno >= ARRAY_SIZE(sco_syscall_table))
3207 +               set_error(regs, iABI_errors(-EINVAL));
3208 +       else
3209 +               lcall7_dispatch(regs, &sco_syscall_table[sysno], 1);
3210 +}
3211 +
3212 +
3213 +static struct exec_domain sco_exec_domain = {
3214 +       name:           "OpenServer",
3215 +       handler:        sco_lcall7,
3216 +       pers_low:       3 /* PER_SCOSVR3, PER_OSR5 */,
3217 +       pers_high:      3 /* PER_SCOSVR3, PER_OSR5 */,
3218 +       signal_map:     sco_to_linux_signals,
3219 +       signal_invmap:  linux_to_sco_signals,
3220 +       err_map:        sco_err_map,
3221 +       socktype_map:   sco_socktype_map,
3222 +       sockopt_map:    sco_sockopt_map,
3223 +       af_map:         sco_af_map,
3224 +       module:         THIS_MODULE
3225 +};
3226 +
3227 +static struct exec_domain xenix_exec_domain = {
3228 +       name:           "Xenix",
3229 +       handler:        sco_lcall7,
3230 +       pers_low:       7 /* PER_XENIX */,
3231 +       pers_high:      7 /* PER_XENIX */,
3232 +       signal_map:     xenix_to_linux_signals,
3233 +       signal_invmap:  linux_to_xenix_signals,
3234 +       err_map:        sco_err_map,
3235 +       socktype_map:   sco_socktype_map,
3236 +       sockopt_map:    sco_sockopt_map,
3237 +       af_map:         sco_af_map,
3238 +       module:         THIS_MODULE
3239 +};
3240 +
3241 +
3242 +static int __init
3243 +sco_module_init(void)
3244 +{
3245 +        int            err;
3246 +
3247 +        err = register_exec_domain(&sco_exec_domain);
3248 +        if (err) {
3249 +                return err;
3250 +        }
3251 +
3252 +        err = register_exec_domain(&xenix_exec_domain);
3253 +        if (err) {
3254 +                unregister_exec_domain(&sco_exec_domain);
3255 +                return err;
3256 +        }
3257 +
3258 +        return err;
3259 +}
3260 +
3261 +static void __exit
3262 +sco_module_exit(void)
3263 +{
3264 +       unregister_exec_domain(&xenix_exec_domain);
3265 +       unregister_exec_domain(&sco_exec_domain);
3266 +}
3267 +
3268 +module_init(sco_module_init);
3269 +module_exit(sco_module_exit);
3270 diff -Nur kernel-source-2.6.16.orig/abi/sco/tapeio.c kernel-source-2.6.16/abi/sco/tapeio.c
3271 --- kernel-source-2.6.16.orig/abi/sco/tapeio.c  1970-01-01 10:00:00.000000000 +1000
3272 +++ kernel-source-2.6.16/abi/sco/tapeio.c       2006-04-27 18:50:24.000000000 +1000
3273 @@ -0,0 +1,112 @@
3274 +#ident "%W% %G%"
3275 +
3276 +#include <linux/kernel.h>
3277 +#include <linux/mtio.h>
3278 +#include <linux/unistd.h>
3279 +#include <linux/syscalls.h>
3280 +
3281 +#include <asm/uaccess.h>
3282 +
3283 +
3284 +int
3285 +sco_tape_ioctl(int fd, u_int cmd, caddr_t data)
3286 +{
3287 +       struct mtop             mtop;
3288 +       mm_segment_t            fs;
3289 +       int                     error;
3290 +
3291 +       mtop.mt_count = 1;
3292 +
3293 +       switch (cmd & 0xff) {
3294 +       case 1:  /* MT_RESET */
3295 +               mtop.mt_op = MTRESET;
3296 +               break;
3297 +
3298 +       case 2:  /* MT_RETEN */
3299 +               mtop.mt_op = MTRETEN;
3300 +               break;
3301 +
3302 +       case 3:  /* MT_REWIND */
3303 +               mtop.mt_op = MTREW;
3304 +               break;
3305 +
3306 +       case 4:  /* MT_ERASE */
3307 +       case 23:  /* HP_ERASE */
3308 +               mtop.mt_op = MTERASE;
3309 +               break;
3310 +
3311 +       case 6:  /* MT_RFM */
3312 +               mtop.mt_op = MTFSF;
3313 +               break;
3314 +
3315 +       case 7:  /* MT_WFM */
3316 +               mtop.mt_op = MTWEOF;
3317 +               break;
3318 +
3319 +       case 8:  /* MT_LOAD */
3320 +               mtop.mt_op = MTLOAD;
3321 +               break;
3322 +
3323 +       case 9:  /* MT_UNLOAD */
3324 +               mtop.mt_op = MTOFFL;
3325 +               break;
3326 +
3327 +       case 19:  /* MT_RSM */
3328 +               mtop.mt_op = MTFSS;
3329 +               break;
3330 +
3331 +       case 20:  /* MT_WSM */
3332 +               mtop.mt_op = MTWSM;
3333 +               break;
3334 +
3335 +       case 21:  /* MT_EOD */
3336 +               mtop.mt_op = MTEOM;
3337 +               break;
3338 +
3339 +       case 24:  /* MT_SETBLK */
3340 +               mtop.mt_op = MTSETBLK;
3341 +               mtop.mt_count = (int)data;
3342 +               break;
3343 +
3344 +       case 25:  /* MT_LOCK */
3345 +               mtop.mt_op = MTLOCK;
3346 +               break;
3347 +
3348 +       case 26:  /* MT_UNLOCK */
3349 +               mtop.mt_op = MTUNLOCK;
3350 +               break;
3351 +
3352 +
3353 +#if 0
3354 +/*
3355 +       The following function codes are just copied from the SCO
3356 +       include file.
3357 +*/
3358 +
3359 +       case 0:  /* MT_STATUS */
3360 +       case 5:  /* MT_AMOUNT */
3361 +       case 10:  /* MT_DSTATUS */
3362 +       case 11:  /* MT_FORMAT */
3363 +       case 12:  /* MT_GETHDR */
3364 +       case 13:  /* MT_PUTHDR */
3365 +       case 14:  /* MT_GETNEWBB */
3366 +       case 15:  /* MT_PUTNEWBB */
3367 +       case 16:  /* MT_GETVTBL */
3368 +       case 17:  /* MT_PUTVTBL */
3369 +       case 18:  /* MT_SERVO */
3370 +       case 22:  /* MT_FORMPART */
3371 +       case 38:  /* MT_SETANSI */
3372 +       case 64:  /* MT_REPORT */
3373 +#endif
3374 +       default:
3375 +               printk (KERN_ERR "abi: SCO tape ioctl func=%d arg=%x unsupported\n",
3376 +                       cmd & 0xff, (int)data);
3377 +               return -EINVAL;
3378 +       }
3379 +
3380 +       fs = get_fs();
3381 +       set_fs(get_ds());
3382 +       error = sys_ioctl(fd, MTIOCTOP, (long)&mtop);
3383 +       set_fs(fs);
3384 +       return (error);
3385 +}
3386 diff -Nur kernel-source-2.6.16.orig/abi/sco/termios.c kernel-source-2.6.16/abi/sco/termios.c
3387 --- kernel-source-2.6.16.orig/abi/sco/termios.c 1970-01-01 10:00:00.000000000 +1000
3388 +++ kernel-source-2.6.16/abi/sco/termios.c      2006-04-27 18:50:24.000000000 +1000
3389 @@ -0,0 +1,187 @@
3390 +/*
3391 + * Copyright (C) 1991, 1992  Linus Torvalds
3392 + *
3393 + * Written by Drew Sullivan.
3394 + * Rewritten by Mike Jagdis.
3395 + */
3396 +
3397 +#ident "%W% %G%"
3398 +
3399 +#include <linux/errno.h>
3400 +#include <linux/kernel.h>
3401 +#include <linux/termios.h>
3402 +#include <linux/unistd.h>
3403 +#include <linux/syscalls.h>
3404 +#include <asm/uaccess.h>
3405 +
3406 +#include <abi/svr4/ioctl.h>
3407 +#include <abi/svr4/termios.h>
3408 +
3409 +
3410 +#define SCO_NCCS (SVR_NCC+5)
3411 +
3412 +struct sco_termios {
3413 +       u_int16_t       c_iflag;
3414 +       u_int16_t       c_oflag;
3415 +       u_int16_t       c_cflag;
3416 +       u_int16_t       c_lflag;
3417 +       char            c_line;
3418 +       u_char          c_cc[SCO_NCCS];
3419 +       char            c_ispeed;
3420 +       char            c_ospeed;
3421 +};
3422 +
3423 +static int
3424 +sco_to_linux_termios(int fd, int op, struct sco_termios *it)
3425 +{
3426 +       struct termios          t;
3427 +       mm_segment_t            old_fs;
3428 +       u_short                 lflag, r;
3429 +       char                    sco_cc[SCO_NCCS];
3430 +       int                     error;
3431 +
3432 +       if (!access_ok(VERIFY_READ, it, sizeof(struct sco_termios)))
3433 +               return -EFAULT;
3434 +
3435 +       old_fs = get_fs();
3436 +       set_fs(get_ds());
3437 +       error = sys_ioctl(fd, TCGETS, (long)&t);
3438 +       set_fs(old_fs);
3439 +
3440 +       if (error)
3441 +               return (error);
3442 +
3443 +       __get_user(t.c_iflag, &it->c_iflag);
3444 +       t.c_iflag &= ~0100000; /* DOSMODE */
3445 +
3446 +       __get_user(t.c_oflag, &it->c_oflag);
3447 +
3448 +       __get_user(t.c_cflag, &it->c_cflag);
3449 +       if (t.c_cflag & 0100000) /* CRTSFL - SCO only? */
3450 +               t.c_cflag |= CRTSCTS;
3451 +       t.c_cflag &= ~0170000; /* LOBLK|CTSFLOW|RTSFLOW|CRTSFL */
3452 +
3453 +       lflag = t.c_lflag;
3454 +       t.c_lflag &= ~0100777;
3455 +       __get_user(r, &it->c_lflag);
3456 +       t.c_lflag |= r;
3457 +
3458 +       if ((t.c_lflag & 0100000))
3459 +               sys_ioctl(fd, TIOCEXCL, 0);
3460 +       else
3461 +               sys_ioctl(fd, TIOCNXCL, 0);
3462 +
3463 +       t.c_lflag &= ~0100000;
3464 +       t.c_lflag |= (t.c_lflag & 0000400) << 7; /* Move IEXTEN */
3465 +       t.c_lflag &= ~0000400;
3466 +       t.c_lflag |= (t.c_lflag & 0001000) >> 1; /* Move TOSTOP */
3467 +       t.c_lflag &= ~0001000;
3468 +       t.c_lflag |= (lflag & 0001000); /* Restore ECHOCTL */
3469 +
3470 +       __get_user(t.c_line, &it->c_line); /* XXX Map this? */
3471 +
3472 +       if (copy_from_user(sco_cc, &it->c_cc, SCO_NCCS))
3473 +               return -EFAULT;
3474 +
3475 +       t.c_cc[0] = sco_cc[0];
3476 +       t.c_cc[1] = sco_cc[1];
3477 +       t.c_cc[2] = sco_cc[2];
3478 +       t.c_cc[3] = sco_cc[3];
3479 +       t.c_cc[7] = sco_cc[7];
3480 +       t.c_cc[8] = sco_cc[11];
3481 +       t.c_cc[9] = sco_cc[12];
3482 +       t.c_cc[10] = sco_cc[10];
3483 +       t.c_cc[16] = sco_cc[6];
3484 +       if (t.c_lflag & ICANON) {
3485 +               t.c_cc[4] = sco_cc[4];
3486 +               t.c_cc[11] = sco_cc[5];
3487 +       } else {
3488 +               t.c_cc[4] = sco_cc[8];
3489 +               t.c_cc[5] = sco_cc[5];
3490 +               t.c_cc[6] = sco_cc[4];
3491 +               t.c_cc[11] = sco_cc[9];
3492 +       }
3493 +
3494 +       set_fs(get_ds());
3495 +       error = sys_ioctl(fd, op, (long)&t);
3496 +       set_fs(old_fs);
3497 +
3498 +       return (error);
3499 +}
3500 +
3501 +static int
3502 +linux_to_sco_termios(int fd, int op, struct sco_termios *it)
3503 +{
3504 +       struct termios          t;
3505 +       char                    sco_cc[SCO_NCCS];
3506 +       mm_segment_t            old_fs;
3507 +       int                     error;
3508 +
3509 +       if (!access_ok(VERIFY_WRITE, it, sizeof(struct sco_termios)))
3510 +               return -EFAULT;
3511 +
3512 +       old_fs = get_fs();
3513 +       set_fs(get_ds());
3514 +       error = sys_ioctl(fd, op, (long)&t);
3515 +       set_fs(old_fs);
3516 +       if (error)
3517 +               return (error);
3518 +
3519 +       put_user(t.c_iflag & 0017777, &it->c_iflag);
3520 +
3521 +       put_user(t.c_oflag & 0177777, &it->c_oflag);
3522 +
3523 +       if (t.c_cflag & CRTSCTS)
3524 +               t.c_cflag |= 0100000; /* CRTSFL - SCO only? */
3525 +       put_user(t.c_cflag & 0177777, &it->c_cflag);
3526 +
3527 +       t.c_lflag &= ~0001000;
3528 +       t.c_lflag |= (t.c_lflag & 0000400) << 1;
3529 +       t.c_lflag &= ~0000400;
3530 +       t.c_lflag |= (t.c_lflag & 0100000) >> 7;
3531 +       t.c_lflag &= ~0100000;
3532 +       put_user(t.c_lflag & 0001777, &it->c_lflag);
3533 +
3534 +       put_user(t.c_line, &it->c_line); /* XXX Map this? */
3535 +
3536 +       sco_cc[0] = t.c_cc[0];
3537 +       sco_cc[1] = t.c_cc[1];
3538 +       sco_cc[2] = t.c_cc[2];
3539 +       sco_cc[3] = t.c_cc[3];
3540 +       sco_cc[6] = t.c_cc[16];
3541 +       sco_cc[7] = t.c_cc[7];
3542 +       sco_cc[8] = t.c_cc[4];
3543 +       sco_cc[9] = t.c_cc[11];
3544 +       sco_cc[10] = t.c_cc[10];
3545 +       sco_cc[11] = t.c_cc[8];
3546 +       sco_cc[12] = t.c_cc[9];
3547 +       if (t.c_lflag & ICANON) {
3548 +               sco_cc[4] = t.c_cc[4];
3549 +               sco_cc[5] = t.c_cc[11];
3550 +       } else {
3551 +               sco_cc[4] = t.c_cc[6];
3552 +               sco_cc[5] = t.c_cc[5];
3553 +       }
3554 +
3555 +       if (copy_to_user(&it->c_cc, sco_cc, SCO_NCCS))
3556 +               error = -EFAULT;
3557 +
3558 +       return (error);
3559 +}
3560 +
3561 +int
3562 +sco_term_ioctl(int fd, unsigned int func, void *arg)
3563 +{
3564 +       switch(func) {
3565 +       case 1: /* XCGETA */
3566 +               return linux_to_sco_termios(fd, TCGETS, arg);
3567 +       case 2: /* XCSETA */
3568 +               return sco_to_linux_termios(fd, TCSETS, arg);
3569 +       case 3: /* XCSETAW */
3570 +               return sco_to_linux_termios(fd, TCSETSW, arg);
3571 +       case 4: /* XCSETAF */
3572 +               return sco_to_linux_termios(fd, TCSETSF, arg);
3573 +       }
3574 +       printk(KERN_ERR "iBCS: SCO termios ioctl %d unsupported\n", func);
3575 +       return -EINVAL;
3576 +}
3577 diff -Nur kernel-source-2.6.16.orig/abi/sco/vtkbd.c kernel-source-2.6.16/abi/sco/vtkbd.c
3578 --- kernel-source-2.6.16.orig/abi/sco/vtkbd.c   1970-01-01 10:00:00.000000000 +1000
3579 +++ kernel-source-2.6.16/abi/sco/vtkbd.c        2006-04-27 18:50:24.000000000 +1000
3580 @@ -0,0 +1,88 @@
3581 +/*
3582 + * This provides internal emulation support for the SCO <sys/vtkd.h> on
3583 + * the multiscreen console. More or less, this involves translating the
3584 + * input ioctl()'s into a similar Linux ioctl()'s.
3585 + *
3586 + * Not emulated SCO multiscreen functions:
3587 + *   None.
3588 + *
3589 + * Not emulated SCO keyboard functions:
3590 + *   KIOCDOSMODE               set DOSMODE
3591 + *   KIOCNONDOSMODE            unset DOSMODE
3592 + *   KDDISPINFO                        get display start and size
3593 + *   KDGKBSTATE                        get state of keyboard shift keys
3594 + *
3595 + * Written by Scott Michel, scottm@intime.com
3596 + * (c) 1994 Scott Michel as part of the Linux iBCS-2 emulator project.
3597 + */
3598 +
3599 +#ident "%W% %G%"
3600 +
3601 +#include <linux/errno.h>
3602 +#include <linux/kernel.h>
3603 +#include <linux/vt.h>
3604 +#include <linux/kd.h>
3605 +#include <linux/syscalls.h>
3606 +#include <asm/uaccess.h>
3607 +
3608 +
3609 +static struct {
3610 +       int     in;             /* only lower 8 bits */
3611 +       int     out;            /* Linux version */
3612 +} trantab[] = {
3613 +#ifdef KDDISPTYPE
3614 +       { 1,  KDDISPTYPE   },
3615 +#endif
3616 +       { 2,  KDMAPDISP    },
3617 +       { 3,  KDUNMAPDISP  },
3618 +       { 6,  KDGKBMODE    },
3619 +       { 7,  KDSKBMODE    },
3620 +       { 8,  KDMKTONE     },
3621 +       { 9,  KDGETMODE    },
3622 +       { 10, KDSETMODE    },
3623 +       { 11, KDADDIO      },
3624 +       { 12, KDDELIO      },
3625 +       { 60, KDENABIO     },
3626 +       { 61, KDDISABIO    },
3627 +#ifdef KIOCINFO
3628 +       { 62, KIOCINFO     },
3629 +#endif
3630 +       { 63, KIOCSOUND    },
3631 +       { 64, KDGKBTYPE    },
3632 +       { 65, KDGETLED     },
3633 +       { 66, KDSETLED     },
3634 +};
3635 +
3636 +
3637 +int
3638 +sco_vtkbd_ioctl(int fd, u_int cmd, caddr_t data)
3639 +{
3640 +       u_int                   gen = (cmd >> 8) & 0xff;
3641 +       u_int                   spec = cmd & 0xff;
3642 +       int                     newf, i;
3643 +
3644 +       switch (gen) {
3645 +       case 'V':
3646 +               /*
3647 +                * Could make this translation process table based, but, why
3648 +                * waste the valuable kernel space ?
3649 +                */
3650 +
3651 +               newf = (spec == 1 ? VT_OPENQRY :
3652 +                       (spec == 2 ? VT_SETMODE :
3653 +                        (spec == 3 ? VT_GETMODE :
3654 +                         (spec == 4 ? VT_RELDISP :
3655 +                          (spec == 5 ? VT_ACTIVATE : -1)))));
3656 +               if (newf != -1)
3657 +                       return sys_ioctl(fd, newf, (long)data);
3658 +               break;
3659 +       case 'K':
3660 +               for (i = 0; i < ARRAY_SIZE(trantab); i++) {
3661 +                       if (spec == trantab[i].in)
3662 +                               return sys_ioctl(fd, trantab[i].out, (long)data);
3663 +               }
3664 +               /* FALLTHROUGH */
3665 +       }
3666 +       printk(KERN_ERR "%s: vtkd ioctl 0x%02x unsupported\n", __FILE__, cmd);
3667 +       return -EINVAL;
3668 +}
3669 diff -Nur kernel-source-2.6.16.orig/abi/solaris/lfs.c kernel-source-2.6.16/abi/solaris/lfs.c
3670 --- kernel-source-2.6.16.orig/abi/solaris/lfs.c 1970-01-01 10:00:00.000000000 +1000
3671 +++ kernel-source-2.6.16/abi/solaris/lfs.c      2006-04-27 18:50:24.000000000 +1000
3672 @@ -0,0 +1,242 @@
3673 +/*
3674 + * Solaris Large File Summit support
3675 + */
3676 +
3677 +#ident "%W% %G%"
3678 +
3679 +#include <linux/errno.h>
3680 +#include <linux/stat.h>
3681 +#include <linux/fs.h>
3682 +#include <linux/sched.h>
3683 +#include <linux/kernel.h>
3684 +#include <linux/mm.h>
3685 +#include <linux/file.h>
3686 +#include <linux/slab.h>
3687 +#include <linux/mman.h>
3688 +#include <linux/net.h>
3689 +#include <linux/socket.h>
3690 +#include <linux/un.h>
3691 +#include <linux/dirent.h>
3692 +#include <linux/syscalls.h>
3693 +#include <asm/uaccess.h>
3694 +
3695 +#include <abi/util/map.h>
3696 +#include <abi/svr4/sysent.h>
3697 +
3698 +
3699 +int
3700 +sol_open64(const char *fname, int flag, int mode)
3701 +{
3702 +       u_long args[3];
3703 +       int error, fd;
3704 +       struct file *file;
3705 +       mm_segment_t old_fs;
3706 +       char *p;
3707 +       struct sockaddr_un addr;
3708 +
3709 +       fd = sys_open(fname, map_flags(flag, fl_svr4_to_linux) | O_LARGEFILE, mode);
3710 +       if (fd < 0)
3711 +               return fd;
3712 +
3713 +       /* Sometimes a program may open a pathname which it expects
3714 +        * to be a named pipe (or STREAMS named pipe) when the
3715 +        * Linux domain equivalent is a Unix domain socket. (e.g.
3716 +        * UnixWare uses a STREAMS named pipe /dev/X/Nserver.0 for
3717 +        * X :0 but Linux uses a Unix domain socket /tmp/.X11-unix/X0)
3718 +        * It isn't enough just to make the symlink because you cannot
3719 +        * open() a socket and read/write it. If we spot the error we can
3720 +        * switch to socket(), connect() and things will likely work
3721 +        * as expected however.
3722 +        */
3723 +       file = fget(fd);
3724 +       if (!file)
3725 +               return fd; /* Huh?!? */
3726 +       if (!S_ISSOCK(file->f_dentry->d_inode->i_mode)) {
3727 +               fput(file);
3728 +               return fd;
3729 +       }
3730 +       fput(file);
3731 +
3732 +       sys_close(fd);
3733 +       args[0] = AF_UNIX;
3734 +       args[1] = SOCK_STREAM;
3735 +       args[2] = 0;
3736 +       old_fs = get_fs();
3737 +       set_fs(get_ds());
3738 +       fd = sys_socketcall(SYS_SOCKET, args);
3739 +       set_fs(old_fs);
3740 +       if (fd < 0)
3741 +               return fd;
3742 +
3743 +       p = getname(fname);
3744 +       if (IS_ERR(p)) {
3745 +               sys_close(fd);
3746 +               return PTR_ERR(p);
3747 +       }
3748 +       if (strlen(p) >= UNIX_PATH_MAX) {
3749 +               putname(p);
3750 +               sys_close(fd);
3751 +               return -E2BIG;
3752 +       }
3753 +       addr.sun_family = AF_UNIX;
3754 +       strcpy(addr.sun_path, p);
3755 +       putname(p);
3756 +
3757 +       args[0] = fd;
3758 +       args[1] = (int)&addr;
3759 +       args[2] = sizeof(struct sockaddr_un);
3760 +       set_fs(get_ds());
3761 +       error = sys_socketcall(SYS_CONNECT, args);
3762 +       set_fs(old_fs);
3763 +       if (error) {
3764 +               sys_close(fd);
3765 +               return error;
3766 +       }
3767 +
3768 +       return fd;
3769 +}
3770 +
3771 +
3772 +struct sol_dirent64 {
3773 +       unsigned long long d_ino;
3774 +       unsigned long long d_off;
3775 +       unsigned short d_reclen;
3776 +       char d_name[1];
3777 +};
3778 +
3779 +
3780 +/* If/when the readdir function is changed to read multiple entries
3781 + * at once this should be updated to take advantage of the fact.
3782 + *
3783 + * N.B. For Linux the reclen in a dirent is the number of characters
3784 + * in the filename, for SCO (at least) reclen is the total size of
3785 + * the particular dirent rounded up to the next multiple of 4. The SCO
3786 + * behaviour is faithfully emulated here.
3787 + *
3788 + * XXXX
3789 + * We don't truncate long filenames at all when copying. If we meet a
3790 + * long filename and the buffer supplied by the application simply isn't
3791 + * big enough to hold it we'll return without filling the buffer (i.e
3792 + * return 0). The application will see this as a (premature) end of
3793 + * directory. Is there a work around for this at all???
3794 + */
3795 +int
3796 +sol_getdents64(int fd, char *buf, int nbytes)
3797 +{
3798 +       int error, here, posn, reclen;
3799 +       struct file *file;
3800 +       struct old_linux_dirent *d;
3801 +       mm_segment_t old_fs;
3802 +
3803 +       if (!access_ok(VERIFY_WRITE, buf, nbytes))
3804 +               return -EFAULT;
3805 +
3806 +       /* Check the file handle here. This is so we can access the current
3807 +        * position in the file structure safely without a tedious call
3808 +        * to sys_lseek that does nothing useful.
3809 +        */
3810 +       file = fget(fd);
3811 +       if (!file)
3812 +               return -EBADF;
3813 +
3814 +       d = (struct old_linux_dirent *)__get_free_page(GFP_KERNEL);
3815 +       if (!d) {
3816 +               fput(file);
3817 +               return -ENOMEM;
3818 +       }
3819 +
3820 +       error = posn = reclen = 0;
3821 +       while (posn + reclen < nbytes) {
3822 +                int string_size;
3823 +               struct sol_dirent64 tmpbuf;
3824 +               /* Save the current position and get another dirent */
3825 +               here = file->f_pos;
3826 +               old_fs = get_fs();
3827 +               set_fs (get_ds());
3828 +               error = old_readdir(fd, d, 1);
3829 +               set_fs(old_fs);
3830 +               if (error <= 0)
3831 +                       break;
3832 +
3833 +               /* If it'll fit in the buffer save it.
3834 +                * Otherwise back up so it is read next time around.
3835 +                * Oh, if we're at the beginning of the buffer there's
3836 +                * no chance that this entry will ever fit so don't
3837 +                * copy it and don't back off - we'll just pretend it
3838 +                * isn't here...
3839 +                */
3840 +               string_size = d->d_namlen + 1; /* chars in d_name + trailing zero */
3841 +               reclen = (sizeof(long long) /* d_ino */
3842 +                       + sizeof(long long) /* d_offset */
3843 +                       + sizeof(unsigned short) /* d_namlen */
3844 +                       + string_size
3845 +                       + 3) & (~3); /* align to a 4 byte boundary */
3846 +               if (posn + reclen <= nbytes) {
3847 +                       tmpbuf.d_off = file->f_pos;
3848 +                       tmpbuf.d_ino = d->d_ino;
3849 +                       tmpbuf.d_off = file->f_pos;
3850 +                       tmpbuf.d_reclen = reclen;
3851 +                       if (copy_to_user(buf+posn, &tmpbuf,
3852 +                                    sizeof(struct sol_dirent64) -1))
3853 +                       {       posn = 0;
3854 +                               error = -EFAULT;
3855 +                               break;
3856 +                       }
3857 +                       if (copy_to_user(buf+posn+sizeof(struct sol_dirent64)-2,
3858 +                                    &d->d_name, string_size))
3859 +                       {       posn = 0;
3860 +                               error = -EFAULT;
3861 +                               break;
3862 +                       }
3863 +                       posn += reclen;
3864 +               } else if (posn) {
3865 +                       sys_lseek(fd, here, 0);
3866 +               } /* else posn == 0 */
3867 +       }
3868 +
3869 +       /* Loose the intermediate buffer. */
3870 +       free_page((unsigned long)d);
3871 +
3872 +       fput(file);
3873 +
3874 +       /* If we've put something in the buffer return the byte count
3875 +        * otherwise return the error status.
3876 +        */
3877 +       return ((posn > 0) ? posn : error);
3878 +}
3879 +
3880 +
3881 +int
3882 +sol_mmap64(u_int addr, u_int len, int prot, int flags,
3883 +           int fd, u_int off_hi, u_int off)
3884 +{
3885 +       loff_t                  off64 = (off | ((loff_t)off_hi << 32));
3886 +       u_long                  pgoff = (off64 >> PAGE_SHIFT);
3887 +       struct file             *file = NULL;
3888 +       int                     error;
3889 +
3890 +       if ((off64 + PAGE_ALIGN(len)) < off64)
3891 +               return -EINVAL;
3892 +
3893 +       if (!(off64 & ~PAGE_MASK))
3894 +               return -EINVAL;
3895 +
3896 +       flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
3897 +       if (!(flags & MAP_ANONYMOUS)) {
3898 +               if (!(file = fget(fd)))
3899 +                       return -EBADF;
3900 +       }
3901 +
3902 +       if (!(flags & 0x80000000) && addr)
3903 +               flags |= MAP_FIXED;
3904 +       else
3905 +               flags &= 0x7fffffff;
3906 +
3907 +       down_write(&current->mm->mmap_sem);
3908 +       error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
3909 +       up_write(&current->mm->mmap_sem);
3910 +
3911 +       if (file)
3912 +               fput(file);
3913 +       return (error);
3914 +}
3915 diff -Nur kernel-source-2.6.16.orig/abi/solaris/Makefile kernel-source-2.6.16/abi/solaris/Makefile
3916 --- kernel-source-2.6.16.orig/abi/solaris/Makefile      1970-01-01 10:00:00.000000000 +1000
3917 +++ kernel-source-2.6.16/abi/solaris/Makefile   2006-04-27 18:50:24.000000000 +1000
3918 @@ -0,0 +1,7 @@
3919 +
3920 +abi-solaris-objs:= lfs.o solarisx86.o socket.o stat.o sysent.o
3921 +
3922 +obj-$(CONFIG_ABI_SOLARIS)      += abi-solaris.o
3923 +
3924 +abi-solaris.o: $(abi-solaris-objs)
3925 +       $(LD) -r -o $@ $(abi-solaris-objs)
3926 diff -Nur kernel-source-2.6.16.orig/abi/solaris/socket.c kernel-source-2.6.16/abi/solaris/socket.c
3927 --- kernel-source-2.6.16.orig/abi/solaris/socket.c      1970-01-01 10:00:00.000000000 +1000
3928 +++ kernel-source-2.6.16/abi/solaris/socket.c   2006-04-27 18:50:24.000000000 +1000
3929 @@ -0,0 +1,496 @@
3930 +/*
3931 + * socket.c: Socket syscall emulation for Solaris 2.6+
3932 + *
3933 + * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz)
3934 + *
3935 + * 1999-08-19 Fixed socketpair code
3936 + *            Jason Rappleye (rappleye@ccr.buffalo.edu)
3937 + */
3938 +
3939 +#ident "%W% %G%"
3940 +
3941 +#include <linux/types.h>
3942 +#include <linux/sched.h>
3943 +#include <linux/smp_lock.h>
3944 +#include <linux/mm.h>
3945 +#include <linux/slab.h>
3946 +#include <linux/net.h>
3947 +#include <linux/socket.h>
3948 +#include <linux/file.h>
3949 +#include <linux/syscalls.h>
3950 +
3951 +#include <asm/uaccess.h>
3952 +#include <asm/string.h>
3953 +
3954 +#define SOCK_SOL_STREAM                2
3955 +#define SOCK_SOL_DGRAM         1
3956 +#define SOCK_SOL_RAW           4
3957 +#define SOCK_SOL_RDM           5
3958 +#define SOCK_SOL_SEQPACKET     6
3959 +
3960 +#define SOL_SO_SNDLOWAT                0x1003
3961 +#define SOL_SO_RCVLOWAT                0x1004
3962 +#define SOL_SO_SNDTIMEO                0x1005
3963 +#define SOL_SO_RCVTIMEO                0x1006
3964 +#define SOL_SO_STATE           0x2000
3965 +
3966 +#define SOL_SS_NDELAY          0x040
3967 +#define SOL_SS_NONBLOCK                0x080
3968 +#define SOL_SS_ASYNC           0x100
3969 +
3970 +#define SO_STATE               0x000e
3971 +
3972 +
3973 +/*
3974 + * 64 bit vs 32bit issues.
3975 + */
3976 +#if BITS_PER_LONG == 32
3977 +#  define sys32_getsockopt     sys_getsockopt
3978 +#  define A(ptr)               ((void *)(ptr))
3979 +#  define __kernel_size_t32    __kernel_size_t
3980 +#endif
3981 +
3982 +
3983 +int sunos_setsockopt(int fd, int level, int optname, u32 optval,
3984 +                               int optlen)
3985 +{
3986 +       int tr_opt = optname;
3987 +       int ret;
3988 +
3989 +       if (level == SOL_IP) {
3990 +               /* Multicast socketopts (ttl, membership) */
3991 +               if (tr_opt >=2 && tr_opt <= 6)
3992 +                       tr_opt += 30;
3993 +       }
3994 +       ret = sys_setsockopt(fd, level, tr_opt, (char *)A(optval), optlen);
3995 +       return ret;
3996 +}
3997 +
3998 +int sunos_getsockopt(int fd, int level, int optname,
3999 +                               u32 optval, u32 optlen)
4000 +{
4001 +       int tr_opt = optname;
4002 +       int ret;
4003 +
4004 +       if (level == SOL_IP) {
4005 +               /* Multicast socketopts (ttl, membership) */
4006 +               if (tr_opt >=2 && tr_opt <= 6)
4007 +                       tr_opt += 30;
4008 +       }
4009 +       ret = sys32_getsockopt(fd, level, tr_opt, (char *)optval, (int *)optlen);
4010 +       return ret;
4011 +}
4012 +
4013 +static int socket_check(int family, int type)
4014 +{
4015 +       if (family != PF_UNIX && family != PF_INET)
4016 +               return -ESOCKTNOSUPPORT;
4017 +       switch (type) {
4018 +       case SOCK_SOL_STREAM:
4019 +               type = SOCK_STREAM;
4020 +               break;
4021 +       case SOCK_SOL_DGRAM:
4022 +               type = SOCK_DGRAM;
4023 +               break;
4024 +       case SOCK_SOL_RAW:
4025 +               type = SOCK_RAW;
4026 +               break;
4027 +       case SOCK_SOL_RDM:
4028 +               type = SOCK_RDM;
4029 +               break;
4030 +       case SOCK_SOL_SEQPACKET:
4031 +               type = SOCK_SEQPACKET;
4032 +               break;
4033 +       default:
4034 +               return -EINVAL;
4035 +       }
4036 +       return type;
4037 +}
4038 +
4039 +static int solaris_to_linux_sockopt(int optname)
4040 +{
4041 +       switch (optname) {
4042 +       case SOL_SO_SNDLOWAT:
4043 +               optname = SO_SNDLOWAT;
4044 +               break;
4045 +       case SOL_SO_RCVLOWAT:
4046 +               optname = SO_RCVLOWAT;
4047 +               break;
4048 +       case SOL_SO_SNDTIMEO:
4049 +               optname = SO_SNDTIMEO;
4050 +               break;
4051 +       case SOL_SO_RCVTIMEO:
4052 +               optname = SO_RCVTIMEO;
4053 +               break;
4054 +       case SOL_SO_STATE:
4055 +               optname = SO_STATE;
4056 +               break;
4057 +       };
4058 +
4059 +       return optname;
4060 +}
4061 +
4062 +int solaris_socket(int family, int type, int protocol)
4063 +{
4064 +       type = socket_check (family, type);
4065 +       if (type < 0)
4066 +               return type;
4067 +       return sys_socket(family, type, protocol);
4068 +}
4069 +
4070 +int solaris_socketpair(int *usockvec)
4071 +{
4072 +       /* solaris socketpair really only takes one arg at the syscall
4073 +        * level, int * usockvec. The libs apparently take care of
4074 +        * making sure that family==AF_UNIX and type==SOCK_STREAM. The
4075 +        * pointer we really want ends up residing in the first (and
4076 +        * supposedly only) argument.
4077 +        */
4078 +
4079 +       return sys_socketpair(AF_UNIX, SOCK_STREAM, 0, (int *)usockvec);
4080 +}
4081 +
4082 +int solaris_bind(int fd, struct sockaddr *addr, int addrlen)
4083 +{
4084 +       return sys_bind(fd, addr, addrlen);
4085 +}
4086 +
4087 +int solaris_setsockopt(int fd, int level, int optname, u32 optval, int optlen)
4088 +{
4089 +       optname = solaris_to_linux_sockopt(optname);
4090 +       if (optname < 0)
4091 +               return optname;
4092 +       if (optname == SO_STATE)
4093 +               return 0;
4094 +
4095 +       return sunos_setsockopt(fd, level, optname, optval, optlen);
4096 +}
4097 +
4098 +int solaris_getsockopt(int fd, int level, int optname, u32 optval, u32 optlen)
4099 +{
4100 +       optname = solaris_to_linux_sockopt(optname);
4101 +       if (optname < 0)
4102 +               return optname;
4103 +
4104 +       if (optname == SO_STATE)
4105 +               optname = SOL_SO_STATE;
4106 +
4107 +       return sunos_getsockopt(fd, level, optname, optval, optlen);
4108 +}
4109 +
4110 +int solaris_connect(int fd, struct sockaddr *addr, int addrlen)
4111 +{
4112 +       return sys_connect(fd, addr, addrlen);
4113 +}
4114 +
4115 +int solaris_accept(int fd, struct sockaddr *addr, int *addrlen)
4116 +{
4117 +       return sys_accept(fd, addr, addrlen);
4118 +}
4119 +
4120 +int solaris_listen(int fd, int backlog)
4121 +{
4122 +       return sys_listen(fd, backlog);
4123 +}
4124 +
4125 +int solaris_shutdown(int fd, int how)
4126 +{
4127 +       return sys_shutdown(fd, how);
4128 +}
4129 +
4130 +#define MSG_SOL_OOB            0x1
4131 +#define MSG_SOL_PEEK           0x2
4132 +#define MSG_SOL_DONTROUTE      0x4
4133 +#define MSG_SOL_EOR            0x8
4134 +#define MSG_SOL_CTRUNC         0x10
4135 +#define MSG_SOL_TRUNC          0x20
4136 +#define MSG_SOL_WAITALL                0x40
4137 +#define MSG_SOL_DONTWAIT       0x80
4138 +
4139 +static int solaris_to_linux_msgflags(int flags)
4140 +{
4141 +       int fl = flags & (MSG_OOB|MSG_PEEK|MSG_DONTROUTE);
4142 +
4143 +       if (flags & MSG_SOL_EOR) fl |= MSG_EOR;
4144 +       if (flags & MSG_SOL_CTRUNC) fl |= MSG_CTRUNC;
4145 +       if (flags & MSG_SOL_TRUNC) fl |= MSG_TRUNC;
4146 +       if (flags & MSG_SOL_WAITALL) fl |= MSG_WAITALL;
4147 +       if (flags & MSG_SOL_DONTWAIT) fl |= MSG_DONTWAIT;
4148 +       return fl;
4149 +}
4150 +
4151 +static int linux_to_solaris_msgflags(int flags)
4152 +{
4153 +       int fl = flags & (MSG_OOB|MSG_PEEK|MSG_DONTROUTE);
4154 +
4155 +       if (flags & MSG_EOR) fl |= MSG_SOL_EOR;
4156 +       if (flags & MSG_CTRUNC) fl |= MSG_SOL_CTRUNC;
4157 +       if (flags & MSG_TRUNC) fl |= MSG_SOL_TRUNC;
4158 +       if (flags & MSG_WAITALL) fl |= MSG_SOL_WAITALL;
4159 +       if (flags & MSG_DONTWAIT) fl |= MSG_SOL_DONTWAIT;
4160 +       return fl;
4161 +}
4162 +
4163 +int solaris_recvfrom(int s, char *buf, int len, int flags, u32 from, u32 fromlen)
4164 +{
4165 +       return sys_recvfrom(s, buf, len, solaris_to_linux_msgflags(flags), (struct sockaddr *)A(from), (int *)A(fromlen));
4166 +}
4167 +
4168 +int solaris_recv(int s, char *buf, int len, int flags)
4169 +{
4170 +       return sys_recvfrom(s, buf, len, solaris_to_linux_msgflags(flags), NULL, NULL);
4171 +}
4172 +
4173 +int solaris_sendto(int s, char *buf, int len, int flags, u32 to, u32 tolen)
4174 +{
4175 +       return sys_sendto(s, buf, len, solaris_to_linux_msgflags(flags), (struct sockaddr *)A(to), (int)A(tolen));
4176 +}
4177 +
4178 +int solaris_send(int s, char *buf, int len, int flags)
4179 +{
4180 +       return sys_sendto(s, buf, len, solaris_to_linux_msgflags(flags), NULL, 0);
4181 +}
4182 +
4183 +int solaris_getpeername(int fd, struct sockaddr *addr, int *addrlen)
4184 +{
4185 +       return sys_getpeername(fd, addr, addrlen);
4186 +}
4187 +
4188 +int solaris_getsockname(int fd, struct sockaddr *addr, int *addrlen)
4189 +{
4190 +       return sys_getsockname(fd, addr, addrlen);
4191 +}
4192 +
4193 +/* XXX This really belongs in some header file... -DaveM */
4194 +#define MAX_SOCK_ADDR  128             /* 108 for Unix domain -
4195 +                                          16 for IP, 16 for IPX,
4196 +                                          24 for IPv6,
4197 +                                          about 80 for AX.25 */
4198 +
4199 +struct sol_nmsghdr {
4200 +       u32             msg_name;
4201 +       int             msg_namelen;
4202 +       u32             msg_iov;
4203 +       u32             msg_iovlen;
4204 +       u32             msg_control;
4205 +       u32             msg_controllen;
4206 +       u32             msg_flags;
4207 +};
4208 +
4209 +struct sol_cmsghdr {
4210 +       u32             cmsg_len;
4211 +       int             cmsg_level;
4212 +       int             cmsg_type;
4213 +       unsigned char   cmsg_data[0];
4214 +};
4215 +
4216 +struct iovec32 {
4217 +       u32             iov_base;
4218 +       u32 iov_len;
4219 +};
4220 +
4221 +static inline int iov_from_user32_to_kern(struct iovec *kiov,
4222 +                                         struct iovec32 *uiov32,
4223 +                                         int niov)
4224 +{
4225 +       int tot_len = 0;
4226 +
4227 +       while(niov > 0) {
4228 +               u32 len, buf;
4229 +
4230 +               if(get_user(len, &uiov32->iov_len) ||
4231 +                  get_user(buf, &uiov32->iov_base)) {
4232 +                       tot_len = -EFAULT;
4233 +                       break;
4234 +               }
4235 +               tot_len += len;
4236 +               kiov->iov_base = (void *)A(buf);
4237 +               kiov->iov_len = (__kernel_size_t) len;
4238 +               uiov32++;
4239 +               kiov++;
4240 +               niov--;
4241 +       }
4242 +       return tot_len;
4243 +}
4244 +
4245 +static inline int msghdr_from_user32_to_kern(struct msghdr *kmsg,
4246 +                                            struct sol_nmsghdr *umsg)
4247 +{
4248 +       u32 tmp1, tmp2, tmp3;
4249 +       int err;
4250 +
4251 +       err = get_user(tmp1, &umsg->msg_name);
4252 +       err |= __get_user(tmp2, &umsg->msg_iov);
4253 +       err |= __get_user(tmp3, &umsg->msg_control);
4254 +       if (err)
4255 +               return -EFAULT;
4256 +
4257 +       kmsg->msg_name = (void *)A(tmp1);
4258 +       kmsg->msg_iov = (struct iovec *)A(tmp2);
4259 +       kmsg->msg_control = (void *)A(tmp3);
4260 +
4261 +       err = get_user(kmsg->msg_namelen, &umsg->msg_namelen);
4262 +       err |= get_user(kmsg->msg_controllen, &umsg->msg_controllen);
4263 +       err |= get_user(kmsg->msg_flags, &umsg->msg_flags);
4264 +
4265 +       kmsg->msg_flags = solaris_to_linux_msgflags(kmsg->msg_flags);
4266 +
4267 +       return err;
4268 +}
4269 +
4270 +/* I've named the args so it is easy to tell whose space the pointers are in. */
4271 +static int verify_iovec32(struct msghdr *kern_msg, struct iovec *kern_iov,
4272 +                         char *kern_address, int mode)
4273 +{
4274 +       int tot_len;
4275 +
4276 +       if(kern_msg->msg_namelen) {
4277 +               if(mode==VERIFY_READ) {
4278 +                       int err = move_addr_to_kernel(kern_msg->msg_name,
4279 +                                                     kern_msg->msg_namelen,
4280 +                                                     kern_address);
4281 +                       if(err < 0)
4282 +                               return err;
4283 +               }
4284 +               kern_msg->msg_name = kern_address;
4285 +       } else
4286 +               kern_msg->msg_name = NULL;
4287 +
4288 +       if(kern_msg->msg_iovlen > UIO_FASTIOV) {
4289 +               kern_iov = kmalloc(kern_msg->msg_iovlen * sizeof(struct iovec),
4290 +                                  GFP_KERNEL);
4291 +               if(!kern_iov)
4292 +                       return -ENOMEM;
4293 +       }
4294 +
4295 +       tot_len = iov_from_user32_to_kern(kern_iov,
4296 +                                         (struct iovec32 *)kern_msg->msg_iov,
4297 +                                         kern_msg->msg_iovlen);
4298 +       if(tot_len >= 0)
4299 +               kern_msg->msg_iov = kern_iov;
4300 +       else if(kern_msg->msg_iovlen > UIO_FASTIOV)
4301 +               kfree(kern_iov);
4302 +
4303 +       return tot_len;
4304 +}
4305 +
4306 +int solaris_sendmsg(int fd, struct sol_nmsghdr *user_msg, unsigned user_flags)
4307 +{
4308 +       struct socket *sock;
4309 +       char address[MAX_SOCK_ADDR];
4310 +       struct iovec iov[UIO_FASTIOV];
4311 +       unsigned char ctl[sizeof(struct cmsghdr) + 20];
4312 +       unsigned char *ctl_buf = ctl;
4313 +       struct msghdr kern_msg;
4314 +       int err, total_len;
4315 +
4316 +       if(msghdr_from_user32_to_kern(&kern_msg, user_msg))
4317 +               return -EFAULT;
4318 +       if(kern_msg.msg_iovlen > UIO_MAXIOV)
4319 +               return -EINVAL;
4320 +       err = verify_iovec32(&kern_msg, iov, address, VERIFY_READ);
4321 +       if (err < 0)
4322 +               goto out;
4323 +       total_len = err;
4324 +
4325 +       if(kern_msg.msg_controllen) {
4326 +               struct sol_cmsghdr *ucmsg = (struct sol_cmsghdr *)kern_msg.msg_control;
4327 +               unsigned long *kcmsg;
4328 +               __kernel_size_t32 cmlen;
4329 +
4330 +               if(kern_msg.msg_controllen > sizeof(ctl) &&
4331 +                  kern_msg.msg_controllen <= 256) {
4332 +                       err = -ENOBUFS;
4333 +                       ctl_buf = kmalloc(kern_msg.msg_controllen, GFP_KERNEL);
4334 +                       if(!ctl_buf)
4335 +                               goto out_freeiov;
4336 +               }
4337 +               __get_user(cmlen, &ucmsg->cmsg_len);
4338 +               kcmsg = (unsigned long *) ctl_buf;
4339 +               *kcmsg++ = (unsigned long)cmlen;
4340 +               err = -EFAULT;
4341 +               if(copy_from_user(kcmsg, &ucmsg->cmsg_level,
4342 +                                 kern_msg.msg_controllen - sizeof(__kernel_size_t32)))
4343 +                       goto out_freectl;
4344 +               kern_msg.msg_control = ctl_buf;
4345 +       }
4346 +       kern_msg.msg_flags = solaris_to_linux_msgflags(user_flags);
4347 +
4348 +       lock_kernel();
4349 +       sock = sockfd_lookup(fd, &err);
4350 +       if (sock != NULL) {
4351 +               if (sock->file->f_flags & O_NONBLOCK)
4352 +                       kern_msg.msg_flags |= MSG_DONTWAIT;
4353 +               err = sock_sendmsg(sock, &kern_msg, total_len);
4354 +               sockfd_put(sock);
4355 +       }
4356 +       unlock_kernel();
4357 +
4358 +out_freectl:
4359 +       /* N.B. Use kfree here, as kern_msg.msg_controllen might change? */
4360 +       if(ctl_buf != ctl)
4361 +               kfree(ctl_buf);
4362 +out_freeiov:
4363 +       if(kern_msg.msg_iov != iov)
4364 +               kfree(kern_msg.msg_iov);
4365 +out:
4366 +       return err;
4367 +}
4368 +
4369 +int solaris_recvmsg(int fd, struct sol_nmsghdr *user_msg, unsigned user_flags)
4370 +{
4371 +       struct iovec iovstack[UIO_FASTIOV];
4372 +       struct msghdr kern_msg;
4373 +       char addr[MAX_SOCK_ADDR];
4374 +       struct socket *sock;
4375 +       struct iovec *iov = iovstack;
4376 +       struct sockaddr *uaddr;
4377 +       int *uaddr_len;
4378 +       unsigned long cmsg_ptr;
4379 +       int err, total_len, len = 0;
4380 +
4381 +       if(msghdr_from_user32_to_kern(&kern_msg, user_msg))
4382 +               return -EFAULT;
4383 +       if(kern_msg.msg_iovlen > UIO_MAXIOV)
4384 +               return -EINVAL;
4385 +
4386 +       uaddr = kern_msg.msg_name;
4387 +       uaddr_len = &user_msg->msg_namelen;
4388 +       err = verify_iovec32(&kern_msg, iov, addr, VERIFY_WRITE);
4389 +       if (err < 0)
4390 +               goto out;
4391 +       total_len = err;
4392 +
4393 +       cmsg_ptr = (unsigned long) kern_msg.msg_control;
4394 +       kern_msg.msg_flags = 0;
4395 +
4396 +       lock_kernel();
4397 +       sock = sockfd_lookup(fd, &err);
4398 +       if (sock != NULL) {
4399 +               if (sock->file->f_flags & O_NONBLOCK)
4400 +                       user_flags |= MSG_DONTWAIT;
4401 +               err = sock_recvmsg(sock, &kern_msg, total_len, user_flags);
4402 +               if(err >= 0)
4403 +                       len = err;
4404 +               sockfd_put(sock);
4405 +       }
4406 +       unlock_kernel();
4407 +
4408 +       if(uaddr != NULL && err >= 0)
4409 +               err = move_addr_to_user(addr, kern_msg.msg_namelen, uaddr, uaddr_len);
4410 +       if(err >= 0) {
4411 +               err = __put_user(linux_to_solaris_msgflags(kern_msg.msg_flags), &user_msg->msg_flags);
4412 +               if(!err) {
4413 +                       /* XXX Convert cmsg back into userspace 32-bit format... */
4414 +                       err = __put_user((unsigned long)kern_msg.msg_control - cmsg_ptr,
4415 +                                        &user_msg->msg_controllen);
4416 +               }
4417 +       }
4418 +
4419 +       if(kern_msg.msg_iov != iov)
4420 +               kfree(kern_msg.msg_iov);
4421 +out:
4422 +       if(err < 0)
4423 +               return err;
4424 +       return len;
4425 +}
4426 diff -Nur kernel-source-2.6.16.orig/abi/solaris/solarisx86.c kernel-source-2.6.16/abi/solaris/solarisx86.c
4427 --- kernel-source-2.6.16.orig/abi/solaris/solarisx86.c  1970-01-01 10:00:00.000000000 +1000
4428 +++ kernel-source-2.6.16/abi/solaris/solarisx86.c       2006-04-27 18:50:24.000000000 +1000
4429 @@ -0,0 +1,84 @@
4430 +
4431 +#include <linux/types.h>
4432 +#include <linux/kernel.h>
4433 +#include <linux/sched.h>
4434 +#include <linux/socket.h>
4435 +#include <linux/file.h>
4436 +#include <linux/mm.h>
4437 +#include <linux/syscalls.h>
4438 +#include <asm/uaccess.h>
4439 +
4440 +#include <abi/svr4/sigset.h>
4441 +
4442 +
4443 +int sol_llseek(struct pt_regs * regs)
4444 +{
4445 +       unsigned int fd;
4446 +       unsigned long offset_high, offset_low;
4447 +       unsigned origin;
4448 +       long long res;
4449 +       unsigned int rvalue;
4450 +       mm_segment_t old_fs;
4451 +       struct inode *inode;
4452 +       struct file *file;
4453 +       get_user(fd, ((unsigned int *)regs->esp)+1);
4454 +       get_user(offset_low, ((unsigned long *)regs->esp)+2);
4455 +       get_user(offset_high, ((unsigned long *)regs->esp)+3);
4456 +       get_user(origin, ((unsigned int *)regs->esp)+4);
4457 +
4458 +       old_fs = get_fs();
4459 +       set_fs(get_ds());
4460 +       rvalue = sys_llseek(fd,offset_high,offset_low,&res,origin);
4461 +       set_fs(old_fs);
4462 +
4463 +       if ( rvalue < -ENOIOCTLCMD) {
4464 +               regs->edx = (res >> 32);
4465 +               rvalue = (res & 0xffffffff);
4466 +       }
4467 +       else if (rvalue == -ESPIPE) {
4468 +               /* Solaris allows you to seek on a pipe */
4469 +               file = fget(fd);
4470 +               if (file) {
4471 +                       inode = file->f_dentry->d_inode;
4472 +                       if (inode && (S_ISCHR(inode->i_mode)
4473 +                                     || S_ISBLK(inode->i_mode))) {
4474 +                               rvalue = 0;
4475 +                               regs->edx = 0;
4476 +                       }
4477 +                       fput(file);
4478 +               }
4479 +       }
4480 +
4481 +       return rvalue;
4482 +}
4483 +
4484 +int sol_memcntl(unsigned addr, unsigned len, int cmd, unsigned arg,
4485 +                int attr, int mask)
4486 +{
4487 +       //      printk("ibcs_memcntl being ignored\n");
4488 +       return 0;
4489 +}
4490 +
4491 +
4492 +enum {
4493 +       GETACL = 1,
4494 +       SETACL = 2,
4495 +       GETACLCNT = 3
4496 +};
4497 +
4498 +int sol_acl(char *pathp, int cmd, int nentries, void *aclbufp)
4499 +{
4500 +       switch (cmd) {
4501 +       case GETACLCNT:
4502 +               return 0;
4503 +
4504 +       case GETACL:
4505 +               return -EIO;
4506 +
4507 +       case SETACL:
4508 +               return -EPERM;
4509 +
4510 +       default:
4511 +               return -EINVAL;
4512 +       }
4513 +}
4514 diff -Nur kernel-source-2.6.16.orig/abi/solaris/stat.c kernel-source-2.6.16/abi/solaris/stat.c
4515 --- kernel-source-2.6.16.orig/abi/solaris/stat.c        1970-01-01 10:00:00.000000000 +1000
4516 +++ kernel-source-2.6.16/abi/solaris/stat.c     2006-04-27 18:50:24.000000000 +1000
4517 @@ -0,0 +1,104 @@
4518 +/*
4519 + * Copyright (c) 2001 Christoph Hellwig.
4520 + * All rights reserved.
4521 + *
4522 + * This program is free software; you can redistribute it and/or modify
4523 + * it under the terms of the GNU General Public License as published by
4524 + * the Free Software Foundation; either version 2 of the License, or
4525 + * (at your option) any later version.
4526 + *
4527 + * This program is distributed in the hope that it will be useful,
4528 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4529 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4530 + * GNU General Public License for more details.
4531 + *
4532 + * You should have received a copy of the GNU General Public License
4533 + * aint32_t with this program; if not, write to the Free Software
4534 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4535 + */
4536 +
4537 +#ident "%W% %G%"
4538 +
4539 +/*
4540 + * Solaris 2 stat64 & friends support.
4541 + */
4542 +#include <linux/kernel.h>
4543 +#include <linux/fs.h>
4544 +#include <linux/sched.h>
4545 +#include <linux/file.h>
4546 +#include <linux/string.h>
4547 +#include <asm/uaccess.h>
4548 +
4549 +#include <abi/solaris/types.h>
4550 +#include <abi/solaris/stat.h>
4551 +
4552 +#include <abi/util/trace.h>
4553 +#include <abi/util/stat.h>
4554 +
4555 +
4556 +int
4557 +report_sol_stat64(struct kstat *stp, struct sol_stat64 *bufp)
4558 +{
4559 +       struct sol_stat64 buf;
4560 +
4561 +       memset(&buf, 0, sizeof(struct sol_stat64));
4562 +
4563 +
4564 +       buf.st_dev      = linux_to_sol_dev_t(stp->dev);
4565 +       buf.st_ino      = linux_to_sol_ino_t(stp->ino);
4566 +       buf.st_mode     = stp->mode;
4567 +       buf.st_nlink    = stp->nlink;
4568 +       buf.st_uid      = linux_to_sol_uid_t(stp->uid);
4569 +       buf.st_gid      = linux_to_sol_gid_t(stp->gid);
4570 +       buf.st_rdev     = linux_to_sol_dev_t(stp->rdev);
4571 +       buf.st_size     = stp->size;
4572 +
4573 +       buf.st_atime    = stp->atime.tv_sec;
4574 +       buf.st_mtime    = stp->mtime.tv_sec;
4575 +       buf.st_ctime    = stp->ctime.tv_sec;
4576 +
4577 +       buf.st_blksize  = stp->blksize;
4578 +       buf.st_blocks   = stp->blocks;
4579 +
4580 +       strcpy(buf.st_fstype, "ext2");
4581 +
4582 +       if (copy_to_user(bufp, &buf, sizeof(struct sol_stat64)))
4583 +               return -EFAULT;
4584 +       return 0;
4585 +}
4586 +
4587 +int
4588 +sol_stat64(char *filename, struct sol_stat64 *bufp)
4589 +{
4590 +       struct kstat st;
4591 +       int error;
4592 +
4593 +       error = vfs_stat(filename, &st);
4594 +       if (!error)
4595 +               error = report_sol_stat64(&st, bufp);
4596 +       return error;
4597 +}
4598 +
4599 +int
4600 +sol_lstat64(char *filename, struct sol_stat64 *bufp)
4601 +{
4602 +       struct kstat st;
4603 +       int error;
4604 +
4605 +       error = vfs_lstat(filename, &st);
4606 +       if (!error)
4607 +               error = report_sol_stat64(&st, bufp);
4608 +       return error;
4609 +}
4610 +
4611 +int
4612 +sol_fstat64(int fd, struct sol_stat64 *bufp)
4613 +{
4614 +       struct kstat st;
4615 +       int error;
4616 +
4617 +       error = vfs_fstat(fd, &st);
4618 +       if (!error)
4619 +               error = report_sol_stat64(&st, bufp);
4620 +       return error;
4621 +}
4622 diff -Nur kernel-source-2.6.16.orig/abi/solaris/sysent.c kernel-source-2.6.16/abi/solaris/sysent.c
4623 --- kernel-source-2.6.16.orig/abi/solaris/sysent.c      1970-01-01 10:00:00.000000000 +1000
4624 +++ kernel-source-2.6.16/abi/solaris/sysent.c   2006-04-27 18:50:24.000000000 +1000
4625 @@ -0,0 +1,461 @@
4626 +/*
4627 + * Copyright (c) 2001 Christoph Hellwig.
4628 + * All rights reserved.
4629 + *
4630 + * This program is free software; you can redistribute it and/or modify
4631 + * it under the terms of the GNU General Public License as published by
4632 + * the Free Software Foundation; either version 2 of the License, or
4633 + * (at your option) any later version.
4634 + *
4635 + * This program is distributed in the hope that it will be useful,
4636 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4637 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4638 + * GNU General Public License for more details.
4639 + *
4640 + * You should have received a copy of the GNU General Public License
4641 + * along with this program; if not, write to the Free Software
4642 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4643 + */
4644 +
4645 +#ident "%W% %G%"
4646 +
4647 +/*
4648 + * Solaris sysent and error tables.
4649 + */
4650 +#include <linux/config.h>
4651 +#include <linux/kernel.h>
4652 +#include <linux/module.h>
4653 +#include <linux/init.h>
4654 +#include <linux/personality.h>
4655 +#include <linux/syscalls.h>
4656 +#include <linux/socket.h>
4657 +#include <linux/net.h>
4658 +#include <asm/uaccess.h>
4659 +
4660 +#include <abi/signal.h>
4661 +
4662 +#include <abi/svr4/sysent.h>
4663 +#include <abi/solaris/sysent.h>
4664 +#include <abi/util/socket.h>
4665 +
4666 +#include <abi/util/errno.h>
4667 +#include <abi/util/sysent.h>
4668 +
4669 +/* kernel module specifications */
4670 +#ifndef EXPORT_NO_SYMBOLS
4671 +#define EXPORT_NO_SYMBOLS
4672 +#endif
4673 +
4674 +MODULE_DESCRIPTION("Solaris personality");
4675 +MODULE_AUTHOR("Christoph Hellwig, partially taken from iBCS");
4676 +MODULE_LICENSE("GPL");
4677 +
4678 +EXPORT_NO_SYMBOLS;
4679 +
4680 +
4681 +/* XXX kill this one */
4682 +#define ITR(trace, name, args)  ,name,args
4683 +
4684 +
4685 +/*
4686 + * We could remove some of the long identity mapped runs but at the
4687 + * expense of extra comparisons for each mapping at run time...
4688 + */
4689 +static u_char solaris_err_table[] = {
4690 +/*   0 -   9 */   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,
4691 +/*  10 -  19 */  10,  11,  12,  13,  14,  15,  16,  17,  18,  19,
4692 +/*  20 -  29 */  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
4693 +/*  30 -  39 */  30,  31,  32,  33,  34,  45,  78,  46,  89,  93,
4694 +/*  40 -  49 */  90,  90,  35,  36,  37,  38,  39,  40,  41,  42,
4695 +/*  50 -  59 */  43,  44,  50,  51,  52,  53,  54,  55,  56,  57,
4696 +/*  60 -  69 */  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,
4697 +/*  70 -  79 */  70,  71,  74,  76,  77,  79,  80,  81,  82,  83,
4698 +/*  80 -  89 */  84,  85,  86,  87,  88,  91,  92,  94,  95,  96,
4699 +/*  90 -  99 */  97,  98,  99, 120, 121, 122, 123, 124, 125, 126,
4700 +/* 100 - 109 */ 127, 128, 129, 130, 131, 132, 133, 134, 143, 144,
4701 +/* 110 - 119 */ 145, 146, 147, 148, 149, 150,  22, 135, 137, 138,
4702 +/* 120 - 122 */ 139, 140,  28
4703 +};
4704 +
4705 +/*
4706 + * Map Linux RESTART* values (512,513,514) to EINTR
4707 + */
4708 +static u_char lnx_err_table[] = {
4709 +/* 512 - 514 */ EINTR, EINTR, EINTR
4710 +};
4711 +
4712 +struct map_segment solaris_err_map[] = {
4713 +       { 0,    0+sizeof(solaris_err_table)-1,  solaris_err_table },
4714 +       { 512,  512+sizeof(lnx_err_table)-1,    lnx_err_table },
4715 +       { -1 }
4716 +};
4717 +
4718 +static long linux_to_solaris_signals[NSIGNALS+1] = {
4719 +/*  0 -  3 */  0,              IBCS_SIGHUP,    IBCS_SIGINT,    IBCS_SIGQUIT,
4720 +/*  4 -  7 */  IBCS_SIGILL,    IBCS_SIGTRAP,   IBCS_SIGABRT,   -1,
4721 +/*  8 - 11 */  IBCS_SIGFPE,    IBCS_SIGKILL,   IBCS_SIGUSR1,   IBCS_SIGSEGV,
4722 +/* 12 - 15 */  IBCS_SIGUSR2,   IBCS_SIGPIPE,   IBCS_SIGALRM,   IBCS_SIGTERM,
4723 +/* 16 - 19 */  IBCS_SIGSEGV,   IBCS_SIGCHLD,   IBCS_SIGCONT,   IBCS_SIGSTOP,
4724 +/* 20 - 23 */  IBCS_SIGTSTP,   IBCS_SIGTTIN,   IBCS_SIGTTOU,   IBCS_SIGURG,
4725 +/* 24 - 27 */  IBCS_SIGGXCPU,  IBCS_SIGGXFSZ,  IBCS_SIGVTALRM, IBCS_SIGPROF,
4726 +/* 28 - 31 */  IBCS_SIGWINCH,  IBCS_SIGIO,     IBCS_SIGPWR,    -1,
4727 +/*     32 */   -1
4728 +};
4729 +
4730 +static long solaris_to_linux_signals[NSIGNALS+1] = {
4731 +/*  0 -  3 */  0,              SIGHUP,         SIGINT,         SIGQUIT,
4732 +/*  4 -  7 */  SIGILL,         SIGTRAP,        SIGIOT,         SIGUNUSED,
4733 +/*  8 - 11 */  SIGFPE,         SIGKILL,        SIGUNUSED,      SIGSEGV,
4734 +/* 12 - 15 */  SIGUNUSED,      SIGPIPE,        SIGALRM,        SIGTERM,
4735 +/* 16 - 19 */  SIGUSR1,        SIGUSR2,        SIGCHLD,        SIGPWR,
4736 +/* 20 - 23 */  SIGWINCH,       SIGURG,         SIGPOLL,        SIGSTOP,
4737 +/* 24 - 27 */  SIGTSTP,        SIGCONT,        SIGTTIN,        SIGTTOU,
4738 +/* 28 - 31 */  SIGVTALRM,      SIGPROF,        SIGXCPU,        SIGXFSZ,
4739 +/*     32 */   -1
4740 +};
4741 +
4742 +static char solaris_socktype[] = {
4743 +       SOCK_STREAM,
4744 +       SOCK_DGRAM,
4745 +       0,
4746 +       SOCK_RAW,
4747 +       SOCK_RDM,
4748 +       SOCK_SEQPACKET
4749 +};
4750 +
4751 +static struct map_segment solaris_socktype_map[] = {
4752 +       { 1, 6, solaris_socktype },
4753 +       { -1 }
4754 +};
4755 +
4756 +static struct map_segment solaris_sockopt_map[] =  {
4757 +       { 0x0001, 0x0001, (char *)SO_DEBUG },
4758 +       { 0x0002, 0x0002, (char *)__SO_ACCEPTCON },
4759 +       { 0x0004, 0x0004, (char *)SO_REUSEADDR },
4760 +       { 0x0008, 0x0008, (char *)SO_KEEPALIVE },
4761 +       { 0x0010, 0x0010, (char *)SO_DONTROUTE },
4762 +       { 0x0020, 0x0020, (char *)SO_BROADCAST },
4763 +       { 0x0040, 0x0040, (char *)SO_USELOOPBACK },
4764 +       { 0x0080, 0x0080, (char *)SO_LINGER },
4765 +       { 0x0100, 0x0100, (char *)SO_OOBINLINE },
4766 +       { 0x0200, 0x0200, (char *)SO_ORDREL },
4767 +       { 0x0400, 0x0400, (char *)SO_IMASOCKET },
4768 +       { 0x1001, 0x1001, (char *)SO_SNDBUF },
4769 +       { 0x1002, 0x1002, (char *)SO_RCVBUF },
4770 +       { 0x1003, 0x1003, (char *)SO_SNDLOWAT },
4771 +       { 0x1004, 0x1004, (char *)SO_RCVLOWAT },
4772 +       { 0x1005, 0x1005, (char *)SO_SNDTIMEO },
4773 +       { 0x1006, 0x1006, (char *)SO_RCVTIMEO },
4774 +       { 0x1007, 0x1007, (char *)SO_ERROR },
4775 +       { 0x1008, 0x1008, (char *)SO_TYPE },
4776 +       { 0x1009, 0x1009, (char *)SO_PROTOTYPE },
4777 +       { -1 }
4778 +};
4779 +
4780 +static struct map_segment solaris_af_map[] =  {
4781 +       { 0, 2, NULL },
4782 +       { -1 }
4783 +};
4784 +
4785 +
4786 +static struct sysent solaris_syscall_table[] = {
4787 +   { abi_syscall,      Fast    ITR(0, "syscall",       "")     }, /*    0 */
4788 +   { sys_exit,         1       ITR(0, "exit",          "d")    }, /*    1 */
4789 +   { abi_fork,         Spl     ITR(0, "fork",          "")     }, /*    2 */
4790 +   { abi_read,         3       ITR(0, "read",          "dpd")  }, /*    3 */
4791 +   { sys_write,                3       ITR(0, "write",         "dpd")  }, /*    4 */
4792 +   { svr4_open,                3       ITR(0, "open",          "soo")  }, /*    5 */
4793 +   { sys_close,                1       ITR(0, "close",         "d")    }, /*    6 */
4794 +   { abi_wait,         Spl     ITR(0, "wait",          "xxx")  }, /*    7 */
4795 +   { sys_creat,                2       ITR(0, "creat",         "so")   }, /*    8 */
4796 +   { sys_link,         2       ITR(0, "link",          "ss")   }, /*    9 */
4797 +   { sys_unlink,       1       ITR(0, "unlink",        "s")    }, /*   10 */
4798 +   { abi_exec,         Spl     ITR(0, "exec",          "sxx")  }, /*   11 */
4799 +   { sys_chdir,                1       ITR(0, "chdir",         "s")    }, /*   12 */
4800 +   { abi_time,         0       ITR(0, "time",          "")     }, /*   13 */
4801 +   { svr4_mknod,       3       ITR(0, "mknod",         "soo")  }, /*   14 */
4802 +   { sys_chmod,                2       ITR(0, "chmod",         "so")   }, /*   15 */
4803 +   { sys_chown,                3       ITR(0, "chown",         "sdd")  }, /*   16 */
4804 +   { abi_brk,          1       ITR(0, "brk/break",     "x")    }, /*   17 */
4805 +   { svr4_stat,                2       ITR(0, "stat",          "sp")   }, /*   18 */
4806 +   { sys_lseek,                3       ITR(0, "seek/lseek",    "ddd")  }, /*   19 */
4807 +   { abi_getpid,       Spl     ITR(0, "getpid",        "")     }, /*   20 */
4808 +   { 0,                        Ukn     ITR(1, "mount",         "")     }, /*   21 */
4809 +   { sys_umount,       1       ITR(0, "umount",        "s")    }, /*   22 */
4810 +   { sys_setuid,       1       ITR(0, "setuid",        "d")    }, /*   23 */
4811 +   { abi_getuid,       Spl     ITR(0, "getuid",        "")     }, /*   24 */
4812 +   { sys_stime,                1       ITR(0, "stime",         "d")    }, /*   25 */
4813 +   { 0,                        Ukn     ITR(0, "ptrace",        "")     }, /*   26 */
4814 +   { sys_alarm,                1       ITR(0, "alarm",         "d")    }, /*   27 */
4815 +   { svr4_fstat,       2       ITR(0, "fstat",         "dp")   }, /*   28 */
4816 +   { sys_pause,                0       ITR(0, "pause",         "")     }, /*   29 */
4817 +   { sys_utime,                2       ITR(0, "utime",         "xx")   }, /*   30 */
4818 +   { 0,                        Ukn     ITR(0, "stty",          "")     }, /*   31 */
4819 +   { 0,                        Ukn     ITR(1, "gtty",          "")     }, /*   32 */
4820 +   { sys_access,       2       ITR(0, "access",        "so")   }, /*   33 */
4821 +   { sys_nice,         1       ITR(0, "nice",          "d")    }, /*   34 */
4822 +   { svr4_statfs,      4       ITR(0, "statfs",        "spdd") }, /*   35 */
4823 +   { sys_sync,         0       ITR(0, "sync",          "")     }, /*   36 */
4824 +   { abi_kill,         2       ITR(0, "kill",          "dd")   }, /*   37 */
4825 +   { svr4_fstatfs,     4       ITR(0, "fstatfs",       "dpdd") }, /*   38 */
4826 +   { abi_procids,      Spl     ITR(0, "procids",       "d")    }, /*   39 */
4827 +   { 0,                        Ukn     ITR(0, "cxenix",        "")     }, /*   40 */
4828 +   { sys_dup,          1       ITR(0, "dup",           "d")    }, /*   41 */
4829 +   { abi_pipe,         Spl     ITR(0, "pipe",          "")     }, /*   42 */
4830 +   { sys_times,                1       ITR(0, "times",         "p")    }, /*   43 */
4831 +   { 0,                        0       ITR(0, "prof",          "")     }, /*   44 */
4832 +   { 0,                        Ukn     ITR(1, "lock/plock",    "")     }, /*   45 */
4833 +   { sys_setgid,       1       ITR(0, "setgid",        "d")    }, /*   46 */
4834 +   { abi_getgid,       Spl     ITR(0, "getgid",        "")     }, /*   47 */
4835 +   { abi_sigfunc,      Fast    ITR(0, "sigfunc",       "xxx")  }, /*   48 */
4836 +   { svr4_msgsys,      Spl     ITR(0, "msgsys",        "dxddd")}, /*   49 */
4837 +   { svr4_sysi86,      3       ITR(0, "sysi86/sys3b",  "d")    }, /*   50 */
4838 +   { sys_acct,         1       ITR(0, "acct/sysacct",  "x")    }, /*   51 */
4839 +   { svr4_shmsys,      Fast    ITR(0, "shmsys",        "ddxo")}, /*   52 */
4840 +   { svr4_semsys,      Spl     ITR(0, "semsys",        "dddx")}, /*   53 */
4841 +   { svr4_ioctl,       Spl     ITR(0, "ioctl",         "dxx")  }, /*   54 */
4842 +   { 0,                        3       ITR(0, "uadmin",        "xxx")  }, /*   55 */
4843 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   56 */
4844 +   { v7_utsname,       1       ITR(0, "utsys",         "x")    }, /*   57 */
4845 +   { sys_fsync,                1       ITR(0, "fsync",         "d")    }, /*   58 */
4846 +   { abi_exec,         Spl     ITR(0, "execv",         "spp")  }, /*   59 */
4847 +   { sys_umask,                1       ITR(0, "umask",         "o")    }, /*   60 */
4848 +   { sys_chroot,       1       ITR(0, "chroot",        "s")    }, /*   61 */
4849 +   { svr4_fcntl,       3       ITR(0, "fcntl",         "dxx")  }, /*   62 */
4850 +   { svr4_ulimit,      2       ITR(0, "ulimit",        "xx")   }, /*   63 */
4851 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   64 */
4852 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   65 */
4853 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   66 */
4854 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   67 */
4855 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   68 */
4856 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   69 */
4857 +   { 0,                        Ukn     ITR(1, "advfs",         "")     }, /*   70 */
4858 +   { 0,                        Ukn     ITR(1, "unadvfs",       "")     }, /*   71 */
4859 +   { 0,                        Ukn     ITR(1, "rmount",        "")     }, /*   72 */
4860 +   { 0,                        Ukn     ITR(1, "rumount",       "")     }, /*   73 */
4861 +   { 0,                        Ukn     ITR(1, "rfstart",       "")     }, /*   74 */
4862 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   75 */
4863 +   { 0,                        Ukn     ITR(1, "rdebug",        "")     }, /*   76 */
4864 +   { 0,                        Ukn     ITR(1, "rfstop",        "")     }, /*   77 */
4865 +   { 0,                        Ukn     ITR(1, "rfsys",         "")     }, /*   78 */
4866 +   { sys_rmdir,                1       ITR(0, "rmdir",         "s")    }, /*   79 */
4867 +   { abi_mkdir,                2       ITR(0, "mkdir",         "so")   }, /*   80 */
4868 +   { svr4_getdents,    3       ITR(0, "getdents",      "dxd")  }, /*   81 */
4869 +   { 0,                        Ukn     ITR(1, "libattach",     "")     }, /*   82 */
4870 +   { 0,                        Ukn     ITR(1, "libdetach",     "")     }, /*   83 */
4871 +   { svr4_sysfs,       3       ITR(0, "sysfs",         "dxx")  }, /*   84 */
4872 +   { svr4_getmsg,      Spl     ITR(0, "getmsg",        "dxxx") }, /*   85 */
4873 +   { svr4_putmsg,      Spl     ITR(0, "putmsg",        "dxxd") }, /*   86 */
4874 +   { sys_poll,         3       ITR(0, "poll",          "xdd")  }, /*   87 */
4875 +   { svr4_lstat,       2       ITR(0, "lstat",         "sp")   }, /*   88 */
4876 +   { sys_symlink,      2       ITR(0, "symlink",       "ss")   }, /*   89 */
4877 +   { sys_readlink,     3       ITR(0, "readlink",      "spd")  }, /*   90 */
4878 +   { sys_setgroups,    2       ITR(0, "setgroups",     "dp")   }, /*   91 */
4879 +   { sys_getgroups,    2       ITR(0, "getgroups",     "dp")   }, /*   92 */
4880 +   { sys_fchmod,       2       ITR(0, "fchmod",        "do")   }, /*   93 */
4881 +   { sys_fchown,       3       ITR(0, "fchown",        "ddd")  }, /*   94 */
4882 +   { abi_sigprocmask,  3       ITR(0, "sigprocmask",   "dxx")  }, /*   95 */
4883 +   { abi_sigsuspend,   Spl     ITR(0, "sigsuspend",    "x")    }, /*   96 */
4884 +   { 0,                        2       ITR(1, "sigaltstack",   "xx")   }, /*   97 */
4885 +   { abi_sigaction,    3       ITR(0, "sigaction",     "dxx")  }, /*   98 */
4886 +   { svr4_sigpending,  2       ITR(1, "sigpending",    "dp")   }, /*   99 */
4887 +   { svr4_context,     Spl     ITR(0, "context",       "")     }, /*   100 */
4888 +   { 0,                        Ukn     ITR(1, "evsys",         "")     }, /*   101 */
4889 +   { 0,                        Ukn     ITR(1, "evtrapret",     "")     }, /*   102 */
4890 +   { svr4_statvfs,     2       ITR(0, "statvfs",       "sp")   }, /*   103 */
4891 +   { svr4_fstatvfs,    2       ITR(0, "fstatvfs",      "dp")   }, /*   104 */
4892 +   { 0,                        Ukn     ITR(0, "sysisc",        "")     }, /*   105 */
4893 +   { 0,                        Ukn     ITR(1, "nfssys",        "")     }, /*   106 */
4894 +   { 0,                        4       ITR(0, "waitid",        "ddxd") }, /*   107 */
4895 +   { 0,                        3       ITR(1, "sigsendsys",    "ddd")  }, /*   108 */
4896 +   { svr4_hrtsys,      Spl     ITR(0, "hrtsys",        "xxx")  }, /*   109 */
4897 +   { 0,                        3       ITR(1, "acancel",       "dxd")  }, /*   110 */
4898 +   { 0,                        Ukn     ITR(1, "async",         "")     }, /*   111 */
4899 +   { 0,                        Ukn     ITR(1, "priocntlsys",   "")     }, /*   112 */
4900 +   { svr4_pathconf,    2       ITR(1, "pathconf",      "sd")   }, /*   113 */
4901 +   { 0,                        3       ITR(1, "mincore",       "xdx")  }, /*   114 */
4902 +   { svr4_mmap,                6       ITR(0, "mmap",          "xxxxdx") },/*   115 */
4903 +   { sys_mprotect,     3       ITR(0, "mprotect",      "xdx")  },/*   116 */
4904 +   { sys_munmap,       2       ITR(0, "munmap",        "xd")   },/*   117 */
4905 +   { svr4_fpathconf,   2       ITR(1, "fpathconf",     "dd")   }, /*   118 */
4906 +   { abi_fork,         Spl     ITR(0, "vfork",         "")     }, /*   119 */
4907 +   { sys_fchdir,       1       ITR(0, "fchdir",        "d")    }, /*   120 */
4908 +   { sys_readv,                3       ITR(0, "readv",         "dxd")  }, /*   121 */
4909 +   { sys_writev,       3       ITR(0, "writev",        "dxd")  }, /*   122 */
4910 +   { svr4_xstat,       3       ITR(0, "xstat",         "dsx")  }, /*   123 */
4911 +   { svr4_lxstat,      3       ITR(0, "lxstat",        "dsx")  }, /*   124 */
4912 +   { svr4_fxstat,      3       ITR(0, "fxstat",        "ddx")  }, /*   125 */
4913 +   { svr4_xmknod,      4       ITR(0, "xmknod",        "dsox")}, /*   126 */
4914 +   { 0,                        Spl     ITR(0, "syslocal",      "d")    }, /*   127 */
4915 +   { svr4_getrlimit,   2       ITR(0, "setrlimit",     "dx")   }, /*   128 */
4916 +   { svr4_setrlimit,   2       ITR(0, "getrlimit",     "dx")   }, /*   129 */
4917 +   { 0,                        3       ITR(1, "lchown",        "sdd")  }, /*   130 */
4918 +   { 0,                        Ukn     ITR(1, "memcntl",       "")     }, /*   131 */
4919 +#ifdef CONFIG_ABI_XTI
4920 +   { svr4_getpmsg,     5       ITR(0, "getpmsg",       "dxxxx")}, /*   132 */
4921 +   { svr4_putpmsg,     5       ITR(0, "putpmsg",       "dxxdd")}, /*   133 */
4922 +#else
4923 +   { 0,                        5       ITR(0, "getpmsg",       "dxxxx")}, /*   132 */
4924 +   { 0,                        5       ITR(0, "putpmsg",       "dxxdd")}, /*   133 */
4925 +#endif
4926 +   { sys_rename,       2       ITR(0, "rename",        "ss")   }, /*   134 */
4927 +   { abi_utsname,      1       ITR(0, "uname",         "x")    }, /*   135 */
4928 +   { svr4_setegid,     1       ITR(1, "setegid",       "d")    }, /*   136 */
4929 +   { svr4_sysconfig,   1       ITR(0, "sysconfig",     "d")    }, /*   137 */
4930 +   { 0,                        Ukn     ITR(1, "adjtime",       "")     }, /*   138 */
4931 +   { svr4_sysinfo,     3       ITR(0, "systeminfo",    "dsd")  }, /*   139 */
4932 +   { socksys_syscall,  1       ITR(0, "socksys_syscall","x")   }, /*   140 */
4933 +   { svr4_seteuid,     1       ITR(1, "seteuid",       "d")    }, /*   141 */
4934 +   { 0,                        Ukn     ITR(1, "vtrace",        "")     }, /*   142 */
4935 +   { 0,                        Ukn     ITR(1, "fork1",         "")     }, /*   143 */
4936 +   { 0,                        Ukn     ITR(1, "sigtimedwait",  "")     }, /*   144 */
4937 +   { 0,                        Ukn     ITR(1, "lwp_info",      "")     }, /*   145 */
4938 +   { 0,                        Ukn     ITR(1, "yield",         "")     }, /*   146 */
4939 +   { 0,                        Ukn     ITR(1, "lwp_sema_wait", "")     }, /*   147 */
4940 +   { 0,                        Ukn     ITR(1, "lwp_sema_post", "")     }, /*   148 */
4941 +   { 0,                        Ukn     ITR(1, "lwp_sema_trywait","")   }, /*   149 */
4942 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   150 */
4943 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   151 */
4944 +   { 0,                        Ukn     ITR(1, "modctl",        "")     }, /*   152 */
4945 +   { 0,                        Ukn     ITR(1, "fchroot",       "")     }, /*   153 */
4946 +   { 0,                        Ukn     ITR(1, "utimes",        "")     }, /*   154 */
4947 +   { 0,                        Ukn     ITR(1, "vhangup",       "")     }, /*   155 */
4948 +   { sys_gettimeofday, 2       ITR(0, "gettimeofday",  "xx")   }, /*   156 */
4949 +   { sys_getitimer,    2       ITR(0, "getitimer",     "dx")   }, /*   157 */
4950 +   { sys_setitimer,    3       ITR(0, "setitimer",     "dxx")  }, /*   158 */
4951 +   { 0,                        Ukn     ITR(1, "lwp_create",    "")     }, /*   159 */
4952 +   { 0,                        Ukn     ITR(1, "lwp_exit",      "")     }, /*   160 */
4953 +   { 0,                        Ukn     ITR(1, "lwp_suspend",   "")     }, /*   161 */
4954 +   { 0,                        Ukn     ITR(1, "lwp_continue",  "")     }, /*   162 */
4955 +   { 0,                        Ukn     ITR(1, "lwp_kill",      "")     }, /*   163 */
4956 +   { 0,                        Ukn     ITR(1, "lwp_self",      "")     }, /*   164 */
4957 +   { 0,                        Ukn     ITR(1, "lwp_setprivate","")     }, /*   165 */
4958 +   { 0,                        Ukn     ITR(1, "lwp_getprivate","")     }, /*   166 */
4959 +   { 0,                        Ukn     ITR(1, "lwp_wait",      "")     }, /*   167 */
4960 +   { 0,                        Ukn     ITR(1, "lwp_mutex_unlock","")   }, /*   168 */
4961 +   { 0,                        Ukn     ITR(1, "lwp_mutex_lock","")     }, /*   169 */
4962 +   { 0,                        Ukn     ITR(1, "lwp_cond_wait", "")     }, /*   170 */
4963 +   { 0,                        Ukn     ITR(1, "lwp_cond_signal","")    }, /*   171 */
4964 +   { 0,                        Ukn     ITR(1, "lwp_cond_broadcast","") }, /*   172 */
4965 +   { sys_pread64,      -4      ITR(1, "pread",         "dpdd") }, /*   173 */
4966 +   { sys_pwrite64,     -4      ITR(1, "pwrite",        "dpdd") }, /*   174 */
4967 +   { sol_llseek,       Spl     ITR(1, "llseek",        "dxxd") }, /*   175 */
4968 +   { 0,                        Ukn     ITR(1, "inst_sync",     "")     }, /*   176 */
4969 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   177 */
4970 +   { 0,                        Ukn     ITR(1, "kaio",          "")     }, /*   178 */
4971 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   179 */
4972 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   180 */
4973 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   181 */
4974 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   182 */
4975 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /*   183 */
4976 +   { 0,                        Ukn     ITR(1, "tsolsys",       "")     }, /*   184 */
4977 +   { sol_acl,          4       ITR(1, "acl",           "sddp") }, /*   185 */
4978 +   { 0,                        Ukn     ITR(1, "auditsys",      "")     }, /*   186 */
4979 +   { 0,                        Ukn     ITR(1, "processor_bind","")     }, /*   187 */
4980 +   { 0,                        Ukn     ITR(1, "processor_info","")     }, /*   188 */
4981 +   { 0,                        Ukn     ITR(1, "p_online",      "")     }, /*   189 */
4982 +   { 0,                        Ukn     ITR(1, "sigqueue",      "")     }, /*   190 */
4983 +   { 0,                        Ukn     ITR(1, "clock_gettime", "")     }, /*   191 */
4984 +   { 0,                        Ukn     ITR(1, "clock_settime", "")     }, /*   192 */
4985 +   { 0,                        Ukn     ITR(1, "clock_getres",  "")     }, /*   193 */
4986 +   { 0,                        Ukn     ITR(1, "timer_create",  "")     }, /*   194 */
4987 +   { 0,                        Ukn     ITR(1, "timer_delete",  "")     }, /*   195 */
4988 +   { 0,                        Ukn     ITR(1, "timer_settime", "")     }, /*   196 */
4989 +   { 0,                        Ukn     ITR(1, "timer_gettime", "")     }, /*   197 */
4990 +   { 0,                        Ukn     ITR(1, "timer_getoverrun","")   }, /*   198 */
4991 +   { sys_nanosleep,    2       ITR(1, "nanosleep",     "pp")   }, /*   199 */
4992 +   { 0,                        Ukn     ITR(1, "modstat",       "")     }, /*   200 */
4993 +   { 0,                        Ukn     ITR(1, "facl",          "")     }, /*   201 */
4994 +   { sys_setreuid,     2       ITR(1, "setreuid",      "dd")   }, /*   202 */
4995 +   { sys_setregid,     2       ITR(1, "setregid",      "dd")   }, /*   203 */
4996 +   { 0,                        Ukn     ITR(1, "install_utrap", "")     }, /*   204 */
4997 +   { 0,                        Ukn     ITR(1, "signotify",     "")     }, /*   205 */
4998 +   { 0,                        Ukn     ITR(1, "schedctl",      "")     }, /*   206 */
4999 +   { 0,                        Ukn     ITR(1, "pset",          "")     }, /*   207 */
5000 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /* 208 */
5001 +   { 0,                        Ukn     ITR(1, "resolvepath",   "")     }, /* 209 */
5002 +   { 0,                        Ukn     ITR(1, "signotifywait", "")     }, /* 210 */
5003 +   { 0,                        Ukn     ITR(1, "lwp_sigredirect","")    }, /* 211 */
5004 +   { 0,                        Ukn     ITR(1, "lwp_alarm",     "")     }, /* 212 */
5005 +   { sol_getdents64,   3       ITR(0, "getdents64",    "dxd")  }, /* 213 */
5006 +   { sol_mmap64,       7       ITR(1, "mmap64",      "pxdddxx")}, /*214 */
5007 +   { sol_stat64,       2       ITR(0, "stat64",        "sp")   }, /* 215 */
5008 +   { sol_lstat64,      2       ITR(0, "lstat64",       "sp")   }, /* 216 */
5009 +   { sol_fstat64,      2       ITR(0, "fstat64",       "dp")   }, /* 217 */
5010 +   { 0,                        Ukn     ITR(1, "statvfs64",     "")     }, /* 218 */
5011 +   { 0,                        Ukn     ITR(1, "fstatvfs64",    "")     }, /* 219 */
5012 +   { 0,                        Ukn     ITR(1, "setrlimit64",   "")     }, /* 220 */
5013 +   { 0,                        Ukn     ITR(1, "getrlimit64",   "")     }, /* 221 */
5014 +   { 0,                        Ukn     ITR(1, "pread64",       "")     }, /* 222 */
5015 +   { 0,                        Ukn     ITR(1, "pwrite64",      "")     }, /* 223 */
5016 +   { 0,                        Ukn     ITR(1, "creat64",       "")     }, /* 224 */
5017 +   { sol_open64,       3       ITR(0, "open64",        "soo")  }, /* 225 */
5018 +   { 0,                        Ukn     ITR(1, "rpcsys",        "")     }, /* 226 */
5019 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /* 227 */
5020 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /* 228 */
5021 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /* 229 */
5022 +   { solaris_socket,   3       ITR(1, "so_socket",     "ddd")  }, /* 230 */
5023 +   { solaris_socketpair,1      ITR(1, "so_socketpair", "dddx") }, /* 231 */
5024 +   { solaris_bind,     3       ITR(1, "bind",          "dxd")  }, /* 232 */
5025 +   { solaris_listen,   2       ITR(1, "listen",        "dd")   }, /* 233 */
5026 +   { solaris_accept,   3       ITR(1, "accept",        "dxx")  }, /* 234 */
5027 +   { solaris_connect,  3       ITR(1, "connect",       "dxd")  }, /* 235 */
5028 +   { solaris_shutdown, 2       ITR(1, "shutdown",      "dd")   }, /* 236 */
5029 +   { solaris_recv,     4       ITR(1, "recv",          "dxdd") }, /* 237 */
5030 +   { solaris_recvfrom, 6       ITR(1, "recvfrom",     "dxddxd")}, /* 238 */
5031 +   { solaris_recvmsg,  3       ITR(1, "recvmsg",       "dxd")  }, /* 239 */
5032 +   { solaris_send,     4       ITR(1, "send",          "dxdd") }, /* 240 */
5033 +   { solaris_sendmsg,          3       ITR(0, "sendmsg",       "dxd")  }, /* 241 */
5034 +   { solaris_sendto,   6       ITR(1, "sendto",       "dxddxd")}, /* 242 */
5035 +   { solaris_getpeername,3     ITR(1, "getpeername",   "dxx")  }, /* 243 */
5036 +   { solaris_getsockname,3     ITR(1, "getsockname",   "dxx")  }, /* 244 */
5037 +   { solaris_getsockopt,5      ITR(1, "getsockopt",    "dddxx")}, /* 245 */
5038 +   { solaris_setsockopt,5      ITR(1, "setsockopt",    "dddxd")}, /* 246 */
5039 +   { 0,                        Ukn     ITR(1, "sockconfig",    "")     }, /* 247 */
5040 +   { 0,                        Ukn     ITR(1, "ntp_gettime",   "")     }, /* 248 */
5041 +   { 0,                Ukn     ITR(0, "ntp_adjtime",   "")     }, /* 249 */
5042 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /* 250 */
5043 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /* 251 */
5044 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /* 252 */
5045 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /* 253 */
5046 +   { 0,                        Ukn     ITR(1, "?",             "")     }, /* 254 */
5047 +   { 0,                        Ukn     ITR(1, "?",             "")     }  /* 255 */
5048 +};
5049 +
5050 +static void solaris_lcall7(int segment, struct pt_regs * regs)
5051 +{
5052 +       int sysno = regs->eax & 0xff;
5053 +
5054 +       if (sysno >= ARRAY_SIZE(solaris_syscall_table))
5055 +               set_error(regs, iABI_errors(-EINVAL));
5056 +       else
5057 +               lcall7_dispatch(regs, &solaris_syscall_table[sysno], 1);
5058 +}
5059 +
5060 +static struct exec_domain solaris_exec_domain = {
5061 +       name:           "Solaris",
5062 +       handler:        solaris_lcall7,
5063 +       pers_low:       13 /* PER_SOLARIS */,
5064 +       pers_high:      13 /* PER_SOLARIS */,
5065 +       signal_map:     solaris_to_linux_signals,
5066 +       signal_invmap:  linux_to_solaris_signals,
5067 +       err_map:        solaris_err_map,
5068 +       socktype_map:   solaris_socktype_map,
5069 +       sockopt_map:    solaris_sockopt_map,
5070 +       af_map:         solaris_af_map,
5071 +       module:         THIS_MODULE,
5072 +};
5073 +
5074 +
5075 +static void __exit solaris_cleanup(void)
5076 +{
5077 +       unregister_exec_domain(&solaris_exec_domain);
5078 +}
5079 +
5080 +static int __init solaris_init(void)
5081 +{
5082 +       return register_exec_domain(&solaris_exec_domain);
5083 +}
5084 +
5085 +module_init(solaris_init);
5086 +module_exit(solaris_cleanup);
5087 diff -Nur kernel-source-2.6.16.orig/abi/svr4/consio.c kernel-source-2.6.16/abi/svr4/consio.c
5088 --- kernel-source-2.6.16.orig/abi/svr4/consio.c 1970-01-01 10:00:00.000000000 +1000
5089 +++ kernel-source-2.6.16/abi/svr4/consio.c      2006-04-27 18:50:24.000000000 +1000
5090 @@ -0,0 +1,53 @@
5091 +#ident "%W% %G%"
5092 +
5093 +#include <linux/errno.h>
5094 +#include <linux/kernel.h>
5095 +#include <linux/types.h>
5096 +#include <linux/module.h>
5097 +
5098 +
5099 +int
5100 +svr4_console_ioctl(int fd, u_int cmd, caddr_t data)
5101 +{
5102 +       switch (cmd) {
5103 +       case 0x6301: /* CONS_CURRENT: Get display adapter type */
5104 +       case 0x6302: /* CONS_GET: Get display mode setting */
5105 +               /*
5106 +                * Always error so the application never tries
5107 +                * anything overly fancy on the console.
5108 +                */
5109 +               return -EINVAL;
5110 +       case 0x4304: /* _TTYDEVTYPE */
5111 +               /* If on console then 1, if pseudo tty then 2 */
5112 +               return 2;
5113 +       }
5114 +
5115 +       printk(KERN_ERR "iBCS: console ioctl %d unsupported\n", cmd);
5116 +       return -EINVAL;
5117 +}
5118 +
5119 +int
5120 +svr4_video_ioctl(int fd, u_int cmd, caddr_t data)
5121 +{
5122 +       switch (cmd) {
5123 +       case 1: /* MAP_CLASS */
5124 +               /* Get video memory map & IO privilege */
5125 +                break;
5126 +
5127 +       /* This doesn't agree with my SCO 3.2.4 ???? */
5128 +       case 4: /* C_IOC */
5129 +               /* see /etc/conf/pack.d/cn/class.h on any SCO unix box :-) */
5130 +                break;
5131 +
5132 +        default:
5133 +                break;
5134 +       }
5135 +
5136 +       printk(KERN_ERR "iBCS: video ioctl %d unsupported\n", cmd);
5137 +       return -EINVAL;
5138 +}
5139 +
5140 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
5141 +EXPORT_SYMBOL(svr4_console_ioctl);
5142 +EXPORT_SYMBOL(svr4_video_ioctl);
5143 +#endif
5144 diff -Nur kernel-source-2.6.16.orig/abi/svr4/fcntl.c kernel-source-2.6.16/abi/svr4/fcntl.c
5145 --- kernel-source-2.6.16.orig/abi/svr4/fcntl.c  1970-01-01 10:00:00.000000000 +1000
5146 +++ kernel-source-2.6.16/abi/svr4/fcntl.c       2006-04-27 18:50:24.000000000 +1000
5147 @@ -0,0 +1,195 @@
5148 +/*
5149 + * Copyright (c) 2002 Caldera Deutschland GmbH.
5150 + * All rights reserved.
5151 + *
5152 + * This program is free software; you can redistribute it and/or modify
5153 + * it under the terms of the GNU General Public License as published by
5154 + * the Free Software Foundation; either version 2 of the License, or
5155 + * (at your option) any later version.
5156 + *
5157 + * This program is distributed in the hope that it will be useful,
5158 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5159 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5160 + * GNU General Public License for more details.
5161 + *
5162 + * You should have received a copy of the GNU General Public License
5163 + * along with this program; if not, write to the Free Software
5164 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
5165 + */
5166 +
5167 +#ident "@(#)fcntl.c 1.1 02/23/02"
5168 +
5169 +#include <linux/types.h>
5170 +#include <linux/errno.h>
5171 +#include <linux/fcntl.h>
5172 +#include <linux/sched.h>
5173 +#include <linux/kernel.h>
5174 +#include <linux/syscalls.h>
5175 +#include <linux/module.h>
5176 +
5177 +#include <asm/uaccess.h>
5178 +#include <asm/ioctls.h>
5179 +
5180 +#include <abi/svr4/types.h>
5181 +#include <abi/util/trace.h>
5182 +#include <abi/util/map.h>
5183 +
5184 +
5185 +struct svr4_flock {
5186 +       int16_t     l_type;     /* numbers don't match */
5187 +       int16_t     l_whence;
5188 +       svr4_off_t  l_start;
5189 +       svr4_off_t  l_len;      /* 0 means to end of file */
5190 +       int16_t     l_sysid;
5191 +       int16_t     l_pid;
5192 +};
5193 +
5194 +
5195 +/*
5196 + * ISC (at least) assumes O_CREAT if O_TRUNC is given.
5197 + * This is emulated here but is it correct for SVR4 in general?
5198 + */
5199 +unsigned short fl_svr4_to_linux[] = {
5200 +       0x0001, 0x0002, 0x0800, 0x0400, 0x1000, 0x0000, 0x0000, 0x0800,
5201 +       0x0040, 0x0240, 0x0080, 0x0100, 0x0000, 0x0000, 0x0000, 0x0000
5202 +};
5203 +
5204 +unsigned short fl_linux_to_svr4[] = {
5205 +       0x0001, 0x0002, 0x0000, 0x0000, 0x0000, 0x0000, 0x0100, 0x0400,
5206 +       0x0800, 0x0200, 0x0008, 0x0004, 0x0010, 0x0000, 0x0000, 0x0000
5207 +};
5208 +
5209 +static inline int svr4_fcntl_flock(int fd, unsigned int cmd, unsigned long arg)
5210 +{
5211 +       struct svr4_flock fl, *flp = (struct svr4_flock *)arg;
5212 +       struct flock l_fl;
5213 +       mm_segment_t fs;
5214 +       int rval;
5215 +
5216 +       /*
5217 +        * We are not supposed to fail once the lock is set,
5218 +        * thus we check the userspace pointer for writeaccess now.
5219 +        */
5220 +       if (!access_ok(VERIFY_WRITE, flp, sizeof(struct svr4_flock)))
5221 +               return -EFAULT;
5222 +
5223 +       rval = copy_from_user(&fl, flp, sizeof(struct svr4_flock));
5224 +       if (rval)
5225 +               return -EFAULT;
5226 +
5227 +       l_fl.l_type = fl.l_type - 1;
5228 +       l_fl.l_whence = fl.l_whence;
5229 +       l_fl.l_start = fl.l_start;
5230 +       l_fl.l_len = fl.l_len;
5231 +       l_fl.l_pid = fl.l_pid;
5232 +
5233 +#if defined(CONFIG_ABI_TRACE)
5234 +       abi_trace(ABI_TRACE_API,
5235 +               "lock l_type: %d l_whence: %d "
5236 +               "l_start: %u l_len: %u "
5237 +               "l_sysid: %d l_pid: %d\n",
5238 +               fl.l_type, fl.l_whence,
5239 +               fl.l_start, fl.l_len,
5240 +               fl.l_sysid, fl.l_pid);
5241 +#endif
5242 +
5243 +       fs = get_fs();
5244 +       set_fs(get_ds());
5245 +       rval = sys_fcntl(fd, cmd, (unsigned long)&l_fl);
5246 +       set_fs(fs);
5247 +
5248 +       if (rval)
5249 +               return rval;
5250 +
5251 +       fl.l_type = l_fl.l_type + 1;
5252 +       fl.l_whence = l_fl.l_whence;
5253 +       fl.l_start = l_fl.l_start;
5254 +       fl.l_len = l_fl.l_len;
5255 +       fl.l_sysid = 0;
5256 +       fl.l_pid = l_fl.l_pid;
5257 +
5258 +       if (__copy_to_user(flp, &fl, sizeof(struct svr4_flock)))
5259 +               return -EFAULT;
5260 +       return 0;
5261 +}
5262 +
5263 +int svr4_fcntl(int fd, unsigned int cmd, unsigned long arg)
5264 +{
5265 +       int rval;
5266 +
5267 +       switch (cmd) {
5268 +       case 0: /* F_DUPFD */
5269 +       case 1: /* F_GETFD */
5270 +       case 2: /* F_SETFD */
5271 +               return sys_fcntl(fd, cmd, arg);
5272 +       case 3: /* F_GETFL */
5273 +               rval = sys_fcntl(fd, cmd, arg);
5274 +               return map_flags(rval, fl_linux_to_svr4);
5275 +       case 4: /* F_SETFL */
5276 +               arg = map_flags(arg, fl_svr4_to_linux);
5277 +               return sys_fcntl(fd, cmd, arg);
5278 +       case 14: /* F_GETLK SVR4 */
5279 +               cmd = 5;
5280 +               /*FALLTHROUGH*/
5281 +       case 5: /* F_GETLK */
5282 +       case 6: /* F_SETLK */
5283 +       case 7: /* F_SETLKW */
5284 +               return svr4_fcntl_flock(fd, cmd, arg);
5285 +       case 10: /* F_ALLOCSP */
5286 +               /* Extend allocation for specified portion of file. */
5287 +               return 0;
5288 +       case 11: /* F_FREESP */
5289 +               /* Free a portion of a file. */
5290 +               return 0;
5291 +
5292 +       /*
5293 +        * These are intended to support the Xenix chsize() and
5294 +        * rdchk() system calls. I don't know if these may be
5295 +        * generated by applications or not.
5296 +        */
5297 +       case 0x6000: /* F_CHSIZE */
5298 +               return sys_ftruncate(fd, arg);
5299 +       case 0x6001: /* F_RDCHK */
5300 +           {
5301 +               mm_segment_t fs;
5302 +               int nbytes;
5303 +
5304 +               fs = get_fs();
5305 +               set_fs(get_ds());
5306 +               rval = sys_ioctl(fd, FIONREAD, (long)&nbytes);
5307 +               set_fs(fs);
5308 +
5309 +               if (rval < 0)
5310 +                       return rval;
5311 +               return (nbytes ? 1 : 0);
5312 +           }
5313 +
5314 +       case  8: /* F_CHKFL */
5315 +           /*FALLTHROUGH*/
5316 +
5317 +       /*
5318 +        * These are made from the Xenix locking() system call.
5319 +        * According to available documentation these would
5320 +        * never be generated by an application - only by the
5321 +        * kernel Xenix support.
5322 +        */
5323 +       case 0x6300: /* F_LK_UNLCK */
5324 +       case 0x7200: /* F_LK_LOCK */
5325 +       case 0x6200: /* F_LK_NBLCK */
5326 +       case 0x7100: /* F_LK_RLCK */
5327 +       case 0x6100: /* F_LK_NBRLCK */
5328 +           /*FALLTHROUGH*/
5329 +
5330 +       default:
5331 +#if defined(CONFIG_ABI_TRACE)
5332 +               abi_trace(ABI_TRACE_API,
5333 +                       "unsupported fcntl 0x%x, arg 0x%lx\n", cmd, arg);
5334 +#endif
5335 +               return -EINVAL;
5336 +       }
5337 +}
5338 +
5339 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
5340 +EXPORT_SYMBOL(fl_svr4_to_linux);
5341 +EXPORT_SYMBOL(svr4_fcntl);
5342 +#endif
5343 diff -Nur kernel-source-2.6.16.orig/abi/svr4/filio.c kernel-source-2.6.16/abi/svr4/filio.c
5344 --- kernel-source-2.6.16.orig/abi/svr4/filio.c  1970-01-01 10:00:00.000000000 +1000
5345 +++ kernel-source-2.6.16/abi/svr4/filio.c       2006-04-27 18:50:24.000000000 +1000
5346 @@ -0,0 +1,94 @@
5347 +/*
5348 + * Copyright (c) 2001 Christoph Hellwig.
5349 + * All rights reserved.
5350 + *
5351 + * This program is free software; you can redistribute it and/or modify
5352 + * it under the terms of the GNU General Public License as published by
5353 + * the Free Software Foundation; either version 2 of the License, or
5354 + * (at your option) any later version.
5355 + *
5356 + * This program is distributed in the hope that it will be useful,
5357 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5358 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5359 + * GNU General Public License for more details.
5360 + *
5361 + * You should have received a copy of the GNU General Public License
5362 + * along with this program; if not, write to the Free Software
5363 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
5364 + */
5365 +
5366 +#ident "%W% %G%"
5367 +
5368 +/*
5369 + * SVR4 file ioctls.
5370 + */
5371 +
5372 +#include <linux/sched.h>
5373 +#include <linux/file.h>
5374 +#include <linux/sockios.h>
5375 +#include <linux/syscalls.h>
5376 +#include <linux/module.h>
5377 +
5378 +#include <asm/uaccess.h>
5379 +#include <asm/ioctls.h>
5380 +
5381 +#include <abi/ioctl.h>
5382 +
5383 +
5384 +int
5385 +svr4_fil_ioctl(int fd, u_int cmd, caddr_t data)
5386 +{
5387 +       switch (cmd) {
5388 +       /* FIOCLEX */
5389 +       case BSD__IOV('f', 1):
5390 +       case BSD__IO('f', 1):
5391 +               FD_SET(fd, files_fdtable(current->files)->close_on_exec);
5392 +               return 0;
5393 +
5394 +       /* FIONCLEX */
5395 +       case BSD__IOV('f', 2):
5396 +       case BSD__IO('f', 2):
5397 +               FD_CLR(fd, files_fdtable(current->files)->close_on_exec);
5398 +               return 0;
5399 +
5400 +       case BSD__IOV('f', 3):
5401 +       case BSD__IO('f', 3): {
5402 +               int             error, nbytes;
5403 +               mm_segment_t    fs;
5404 +
5405 +               fs = get_fs();
5406 +               set_fs(get_ds());
5407 +               error = sys_ioctl(fd, FIONREAD, (long)&nbytes);
5408 +               set_fs(fs);
5409 +
5410 +               return (error <= 0 ? error : nbytes);
5411 +       }
5412 +
5413 +       /* FGETOWN */
5414 +       case BSD__IOW('f', 123, int):
5415 +               return sys_ioctl(fd, FIOGETOWN, (long)data);
5416 +
5417 +       /* FSETOWN */
5418 +       case BSD__IOW('f', 124, int):
5419 +               return sys_ioctl(fd, FIOSETOWN, (long)data);
5420 +
5421 +       /* FIOASYNC */
5422 +       case BSD__IOW('f', 125, int):
5423 +               return sys_ioctl(fd, FIOASYNC, (long)data);
5424 +
5425 +       /* FIONBIO */
5426 +       case BSD__IOW('f', 126, int):
5427 +               return sys_ioctl(fd, FIONBIO, (long)data);
5428 +
5429 +       /* FIONREAD */
5430 +       case BSD__IOR('f', 127, int):
5431 +               return sys_ioctl(fd, FIONREAD, (long)data);
5432 +       }
5433 +
5434 +       printk(KERN_ERR "%s: file ioctl 0x%08x unsupported\n", __FUNCTION__, cmd);
5435 +       return -EINVAL;
5436 +}
5437 +
5438 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
5439 +EXPORT_SYMBOL(svr4_fil_ioctl);
5440 +#endif
5441 diff -Nur kernel-source-2.6.16.orig/abi/svr4/hrtsys.c kernel-source-2.6.16/abi/svr4/hrtsys.c
5442 --- kernel-source-2.6.16.orig/abi/svr4/hrtsys.c 1970-01-01 10:00:00.000000000 +1000
5443 +++ kernel-source-2.6.16/abi/svr4/hrtsys.c      2006-04-27 18:50:24.000000000 +1000
5444 @@ -0,0 +1,194 @@
5445 +/*
5446 + * Copyright (C) 1994 Eric Youngdale.
5447 + *
5448 + * The hrtsys interface is used by SVR4, and is effectively a way of doing
5449 + * itimer.  I do not know why this is used instead of the regular itimer
5450 + * stuff, but it appears to be related to bsd programs/functionality.
5451 + */
5452 +
5453 +#ident "%W% %G%"
5454 +
5455 +#include <linux/module.h>
5456 +#include <linux/ptrace.h>
5457 +#include <linux/errno.h>
5458 +#include <linux/mm.h>
5459 +#include <linux/string.h>
5460 +#include <linux/syscalls.h>
5461 +#include <asm/uaccess.h>
5462 +
5463 +#include <asm/abi_machdep.h>
5464 +#include <abi/util/trace.h>
5465 +
5466 +
5467 +struct hrt_time_t {
5468 +       unsigned long secs;
5469 +       unsigned long sub_sec; /* Less than one second. */
5470 +       unsigned long resolution; /* Resolution of timer */
5471 +};
5472 +
5473 +struct hrtcmd {
5474 +       int cmd;
5475 +       int clk;
5476 +       struct hrt_time_t interval;
5477 +       struct hrt_time_t tod;
5478 +       int flags;
5479 +       int error;
5480 +       int reserved[3];
5481 +};
5482 +
5483 +static int
5484 +ibcs_hrtcntl (struct pt_regs * regs)
5485 +{
5486 +       unsigned int param[4];
5487 +       struct timeval * tv;
5488 +       int i, error;
5489 +
5490 +       for (i=0; i<4; i++)
5491 +               param[i] = get_syscall_parameter (regs, 1+i);
5492 +
5493 +       if (param[0] != 1 || param[1] != 1 || param[2] != 0)
5494 +               return -EINVAL;
5495 +
5496 +       tv = (struct timeval *) param[3];
5497 +
5498 +#if defined(CONFIG_ABI_TRACE)
5499 +       abi_trace(ABI_TRACE_API, "hrtcntl(0x%lx)\n", (u_long)tv);
5500 +#endif
5501 +
5502 +       if (!access_ok(VERIFY_WRITE, (char *) tv,sizeof *tv))
5503 +               return -EFAULT;
5504 +
5505 +       return sys_gettimeofday(tv, NULL);
5506 +}
5507 +
5508 +static int
5509 +ibcs_hrtalarm (struct pt_regs * regs)
5510 +{
5511 +       struct itimerval get_buffer;
5512 +       struct hrtcmd * hcmd;
5513 +       int i, error, cmd, retval, which;
5514 +       mm_segment_t old_fs = get_fs();
5515 +
5516 +       i = get_syscall_parameter (regs, 2);
5517 +       if(i != 1)
5518 +               return -EINVAL;
5519 +
5520 +       hcmd = (struct hrtcmd *) get_syscall_parameter (regs, 1);
5521 +
5522 +       if (!access_ok (VERIFY_WRITE, (char *) hcmd,sizeof *hcmd))
5523 +               return -EFAULT;
5524 +
5525 +       get_user (cmd, ((unsigned long *) hcmd));
5526 +
5527 +       /* Now figure out which clock we want to fiddle with */
5528 +       get_user (which, ((unsigned long *) hcmd)+1);
5529 +
5530 +#if defined(CONFIG_ABI_TRACE)
5531 +       abi_trace(ABI_TRACE_API, "hrtalarm(0x%lx %d)\n",
5532 +                       (u_long)cmd, which);
5533 +#endif
5534 +
5535 +       switch (which) {
5536 +               case 4:
5537 +                       which = 2;
5538 +                       break;
5539 +               case 2:
5540 +                       which = 1;
5541 +                       break;
5542 +               case 1:
5543 +                       which = 0;
5544 +                       break;
5545 +               default:
5546 +                       return -EINVAL;
5547 +       };
5548 +
5549 +       switch (cmd) {
5550 +               case 0xc:
5551 +                       if(({long r; get_user(r, ((unsigned long *) hcmd)+4); r;}) != 1000000)
5552 +                               return -EINVAL;
5553 +                       if (copy_from_user(&get_buffer.it_value, ((unsigned long *) hcmd)+2,
5554 +                               sizeof(struct timeval)))
5555 +                               return -EFAULT;
5556 +                       memset(&get_buffer.it_interval, 0, sizeof(struct timeval));
5557 +                       set_fs(get_ds());
5558 +                       retval = sys_setitimer(which, &get_buffer, NULL);
5559 +                       set_fs(old_fs);
5560 +                       break;
5561 +               case 0xd:
5562 +                       set_fs(get_ds());
5563 +                       retval = sys_getitimer(which, &get_buffer);
5564 +                       set_fs(old_fs);
5565 +
5566 +#if defined(CONFIG_ABI_TRACE)
5567 +                       abi_trace(ABI_TRACE_API, "hrtalarm(d %lx) %lx %lx %lx %lx\n",
5568 +                                       (u_long)hcmd,
5569 +                                       get_buffer.it_interval.tv_sec,
5570 +                                       get_buffer.it_interval.tv_usec,
5571 +                                       get_buffer.it_value.tv_sec,
5572 +                                       get_buffer.it_value.tv_usec);
5573 +#endif
5574 +
5575 +                       put_user(1000000, &hcmd->interval.resolution);
5576 +                       if (copy_to_user(((unsigned long *) hcmd)+2, &get_buffer.it_interval,
5577 +                               sizeof(get_buffer)))
5578 +                               return -EFAULT;
5579 +                       retval = 1;
5580 +                       break;
5581 +               case 0xf:
5582 +                       if(({long r; get_user(r, ((unsigned long *) hcmd)+4); r;}) != 1000000)
5583 +                               return -EINVAL;
5584 +                       if(({long r; get_user(r, ((unsigned long *) hcmd)+7); r;}) != 1000000)
5585 +                               return -EINVAL;
5586 +                       if (copy_from_user(&get_buffer.it_value, &hcmd->tod,
5587 +                               sizeof(struct timeval)))
5588 +                               return -EFAULT;
5589 +                       if (copy_from_user(&get_buffer.it_interval, &hcmd->interval,
5590 +                               sizeof(struct timeval)))
5591 +                               return -EFAULT;
5592 +                       set_fs(get_ds());
5593 +                       retval = sys_setitimer(which, &get_buffer, NULL);
5594 +                       set_fs(old_fs);
5595 +                       break;
5596 +               case 0x10:
5597 +                       memset(&get_buffer, 0, sizeof(get_buffer));
5598 +                       set_fs(get_ds());
5599 +                       retval = sys_setitimer(which, &get_buffer, NULL);
5600 +                       set_fs(old_fs);
5601 +                       break;
5602 +               default:
5603 +                       retval = -EINVAL;
5604 +       };
5605 +
5606 +       return retval;
5607 +}
5608 +
5609 +int
5610 +svr4_hrtsys (struct pt_regs * regs)
5611 +{
5612 +       int func, retval;
5613 +
5614 +       func  = get_syscall_parameter (regs, 0);
5615 +
5616 +#if defined(CONFIG_ABI_TRACE)
5617 +       abi_trace(ABI_TRACE_API, "hrtsys(%d)\n", func);
5618 +#endif
5619 +
5620 +       switch (func) {
5621 +               case 0:
5622 +                       retval = ibcs_hrtcntl(regs);
5623 +                       break;
5624 +               case 1:
5625 +                       retval = ibcs_hrtalarm(regs);
5626 +                       break;
5627 +               case 2:
5628 +               case 3:
5629 +               default:
5630 +                       retval = -EINVAL;
5631 +       }
5632 +
5633 +       return retval;
5634 +}
5635 +
5636 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
5637 +EXPORT_SYMBOL(svr4_hrtsys);
5638 +#endif
5639 diff -Nur kernel-source-2.6.16.orig/abi/svr4/ioctl.c kernel-source-2.6.16/abi/svr4/ioctl.c
5640 --- kernel-source-2.6.16.orig/abi/svr4/ioctl.c  1970-01-01 10:00:00.000000000 +1000
5641 +++ kernel-source-2.6.16/abi/svr4/ioctl.c       2006-04-27 18:50:24.000000000 +1000
5642 @@ -0,0 +1,198 @@
5643 +/*
5644 + * Copyright (C) 1991, 1992  Linus Torvalds
5645 + *
5646 + * Written by Drew Sullivan.
5647 + * Rewritten by Mike Jagdis.
5648 + */
5649 +
5650 +#ident "%W% %G%"
5651 +
5652 +#include <linux/config.h>
5653 +#include <linux/errno.h>
5654 +#include <linux/kernel.h>
5655 +#include <linux/module.h>
5656 +#include <linux/syscalls.h>
5657 +#include <asm/uaccess.h>
5658 +
5659 +#include <asm/abi_machdep.h>
5660 +#include <abi/svr4/ioctl.h>
5661 +
5662 +
5663 +/*
5664 + * __svr4_ioctl() is a meta mapper, that is
5665 + * it looks up the class of the ioctl and then
5666 + * dispatchs to lower level routines to handle the
5667 + * mapping of the actual ioctls
5668 + */
5669 +int
5670 +__svr4_ioctl(struct pt_regs *regs, int fd, unsigned long ioctl_num, void *arg)
5671 +{
5672 +       unsigned int class = ioctl_num >> 8;
5673 +       char class_str[4];
5674 +
5675 +       switch (class) {
5676 +
5677 +       /*
5678 +        * SCO ioctls on the pseudo NFS device probably.
5679 +        */
5680 +       case 0:
5681 +               return abi_ioctl_socksys(fd, ioctl_num, arg);
5682 +
5683 +       /*
5684 +        * SCO console keyboard stuff?
5685 +        */
5686 +       case 'A':
5687 +               return -EINVAL;
5688 +
5689 +       case 't':
5690 +               return svr4_tape_ioctl(fd, ioctl_num, arg);
5691 +
5692 +       case 'f':
5693 +               return svr4_fil_ioctl(fd, ioctl_num, arg);
5694 +
5695 +       /*
5696 +        * Xenix ioctl compatibility.
5697 +        */
5698 +       case 'T':
5699 +               return svr4_term_ioctl(fd, ioctl_num & 0xFF, arg);
5700 +
5701 +       case 'C':
5702 +       case 'c':
5703 +               return svr4_console_ioctl(fd, ioctl_num, arg);
5704 +
5705 +       case ('i' << 16) | ('C' << 8):  /* iBCS2 POSIX */
5706 +               return svr4_video_ioctl(fd, ioctl_num & 0xFF, arg);
5707 +
5708 +       /*
5709 +        * SCO 3.2.2 uses ('X'<<8)|1 for access to the video map
5710 +        * and the 'X' set is also used for synchronous comm
5711 +        * lines (I think?). SVR4 uses it for tty extensions to
5712 +        * support hardware flow control and external clocks.
5713 +        */
5714 +       case 'X':
5715 +               return svr4_termiox_ioctl(fd, ioctl_num & 0xFF, arg);
5716 +
5717 +       /*
5718 +        * These aren't implemented and are never likely to be as they
5719 +        * are specific to drivers for obscure hardware. (For those
5720 +        * that don't know they're the JERQ ioctls. Says it all
5721 +        * really!)
5722 +        */
5723 +       case 'j':
5724 +               return -EINVAL;
5725 +
5726 +       /*
5727 +        * The 'S' set could also be display mode switch
5728 +        * ioctls in a SCO 3.2.x x<4 environment. It should
5729 +        * depend on the descriptor they are applied to.
5730 +        * According to ISC the Xenix STREAMS ioctls had the
5731 +        * high bit set on the command to differentiate them
5732 +        * from mode switch ioctls. Yuk, yuk, yuk...
5733 +        */
5734 +       case 'S':
5735 +               return svr4_stream_ioctl(regs, fd, ioctl_num & 0x7F, arg);
5736 +
5737 +       /*
5738 +        * These are STREAMS socket module ioctls.
5739 +        */
5740 +       case 'I':
5741 +#if defined(CONFIG_ABI_XTI)
5742 +               return svr4_sockmod_ioctl(fd, ioctl_num & 0xFF, arg);
5743 +#else
5744 +               return -EINVAL;
5745 +#endif
5746 +
5747 +       /*
5748 +        * EUC ioctls. These are something to do with chararcter
5749 +        * code set conversions in SVR4. If we don't support
5750 +        * them the correct thing to do is to return EINVAL.
5751 +        */
5752 +       case 'E' | 0x80:
5753 +               return -EINVAL;
5754 +
5755 +       /*
5756 +        * SCO channel mapping. I can't find any documentation
5757 +        * for this. These are the LD?MAP ioctls defined in
5758 +        * sys/termio.h and sys/emap.h. They are used by mapchan.
5759 +        */
5760 +       case 'D':
5761 +               return -EINVAL;
5762 +       }
5763 +
5764 +       /*
5765 +        * If we haven't handled it yet it must be a BSD style ioctl
5766 +        * with a (possible) argument description in the high word of
5767 +        * the opcode.
5768 +        */
5769 +       switch (class & 0xff) {
5770 +
5771 +       /*
5772 +        * From SVR4 as specified in sys/iocomm.h.
5773 +        */
5774 +       case 'f':
5775 +               return svr4_fil_ioctl(fd, ioctl_num, arg);
5776 +
5777 +       /*
5778 +        * BSD or V7 terminal ioctls.
5779 +        */
5780 +       case 't':
5781 +               return bsd_ioctl_termios(fd, ioctl_num, arg);
5782 +
5783 +       /*
5784 +        * "Traditional" BSD and Wyse V/386 3.2.1A TCP/IP ioctls.
5785 +        */
5786 +       case 's':
5787 +       case 'r':
5788 +       case 'i':
5789 +               return abi_ioctl_socksys(fd, ioctl_num, arg);
5790 +
5791 +       /*
5792 +        * SVR3 streams based socket TCP/IP ioctls.
5793 +        *
5794 +        * These are handed over to the standard ioctl
5795 +        * handler since /dev/socksys is an emulated device
5796 +        * and front ends any sockets created through it.
5797 +        * Note that 'S' ioctls without the BSDish argument
5798 +        * type in the high bytes are STREAMS ioctls and 'I'
5799 +        * ioctls without the BSDish type in the high bytes
5800 +        * are the STREAMS socket module ioctls. (see above).
5801 +        */
5802 +       case 'S':
5803 +       case 'R':
5804 +       case 'I':
5805 +               return abi_ioctl_socksys(fd, ioctl_num, arg);
5806 +       }
5807 +
5808 +       /*
5809 +        * If nothing has handled it yet someone may have to do some
5810 +        * more work...
5811 +        */
5812 +       class_str[0] = class & 0xFF0000 ? (char)((class >> 16) & 0xFF) : '.';
5813 +       class_str[1] = class & 0x00FF00 ? (char)((class >>  8) & 0xFF) : '.';
5814 +       class_str[2] = class & 0x0000FF ? (char)((class      ) & 0xFF) : '.';
5815 +       class_str[3] = 0;
5816 +
5817 +       printk(KERN_DEBUG "svr4: ioctl(%d, %lx[%s], 0x%p) unsupported\n",
5818 +               fd, ioctl_num, class_str, arg);
5819 +
5820 +       return -EINVAL;
5821 +}
5822 +
5823 +int
5824 +svr4_ioctl(struct pt_regs * regs)
5825 +{
5826 +       u_int                   num;
5827 +       int                     fd;
5828 +       caddr_t                 data;
5829 +
5830 +       fd = (int)get_syscall_parameter(regs, 0);
5831 +       num = (u_int)get_syscall_parameter(regs, 1);
5832 +       data = (caddr_t)get_syscall_parameter(regs, 2);
5833 +
5834 +       return __svr4_ioctl(regs, fd, num, data);
5835 +}
5836 +
5837 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
5838 +EXPORT_SYMBOL(__svr4_ioctl);
5839 +EXPORT_SYMBOL(svr4_ioctl);
5840 +#endif
5841 diff -Nur kernel-source-2.6.16.orig/abi/svr4/ipc.c kernel-source-2.6.16/abi/svr4/ipc.c
5842 --- kernel-source-2.6.16.orig/abi/svr4/ipc.c    1970-01-01 10:00:00.000000000 +1000
5843 +++ kernel-source-2.6.16/abi/svr4/ipc.c 2006-04-27 18:50:24.000000000 +1000
5844 @@ -0,0 +1,716 @@
5845 +/*
5846 + * Copyright (C) 1994  Mike Jagdis (jaggy@purplet.demon.co.uk)
5847 + * Copyright (C) 2001   Christoph Hellwig (hch@caldera.de)
5848 + *
5849 + * Massive work over with a fine tooth comb, lots of rewriting. There
5850 + * were a *lot* of bugs in this - mismatched structs that weren't
5851 + * mapped, wrong pointers etc. I've tested this version with the
5852 + * demo programs from the Wyse V/386 IPC documentation which exercise
5853 + * all the functions. I don't have any major IPC using applications
5854 + * to test it with - as far as I know...
5855 + *
5856 + * Again rewritten for Linux 2.4 - Linux 2.4 changes a lot of structures
5857 + * and the cruft this file relied on has simply changed...
5858 + *
5859 + * Original copyright etc. follows:
5860 + *
5861 + * Copyright (C) 1993,1994  Joe Portman (baron@hebron.connected.com)
5862 + *     First stab at ibcs shm, sem and msg handlers
5863 + *
5864 + * NOTE:
5865 + * Please contact the author above before blindly making changes
5866 + * to this file. You will break things.
5867 + *
5868 + * 04-15-1994 JLP III
5869 + *     Still no msgsys, but IPC_STAT now works for shm calls
5870 + *     Corrected argument order for sys_ipc calls, to accomodate Mike's
5871 + *     changes, so that we can just call sys_ipc instead of the internal
5872 + *     sys_* calls for ipc functions.
5873 + *     Cleaned up translation of perm structures
5874 + *     tstshm for Oracle now works.
5875 + *
5876 + * 04-23-1994 JLP III
5877 + *     Added in msgsys calls, Tested and working
5878 + *     Added translation for IPC_SET portions of all xxxctl functions.
5879 + *     Added SHM_LOCK and SHM_UNLOCK to shmsys
5880 + *
5881 + * 04-28-1994 JLP III
5882 + *     Special thanks to Brad Pepers for adding in the GETALL and SETALL
5883 + *     case of semaphores. (pepersb@cuug.ab.ca)
5884 + */
5885 +
5886 +#ident "%W% %G%"
5887 +
5888 +#include <linux/module.h>
5889 +#include <linux/errno.h>
5890 +#include <linux/fs.h>
5891 +#include <linux/kernel.h>
5892 +#include <linux/personality.h>
5893 +#include <linux/ptrace.h>
5894 +#include <linux/sched.h>
5895 +#include <linux/string.h>
5896 +#define __KERNEL_SYSCALLS__
5897 +#include <linux/unistd.h>
5898 +#include <linux/syscalls.h>
5899 +#include <linux/ipc.h>
5900 +#include <linux/sem.h>
5901 +#include <linux/shm.h>
5902 +#include <linux/msg.h>
5903 +
5904 +#include <asm/uaccess.h>
5905 +#include <asm/ipc.h>
5906 +
5907 +#include <abi/svr4/ipc.h>
5908 +#include <abi/util/trace.h>
5909 +#include <abi/util/errno.h>
5910 +
5911 +
5912 +static __inline__ void
5913 +ip_to_lp(struct ibcs2_ipc_perm *ip, struct ipc_perm *lp)
5914 +{
5915 +       lp->uid = ip->uid;
5916 +       lp->gid = ip->gid;
5917 +       lp->cuid = ip->cuid;
5918 +       lp->cgid = ip->cgid;
5919 +       lp->mode = ip->mode;
5920 +       lp->seq = ip->seq;
5921 +       lp->key = ip->key;
5922 +}
5923 +
5924 +static __inline__ void
5925 +lp_to_ip(struct ipc_perm *lp, struct ibcs2_ipc_perm *ip)
5926 +{
5927 +       ip->uid = lp->uid;
5928 +       ip->gid = lp->gid;
5929 +       ip->cuid = lp->cuid;
5930 +       ip->cgid = lp->cgid;
5931 +       ip->mode = lp->mode;
5932 +       ip->seq = lp->seq;
5933 +       ip->key = lp->key;
5934 +}
5935 +
5936 +static __inline__ void
5937 +ip_to_lp_l(struct abi4_ipc_perm *ip, struct ipc_perm *lp)
5938 +{
5939 +       lp->uid = ip->uid;
5940 +       lp->gid = ip->gid;
5941 +       lp->cuid = ip->cuid;
5942 +       lp->cgid = ip->cgid;
5943 +       lp->mode = ip->mode;
5944 +       lp->seq = ip->seq;
5945 +       lp->key = ip->key;
5946 +}
5947 +
5948 +static __inline__ void
5949 +lp_to_ip_l(struct ipc_perm *lp, struct abi4_ipc_perm *ip)
5950 +{
5951 +       ip->uid = lp->uid;
5952 +       ip->gid = lp->gid;
5953 +       ip->cuid = lp->cuid;
5954 +       ip->cgid = lp->cgid;
5955 +       ip->mode = lp->mode;
5956 +       ip->seq = lp->seq;
5957 +       ip->key = lp->key;
5958 +}
5959 +
5960 +static void
5961 +isem_to_lsem(struct ibcs2_semid_ds *is, struct semid_ds *ls)
5962 +{
5963 +       ip_to_lp(&is->sem_perm, &ls->sem_perm);
5964 +
5965 +       ls->sem_base = is->sem_base;
5966 +       ls->sem_nsems = is->sem_nsems;
5967 +       ls->sem_otime = is->sem_otime;
5968 +       ls->sem_ctime = is->sem_ctime;
5969 +}
5970 +
5971 +static void
5972 +lsem_to_isem(struct semid_ds *ls, struct ibcs2_semid_ds *is)
5973 +{
5974 +       lp_to_ip(&ls->sem_perm, &is->sem_perm);
5975 +
5976 +       is->sem_base = ls->sem_base;
5977 +       is->sem_nsems = ls->sem_nsems;
5978 +       is->sem_otime = ls->sem_otime;
5979 +       is->sem_ctime = ls->sem_ctime;
5980 +}
5981 +
5982 +static void
5983 +isem_to_lsem_l(struct abi4_semid_ds *is, struct semid_ds *ls)
5984 +{
5985 +       ip_to_lp_l(&is->sem_perm, &ls->sem_perm);
5986 +
5987 +       ls->sem_base = is->sem_base;
5988 +       ls->sem_nsems = is->sem_nsems;
5989 +       ls->sem_otime = is->sem_otime;
5990 +       ls->sem_ctime = is->sem_ctime;
5991 +}
5992 +
5993 +static void
5994 +lsem_to_isem_l(struct semid_ds *ls, struct abi4_semid_ds *is)
5995 +{
5996 +       memset(is, 0, sizeof(*is));
5997 +
5998 +       lp_to_ip_l(&ls->sem_perm, &is->sem_perm);
5999 +
6000 +       is->sem_base = ls->sem_base;
6001 +       is->sem_nsems = ls->sem_nsems;
6002 +       is->sem_otime = ls->sem_otime;
6003 +       is->sem_ctime = ls->sem_ctime;
6004 +}
6005 +
6006 +static int
6007 +__ibcs2_semctl(int first, int second, int third, union semun *fourth)
6008 +{
6009 +       struct ibcs2_semid_ds   is, *isp;
6010 +       struct semid_ds         ls;
6011 +       union semun             lsemun;
6012 +       mm_segment_t            fs;
6013 +       int                     err;
6014 +
6015 +       err = get_user(isp, (struct ibcs2_semid_ds **)&fourth->buf);
6016 +       if (err)
6017 +               return (err);
6018 +
6019 +       err = copy_from_user(&is, isp, sizeof(is)) ? -EFAULT : 0;
6020 +       if (err)
6021 +               return (err);
6022 +
6023 +       isem_to_lsem(&is, &ls);
6024 +       lsemun.buf = &ls;
6025 +
6026 +       fs = get_fs();
6027 +       set_fs(get_ds());
6028 +       err = sys_ipc(SEMCTL, first, second, third, &lsemun,0);
6029 +       set_fs(fs);
6030 +
6031 +       if (err < 0)
6032 +               return (err);
6033 +
6034 +       lsem_to_isem(&ls, &is);
6035 +       return copy_to_user(isp, &is, sizeof(is)) ? -EFAULT : 0;
6036 +}
6037 +
6038 +static int
6039 +__abi4_semctl(int first, int second, int third, union semun *fourth)
6040 +{
6041 +       struct abi4_semid_ds    is, *isp;
6042 +       struct semid_ds         ls;
6043 +       union semun             lsemun;
6044 +       mm_segment_t            fs;
6045 +       int                     err;
6046 +
6047 +       err = get_user(isp, (struct abi4_semid_ds **)&fourth->buf);
6048 +       if (err)
6049 +               return (err);
6050 +
6051 +       err = copy_from_user(&is, isp, sizeof(is)) ? -EFAULT : 0;
6052 +       if (err)
6053 +               return (err);
6054 +
6055 +       isem_to_lsem_l(&is, &ls);
6056 +       lsemun.buf = &ls;
6057 +
6058 +       fs = get_fs();
6059 +       set_fs(get_ds());
6060 +       err = sys_ipc(SEMCTL, first, second, third, &lsemun,0);
6061 +       set_fs(fs);
6062 +
6063 +       if (err < 0)
6064 +               return (err);
6065 +
6066 +       lsem_to_isem_l(&ls, &is);
6067 +       return copy_to_user(isp, &is, sizeof(is)) ? -EFAULT : 0;
6068 +}
6069 +
6070 +static int
6071 +svr4_semctl(int arg1, int arg2, int arg3, union semun *arg4)
6072 +{
6073 +       int                     cmd = svr4sem2linux[arg3];
6074 +
6075 +       switch (arg3) {
6076 +       case SVR4_SEM_SETALL:
6077 +       case SVR4_SEM_GETALL:
6078 +               return __ibcs2_semctl(arg1, 0, cmd, arg4);
6079 +       case SVR4_IPC_RMID:
6080 +       case SVR4_IPC_RMID_L:
6081 +       case SVR4_SEM_SETVAL:
6082 +       case SVR4_SEM_GETVAL:
6083 +       case SVR4_SEM_GETPID:
6084 +       case SVR4_SEM_GETNCNT:
6085 +       case SVR4_SEM_GETZCNT:
6086 +               return  sys_ipc(SEMCTL, arg1, arg2, cmd, arg4, 0);
6087 +       case SVR4_IPC_SET:
6088 +       case SVR4_IPC_STAT:
6089 +               return __ibcs2_semctl(arg1, arg2, cmd, arg4);
6090 +       case SVR4_IPC_STAT_L:
6091 +       case SVR4_IPC_SET_L:
6092 +               return __abi4_semctl(arg1, arg2, cmd, arg4);
6093 +       }
6094 +
6095 +       __abi_trace("semctl: unsupported command %d\n", arg3);
6096 +       return -EINVAL;
6097 +}
6098 +
6099 +static int
6100 +svr4_semget(int arg1, int arg2, int arg3)
6101 +{
6102 +#if defined(CONFIG_ABI_TRACE)
6103 +       abi_trace(ABI_TRACE_API, "semget(%d, %d, %o)\n", arg1, arg2, arg3);
6104 +#endif
6105 +       return sys_semget(arg1, arg2, arg3);
6106 +
6107 +}
6108 +
6109 +static int
6110 +svr4_semop(int arg1, struct sembuf *arg2, int arg3)
6111 +{
6112 +#if defined(CONFIG_ABI_TRACE)
6113 +       if (abi_traced(ABI_TRACE_API)) {
6114 +               struct sembuf   tmp, *tp = arg2;
6115 +               int             i;
6116 +
6117 +               for (i = 0; i < arg3; i++) {
6118 +                       if (copy_from_user (&tmp, tp, sizeof(tmp)))
6119 +                       {       __abi_trace("semop(-EFAULT)\n");
6120 +                               break;
6121 +                       }
6122 +                       __abi_trace("semop(%d, %d, 0%o)\n",
6123 +                                       tmp.sem_num, tmp.sem_op,
6124 +                                       tmp.sem_flg);
6125 +                       tp++;
6126 +               }
6127 +       }
6128 +#endif
6129 +
6130 +       return sys_semop(arg1, arg2, arg3);
6131 +}
6132 +
6133 +int
6134 +svr4_semsys(struct pt_regs *regp)
6135 +{
6136 +       int                     which, arg1, arg2, arg3;
6137 +       union semun             *arg4;
6138 +
6139 +       which = get_syscall_parameter(regp, 0);
6140 +       arg1 = get_syscall_parameter(regp, 1);
6141 +       arg2 = get_syscall_parameter(regp, 2);
6142 +       arg3 = get_syscall_parameter(regp, 3);
6143 +
6144 +       /*
6145 +        * XXX - The value for arg4 depends on how union
6146 +        * passing is implement on this architecture and
6147 +        * compiler. The following is *only* known to be
6148 +        * right for Intel (the default else case).
6149 +        */
6150 +#ifdef __sparc__
6151 +       arg4 = (union semun *)get_syscall_parameter(regp, 4);
6152 +#else
6153 +       arg4 = (union semun *)(((u_long *)regp->esp) + (5));
6154 +#endif
6155 +
6156 +       switch (which) {
6157 +       case SVR4_semctl:
6158 +               return svr4_semctl(arg1, arg2, arg3, arg4);
6159 +       case SVR4_semget:
6160 +               return svr4_semget(arg1, arg2, arg3);
6161 +       case SVR4_semop:
6162 +               return svr4_semop(arg1, (struct sembuf *)arg2, arg3);
6163 +       }
6164 +
6165 +       return -EINVAL;
6166 +}
6167 +
6168 +static void
6169 +ishm_to_lshm(struct ibcs2_shmid_ds *is, struct shmid_ds *ls)
6170 +{
6171 +       ip_to_lp(&is->shm_perm, &ls->shm_perm);
6172 +       ls->shm_segsz = is->shm_segsz;
6173 +       ls->shm_lpid = is->shm_lpid;
6174 +       ls->shm_cpid = is->shm_cpid;
6175 +       ls->shm_nattch = is->shm_nattch;
6176 +       ls->shm_atime = is->shm_atime;
6177 +       ls->shm_dtime = is->shm_dtime;
6178 +       ls->shm_ctime = is->shm_ctime;
6179 +}
6180 +
6181 +static void
6182 +lshm_to_ishm(struct shmid_ds *ls, struct ibcs2_shmid_ds *is)
6183 +{
6184 +       lp_to_ip(&ls->shm_perm, &is->shm_perm);
6185 +       is->shm_segsz = ls->shm_segsz;
6186 +       is->shm_lpid = ls->shm_lpid;
6187 +       is->shm_cpid = ls->shm_cpid;
6188 +       is->shm_nattch = ls->shm_nattch;
6189 +       is->shm_atime = ls->shm_atime;
6190 +       is->shm_dtime = ls->shm_dtime;
6191 +       is->shm_ctime = ls->shm_ctime;
6192 +}
6193 +
6194 +static void
6195 +ishm_to_lshm_l(struct abi4_shmid_ds *is, struct shmid_ds *ls)
6196 +{
6197 +       ip_to_lp_l(&is->shm_perm, &ls->shm_perm);
6198 +       ls->shm_segsz = is->shm_segsz;
6199 +       ls->shm_lpid = is->shm_lpid;
6200 +       ls->shm_cpid = is->shm_cpid;
6201 +       ls->shm_nattch = is->shm_nattch;
6202 +       ls->shm_atime = is->shm_atime;
6203 +       ls->shm_dtime = is->shm_dtime;
6204 +       ls->shm_ctime = is->shm_ctime;
6205 +}
6206 +
6207 +static void
6208 +lshm_to_ishm_l(struct shmid_ds *ls, struct abi4_shmid_ds *is)
6209 +{
6210 +       memset(is, 0, sizeof(*is));
6211 +       lp_to_ip_l(&ls->shm_perm, &is->shm_perm);
6212 +       is->shm_segsz = ls->shm_segsz;
6213 +       is->shm_lpid = ls->shm_lpid;
6214 +       is->shm_cpid = ls->shm_cpid;
6215 +       is->shm_nattch = ls->shm_nattch;
6216 +       is->shm_atime = ls->shm_atime;
6217 +       is->shm_dtime = ls->shm_dtime;
6218 +       is->shm_ctime = ls->shm_ctime;
6219 +}
6220 +
6221 +static int
6222 +svr4_shmdt(struct pt_regs *regp)
6223 +{
6224 +       caddr_t                 addr = (caddr_t)get_syscall_parameter(regp, 1);
6225 +
6226 +#if defined(CONFIG_ABI_TRACE)
6227 +       abi_trace(ABI_TRACE_API, "shmdt(%p)\n", addr);
6228 +#endif
6229 +       return sys_shmdt(addr);
6230 +}
6231 +
6232 +static int
6233 +svr4_shmctl(int arg1, int cmd, char *arg3)
6234 +{
6235 +       struct ibcs2_shmid_ds   is;
6236 +       struct abi4_shmid_ds    is4;
6237 +       struct shmid_ds         ls;
6238 +       mm_segment_t            fs;
6239 +       int                     err;
6240 +
6241 +#if defined(CONFIG_ABI_TRACE)
6242 +       abi_trace(ABI_TRACE_API, "shmctl(%d, %x, %p)\n", arg1, cmd, arg3);
6243 +#endif
6244 +
6245 +       switch (cmd) {
6246 +       case SVR4_SHM_LOCK:
6247 +               return sys_shmctl(arg1, SHM_LOCK, (struct shmid_ds *)arg3);
6248 +       case SVR4_SHM_UNLOCK:
6249 +               return sys_shmctl(arg1, SHM_UNLOCK, (struct shmid_ds *)arg3);
6250 +       case SVR4_IPC_SET:
6251 +               err = copy_from_user(&is, arg3, sizeof(is)) ? -EFAULT : 0;
6252 +               if (err)
6253 +                       break;
6254 +               ishm_to_lshm(&is, &ls);
6255 +
6256 +               fs = get_fs();
6257 +               set_fs(get_ds());
6258 +               err = sys_shmctl(arg1, IPC_SET, &ls);
6259 +               set_fs(fs);
6260 +
6261 +               if (err < 0)
6262 +                       break;
6263 +               lshm_to_ishm(&ls, &is);
6264 +               err = copy_to_user(arg3, &is, sizeof(is)) ? -EFAULT : 0;
6265 +               break;
6266 +       case SVR4_IPC_SET_L:
6267 +               err = copy_from_user(&is4, arg3, sizeof(is4)) ? -EFAULT : 0;
6268 +               if (err)
6269 +                       break;
6270 +               ishm_to_lshm_l(&is4, &ls);
6271 +
6272 +               fs = get_fs();
6273 +               set_fs(get_ds());
6274 +               err = sys_shmctl(arg1, IPC_SET, &ls);
6275 +               set_fs(fs);
6276 +
6277 +               if (err < 0)
6278 +                       break;
6279 +               lshm_to_ishm_l(&ls, &is4);
6280 +               err = copy_to_user(arg3, &is4, sizeof(is4)) ? -EFAULT : 0;
6281 +               break;
6282 +       case SVR4_IPC_RMID:
6283 +       case SVR4_IPC_RMID_L:
6284 +               return sys_shmctl(arg1, IPC_RMID, (struct shmid_ds *)arg3);
6285 +       case SVR4_IPC_STAT:
6286 +               fs = get_fs();
6287 +               set_fs(get_ds());
6288 +               err = sys_shmctl(arg1, IPC_STAT, &ls);
6289 +               set_fs(fs);
6290 +
6291 +               if (err < 0)
6292 +                       break;
6293 +
6294 +               lshm_to_ishm(&ls, &is);
6295 +               err = copy_to_user(arg3, &is, sizeof(is)) ? -EFAULT : 0;
6296 +               break;
6297 +       case SVR4_IPC_STAT_L:
6298 +               fs = get_fs();
6299 +               set_fs(get_ds());
6300 +               err = sys_shmctl(arg1, IPC_STAT, &ls);
6301 +               set_fs(fs);
6302 +               if (err < 0)
6303 +                       break;
6304 +
6305 +               lshm_to_ishm_l(&ls, &is4);
6306 +               err = copy_to_user((char *)arg3, &is4, sizeof(is4)) ? -EFAULT : 0;
6307 +               break;
6308 +       default:
6309 +#if defined(CONFIG_ABI_TRACE)
6310 +               __abi_trace("shmctl: unsupported command %d\n", cmd);
6311 +#endif
6312 +               err = -EINVAL;
6313 +       }
6314 +
6315 +       return (err);
6316 +}
6317 +
6318 +int
6319 +svr4_shmsys(struct pt_regs *regp)
6320 +{
6321 +       int                     arg1, arg2, arg3, cmd, err = 0;
6322 +       u_long                  raddr;
6323 +       mm_segment_t            fs;
6324 +
6325 +       cmd = get_syscall_parameter(regp, 0);
6326 +       if (cmd == SVR4_shmdt) {
6327 +               err = svr4_shmdt(regp);
6328 +               goto out;
6329 +       }
6330 +
6331 +       arg1 = get_syscall_parameter(regp, 1);
6332 +       arg2 = get_syscall_parameter(regp, 2);
6333 +       arg3 = get_syscall_parameter(regp, 3);
6334 +
6335 +       switch (cmd) {
6336 +       case SVR4_shmat:
6337 +#if defined(CONFIG_ABI_TRACE)
6338 +               abi_trace(ABI_TRACE_API, "shmat(%d, %x, %o)\n", arg1, arg2, arg3);
6339 +#endif
6340 +
6341 +               fs = get_fs();
6342 +               set_fs(get_ds());
6343 +               err = do_shmat(arg1, (caddr_t)arg2, arg3, &raddr);
6344 +               set_fs(fs);
6345 +               if (err >= 0)
6346 +                       err = (int)raddr;
6347 +
6348 +#if defined(CONFIG_ABI_TRACE)
6349 +               abi_trace(ABI_TRACE_API, "shmat returns %x\n", err);
6350 +#endif
6351 +               break;
6352 +       case SVR4_shmget:
6353 +#if defined(CONFIG_ABI_TRACE)
6354 +               abi_trace(ABI_TRACE_API, "shmget(%d, %x, %o)\n", arg1, arg2, arg3);
6355 +#endif
6356 +               err = sys_shmget(arg1, arg2, arg3);
6357 +#if defined(CONFIG_ABI_TRACE)
6358 +               abi_trace(ABI_TRACE_API, "shmget returns %d\n", err);
6359 +#endif
6360 +               break;
6361 +       case SVR4_shmctl:
6362 +               err = svr4_shmctl(arg1, arg2, (char *)arg3);
6363 +               break;
6364 +       default:
6365 +#if defined(CONFIG_ABI_TRACE)
6366 +               __abi_trace("shmsys: unsupported command: %x\n", cmd);
6367 +#endif
6368 +               err = -EINVAL;
6369 +       }
6370 +
6371 +out:
6372 +       if (err < 0 && err > -255) {
6373 +               set_error(regp, iABI_errors(-err));
6374 +               abi_trace(ABI_TRACE_API, "Error %d\n", get_result(regp));
6375 +               return 0;
6376 +       }
6377 +
6378 +       clear_error(regp);
6379 +       set_result(regp, err);
6380 +       return 0;
6381 +}
6382 +
6383 +static void
6384 +imsq_to_lmsq(struct ibcs2_msqid_ds * im, struct msqid_ds * lm)
6385 +{
6386 +       ip_to_lp(&im->msg_perm, &lm->msg_perm);
6387 +       lm->msg_first = im->msg_first;
6388 +       lm->msg_last = im->msg_last;
6389 +       lm->msg_cbytes = im->msg_cbytes;
6390 +       lm->msg_qnum = im->msg_qnum;
6391 +       lm->msg_qbytes = im->msg_qbytes;
6392 +       lm->msg_lspid = im->msg_lspid;
6393 +       lm->msg_lrpid = im->msg_lrpid;
6394 +       lm->msg_stime = im->msg_stime;
6395 +       lm->msg_rtime = im->msg_rtime;
6396 +       lm->msg_ctime = im->msg_ctime;
6397 +}
6398 +
6399 +static void
6400 +lmsq_to_imsq(struct msqid_ds *lm, struct ibcs2_msqid_ds *im)
6401 +{
6402 +       lp_to_ip(&lm->msg_perm, &im->msg_perm);
6403 +       im->msg_first = lm->msg_first;
6404 +       im->msg_last = lm->msg_last;
6405 +       im->msg_cbytes = lm->msg_cbytes;
6406 +       im->msg_qnum = lm->msg_qnum;
6407 +       im->msg_qbytes = lm->msg_qbytes;
6408 +       im->msg_lspid = lm->msg_lspid;
6409 +       im->msg_lrpid = lm->msg_lrpid;
6410 +       im->msg_stime = lm->msg_stime;
6411 +       im->msg_rtime = lm->msg_rtime;
6412 +       im->msg_ctime = lm->msg_ctime;
6413 +}
6414 +
6415 +static void
6416 +imsq_to_lmsq_l(struct abi4_msqid_ds *im, struct msqid_ds *lm)
6417 +{
6418 +       ip_to_lp_l(&im->msg_perm, &lm->msg_perm);
6419 +       lm->msg_first = im->msg_first;
6420 +       lm->msg_last = im->msg_last;
6421 +       lm->msg_cbytes = im->msg_cbytes;
6422 +       lm->msg_qnum = im->msg_qnum;
6423 +       lm->msg_qbytes = im->msg_qbytes;
6424 +       lm->msg_lspid = im->msg_lspid;
6425 +       lm->msg_lrpid = im->msg_lrpid;
6426 +       lm->msg_stime = im->msg_stime;
6427 +       lm->msg_rtime = im->msg_rtime;
6428 +       lm->msg_ctime = im->msg_ctime;
6429 +}
6430 +
6431 +static void
6432 +lmsq_to_imsq_l(struct msqid_ds *lm, struct abi4_msqid_ds *im)
6433 +{
6434 +       memset(im, 0, sizeof(*im));
6435 +       lp_to_ip_l(&lm->msg_perm, &im->msg_perm);
6436 +       im->msg_first = lm->msg_first;
6437 +       im->msg_last = lm->msg_last;
6438 +       im->msg_cbytes = lm->msg_cbytes;
6439 +       im->msg_qnum = lm->msg_qnum;
6440 +       im->msg_qbytes = lm->msg_qbytes;
6441 +       im->msg_lspid = lm->msg_lspid;
6442 +       im->msg_lrpid = lm->msg_lrpid;
6443 +       im->msg_stime = lm->msg_stime;
6444 +       im->msg_rtime = lm->msg_rtime;
6445 +       im->msg_ctime = lm->msg_ctime;
6446 +}
6447 +
6448 +static int
6449 +svr4_msgctl(int arg1, int cmd, char *arg3)
6450 +{
6451 +       struct ibcs2_msqid_ds   im;
6452 +       struct abi4_msqid_ds    im4;
6453 +       struct msqid_ds         lm;
6454 +       mm_segment_t            fs;
6455 +       int                     err;
6456 +
6457 +       switch (cmd) {
6458 +       case SVR4_IPC_SET:
6459 +               err = copy_from_user(&im, arg3, sizeof(im)) ? -EFAULT : 0;
6460 +               if (err)
6461 +                       break;
6462 +
6463 +               imsq_to_lmsq(&im, &lm);
6464 +
6465 +               fs = get_fs();
6466 +               set_fs(get_ds());
6467 +               err = sys_msgctl(arg1, IPC_SET, &lm);
6468 +               set_fs(fs);
6469 +
6470 +               lmsq_to_imsq(&lm, &im);
6471 +               err = copy_to_user(arg3, &im, sizeof(im)) ? -EFAULT : 0;
6472 +               break;
6473 +       case SVR4_IPC_SET_L:
6474 +               err = copy_from_user(&im4, arg3, sizeof(im4)) ? -EFAULT : 0;
6475 +               if (err)
6476 +                       break;
6477 +               imsq_to_lmsq_l(&im4, &lm);
6478 +
6479 +               fs = get_fs();
6480 +               set_fs(get_ds());
6481 +               err = sys_msgctl(arg1, IPC_SET, &lm);
6482 +               set_fs(fs);
6483 +
6484 +               lmsq_to_imsq_l(&lm, &im4);
6485 +               err = copy_to_user(arg3, &im4, sizeof(im4)) ? -EFAULT : 0;
6486 +               break;
6487 +       case SVR4_IPC_RMID:
6488 +       case SVR4_IPC_RMID_L:
6489 +               return sys_msgctl(arg1, IPC_RMID, (struct msqid_ds *)arg3);
6490 +       case SVR4_IPC_STAT:
6491 +               fs = get_fs();
6492 +               set_fs(get_ds());
6493 +               err = sys_msgctl(arg1, IPC_STAT, &lm);
6494 +               set_fs(fs);
6495 +
6496 +               if (err < 0)
6497 +                       break;
6498 +
6499 +               lmsq_to_imsq(&lm, &im);
6500 +               err = copy_to_user(arg3, &im, sizeof(im)) ? -EFAULT : 0;
6501 +               break;
6502 +       case SVR4_IPC_STAT_L:
6503 +               fs = get_fs();
6504 +               set_fs(get_ds());
6505 +               err = sys_msgctl(arg1, IPC_STAT, &lm);
6506 +               set_fs(fs);
6507 +
6508 +               if (err < 0)
6509 +                       break;
6510 +
6511 +               lmsq_to_imsq_l(&lm, &im4);
6512 +               err = copy_to_user(arg3, &im4, sizeof(im4)) ? -EFAULT : 0;
6513 +               break;
6514 +       default:
6515 +               __abi_trace("msgctl: unsupported command: %x\n", cmd);
6516 +               err = -EINVAL;
6517 +       }
6518 +
6519 +       return (err);
6520 +}
6521 +
6522 +int
6523 +svr4_msgsys(struct pt_regs *regp)
6524 +{
6525 +       int                     err, cmd, arg1, arg2, arg3, arg4, arg5;
6526 +
6527 +       /*
6528 +        * Special handling as msgrcv is ugly.
6529 +        */
6530 +       cmd = get_syscall_parameter(regp, 0);
6531 +       arg1 = get_syscall_parameter(regp, 1);
6532 +       arg2 = get_syscall_parameter(regp, 2);
6533 +
6534 +       switch (cmd) {
6535 +       case SVR4_msgget:
6536 +               return sys_msgget((key_t)arg1, arg2);
6537 +       case SVR4_msgctl:
6538 +               arg3 = get_syscall_parameter(regp, 3);
6539 +               return svr4_msgctl(arg1, arg2, (caddr_t)arg3);
6540 +       case SVR4_msgrcv:
6541 +               arg3 = get_syscall_parameter(regp, 3);
6542 +               arg4 = get_syscall_parameter(regp, 4);
6543 +               arg5 = get_syscall_parameter(regp, 5);
6544 +               return sys_msgrcv(arg1, (struct msgbuf *)arg2, arg3, arg4, arg5);
6545 +       case SVR4_msgsnd:
6546 +               arg3 = get_syscall_parameter(regp, 3);
6547 +               arg4 = get_syscall_parameter(regp, 4);
6548 +               err = sys_msgsnd(arg1, (struct msgbuf *)arg2, arg3, arg4);
6549 +               return ((err > 0) ? 0 : err);
6550 +       }
6551 +
6552 +       __abi_trace("msgsys: unsupported command: %x\n", cmd);
6553 +       return -EINVAL;
6554 +}
6555 +
6556 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
6557 +EXPORT_SYMBOL(svr4_msgsys);
6558 +EXPORT_SYMBOL(svr4_semsys);
6559 +EXPORT_SYMBOL(svr4_shmsys);
6560 +#endif
6561 diff -Nur kernel-source-2.6.16.orig/abi/svr4/Makefile kernel-source-2.6.16/abi/svr4/Makefile
6562 --- kernel-source-2.6.16.orig/abi/svr4/Makefile 1970-01-01 10:00:00.000000000 +1000
6563 +++ kernel-source-2.6.16/abi/svr4/Makefile      2006-04-27 18:50:24.000000000 +1000
6564 @@ -0,0 +1,20 @@
6565 +
6566 +svr4-y         := hrtsys.o ioctl.o ipc.o mmap.o open.o svr4.o sysconf.o \
6567 +                  sysfs.o sysinfo.o sysi86.o ulimit.o utsname.o stream.o \
6568 +                  stat.o socksys.o signal.o misc.o socket.o statvfs.o \
6569 +                  fcntl.o
6570 +
6571 +# emulations for all kinds of weird ioctls...
6572 +svr4-y         += filio.o termios.o consio.o tapeio.o sockio.o
6573 +
6574 +# networking
6575 +svr4-$(CONFIG_ABI_XTI) += timod.o xti.o
6576 +svr4-$(CONFIG_ABI_SPX) += timod.o
6577 +
6578 +abi-svr4-objs  += $(sort $(svr4-y))
6579 +
6580 +
6581 +obj-$(CONFIG_ABI_SVR4) += abi-svr4.o
6582 +
6583 +abi-svr4.o: $(abi-svr4-objs)
6584 +       $(LD) -r -o $@ $(abi-svr4-objs)
6585 diff -Nur kernel-source-2.6.16.orig/abi/svr4/misc.c kernel-source-2.6.16/abi/svr4/misc.c
6586 --- kernel-source-2.6.16.orig/abi/svr4/misc.c   1970-01-01 10:00:00.000000000 +1000
6587 +++ kernel-source-2.6.16/abi/svr4/misc.c        2006-04-27 18:50:24.000000000 +1000
6588 @@ -0,0 +1,667 @@
6589 +/*
6590 + * Copyright (C) 1993  Linus Torvalds
6591 + * Copyright (C) 2001  Caldera Deutschland GmbH
6592 + *
6593 + * Modified by Eric Youngdale to include all ibcs syscalls.
6594 + * Re-written by Drew Sullivan to handle lots more of the syscalls correctly.
6595 + */
6596 +
6597 +#ident "%W% %G%"
6598 +
6599 +#include <linux/module.h>
6600 +#include <linux/types.h>
6601 +#include <linux/errno.h>
6602 +#include <linux/sched.h>
6603 +#include <linux/kernel.h>
6604 +#include <linux/mm.h>
6605 +#include <linux/gfp.h>
6606 +#include <linux/stat.h>
6607 +#include <linux/stddef.h>
6608 +#include <linux/unistd.h>
6609 +#include <linux/ptrace.h>
6610 +#include <linux/fcntl.h>
6611 +#include <linux/time.h>
6612 +#include <linux/personality.h>
6613 +#include <linux/syscalls.h>
6614 +
6615 +#include <linux/fs.h>
6616 +#include <linux/sys.h>
6617 +#include <linux/slab.h>
6618 +#include <linux/file.h>
6619 +#include <linux/dirent.h>
6620 +
6621 +#include <asm/uaccess.h>
6622 +#include <asm/system.h>
6623 +
6624 +#include <abi/signal.h>
6625 +#include <abi/util/trace.h>
6626 +
6627 +#include <abi/svr4/types.h>
6628 +
6629 +
6630 +MODULE_DESCRIPTION("common code for SVR3/SVR4 based personalities");
6631 +MODULE_AUTHOR("Christoph Hellwig, partially taken from iBCS");
6632 +MODULE_LICENSE("GPL");
6633 +
6634 +
6635 +int
6636 +abi_time(void)
6637 +{
6638 +       return sys_time(0);
6639 +}
6640 +
6641 +int
6642 +abi_brk(unsigned long brk)
6643 +{
6644 +       unsigned long newbrk = PAGE_ALIGN(brk), oldbrk, sysbrk;
6645 +
6646 +       down_read(&current->mm->mmap_sem);
6647 +       if (!brk)
6648 +               goto report;
6649 +       oldbrk = PAGE_ALIGN(current->mm->brk);
6650 +       up_read(&current->mm->mmap_sem);
6651 +
6652 +       if (newbrk != oldbrk) {
6653 +               sysbrk = sys_brk(brk);
6654 +               if (PAGE_ALIGN(sysbrk) != newbrk)
6655 +                       return -ENOMEM;
6656 +       }
6657 +       return 0;
6658 +
6659 +report:
6660 +       /* return non-pagealigned old brk value */
6661 +       oldbrk = current->mm->brk;
6662 +       up_read(&current->mm->mmap_sem);
6663 +       return oldbrk;
6664 +}
6665 +
6666 +/*
6667 + * UNIX wants a 0-edx after fork and may have set
6668 + * the carry flag before calling fork.
6669 + */
6670 +int
6671 +abi_fork(struct pt_regs *regs)
6672 +{
6673 +       int             retval;
6674 +
6675 +       regs->eflags &= ~1;
6676 +       retval = do_fork(SIGCHLD, regs->esp, regs, 0,
6677 +                /* parent_tidptr */NULL, /* child_tidptr */NULL);
6678 +       regs->edx = 0;
6679 +       return retval;
6680 +}
6681 +
6682 +/*
6683 + * Unlike Linux, UNIX does not use C calling conventions
6684 + * for pipe().
6685 + */
6686 +int
6687 +abi_pipe(struct pt_regs *regs)
6688 +{
6689 +       int             filedes[2], retval;
6690 +
6691 +       retval = do_pipe(filedes);
6692 +       if (retval == 0) {
6693 +               retval = filedes[0];
6694 +               regs->edx = filedes[1];
6695 +       }
6696 +       return retval;
6697 +}
6698 +
6699 +/*
6700 + * Note the double value return in eax and edx.
6701 + */
6702 +int
6703 +abi_getpid(struct pt_regs *regs)
6704 +{
6705 +       regs->edx = current->parent->pid;
6706 +       return current->pid;
6707 +}
6708 +
6709 +/*
6710 + * Note the double value return in eax and edx.
6711 + */
6712 +int
6713 +abi_getuid(struct pt_regs *regs)
6714 +{
6715 +       regs->edx = current->euid;
6716 +       return current->uid;
6717 +}
6718 +
6719 +/*
6720 + * Note the double value return in eax and edx.
6721 + */
6722 +int
6723 +abi_getgid(struct pt_regs *regs)
6724 +{
6725 +       regs->edx = current->egid;
6726 +       return current->gid;
6727 +}
6728 +
6729 +
6730 +
6731 +enum {
6732 +       FLAG_ZF = 0x0040,
6733 +       FLAG_PF = 0x0004,
6734 +       FLAG_SF = 0x0080,
6735 +       FLAG_OF = 0x0800,
6736 +};
6737 +
6738 +#define MAGIC_WAITPID_FLAG (FLAG_ZF | FLAG_PF | FLAG_SF | FLAG_OF)
6739 +
6740 +int
6741 +abi_wait(struct pt_regs * regs)
6742 +{
6743 +       mm_segment_t            fs;
6744 +       long                    result, kopt = 0;
6745 +       int                     loc, opt;
6746 +       pid_t                   pid;
6747 +
6748 +       /*
6749 +        * Xenix wait() puts status to edx and returns pid.
6750 +        *
6751 +        * XXX  xenix should get it's own syyent table so we can
6752 +        * XXX  rip this cruft out.
6753 +        */
6754 +       if (is_cur_personality(PER_XENIX)) {
6755 +               fs = get_fs();
6756 +               set_fs(get_ds());
6757 +               result = sys_wait4(-1, &loc, 0, NULL);
6758 +               set_fs(fs);
6759 +
6760 +               regs->edx = loc;
6761 +               return result;
6762 +       }
6763 +
6764 +       /*
6765 +        * if ZF,PF,SF,and OF are set then it is waitpid
6766 +        */
6767 +       if ((regs->eflags & MAGIC_WAITPID_FLAG) == MAGIC_WAITPID_FLAG) {
6768 +               get_user(pid, ((u_long *)regs->esp)+1);
6769 +               get_user(loc, ((u_long *)regs->esp)+2);
6770 +               get_user(opt, ((u_long *)regs->esp)+3);
6771 +
6772 +               /*
6773 +                * Now translate the options from the SVr4 numbers
6774 +                */
6775 +               if (opt & 0100)
6776 +                       kopt |= WNOHANG;
6777 +               if (opt & 4)
6778 +                       kopt |= WUNTRACED;
6779 +
6780 +               result = sys_wait4(pid, (u_int *)loc, kopt, NULL);
6781 +       } else {
6782 +               get_user(loc, ((u_long *)regs->esp)+1);
6783 +               result = sys_wait4(-1, (u_int *)loc, WUNTRACED, NULL);
6784 +       }
6785 +
6786 +       if (result < 0 || !loc)
6787 +               return result;
6788 +
6789 +       get_user(regs->edx, (u_long *)loc);
6790 +       if ((regs->edx & 0xff) == 0x7f) {
6791 +               int             sig;
6792 +
6793 +               sig = (regs->edx >> 8) & 0xff;
6794 +               if (sig < NSIGNALS)
6795 +                       sig = current_thread_info()->exec_domain->signal_map[sig];
6796 +               regs->edx = (regs->edx & (~0xff00)) | (sig << 8);
6797 +               put_user(regs->edx, (u_long *)loc);
6798 +       } else if (regs->edx && regs->edx == (regs->edx & 0xff)) {
6799 +               if ((regs->edx & 0x7f) < NSIGNALS)
6800 +                       regs->edx = current_thread_info()->exec_domain->signal_map[regs->edx & 0x7f];
6801 +               put_user(regs->edx, (u_long *)loc);
6802 +       }
6803 +       return result;
6804 +}
6805 +
6806 +#if defined(CONFIG_ABI_TRACE)
6807 +/*
6808 + * Trace arguments of exec().
6809 + *
6810 + * We show up to twenty arguments and enviroment variables.
6811 + * This could as well be sysctl configurable.
6812 + */
6813 +static void
6814 +trace_exec(struct pt_regs *regs, char *pgm, char **argv, char **envp)
6815 +{
6816 +       char                    **v, *p = NULL, *q = NULL;
6817 +       int                     i;
6818 +
6819 +       q = getname(pgm);
6820 +       if (IS_ERR(q)) {
6821 +               __abi_trace("\tpgm: %p pointer error %ld\n", pgm, PTR_ERR(q));
6822 +       } else {
6823 +               __abi_trace("\tpgm: %p \"%s\"\n", pgm, q);
6824 +               putname(q);
6825 +       }
6826 +
6827 +       for (i = 0, v = argv; v && i < 20; v++, i++) {
6828 +               if (get_user(p, v) || !p)
6829 +                       break;
6830 +
6831 +               q = getname(p);
6832 +               if (IS_ERR(q)) {
6833 +                       __abi_trace("\targ: %p pointer error %ld\n",
6834 +                                       p, PTR_ERR(q));
6835 +               } else {
6836 +                       __abi_trace("\targ: %p \"%s\"\n", p, q);
6837 +                       putname(q);
6838 +               }
6839 +       }
6840 +
6841 +       if (v && p)
6842 +               __abi_trace("\targ: ...\n");
6843 +
6844 +       for (i = 0, v = envp; v && i < 20; v++, i++) {
6845 +               if (get_user(p, v) || !p)
6846 +                       break;
6847 +
6848 +               q = getname(p);
6849 +               if (IS_ERR(q)) {
6850 +                       __abi_trace("\tenv: %p pointer error %ld\n",
6851 +                                       p, PTR_ERR(q));
6852 +               } else {
6853 +                       __abi_trace("\tenv: %p \"%s\"\n", p, q);
6854 +                       putname(q);
6855 +               }
6856 +       }
6857 +
6858 +       if (v && p)
6859 +               __abi_trace("\tenv: ...\n");
6860 +}
6861 +#endif
6862 +
6863 +/*
6864 + * Execute a new program.
6865 + *
6866 + * The difference from the native version is that we
6867 + * optionally trace the arguments.
6868 + */
6869 +int
6870 +abi_exec(struct pt_regs *regs)
6871 +{
6872 +       char            *pgm, **argv, **envp;
6873 +       char            *filename;
6874 +       int             error;
6875 +       u_long          *ulptr;
6876 +
6877 +       ulptr = (u_long *)&pgm;
6878 +       if (get_user(*ulptr, ((u_long *)regs->esp)+1))
6879 +               return -EFAULT;
6880 +       ulptr = (u_long *)&argv;
6881 +       if (get_user(*ulptr, ((u_long *)regs->esp)+2))
6882 +               return -EFAULT;
6883 +       ulptr = (u_long *)&envp;
6884 +       if (get_user(*ulptr, ((u_long *)regs->esp)+3))
6885 +               return -EFAULT;
6886 +
6887 +#if defined(CONFIG_ABI_TRACE)
6888 +       if (abi_traced(ABI_TRACE_API))
6889 +               trace_exec(regs, pgm, argv, envp);
6890 +#endif
6891 +
6892 +       filename = getname(pgm);
6893 +       if (!IS_ERR(filename)) {
6894 +               error = do_execve(filename, argv, envp, regs);
6895 +               putname (filename);
6896 +        } else
6897 +               error = PTR_ERR(filename);
6898 +       return error;
6899 +}
6900 +
6901 +/*
6902 + * Yet another crufy SysV multiplexed syscall.
6903 + * This time it's all the process group and session handling.
6904 + *
6905 + * NOTE: we return EPERM on get_user failures as EFAULT is not
6906 + * a valid return value for theses calls.
6907 + */
6908 +int
6909 +abi_procids(struct pt_regs *regs)
6910 +{
6911 +       int                     offset = 0, op;
6912 +
6913 +       if (get_user(op, ((u_long *)regs->esp)+1))
6914 +               return -EPERM;
6915 +
6916 +       /* Remap op codes for current personality if necessary. */
6917 +       switch (get_cur_personality_id()) {
6918 +       case (PERID_SVR3):
6919 +       case (PERID_SCOSVR3):
6920 +       case (PERID_WYSEV386):
6921 +       case (PERID_XENIX):
6922 +               /*
6923 +                * SCO at least uses an interesting library to
6924 +                * syscall mapping that leaves an extra return
6925 +                * address between the op code and the arguments.
6926 +                *
6927 +                * WTF does SCO at least mean?
6928 +                * Could someone please verify this with another
6929 +                * SVR3 derivate as I have none.
6930 +                *                                      --hch
6931 +                */
6932 +               offset = 1;
6933 +
6934 +               if (op < 0 || op > 5)
6935 +                       return -EINVAL;
6936 +               op = "\000\001\005\003\377\377"[op];
6937 +       }
6938 +
6939 +       switch (op) {
6940 +       case 0: /* getpgrp */
6941 +               return process_group(current);
6942 +
6943 +       case 1: /* setpgrp */
6944 +               sys_setpgid(0, 0);
6945 +               return process_group(current);
6946 +
6947 +       case 2: /* getsid */
6948 +           {
6949 +               pid_t           pid;
6950 +
6951 +               if (get_user(pid, ((u_long *)regs->esp)+2 + offset))
6952 +                       return -EPERM;
6953 +               return sys_getsid(pid);
6954 +           }
6955 +
6956 +       case 3: /* setsid */
6957 +               return sys_setsid();
6958 +
6959 +       case 4: /* getpgid */
6960 +           {
6961 +               pid_t           pid;
6962 +
6963 +               if (get_user(pid, ((u_long *)regs->esp)+2 + offset))
6964 +                       return -EPERM;
6965 +               return sys_getpgid(pid);
6966 +           }
6967 +
6968 +       case 5: /* setpgid */
6969 +           {
6970 +               pid_t           pid, pgid;
6971 +
6972 +               if (get_user(pid, ((u_long *)regs->esp)+2 + offset))
6973 +                       return -EPERM;
6974 +               if (get_user(pgid, ((u_long *)regs->esp)+3 + offset))
6975 +                       return -EPERM;
6976 +               return sys_setpgid(pid, pgid);
6977 +           }
6978 +       }
6979 +
6980 +       return -EINVAL;
6981 +}
6982 +
6983 +
6984 +/*
6985 + * Stupid bloody thing is trying to read a directory.
6986 + *
6987 + * Some old programs expect this to work. It works on SCO.
6988 + * To emulate it we have to map a dirent to a direct. This
6989 + * involves shrinking a long inode to a short. Fortunately
6990 + * nothing this archaic is likely to care about anything
6991 + * but the filenames of entries with non-zero inodes.
6992 + */
6993 +int
6994 +abi_read_dir(int fd, char *buf, int count)
6995 +{
6996 +       struct file             *fp;
6997 +       struct old_linux_dirent *de;
6998 +       mm_segment_t            fs;
6999 +       int                     error, here;
7000 +       int                     posn = 0, reclen = 0;
7001 +
7002 +
7003 +       fp = fget(fd);
7004 +       if (!fp)
7005 +               return -EBADF;
7006 +
7007 +       error = -ENOMEM;
7008 +       de = (struct old_linux_dirent *)__get_free_page(GFP_KERNEL);
7009 +       if (!de)
7010 +               goto out_fput;
7011 +
7012 +       error = 0;
7013 +       while (posn + reclen < count) {
7014 +               char            *p;
7015 +
7016 +               /*
7017 +                * Save the current position and get another dirent
7018 +                */
7019 +               here = fp->f_pos;
7020 +
7021 +               fs = get_fs();
7022 +               set_fs (get_ds());
7023 +               error = old_readdir(fd, de, 1);
7024 +               set_fs(fs);
7025 +
7026 +               if (error <= 0)
7027 +                       break;
7028 +
7029 +               /*
7030 +                * If it'll fit in the buffer save it.
7031 +                * Otherwise back up so it is read next time around.
7032 +                * Oh, if we're at the beginning of the buffer there's
7033 +                * no chance that this entry will ever fit so don't
7034 +                * copy it and don't back off - we'll just pretend it
7035 +                * isn't here...
7036 +                */
7037 +
7038 +               /*
7039 +                * SCO (at least) handles long filenames by breaking
7040 +                * them up in to 14 character chunks of which all
7041 +                * but the last have the inode set to 0xffff.
7042 +                * Those chunks will get aligned to a 4 byte boundary
7043 +                * thus leaving two bytes in each entry for other purposes.
7044 +                *
7045 +                * Well, that's SCO E(A)FS.
7046 +                * HTFS and DTFS should handle it better.
7047 +                *                                      --hch
7048 +                */
7049 +               reclen = 16 * ((de->d_namlen + 13) / 14);
7050 +               if (posn + reclen > count) {
7051 +                       if (posn)
7052 +                               sys_lseek(fd, here, 0);
7053 +                       continue;
7054 +               }
7055 +
7056 +               p = de->d_name;
7057 +
7058 +               /*
7059 +                * Put all but the last chunk.
7060 +                */
7061 +               while (de->d_namlen > 14) {
7062 +                       put_user(0xffff, (u_short *)(buf+posn));
7063 +                       posn += 2;
7064 +                       if (copy_to_user(buf+posn, p, 14))
7065 +                               goto out_fault;
7066 +                       posn += 14;
7067 +                       p += 14;
7068 +                       de->d_namlen -= 14;
7069 +               }
7070 +
7071 +               /*
7072 +                * Put the last chunk. Note the we have to fold a
7073 +                * long inode number down to a short avoiding
7074 +                * giving a zero inode number since that indicates
7075 +                * an unused directory slot. Note also that the
7076 +                * folding used here must match that used in stat()
7077 +                * or path finding programs that do read() on
7078 +                * directories will fail.
7079 +                */
7080 +#if 0
7081 +               /*
7082 +                * This appears to match what SCO does for
7083 +                * reads on a directory with long inodes.
7084 +                */
7085 +               if ((u_long)de->d_ino > 0xfffe) {
7086 +                       if (put_user(0xfffe, buf+posn))
7087 +                               goto out_fault;
7088 +               } else {
7089 +                       if (put_user((short)de->d_ino, buf+posn))
7090 +                               goto out_fault;
7091 +               }
7092 +#else
7093 +               /*
7094 +                * This attempts to match the way stat and
7095 +                * getdents fold long inodes to shorts.
7096 +                */
7097 +               if ((u_long)de->d_ino & 0xffff ) {
7098 +                       if (put_user((u_long)de->d_ino & 0xffff, buf+posn))
7099 +                               goto out_fault;
7100 +               } else {
7101 +                       if (put_user(0xfffe, buf+posn))
7102 +                               goto out_fault;
7103 +               }
7104 +#endif
7105 +               posn += 2;
7106 +               if (copy_to_user(buf+posn, p, de->d_namlen))
7107 +                       goto out_fault;
7108 +
7109 +               /*
7110 +                * Ensure that filenames that don't fill the array
7111 +                * completely are null filled.
7112 +                */
7113 +               for (; de->d_namlen < 14; de->d_namlen++) {
7114 +                       if (put_user('\0', buf+posn+de->d_namlen))
7115 +                               goto out_fault;
7116 +               }
7117 +               posn += 14;
7118 +       }
7119 +
7120 +       free_page((u_long)de);
7121 +       fput(fp);
7122 +
7123 +       /*
7124 +        * If we've put something in the buffer return the byte count
7125 +        * otherwise return the error status.
7126 +        */
7127 +       return (posn ? posn : error);
7128 +
7129 +out_fault:
7130 +       error = -EFAULT;
7131 +       free_page((u_long)de);
7132 +out_fput:
7133 +       fput(fp);
7134 +       return error;
7135 +}
7136 +
7137 +/*
7138 + * We could use Linux read if there wouldn't be the
7139 + * read on directory issue..
7140 + */
7141 +int
7142 +abi_read(int fd, char *buf, int count)
7143 +{
7144 +       int             error;
7145 +
7146 +       error = sys_read(fd, buf, count);
7147 +       if (error == -EISDIR)
7148 +               error = abi_read_dir(fd, buf, count);
7149 +       return error;
7150 +}
7151 +
7152 +/*
7153 + * Linux doesn't allow trailing slashes in mkdir.
7154 + * Old UNIX apps expect it work anyway, so we have
7155 + * to get rid of them here.
7156 + */
7157 +int
7158 +abi_mkdir(const char *fname, int mode)
7159 +{
7160 +       mm_segment_t            fs;
7161 +       char                    *tmp, *p;
7162 +       int                     error;
7163 +
7164 +       tmp = getname(fname);
7165 +       if (IS_ERR(tmp))
7166 +               return PTR_ERR(tmp);
7167 +
7168 +       for (p = tmp; *p; p++);
7169 +               p--;
7170 +       if (*p == '/')
7171 +               *p = '\0';
7172 +
7173 +       fs = get_fs();
7174 +       set_fs(get_ds());
7175 +       error = sys_mkdir(tmp, mode);
7176 +       set_fs(fs);
7177 +
7178 +       putname(tmp);
7179 +       return error;
7180 +}
7181 +
7182 +/*
7183 + * Unlike UNIX Linux doesn't allow to create
7184 + * directories using mknod.
7185 + */
7186 +int
7187 +svr4_mknod(char *filename, svr4_o_mode_t mode, svr4_o_dev_t dev)
7188 +{
7189 +       if ((mode & 0017000) == 0040000)
7190 +               return abi_mkdir(filename, mode);
7191 +       return sys_mknod(filename, mode,
7192 +               MKDEV (SVR4_O_MAJOR (dev), SVR4_O_MINOR (dev)));
7193 +}
7194 +
7195 +static int
7196 +svr4_do_xmknod(char *filename, svr4_mode_t mode, svr4_dev_t dev)
7197 +{
7198 +       u_int minor = SVR4_MINOR (dev), major = SVR4_MAJOR (dev);
7199 +
7200 +       if (minor > 0xff || major > 0xff)
7201 +               return -EINVAL;
7202 +       return svr4_mknod(filename, mode, SVR4_O_MKDEV (major, minor));
7203 +}
7204 +
7205 +
7206 +enum {SVR4_mknod = 1, SVR4_xmknod = 2};
7207 +
7208 +int
7209 +svr4_xmknod(int vers, char *filename, svr4_mode_t mode, svr4_dev_t dev)
7210 +{
7211 +       switch (vers) {
7212 +       case SVR4_mknod:
7213 +               return svr4_mknod(filename, mode, dev);
7214 +       case SVR4_xmknod:
7215 +               return svr4_do_xmknod(filename, mode, dev);
7216 +       }
7217 +
7218 +#if defined(CONFIG_ABI_TRACE)
7219 +       abi_trace(ABI_TRACE_API, "xmknod version %d not supported\n", vers);
7220 +#endif
7221 +       return -EINVAL;
7222 +}
7223 +
7224 +int
7225 +abi_kill(int pid, int sig)
7226 +{
7227 +       int insig, outsig;
7228 +
7229 +       insig = (sig & 0xff);
7230 +       outsig = current_thread_info()->exec_domain->signal_map[insig];
7231 +
7232 +#if defined(CONFIG_ABI_TRACE)
7233 +       abi_trace(ABI_TRACE_SIGNAL, "kill: %d -> %d\n", insig, outsig);
7234 +#endif
7235 +
7236 +       return sys_kill(pid, outsig);
7237 +}
7238 +
7239 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
7240 +EXPORT_SYMBOL(abi_brk);
7241 +EXPORT_SYMBOL(abi_exec);
7242 +EXPORT_SYMBOL(abi_fork);
7243 +EXPORT_SYMBOL(abi_getgid);
7244 +EXPORT_SYMBOL(abi_getpid);
7245 +EXPORT_SYMBOL(abi_getuid);
7246 +EXPORT_SYMBOL(abi_kill);
7247 +EXPORT_SYMBOL(abi_mkdir);
7248 +EXPORT_SYMBOL(abi_pipe);
7249 +EXPORT_SYMBOL(abi_procids);
7250 +EXPORT_SYMBOL(abi_read);
7251 +EXPORT_SYMBOL(abi_time);
7252 +EXPORT_SYMBOL(abi_wait);
7253 +EXPORT_SYMBOL(svr4_mknod);
7254 +EXPORT_SYMBOL(svr4_xmknod);
7255 +#endif
7256 diff -Nur kernel-source-2.6.16.orig/abi/svr4/mmap.c kernel-source-2.6.16/abi/svr4/mmap.c
7257 --- kernel-source-2.6.16.orig/abi/svr4/mmap.c   1970-01-01 10:00:00.000000000 +1000
7258 +++ kernel-source-2.6.16/abi/svr4/mmap.c        2006-04-27 18:50:24.000000000 +1000
7259 @@ -0,0 +1,75 @@
7260 +/*
7261 + * Copyright (c) 2001 Christoph Hellwig.
7262 + * All rights reserved.
7263 + *
7264 + * This program is free software; you can redistribute it and/or modify
7265 + * it under the terms of the GNU General Public License as published by
7266 + * the Free Software Foundation; either version 2 of the License, or
7267 + * (at your option) any later version.
7268 + *
7269 + * This program is distributed in the hope that it will be useful,
7270 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7271 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7272 + * GNU General Public License for more details.
7273 + *
7274 + * You should have received a copy of the GNU General Public License
7275 + * along with this program; if not, write to the Free Software
7276 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
7277 + */
7278 +
7279 +#ident "%W% %G%"
7280 +
7281 +/*
7282 + * Support for mmap on SVR4 and derivates.
7283 + */
7284 +#include <linux/mm.h>
7285 +#include <linux/errno.h>
7286 +#include <linux/file.h>
7287 +#include <linux/mman.h>
7288 +#include <linux/module.h>
7289 +
7290 +#include <asm/uaccess.h>
7291 +
7292 +#include <abi/svr4/mman.h>
7293 +#include <abi/svr4/types.h>
7294 +
7295 +#include <abi/util/trace.h>
7296 +
7297 +
7298 +u_long
7299 +svr4_mmap(u_long addr, size_t len, int prot, int flags, int fd, svr4_off_t off)
7300 +{
7301 +       struct file *file = NULL;
7302 +       u_long mapaddr;
7303 +
7304 +       if (flags & SVR4_MAP_UNIMPL) {
7305 +#if defined(CONFIG_ABI_TRACE)
7306 +               abi_trace(ABI_TRACE_UNIMPL,
7307 +                   "unsupported mmap flags: 0x%x\n", flags & SVR4_MAP_UNIMPL);
7308 +#endif
7309 +               flags &= ~SVR4_MAP_UNIMPL;
7310 +       }
7311 +
7312 +       if (!(flags & SVR4_MAP_ANONYMOUS)) {
7313 +               file = fget(fd);
7314 +               if (!file)
7315 +                       goto Ebadfd;
7316 +
7317 +               flags &= ~SVR4_MAP_ANONYMOUS;
7318 +               flags |= MAP_ANONYMOUS;
7319 +       }
7320 +
7321 +       down_write(&current->mm->mmap_sem);
7322 +       mapaddr = do_mmap(file, addr, len, prot, flags, off);
7323 +       up_write(&current->mm->mmap_sem);
7324 +
7325 +       if (file)
7326 +               fput(file);
7327 +       return mapaddr;
7328 +Ebadfd:
7329 +       return -EBADFD;
7330 +}
7331 +
7332 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
7333 +EXPORT_SYMBOL(svr4_mmap);
7334 +#endif
7335 diff -Nur kernel-source-2.6.16.orig/abi/svr4/open.c kernel-source-2.6.16/abi/svr4/open.c
7336 --- kernel-source-2.6.16.orig/abi/svr4/open.c   1970-01-01 10:00:00.000000000 +1000
7337 +++ kernel-source-2.6.16/abi/svr4/open.c        2006-04-27 18:50:24.000000000 +1000
7338 @@ -0,0 +1,322 @@
7339 +/*
7340 + * Copyright (c) 1993  Joe Portman (baron@hebron.connected.com)
7341 + * Copyright (c) 1993, 1994  Drew Sullivan (re-worked for iBCS2)
7342 + * Copyright (c) 2000  Christoph Hellwig (rewrote lookup-related code)
7343 + */
7344 +
7345 +#ident "%W% %G%"
7346 +
7347 +#include <linux/config.h>
7348 +#include <linux/module.h>
7349 +
7350 +#include <linux/vfs.h>
7351 +#include <linux/types.h>
7352 +#include <linux/utime.h>
7353 +#include <linux/errno.h>
7354 +#include <linux/fcntl.h>
7355 +#include <linux/stat.h>
7356 +#include <linux/string.h>
7357 +#include <linux/sched.h>
7358 +#include <linux/kernel.h>
7359 +#include <linux/signal.h>
7360 +#include <linux/tty.h>
7361 +#include <linux/time.h>
7362 +#include <linux/slab.h>
7363 +#include <linux/socket.h>
7364 +#include <linux/net.h>
7365 +#include <linux/un.h>
7366 +#include <linux/file.h>
7367 +#include <linux/dirent.h>
7368 +#include <linux/personality.h>
7369 +#include <linux/syscalls.h>
7370 +#include <linux/namei.h>
7371 +
7372 +#include <asm/uaccess.h>
7373 +#include <asm/bitops.h>
7374 +
7375 +#include <asm/abi_machdep.h>
7376 +#include <abi/svr4/statfs.h>
7377 +#include <abi/svr4/sysent.h>
7378 +
7379 +#include <abi/util/trace.h>
7380 +#include <abi/util/map.h>
7381 +
7382 +
7383 +static int
7384 +copy_kstatfs(struct svr4_statfs *buf, struct kstatfs *st)
7385 +{
7386 +       struct svr4_statfs ibcsstat;
7387 +
7388 +       ibcsstat.f_type = st->f_type;
7389 +       ibcsstat.f_bsize = st->f_bsize;
7390 +       ibcsstat.f_frsize = 0;
7391 +       ibcsstat.f_blocks = st->f_blocks;
7392 +       ibcsstat.f_bfree = st->f_bfree;
7393 +       ibcsstat.f_files = st->f_files;
7394 +       ibcsstat.f_ffree = st->f_ffree;
7395 +       memset(ibcsstat.f_fname, 0, sizeof(ibcsstat.f_fname));
7396 +       memset(ibcsstat.f_fpack, 0, sizeof(ibcsstat.f_fpack));
7397 +
7398 +       /* Finally, copy it to the user's buffer */
7399 +       return copy_to_user(buf, &ibcsstat, sizeof(struct svr4_statfs));
7400 +}
7401 +
7402 +int svr4_statfs(const char * path, struct svr4_statfs * buf, int len, int fstype)
7403 +{
7404 +       struct svr4_statfs ibcsstat;
7405 +
7406 +       if (len > (int)sizeof(struct svr4_statfs))
7407 +               return -EINVAL;
7408 +
7409 +       if (!fstype) {
7410 +               struct nameidata nd;
7411 +               int error;
7412 +
7413 +               error = user_path_walk(path, &nd);
7414 +               if (!error) {
7415 +                       struct kstatfs tmp;
7416 +
7417 +                       error = vfs_statfs(nd.dentry->d_inode->i_sb, &tmp);
7418 +                       if (!error && copy_kstatfs(buf, &tmp))
7419 +                               error = -EFAULT;
7420 +                       path_release(&nd);
7421 +               }
7422 +
7423 +               return error;
7424 +       }
7425 +
7426 +       /*
7427 +        * Linux can't stat unmounted filesystems so we
7428 +        * simply lie and claim 500MB of 8GB is free. Sorry.
7429 +        */
7430 +       ibcsstat.f_bsize = 1024;
7431 +       ibcsstat.f_frsize = 0;
7432 +       ibcsstat.f_blocks = 8 * 1024 * 1024;    /* 8GB */
7433 +       ibcsstat.f_bfree = 500 * 1024;          /* 100MB */
7434 +       ibcsstat.f_files = 60000;
7435 +       ibcsstat.f_ffree = 50000;
7436 +       memset(ibcsstat.f_fname, 0, sizeof(ibcsstat.f_fname));
7437 +       memset(ibcsstat.f_fpack, 0, sizeof(ibcsstat.f_fpack));
7438 +
7439 +       /* Finally, copy it to the user's buffer */
7440 +       return copy_to_user(buf, &ibcsstat, len) ? -EFAULT : 0;
7441 +}
7442 +
7443 +int svr4_fstatfs(unsigned int fd, struct svr4_statfs * buf, int len, int fstype)
7444 +{
7445 +       struct svr4_statfs ibcsstat;
7446 +
7447 +       if (len > (int)sizeof(struct svr4_statfs))
7448 +               return -EINVAL;
7449 +
7450 +       if (!fstype) {
7451 +               struct file * file;
7452 +               struct kstatfs tmp;
7453 +               int error;
7454 +
7455 +               error = -EBADF;
7456 +               file = fget(fd);
7457 +               if (!file)
7458 +                       goto out;
7459 +               error = vfs_statfs(file->f_dentry->d_inode->i_sb, &tmp);
7460 +               if (!error && copy_kstatfs(buf, &tmp))
7461 +                       error = -EFAULT;
7462 +               fput(file);
7463 +
7464 +out:
7465 +               return error;
7466 +       }
7467 +
7468 +       /*
7469 +        * Linux can't stat unmounted filesystems so we
7470 +        * simply lie and claim 500MB of 8GB is free. Sorry.
7471 +        */
7472 +       ibcsstat.f_bsize = 1024;
7473 +       ibcsstat.f_frsize = 0;
7474 +       ibcsstat.f_blocks = 8 * 1024 * 1024;    /* 8GB */
7475 +       ibcsstat.f_bfree = 500 * 1024;          /* 100MB */
7476 +       ibcsstat.f_files = 60000;
7477 +       ibcsstat.f_ffree = 50000;
7478 +       memset(ibcsstat.f_fname, 0, sizeof(ibcsstat.f_fname));
7479 +       memset(ibcsstat.f_fpack, 0, sizeof(ibcsstat.f_fpack));
7480 +
7481 +       /* Finally, copy it to the user's buffer */
7482 +       return copy_to_user(buf, &ibcsstat, len) ? -EFAULT : 0;
7483 +}
7484 +
7485 +int svr4_open(const char *fname, int flag, int mode)
7486 +{
7487 +#ifdef __sparc__
7488 +       return sys_open(fname, map_flags(flag, fl_svr4_to_linux), mode);
7489 +#else
7490 +       u_long args[3];
7491 +       int error, fd;
7492 +       struct file *file;
7493 +       mm_segment_t old_fs;
7494 +       char *p;
7495 +       struct sockaddr_un addr;
7496 +
7497 +       fd = sys_open(fname, map_flags(flag, fl_svr4_to_linux), mode);
7498 +       if (fd < 0)
7499 +               return fd;
7500 +
7501 +       /* Sometimes a program may open a pathname which it expects
7502 +        * to be a named pipe (or STREAMS named pipe) when the
7503 +        * Linux domain equivalent is a Unix domain socket. (e.g.
7504 +        * UnixWare uses a STREAMS named pipe /dev/X/Nserver.0 for
7505 +        * X :0 but Linux uses a Unix domain socket /tmp/.X11-unix/X0)
7506 +        * It isn't enough just to make the symlink because you cannot
7507 +        * open() a socket and read/write it. If we spot the error we can
7508 +        * switch to socket(), connect() and things will likely work
7509 +        * as expected however.
7510 +        */
7511 +       file = fget(fd);
7512 +       if (!file)
7513 +               return fd; /* Huh?!? */
7514 +       if (!S_ISSOCK(file->f_dentry->d_inode->i_mode)) {
7515 +               fput(file);
7516 +               return fd;
7517 +       }
7518 +       fput(file);
7519 +
7520 +       sys_close(fd);
7521 +       args[0] = AF_UNIX;
7522 +       args[1] = SOCK_STREAM;
7523 +       args[2] = 0;
7524 +       old_fs = get_fs();
7525 +       set_fs(get_ds());
7526 +       fd = sys_socketcall(SYS_SOCKET, args);
7527 +       set_fs(old_fs);
7528 +       if (fd < 0)
7529 +               return fd;
7530 +
7531 +       p = getname(fname);
7532 +       if (IS_ERR(p)) {
7533 +               sys_close(fd);
7534 +               return PTR_ERR(p);
7535 +       }
7536 +       if (strlen(p) >= UNIX_PATH_MAX) {
7537 +               putname(p);
7538 +               sys_close(fd);
7539 +               return -E2BIG;
7540 +       }
7541 +       addr.sun_family = AF_UNIX;
7542 +       strcpy(addr.sun_path, p);
7543 +       putname(p);
7544 +
7545 +       args[0] = fd;
7546 +       args[1] = (int)&addr;
7547 +       args[2] = sizeof(struct sockaddr_un);
7548 +       set_fs(get_ds());
7549 +       error = sys_socketcall(SYS_CONNECT, args);
7550 +       set_fs(old_fs);
7551 +       if (error) {
7552 +               sys_close(fd);
7553 +               return error;
7554 +       }
7555 +
7556 +       return fd;
7557 +#endif
7558 +}
7559 +
7560 +#define NAME_OFFSET(de)        ((int) ((de)->d_name - (char *) (de)))
7561 +#define ROUND_UP(x)    (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
7562 +
7563 +struct svr4_getdents_callback {
7564 +       struct dirent * current_dir;
7565 +       struct dirent * previous;
7566 +       int count;
7567 +       int error;
7568 +};
7569 +
7570 +static int svr4_filldir(void * __buf, const char * name, int namlen,
7571 +       loff_t offset, ino_t ino, unsigned int d_type)
7572 +{
7573 +       struct dirent * dirent;
7574 +       struct svr4_getdents_callback * buf = (struct svr4_getdents_callback *) __buf;
7575 +       int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
7576 +
7577 +       buf->error = -EINVAL;   /* only used if we fail.. */
7578 +       if (reclen > buf->count)
7579 +               return -EINVAL;
7580 +
7581 +       dirent = buf->previous;
7582 +       if (dirent)
7583 +               put_user(offset, &dirent->d_off);
7584 +       dirent = buf->current_dir;
7585 +       buf->previous = dirent;
7586 +
7587 +       if (is_cur_personality_flag(PERF_SHORT_INODE)) {
7588 +               /* read() on a directory only handles
7589 +                * short inodes but cannot use 0 as that
7590 +                * indicates an empty directory slot.
7591 +                * Therefore stat() must also fold
7592 +                * inode numbers avoiding 0. Which in
7593 +                * turn means that getdents() must fold
7594 +                * inodes avoiding 0 - if the program
7595 +                * was built in a short inode environment.
7596 +                * If we have short inodes in the dirent
7597 +                * we also have a two byte pad so we
7598 +                * can let the high word fall in the pad.
7599 +                * This makes it a little more robust if
7600 +                * we guessed the inode size wrong.
7601 +                */
7602 +               if (!((unsigned long)dirent->d_ino & 0xffff))
7603 +                       dirent->d_ino = 0xfffffffe;
7604 +       }
7605 +
7606 +       put_user(ino, &dirent->d_ino);
7607 +       put_user(reclen, &dirent->d_reclen);
7608 +       if (copy_to_user(dirent->d_name, name, namlen))
7609 +               return -EFAULT;
7610 +       put_user(0, dirent->d_name + namlen);
7611 +       {       char *ptr = (char *)dirent;
7612 +               ptr += reclen;
7613 +               dirent = (struct dirent *)ptr;
7614 +       }
7615 +       buf->current_dir = dirent;
7616 +       buf->count -= reclen;
7617 +       return 0;
7618 +}
7619 +
7620 +
7621 +
7622 +int svr4_getdents(int fd, char *dirent, int count)
7623 +{
7624 +       struct file * file;
7625 +       struct dirent * lastdirent;
7626 +       struct svr4_getdents_callback buf;
7627 +       int error;
7628 +
7629 +       error = -EBADF;
7630 +       file = fget(fd);
7631 +       if (!file)
7632 +               goto out;
7633 +
7634 +       buf.current_dir = (struct dirent *) dirent;
7635 +       buf.previous = NULL;
7636 +       buf.count = count;
7637 +       buf.error = 0;
7638 +       error = vfs_readdir(file, svr4_filldir, &buf);
7639 +       if (error < 0)
7640 +               goto out_putf;
7641 +       error = buf.error;
7642 +       lastdirent = buf.previous;
7643 +       if (lastdirent) {
7644 +               put_user(file->f_pos, &lastdirent->d_off);
7645 +               error = count - buf.count;
7646 +       }
7647 +
7648 +out_putf:
7649 +       fput(file);
7650 +
7651 +out:
7652 +       return error;
7653 +}
7654 +
7655 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
7656 +EXPORT_SYMBOL(svr4_fstatfs);
7657 +EXPORT_SYMBOL(svr4_getdents);
7658 +EXPORT_SYMBOL(svr4_open);
7659 +EXPORT_SYMBOL(svr4_statfs);
7660 +#endif
7661 diff -Nur kernel-source-2.6.16.orig/abi/svr4/signal.c kernel-source-2.6.16/abi/svr4/signal.c
7662 --- kernel-source-2.6.16.orig/abi/svr4/signal.c 1970-01-01 10:00:00.000000000 +1000
7663 +++ kernel-source-2.6.16/abi/svr4/signal.c      2006-04-27 18:50:24.000000000 +1000
7664 @@ -0,0 +1,530 @@
7665 +/*
7666 + * signal.c - signal emulation code
7667 + *
7668 + *  This module does not go through the normal processing routines for
7669 + *  ibcs. The reason for this is that for most events, the return is a
7670 + *  procedure address for the previous setting. This procedure address
7671 + *  may be negative which is not an error. Therefore, the return processing
7672 + *  for standard functions is skipped by declaring this routine as a "special"
7673 + *  module for the decoder and dealing with the register settings directly.
7674 + *
7675 + * Please consider this closely if you plan on changing this mode.
7676 + * -- Al Longyear
7677 + */
7678 +
7679 +#ident "%W% %G%"
7680 +
7681 +#include <linux/module.h>
7682 +#include <linux/errno.h>
7683 +#include <linux/sched.h>
7684 +#include <linux/kernel.h>
7685 +#include <linux/mm.h>
7686 +#include <linux/stddef.h>
7687 +#define __KERNEL_SYSCALLS__
7688 +#include <linux/unistd.h>
7689 +#include <linux/ptrace.h>
7690 +#include <linux/fcntl.h>
7691 +#include <linux/personality.h>
7692 +#include <linux/fs.h>
7693 +#include <linux/sys.h>
7694 +#include <linux/signal.h>
7695 +#include <linux/syscalls.h>
7696 +
7697 +#include <asm/system.h>
7698 +#include <asm/uaccess.h>
7699 +
7700 +#include <abi/util/map.h>
7701 +#include <abi/util/errno.h>
7702 +#include <abi/util/trace.h>
7703 +
7704 +
7705 +#define SIG_HOLD       ((__sighandler_t)2)     /* hold signal */
7706 +
7707 +#include <abi/signal.h>
7708 +#include <abi/svr4/sigaction.h>
7709 +
7710 +typedef void (*pfn) (void);     /* Completion function */
7711 +
7712 +/*
7713 + * Parameters to the signal functions have a common stack frame. This
7714 + * defines the stack frame.
7715 + */
7716 +#define SIGNAL_NUMBER(regp)    get_syscall_parameter((regp), 0)
7717 +#define HIDDEN_PARAM(regp)     (SIGNAL_NUMBER((regp)) & ~0xFF)
7718 +#define SECOND_PARAM(regp)     get_syscall_parameter((regp), 1)
7719 +#define THIRD_PARAM(regp)      ((u_long)(regp)->edx)
7720 +
7721 +/* Return a mask that includes SIG only.  */
7722 +#define __sigmask(sig)         (1 << ((sig) - 1))
7723 +#define _S(nr)                 (1 << ((nr) - 1))
7724 +#define _BLOCKABLE             (~(_S(IBCS_SIGKILL) | _S(IBCS_SIGSTOP)))
7725 +
7726 +
7727 +static __inline int
7728 +abi_signal_suspend(struct pt_regs *regs, old_sigset_t mask)
7729 +{
7730 +       return signal_suspend(regs, mask);
7731 +}
7732 +
7733 +
7734 +void
7735 +deactivate_signal(struct task_struct *task, int signum)
7736 +{
7737 +       spin_lock_irq(&task->sighand->siglock);
7738 +       sigdelset(&task->pending.signal, signum);
7739 +       recalc_sigpending();
7740 +       spin_unlock_irq(&task->sighand->siglock);
7741 +}
7742 +
7743 +/*
7744 + *  Translate the signal number to the corresponding item for Linux.
7745 + */
7746 +static __inline int
7747 +abi_mapsig(int sig)
7748 +{
7749 +       if ((u_int)sig >= NSIGNALS)
7750 +               return (-1);
7751 +       return (current_thread_info()->exec_domain->signal_map[sig]);
7752 +}
7753 +
7754 +/*
7755 + * Either we want this static or in a header...
7756 + */
7757 +__inline int
7758 +abi_signo(struct pt_regs *regp, int *sigp)
7759 +{
7760 +       int                     value;
7761 +
7762 +       value = abi_mapsig(SIGNAL_NUMBER(regp) & 0xFF);
7763 +       if (value == -1) {
7764 +               set_error(regp, iABI_errors(EINVAL));
7765 +               return 0;
7766 +       } else {
7767 +               *sigp = value;
7768 +               return 1;
7769 +       }
7770 +}
7771 +
7772 +/*
7773 + * Process the signal() function from iBCS
7774 + *
7775 + * This version appeared in "Advanced Programming in the Unix Environment"
7776 + * by W. Richard Stevens, page 298.
7777 + */
7778 +void
7779 +abi_sig_handler(struct pt_regs *regp, int sig,
7780 +               __sighandler_t handler, int oneshot)
7781 +{
7782 +       struct sigaction        act, oact;
7783 +       mm_segment_t            fs;
7784 +       int                     error;
7785 +
7786 +       sigemptyset(&act.sa_mask);
7787 +       act.sa_restorer = NULL;
7788 +       act.sa_handler = handler;
7789 +       act.sa_flags = 0;
7790 +
7791 +       if (oneshot)
7792 +               act.sa_flags |= SA_ONESHOT | SA_NOMASK;
7793 +
7794 +       fs = get_fs();
7795 +       set_fs(get_ds());
7796 +       error = sys_rt_sigaction(sig, &act, &oact, sizeof(sigset_t));
7797 +       set_fs(fs);
7798 +
7799 +       if (error < 0) {
7800 +               set_error(regp, iABI_errors(-error));
7801 +       } else {
7802 +               set_result(regp, (int)oact.sa_handler);
7803 +       }
7804 +}
7805 +
7806 +/*
7807 + * Process the signal() function from iBCS
7808 + */
7809 +int
7810 +abi_signal(struct pt_regs *regp)
7811 +{
7812 +       __sighandler_t  vec;
7813 +       int             sig;
7814 +
7815 +       if (abi_signo(regp, &sig)) {
7816 +               vec = (__sighandler_t)SECOND_PARAM(regp);
7817 +               abi_sig_handler(regp, sig, vec, 1);
7818 +       }
7819 +
7820 +       return 0;
7821 +}
7822 +
7823 +/*
7824 + * Process the SVR4 sigset function.
7825 + *
7826 + * This is basically the same as the signal() routine with the
7827 + * exception that it will accept a SIG_HOLD parameter.
7828 + *
7829 + * A SIG_HOLD will defer the processing of the signal until a sigrelse()
7830 + * function is called or the signal handler is set again using this function.
7831 + */
7832 +int
7833 +abi_sigset(struct pt_regs *regp)
7834 +{
7835 +       int             sig, error;
7836 +       sigset_t        newmask, oldmask;
7837 +       __sighandler_t  vec;
7838 +       mm_segment_t    fs;
7839 +       int             action;
7840 +
7841 +
7842 +       if (abi_signo(regp, &sig) == 0)
7843 +               return 0;
7844 +
7845 +       vec = (__sighandler_t)SECOND_PARAM(regp);
7846 +       action = SIG_BLOCK;
7847 +
7848 +       if (vec != SIG_HOLD) {
7849 +               action = SIG_UNBLOCK;
7850 +               deactivate_signal(current, sig);
7851 +               abi_sig_handler(regp, sig, vec, 0);
7852 +       }
7853 +
7854 +       /*
7855 +        * Process the signal hold/unhold function.
7856 +        */
7857 +       sigemptyset(&newmask);
7858 +       sigaddset(&newmask, sig);
7859 +
7860 +       fs = get_fs();
7861 +       set_fs(get_ds());
7862 +       error = sys_rt_sigprocmask(action, &newmask, &oldmask,
7863 +               sizeof(sigset_t));
7864 +       set_fs(fs);
7865 +
7866 +       if (error < 0)
7867 +               set_error(regp, iABI_errors(-error));
7868 +
7869 +       return 0;
7870 +}
7871 +
7872 +/*
7873 + * Process the iBCS sighold function.
7874 + *
7875 + * Suspend the signal from future recognition.
7876 + */
7877 +void
7878 +abi_sighold(struct pt_regs *regp)
7879 +{
7880 +       sigset_t        newmask, oldmask;
7881 +       int             error, sig;
7882 +       mm_segment_t    fs;
7883 +
7884 +       if (!abi_signo(regp, &sig))
7885 +               return;
7886 +
7887 +       sigemptyset(&newmask);
7888 +       sigaddset(&newmask, sig);
7889 +
7890 +       fs = get_fs();
7891 +       set_fs(get_ds());
7892 +       error = sys_rt_sigprocmask(SIG_BLOCK, &newmask,
7893 +                       &oldmask, sizeof(sigset_t));
7894 +       set_fs(fs);
7895 +
7896 +       if (error < 0)
7897 +               set_error(regp, iABI_errors(-error));
7898 +}
7899 +
7900 +/*
7901 + * Process the iBCS sigrelse.
7902 + *
7903 + * Re-enable the signal processing from a previously suspended
7904 + * signal. This may have been done by calling the sighold() function
7905 + * or a longjmp() during the signal processing routine. If you do a
7906 + * longjmp() function then it is expected that you will call sigrelse
7907 + * or set the handler again using sigset before going on with the program.
7908 + */
7909 +void
7910 +abi_sigrelse(struct pt_regs *regp)
7911 +{
7912 +       sigset_t        newmask, oldmask;
7913 +       int             error, sig;
7914 +       mm_segment_t    fs;
7915 +
7916 +       if (!abi_signo(regp, &sig))
7917 +               return;
7918 +
7919 +       sigemptyset(&newmask);
7920 +       sigaddset(&newmask, sig);
7921 +
7922 +       fs = get_fs();
7923 +       set_fs(get_ds());
7924 +       error = sys_rt_sigprocmask(SIG_UNBLOCK, &newmask,
7925 +                       &oldmask, sizeof(sigset_t));
7926 +       set_fs(fs);
7927 +
7928 +       if (error < 0)
7929 +               set_error(regp, iABI_errors(-error));
7930 +}
7931 +
7932 +/*
7933 + * Process the iBCS sigignore
7934 + *
7935 + * This is basically a signal (...,SIG_IGN) call.
7936 + */
7937 +void
7938 +abi_sigignore(struct pt_regs *regp)
7939 +{
7940 +       struct sigaction        act, oact;
7941 +       int                     error, sig;
7942 +       mm_segment_t            fs;
7943 +
7944 +       if (!abi_signo(regp, &sig))
7945 +               return;
7946 +
7947 +       sigemptyset(&act.sa_mask);
7948 +
7949 +       act.sa_restorer = NULL;
7950 +       act.sa_handler = SIG_IGN;
7951 +       act.sa_flags   = 0;
7952 +
7953 +       fs = get_fs();
7954 +       set_fs(get_ds());
7955 +       error = sys_rt_sigaction(sig, &act, &oact, sizeof(sigset_t));
7956 +       set_fs(fs);
7957 +
7958 +       if (error < 0)
7959 +               set_error(regp, iABI_errors(-error));
7960 +}
7961 +
7962 +/*
7963 + * Process the iBCS sigpause
7964 + *
7965 + * Wait for the signal indicated to arrive before resuming the
7966 + * processing. I do not know if the signal is processed first using
7967 + * the normal event processing before the return. If someone can
7968 + * shed some light on this then please correct this code. I block
7969 + * the signal and look for it to show up in the pending list.
7970 + */
7971 +void
7972 +abi_sigpause(struct pt_regs *regs)
7973 +{
7974 +       old_sigset_t            newset;
7975 +       int                     error, sig;
7976 +
7977 +       if (!abi_signo(regs, &sig))
7978 +               return;
7979 +       newset = (~0UL) & (1UL << (sig-1));
7980 +
7981 +       if ((error = abi_signal_suspend(regs, newset) < 0))
7982 +               set_error(regs, iABI_errors(-error));
7983 +}
7984 +
7985 +/*
7986 + * This is the service routine for the syscall #48 (signal funcs).
7987 + *
7988 + * Examine the request code and branch on the request to the appropriate
7989 + * function.
7990 + */
7991 +int
7992 +abi_sigfunc(struct pt_regs *regp)
7993 +{
7994 +       int                     sig_type = (int)HIDDEN_PARAM(regp);
7995 +
7996 +#if defined(CONFIG_ABI_TRACE)
7997 +       abi_trace(ABI_TRACE_SIGNAL|ABI_TRACE_SIGNAL_F,
7998 +               "sig%s(%ld, 0x%08lx, 0x%08lx)\n",
7999 +                       sig_type == 0 ? "nal"
8000 +                       : (sig_type == 0x100 ? "set"
8001 +                       : (sig_type == 0x200 ? "hold"
8002 +                       : (sig_type == 0x400 ? "relse"
8003 +                       : (sig_type == 0x800 ? "ignore"
8004 +                       : (sig_type == 0x1000 ? "pause"
8005 +                       : "???" ))))),
8006 +                       SIGNAL_NUMBER(regp) & 0xff,
8007 +                       SECOND_PARAM(regp),
8008 +                       THIRD_PARAM(regp));
8009 +#endif
8010 +
8011 +       regp->eflags &= ~1;
8012 +       regp->eax     = 0;
8013 +
8014 +       switch (sig_type) {
8015 +       case 0x0000:
8016 +               abi_signal(regp);
8017 +               break;
8018 +       case 0x0100:
8019 +               abi_sigset(regp);
8020 +               break;
8021 +       case 0x0200:
8022 +               abi_sighold(regp);
8023 +               break;
8024 +       case 0x0400:
8025 +               abi_sigrelse(regp);
8026 +               break;
8027 +       case 0x0800:
8028 +               abi_sigignore(regp);
8029 +               break;
8030 +       case 0x1000:
8031 +               abi_sigpause(regp);
8032 +               break;
8033 +       default:
8034 +               set_error(regp, EINVAL);
8035 +
8036 +#if defined(CONFIG_ABI_TRACE)
8037 +               abi_trace(ABI_TRACE_SIGNAL|ABI_TRACE_SIGNAL_F,
8038 +                               "sigfunc(%x, %ld, %lx, %lx) unsupported\n",
8039 +                               sig_type, SIGNAL_NUMBER(regp),
8040 +                               SECOND_PARAM(regp), THIRD_PARAM(regp));
8041 +#endif
8042 +               return 0;
8043 +       }
8044 +
8045 +#if defined(CONFIG_ABI_TRACE)
8046 +       abi_trace(ABI_TRACE_SIGNAL|ABI_TRACE_SIGNAL_F,
8047 +                       "returns %d\n", get_result(regp));
8048 +#endif
8049 +       return 0;
8050 +}
8051 +
8052 +/*
8053 + * This function is used to handle the sigaction call from SVr4 binaries.
8054 + *
8055 + * If anyone else uses this, this function needs to be modified since the
8056 + * order and size of the ibcs_sigaction structure is different in ibcs
8057 + * and the SVr4 ABI
8058 + */
8059 +asmlinkage int
8060 +abi_sigaction(int abi_signum, const struct abi_sigaction *action,
8061 +               struct abi_sigaction *oldaction)
8062 +{
8063 +       struct abi_sigaction    new_sa, old_sa;
8064 +       struct sigaction        nsa, osa;
8065 +       mm_segment_t            fs;
8066 +       int                     error, signo;
8067 +
8068 +       signo = abi_mapsig(abi_signum);
8069 +       if (signo == -1)
8070 +               return -EINVAL;
8071 +
8072 +       if (oldaction) {
8073 +               if (!access_ok(VERIFY_WRITE, oldaction,
8074 +                               sizeof(struct abi_sigaction)))
8075 +                       return (-EFAULT);
8076 +       }
8077 +
8078 +       if (action) {
8079 +               error = copy_from_user(&new_sa, action,
8080 +                               sizeof(struct abi_sigaction));
8081 +               if (error)
8082 +                       return (-EFAULT);
8083 +               nsa.sa_restorer = NULL;
8084 +               nsa.sa_handler = new_sa.sa_handler;
8085 +               nsa.sa_mask = map_sigvec_to_kernel(new_sa.sa_mask,
8086 +                       current_thread_info()->exec_domain->signal_map);
8087 +               if (new_sa.sa_flags & ABI_SA_ONSTACK)
8088 +                       nsa.sa_flags |= SA_ONSTACK;
8089 +               if (new_sa.sa_flags & ABI_SA_RESTART)
8090 +                       nsa.sa_flags |= SA_RESTART;
8091 +               if (new_sa.sa_flags & ABI_SA_NODEFER)
8092 +                       nsa.sa_flags |= SA_NODEFER;
8093 +               if (new_sa.sa_flags & ABI_SA_RESETHAND)
8094 +                       nsa.sa_flags |= SA_RESETHAND;
8095 +               if (new_sa.sa_flags & ABI_SA_NOCLDSTOP)
8096 +                       nsa.sa_flags |= SA_NOCLDSTOP;
8097 +               if (new_sa.sa_flags & ABI_SA_NOCLDWAIT)
8098 +                       nsa.sa_flags |= SA_NOCLDWAIT;
8099 +       }
8100 +
8101 +       fs = get_fs();
8102 +       set_fs(get_ds());
8103 +       error = sys_rt_sigaction(signo, action ? &nsa : NULL,
8104 +                       oldaction ? &osa : NULL, sizeof(sigset_t));
8105 +       set_fs(fs);
8106 +
8107 +       if (error || !oldaction)
8108 +               return (error);
8109 +
8110 +       old_sa.sa_handler = osa.sa_handler;
8111 +       old_sa.sa_mask = map_sigvec_from_kernel(osa.sa_mask,
8112 +                       current_thread_info()->exec_domain->signal_invmap);
8113 +       old_sa.sa_flags = 0;
8114 +       if (osa.sa_flags & SA_ONSTACK)
8115 +               old_sa.sa_flags |= ABI_SA_ONSTACK;
8116 +       if (osa.sa_flags & SA_RESTART)
8117 +               old_sa.sa_flags |= ABI_SA_RESTART;
8118 +       if (osa.sa_flags & SA_NODEFER)
8119 +               old_sa.sa_flags |= ABI_SA_NODEFER;
8120 +       if (osa.sa_flags & SA_RESETHAND)
8121 +               old_sa.sa_flags |= ABI_SA_RESETHAND;
8122 +       if (osa.sa_flags & SA_NOCLDSTOP)
8123 +               old_sa.sa_flags |= ABI_SA_NOCLDSTOP;
8124 +       if (osa.sa_flags & SA_NOCLDWAIT)
8125 +               old_sa.sa_flags |= ABI_SA_NOCLDWAIT;
8126 +       /*
8127 +        * We already did the verify_area at the beginning.
8128 +        */
8129 +       if (__copy_to_user(oldaction, &old_sa, sizeof(struct abi_sigaction)))
8130 +               return -EFAULT;
8131 +       return 0;
8132 +}
8133 +
8134 +
8135 +static short int howcnv[] = {SIG_SETMASK, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK};
8136 +
8137 +asmlinkage int
8138 +abi_sigprocmask(int how, u_long *abinset, u_long *abioset)
8139 +{
8140 +       sigset_t                new_set, *nset = NULL;
8141 +       sigset_t                old_set, *oset = NULL;
8142 +       u_long                  new_set_abi, old_set_abi;
8143 +       mm_segment_t            fs;
8144 +       int                     error;
8145 +
8146 +       if (abinset) {
8147 +               get_user(new_set_abi, abinset);
8148 +               new_set = map_sigvec_to_kernel(new_set_abi,
8149 +                       current_thread_info()->exec_domain->signal_map);
8150 +               nset = &new_set;
8151 +       }
8152 +
8153 +       if (abioset)
8154 +               oset = &old_set;
8155 +
8156 +       fs = get_fs();
8157 +       set_fs(get_ds());
8158 +       error = sys_rt_sigprocmask(howcnv[how], nset, oset, sizeof(sigset_t));
8159 +       set_fs(fs);
8160 +
8161 +       if (!error && abioset) {
8162 +               old_set_abi = map_sigvec_from_kernel(old_set,
8163 +                       current_thread_info()->exec_domain->signal_invmap);
8164 +               put_user(old_set_abi, abioset);
8165 +       }
8166 +
8167 +       return (error);
8168 +}
8169 +
8170 +int
8171 +abi_sigsuspend(struct pt_regs *regs)
8172 +{
8173 +       u_long                  abi_mask, *abi_maskp;
8174 +       old_sigset_t            mask;
8175 +
8176 +       abi_maskp = (u_long *)SIGNAL_NUMBER(regs);
8177 +       if (get_user(abi_mask, abi_maskp))
8178 +               return -EFAULT;
8179 +
8180 +       mask = map_bitvec(abi_mask, current_thread_info()->exec_domain->signal_map);
8181 +#if defined(CONFIG_ABI_TRACE)
8182 +       abi_trace(ABI_TRACE_SIGNAL,
8183 +                       "sigsuspend(mask = %lx)\n", mask);
8184 +#endif
8185 +       return abi_signal_suspend(regs, mask);
8186 +}
8187 +
8188 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
8189 +EXPORT_SYMBOL(abi_sigaction);
8190 +EXPORT_SYMBOL(abi_sigfunc);
8191 +EXPORT_SYMBOL(abi_sigprocmask);
8192 +EXPORT_SYMBOL(abi_sigsuspend);
8193 +EXPORT_SYMBOL(deactivate_signal);
8194 +#endif
8195 diff -Nur kernel-source-2.6.16.orig/abi/svr4/socket.c kernel-source-2.6.16/abi/svr4/socket.c
8196 --- kernel-source-2.6.16.orig/abi/svr4/socket.c 1970-01-01 10:00:00.000000000 +1000
8197 +++ kernel-source-2.6.16/abi/svr4/socket.c      2006-04-27 18:50:24.000000000 +1000
8198 @@ -0,0 +1,262 @@
8199 +/*
8200 + * Copyright (c) 1994,1996 Mike Jagdis (jaggy@purplet.demon.co.uk)
8201 + */
8202 +
8203 +#ident "%W% %G%"
8204 +
8205 +#include <linux/module.h>
8206 +#include <linux/fs.h>
8207 +#include <linux/mm.h>
8208 +#include <linux/net.h>
8209 +#include <linux/personality.h>
8210 +#include <linux/ptrace.h>
8211 +#include <linux/socket.h>
8212 +#include <linux/syscalls.h>
8213 +#include <linux/types.h>
8214 +#include <asm/uaccess.h>
8215 +#include <asm/ioctls.h>
8216 +
8217 +#include <abi/util/map.h>
8218 +#include <abi/util/trace.h>
8219 +#include <abi/util/socket.h>
8220 +
8221 +
8222 +int
8223 +abi_do_setsockopt(unsigned long *sp)
8224 +{
8225 +       int error;
8226 +       int level, optname;
8227 +
8228 +       if (!access_ok(VERIFY_READ,
8229 +                       ((unsigned long *)sp),
8230 +                       5*sizeof(long)))
8231 +               return -EFAULT;
8232 +
8233 +       get_user(level, ((unsigned long *)sp)+1);
8234 +       get_user(optname, ((unsigned long *)sp)+2);
8235 +
8236 +#if defined(CONFIG_ABI_TRACE)
8237 +       if (abi_traced(ABI_TRACE_STREAMS|ABI_TRACE_SOCKSYS)) {
8238 +               u_long optval, optlen;
8239 +
8240 +               get_user(optval, ((u_long *)sp) + 3);
8241 +               get_user(optlen, ((u_long *)sp) + 4);
8242 +               __abi_trace("setsockopt level=%d, optname=%d, "
8243 +                               "optval=0x%08lx, optlen=0x%08lx\n",
8244 +                               level, optname, optval, optlen);
8245 +       }
8246 +#endif
8247 +
8248 +       switch (level) {
8249 +               case 0: /* IPPROTO_IP aka SOL_IP */
8250 +                       /* This is correct for the SCO family. Hopefully
8251 +                        * it is correct for other SYSV...
8252 +                        */
8253 +                       optname--;
8254 +                       if (optname == 0)
8255 +                               optname = 4;
8256 +                       if (optname > 4) {
8257 +                               optname += 24;
8258 +                               if (optname <= 33)
8259 +                                       optname--;
8260 +                               if (optname < 32 || optname > 36)
8261 +                                       return -EINVAL;
8262 +                       }
8263 +                       put_user(optname, ((unsigned long *)sp)+2);
8264 +                       break;
8265 +
8266 +               case 0xffff:
8267 +                       put_user(SOL_SOCKET, ((unsigned long *)sp)+1);
8268 +                       optname = map_value(current_thread_info()->exec_domain->sockopt_map, optname, 0);
8269 +                       put_user(optname, ((unsigned long *)sp)+2);
8270 +
8271 +                       switch (optname) {
8272 +                               case SO_LINGER: {
8273 +                                       unsigned long optlen;
8274 +
8275 +                                       /* SO_LINGER takes a struct linger
8276 +                                        * as the argument but some code
8277 +                                        * uses an int and expects to get
8278 +                                        * away without an error. Sigh...
8279 +                                        */
8280 +                                       get_user(optlen, ((unsigned long *)sp)+4);
8281 +                                       if (optlen == sizeof(int))
8282 +                                               return 0;
8283 +                                       break;
8284 +                               }
8285 +
8286 +                               /* The following are not currently implemented
8287 +                                * under Linux so we must fake them in
8288 +                                * reasonable ways. (Only SO_PROTOTYPE is
8289 +                                * documented in SCO's man page).
8290 +                                */
8291 +                               case SO_PROTOTYPE:
8292 +                               case SO_ORDREL:
8293 +                               case SO_SNDTIMEO:
8294 +                               case SO_RCVTIMEO:
8295 +                                       return -ENOPROTOOPT;
8296 +
8297 +                               case SO_USELOOPBACK:
8298 +                               case SO_SNDLOWAT:
8299 +                               case SO_RCVLOWAT:
8300 +                                       return 0;
8301 +
8302 +                               /* The following are not currenty implemented
8303 +                                * under Linux and probably aren't settable
8304 +                                * anyway.
8305 +                                */
8306 +                               case SO_IMASOCKET:
8307 +                                       return -ENOPROTOOPT;
8308 +                       }
8309 +
8310 +               default:
8311 +                       /* FIXME: We assume everything else uses the
8312 +                        * same level and option numbers. This is true
8313 +                        * for IPPROTO_TCP(/SOL_TCP) and TCP_NDELAY
8314 +                        * but is known to be incorrect for other
8315 +                        * potential options :-(.
8316 +                        */
8317 +                       break;
8318 +       }
8319 +
8320 +       return sys_socketcall(SYS_SETSOCKOPT, sp);
8321 +}
8322 +
8323 +int
8324 +abi_do_getsockopt(unsigned long *sp)
8325 +{
8326 +       int error;
8327 +       int level, optname;
8328 +       char *optval;
8329 +       long *optlen;
8330 +       unsigned long *ulptr;
8331 +
8332 +       if (!access_ok(VERIFY_READ,
8333 +                       ((unsigned long *)sp),
8334 +                       5*sizeof(long)))
8335 +               return -EFAULT;
8336 +
8337 +       ulptr = (unsigned long *)&level;
8338 +       get_user(*ulptr, ((unsigned long *)sp)+1);
8339 +       ulptr = (unsigned long *)&optname;
8340 +       get_user(*ulptr, ((unsigned long *)sp)+2);
8341 +       ulptr = (unsigned long *)&optval;
8342 +       get_user(*ulptr, ((unsigned long *)sp)+3);
8343 +       ulptr = (unsigned long *)&optlen;
8344 +       get_user(*ulptr, ((unsigned long *)sp)+4);
8345 +
8346 +#if defined(CONFIG_ABI_TRACE)
8347 +       if (abi_traced(ABI_TRACE_STREAMS|ABI_TRACE_SOCKSYS)) {
8348 +               long l;
8349 +
8350 +               get_user(l, optlen);
8351 +               __abi_trace("getsockopt level=%d, optname=%d, optval=0x%08lx, "
8352 +                               "optlen=0x%08lx[%ld]\n", level, optname,
8353 +                               (u_long)optval, (u_long)optlen, l);
8354 +       }
8355 +#endif
8356 +
8357 +       switch (level) {
8358 +               case 0: /* IPPROTO_IP aka SOL_IP */
8359 +                       /* This is correct for the SCO family. Hopefully
8360 +                        * it is correct for other SYSV...
8361 +                        */
8362 +                       optname--;
8363 +                       if (optname == 0)
8364 +                               optname = 4;
8365 +                       if (optname > 4) {
8366 +                               optname += 24;
8367 +                               if (optname <= 33)
8368 +                                       optname--;
8369 +                               if (optname < 32 || optname > 36)
8370 +                                       return -EINVAL;
8371 +                       }
8372 +                       put_user(optname, ((unsigned long *)sp)+2);
8373 +                       break;
8374 +
8375 +               case 0xffff:
8376 +                       put_user(SOL_SOCKET, ((unsigned long *)sp)+1);
8377 +                       optname = map_value(current_thread_info()->exec_domain->sockopt_map, optname, 0);
8378 +                       put_user(optname, ((unsigned long *)sp)+2);
8379 +
8380 +                       switch (optname) {
8381 +                               case SO_LINGER: {
8382 +                                       long l;
8383 +
8384 +                                       /* SO_LINGER takes a struct linger
8385 +                                        * as the argument but some code
8386 +                                        * uses an int and expects to get
8387 +                                        * away without an error. Sigh...
8388 +                                        */
8389 +                                       get_user(l, optlen);
8390 +                                       if (l == sizeof(int)) {
8391 +                                               put_user(0, (long *)optval);
8392 +                                               return 0;
8393 +                                       }
8394 +                                       break;
8395 +                               }
8396 +
8397 +                               /* The following are not currently implemented
8398 +                                * under Linux so we must fake them in
8399 +                                * reasonable ways. (Only SO_PROTOTYPE is
8400 +                                * documented in SCO's man page).
8401 +                                */
8402 +                               case SO_PROTOTYPE: {
8403 +                                       unsigned long len;
8404 +                                       error = get_user(len, optlen);
8405 +                                       if (error)
8406 +                                               return error;
8407 +                                       if (len < sizeof(long))
8408 +                                               return -EINVAL;
8409 +
8410 +                                       if (access_ok(VERIFY_WRITE,
8411 +                                                       (char *)optval,
8412 +                                                       sizeof(long))) {
8413 +                                               put_user(0, (long *)optval);
8414 +                                               put_user(sizeof(long),
8415 +                                                       optlen);
8416 +                                               return 0;
8417 +                                       }
8418 +                                       return -EFAULT;
8419 +                               }
8420 +
8421 +                               case SO_ORDREL:
8422 +                               case SO_SNDTIMEO:
8423 +                               case SO_RCVTIMEO:
8424 +                                       return -ENOPROTOOPT;
8425 +
8426 +                               case SO_USELOOPBACK:
8427 +                               case SO_SNDLOWAT:
8428 +                               case SO_RCVLOWAT:
8429 +                               case SO_IMASOCKET: {
8430 +                                       unsigned long len;
8431 +                                       error = get_user(len, optlen);
8432 +                                       if (error)
8433 +                                               return error;
8434 +                                       if (len < sizeof(long))
8435 +                                               return -EINVAL;
8436 +
8437 +                                       if (access_ok(VERIFY_WRITE,
8438 +                                                       (char *)optval,
8439 +                                                       sizeof(long))) {
8440 +                                               put_user(1, (long *)optval);
8441 +                                               put_user(sizeof(long),
8442 +                                                       optlen);
8443 +                                               return 0;
8444 +                                       }
8445 +                                       return -EFAULT;
8446 +                               }
8447 +                       }
8448 +
8449 +               default:
8450 +                       /* FIXME: We assume everything else uses the
8451 +                        * same level and option numbers. This is true
8452 +                        * for IPPROTO_TCP(/SOL_TCP) and TCP_NDELAY
8453 +                        * but is known to be incorrect for other
8454 +                        * potential options :-(.
8455 +                        */
8456 +                       break;
8457 +       }
8458 +
8459 +       return sys_socketcall(SYS_GETSOCKOPT, sp);
8460 +}
8461 diff -Nur kernel-source-2.6.16.orig/abi/svr4/sockio.c kernel-source-2.6.16/abi/svr4/sockio.c
8462 --- kernel-source-2.6.16.orig/abi/svr4/sockio.c 1970-01-01 10:00:00.000000000 +1000
8463 +++ kernel-source-2.6.16/abi/svr4/sockio.c      2006-04-27 18:50:24.000000000 +1000
8464 @@ -0,0 +1,309 @@
8465 +/*     $Id$    */
8466 +
8467 +#include <linux/config.h>
8468 +#include <linux/errno.h>
8469 +#include <linux/fs.h>
8470 +#include <linux/sched.h>
8471 +#include <linux/kernel.h>
8472 +#include <linux/sockios.h>
8473 +#include <linux/file.h>
8474 +#include <linux/slab.h>
8475 +#include <linux/syscalls.h>
8476 +#include <asm/uaccess.h>
8477 +#include <asm/ioctls.h>
8478 +
8479 +#include <abi/stream.h>
8480 +#include <abi/tli.h>
8481 +#include <abi/socksys.h> /* for socksys_fdinit */
8482 +
8483 +#include <abi/svr4/ioctl.h>
8484 +#include <abi/util/trace.h>
8485 +
8486 +
8487 +/*
8488 + * Check if the inode belongs to /dev/socksys.
8489 + */
8490 +#define IS_SOCKSYS(ip) (MAJOR((ip)->i_rdev) == SOCKSYS_MAJOR)
8491 +
8492 +
8493 +static int
8494 +i_nread(u_int fd, struct file *fp, struct inode *ip,
8495 +               void *data, struct pt_regs *regs)
8496 +{
8497 +       int error=0;
8498 +
8499 +       if (!access_ok(VERIFY_WRITE, data, sizeof(u_long))) {
8500 +               error = -EFAULT;
8501 +               goto fput;
8502 +       }
8503 +
8504 +#if !defined(CONFIG_ABI_XTI)
8505 +       if (S_ISSOCK(ip->i_mode)) {
8506 +               struct T_private *ti = Priv(fp);
8507 +
8508 +               if (IS_SOCKSYS(ip))
8509 +                       timod_update_socket(fd, fp, regs);
8510 +
8511 +               if (ti && ti->pfirst) {
8512 +                       put_user(ti->pfirst->length, (u_long *)data);
8513 +                       fput(fp);
8514 +                       return 1; /* at least 1... (FIXME) */
8515 +               }
8516 +       }
8517 +
8518 +       fput(fp);
8519 +#endif
8520 +
8521 +       error = sys_ioctl(fd, TIOCINQ, (long)data);
8522 +       if (error == -EINVAL)
8523 +               return 0;
8524 +       else if (error)
8525 +               return error;
8526 +
8527 +       __get_user(error, (u_long *)data);
8528 +       return !!error;
8529 +fput:
8530 +       fput(fp);
8531 +       return error;
8532 +}
8533 +
8534 +static int
8535 +i_peek(u_int fd, struct file *fp, struct inode *ip,
8536 +               void *data, struct pt_regs *regs)
8537 +{
8538 +#if !defined(CONFIG_ABI_XTI)
8539 +       fput(fp);
8540 +       return 0;
8541 +#else
8542 +       struct T_private        *ti = Priv(fp);
8543 +       struct T_primsg         *tp;
8544 +       struct strpeek          buf, *uap = data;
8545 +       int                     error = -EFAULT;
8546 +
8547 +       if (copy_from_user(&buf, uap, sizeof(buf)))
8548 +               goto fput;
8549 +
8550 +       error = 0;
8551 +       if (!S_ISSOCK(ip->i_mode))
8552 +               goto fput;
8553 +
8554 +       if (IS_SOCKSYS(ip))
8555 +               timod_update_socket(fd, fp, regs);
8556 +
8557 +       if (!ti || !ti->pfirst)
8558 +               goto fput;
8559 +       tp = ti->pfirst;
8560 +
8561 +       error = -EFAULT;
8562 +       if (!buf.flags || buf.flags == tp->pri) {
8563 +               int     l;
8564 +
8565 +
8566 +
8567 +               if (buf.ctl.maxlen <= tp->length)
8568 +                       l = buf.ctl.maxlen;
8569 +               else
8570 +                       l = tp->length;
8571 +
8572 +               if (copy_to_user(buf.ctl.buf,
8573 +                   ((char *)&tp->type) + ti->offset, l))
8574 +                       goto fput;
8575 +
8576 +               if (put_user(l, &uap->ctl.len))
8577 +                       goto fput;
8578 +
8579 +               if (buf.dat.maxlen >= 0 && put_user(0, &uap->dat.len))
8580 +                       goto fput;
8581 +
8582 +               if (put_user(tp->pri, &uap->flags))
8583 +                       goto fput;
8584 +
8585 +               error = 1;
8586 +       }
8587 +fput:
8588 +       fput(fp);
8589 +       return error;
8590 +#endif /* CONFIG_ABI_XTI */
8591 +}
8592 +
8593 +static int
8594 +i_str(u_int fd, struct file *fp, struct inode *ip,
8595 +               void *data, struct pt_regs *regs)
8596 +{
8597 +       int                     cmd;
8598 +       /*
8599 +        * Unpack the ioctl data and forward as a normal
8600 +        * ioctl. Timeouts are not handled (yet?).
8601 +        */
8602 +       struct strioctl {
8603 +               int cmd, timeout, len;
8604 +               char *data;
8605 +       } it, *uap = data;
8606 +
8607 +       if (copy_from_user(&it, uap, sizeof(struct strioctl)))
8608 +               return -EFAULT;
8609 +       cmd = it.cmd >> 8;
8610 +
8611 +#if defined(CONFIG_ABI_TRACE)
8612 +       abi_trace(ABI_TRACE_STREAMS, "STREAMS I_STR ioctl(%d, 0x%08x, %p)\n",
8613 +                       fd, it.cmd, it.data);
8614 +#endif
8615 +
8616 +#ifdef CONFIG_ABI_XTI
8617 +       if (cmd == 'T')
8618 +               return timod_ioctl(regs, fd, it.cmd & 0xff, it.data, it.len,
8619 +                       &uap->len);
8620 +#endif
8621 +       return __svr4_ioctl(regs, fd, it.cmd, it.data);
8622 +}
8623 +
8624 +int
8625 +svr4_stream_ioctl(struct pt_regs *regs, int fd, u_int cmd, caddr_t data)
8626 +{
8627 +       struct file             *fp;
8628 +       struct inode            *ip;
8629 +       int                     error;
8630 +
8631 +       fp = fget(fd);
8632 +       if (!fp)
8633 +               return -EBADF;
8634 +       ip = fp->f_dentry->d_inode;
8635 +
8636 +       /*
8637 +        * Special hack^H^Hndling for socksys fds
8638 +        */
8639 +       if (S_ISSOCK(ip->i_mode) == 0 && IS_SOCKSYS(ip)) {
8640 +               error = socksys_fdinit(fd, 0, NULL, NULL);
8641 +               if (error < 0)
8642 +                       return error;
8643 +               fput(fp);
8644 +               fp = fget(fd);
8645 +               if (!fp)
8646 +                       return -EBADF;
8647 +               ip = fp->f_dentry->d_inode;
8648 +       }
8649 +
8650 +       switch (cmd) {
8651 +       case 001: /* I_NREAD */
8652 +               return i_nread(fd, fp, ip, data, regs);
8653 +
8654 +       case 017: /* I_PEEK */
8655 +               return i_peek(fd, fp, ip, data, regs);
8656 +       }
8657 +
8658 +       fput(fp);
8659 +
8660 +       switch (cmd) {
8661 +       case 010: /* I_STR */
8662 +               return i_str(fd, fp, ip, data, regs);
8663 +       case 002: { /* I_PUSH */
8664 +               char *tmp;
8665 +
8666 +               /* Get the name anyway to validate it. */
8667 +               tmp = getname(data);
8668 +               if (IS_ERR(tmp))
8669 +                       return PTR_ERR(tmp);
8670 +
8671 +#if defined(CONFIG_ABI_TRACE)
8672 +               abi_trace(ABI_TRACE_STREAMS,
8673 +                               "%d STREAMS I_PUSH %s\n", fd, tmp);
8674 +#endif
8675 +
8676 +               putname(tmp);
8677 +               return 0;
8678 +       }
8679 +       case 003: /* I_POP */
8680 +#if defined(CONFIG_ABI_TRACE)
8681 +                 abi_trace(ABI_TRACE_STREAMS, "%d STREAMS I_POP\n", fd);
8682 +#endif
8683 +                 return 0;
8684 +
8685 +       case 005: /* I_FLUSH */
8686 +                 return 0;
8687 +
8688 +       case 013: { /* I_FIND */
8689 +               char *tmp;
8690 +
8691 +               /* Get the name anyway to validate it. */
8692 +               tmp = getname(data);
8693 +               if (IS_ERR(tmp))
8694 +                               return PTR_ERR(tmp);
8695 +
8696 +#if defined(CONFIG_ABI_TRACE)
8697 +               abi_trace(ABI_TRACE_STREAMS,
8698 +                               "%d STREAMS I_FIND %s\n", fd, tmp);
8699 +#endif
8700 +#ifdef CONFIG_ABI_XTI
8701 +               if (!strcmp(tmp, "timod")) {
8702 +                       putname(tmp);
8703 +                       return 1;
8704 +               }
8705 +#endif
8706 +               putname(tmp);
8707 +               return 0;
8708 +       }
8709 +
8710 +       /* FIXME: These are bogus. */
8711 +       case 011: /* I_SETSIG */
8712 +               return sys_ioctl(fd, FIOSETOWN, (long)current->pid);
8713 +       case 012: /* I_GETSIG */
8714 +               return sys_ioctl(fd, FIOGETOWN, (long)data);
8715 +
8716 +       case 020: /* I_FDINSERT */
8717 +#ifdef CONFIG_ABI_XTI
8718 +               return stream_fdinsert(regs, fd,
8719 +                               (struct strfdinsert *)data);
8720 +#else
8721 +               return -EINVAL;
8722 +#endif
8723 +
8724 +       case 004: /* I_LOOK */
8725 +       case 006: /* I_SRDOPT */
8726 +       case 007: /* I_GRDOPT */
8727 +       case 014: /* I_LINK */
8728 +       case 015: /* I_UNLINK */
8729 +       case 021: /* I_SENDFD */
8730 +       case 022: /* I_RECVFD */
8731 +       case 023: /* I_SWROPT */
8732 +       case 040: /* I_SETCLTIME */
8733 +               return 0; /* Lie... */
8734 +       case 042: /* I_CANPUT */
8735 +               /*
8736 +                * Arg is the priority band in question. We only
8737 +                * support one priority band so data must be 0.
8738 +                * If the band is writable we should return 1, if
8739 +                * the band is flow controlled we should return 0.
8740 +                */
8741 +               if (data)
8742 +                       return -EINVAL;
8743 +
8744 +               /* FIXME: How can we test if a write would block? */
8745 +               return 1;
8746 +
8747 +       case 024: /* I_GWROPT */
8748 +       case 025: /* I_LIST */
8749 +       case 026: /* I_PLINK */
8750 +       case 027: /* I_PUNLINK */
8751 +       case 030: /* I_SETEV */
8752 +       case 031: /* I_GETEV */
8753 +       case 032: /* I_STREV */
8754 +       case 033: /* I_UNSTREV */
8755 +       case 034: /* I_FLUSHBAND */
8756 +       case 035: /* I_CKBAND */
8757 +       case 036: /* I_GETBAND */
8758 +       case 037: /* I_ATMARK */
8759 +       case 041: /* I_GETCLTIME */
8760 +                       /* Unsupported - drop out. */
8761 +                break;
8762 +
8763 +        default:
8764 +                break;
8765 +       }
8766 +
8767 +       printk(KERN_ERR "iBCS: STREAMS ioctl 0%o unsupported\n", cmd);
8768 +       return -EINVAL;
8769 +}
8770 +
8771 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
8772 +EXPORT_SYMBOL(svr4_stream_ioctl);
8773 +#endif
8774 diff -Nur kernel-source-2.6.16.orig/abi/svr4/socksys.c kernel-source-2.6.16/abi/svr4/socksys.c
8775 --- kernel-source-2.6.16.orig/abi/svr4/socksys.c        1970-01-01 10:00:00.000000000 +1000
8776 +++ kernel-source-2.6.16/abi/svr4/socksys.c     2006-04-27 18:50:24.000000000 +1000
8777 @@ -0,0 +1,1243 @@
8778 +/*
8779 + * socksys.c - SVR4 /dev/socksys emulation
8780 + *
8781 + * Copyright (c) 1994-1996 Mike Jagdis (jaggy@purplet.demon.co.uk)
8782 + * Copyright (c) 2001 Caldera Deutschland GmbH
8783 + * Copyright (c) 2001 Christoph Hellwig
8784 + */
8785 +
8786 +#ident "%W% %G%"
8787 +
8788 +#include <linux/config.h>
8789 +#include <linux/module.h>
8790 +
8791 +#include <linux/types.h>
8792 +#include <linux/errno.h>
8793 +#include <linux/fs.h>
8794 +#include <linux/fcntl.h>
8795 +#include <linux/major.h>
8796 +#include <linux/kernel.h>
8797 +#include <linux/in.h>
8798 +#include <linux/net.h>
8799 +#include <linux/sched.h>
8800 +#include <linux/signal.h>
8801 +#include <linux/socket.h>
8802 +#include <net/sock.h>
8803 +#include <linux/slab.h>
8804 +#include <linux/mm.h>
8805 +#include <linux/un.h>
8806 +#include <linux/utsname.h>
8807 +#include <linux/time.h>
8808 +#include <linux/termios.h>
8809 +#include <linux/sys.h>
8810 +#include <linux/file.h>
8811 +#include <linux/poll.h>
8812 +#include <linux/capability.h>
8813 +#include <linux/personality.h>
8814 +#include <linux/init.h>
8815 +#include <linux/syscalls.h>
8816 +#include <linux/namei.h>
8817 +
8818 +#include <asm/uaccess.h>
8819 +
8820 +#include <abi/stream.h>
8821 +#include <abi/socksys.h>
8822 +#include <abi/svr4/sockio.h>
8823 +#include <abi/svr4/sysent.h>
8824 +#include <abi/tli.h>
8825 +
8826 +#include <abi/util/map.h>
8827 +#include <abi/util/trace.h>
8828 +#include <abi/util/revalidate.h>
8829 +
8830 +
8831 +/*
8832 + * External declarations.
8833 + */
8834 +struct svr4_stat;
8835 +
8836 +/*
8837 + * Forward declarations.
8838 + */
8839 +static int     socksys_open(struct inode *ip, struct file *fp);
8840 +#if defined(CONFIG_ABI_XTI)
8841 +static int     socksys_release(struct inode *ip, struct file *fp);
8842 +static u_int   socksys_poll(struct file *fp, struct poll_table_struct *wait);
8843 +#endif
8844 +static int     socksys_read(struct file *fp, char *buf,
8845 +                       size_t count, loff_t *ppos);
8846 +static int     socksys_write(struct file *fp, const char *buf,
8847 +                       size_t count, loff_t *ppos);
8848 +
8849 +/*
8850 + * The socksys socket file operations.
8851 + * This gets filled in on module initialization.
8852 + */
8853 +static struct file_operations socksys_socket_fops = {
8854 +       /* NOTHING */
8855 +};
8856 +
8857 +/*
8858 + * File operations for the user-visible device files.
8859 + *
8860 + * While open the files are handled as sockets.
8861 + */
8862 +static struct file_operations socksys_fops = {
8863 +       owner:          THIS_MODULE,
8864 +       open:           socksys_open,
8865 +       read:           socksys_read,
8866 +       write:          socksys_write,
8867 +#ifdef CONFIG_ABI_XTI
8868 +       poll:           socksys_poll,
8869 +       release:        socksys_release,
8870 +#endif
8871 +};
8872 +
8873 +
8874 +void
8875 +inherit_socksys_funcs(u_int fd, int state)
8876 +{
8877 +       struct file             *fp;
8878 +       struct inode            *ip;
8879 +#ifdef CONFIG_ABI_XTI
8880 +       struct T_private        *tp;
8881 +#endif
8882 +        struct socket           *sp;
8883 +
8884 +       fp = fget(fd);
8885 +       if (fp == NULL)
8886 +               return;
8887 +       ip = fp->f_dentry->d_inode;
8888 +
8889 +       /*
8890 +        * SYSV sockets are BSD like with respect to ICMP errors
8891 +        * with UDP rather than RFC conforming. I think.
8892 +        */
8893 +        sp = SOCKET_I(ip); /* inode -> socket */
8894 +       if (sp->sk)
8895 +                sock_set_flag(sp->sk, SOCK_BSDISM);
8896 +
8897 +       ip->i_mode = 0020000; /* S_IFCHR */
8898 +       ip->i_rdev = MKDEV(SOCKSYS_MAJOR, 0);
8899 +
8900 +#ifdef CONFIG_ABI_XTI
8901 +       tp = kmalloc(sizeof(struct T_private), GFP_KERNEL);
8902 +       if (tp) {
8903 +               tp->magic = XTI_MAGIC;
8904 +               tp->state = state;
8905 +               tp->offset = 0;
8906 +               tp->pfirst = NULL;
8907 +               tp->plast = NULL;
8908 +       }
8909 +       fp->private_data = tp;
8910 +#endif
8911 +
8912 +       fp->f_op = &socksys_socket_fops;
8913 +       fput(fp);
8914 +}
8915 +
8916 +static int
8917 +spx_connect(u_int fd, int spxnum)
8918 +{
8919 +       struct sockaddr_un      sun;
8920 +       int                     newfd, err;
8921 +       mm_segment_t            fs;
8922 +
8923 +#if defined(CONFIG_ABI_TRACE)
8924 +       abi_trace(ABI_TRACE_SOCKSYS,
8925 +                       "SPX: %u choose service %d\n", fd, spxnum);
8926 +#endif
8927 +
8928 +       /*
8929 +        * Rather than use an explicit path to the X :0 server
8930 +        * socket we should use the given number to look up a path
8931 +        * name to use (we can't rely on servers registering their
8932 +        * sockets either - for one thing we don't emulate that yet
8933 +        * and for another thing different OS binaries do things in
8934 +        * different ways but all must interoperate).
8935 +        * I suggest putting the mapping in, say, /dev/spx.map/%d
8936 +        * where each file is a symlink containing the path of the
8937 +        * socket to use. Then we can just do a readlink() here to
8938 +        * get the pathname.
8939 +        *   Hey, this is what we do here now!
8940 +        */
8941 +       sun.sun_family = AF_UNIX;
8942 +       sprintf(sun.sun_path, "/dev/spx.map/%u", spxnum);
8943 +
8944 +       fs = get_fs();
8945 +       set_fs(get_ds());
8946 +       err = sys_readlink(sun.sun_path, sun.sun_path, strlen(sun.sun_path));
8947 +       set_fs(fs);
8948 +
8949 +       if (err == -ENOENT) {
8950 +#if defined(CONFIG_ABI_TRACE)
8951 +               abi_trace(ABI_TRACE_SOCKSYS,
8952 +                       "SPX: %u no symlink \"%s\", try X :0\n",
8953 +                       fd, sun.sun_path);
8954 +#endif
8955 +               strcpy(sun.sun_path, "/tmp/.X11-unix/X0");
8956 +       } else if (err < 0) {
8957 +#if defined(CONFIG_ABI_TRACE)
8958 +               abi_trace(ABI_TRACE_SOCKSYS,
8959 +                       "SPX: readlink failed with %d\n", err);
8960 +#endif
8961 +               return (err);
8962 +       } else
8963 +               sun.sun_path[err] = '\0';
8964 +
8965 +       set_fs(get_ds());
8966 +       newfd = sys_socket(AF_UNIX, SOCK_STREAM, 0);
8967 +       set_fs(fs);
8968 +
8969 +       if (newfd < 0) {
8970 +#if defined(CONFIG_ABI_TRACE)
8971 +               abi_trace(ABI_TRACE_SOCKSYS,
8972 +                       "SPX: %u got no UNIX domain socket (err=%d)\n",
8973 +                       fd, err);
8974 +#endif
8975 +               return (newfd);
8976 +       }
8977 +
8978 +#if defined(CONFIG_ABI_TRACE)
8979 +       abi_trace(ABI_TRACE_SOCKSYS,
8980 +               "SPX: %u got a UNIX domain socket\n", fd);
8981 +#endif
8982 +
8983 +       set_fs(get_ds());
8984 +       err = sys_connect(newfd, (struct sockaddr *)&sun, sizeof(struct sockaddr_un));
8985 +       set_fs(fs);
8986 +
8987 +       if (err) {
8988 +#if defined(CONFIG_ABI_TRACE)
8989 +               abi_trace(ABI_TRACE_SOCKSYS,
8990 +                       "SPX: %u connect to \"%s\" failed (err = %d)\n",
8991 +                       fd, sun.sun_path, err);
8992 +#endif
8993 +               sys_close(newfd);
8994 +               return (err);
8995 +       }
8996 +
8997 +#if defined(CONFIG_ABI_TRACE)
8998 +       abi_trace(ABI_TRACE_SOCKSYS,
8999 +               "SPX: %u connect to \"%s\"\n",
9000 +               fd, sun.sun_path);
9001 +#endif
9002 +       return (newfd);
9003 +}
9004 +
9005 +/*
9006 + * XTI to Linux protocol table.
9007 + */
9008 +static int inet_prot[16] = {
9009 +       IPPROTO_ICMP,   IPPROTO_ICMP,
9010 +       IPPROTO_IGMP,   IPPROTO_IPIP,
9011 +       IPPROTO_TCP,    IPPROTO_EGP,
9012 +       IPPROTO_PUP,    IPPROTO_UDP,
9013 +       IPPROTO_IDP,    IPPROTO_RAW,
9014 +};
9015 +
9016 +static int inet_type[16] = {
9017 +       SOCK_RAW,       SOCK_RAW,
9018 +       SOCK_RAW,       SOCK_RAW,
9019 +       SOCK_STREAM,    SOCK_RAW,
9020 +       SOCK_RAW,       SOCK_DGRAM,
9021 +       SOCK_RAW,       SOCK_RAW,
9022 +};
9023 +
9024 +
9025 +static int
9026 +xti_connect(struct file *fp, u_int fd, dev_t dev)
9027 +{
9028 +       int                     family, type, prot = 0, i, s;
9029 +       mm_segment_t            fs;
9030 +
9031 +#if defined(CONFIG_ABI_TRACE)
9032 +       abi_trace(ABI_TRACE_SOCKSYS,
9033 +               "XTI: %d get socket for transport end point "
9034 +               "(dev = 0x%04x)\n", fd, dev);
9035 +#endif
9036 +
9037 +       switch ((family = ((MINOR(dev) >> 4) & 0x0f))) {
9038 +       case AF_UNIX:
9039 +               type = SOCK_STREAM;
9040 +               break;
9041 +       case AF_INET:
9042 +               i = MINOR(dev) & 0x0f;
9043 +               type = inet_type[i];
9044 +               prot = inet_prot[i];
9045 +               break;
9046 +       default:
9047 +               type = SOCK_RAW;
9048 +               break;
9049 +       }
9050 +
9051 +       fput(fp);
9052 +
9053 +#if defined(CONFIG_ABI_TRACE)
9054 +       abi_trace(ABI_TRACE_SOCKSYS,
9055 +               "XTI: %d socket %d %d %d\n",
9056 +               fd, family, type, prot);
9057 +#endif
9058 +
9059 +       fs = get_fs();
9060 +       set_fs(get_ds());
9061 +       s = sys_socket(family, type, prot);
9062 +       set_fs(fs);
9063 +
9064 +       return (s);
9065 +}
9066 +
9067 +int
9068 +socksys_fdinit(int fd, int rw, const char *buf, int *count)
9069 +{
9070 +       struct file             *fp;
9071 +       struct inode            *ip;
9072 +       int                     sockfd, error = -EINVAL;
9073 +
9074 +#if defined(CONFIG_ABI_TRACE)
9075 +       abi_trace(ABI_TRACE_SOCKSYS, "socksys: fd=%d initializing\n", fd);
9076 +#endif
9077 +
9078 +       fp = fget(fd);
9079 +       if (!fp)
9080 +               return -EBADF;
9081 +       ip = fp->f_dentry->d_inode;
9082 +
9083 +       /*
9084 +        * Minor = 0 is the socksys device itself. No special handling
9085 +        *           will be needed as it is controlled by the application
9086 +        *           via ioctls.
9087 +        */
9088 +       if (MINOR(ip->i_rdev) == 0)
9089 +               goto fput;
9090 +
9091 +       /*
9092 +        * Minor = 1 is the spx device. This is the client side of a
9093 +        *           streams pipe to the X server. Under SCO and friends
9094 +        *           the library code messes around setting the connection
9095 +        *           up itself. We do it ourselves - this means we don't
9096 +        *           need to worry about the implementation of the server
9097 +        *           side (/dev/X0R - which must exist but can be a link
9098 +        *           to /dev/null) nor do we need to actually implement
9099 +        *           getmsg/putmsg.
9100 +        */
9101 +       if (MINOR(ip->i_rdev) == 1) {
9102 +               int unit = 1;
9103 +
9104 +               /*
9105 +                * It seems early spx implementations were just a
9106 +                * quick hack to get X to work. They only supported
9107 +                * one destination and connected automatically.
9108 +                * Later versions take a single byte write, the
9109 +                * value of the byte telling them which destination
9110 +                * to connect to. Hence this quick hack to work
9111 +                * with both. If the first write is a single byte
9112 +                * it's a connect request otherwise we auto-connect
9113 +                * to destination 1.
9114 +                */
9115 +#if 0
9116 +               if (rw == 1 && *count == 1) {
9117 +                       error = get_user(unit, buf);
9118 +                       if (error)
9119 +                               goto fput;
9120 +                       (*count)--;
9121 +               }
9122 +#endif
9123 +
9124 +               fput(fp);
9125 +
9126 +               sockfd = spx_connect(fd, unit);
9127 +       } else {
9128 +               /*
9129 +                * Otherwise the high 4 bits specify the address/protocol
9130 +                * family (AF_INET, AF_UNIX etc.) and the low 4 bits determine
9131 +                * the protocol (IPPROTO_IP, IPPROTO_UDP, IPPROTO_TCP etc.)
9132 +                * although not using a one-to-one mapping as the minor number
9133 +                * is not big enough to hold everything directly. The socket
9134 +                * type is inferrred from the protocol.
9135 +                */
9136 +               sockfd = xti_connect(fp, fd, ip->i_rdev);
9137 +       }
9138 +
9139 +       /*
9140 +        * Give up if we weren't able to allocate a socket.
9141 +        * There is no sense in plying our funny game without a new fd.
9142 +        */
9143 +       if (sockfd < 0)
9144 +               return sockfd;
9145 +
9146 +       /*
9147 +        * Redirect operations on the socket fd via our emulation
9148 +        * handlers then swap the socket fd and the original fd,
9149 +        * discarding the original fd.
9150 +        */
9151 +       inherit_socksys_funcs(sockfd, TS_UNBND);
9152 +
9153 +#if defined(CONFIG_ABI_TRACE)
9154 +       abi_trace(ABI_TRACE_SOCKSYS, "XTI: %d -> %d\n", fd, sockfd);
9155 +#endif
9156 +
9157 +       sys_dup2(sockfd, fd);
9158 +       sys_close(sockfd);
9159 +       return 1;
9160 +
9161 +fput:
9162 +       fput(fp);
9163 +       return error;
9164 +}
9165 +
9166 +static int
9167 +socksys_open(struct inode *ip, struct file *fp)
9168 +{
9169 +#if defined(CONFIG_ABI_TRACE)
9170 +       abi_trace(ABI_TRACE_SOCKSYS,
9171 +               "socksys: fp=0x%p, ip=0x%p opening\n", fp, ip);
9172 +#endif
9173 +       return 0;
9174 +}
9175 +
9176 +#ifdef CONFIG_ABI_XTI
9177 +static int
9178 +socksys_release(struct inode *ip, struct file *fp)
9179 +{
9180 +       int                     error = 0;
9181 +
9182 +       /*
9183 +        * Not being a socket is not an error - it is probably
9184 +        * just the pseudo device transport provider.
9185 +        */
9186 +       if (!ip || !S_ISSOCK(ip->i_mode))
9187 +               goto out;
9188 +
9189 +       if (fp->private_data) {
9190 +               struct T_primsg *it;
9191 +
9192 +               it = ((struct T_private *)fp->private_data)->pfirst;
9193 +               while (it) {
9194 +                       struct T_primsg *tmp = it;
9195 +                       it = it->next;
9196 +                       kfree(tmp);
9197 +               }
9198 +               kfree(fp->private_data);
9199 +       }
9200 +       error = socket_file_ops.release(ip, fp);
9201 +out:
9202 +#if defined(CONFIG_ABI_TRACE)
9203 +       abi_trace(ABI_TRACE_SOCKSYS, "socksys: %p closed\n", fp);
9204 +#endif
9205 +       return error;
9206 +}
9207 +
9208 +static u_int
9209 +socksys_poll(struct file *fp, struct poll_table_struct *wait)
9210 +{
9211 +       struct inode            *ip = fp->f_dentry->d_inode;
9212 +       u_int                   mask = 0;
9213 +
9214 +       /*
9215 +        * If this is a timod transport end point and there
9216 +        * is a control message queued we have readable data.
9217 +        */
9218 +       if (ip && S_ISSOCK(ip->i_mode) && MINOR(ip->i_rdev) != 1) {
9219 +               if (Priv(fp) && Priv(fp)->pfirst) {
9220 +                       if (Priv(fp)->pfirst->pri == MSG_HIPRI)
9221 +                               mask |= POLLPRI;
9222 +                       else
9223 +                               mask |= POLLIN;
9224 +               }
9225 +       }
9226 +
9227 +       return (mask | socket_file_ops.poll(fp, wait));
9228 +}
9229 +#endif
9230 +
9231 +static int
9232 +socksys_read(struct file *fp, char *buf, size_t count, loff_t *ppos)
9233 +{
9234 +       int                     fd, error;
9235 +
9236 +       if (S_ISSOCK(fp->f_dentry->d_inode->i_mode))
9237 +               BUG();
9238 +
9239 +       for (fd = 0; fd < files_fdtable(current->files)->max_fdset; fd++) {
9240 +               if (fcheck(fd) == fp) {
9241 +                       error = socksys_fdinit(fd, 0, NULL, NULL);
9242 +                       if (error < 0)
9243 +                               return error;
9244 +                       fput(fp);
9245 +                       fp = fget(fd);
9246 +                       return fp->f_op->read(fp, buf, count, ppos);
9247 +               }
9248 +       }
9249 +
9250 +       return -EINVAL;
9251 +}
9252 +
9253 +static int
9254 +socksys_write(struct file *fp, const char *buf, size_t count, loff_t *ppos)
9255 +{
9256 +       int                     fd, error;
9257 +
9258 +       if (S_ISSOCK(fp->f_dentry->d_inode->i_mode))
9259 +               BUG();
9260 +
9261 +       for (fd = 0; fd < files_fdtable(current->files)->max_fdset; fd++) {
9262 +               if (fcheck(fd) == fp) {
9263 +                       error = socksys_fdinit(fd, 1, buf, &count);
9264 +                       if (error < 0)
9265 +                               return error;
9266 +                       fput(fp);
9267 +                       fp = fget(fd);
9268 +                       if (count == 1)
9269 +                               return 1;
9270 +                       printk("count=%d\n", count);
9271 +                       return fp->f_op->write(fp, buf, count, ppos);
9272 +               }
9273 +       }
9274 +
9275 +       return -EINVAL;
9276 +}
9277 +
9278 +
9279 +/*
9280 + * Get a socket but replace the socket file
9281 + * operations with our own so we can do the
9282 + * right thing for ioctls.
9283 + */
9284 +static int
9285 +socksys_socket(u_long *sp)
9286 +{
9287 +       u_long                  x;
9288 +       int                     fd;
9289 +
9290 +       get_user(x, ((u_long *)sp)+0);
9291 +       put_user(map_value(current_thread_info()->exec_domain->af_map, x, 0), sp+0);
9292 +       get_user(x, ((u_long *)sp)+1);
9293 +       put_user(map_value(current_thread_info()->exec_domain->socktype_map, x, 0), sp+1);
9294 +
9295 +       fd = sys_socketcall(SYS_SOCKET, sp);
9296 +       if (fd >= 0)
9297 +               inherit_socksys_funcs(fd, TS_UNBND);
9298 +       return fd;
9299 +}
9300 +
9301 +static int
9302 +socksys_accept(u_long *sp)
9303 +{
9304 +       int                     fd;
9305 +
9306 +       fd = sys_socketcall(SYS_ACCEPT, sp);
9307 +       if (fd >= 0)
9308 +               inherit_socksys_funcs(fd, TS_DATA_XFER);
9309 +       return fd;
9310 +}
9311 +
9312 +static int
9313 +socksys_getipdomain(u_long *sp)
9314 +{
9315 +       char                    *name, *p;
9316 +       int                     error, len;
9317 +       u_long                  *ulptr;
9318 +
9319 +       ulptr = (u_long *)&name;
9320 +       error = get_user(*ulptr, (char *)(sp+0));
9321 +       if (error)
9322 +               return error;
9323 +
9324 +       get_user(len, sp+1);
9325 +       if (error)
9326 +               return error;
9327 +
9328 +       down_read(&uts_sem);
9329 +       if (access_ok(VERIFY_WRITE, name, len)) {
9330 +               --len;
9331 +               for (p = system_utsname.nodename; *p && *p != '.'; p++)
9332 +                       ;
9333 +               if (*p == '.')
9334 +                       p++;
9335 +               else
9336 +                       p = system_utsname.domainname;
9337 +
9338 +               if (strcmp(p, "(none)")) {
9339 +                       for (; *p && len > 0; p++,len--) {
9340 +                               __put_user(*p, name);
9341 +                               name++;
9342 +                       }
9343 +               }
9344 +               __put_user('\0', name);
9345 +               error = 0;
9346 +       }
9347 +       else
9348 +               error = -EFAULT;
9349 +       up_read(&uts_sem);
9350 +       return error;
9351 +}
9352 +
9353 +static int
9354 +socksys_setipdomain(u_long *sp)
9355 +{
9356 +       char                    *name, *p;
9357 +       int                     error, len, togo;
9358 +       unsigned long           *ulptr;
9359 +
9360 +       if (!capable(CAP_SYS_ADMIN))
9361 +               return -EPERM;
9362 +
9363 +       ulptr = (u_long *)&name;
9364 +       error = get_user(*ulptr, (char *)(sp+0));
9365 +       if (error)
9366 +               return error;
9367 +
9368 +       error = get_user(len, sp+1);
9369 +       if (error)
9370 +               return error;
9371 +
9372 +       down_write(&uts_sem);
9373 +       togo = __NEW_UTS_LEN;
9374 +       for (p = system_utsname.nodename; *p && *p != '.'; p++,togo--)
9375 +               ;
9376 +       if (*p == '.')
9377 +               p++,togo--;
9378 +
9379 +       error = -EINVAL;
9380 +       if (len <= togo) {
9381 +               while (len-- > 0) {
9382 +                       get_user(*p, name);
9383 +                       p++;
9384 +                       name++;
9385 +               }
9386 +               *p = '\0';
9387 +               error = 0;
9388 +       }
9389 +       up_write(&uts_sem);
9390 +       return error;
9391 +}
9392 +
9393 +static int
9394 +socksys_setreugid(int cmd, u_long *sp)
9395 +{
9396 +       uid_t                   ruid, euid;
9397 +       int                     error;
9398 +
9399 +       error = get_user(ruid, sp+0);
9400 +       if (error)
9401 +               return error;
9402 +
9403 +       error = get_user(euid, sp+1);
9404 +       if (error)
9405 +               return error;
9406 +
9407 +       return (cmd == SSYS_SO_SETREUID) ?
9408 +               sys_setreuid16(ruid, euid) :
9409 +                 sys_setregid16(ruid, euid);
9410 +}
9411 +
9412 +/*
9413 + * Get a socketpair but replace the socket file
9414 + * operations with our own so we can do the
9415 + * right thing for ioctls.
9416 + */
9417 +static int
9418 +socksys_socketpair(u_long *sp)
9419 +{
9420 +       struct file             *fp;
9421 +       struct inode            *ip;
9422 +       mm_segment_t            fs;
9423 +       int                     pairin[2], pairout[2];
9424 +       int                     error;
9425 +
9426 +       /*
9427 +        * The first two arguments are file descriptors
9428 +        * of sockets which have already been opened
9429 +        * and should now be connected back to back.
9430 +        */
9431 +       error = get_user(pairin[0], sp+0);
9432 +       if (!error)
9433 +               error = get_user(pairin[1], sp+1);
9434 +       if (error)
9435 +               return error;
9436 +
9437 +       fp = fget(pairin[0]);
9438 +       if (!fp)
9439 +               return -EBADF;
9440 +       ip = fp->f_dentry->d_inode;
9441 +
9442 +       fput(fp); /* this looks boguos */
9443 +       if (!ip || !S_ISSOCK(ip->i_mode))
9444 +               return -EBADF;
9445 +
9446 +
9447 +       /*
9448 +        * XXX Do we need to close these here?
9449 +        * XXX If we fail to connect them should they be open?
9450 +        */
9451 +       sys_close(pairin[0]);
9452 +       sys_close(pairin[1]);
9453 +
9454 +       fs = get_fs();
9455 +       set_fs(get_ds());
9456 +       error = sys_socketpair(AF_UNIX, SOCKET_I(ip)->type, 0, pairout);
9457 +       set_fs(fs);
9458 +
9459 +       if (error < 0)
9460 +               return error;
9461 +
9462 +       if (pairout[0] != pairin[0]) {
9463 +               sys_dup2(pairout[0], pairin[0]);
9464 +               sys_close(pairout[0]);
9465 +       }
9466 +
9467 +       if (pairout[1] != pairin[1]) {
9468 +               sys_dup2(pairout[1], pairin[1]);
9469 +               sys_close(pairout[1]);
9470 +       }
9471 +
9472 +       inherit_socksys_funcs(pairin[0], TS_DATA_XFER);
9473 +       inherit_socksys_funcs(pairin[1], TS_DATA_XFER);
9474 +       return 0;
9475 +}
9476 +
9477 +int
9478 +socksys_syscall(u_long *sp)
9479 +{
9480 +       int error, cmd;
9481 +       unsigned long *ulptr;
9482 +
9483 +       error = get_user(cmd, sp);
9484 +       if (error)
9485 +               return error;
9486 +       sp++;
9487 +
9488 +#if defined(CONFIG_ABI_TRACE)
9489 +       if (abi_traced(ABI_TRACE_SOCKSYS)) {
9490 +               u_long a0, a1, a2, a3, a4, a5;
9491 +               static const char * const cmd_map[] = {
9492 +                       "", "accept", "bind", "connect", "getpeername",
9493 +                       "getsockname", "getsockopt", "listen", "recv",
9494 +                       "recvfrom", "send", "sendto", "setsockopt", "shutdown",
9495 +                       "socket", "select", "getipdomain", "setipdomain",
9496 +                       "adjtime", "setreuid", "setregid", "gettimeofday",
9497 +                       "settimeofday", "getitimer", "setitimer",
9498 +                       "recvmsg", "sendmsg", "sockpair"
9499 +               };
9500 +
9501 +               get_user(a0, sp+0);
9502 +               get_user(a1, sp+1);
9503 +               get_user(a2, sp+2);
9504 +               get_user(a3, sp+3);
9505 +               get_user(a4, sp+4);
9506 +               get_user(a5, sp+5);
9507 +
9508 +               __abi_trace("socksys: %s (%d) "
9509 +                               "<0x%lx,0x%lx,0x%lx,0x%lx,0x%lx,0x%lx>\n",
9510 +                               (cmd >= 0 &&
9511 +                                cmd < sizeof(cmd_map) / sizeof(cmd_map[0]))
9512 +                               ? cmd_map[cmd] : "???", cmd,
9513 +                               a0, a1, a2, a3, a4, a5);
9514 +       }
9515 +#endif
9516 +
9517 +       switch (cmd) {
9518 +       case SSYS_SO_SOCKET:
9519 +               return socksys_socket(sp);
9520 +       case SSYS_SO_ACCEPT:
9521 +               return socksys_accept(sp);
9522 +       case SSYS_SO_BIND:
9523 +               return sys_socketcall(SYS_BIND, sp);
9524 +       case SSYS_SO_CONNECT:
9525 +               return sys_socketcall(SYS_CONNECT, sp);
9526 +       case SSYS_SO_GETPEERNAME:
9527 +               return sys_socketcall(SYS_GETPEERNAME, sp);
9528 +       case SSYS_SO_GETSOCKNAME:
9529 +               return sys_socketcall(SYS_GETSOCKNAME, sp);
9530 +       case SSYS_SO_GETSOCKOPT:
9531 +               return abi_do_getsockopt((u_long *)sp);
9532 +       case SSYS_SO_LISTEN:
9533 +               return sys_socketcall(SYS_LISTEN, sp);
9534 +       case SSYS_SO_RECV:
9535 +               if ((error = sys_socketcall(SYS_RECV, sp)) == -EAGAIN)
9536 +                       return -EWOULDBLOCK;
9537 +               return error;
9538 +       case SSYS_SO_RECVFROM:
9539 +               if ((error = sys_socketcall(SYS_RECVFROM, sp)) == -EAGAIN)
9540 +                       return -EWOULDBLOCK;
9541 +               return error;
9542 +       case SSYS_SO_SEND:
9543 +               if ((error = sys_socketcall(SYS_SEND, sp)) == -EAGAIN)
9544 +                       error = -EWOULDBLOCK;
9545 +               return error;
9546 +       case SSYS_SO_SENDTO:
9547 +               if ((error = sys_socketcall(SYS_SENDTO, sp)) == -EAGAIN)
9548 +                       error = -EWOULDBLOCK;
9549 +               return error;
9550 +       case SSYS_SO_SETSOCKOPT:
9551 +               return abi_do_setsockopt(sp);
9552 +       case SSYS_SO_SHUTDOWN:
9553 +               return sys_socketcall(SYS_SHUTDOWN, sp);
9554 +       case SSYS_SO_GETIPDOMAIN:
9555 +               return socksys_getipdomain(sp);
9556 +       case SSYS_SO_SETIPDOMAIN:
9557 +               return socksys_setipdomain(sp);
9558 +       case SSYS_SO_SETREUID:
9559 +       case SSYS_SO_SETREGID:
9560 +               return socksys_setreugid(cmd, sp);
9561 +       case SSYS_SO_GETTIME:
9562 +       case SSYS_SO_SETTIME:
9563 +       {
9564 +               struct timeval *tv;
9565 +               struct timezone *tz;
9566 +
9567 +               ulptr = (unsigned long *)&tv;
9568 +               if ((error = get_user(*ulptr, sp+0)))
9569 +                       return error;
9570 +               ulptr = (unsigned long *)&tz;
9571 +               if ((error = get_user(*ulptr, sp+1)))
9572 +                       return error;
9573 +               return (cmd == SSYS_SO_GETTIME)
9574 +                       ? sys_gettimeofday(tv, tz)
9575 +                       : sys_settimeofday(tv, tz);
9576 +       }
9577 +
9578 +       case SSYS_SO_GETITIMER:
9579 +       {
9580 +               int which;
9581 +               struct itimerval *value;
9582 +
9583 +               ulptr = (unsigned long *)&which;
9584 +               if ((error = get_user(*ulptr, sp+0)))
9585 +                       return error;
9586 +               ulptr = (unsigned long *)&value;
9587 +               if ((error = get_user(*ulptr, sp+1)))
9588 +                       return error;
9589 +               return sys_getitimer(which, value);
9590 +       }
9591 +       case SSYS_SO_SETITIMER:
9592 +       {
9593 +               int which;
9594 +               struct itimerval *value, *ovalue;
9595 +
9596 +               ulptr = (unsigned long *)&which;
9597 +               if ((error = get_user(*ulptr, sp+0)))
9598 +                       return error;
9599 +               ulptr = (unsigned long *)&value;
9600 +               if ((error = get_user(*ulptr, sp+1)))
9601 +                       return error;
9602 +               ulptr = (unsigned long *)&ovalue;
9603 +               if ((error = get_user(*ulptr, sp+2)))
9604 +                       return error;
9605 +               return sys_setitimer(which, value, ovalue);
9606 +       }
9607 +
9608 +#if BUGGY
9609 +       case SSYS_SO_SELECT:
9610 +               /*
9611 +                * This may be wrong? I don't know how to trigger
9612 +                * this case. Select seems to go via the Xenix
9613 +                * select entry point.
9614 +                */
9615 +               return sys_select(sp);
9616 +#endif
9617 +
9618 +       case SSYS_SO_ADJTIME:
9619 +               return -EINVAL;
9620 +
9621 +       /*
9622 +        * These appear in SCO 3.2v5. I assume that the format of
9623 +        * a msghdr is identical with Linux. I have not checked.
9624 +        */
9625 +       case SSYS_SO_RECVMSG:
9626 +               if ((error = sys_socketcall(SYS_RECVMSG, sp)) == -EAGAIN)
9627 +                       error = -EWOULDBLOCK;
9628 +               return error;
9629 +       case SSYS_SO_SENDMSG:
9630 +               if ((error = sys_socketcall(SYS_SENDMSG, sp)) == -EAGAIN)
9631 +                       error = -EWOULDBLOCK;
9632 +               return error;
9633 +       case SSYS_SO_SOCKPAIR:
9634 +               return socksys_socketpair(sp);
9635 +       }
9636 +
9637 +       return -EINVAL;
9638 +}
9639 +
9640 +static int
9641 +socksys_getdomainname(caddr_t arg)
9642 +{
9643 +       struct domnam_args      dn;
9644 +       char                    *p;
9645 +       int                     error = 0;
9646 +
9647 +       if (copy_from_user(&dn, arg, sizeof(struct domnam_args)))
9648 +               return -EFAULT;
9649 +
9650 +       down_read(&uts_sem);
9651 +       if (access_ok(VERIFY_WRITE, dn.name, dn.namelen)) {
9652 +               --dn.namelen;
9653 +               for (p = system_utsname.domainname; *p && dn.namelen > 0; p++) {
9654 +                       __put_user(*p, dn.name);
9655 +                       dn.name++;
9656 +                       dn.namelen--;
9657 +               }
9658 +               __put_user('\0', dn.name);
9659 +       }
9660 +       else
9661 +               error = -EFAULT;
9662 +       up_read(&uts_sem);
9663 +       return error;
9664 +}
9665 +
9666 +static int
9667 +socksys_setdomainname(caddr_t arg)
9668 +{
9669 +       struct domnam_args      dn;
9670 +
9671 +       if (copy_from_user(&dn, arg, sizeof(struct domnam_args)))
9672 +               return -EFAULT;
9673 +       return sys_setdomainname(dn.name, dn.namelen);
9674 +}
9675 +
9676 +/*
9677 + * I think this was used before symlinks were added
9678 + * to the base SCO OS?
9679 + */
9680 +static int
9681 +socksys_lstat(caddr_t arg)
9682 +{
9683 +       struct lstat_args       st;
9684 +
9685 +       if (copy_from_user(&st, arg, sizeof(struct lstat_args)))
9686 +               return -EFAULT;
9687 +       return svr4_lstat(st.fname, st.statb);
9688 +}
9689 +
9690 +static int
9691 +socksys_getfh(caddr_t arg)
9692 +{
9693 +       struct getfh_args       gf;
9694 +       struct nameidata        nd;
9695 +       int                     error;
9696 +
9697 +       if (!capable(CAP_SYS_ADMIN))
9698 +               return -EPERM;
9699 +
9700 +       if (copy_from_user(&gf, arg, sizeof(struct getfh_args)))
9701 +               return -EFAULT;
9702 +
9703 +       if (!access_ok(VERIFY_WRITE, gf.fhp, sizeof(fhandle_t)))
9704 +               return -EFAULT;
9705 +
9706 +       error = user_path_walk(gf.fname, &nd);
9707 +       if (error)
9708 +               return error;
9709 +
9710 +       error = do_revalidate(nd.dentry);
9711 +       if (!error) {
9712 +               struct inode    *ip = nd.dentry->d_inode;
9713 +
9714 +               __put_user(ip->i_rdev, &gf.fhp->fh.fsid);
9715 +               __put_user(ip->i_ino, &gf.fhp->fh.fno);
9716 +               __put_user(0L, &gf.fhp->fh.fgen);
9717 +               __put_user(ip->i_rdev, &gf.fhp->fh.ex_fsid);
9718 +               __put_user(ip->i_ino, &gf.fhp->fh.ex_fno);
9719 +               __put_user(0L, &gf.fhp->fh.ex_fgen);
9720 +               error = 0;
9721 +       }
9722 +       path_release(&nd);
9723 +       return error;
9724 +}
9725 +
9726 +static int
9727 +socksys_getpeername(int fd, caddr_t arg)
9728 +{
9729 +       struct sockaddr         uaddr;
9730 +       int                     addrlen;
9731 +       mm_segment_t            fs;
9732 +       int                     error;
9733 +
9734 +       addrlen = sizeof(struct sockaddr);
9735 +
9736 +       if (!access_ok(VERIFY_WRITE, arg, addrlen))
9737 +               return -EFAULT;
9738 +
9739 +       fs = get_fs();
9740 +       set_fs(get_ds());
9741 +       error = sys_getpeername(fd, &uaddr, &addrlen);
9742 +       set_fs(fs);
9743 +
9744 +       if (error >= 0)
9745 +               if (copy_to_user(arg, &uaddr, addrlen))
9746 +                       error = -EFAULT;
9747 +       return error;
9748 +}
9749 +
9750 +static int
9751 +socksys_getsockname(int fd, caddr_t arg)
9752 +{
9753 +       struct sockaddr         uaddr;
9754 +       int                     addrlen;
9755 +       mm_segment_t            fs;
9756 +       int                     error;
9757 +
9758 +       addrlen = sizeof(struct sockaddr);
9759 +
9760 +       if (!access_ok(VERIFY_WRITE, arg, addrlen))
9761 +               return -EFAULT;
9762 +
9763 +       fs = get_fs();
9764 +       set_fs(get_ds());
9765 +       error = sys_getsockname(fd, &uaddr, &addrlen);
9766 +       set_fs(fs);
9767 +
9768 +       if (error >= 0)
9769 +               if (copy_to_user(arg, &uaddr, addrlen))
9770 +                       error = -EFAULT;
9771 +       return error;
9772 +}
9773 +
9774 +static int
9775 +socksys_gifonep(caddr_t data)
9776 +{
9777 +       return -EOPNOTSUPP;
9778 +}
9779 +
9780 +static int
9781 +socksys_sifonep(caddr_t data)
9782 +{
9783 +#if 0
9784 +       struct svr4_ifreq       *ifr = (struct svr4_ifreq *)data;
9785 +
9786 +       printk("SIOCSIFONEP (spsize = %x, spthresh = %x) not supported\n",
9787 +                       ifr->svr4_ifr_onepacket.spsize,
9788 +                       ifr->svr4_ifr_onepacket.spthresh);
9789 +#endif
9790 +       return -EOPNOTSUPP;
9791 +}
9792 +
9793 +int
9794 +abi_ioctl_socksys(int fd, unsigned int cmd, caddr_t arg)
9795 +{
9796 +       int error;
9797 +
9798 +       switch (cmd) {
9799 +       /*
9800 +        * Strictly the ip domain and nis domain are separate and
9801 +        * distinct under SCO but Linux only has the one domain.
9802 +        */
9803 +       case NIOCGETDOMNAM:
9804 +               return socksys_getdomainname(arg);
9805 +       case NIOCSETDOMNAM:
9806 +               return socksys_setdomainname(arg);
9807 +       case NIOCLSTAT:
9808 +               return socksys_lstat(arg);
9809 +       case NIOCOLDGETFH:
9810 +       case NIOCGETFH:
9811 +               return socksys_getfh(arg);
9812 +       case NIOCNFSD:
9813 +       case NIOCASYNCD:
9814 +       case NIOCCLNTHAND:
9815 +       case NIOCEXPORTFS:
9816 +               return -EINVAL;
9817 +
9818 +       case SSYS_SIOCSOCKSYS:          /* Pseudo socket syscall */
9819 +       case SVR4_SIOCSOCKSYS:
9820 +               return socksys_syscall((u_long *)arg);
9821 +
9822 +       case SSYS_SIOCSHIWAT:           /* set high watermark */
9823 +       case SVR4_SIOCSHIWAT:
9824 +       case SSYS_SIOCSLOWAT:           /* set low watermark */
9825 +       case SVR4_SIOCSLOWAT:
9826 +               /*
9827 +                * Linux doesn't support them but lie anyway
9828 +                * or some things take it as fatal (why?)
9829 +                *
9830 +                * FIXME: actually we can do this now...
9831 +                */
9832 +               return 0;
9833 +       case SSYS_SIOCGHIWAT:           /* get high watermark */
9834 +       case SVR4_SIOCGHIWAT:
9835 +       case SSYS_SIOCGLOWAT:           /* get low watermark */
9836 +       case SVR4_SIOCGLOWAT:
9837 +               /*
9838 +                * Linux doesn't support them but lie anyway
9839 +                * or some things take it as fatal (why?)
9840 +                *
9841 +                * FIXME: actually we can do this now...
9842 +                */
9843 +               if (!access_ok(VERIFY_WRITE, arg, sizeof(u_long)))
9844 +                       return -EFAULT;
9845 +               put_user(0, (u_long *)arg);
9846 +               return 0;
9847 +       case SSYS_SIOCATMARK:           /* at oob mark? */
9848 +       case SVR4_SIOCATMARK:
9849 +               return sys_ioctl(fd, SIOCATMARK, (long)arg);
9850 +
9851 +       case SSYS_SIOCSPGRP:            /* set process group */
9852 +       case SVR4_SIOCSPGRP:
9853 +               return sys_ioctl(fd, SIOCSPGRP, (long)arg);
9854 +       case SSYS_SIOCGPGRP:            /* get process group */
9855 +       case SVR4_SIOCGPGRP:
9856 +               return sys_ioctl(fd, SIOCGPGRP, (long)arg);
9857 +
9858 +       case FIONREAD:
9859 +       case SSYS_FIONREAD:             /* BSD compatibilty */
9860 +               error = sys_ioctl(fd, TIOCINQ, (long)arg);
9861 +#if defined(CONFIG_ABI_TRACE)
9862 +               if (!error && abi_traced(ABI_TRACE_SOCKSYS)) {
9863 +                       u_long n;
9864 +
9865 +                       get_user(n, (u_long *)arg);
9866 +                       __abi_trace("socksys: %d FIONREAD "
9867 +                                       "found %lu bytes ready\n",
9868 +                                       fd, n);
9869 +               }
9870 +#endif
9871 +               return error;
9872 +       case SSYS_FIONBIO:              /* BSD compatibilty */
9873 +               return sys_ioctl(fd, FIONBIO, (long)arg);
9874 +       case SSYS_FIOASYNC:             /* BSD compatibilty */
9875 +               return sys_ioctl(fd, FIOASYNC, (long)arg);
9876 +       case SSYS_SIOCADDRT:            /* add route */
9877 +       case SVR4_SIOCADDRT:
9878 +               return sys_ioctl(fd, SIOCADDRT, (long)arg);
9879 +       case SSYS_SIOCDELRT:            /* delete route */
9880 +       case SVR4_SIOCDELRT:
9881 +               return sys_ioctl(fd, SIOCDELRT, (long)arg);
9882 +       case SSYS_SIOCSIFADDR:          /* set ifnet address */
9883 +       case SVR4_SIOCSIFADDR:
9884 +               return sys_ioctl(fd, SIOCSIFADDR, (long)arg);
9885 +       case SSYS_SIOCGIFADDR:          /* get ifnet address */
9886 +       case SVR4_SIOCGIFADDR:
9887 +               return sys_ioctl(fd, SIOCGIFADDR, (long)arg);
9888 +       case SSYS_SIOCSIFDSTADDR:       /* set p-p address */
9889 +       case SVR4_SIOCSIFDSTADDR:
9890 +               return sys_ioctl(fd, SIOCSIFDSTADDR, (long)arg);
9891 +       case SSYS_SIOCGIFDSTADDR:       /* get p-p address */
9892 +       case SVR4_SIOCGIFDSTADDR:
9893 +               return sys_ioctl(fd, SIOCGIFDSTADDR, (long)arg);
9894 +       case SSYS_SIOCSIFFLAGS:         /* set ifnet flags */
9895 +       case SVR4_SIOCSIFFLAGS:
9896 +               return sys_ioctl(fd, SIOCSIFFLAGS, (long)arg);
9897 +       case SSYS_SIOCGIFFLAGS:         /* get ifnet flags */
9898 +       case SVR4_SIOCGIFFLAGS:
9899 +#if 0
9900 +       case SVRX_SIOCGIFFLAGS:
9901 +#endif
9902 +               return sys_ioctl(fd, SIOCGIFFLAGS, (long)arg);
9903 +       case SSYS_SIOCGIFCONF:          /* get ifnet list */
9904 +       case SVR4_SIOCGIFCONF:
9905 +#if 0
9906 +       case SVRX_SIOCGIFCONF:
9907 +#endif
9908 +               return sys_ioctl(fd, SIOCGIFCONF, (long)arg);
9909 +       case SSYS_SIOCGIFBRDADDR:       /* get broadcast addr */
9910 +       case SVR4_SIOCGIFBRDADDR:
9911 +               return sys_ioctl(fd, SIOCGIFBRDADDR, (long)arg);
9912 +       case SSYS_SIOCSIFBRDADDR:       /* set broadcast addr */
9913 +       case SVR4_SIOCSIFBRDADDR:
9914 +               return sys_ioctl(fd, SIOCSIFBRDADDR, (long)arg);
9915 +       case SSYS_SIOCGIFNETMASK:       /* get net addr mask */
9916 +       case SVR4_SIOCGIFNETMASK:
9917 +               return sys_ioctl(fd, SIOCGIFNETMASK, (long)arg);
9918 +       case SSYS_SIOCSIFNETMASK:       /* set net addr mask */
9919 +               return sys_ioctl(fd, SIOCSIFNETMASK, (long)arg);
9920 +       case SSYS_SIOCGIFMETRIC:        /* get IF metric */
9921 +       case SVR4_SIOCGIFMETRIC:
9922 +               return sys_ioctl(fd, SIOCGIFMETRIC, (long)arg);
9923 +       case SSYS_SIOCSIFMETRIC:        /* set IF metric */
9924 +       case SVR4_SIOCSIFMETRIC:
9925 +               return sys_ioctl(fd, SIOCSIFMETRIC, (long)arg);
9926 +       case SSYS_SIOCSARP:             /* set arp entry */
9927 +       case SVR4_SIOCSARP:
9928 +               return sys_ioctl(fd, SIOCSARP, (long)arg);
9929 +       case SSYS_SIOCGARP:             /* get arp entry */
9930 +       case SVR4_SIOCGARP:
9931 +               return sys_ioctl(fd, SIOCGARP, (long)arg);
9932 +       case SSYS_SIOCDARP:             /* delete arp entry */
9933 +       case SVR4_SIOCDARP:
9934 +               return sys_ioctl(fd, SIOCDARP, (long)arg);
9935 +       case SSYS_SIOCGENADDR:          /* Get ethernet addr */
9936 +       case SVR4_SIOCGENADDR:
9937 +               return sys_ioctl(fd, SIOCGIFHWADDR, (long)arg);
9938 +       case SSYS_SIOCSIFMTU:           /* get if_mtu */
9939 +       case SVR4_SIOCSIFMTU:
9940 +               return sys_ioctl(fd, SIOCSIFMTU, (long)arg);
9941 +       case SSYS_SIOCGIFMTU:           /* set if_mtu */
9942 +       case SVR4_SIOCGIFMTU:
9943 +               return sys_ioctl(fd, SIOCGIFMTU, (long)arg);
9944 +
9945 +       case SSYS_SIOCGETNAME:          /* getsockname */
9946 +       case SVR4_SIOCGETNAME:
9947 +               return socksys_getsockname(fd, arg);
9948 +       case SSYS_SIOCGETPEER:          /* getpeername */
9949 +       case SVR4_SIOCGETPEER:
9950 +               return socksys_getpeername(fd, arg);
9951 +
9952 +       case SSYS_IF_UNITSEL:           /* set unit number */
9953 +       case SVR4_IF_UNITSEL:
9954 +       case SSYS_SIOCXPROTO:           /* empty proto table */
9955 +       case SVR4_SIOCXPROTO:
9956 +
9957 +       case SSYS_SIOCIFDETACH:         /* detach interface */
9958 +       case SVR4_SIOCIFDETACH:
9959 +       case SSYS_SIOCGENPSTATS:        /* get ENP stats */
9960 +       case SVR4_SIOCGENPSTATS:
9961 +
9962 +       case SSYS_SIOCSIFNAME:          /* set interface name */
9963 +       case SVR4_SIOCSIFNAME:
9964 +
9965 +       case SSYS_SIOCPROTO:            /* link proto */
9966 +       case SVR4_SIOCPROTO:
9967 +       case SSYS_SIOCX25XMT:
9968 +       case SVR4_SIOCX25XMT:
9969 +       case SSYS_SIOCX25RCV:
9970 +       case SVR4_SIOCX25RCV:
9971 +       case SSYS_SIOCX25TBL:
9972 +       case SVR4_SIOCX25TBL:
9973 +
9974 +       case SSYS_SIOCGIFONEP:          /* get one-packet params */
9975 +               return socksys_gifonep(arg);
9976 +       case SSYS_SIOCSIFONEP:          /* set one-packet params */
9977 +               return socksys_sifonep(arg);
9978 +
9979 +       default:
9980 +               printk(KERN_DEBUG "%d iBCS: socksys: %d: ioctl 0x%x with argument 0x%p requested\n",
9981 +                       current->pid, fd, cmd, arg);
9982 +               break;
9983 +       }
9984 +
9985 +       return -EINVAL;
9986 +}
9987 +
9988 +static int __init
9989 +socksys_init(void)
9990 +{
9991 +       int ret;
9992 +
9993 +       if ((ret = register_chrdev(SOCKSYS_MAJOR, "socksys", &socksys_fops))) {
9994 +               printk(KERN_ERR "abi: unable register socksys char major\n");
9995 +               return (ret);
9996 +       }
9997 +
9998 +       fops_get(&socket_file_ops);
9999 +       socksys_socket_fops = socket_file_ops;
10000 +#ifdef CONFIG_ABI_XTI
10001 +       socksys_socket_fops.release = socksys_release;
10002 +       socksys_socket_fops.poll = socksys_poll;
10003 +#endif
10004 +       return (0);
10005 +}
10006 +
10007 +static void __exit
10008 +socksys_exit(void)
10009 +{
10010 +       fops_put(&socket_file_ops);
10011 +       unregister_chrdev(SOCKSYS_MAJOR, "socksys");
10012 +}
10013 +
10014 +module_init(socksys_init);
10015 +module_exit(socksys_exit);
10016 +
10017 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
10018 +EXPORT_SYMBOL(abi_ioctl_socksys);
10019 +EXPORT_SYMBOL(socksys_syscall);
10020 +#endif
10021 diff -Nur kernel-source-2.6.16.orig/abi/svr4/stat.c kernel-source-2.6.16/abi/svr4/stat.c
10022 --- kernel-source-2.6.16.orig/abi/svr4/stat.c   1970-01-01 10:00:00.000000000 +1000
10023 +++ kernel-source-2.6.16/abi/svr4/stat.c        2006-04-27 18:50:24.000000000 +1000
10024 @@ -0,0 +1,223 @@
10025 +/*
10026 + * Copyright (c) 2001 Caldera Deutschland GmbH.
10027 + * Copyright (c) 2001 Christoph Hellwig.
10028 + * All rights reserved.
10029 + *
10030 + * This program is free software; you can redistribute it and/or modify
10031 + * it under the terms of the GNU General Public License as published by
10032 + * the Free Software Foundation; either version 2 of the License, or
10033 + * (at your option) any later version.
10034 + *
10035 + * This program is distributed in the hope that it will be useful,
10036 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
10037 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10038 + * GNU General Public License for more details.
10039 + *
10040 + * You should have received a copy of the GNU General Public License
10041 + * along with this program; if not, write to the Free Software
10042 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
10043 + */
10044 +
10045 +#ident "%W% %G%"
10046 +
10047 +/*
10048 + * SVR4 stat & friends support.
10049 + */
10050 +#include <linux/kernel.h>
10051 +#include <linux/fs.h>
10052 +#include <linux/sched.h>
10053 +#include <linux/file.h>
10054 +#include <linux/string.h>
10055 +#include <linux/module.h>
10056 +#include <asm/uaccess.h>
10057 +
10058 +#include <abi/svr4/types.h>
10059 +#include <abi/svr4/stat.h>
10060 +
10061 +#include <abi/util/stat.h>
10062 +#include <abi/util/trace.h>
10063 +
10064 +
10065 +enum {SVR4_stat = 1, SVR4_xstat = 2};
10066 +
10067 +int
10068 +report_svr4_stat(struct kstat *stp, struct svr4_stat *bufp)
10069 +{
10070 +       struct svr4_stat buf;
10071 +
10072 +       memset(&buf, 0, sizeof(struct svr4_stat));
10073 +
10074 +
10075 +       buf.st_dev      = linux_to_svr4_o_dev_t(stp->dev);
10076 +       buf.st_ino      = linux_to_svr4_o_ino_t(stp->ino);
10077 +       buf.st_mode     = stp->mode;
10078 +       buf.st_nlink    = stp->nlink;
10079 +       buf.st_uid      = linux_to_svr4_o_uid_t(stp->uid);
10080 +       buf.st_gid      = linux_to_svr4_o_gid_t(stp->gid);
10081 +       buf.st_rdev     = linux_to_svr4_o_dev_t(stp->rdev);
10082 +
10083 +       if (stp->size > MAX_NON_LFS)
10084 +               return -EOVERFLOW;      /* XXX: what to return for SVR4?? */
10085 +
10086 +       buf.st_size     = stp->size;
10087 +
10088 +       buf.st_atime    = stp->atime.tv_sec;
10089 +       buf.st_mtime    = stp->mtime.tv_sec;
10090 +       buf.st_ctime    = stp->ctime.tv_sec;
10091 +
10092 +       if (copy_to_user(bufp, &buf, sizeof(struct svr4_stat)))
10093 +               return -EFAULT;
10094 +       return 0;
10095 +}
10096 +
10097 +int
10098 +report_svr4_xstat(struct kstat *stp, struct svr4_xstat *bufp)
10099 +{
10100 +       struct svr4_xstat buf;
10101 +
10102 +       memset(&buf, 0, sizeof(struct svr4_xstat));
10103 +
10104 +
10105 +       buf.st_dev      = linux_to_svr4_dev_t(stp->dev);
10106 +       buf.st_ino      = linux_to_svr4_ino_t(stp->ino);
10107 +       buf.st_mode     = stp->mode;
10108 +       buf.st_nlink    = stp->nlink;
10109 +       buf.st_uid      = linux_to_svr4_uid_t(stp->uid);
10110 +       buf.st_gid      = linux_to_svr4_gid_t(stp->gid);
10111 +       buf.st_rdev     = linux_to_svr4_dev_t(stp->rdev);
10112 +
10113 +       if (stp->size > MAX_NON_LFS)
10114 +               return -EOVERFLOW;      /* XXX: what to return for SVR4?? */
10115 +
10116 +       buf.st_size     = stp->size;
10117 +
10118 +       buf.st_atim.tv_sec = stp->atime.tv_sec;
10119 +       buf.st_atim.tv_usec = stp->atime.tv_nsec / 1000;
10120 +       buf.st_mtim.tv_sec = stp->mtime.tv_sec;
10121 +       buf.st_mtim.tv_usec = stp->mtime.tv_nsec / 1000;
10122 +       buf.st_ctim.tv_sec = stp->ctime.tv_sec;
10123 +       buf.st_ctim.tv_usec = stp->ctime.tv_nsec / 1000;
10124 +
10125 +       buf.st_blksize  = stp->blksize;
10126 +       buf.st_blocks   = stp->blocks;
10127 +
10128 +       if (copy_to_user(bufp, &buf, sizeof(struct svr4_xstat)))
10129 +               return -EFAULT;
10130 +       return 0;
10131 +}
10132 +
10133 +int
10134 +svr4_stat(char *filename, struct svr4_stat *bufp)
10135 +{
10136 +       struct kstat st;
10137 +       int error;
10138 +
10139 +       error = vfs_stat(filename, &st);
10140 +       if (!error)
10141 +               error = report_svr4_stat(&st, bufp);
10142 +       return error;
10143 +}
10144 +
10145 +int
10146 +svr4_lstat(char *filename, struct svr4_stat *bufp)
10147 +{
10148 +       struct kstat st;
10149 +       int error;
10150 +
10151 +       error = vfs_lstat(filename, &st);
10152 +       if (!error)
10153 +               error = report_svr4_stat(&st, bufp);
10154 +       return error;
10155 +}
10156 +
10157 +int
10158 +svr4_fstat(int fd, struct svr4_stat *bufp)
10159 +{
10160 +       struct kstat st;
10161 +       int error;
10162 +
10163 +       error = vfs_fstat(fd, &st);
10164 +       if (!error)
10165 +               error = report_svr4_stat(&st, bufp);
10166 +       return error;
10167 +}
10168 +
10169 +int
10170 +svr4_xstat(int vers, char *filename, void *bufp)
10171 +{
10172 +       struct kstat st;
10173 +       int error;
10174 +
10175 +       error = vfs_stat(filename, &st);
10176 +       if (error)
10177 +               return error;
10178 +
10179 +       switch (vers) {
10180 +       case SVR4_stat:
10181 +               return report_svr4_stat(&st, bufp);
10182 +       case SVR4_xstat:
10183 +               return report_svr4_xstat(&st, bufp);
10184 +       }
10185 +
10186 +#if defined(CONFIG_ABI_TRACE)
10187 +       abi_trace(ABI_TRACE_API, "xstat version %d not supported\n", vers);
10188 +#endif
10189 +       return -EINVAL;
10190 +}
10191 +
10192 +int
10193 +svr4_lxstat(int vers, char *filename, void *bufp)
10194 +{
10195 +       struct kstat st;
10196 +       int error;
10197 +
10198 +       error = vfs_lstat(filename, &st);
10199 +       if (error)
10200 +               return error;
10201 +
10202 +       switch (vers) {
10203 +       case SVR4_stat:
10204 +               return report_svr4_stat(&st, bufp);
10205 +       case SVR4_xstat:
10206 +               return report_svr4_xstat(&st, bufp);
10207 +       }
10208 +
10209 +#if defined(CONFIG_ABI_TRACE)
10210 +       abi_trace(ABI_TRACE_API, "lxstat version %d not supported\n", vers);
10211 +#endif
10212 +       return -EINVAL;
10213 +}
10214 +
10215 +int
10216 +svr4_fxstat(int vers, int fd, void *bufp)
10217 +{
10218 +       struct kstat st;
10219 +       int error;
10220 +
10221 +       error = vfs_fstat(fd, &st);
10222 +       if (error)
10223 +               return error;
10224 +
10225 +       switch (vers) {
10226 +       case SVR4_stat:
10227 +               return report_svr4_stat(&st, bufp);
10228 +       case SVR4_xstat:
10229 +               return report_svr4_xstat(&st, bufp);
10230 +       }
10231 +
10232 +#if defined(CONFIG_ABI_TRACE)
10233 +       abi_trace(ABI_TRACE_API, "fxstat version %d not supported\n", vers);
10234 +#endif
10235 +       return -EINVAL;
10236 +}
10237 +
10238 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
10239 +EXPORT_SYMBOL(report_svr4_stat);
10240 +EXPORT_SYMBOL(report_svr4_xstat);
10241 +EXPORT_SYMBOL(svr4_fstat);
10242 +EXPORT_SYMBOL(svr4_fxstat);
10243 +EXPORT_SYMBOL(svr4_lstat);
10244 +EXPORT_SYMBOL(svr4_lxstat);
10245 +EXPORT_SYMBOL(svr4_stat);
10246 +EXPORT_SYMBOL(svr4_xstat);
10247 +#endif
10248 diff -Nur kernel-source-2.6.16.orig/abi/svr4/statvfs.c kernel-source-2.6.16/abi/svr4/statvfs.c
10249 --- kernel-source-2.6.16.orig/abi/svr4/statvfs.c        1970-01-01 10:00:00.000000000 +1000
10250 +++ kernel-source-2.6.16/abi/svr4/statvfs.c     2006-04-27 18:50:24.000000000 +1000
10251 @@ -0,0 +1,124 @@
10252 +/*
10253 + * Copyright (c) 2001 Caldera Deutschland GmbH.
10254 + * Copyright (c) 2001 Christoph Hellwig.
10255 + * All rights reserved.
10256 + *
10257 + * This program is free software; you can redistribute it and/or modify
10258 + * it under the terms of the GNU General Public License as published by
10259 + * the Free Software Foundation; either version 2 of the License, or
10260 + * (at your option) any later version.
10261 + *
10262 + * This program is distributed in the hope that it will be useful,
10263 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
10264 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10265 + * GNU General Public License for more details.
10266 + *
10267 + * You should have received a copy of the GNU General Public License
10268 + * along with this program; if not, write to the Free Software
10269 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
10270 + */
10271 +
10272 +#ident "%W% %G%"
10273 +
10274 +/*
10275 + * SVR4 statvfs/fstatvfs support.
10276 + */
10277 +#include <linux/kernel.h>
10278 +#include <linux/fs.h>
10279 +#include <linux/statfs.h>
10280 +#include <linux/mount.h>
10281 +#include <linux/sched.h>
10282 +#include <linux/file.h>
10283 +#include <linux/string.h>
10284 +#include <linux/namei.h>
10285 +#include <linux/module.h>
10286 +#include <asm/uaccess.h>
10287 +
10288 +
10289 +struct svr4_statvfs {
10290 +       u_int32_t  f_bsize;
10291 +       u_int32_t  f_frsize;
10292 +       u_int32_t  f_blocks;
10293 +       u_int32_t  f_bfree;
10294 +       u_int32_t  f_bavail;
10295 +       u_int32_t  f_files;
10296 +       u_int32_t  f_free;
10297 +       u_int32_t  f_sid;
10298 +       char       f_basetype[16];
10299 +       u_int32_t  f_flag;
10300 +       u_int32_t  f_namemax;
10301 +       char       f_fstr[32];
10302 +       u_int32_t  f_filler[16];
10303 +};
10304 +
10305 +static int
10306 +report_statvfs(struct vfsmount *mnt, struct inode *ip, struct svr4_statvfs *bufp)
10307 +{
10308 +       struct svr4_statvfs buf;
10309 +       struct kstatfs s;
10310 +       int error;
10311 +
10312 +       error = vfs_statfs(mnt->mnt_sb, &s);
10313 +       if (error)
10314 +               return error;
10315 +
10316 +       memset(&buf, 0, sizeof(struct svr4_statvfs));
10317 +
10318 +       buf.f_bsize     = s.f_bsize;
10319 +       buf.f_frsize    = s.f_bsize;
10320 +       buf.f_blocks    = s.f_blocks;
10321 +       buf.f_bfree     = s.f_bfree;
10322 +       buf.f_bavail    = s.f_bavail;
10323 +       buf.f_files     = s.f_files;
10324 +       buf.f_free      = s.f_ffree;
10325 +       buf.f_sid       = ip->i_sb->s_dev;
10326 +
10327 +       /* Get the name of the filesystem */
10328 +       strcpy(buf.f_basetype, ip->i_sb->s_type->name);
10329 +
10330 +       /* Check for a few flags statvfs wants but statfs doesn't have. */
10331 +       if (IS_RDONLY(ip))
10332 +               buf.f_flag |= 1;
10333 +       if (mnt->mnt_flags & MNT_NOSUID)
10334 +               buf.f_flag |= 2;
10335 +
10336 +       buf.f_namemax   = s.f_namelen;
10337 +
10338 +       if (copy_to_user(bufp, &buf, sizeof(struct svr4_statvfs)))
10339 +               return -EFAULT;
10340 +       return 0;
10341 +}
10342 +
10343 +int
10344 +svr4_statvfs(char *filename, struct svr4_statvfs *bufp)
10345 +{
10346 +       struct nameidata nd;
10347 +       int error;
10348 +
10349 +       error = user_path_walk(filename, &nd);
10350 +       if (!error) {
10351 +               error = report_statvfs(nd.mnt, nd.dentry->d_inode, bufp);
10352 +               path_release(&nd);
10353 +       }
10354 +       return error;
10355 +}
10356 +
10357 +int
10358 +svr4_fstatvfs(int fd, struct svr4_statvfs *bufp)
10359 +{
10360 +       struct file *fp;
10361 +       int error = -EBADF;
10362 +
10363 +       fp = fget(fd);
10364 +       if (fp) {
10365 +               error = report_statvfs(fp->f_vfsmnt,
10366 +                               fp->f_dentry->d_inode, bufp);
10367 +               fput(fp);
10368 +       }
10369 +       return error;
10370 +}
10371 +
10372 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
10373 +EXPORT_SYMBOL(svr4_statvfs);
10374 +EXPORT_SYMBOL(svr4_fstatvfs);
10375 +#endif
10376 diff -Nur kernel-source-2.6.16.orig/abi/svr4/stream.c kernel-source-2.6.16/abi/svr4/stream.c
10377 --- kernel-source-2.6.16.orig/abi/svr4/stream.c 1970-01-01 10:00:00.000000000 +1000
10378 +++ kernel-source-2.6.16/abi/svr4/stream.c      2006-04-27 18:50:24.000000000 +1000
10379 @@ -0,0 +1,114 @@
10380 +/*
10381 + * Copyright 1994,1995 Mike Jagdis (jaggy@purplet.demon.co.uk)
10382 + */
10383 +
10384 +#ident "%W% %G%"
10385 +
10386 +#include <linux/config.h>
10387 +#include <linux/errno.h>
10388 +#include <linux/ptrace.h>
10389 +#include <linux/sched.h>
10390 +#include <linux/file.h>
10391 +#include <linux/fs.h>
10392 +#include <linux/module.h>
10393 +#include <asm/uaccess.h>
10394 +
10395 +#include <asm/abi_machdep.h>
10396 +#include <abi/tli.h>
10397 +
10398 +
10399 +#if !defined(CONFIG_ABI_XTI) && !defined(CONFIG_ABI_SPX)
10400 +#  define timod_getmsg(fd, ino, is_pmsg, regs) 0
10401 +#  define timod_putmsg(fd, ino, is_pmsg, regs) 0
10402 +#endif
10403 +
10404 +/*
10405 + * Check if the inode belongs to /dev/spx.
10406 + */
10407 +#define IS_SPX(ip) ((MAJOR((ip)->i_rdev) == 30 && MINOR((ip)->i_rdev) == 1))
10408 +
10409 +
10410 +int
10411 +svr4_getmsg(struct pt_regs *regs)
10412 +{
10413 +       struct file             *fp;
10414 +       struct inode            *ip;
10415 +       int                     fd;
10416 +       int                     error = -EBADF;
10417 +
10418 +       fd = (int)get_syscall_parameter(regs, 0);
10419 +       fp = fget(fd);
10420 +       if (fp) {
10421 +               ip = fp->f_dentry->d_inode;
10422 +               if (S_ISSOCK(ip->i_mode))
10423 +                       error = timod_getmsg(fd, ip, 0, regs);
10424 +               fput(fp);
10425 +       }
10426 +       return error;
10427 +}
10428 +
10429 +int
10430 +svr4_putmsg(struct pt_regs *regs)
10431 +{
10432 +       struct file             *fp;
10433 +       struct inode            *ip;
10434 +       int                     fd;
10435 +       int                     error = -EBADF;
10436 +
10437 +       fd = (int)get_syscall_parameter(regs, 0);
10438 +       fp = fget(fd);
10439 +       if (fp) {
10440 +               ip = fp->f_dentry->d_inode;
10441 +               if (S_ISSOCK(ip->i_mode) || IS_SPX(ip))
10442 +                       error = timod_putmsg(fd, ip, 0, regs);
10443 +               fput(fp);
10444 +       }
10445 +       return error;
10446 +}
10447 +
10448 +#ifdef CONFIG_ABI_XTI
10449 +int
10450 +svr4_getpmsg(struct pt_regs *regs)
10451 +{
10452 +       struct file             *fp;
10453 +       struct inode            *ip;
10454 +       int                     fd;
10455 +       int                     error = -EBADF;
10456 +
10457 +       fd = (int)get_syscall_parameter(regs, 0);
10458 +       fp = fget(fd);
10459 +       if (fp) {
10460 +               ip = fp->f_dentry->d_inode;
10461 +               if (S_ISSOCK(ip->i_mode))
10462 +                       error = timod_getmsg(fd, ip, 1, regs);
10463 +               fput(fp);
10464 +       }
10465 +       return error;
10466 +}
10467 +
10468 +int
10469 +svr4_putpmsg(struct pt_regs *regs)
10470 +{
10471 +       struct file             *fp;
10472 +       struct inode            *ip;
10473 +       int                     fd;
10474 +       int                     error = -EBADF;
10475 +
10476 +       fd = (int)get_syscall_parameter(regs, 0);
10477 +       fp = fget(fd);
10478 +       if (fp) {
10479 +               ip = fp->f_dentry->d_inode;
10480 +               if (S_ISSOCK(ip->i_mode) || IS_SPX(ip))
10481 +                       error = timod_putmsg(fd, ip, 1, regs);
10482 +               fput(fp);
10483 +       }
10484 +       return error;
10485 +}
10486 +#endif /* CONFIG_ABI_XTI */
10487 +
10488 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
10489 +EXPORT_SYMBOL(svr4_getmsg);
10490 +EXPORT_SYMBOL(svr4_getpmsg);
10491 +EXPORT_SYMBOL(svr4_putmsg);
10492 +EXPORT_SYMBOL(svr4_putpmsg);
10493 +#endif
10494 diff -Nur kernel-source-2.6.16.orig/abi/svr4/svr4.c kernel-source-2.6.16/abi/svr4/svr4.c
10495 --- kernel-source-2.6.16.orig/abi/svr4/svr4.c   1970-01-01 10:00:00.000000000 +1000
10496 +++ kernel-source-2.6.16/abi/svr4/svr4.c        2006-04-27 18:50:24.000000000 +1000
10497 @@ -0,0 +1,331 @@
10498 +/*
10499 + * Copyright (C) 1995  Mike Jagdis
10500 + */
10501 +
10502 +#ident "%W% %G%"
10503 +
10504 +#include <linux/types.h>
10505 +#include <linux/errno.h>
10506 +#include <linux/sched.h>
10507 +#include <linux/kernel.h>
10508 +#include <linux/mm.h>
10509 +#include <linux/stddef.h>
10510 +#include <linux/unistd.h>
10511 +#include <linux/ptrace.h>
10512 +#include <linux/fcntl.h>
10513 +#include <linux/time.h>
10514 +#include <linux/fs.h>
10515 +#include <linux/statfs.h>
10516 +#include <linux/sys.h>
10517 +#include <linux/slab.h>
10518 +#include <linux/personality.h>
10519 +#include <linux/syscalls.h>
10520 +#include <linux/module.h>
10521 +#include <asm/uaccess.h>
10522 +
10523 +#include <asm/abi_machdep.h>
10524 +#include <abi/svr4/sigset.h>
10525 +#include <abi/svr4/siginfo.h>
10526 +
10527 +#include <abi/util/trace.h>
10528 +
10529 +
10530 +/*
10531 + * Interactive SVR4's /bin/sh calls access(... 011) but Linux returns
10532 + * EINVAL if the access mode has any other bits than 007 set.
10533 + */
10534 +
10535 +int
10536 +svr4_access(char *path, int mode)
10537 +{
10538 +       return sys_access(path, mode & 007);
10539 +}
10540 +
10541 +
10542 +enum {
10543 +       SVR4_CLD_EXITED = 1,
10544 +       SVR4_CLD_KILLED = 2,
10545 +       SVR4_CLD_DUMPED = 3,
10546 +       SVR4_CLD_TRAPPED = 4,
10547 +       SVR4_CLD_STOPPED = 5,
10548 +       SVR4_CLD_CONTINUED = 6
10549 +};
10550 +
10551 +int
10552 +svr4_waitid(int idtype, int id, struct svr4_siginfo *infop, int options)
10553 +{
10554 +       long result, kopt;
10555 +       mm_segment_t old_fs;
10556 +       int pid, status;
10557 +
10558 +       switch (idtype) {
10559 +               case 0: /* P_PID */
10560 +                       pid = id;
10561 +                       break;
10562 +
10563 +               case 1: /* P_PGID */
10564 +                       pid = -id;
10565 +                       break;
10566 +
10567 +               case 7: /* P_ALL */
10568 +                       pid = -1;
10569 +                       break;
10570 +
10571 +               default:
10572 +                       return -EINVAL;
10573 +       }
10574 +
10575 +       if (infop) {
10576 +               if (!access_ok(VERIFY_WRITE, infop,
10577 +                                       sizeof(struct svr4_siginfo)))
10578 +                       return -EFAULT;
10579 +       }
10580 +
10581 +       kopt = 0;
10582 +       if (options & 0100) kopt |= WNOHANG;
10583 +       if (options & 4) kopt |= WUNTRACED;
10584 +
10585 +       old_fs = get_fs();
10586 +       set_fs(get_ds());
10587 +       result = sys_wait4(pid, &status, kopt, NULL);
10588 +       set_fs(old_fs);
10589 +       if (result < 0)
10590 +               return result;
10591 +
10592 +       if (infop) {
10593 +               unsigned long op, st;
10594 +
10595 +               put_user(current_thread_info()->exec_domain->signal_map[SIGCHLD],
10596 +                       &infop->si_signo);
10597 +               put_user(result,
10598 +                       &infop->_data._proc._pid);
10599 +
10600 +               if ((status & 0xff) == 0) {
10601 +                       /* Normal exit. */
10602 +                       op = SVR4_CLD_EXITED;
10603 +                       st = status >> 8;
10604 +               } else if ((status & 0xff) == 0x7f) {
10605 +                       /* Stopped. */
10606 +                       st = (status & 0xff00) >> 8;
10607 +                       op = (st == SIGSTOP || st == SIGTSTP)
10608 +                               ? SVR4_CLD_STOPPED
10609 +                               : SVR4_CLD_CONTINUED;
10610 +                       st = current_thread_info()->exec_domain->signal_invmap[st];
10611 +               } else {
10612 +                       st = (status & 0xff00) >> 8;
10613 +                       op = (status & 0200)
10614 +                               ? SVR4_CLD_DUMPED
10615 +                               : SVR4_CLD_KILLED;
10616 +                       st = current_thread_info()->exec_domain->signal_invmap[st];
10617 +               }
10618 +               put_user(op, &infop->si_code);
10619 +               put_user(st, &infop->_data._proc._pdata._cld._status);
10620 +       }
10621 +       return 0;
10622 +}
10623 +
10624 +int
10625 +svr4_seteuid(int uid)
10626 +{
10627 +       return sys_setreuid16(-1, uid);
10628 +}
10629 +
10630 +int
10631 +svr4_setegid(int gid)
10632 +{
10633 +       return sys_setregid16(-1, gid);
10634 +}
10635 +
10636 +/* POSIX.1 names */
10637 +#define _PC_LINK_MAX    1
10638 +#define _PC_MAX_CANON   2
10639 +#define _PC_MAX_INPUT   3
10640 +#define _PC_NAME_MAX    4
10641 +#define _PC_PATH_MAX    5
10642 +#define _PC_PIPE_BUF    6
10643 +#define _PC_NO_TRUNC    7
10644 +#define _PC_VDISABLE    8
10645 +#define _PC_CHOWN_RESTRICTED    9
10646 +/* POSIX.4 names */
10647 +#define _PC_ASYNC_IO    10
10648 +#define _PC_PRIO_IO     11
10649 +#define _PC_SYNC_IO     12
10650 +
10651 +int
10652 +svr4_pathconf(char *path, int name)
10653 +{
10654 +       switch (name) {
10655 +               case _PC_LINK_MAX:
10656 +                       /* Although Linux headers define values on a per
10657 +                        * filesystem basis there is no way to access
10658 +                        * these without hard coding fs information here
10659 +                        * so for now we use a bogus value.
10660 +                        */
10661 +                       return LINK_MAX;
10662 +
10663 +               case _PC_MAX_CANON:
10664 +                       return MAX_CANON;
10665 +
10666 +               case _PC_MAX_INPUT:
10667 +                       return MAX_INPUT;
10668 +
10669 +               case _PC_PATH_MAX:
10670 +                       return PATH_MAX;
10671 +
10672 +               case _PC_PIPE_BUF:
10673 +                       return PIPE_BUF;
10674 +
10675 +               case _PC_CHOWN_RESTRICTED:
10676 +                       /* We should really think about this and tell
10677 +                        * the truth.
10678 +                        */
10679 +                       return 0;
10680 +
10681 +               case _PC_NO_TRUNC:
10682 +                       /* Not sure... It could be fs dependent? */
10683 +                       return 1;
10684 +
10685 +               case _PC_VDISABLE:
10686 +                       return 1;
10687 +
10688 +               case _PC_NAME_MAX: {
10689 +                       struct statfs buf;
10690 +                       char *p;
10691 +                       int error;
10692 +                       mm_segment_t old_fs;
10693 +
10694 +                       p = getname(path);
10695 +                       error = PTR_ERR(p);
10696 +                       if (!IS_ERR(p)) {
10697 +                               old_fs = get_fs();
10698 +                               set_fs (get_ds());
10699 +                               error = sys_statfs(p, &buf);
10700 +                               set_fs(old_fs);
10701 +                               putname(p);
10702 +                               if (!error)
10703 +                                       return buf.f_namelen;
10704 +                       }
10705 +                       return error;
10706 +               }
10707 +       }
10708 +
10709 +       return -EINVAL;
10710 +}
10711 +
10712 +int
10713 +svr4_fpathconf(int fildes, int name)
10714 +{
10715 +       switch (name) {
10716 +               case _PC_LINK_MAX:
10717 +                       /* Although Linux headers define values on a per
10718 +                        * filesystem basis there is no way to access
10719 +                        * these without hard coding fs information here
10720 +                        * so for now we use a bogus value.
10721 +                        */
10722 +                       return LINK_MAX;
10723 +
10724 +               case _PC_MAX_CANON:
10725 +                       return MAX_CANON;
10726 +
10727 +               case _PC_MAX_INPUT:
10728 +                       return MAX_INPUT;
10729 +
10730 +               case _PC_PATH_MAX:
10731 +                       return PATH_MAX;
10732 +
10733 +               case _PC_PIPE_BUF:
10734 +                       return PIPE_BUF;
10735 +
10736 +               case _PC_CHOWN_RESTRICTED:
10737 +                       /* We should really think about this and tell
10738 +                        * the truth.
10739 +                        */
10740 +                       return 0;
10741 +
10742 +               case _PC_NO_TRUNC:
10743 +                       /* Not sure... It could be fs dependent? */
10744 +                       return 1;
10745 +
10746 +               case _PC_VDISABLE:
10747 +                       return 1;
10748 +
10749 +               case _PC_NAME_MAX: {
10750 +                       struct statfs buf;
10751 +                       int error;
10752 +                       mm_segment_t old_fs;
10753 +
10754 +                       old_fs = get_fs();
10755 +                       set_fs (get_ds());
10756 +                       error = sys_fstatfs(fildes, &buf);
10757 +                       set_fs(old_fs);
10758 +                       if (!error)
10759 +                               return buf.f_namelen;
10760 +                       return error;
10761 +               }
10762 +       }
10763 +
10764 +       return -EINVAL;
10765 +}
10766 +
10767 +int
10768 +svr4_sigpending(int which_routine, svr4_sigset_t *set)
10769 +{
10770 +       /* Solaris multiplexes on this one */
10771 +       /* Which routine has the actual routine that should be called */
10772 +
10773 +       switch (which_routine){
10774 +       case 1:                 /* sigpending */
10775 +               printk ("iBCS/Intel: sigpending not implemented\n");
10776 +               return -EINVAL;
10777 +
10778 +       case 2:                 /* sigfillset */
10779 +               set->setbits [0] = ~0;
10780 +               set->setbits [1] = 0;
10781 +               set->setbits [2] = 0;
10782 +               set->setbits [3] = 0;
10783 +               return 0;
10784 +       }
10785 +       return -EINVAL;
10786 +}
10787 +
10788 +typedef void svr4_ucontext_t;
10789 +
10790 +static int
10791 +svr4_setcontext(svr4_ucontext_t *c, struct pt_regs *regs)
10792 +{
10793 +       printk (KERN_DEBUG "Getting context\n");
10794 +       return 0;
10795 +}
10796 +
10797 +static int
10798 +svr4_getcontext(svr4_ucontext_t *c, struct pt_regs *regs)
10799 +{
10800 +       printk (KERN_DEBUG "Setting context\n");
10801 +       return 0;
10802 +}
10803 +
10804 +int
10805 +svr4_context(struct pt_regs *regs)
10806 +{
10807 +       int context_fn = get_syscall_parameter (regs, 0);
10808 +       struct svr4_ucontext_t *uc = (void *) get_syscall_parameter (regs, 1);
10809 +
10810 +       switch (context_fn){
10811 +               case 0: /* getcontext */
10812 +                       return svr4_getcontext (uc, regs);
10813 +
10814 +               case 1: /* setcontext */
10815 +                       return svr4_setcontext (uc, regs);
10816 +       }
10817 +       return -EINVAL;
10818 +}
10819 +
10820 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
10821 +EXPORT_SYMBOL(svr4_context);
10822 +EXPORT_SYMBOL(svr4_fpathconf);
10823 +EXPORT_SYMBOL(svr4_pathconf);
10824 +EXPORT_SYMBOL(svr4_setegid);
10825 +EXPORT_SYMBOL(svr4_seteuid);
10826 +EXPORT_SYMBOL(svr4_sigpending);
10827 +EXPORT_SYMBOL(svr4_waitid);
10828 +#endif
10829 diff -Nur kernel-source-2.6.16.orig/abi/svr4/sysconf.c kernel-source-2.6.16/abi/svr4/sysconf.c
10830 --- kernel-source-2.6.16.orig/abi/svr4/sysconf.c        1970-01-01 10:00:00.000000000 +1000
10831 +++ kernel-source-2.6.16/abi/svr4/sysconf.c     2006-04-27 18:50:24.000000000 +1000
10832 @@ -0,0 +1,186 @@
10833 +/*
10834 + * sysconf.c - sysv sysconf(2) and sysconfig(2) emulation
10835 + *
10836 + * Copyright (C) 1994  Mike Jagdis (jaggy@purplet.demon.co.uk)
10837 + */
10838 +
10839 +#ident "%W% %G%"
10840 +
10841 +#include <linux/module.h>
10842 +#include <linux/errno.h>
10843 +#include <linux/sched.h>
10844 +#include <linux/kernel.h>
10845 +#include <linux/mm.h>
10846 +#include <linux/stddef.h>
10847 +#include <linux/limits.h>
10848 +#include <linux/unistd.h>
10849 +#include <linux/ptrace.h>
10850 +#include <linux/fcntl.h>
10851 +#include <linux/smp.h>
10852 +#include <linux/swap.h>
10853 +#include <linux/fs.h>
10854 +#include <linux/sys.h>
10855 +#include <asm/uaccess.h>
10856 +#include <asm/system.h>
10857 +
10858 +#include <abi/svr4/sysconf.h>
10859 +#include <abi/util/trace.h>
10860 +
10861 +
10862 +/* The sysconf() call is supposed to give applications access to various
10863 + * kernel parameters. According to SCO's man page this a POSIX mandated
10864 + * function. Perhaps it should be moved across as a native Linux call?
10865 + *
10866 + * N.B. SCO only has sysconf in the Xenix group. Therefore this is based
10867 + * on the Xenix spec. Is SVR4 the same? Wyse Unix V.3.2.1A doesn't have
10868 + * sysconf documented at all.
10869 + *
10870 + * N.B. 0-7 are required (by who?). Other values may be defined for
10871 + * various systems but there appears no guarantee that they match across
10872 + * platforms. Thus, unless we can identify what system the executable
10873 + * was compiled for, we probably prefer to have extensions fail. Hell,
10874 + * nothing important is going to use this obscure stuff anyway...
10875 + */
10876 +#define _SC_ARG_MAX    0
10877 +#define _SC_CHILD_MAX  1
10878 +#define _SC_CLK_TCK    2
10879 +#define _SC_NGROUPS_MAX        3
10880 +#define _SC_OPEN_MAX   4
10881 +#define _SC_JOB_CONTROL        5
10882 +#define _SC_SAVED_IDS  6
10883 +#define _SC_VERSION    7
10884 +
10885 +#define _SC_PAGESIZE           11
10886 +#define _SCO_SC_PAGESIZE       34
10887 +
10888 +
10889 +/* This is an SVR4 system call that is undocumented except for some
10890 + * hints in a header file. It appears to be a forerunner to the
10891 + * POSIX sysconf() call.
10892 + */
10893 +int svr4_sysconfig(int name)
10894 +{
10895 +       switch (name) {
10896 +               case _CONFIG_NGROUPS:
10897 +                       /* From limits.h */
10898 +                       return (NGROUPS_MAX);
10899 +
10900 +               case _CONFIG_CHILD_MAX:
10901 +                       /* From limits.h */
10902 +                       return (CHILD_MAX);
10903 +
10904 +               case _CONFIG_OPEN_FILES:
10905 +                       /* From limits.h */
10906 +                       return (OPEN_MAX);
10907 +
10908 +               case _CONFIG_POSIX_VER:
10909 +                       /* The version of the POSIX standard we conform
10910 +                        * to. SCO defines _POSIX_VERSION as 198808L
10911 +                        * sys/unistd.h. What are we? We are 199009L.
10912 +                        */
10913 +                       return (199009L);
10914 +
10915 +               case _CONFIG_PAGESIZE:
10916 +                       return (PAGE_SIZE);
10917 +
10918 +               case _CONFIG_CLK_TCK:
10919 +                       return (HZ);
10920 +
10921 +               case _CONFIG_XOPEN_VER:
10922 +                       return 4;
10923 +
10924 +               case _CONFIG_NACLS_MAX:
10925 +                       return 0;
10926 +
10927 +               case _CONFIG_NPROC:
10928 +                       return 4000; /* max_threads */
10929 +
10930 +               case _CONFIG_NENGINE:
10931 +               case _CONFIG_NENGINE_ONLN:
10932 +                       return (num_online_cpus());
10933 +
10934 +               case _CONFIG_TOTAL_MEMORY:
10935 +                       return (max_mapnr << (PAGE_SHIFT-10));
10936 +
10937 +               case _CONFIG_USEABLE_MEMORY:
10938 +               case _CONFIG_GENERAL_MEMORY:
10939 +                       return (max_mapnr << (PAGE_SHIFT-10));
10940 +/*                     return ((unsigned long) (nr_free_pages()) << (PAGE_SHIFT-10)); */
10941 +
10942 +               case _CONFIG_DEDICATED_MEMORY:
10943 +                       return 0;
10944 +
10945 +               case _CONFIG_NCGS_CONF:
10946 +               case _CONFIG_NCGS_ONLN:
10947 +               case _CONFIG_MAX_ENG_PER_CG:
10948 +                       return 1; /* no NUMA-Q support on Linux yet */
10949 +                                 /* well, there is.  we lie anyway   --hch */
10950 +
10951 +               case _CONFIG_CACHE_LINE:
10952 +                       return 32; /* XXX is there a more accurate way? */
10953 +
10954 +               case _CONFIG_KERNEL_VM:
10955 +                       return -EINVAL;
10956 +
10957 +               case _CONFIG_ARG_MAX:
10958 +                       /* From limits.h */
10959 +                       return (ARG_MAX);
10960 +       }
10961 +
10962 +#if defined(CONFIG_ABI_TRACE)
10963 +       abi_trace(ABI_TRACE_API, "unsupported sysconfig call %d\n", name);
10964 +#endif
10965 +       return -EINVAL;
10966 +}
10967 +
10968 +
10969 +int ibcs_sysconf(int name)
10970 +{
10971 +       switch (name) {
10972 +               case _SC_ARG_MAX:
10973 +                       /* From limits.h */
10974 +                       return (ARG_MAX);
10975 +
10976 +               case _SC_CHILD_MAX:
10977 +                       /* From limits.h */
10978 +                       return (CHILD_MAX);
10979 +
10980 +               case _SC_CLK_TCK:
10981 +                       return (HZ);
10982 +
10983 +               case _SC_NGROUPS_MAX:
10984 +                       /* From limits.h */
10985 +                       return (NGROUPS_MAX);
10986 +
10987 +               case _SC_OPEN_MAX:
10988 +                       /* From limits.h */
10989 +                       return (OPEN_MAX);
10990 +
10991 +               case _SC_JOB_CONTROL:
10992 +                       return (1);
10993 +
10994 +               case _SC_SAVED_IDS:
10995 +                       return (1);
10996 +
10997 +               case _SC_PAGESIZE:
10998 +               case _SCO_SC_PAGESIZE:
10999 +                       return PAGE_SIZE;
11000 +
11001 +               case _SC_VERSION:
11002 +                       /* The version of the POSIX standard we conform
11003 +                        * to. SCO defines _POSIX_VERSION as 198808L
11004 +                        * sys/unistd.h. What are we?
11005 +                        */
11006 +                       return (198808L);
11007 +       }
11008 +
11009 +#if defined(CONFIG_ABI_TRACE)
11010 +       abi_trace(ABI_TRACE_API, "unsupported sysconf call %d\n", name);
11011 +#endif
11012 +       return -EINVAL;
11013 +}
11014 +
11015 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
11016 +EXPORT_SYMBOL(ibcs_sysconf);
11017 +EXPORT_SYMBOL(svr4_sysconfig);
11018 +#endif
11019 diff -Nur kernel-source-2.6.16.orig/abi/svr4/sysfs.c kernel-source-2.6.16/abi/svr4/sysfs.c
11020 --- kernel-source-2.6.16.orig/abi/svr4/sysfs.c  1970-01-01 10:00:00.000000000 +1000
11021 +++ kernel-source-2.6.16/abi/svr4/sysfs.c       2006-04-27 18:50:24.000000000 +1000
11022 @@ -0,0 +1,130 @@
11023 +/*
11024 + * Copyright (C) 1994  Mike Jagdis (jaggy@purplet.demon.co.uk)
11025 + */
11026 +
11027 +#ident "%W% %G%"
11028 +
11029 +#include <linux/module.h>
11030 +#include <linux/personality.h>
11031 +#include <linux/sched.h>
11032 +#include <linux/syscalls.h>
11033 +#include <asm/uaccess.h>
11034 +
11035 +#include <abi/util/trace.h>
11036 +
11037 +/*
11038 + * The kernel sysfs() code is almost all we need but, apparently,
11039 + * the SCO (at least) sysfs() will also accept a "magic number"
11040 + * as an index argument and will return the name of the relevant
11041 + * file system. Since Linux doesn't have any concept of fs magic
11042 + * numbers outside the file system code themselves there is no
11043 + * clean way to do it in the kernel. There isn't a clean way to
11044 + * to it here either but it needs to be done somehow :-(.
11045 + */
11046 +enum {
11047 +       GETFSIND = 1,
11048 +       GETFSTYP = 2,
11049 +       GETNFSTYP = 3
11050 +};
11051 +
11052 +int
11053 +svr4_sysfs(int cmd, int arg1, int arg2)
11054 +{
11055 +       if (cmd == GETFSIND)
11056 +               return sys_sysfs(cmd, arg1, arg2);
11057 +
11058 +       if (cmd == GETNFSTYP)
11059 +               return sys_sysfs(cmd, arg1, arg2);
11060 +
11061 +       if (cmd == GETFSTYP) {
11062 +               char *buf = (char *)arg2;
11063 +               int error;
11064 +
11065 +               if (arg1 & 0x80000000)
11066 +                       arg1 &= 0x0000ffff;
11067 +               if (arg1 >= 0 && arg1 < sys_sysfs(GETNFSTYP,0,0))
11068 +                       return sys_sysfs(cmd, arg1-1, arg2);
11069 +
11070 +               /*
11071 +                * Kludge alert! Hardcoded known magic numbers!
11072 +                */
11073 +               switch (arg1) {
11074 +               case 0xef53: case 0xffffef53:
11075 +               case 0xef51: case 0xffffef51:
11076 +                       /*
11077 +                        * Some SCO programs (i.e. Informix Dynamic
11078 +                        * Server are using this to detect "real"
11079 +                        * filesystems by checking type names :-(.
11080 +                        * So we lie :-).
11081 +                        */
11082 +                       if (is_cur_personality(PER_SCOSVR3))
11083 +                               error = copy_to_user(buf, "HTFS", 5);
11084 +                       else
11085 +                               error = copy_to_user(buf, "ext2", 5);
11086 +                       break;
11087 +               case 0x137d:
11088 +                       error = copy_to_user(buf, "ext", 4);
11089 +                       break;
11090 +               case 0x9660: case 0xffff9660:
11091 +                       error = copy_to_user(buf, "iso9660", 8);
11092 +                       break;
11093 +               case 0x4d44:
11094 +                       error = copy_to_user(buf, "msdos", 6);
11095 +                       break;
11096 +               case 0x6969:
11097 +                       error = copy_to_user(buf, "nfs", 4);
11098 +                       break;
11099 +               case 0x9fa0: case 0xffff9fa0:
11100 +                       error = copy_to_user(buf, "proc", 5);
11101 +                       break;
11102 +               case 0xf995e849:
11103 +               case 0xe849: case 0xffffe849:
11104 +                       error = copy_to_user(buf, "hpfs", 5);
11105 +                       break;
11106 +               case 0x137f: /* original */
11107 +               case 0x138f: /* original + 30 char names */
11108 +               case 0x2468: /* V2 */
11109 +               case 0x2478: /* V2 + 30 char names */
11110 +                       error = copy_to_user(buf, "minix", 6);
11111 +                       break;
11112 +               case 0x564c:
11113 +                       error = copy_to_user(buf, "ncpfs", 6);
11114 +                       break;
11115 +               case 0x517b:
11116 +                       error = copy_to_user(buf, "smbfs", 6);
11117 +                       break;
11118 +               case 0x00011954:
11119 +                       error = copy_to_user(buf, "ufs", 4);
11120 +                       break;
11121 +               case 0x012fd16d: case 0xffffd16d:
11122 +                       error = copy_to_user(buf, "xiafs", 6);
11123 +                       break;
11124 +               case 0x012ff7b3+1: case 0xfffff7b3+1:
11125 +                       error = copy_to_user(buf, "xenix", 6);
11126 +                       break;
11127 +               case 0x012ff7b3+2: case 0xfffff7b3+2:
11128 +               case 0x012ff7b3+3: case 0xfffff7b3+3:
11129 +                       error = copy_to_user(buf, "sysv", 5);
11130 +                       break;
11131 +               case 0x012ff7b3+4: case 0xfffff7b3+4:
11132 +                       error = copy_to_user(buf, "coherent", 9);
11133 +                       break;
11134 +               default:
11135 +                       error = copy_to_user(buf, "", 1);
11136 +                       break;
11137 +               }
11138 +
11139 +               if (error)
11140 +                       return -EFAULT;
11141 +               return 0;
11142 +       }
11143 +
11144 +#if defined(CONFIG_ABI_TRACE)
11145 +       abi_trace(ABI_TRACE_API, "unsupported sysfs call %d\n", cmd);
11146 +#endif
11147 +       return -EINVAL;
11148 +}
11149 +
11150 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
11151 +EXPORT_SYMBOL(svr4_sysfs);
11152 +#endif
11153 diff -Nur kernel-source-2.6.16.orig/abi/svr4/sysi86.c kernel-source-2.6.16/abi/svr4/sysi86.c
11154 --- kernel-source-2.6.16.orig/abi/svr4/sysi86.c 1970-01-01 10:00:00.000000000 +1000
11155 +++ kernel-source-2.6.16/abi/svr4/sysi86.c      2006-04-27 18:50:24.000000000 +1000
11156 @@ -0,0 +1,180 @@
11157 +/*
11158 + * Copyright 1994,1995 Mike Jagdis <jaggy@purplet.demon.co.uk>
11159 + * Copyright 2002 Caldera Deutschland GmbH
11160 + */
11161 +
11162 +#ident "%W% %G%"
11163 +
11164 +#include <linux/sched.h>
11165 +#include <linux/kernel.h>
11166 +#include <linux/ptrace.h>
11167 +#include <linux/syscalls.h>
11168 +#include <linux/mm.h>
11169 +#include <linux/module.h>
11170 +#include <asm/uaccess.h>
11171 +
11172 +#include <abi/util/trace.h>
11173 +
11174 +
11175 +/*
11176 + * The sysi86() call is used for machine specific functions. Only the
11177 + * most basic are implemented here.
11178 + */
11179 +#define SI86SWPI        1       /* General swap functions. */
11180 +#define SI86SYM         2       /* Get symbol table */
11181 +#define SI86CONF        4       /* Get configuration table */
11182 +#define SI86BOOT        5       /* Get timestamp and name of program
11183 +                                * booted.
11184 +                                */
11185 +#define SI86DMM         7       /* Double-map data segment for
11186 +                                * read/write/execute support
11187 +                                */
11188 +#define SI86AUTO        9       /* Was an auto-config boot done? */
11189 +#define SI86EDT         10      /* Copy contents of EDT to user */
11190 +#define SI86SWAP        12      /* Declare swap space */
11191 +#define SI86FPHW        40      /* what (if any?) floating-point hardware */
11192 +#  define FP_NO                0       /* No fp at all */
11193 +#  define FP_SW                1       /* using emulator */
11194 +#  define FP_HW                2       /* using hardware */
11195 +#  define FP_287       2       /* using a 287 */
11196 +#  define FP_387       3       /* using a 387 */
11197 +#define GRNON          52      /* set green light to solid on state */
11198 +#define GRNFLASH       53      /* start green light flashing */
11199 +#define STIME          54      /* set internal time */
11200 +#define SETNAME                56      /* rename the system */
11201 +#define RNVR           58      /* read NVRAM */
11202 +#define WNVR           59      /* write NVRAM */
11203 +#define RTODC          60      /* read time of day clock */
11204 +#define CHKSER         61      /* check soft serial number */
11205 +#define SI86NVPRT       62      /* print an xtra_nvr structure */
11206 +#define SANUPD         63      /* sanity update of kernel buffers */
11207 +#define SI86KSTR        64      /* make a copy of a kernel string */
11208 +#define SI86MEM         65      /* return the memory size of system */
11209 +#define SI86TODEMON     66      /* Transfer control to firmware.        */
11210 +#define SI86CCDEMON     67      /* Control character access to demon.   */
11211 +#define SI86CACHE       68      /* Turn cache on and off.               */
11212 +#define SI86DELMEM      69      /* Delete available memory for testing. */
11213 +#define SI86ADDMEM      70      /* Add back deleted memory.             */
11214 +/* 71 through 74 reserved for VPIX */
11215 +#define SI86V86         71      /* V86 system calls (see v86.h)         */
11216 +#define        SI86SLTIME      72      /* Set local time correction            */
11217 +#define SI86DSCR        75      /* Set a segment or gate descriptor     */
11218 +#define RDUBLK         76      /* Read U Block */
11219 +/* #ifdef MERGE386 */
11220 +/* NFA entry point */
11221 +#define SI86NFA         77      /* make nfa_sys system call */
11222 +#define SI86VM86       81
11223 +#define SI86VMENABLE   82
11224 +/* #endif MERGE386 */
11225 +#define SI86VM86        81
11226 +#define SI86VMENABLE    82
11227 +#define SI86LIMUSER     91      /* liscense interface */
11228 +#define SI86RDID        92      /* ROM BIOS Machid ID */
11229 +#define SI86RDBOOT      93      /* Bootable Non-SCSI Hard Disk */
11230 +/* Merged Product defines */
11231 +#define SI86SHFIL      100     /* map a file into addr space of a proc */
11232 +#define SI86PCHRGN     101     /* make globally visible change to a region */
11233 +#define SI86BADVISE    102     /* badvise subcommand - see below for   */
11234 +                               /*      badvise subfunction definitions */
11235 +#define SI86SHRGN      103     /* enable/disable XENIX small model shared */
11236 +                               /*      data context switching             */
11237 +#define        SI86CHIDT       104     /* set user level int 0xf0, ... 0xff handlers */
11238 +#define        SI86EMULRDA     105     /* remove special emulator read access  */
11239 +#define SI86GETPIPE    106     /* return the pipe filesystem */
11240 +#define SI86SETPIPE    107     /* set the pipe filesystem */
11241 +#define SI86SETPIPE_NM 108     /* set the pipe filesystem -non mountable */
11242 +#define SI86GETNPIPE   109     /* get # of pipe filesystems */
11243 +#define SI86GETPIPE_ALL        110     /* get data on all of pipe filesystems */
11244 +#define SI86POPPIPE    111     /* pop pipe file system off stack */
11245 +#define SI86APM                112     /* get APM information passed by boot(HW) */
11246 +#define SI86TIMECHG    113     /* get time before/after last timechange */
11247 +#define SI86GETFEATURES        114     /* get os features vector */
11248 +
11249 +/* The SI86BADVISE command is used to set Xenix behaviour. */
11250 +#define SI86B_SET              0x0100  /* Set badvise bits */
11251 +#define SI86B_GET              0x0200  /* Get badvise bits */
11252 +#define        SI86B_LOCK              0x0001  /* XENIX advisory locking bit */
11253 +#define SI86B_PRE_SV           0x0008  /* follow pre-System V x.out behavior */
11254 +#define SI86B_XOUT             0x0010  /* follow XENIX x.out behavior */
11255 +#define SI86B_XSDSWTCH         0x0080  /* XENIX small model shared data */
11256 +                                       /* context switching enabled */
11257 +
11258 +/*
11259 + *  The SI86DSCR subcommand of the sysi86() system call
11260 + *  sets a segment or gate descriptor in the kernel.
11261 + *  The following descriptor types are accepted:
11262 + *    - executable and data segments in the LDT at DPL 3
11263 + *    - a call gate in the GDT at DPL 3 that points to a segment in the LDT
11264 + *  The request structure declared below is used to pass the values
11265 + *  to be placed in the descriptor.  A pointer to the structure is
11266 + *  passed as the second argument of the system call.
11267 + *  If acc1 is zero, the descriptor is cleared.
11268 + */
11269 +struct ssd {
11270 +       uint32_t  sel;  /* descriptor selector */
11271 +       uint32_t  bo;   /* segment base or gate offset */
11272 +       uint32_t  ls;   /* segment limit or gate selector */
11273 +       uint32_t  acc1; /* access byte 5 */
11274 +       uint32_t  acc2; /* access bits in byte 6 or gate count */
11275 +};
11276 +
11277 +
11278 +int
11279 +svr4_sysi86(int cmd, void *arg1, int arg2)
11280 +{
11281 +       switch (cmd) {
11282 +       case SI86FPHW:
11283 +               /*
11284 +                * If we remove the 'static' from the definition
11285 +                * of fpu_error in linux/init/main.c we can tell
11286 +                * whether we are using hardware or software at
11287 +                * least. For now let's lie...
11288 +                * (actually SCO Unix 3.4 gives me -1...)
11289 +                */
11290 +               return put_user(FP_387, (unsigned long *)arg1);
11291 +       case STIME:
11292 +               /*
11293 +                * Set the system time. The argument is a long,
11294 +                * sys_stime() expects a pointer to a long...
11295 +                */
11296 +               return sys_stime(arg1);
11297 +       case SETNAME:
11298 +               /*
11299 +                * The name is required to be string of no more
11300 +                * than 7 characters. We don't get passed the
11301 +                * length so we are depending upon the current
11302 +                * implementation of sys_sethostname() here.
11303 +                */
11304 +               return sys_sethostname(arg1, 7);
11305 +       case SI86MEM:
11306 +           {
11307 +               /*
11308 +                * Returns the size of physical memory.
11309 +                */
11310 +               struct sysinfo  i;
11311 +
11312 +               si_meminfo(&i);
11313 +               return (i.totalram << PAGE_SHIFT);
11314 +           }
11315 +       case SI86DSCR:
11316 +           {
11317 +               struct ssd s;
11318 +
11319 +               if (copy_from_user(&s, arg1, sizeof(struct ssd)))
11320 +                       return -EFAULT;
11321 +
11322 +               printk("SI86DSCR(%x,%x,%x,%x,%x)\n",
11323 +                        s.sel, s.bo, s.ls, s.acc1, s.acc2);
11324 +               return -EINVAL;
11325 +           }
11326 +       default:
11327 +#if defined(CONFIG_ABI_TRACE)
11328 +               abi_trace(ABI_TRACE_API, "unsupported sysi86 subcall %d\n", cmd);
11329 +#endif
11330 +               return -EINVAL;
11331 +       }
11332 +}
11333 +
11334 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
11335 +EXPORT_SYMBOL(svr4_sysi86);
11336 +#endif
11337 diff -Nur kernel-source-2.6.16.orig/abi/svr4/sysinfo.c kernel-source-2.6.16/abi/svr4/sysinfo.c
11338 --- kernel-source-2.6.16.orig/abi/svr4/sysinfo.c        1970-01-01 10:00:00.000000000 +1000
11339 +++ kernel-source-2.6.16/abi/svr4/sysinfo.c     2006-04-27 18:50:24.000000000 +1000
11340 @@ -0,0 +1,128 @@
11341 +/*
11342 + * Copyright (C) 1995  Eric Youngdale
11343 + */
11344 +
11345 +#ident "%W% %G%"
11346 +
11347 +#include <linux/module.h>
11348 +#include <linux/version.h>
11349 +#include <linux/compile.h>
11350 +#include <linux/mm.h>
11351 +#include <linux/errno.h>
11352 +#include <linux/sched.h>
11353 +#include <linux/utsname.h>
11354 +#include <asm/uaccess.h>
11355 +
11356 +#include <abi/util/trace.h>
11357 +
11358 +
11359 +#define __O_SI_SYSNAME          1       /* return name of operating system */
11360 +#define __O_SI_HOSTNAME         2       /* return name of node */
11361 +#define SI_RELEASE              3       /* return release of operating system */
11362 +#define SI_VERSION              4       /* return version field of utsname */
11363 +#define __O_SI_MACHINE          5       /* return kind of machine */
11364 +#define __O_SI_ARCHITECTURE     6       /* return instruction set arch */
11365 +#define SI_HW_SERIAL            7       /* return hardware serial number */
11366 +#define __O_SI_HW_PROVIDER      8       /* return hardware manufacturer */
11367 +#define SI_SRPC_DOMAIN          9       /* return secure RPC domain */
11368 +#define SI_INITTAB_NAME         10      /* return name of inittab file used */
11369 +#define SI_ARCHITECTURE         100     /* return instruction set arch */
11370 +#define SI_BUSTYPES             101     /* return list of bus types */
11371 +#define SI_HOSTNAME             102     /* return fully-qualified node name */
11372 +#define SI_HW_PROVIDER          103     /* return hardware manufacturer */
11373 +#define SI_KERNEL_STAMP         104     /* return kernel generation timestamp */
11374 +#define SI_MACHINE              105     /* return kind of machine */
11375 +#define SI_OS_BASE              106     /* return base operating system */
11376 +#define SI_OS_PROVIDER          107     /* return operating system provider */
11377 +#define SI_SYSNAME              108     /* return name of operating system */
11378 +#define SI_USER_LIMIT           109     /* return maximum number of users */
11379 +
11380 +
11381 +
11382 +int svr4_sysinfo(int cmd, char * buf, long count)
11383 +{
11384 +       char * return_string;
11385 +       static unsigned int serial_number = 0;
11386 +       char buffer[16];
11387 +       int error;
11388 +       int slen;
11389 +
11390 +       return_string = NULL;
11391 +
11392 +       switch(cmd) {
11393 +               case __O_SI_SYSNAME:
11394 +               case SI_SYSNAME:
11395 +                       return_string = system_utsname.sysname;
11396 +                       break;
11397 +               case __O_SI_HOSTNAME:
11398 +               case SI_HOSTNAME:
11399 +                       return_string = system_utsname.nodename;
11400 +                       break;
11401 +               case SI_VERSION:
11402 +                       return_string = "2";
11403 +                       break;
11404 +               case SI_RELEASE:
11405 +                       return_string = system_utsname.release;
11406 +                       break;
11407 +               case SI_MACHINE:
11408 +               case __O_SI_MACHINE:
11409 +                       return_string = system_utsname.machine;
11410 +                       break;
11411 +               case __O_SI_ARCHITECTURE:
11412 +               case SI_ARCHITECTURE:
11413 +                       return_string = "IA32"; /* XXX: this seems wrong, the name ia32 is very new ... -- ch */
11414 +                       break;
11415 +               case SI_BUSTYPES:
11416 +                       return_string = "PCI ISA";
11417 +                       break;
11418 +               case __O_SI_HW_PROVIDER:
11419 +               case SI_HW_PROVIDER:
11420 +                       return_string = "Generic AT";
11421 +                       break;
11422 +               case SI_KERNEL_STAMP:
11423 +                       return_string = UTS_VERSION;
11424 +                       break;
11425 +               case SI_INITTAB_NAME:
11426 +                       return_string = "/etc/inittab";
11427 +                       break;
11428 +               case SI_HW_SERIAL:
11429 +                       if(serial_number == 0)
11430 +                               serial_number = 0xdeadbeef;
11431 +                       sprintf(buffer,"%8.8x", serial_number);
11432 +                       return_string = buffer;
11433 +                       break;
11434 +               case SI_OS_BASE:
11435 +                       return_string = "Linux";
11436 +                       break;
11437 +               case SI_OS_PROVIDER:
11438 +                       return_string = "LBT"; /* someone's initials ? */
11439 +                       break;
11440 +               case SI_SRPC_DOMAIN:
11441 +                       return_string = system_utsname.domainname;
11442 +                       break;
11443 +               case SI_USER_LIMIT:
11444 +                       /* have you seen a Linux box with more than 500000 users? */
11445 +                       return_string = "500000";
11446 +                       break;
11447 +               default:
11448 +#if defined(CONFIG_ABI_TRACE)
11449 +                       abi_trace(ABI_TRACE_API,
11450 +                                       "unsupported sysinfo call %d\n", cmd);
11451 +#endif
11452 +               return -EINVAL;
11453 +       }
11454 +
11455 +       if (!return_string)
11456 +               return 0;
11457 +
11458 +       down_read(&uts_sem);
11459 +       slen = (count < strlen(return_string) + 1 ? count : strlen(return_string) + 1);
11460 +       error = copy_to_user(buf, return_string, slen);
11461 +       up_read(&uts_sem);
11462 +
11463 +       return error ? -EFAULT : slen;
11464 +}
11465 +
11466 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
11467 +EXPORT_SYMBOL(svr4_sysinfo);
11468 +#endif
11469 diff -Nur kernel-source-2.6.16.orig/abi/svr4/tapeio.c kernel-source-2.6.16/abi/svr4/tapeio.c
11470 --- kernel-source-2.6.16.orig/abi/svr4/tapeio.c 1970-01-01 10:00:00.000000000 +1000
11471 +++ kernel-source-2.6.16/abi/svr4/tapeio.c      2006-04-27 18:50:24.000000000 +1000
11472 @@ -0,0 +1,92 @@
11473 +#ident "%W% %G%"
11474 +
11475 +#include <linux/errno.h>
11476 +#include <linux/kernel.h>
11477 +#include <linux/mtio.h>
11478 +#include <linux/syscalls.h>
11479 +#include <asm/uaccess.h>
11480 +
11481 +
11482 +int
11483 +svr4_tape_ioctl(int fd, u_int cmd, caddr_t data)
11484 +{
11485 +       mm_segment_t            fs;
11486 +       int                     error;
11487 +       struct mtop             mtop;
11488 +
11489 +       mtop.mt_count = 1;
11490 +
11491 +       switch (cmd & 0xff) {
11492 +       case 1:         /* MT_RETEN */
11493 +               mtop.mt_op = MTRETEN;
11494 +               break;
11495 +       case 2:         /* MT_REWIND */
11496 +               mtop.mt_op = MTREW;
11497 +               break;
11498 +       case 3:         /* MT_ERASE */
11499 +               mtop.mt_op = MTERASE;
11500 +               break;
11501 +       case 4:         /* MT_WFM */
11502 +               mtop.mt_op = MTWEOF;
11503 +               break;
11504 +       case 5:         /* MT_RESET */
11505 +               mtop.mt_op = MTRESET;
11506 +               break;
11507 +       case 7:         /* T_SFF */
11508 +               mtop.mt_op = MTFSF;
11509 +               break;
11510 +       case 8:         /* T_SBF */
11511 +               mtop.mt_op = MTBSF;
11512 +               break;
11513 +       case 9:         /* T_LOAD */
11514 +               mtop.mt_op = MTLOAD;
11515 +               break;
11516 +       case 10:  /* MT_UNLOAD */
11517 +               mtop.mt_op = MTOFFL;
11518 +               break;
11519 +       case 15:        /* T_WRBLKLEN */
11520 +               mtop.mt_op = MTLOCK;
11521 +               mtop.mt_count = (int)data;
11522 +               break;
11523 +       case 16:        /* T_PREVMV */
11524 +               mtop.mt_op = MTLOCK;
11525 +               break;
11526 +       case 17:        /* T_ALLOMV */
11527 +               mtop.mt_op = MTUNLOCK;
11528 +               break;
11529 +       case 20:        /* T_EOD */
11530 +               mtop.mt_op = MTEOM;
11531 +               mtop.mt_count = (int)data;
11532 +               break;
11533 +       case 21:        /* T_SSFB */
11534 +               mtop.mt_op = MTBSFM;
11535 +               mtop.mt_count = (int)data;
11536 +               break;
11537 +       case 22:        /* T_SSFF */
11538 +               mtop.mt_op = MTFSFM;
11539 +               mtop.mt_count = (int)data;
11540 +               break;
11541 +       case 24:        /* T_STD */
11542 +               mtop.mt_op = MTSETDENSITY;
11543 +               mtop.mt_count = (int)data;
11544 +               break;
11545 +
11546 +#if 0
11547 +       case 6:         /* T_STATUS */
11548 +       case 14:        /* T_RDBLKLEN */
11549 +       case 18:        /* T_SBB */
11550 +       case 19:        /* T_SFB */
11551 +       case 23:        /* T_STS */
11552 +#endif
11553 +       default:
11554 +               printk (KERN_ERR "iBCS: SYSV tape ioctl func=%d arg=%x unsupported\n",
11555 +                               cmd & 0xff, (int)data);
11556 +                       return -EINVAL;
11557 +       }
11558 +
11559 +       fs = get_fs();
11560 +       set_fs(get_ds());
11561 +       error = sys_ioctl(fd, MTIOCTOP, (long)&mtop);
11562 +       set_fs (fs);
11563 +       return (error);
11564 +}
11565 diff -Nur kernel-source-2.6.16.orig/abi/svr4/termios.c kernel-source-2.6.16/abi/svr4/termios.c
11566 --- kernel-source-2.6.16.orig/abi/svr4/termios.c        1970-01-01 10:00:00.000000000 +1000
11567 +++ kernel-source-2.6.16/abi/svr4/termios.c     2006-04-27 18:50:24.000000000 +1000
11568 @@ -0,0 +1,983 @@
11569 +#ident "%W% %G%"
11570 +
11571 +#include <linux/kernel.h>
11572 +#include <linux/unistd.h>
11573 +#include <linux/termios.h>
11574 +#include <linux/syscalls.h>
11575 +#include <asm/uaccess.h>
11576 +
11577 +#include <abi/svr4/ioctl.h>
11578 +#include <abi/svr4/termios.h>
11579 +
11580 +
11581 +static int
11582 +svr_to_linux_termio(int fd, int op, struct svr_termio *it)
11583 +{
11584 +       struct termio           t;
11585 +       mm_segment_t            fs;
11586 +       char                    eof;
11587 +       u_short                 lflag;
11588 +       int                     error;
11589 +
11590 +       if (!access_ok(VERIFY_READ, it, sizeof(struct svr_termio)))
11591 +               return -EFAULT;
11592 +
11593 +       fs = get_fs();
11594 +       set_fs(get_ds());
11595 +       error = sys_ioctl(fd, TCGETA, (long)&t);
11596 +       set_fs(fs);
11597 +
11598 +       if (error)
11599 +               return (error);
11600 +
11601 +       /* Save things we may need later. */
11602 +       eof = t.c_cc[4];
11603 +       lflag = t.c_lflag;
11604 +
11605 +       /* Copy the entire structure then fix up as necessary. */
11606 +       if (copy_from_user(&t, it, sizeof(struct svr_termio)))
11607 +               return -EFAULT;
11608 +
11609 +       /* If ICANON isn't set then we've been given VMIN in place
11610 +        * of VEOF.
11611 +        */
11612 +       if (!(t.c_lflag & 0000002)) {
11613 +               t.c_cc[6] = t.c_cc[4];
11614 +               t.c_cc[4] = eof;
11615 +       }
11616 +
11617 +       if (t.c_cflag & 0100000) /* CRTSFL - SCO only? */
11618 +               t.c_cflag |= CRTSCTS;
11619 +       t.c_cflag &= ~0170000; /* LOBLK|CTSFLOW|RTSFLOW|CRTSFL */
11620 +
11621 +       set_fs(get_ds());
11622 +       error = sys_ioctl(fd, op, (long)&t);
11623 +       set_fs(fs);
11624 +
11625 +       return (error);
11626 +}
11627 +
11628 +static int
11629 +linux_to_svr_termio(int fd, struct svr_termio *it)
11630 +{
11631 +       struct termio           t;
11632 +       mm_segment_t            fs;
11633 +       int                     error;
11634 +
11635 +       if (!access_ok(VERIFY_WRITE, it, sizeof(struct svr_termio)))
11636 +               return -EFAULT;
11637 +
11638 +       fs = get_fs();
11639 +       set_fs(get_ds());
11640 +       error = sys_ioctl(fd, TCGETA, (long)&t);
11641 +       set_fs(fs);
11642 +
11643 +       if (error)
11644 +               return (error);
11645 +
11646 +       /* If ICANON isn't set then we substitute VEOF with VMIN. */
11647 +       if (!(t.c_lflag & 0000002))
11648 +               t.c_cc[4] = t.c_cc[6];
11649 +
11650 +       /* Copy to the user supplied structure. */
11651 +       if (copy_to_user(it, &t, sizeof(struct svr_termio)))
11652 +               error = -EFAULT;
11653 +       return (error);
11654 +}
11655 +
11656 +static int
11657 +svr4_to_linux_termios(int fd, int op, struct svr4_termios *it)
11658 +{
11659 +       struct termios          t;
11660 +       mm_segment_t            fs;
11661 +       u_short                 lflag, r;
11662 +       char                    svr4_cc[SVR4_NCCS];
11663 +       int                     error;
11664 +
11665 +       if (!access_ok(VERIFY_READ, it, sizeof(struct svr4_termios)))
11666 +               return -EFAULT;
11667 +
11668 +       fs = get_fs();
11669 +       set_fs(get_ds());
11670 +       error = sys_ioctl(fd, TCGETS, (long)&t);
11671 +       set_fs(fs);
11672 +
11673 +       if (error)
11674 +               return (error);
11675 +
11676 +       __get_user(t.c_iflag, &it->c_iflag);
11677 +       t.c_iflag &= ~0100000; /* DOSMODE */
11678 +
11679 +       __get_user(t.c_oflag, &it->c_oflag);
11680 +       __get_user(t.c_cflag, &it->c_cflag);
11681 +
11682 +       if (t.c_cflag & 0100000) /* CRTSFL - SCO only? */
11683 +               t.c_cflag |= CRTSCTS;
11684 +
11685 +       t.c_cflag &= ~0170000; /* LOBLK|CTSFLOW|RTSFLOW|CRTSFL */
11686 +
11687 +       lflag = t.c_lflag;
11688 +       t.c_lflag &= ~0100777;
11689 +       __get_user(r, &it->c_lflag);
11690 +       t.c_lflag |= r;
11691 +
11692 +       if ((t.c_lflag & 0100000))
11693 +               sys_ioctl(fd, TIOCEXCL, 0);
11694 +       else
11695 +               sys_ioctl(fd, TIOCNXCL, 0);
11696 +
11697 +       t.c_lflag &= ~0100000;
11698 +       t.c_lflag |= (t.c_lflag & 0000400) << 7; /* Move IEXTEN */
11699 +       t.c_lflag &= ~0000400;
11700 +       t.c_lflag |= (t.c_lflag & 0001000) >> 1; /* Move TOSTOP */
11701 +       t.c_lflag &= ~0001000;
11702 +       t.c_lflag |= (lflag & 0001000); /* Restore ECHOCTL */
11703 +
11704 +       if (copy_from_user(svr4_cc, &it->c_cc, SVR4_NCCS))
11705 +               return -EFAULT;
11706 +
11707 +       t.c_cc[0] = svr4_cc[0];
11708 +       t.c_cc[1] = svr4_cc[1];
11709 +       t.c_cc[2] = svr4_cc[2];
11710 +       t.c_cc[3] = svr4_cc[3];
11711 +       t.c_cc[7] = svr4_cc[7];
11712 +       t.c_cc[8] = svr4_cc[8];
11713 +       t.c_cc[9] = svr4_cc[9];
11714 +       t.c_cc[10] = svr4_cc[10];
11715 +       t.c_cc[12] = svr4_cc[12];
11716 +       t.c_cc[13] = svr4_cc[13];
11717 +       t.c_cc[14] = svr4_cc[14];
11718 +       t.c_cc[15] = svr4_cc[15];
11719 +       t.c_cc[16] = svr4_cc[16];
11720 +
11721 +       if (t.c_lflag & ICANON) {
11722 +               t.c_cc[4] = svr4_cc[4];
11723 +               t.c_cc[11] = svr4_cc[5];
11724 +       } else {
11725 +               t.c_cc[5] = svr4_cc[5];
11726 +               t.c_cc[6] = svr4_cc[4];
11727 +               t.c_cc[11] = svr4_cc[6];
11728 +       }
11729 +
11730 +       set_fs(get_ds());
11731 +       error = sys_ioctl(fd, op, (long)&t);
11732 +       set_fs(fs);
11733 +
11734 +       return (error);
11735 +}
11736 +
11737 +static int
11738 +linux_to_svr4_termios(int fd, int op, struct svr4_termios *it)
11739 +{
11740 +       struct termios          t;
11741 +       char                    svr4_cc[SVR4_NCCS];
11742 +       mm_segment_t            fs;
11743 +       int                     error;
11744 +
11745 +       if (!access_ok(VERIFY_WRITE, it, sizeof(struct svr4_termios)))
11746 +               return -EFAULT;
11747 +
11748 +       fs = get_fs();
11749 +       set_fs(get_ds());
11750 +       error = sys_ioctl(fd, op, (long)&t);
11751 +       set_fs(fs);
11752 +
11753 +       if (error)
11754 +               return (error);
11755 +
11756 +       put_user(t.c_iflag & 0017777, &it->c_iflag);
11757 +       put_user(t.c_oflag & 0177777, &it->c_oflag);
11758 +
11759 +       if (t.c_cflag & CRTSCTS)
11760 +               t.c_cflag |= 0100000; /* CRTSFL - SCO only? */
11761 +       put_user(t.c_cflag & 0177777, &it->c_cflag);
11762 +
11763 +       t.c_lflag &= ~0001000;
11764 +       t.c_lflag |= (t.c_lflag & 0000400) << 1;
11765 +       t.c_lflag &= ~0000400;
11766 +       t.c_lflag |= (t.c_lflag & 0100000) >> 7;
11767 +       t.c_lflag &= ~0100000;
11768 +       put_user(t.c_lflag & 0001777, &it->c_lflag);
11769 +
11770 +       svr4_cc[0] = t.c_cc[0];
11771 +       svr4_cc[1] = t.c_cc[1];
11772 +       svr4_cc[2] = t.c_cc[2];
11773 +       svr4_cc[3] = t.c_cc[3];
11774 +       svr4_cc[6] = t.c_cc[16];
11775 +       svr4_cc[7] = t.c_cc[7];
11776 +       svr4_cc[8] = t.c_cc[8];
11777 +       svr4_cc[9] = t.c_cc[9];
11778 +       svr4_cc[10] = t.c_cc[10];
11779 +       svr4_cc[11] = t.c_cc[10];
11780 +       svr4_cc[12] = t.c_cc[12];
11781 +       svr4_cc[13] = t.c_cc[13];
11782 +       svr4_cc[14] = t.c_cc[14];
11783 +       svr4_cc[15] = t.c_cc[15];
11784 +
11785 +       if (t.c_lflag & ICANON) {
11786 +               svr4_cc[4] = t.c_cc[4];
11787 +               svr4_cc[5] = t.c_cc[11];
11788 +       } else {
11789 +               svr4_cc[4] = t.c_cc[6];
11790 +               svr4_cc[5] = t.c_cc[5];
11791 +       }
11792 +
11793 +       if (copy_to_user(&it->c_cc, svr4_cc, SVR4_NCCS))
11794 +               error = -EFAULT;
11795 +
11796 +       return (error);
11797 +}
11798 +
11799 +int
11800 +svr4_term_ioctl(int fd, u_int cmd, caddr_t data)
11801 +{
11802 +       switch (cmd) {
11803 +       case 1: /* TCGETA  (TIOC|1) */
11804 +               return linux_to_svr_termio(fd,
11805 +                       (struct svr_termio *)data);
11806 +       case 2: /* TCSETA  (TIOC|2) */
11807 +               return svr_to_linux_termio(fd, TCSETA,
11808 +                       (struct svr_termio *)data);
11809 +       case 3: /* TCSETAW (TIOC|3) */
11810 +               return svr_to_linux_termio(fd, TCSETAW,
11811 +                       (struct svr_termio *)data);
11812 +       case 4: /* TCSETAF (TIOC|4) */
11813 +               return svr_to_linux_termio(fd, TCSETAF,
11814 +                       (struct svr_termio *)data);
11815 +       case 5: /* TCSBRK  (TIOC|5) */
11816 +               return sys_ioctl(fd, TCSBRK, (long)data);
11817 +       case 6: /* TCXONC  (TIOC|6) */
11818 +               return sys_ioctl(fd, TCXONC, (long)data);
11819 +       case 7: /* TCFLSH  (TIOC|7) */
11820 +               return sys_ioctl(fd, TCFLSH, (long)data);
11821 +       /* This group appear in SVR4 but not SVR3 (SCO). */
11822 +       case 8: /* TIOCKBON */
11823 +       case 9: /* TIOCKBOF */
11824 +       case 10: /* KBENABLED */
11825 +               return -EINVAL;
11826 +
11827 +       /* This set is used by SVR4 for termios ioctls. */
11828 +       case 13: /* TCGETS */
11829 +               return linux_to_svr4_termios(fd, TCGETS,
11830 +                       (struct svr4_termios *)data);
11831 +       case 14: /* TCSETS */
11832 +               return svr4_to_linux_termios(fd, TCSETS,
11833 +                       (struct svr4_termios *)data);
11834 +       case 15: /* TCSETSW */
11835 +               return svr4_to_linux_termios(fd, TCSETSW,
11836 +                       (struct svr4_termios *)data);
11837 +       case 16: /* TCSETSF */
11838 +               return svr4_to_linux_termios(fd, TCSETSF,
11839 +                       (struct svr4_termios *)data);
11840 +
11841 +       /* These two are specific to ISC. */
11842 +       case 20: /* TCSETPGRP  (TIOC|20) set pgrp of tty */
11843 +               return sys_ioctl(fd, TIOCSPGRP, (long)data);
11844 +       case 21: /* TCGETPGRP  (TIOC|21) get pgrp of tty */
11845 +               return sys_ioctl(fd, TIOCGPGRP, (long)data);
11846 +
11847 +       case  34: /* TCGETSC (TIOC|34) ioctl for scancodes */
11848 +               return 0x04; /* Translates scancode to ascii */
11849 +       case  35: /* TCSETSC (TIOC|35) ioctl for scancodes */
11850 +               return 0;
11851 +
11852 +       case 103: /* TIOCSWINSZ (TIOC|103) */
11853 +               return sys_ioctl(fd, TIOCSWINSZ, (long)data);
11854 +       case 104: /* TIOCGWINSZ (TIOC|104) */
11855 +               return sys_ioctl(fd, TIOCGWINSZ, (long)data);
11856 +
11857 +       case 118: /* TIOCSPGRP  (TIOC|118) set pgrp of tty */
11858 +               return sys_ioctl(fd, TIOCSPGRP, (long)data);
11859 +       case 119: /* TIOCGPGRP  (TIOC|119) get pgrp of tty */
11860 +               return sys_ioctl(fd, TIOCGPGRP, (long)data);
11861 +
11862 +       case  32: /* TCDSET  (TIOC|32) */
11863 +       case  33: /* RTS_TOG (TIOC|33) 386 - "RTS" toggle define 8A1 protocol */
11864 +
11865 +       case 120: /* TIOSETSAK  (TIOC|120) set SAK sequence for tty */
11866 +       case 121: /* TIOGETSAK  (TIOC|121) get SAK sequence for tty */
11867 +               printk(KERN_ERR "iBCS: termio ioctl %d unimplemented\n", cmd);
11868 +               return -EINVAL;
11869 +       }
11870 +
11871 +       printk(KERN_ERR "iBCS: termio ioctl %d unsupported\n", cmd);
11872 +       return -EINVAL;
11873 +}
11874 +
11875 +struct termiox {
11876 +       unsigned short x_hflag;
11877 +       unsigned short x_cflag;
11878 +       unsigned short x_rflag[5];
11879 +       unsigned short x_sflag;
11880 +};
11881 +
11882 +#define RTSXOFF 0x0001
11883 +#define CTSXON 0x0002
11884 +
11885 +int
11886 +svr4_termiox_ioctl(int fd, u_int cmd, caddr_t data)
11887 +{
11888 +       struct termios          t;
11889 +       struct termiox          tx;
11890 +       mm_segment_t            fs;
11891 +       int                     error;
11892 +
11893 +       if (cmd < 1 || cmd > 4)
11894 +               return -EINVAL;
11895 +
11896 +       if (!access_ok(cmd == 1 ? VERIFY_WRITE : VERIFY_READ,
11897 +                       data, sizeof(struct termiox)))
11898 +               return -EFAULT;
11899 +
11900 +       fs = get_fs();
11901 +       set_fs(get_ds());
11902 +       error = sys_ioctl(fd, TCGETS, (long)&t);
11903 +       set_fs(fs);
11904 +
11905 +       if (error)
11906 +               return (error);
11907 +
11908 +       if (cmd == 1) { /* TCGETX */
11909 +               memset(&tx, '\0', sizeof(struct termiox));
11910 +               if (t.c_cflag & CRTSCTS)
11911 +                       tx.x_hflag = RTSXOFF|CTSXON;
11912 +               if (copy_to_user(data, &tx, sizeof(struct termiox)))
11913 +                       return -EFAULT;
11914 +               return 0;
11915 +       }
11916 +
11917 +       if (copy_from_user(&tx, data, sizeof(struct termiox)))
11918 +               return -EFAULT;
11919 +
11920 +       if ((tx.x_hflag != 0 && tx.x_hflag != (RTSXOFF|CTSXON))
11921 +       || tx.x_cflag || tx.x_rflag[0] || tx.x_rflag[1]
11922 +       || tx.x_rflag[2] || tx.x_rflag[3] || tx.x_rflag[4]
11923 +       || tx.x_sflag)
11924 +               return -EINVAL;
11925 +
11926 +       if (tx.x_hflag)
11927 +               t.c_cflag |= CRTSCTS;
11928 +       else
11929 +               t.c_cflag &= (~CRTSCTS);
11930 +
11931 +       fs = get_fs();
11932 +       set_fs(get_ds());
11933 +       switch (cmd) {
11934 +               case 2: /* TCSETX */
11935 +                       error = sys_ioctl(fd, TCSETS, (long)&t);
11936 +                       break;
11937 +               case 3: /* TCSETXW */
11938 +                       error = sys_ioctl(fd, TCSETSW, (long)&t);
11939 +                       break;
11940 +               case 4: /* TCSETXF */
11941 +                       error = sys_ioctl(fd, TCSETSF, (long)&t);
11942 +                       break;
11943 +       }
11944 +       set_fs(fs);
11945 +       return (error);
11946 +}
11947 +
11948 +#define BSD_NCCS 20
11949 +struct bsd_termios {
11950 +       unsigned long   c_iflag;
11951 +       unsigned long   c_oflag;
11952 +       unsigned long   c_cflag;
11953 +       unsigned long   c_lflag;
11954 +       unsigned char   c_cc[BSD_NCCS];
11955 +       long            c_ispeed;
11956 +       long            c_ospeed;
11957 +};
11958 +static unsigned long speed_map[] = {
11959 +       0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
11960 +       4800, 9600, 19200, 38400
11961 +};
11962 +
11963 +static unsigned long
11964 +bsd_to_linux_speed(unsigned long s)
11965 +{
11966 +       unsigned int i;
11967 +
11968 +#ifdef B57600
11969 +       if (s == 57600)
11970 +               return B57600;
11971 +#endif
11972 +#ifdef B115200
11973 +       if (s == 115200)
11974 +               return B115200;
11975 +#endif
11976 +
11977 +       for (i=0; i<sizeof(speed_map)/sizeof(speed_map[0]); i++)
11978 +               if (s <= speed_map[i])
11979 +                       return i;
11980 +       return B38400;
11981 +}
11982 +
11983 +static unsigned long
11984 +linux_to_bsd_speed(unsigned long s)
11985 +{
11986 +#ifdef B57600
11987 +       if (s == B57600)
11988 +               return 57600;
11989 +#endif
11990 +#ifdef B115200
11991 +       if (s == B115200)
11992 +               return 115200;
11993 +#endif
11994 +       return speed_map[s];
11995 +}
11996 +
11997 +
11998 +
11999 +
12000 +static int
12001 +bsd_to_linux_termios(int fd, int op, struct bsd_termios *it)
12002 +{
12003 +       struct termios t;
12004 +       mm_segment_t old_fs;
12005 +       unsigned long temp;
12006 +       char bsd_cc[BSD_NCCS];
12007 +       int error;
12008 +
12009 +       if (!access_ok(VERIFY_READ, it, sizeof(struct bsd_termios)))
12010 +               return -EFAULT;
12011 +
12012 +       old_fs = get_fs();
12013 +       set_fs(get_ds());
12014 +       error = sys_ioctl(fd, TCGETS, (long)&t);
12015 +       set_fs(old_fs);
12016 +       if (error)
12017 +               return error;
12018 +
12019 +       __get_user(t.c_iflag, &it->c_iflag);
12020 +       t.c_iflag = (t.c_iflag & ~0xc00)
12021 +                       | ((t.c_iflag & 0x400) << 1)
12022 +                       | ((t.c_iflag & 0x800) >> 1);
12023 +
12024 +       get_user(temp, &it->c_oflag);
12025 +       t.c_oflag = (t.c_oflag & ~0x1805)
12026 +                       | (temp & 9)
12027 +                       | ((temp & 2) << 1)
12028 +                       | ((temp & 4) << 10)
12029 +                       | ((temp & 4) << 9);
12030 +
12031 +       get_user(temp, &it->c_cflag);
12032 +       t.c_cflag = (t.c_cflag & ~0xfff)
12033 +                       | ((temp & 0xff00) >> 4);
12034 +       if (t.c_cflag & 0x30000)
12035 +               t.c_cflag |= 020000000000;
12036 +       t.c_cflag |= bsd_to_linux_speed(({long s; get_user(s, &it->c_ospeed); s;}))
12037 +               | (bsd_to_linux_speed(({long s; get_user(s, &it->c_ispeed); s;})) << 16);
12038 +
12039 +       get_user(temp, &it->c_lflag);
12040 +       t.c_lflag = (t.c_lflag & ~0157663)
12041 +                       | ((temp & 1) << 12)
12042 +                       | ((temp & 0x46) << 3)
12043 +                       | ((temp & 0x420) << 5)
12044 +                       | ((temp & 0x180) >> 7)
12045 +                       | ((temp & 0x400000) >> 14)
12046 +                       | ((temp & 0x2800000) >> 11)
12047 +                       | ((temp & 0x80000000) >> 24);
12048 +
12049 +       if (copy_from_user(bsd_cc, &it->c_cc, BSD_NCCS))
12050 +               return -EFAULT;
12051 +
12052 +       t.c_cc[VEOF] = bsd_cc[0];
12053 +       t.c_cc[VEOL] = bsd_cc[1];
12054 +       t.c_cc[VEOL2] = bsd_cc[2];
12055 +       t.c_cc[VERASE] = bsd_cc[3];
12056 +       t.c_cc[VWERASE] = bsd_cc[4];
12057 +       t.c_cc[VKILL] = bsd_cc[5];
12058 +       t.c_cc[VREPRINT] = bsd_cc[6];
12059 +       t.c_cc[VSWTC] = bsd_cc[7];
12060 +       t.c_cc[VINTR] = bsd_cc[8];
12061 +       t.c_cc[VQUIT] = bsd_cc[9];
12062 +       t.c_cc[VSUSP] = bsd_cc[10];
12063 +/*     t.c_cc[VDSUSP] = bsd_cc[11];*/
12064 +       t.c_cc[VSTART] = bsd_cc[12];
12065 +       t.c_cc[VSTOP] = bsd_cc[13];
12066 +       t.c_cc[VLNEXT] = bsd_cc[14];
12067 +       t.c_cc[VDISCARD] = bsd_cc[15];
12068 +       t.c_cc[VMIN] = bsd_cc[16];
12069 +       t.c_cc[VTIME] = bsd_cc[17];
12070 +/*     t.c_cc[VSTATUS] = bsd_cc[18];*/
12071 +
12072 +       set_fs(get_ds());
12073 +       error = sys_ioctl(fd, op, (long)&t);
12074 +       set_fs(old_fs);
12075 +
12076 +       return error;
12077 +}
12078 +
12079 +
12080 +static int
12081 +linux_to_bsd_termios(int fd, int op, struct bsd_termios *it)
12082 +{
12083 +       struct termios t;
12084 +       char bsd_cc[BSD_NCCS];
12085 +       mm_segment_t old_fs;
12086 +       int error;
12087 +
12088 +       if (!access_ok(VERIFY_WRITE, it, sizeof(struct bsd_termios)))
12089 +               return -EFAULT;
12090 +
12091 +       old_fs = get_fs();
12092 +       set_fs(get_ds());
12093 +       error = sys_ioctl(fd, op, (long)&t);
12094 +       set_fs(old_fs);
12095 +       if (error)
12096 +               return error;
12097 +
12098 +       put_user((t.c_iflag & 0777)
12099 +                       | ((t.c_iflag & 02000) >> 1)
12100 +                       | ((t.c_iflag & 010000) >> 2)
12101 +                       | ((t.c_iflag & 020000) >> 4),
12102 +               &it->c_iflag);
12103 +
12104 +       put_user((t.c_oflag & 1)
12105 +                       | ((t.c_oflag & 04) >> 1)
12106 +                       | ((t.c_oflag & 014000) == 014000 ? 4 : 0),
12107 +               &it->c_oflag);
12108 +
12109 +       put_user((t.c_cflag & ~020000007777)
12110 +                       | ((t.c_cflag & 0xff0) << 4)
12111 +                       | ((t.c_cflag & 020000000000) ? 0x30000 : 0),
12112 +               &it->c_cflag);
12113 +
12114 +       put_user(linux_to_bsd_speed(t.c_cflag & CBAUD), &it->c_ospeed);
12115 +       if ((t.c_cflag & CIBAUD) != 0)
12116 +               put_user(linux_to_bsd_speed((t.c_cflag & CIBAUD) >> 16),
12117 +                       &it->c_ispeed);
12118 +       else
12119 +               put_user(linux_to_bsd_speed(t.c_cflag & CBAUD),
12120 +                       &it->c_ispeed);
12121 +
12122 +       put_user((t.c_lflag & 07777626010)
12123 +                       | ((t.c_lflag & 03) << 7)
12124 +                       | ((t.c_lflag & 01160) >> 3)
12125 +                       | ((t.c_lflag & 0400) << 14)
12126 +                       | ((t.c_lflag & 02000) >> 4)
12127 +                       | ((t.c_lflag & 04000) >> 11)
12128 +                       | ((t.c_lflag & 010000) << 11)
12129 +                       | ((t.c_lflag & 040000) << 15)
12130 +                       | ((t.c_lflag & 0100000) >> 5),
12131 +               &it->c_lflag);
12132 +
12133 +       bsd_cc[0] = t.c_cc[VEOF];
12134 +       bsd_cc[1] = t.c_cc[VEOL];
12135 +       bsd_cc[2] = t.c_cc[VEOL2];
12136 +       bsd_cc[3] = t.c_cc[VERASE];
12137 +       bsd_cc[4] = t.c_cc[VWERASE];
12138 +       bsd_cc[5] = t.c_cc[VKILL];
12139 +       bsd_cc[6] = t.c_cc[VREPRINT];
12140 +       bsd_cc[7] = t.c_cc[VSWTC];
12141 +       bsd_cc[8] = t.c_cc[VINTR];
12142 +       bsd_cc[9] = t.c_cc[VQUIT];
12143 +       bsd_cc[10] = t.c_cc[VSUSP];
12144 +       bsd_cc[11] = t.c_cc[VSUSP];
12145 +       bsd_cc[12] = t.c_cc[VSTART];
12146 +       bsd_cc[13] = t.c_cc[VSTOP];
12147 +       bsd_cc[14] = t.c_cc[VLNEXT];
12148 +       bsd_cc[15] = t.c_cc[VDISCARD];
12149 +       bsd_cc[16] = t.c_cc[VMIN];
12150 +       bsd_cc[17] = t.c_cc[VTIME];
12151 +       bsd_cc[18] = 0; /* t.c_cc[VSTATUS]; */
12152 +       bsd_cc[19] = 0;
12153 +
12154 +       if (copy_to_user(&it->c_cc, bsd_cc, BSD_NCCS))
12155 +               error = -EFAULT;
12156 +
12157 +       return error;
12158 +}
12159 +
12160 +
12161 +
12162 +
12163 +struct v7_sgttyb {
12164 +       unsigned char   sg_ispeed;
12165 +       unsigned char   sg_ospeed;
12166 +       unsigned char   sg_erase;
12167 +       unsigned char   sg_kill;
12168 +       int     sg_flags;
12169 +};
12170 +
12171 +struct v7_tchars {
12172 +       char    t_intrc;
12173 +       char    t_quitc;
12174 +       char    t_startc;
12175 +       char    t_stopc;
12176 +       char    t_eofc;
12177 +       char    t_brkc;
12178 +};
12179 +
12180 +struct v7_ltchars {
12181 +       char    t_suspc;
12182 +       char    t_dsuspc;
12183 +       char    t_rprntc;
12184 +       char    t_flushc;
12185 +       char    t_werasc;
12186 +       char    t_lnextc;
12187 +};
12188 +
12189 +
12190 +int bsd_ioctl_termios(int fd, unsigned int func, void *data)
12191 +{
12192 +       switch (func & 0xff) {
12193 +               case 0:  {                              /* TIOCGETD */
12194 +                       unsigned long ldisc;
12195 +                       mm_segment_t old_fs;
12196 +                       int error;
12197 +
12198 +                       if (!access_ok(VERIFY_WRITE, data,
12199 +                                       sizeof(unsigned short)))
12200 +                               return -EFAULT;
12201 +
12202 +                       old_fs = get_fs();
12203 +                       set_fs(get_ds());
12204 +                       error = sys_ioctl(fd, TIOCGETD, (long)&ldisc);
12205 +                       set_fs(old_fs);
12206 +                       if (!error)
12207 +                               put_user(ldisc, (unsigned short *)data);
12208 +                       return error;
12209 +               }
12210 +               case 1: {                               /* TIOCSETD */
12211 +                       unsigned long ldisc;
12212 +                       mm_segment_t old_fs;
12213 +                       int error;
12214 +
12215 +                       if (!access_ok(VERIFY_READ, data,
12216 +                                       sizeof(unsigned short)))
12217 +                               return -EFAULT;
12218 +
12219 +                       get_user(ldisc, (unsigned short *)data);
12220 +                       old_fs = get_fs();
12221 +                       set_fs(get_ds());
12222 +                       error = sys_ioctl(fd, TIOCSETD, (long)&ldisc);
12223 +                       set_fs(old_fs);
12224 +                       return error;
12225 +               }
12226 +
12227 +               case 2: {                               /* TIOCHPCL */
12228 +                       int error;
12229 +                       mm_segment_t old_fs;
12230 +                       struct termios t;
12231 +
12232 +                       old_fs = get_fs();
12233 +                       set_fs(get_ds());
12234 +                       error = sys_ioctl(fd, TCGETS, (long)&t);
12235 +                       set_fs(old_fs);
12236 +                       if (error)
12237 +                               return error;
12238 +
12239 +                       if (data)
12240 +                               t.c_cflag |= HUPCL;
12241 +                       else
12242 +                               t.c_cflag &= ~HUPCL;
12243 +
12244 +                       old_fs = get_fs();
12245 +                       set_fs(get_ds());
12246 +                       error = sys_ioctl(fd, TCSETS, (long)&t);
12247 +                       set_fs(old_fs);
12248 +                       return error;
12249 +               }
12250 +
12251 +               case 8: {                               /* TIOCGETP */
12252 +                       int error;
12253 +                       mm_segment_t old_fs;
12254 +                       struct termios t;
12255 +                       struct v7_sgttyb sg;
12256 +
12257 +                       if (!access_ok(VERIFY_WRITE, data, sizeof(sg)))
12258 +                               return -EFAULT;
12259 +
12260 +                       old_fs = get_fs();
12261 +                       set_fs(get_ds());
12262 +                       error = sys_ioctl(fd, TCGETS, (long)&t);
12263 +                       set_fs(old_fs);
12264 +                       if (error)
12265 +                               return error;
12266 +
12267 +                       sg.sg_ispeed = sg.sg_ospeed = 0;
12268 +                       sg.sg_erase = t.c_cc[VERASE];
12269 +                       sg.sg_kill = t.c_cc[VKILL];
12270 +                       sg.sg_flags =
12271 +                               /* Old - became TANDEM instead.
12272 +                                * ((t.c_cflag & HUPCL) >> 10)
12273 +                                * |
12274 +                                */
12275 +/* O_ODDP */                   ((t.c_cflag & PARODD) >> 3)
12276 +/* O_EVENP */                  | ((t.c_cflag & PARENB) >> 1)
12277 +/* LITOUT */                   | ((t.c_cflag & OPOST) ? 0 : 0x200000)
12278 +/* O_CRMOD */                  | ((t.c_oflag & ONLCR) << 2)
12279 +/* O_NL1|O_VTDELAY */          | (t.c_oflag & (NL1|VTDLY))
12280 +/* O_TBDELAY */                        | ((t.c_oflag & TABDLY) ? 02000 : 0)
12281 +/* O_CRDELAY */                        | ((t.c_oflag & CRDLY) << 3)
12282 +/* O_BSDELAY */                        | ((t.c_oflag & BSDLY) << 2)
12283 +/* O_ECHO|O_LCASE */           | (t.c_lflag & (XCASE|ECHO))
12284 +                               | ((t.c_lflag & ICANON)
12285 +/* O_CBREAK or O_RAW */                ? 0 : ((t.c_lflag & ISIG) ? 0x02 : 0x20))
12286 +                               /* Incomplete... */
12287 +                               ;
12288 +
12289 +                       if (copy_to_user(data, &sg, sizeof(sg)))
12290 +                               return -EFAULT;
12291 +                       return 0;
12292 +               }
12293 +
12294 +               case 9:                                 /* TIOCSETP */
12295 +               case 10: {                              /* TIOCSETN */
12296 +                       int error;
12297 +                       mm_segment_t old_fs;
12298 +                       struct termios t;
12299 +                       struct v7_sgttyb sg;
12300 +
12301 +                       if (!access_ok(VERIFY_READ, data, sizeof(sg)))
12302 +                               return -EFAULT;
12303 +                       if (copy_from_user(&sg, data, sizeof(sg)))
12304 +                               return -EFAULT;
12305 +
12306 +                       old_fs = get_fs();
12307 +                       set_fs(get_ds());
12308 +                       error = sys_ioctl(fd, TCGETS, (long)&t);
12309 +                       set_fs(old_fs);
12310 +                       if (error)
12311 +                               return error;
12312 +
12313 +                       t.c_cc[VERASE] = sg.sg_erase;
12314 +                       t.c_cc[VKILL] = sg.sg_kill;
12315 +                       t.c_iflag = ICRNL | IXON;
12316 +                       t.c_oflag = 0;
12317 +                       t.c_lflag = ISIG | ICANON;
12318 +                       if (sg.sg_flags & 0x02)         /* O_CBREAK */
12319 +                               t.c_lflag &= (~ICANON);
12320 +                       if (sg.sg_flags & 0x08)         /* O_ECHO */
12321 +                               t.c_lflag |= ECHO|ECHOE|ECHOK|ECHOCTL|ECHOKE|IEXTEN;
12322 +                       if (sg.sg_flags & 0x10) /* O_CRMOD */
12323 +                               t.c_oflag |= OPOST|ONLCR;
12324 +                       if (sg.sg_flags & 0x20) {       /* O_RAW */
12325 +                               t.c_iflag = 0;
12326 +                               t.c_lflag &= ~(ISIG|ICANON);
12327 +                       }
12328 +                       if (sg.sg_flags & 0x200000)     /* LITOUT */
12329 +                               t.c_oflag &= (~OPOST);
12330 +                       if (!(t.c_lflag & ICANON)) {
12331 +                               t.c_cc[VMIN] = 1;
12332 +                               t.c_cc[VTIME] = 0;
12333 +                       }
12334 +
12335 +                       old_fs = get_fs();
12336 +                       set_fs(get_ds());
12337 +                       error = sys_ioctl(fd, TCSETS, (long)&t);
12338 +                       set_fs(old_fs);
12339 +                       return error;
12340 +               }
12341 +
12342 +               case 17: {                              /* TIOCSETC */
12343 +                       int error;
12344 +                       mm_segment_t old_fs;
12345 +                       struct termios t;
12346 +                       struct v7_tchars tc;
12347 +
12348 +                       if (!access_ok(VERIFY_READ, data, sizeof(tc)))
12349 +                               return -EFAULT;
12350 +                       if (copy_from_user(&tc, data, sizeof(tc)))
12351 +                               return -EFAULT;
12352 +
12353 +                       old_fs = get_fs();
12354 +                       set_fs(get_ds());
12355 +                       error = sys_ioctl(fd, TCGETS, (long)&t);
12356 +                       set_fs(old_fs);
12357 +                       if (error)
12358 +                               return error;
12359 +
12360 +                       t.c_cc[VINTR] = tc.t_intrc;
12361 +                       t.c_cc[VQUIT] = tc.t_quitc;
12362 +                       t.c_cc[VSTART] = tc.t_startc;
12363 +                       t.c_cc[VSTOP] = tc.t_stopc;
12364 +                       t.c_cc[VEOF] = tc.t_eofc;
12365 +                       t.c_cc[VEOL2] = tc.t_brkc;
12366 +
12367 +                       old_fs = get_fs();
12368 +                       set_fs(get_ds());
12369 +                       error = sys_ioctl(fd, TCSETS, (long)&t);
12370 +                       set_fs(old_fs);
12371 +                       return error;
12372 +               }
12373 +
12374 +               case 18: {                              /* TIOCGETC */
12375 +                       int error;
12376 +                       mm_segment_t old_fs;
12377 +                       struct termios t;
12378 +                       struct v7_tchars tc;
12379 +
12380 +                       if (!access_ok(VERIFY_WRITE, data, sizeof(tc)))
12381 +                               return -EFAULT;
12382 +
12383 +                       old_fs = get_fs();
12384 +                       set_fs(get_ds());
12385 +                       error = sys_ioctl(fd, TCGETS, (long)&t);
12386 +                       set_fs(old_fs);
12387 +                       if (error)
12388 +                               return error;
12389 +
12390 +                       tc.t_intrc = t.c_cc[VINTR];
12391 +                       tc.t_quitc = t.c_cc[VQUIT];
12392 +                       tc.t_startc = t.c_cc[VSTART];
12393 +                       tc.t_stopc = t.c_cc[VSTOP];
12394 +                       tc.t_eofc = t.c_cc[VEOF];
12395 +                       tc.t_brkc = t.c_cc[VEOL2];
12396 +
12397 +                       if (copy_to_user(data, &tc, sizeof(tc)))
12398 +                               return -EFAULT;
12399 +                       return 0;
12400 +               }
12401 +
12402 +               case 116: {                             /* TIOCGLTC */
12403 +                       int error;
12404 +                       mm_segment_t old_fs;
12405 +                       struct termios t;
12406 +                       struct v7_ltchars tc;
12407 +
12408 +                       if (!access_ok(VERIFY_WRITE, data, sizeof(tc)))
12409 +                               return -EFAULT;
12410 +
12411 +                       old_fs = get_fs();
12412 +                       set_fs(get_ds());
12413 +                       error = sys_ioctl(fd, TCGETS, (long)&t);
12414 +                       set_fs(old_fs);
12415 +                       if (error)
12416 +                               return error;
12417 +
12418 +                       tc.t_suspc = t.c_cc[VSUSP];
12419 +                       tc.t_dsuspc = t.c_cc[VSUSP];
12420 +                       tc.t_rprntc = t.c_cc[VREPRINT];
12421 +                       tc.t_flushc = t.c_cc[VEOL2];
12422 +                       tc.t_werasc = t.c_cc[VWERASE];
12423 +                       tc.t_lnextc = t.c_cc[VLNEXT];
12424 +
12425 +                       if (copy_to_user(data, &tc, sizeof(tc)))
12426 +                               return -EFAULT;
12427 +                       return 0;
12428 +               }
12429 +
12430 +               case 117: {                             /* TIOCSLTC */
12431 +                       int error;
12432 +                       mm_segment_t old_fs;
12433 +                       struct termios t;
12434 +                       struct v7_ltchars tc;
12435 +
12436 +                       if (!access_ok(VERIFY_READ, data, sizeof(tc)))
12437 +                               return -EFAULT;
12438 +                       if (copy_from_user(&tc, data, sizeof(tc)))
12439 +                               return -EFAULT;
12440 +
12441 +                       old_fs = get_fs();
12442 +                       set_fs(get_ds());
12443 +                       error = sys_ioctl(fd, TCGETS, (long)&t);
12444 +                       set_fs(old_fs);
12445 +                       if (error)
12446 +                               return error;
12447 +
12448 +                       t.c_cc[VSUSP] = tc.t_suspc;
12449 +                       t.c_cc[VEOL2] = tc.t_dsuspc;
12450 +                       t.c_cc[VREPRINT] = tc.t_rprntc;
12451 +                       t.c_cc[VEOL2] = tc.t_flushc;
12452 +                       t.c_cc[VWERASE] = tc.t_werasc;
12453 +                       t.c_cc[VLNEXT] = tc.t_lnextc;
12454 +
12455 +                       old_fs = get_fs();
12456 +                       set_fs(get_ds());
12457 +                       error = sys_ioctl(fd, TCSETS, (long)&t);
12458 +                       set_fs(old_fs);
12459 +                       return error;
12460 +               }
12461 +
12462 +               case 13:                                /* TIOEXCL */
12463 +                       return sys_ioctl(fd, TIOCEXCL, (long)data);
12464 +
12465 +               case 14:                                /* TIOCNXCL */
12466 +                       return sys_ioctl(fd, TIOCNXCL, (long)data);
12467 +
12468 +               case 16:                                /* TIOCFLUSH */
12469 +                       return sys_ioctl(fd, TCFLSH, (long)data);
12470 +
12471 +
12472 +               /* ISC (maybe SVR4 in general?) has some extensions over
12473 +                * the sgtty stuff. So do later BSDs. Needless to say they
12474 +                * both have different extensions.
12475 +                */
12476 +               case 20: /* TCSETPGRP  (TIOC|20) set pgrp of tty */
12477 +                       return bsd_to_linux_termios(fd, TCSETS, data);
12478 +
12479 +               case 21: /* TCGETPGRP  (TIOC|21) get pgrp of tty */
12480 +                       return bsd_to_linux_termios(fd, TCSETSW, data);
12481 +
12482 +               case 19:                                /* TIOCGETA */
12483 +                       return linux_to_bsd_termios(fd, TCGETS, data);
12484 +
12485 +               case 22:                                /* TIOCSETAF */
12486 +                       return bsd_to_linux_termios(fd, TCSETSF, data);
12487 +
12488 +               case 26:                                /* TIOCGETD */
12489 +                       return sys_ioctl(fd, TIOCGETD, (long)data);
12490 +
12491 +               case 27:                                /* TIOCSETD */
12492 +                       return sys_ioctl(fd, TIOCSETD, (long)data);
12493 +
12494 +               case 97:                                /* TIOCSCTTY */
12495 +                       return sys_ioctl(fd, TIOCSCTTY, (long)data);
12496 +
12497 +               case 103:                               /* TIOCSWINSZ */
12498 +                       return sys_ioctl(fd, TIOCSWINSZ, (long)data);
12499 +
12500 +               case 104:                               /* TIOCGWINSZ */
12501 +                       return sys_ioctl(fd, TIOCGWINSZ, (long)data);
12502 +
12503 +               case 113:                               /* TIOCNOTTY */
12504 +                       return sys_ioctl(fd, TIOCNOTTY, (long)data);
12505 +
12506 +               case 118:                               /* TIOCSPGRP */
12507 +                       return sys_ioctl(fd, TIOCSPGRP, (long)data);
12508 +
12509 +               case 119:                               /* TIOCGPGRP */
12510 +                       return sys_ioctl(fd, TIOCGPGRP, (long)data);
12511 +
12512 +               case 123:                               /* TIOCSBRK */
12513 +                       return sys_ioctl(fd, TCSBRK, (long)data);
12514 +
12515 +               case 124:                               /* TIOCLGET */
12516 +               case 125:                               /* TIOCLSET */
12517 +                       return 0;
12518 +
12519 +
12520 +               case 3:                                 /* TIOCMODG */
12521 +               case 4:                                 /* TIOCMODS */
12522 +               case 94:                                /* TIOCDRAIN */
12523 +               case 95:                                /* TIOCSIG */
12524 +               case 96:                                /* TIOCEXT */
12525 +               case 98:                                /* TIOCCONS */
12526 +               case 102:                               /* TIOCUCNTL */
12527 +               case 105:                               /* TIOCREMOTE */
12528 +               case 106:                               /* TIOCMGET */
12529 +               case 107:                               /* TIOCMBIC */
12530 +               case 108:                               /* TIOCMBIS */
12531 +               case 109:                               /* TIOCMSET */
12532 +               case 110:                               /* TIOCSTART */
12533 +               case 111:                               /* TIOCSTOP */
12534 +               case 112:                               /* TIOCPKT */
12535 +               case 114:                               /* TIOCSTI */
12536 +               case 115:                               /* TIOCOUTQ */
12537 +               case 120:                               /* TIOCCDTR */
12538 +               case 121:                               /* TIOCSDTR */
12539 +               case 122:                               /* TIOCCBRK */
12540 +                        break;
12541 +       }
12542 +
12543 +       printk(KERN_ERR "BSD/V7: terminal ioctl 0x%08lx unsupported\n",
12544 +               (unsigned long)func);
12545 +       return -EINVAL;
12546 +}
12547 +
12548 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
12549 +EXPORT_SYMBOL(bsd_ioctl_termios);
12550 +EXPORT_SYMBOL(svr4_term_ioctl);
12551 +#endif
12552 diff -Nur kernel-source-2.6.16.orig/abi/svr4/timod.c kernel-source-2.6.16/abi/svr4/timod.c
12553 --- kernel-source-2.6.16.orig/abi/svr4/timod.c  1970-01-01 10:00:00.000000000 +1000
12554 +++ kernel-source-2.6.16/abi/svr4/timod.c       2006-04-27 18:50:24.000000000 +1000
12555 @@ -0,0 +1,200 @@
12556 +/*
12557 + * Copyright 1995, 1996  Mike Jagdis (jaggy@purplet.demon.co.uk)
12558 + */
12559 +
12560 +#ident "%W% %G%"
12561 +
12562 +#include <linux/config.h>
12563 +#include <linux/types.h>
12564 +#include <linux/errno.h>
12565 +#include <linux/fs.h>
12566 +#include <linux/ptrace.h>
12567 +#include <linux/sched.h>
12568 +#include <linux/kernel.h>
12569 +#include <linux/slab.h>
12570 +#include <linux/mm.h>
12571 +#include <linux/fcntl.h>
12572 +#include <linux/socket.h>
12573 +#include <linux/in.h>
12574 +#include <linux/un.h>
12575 +#include <linux/file.h>
12576 +#include <linux/personality.h>
12577 +#include <linux/poll.h>
12578 +#include <linux/syscalls.h>
12579 +#include <asm/uaccess.h>
12580 +
12581 +#include <net/sock.h>
12582 +
12583 +#include <asm/abi_machdep.h>
12584 +#include <abi/stream.h>
12585 +#include <abi/tli.h>
12586 +
12587 +#include <abi/svr4/ioctl.h>
12588 +#include <abi/util/trace.h>
12589 +
12590 +
12591 +/*
12592 + * Check if the inode belongs to /dev/socksys.
12593 + */
12594 +#define IS_SOCKSYS(ip) (MAJOR((ip)->i_rdev) == SOCKSYS_MAJOR)
12595 +
12596 +
12597 +int
12598 +timod_getmsg(int fd, struct inode *ip, int pmsg, struct pt_regs *regs)
12599 +{
12600 +       struct strbuf   ctl, *ctlp, dat, *datp;
12601 +       int             flags, *flagsp, *bandp;
12602 +       int             error;
12603 +
12604 +       ctlp = (struct strbuf *)get_syscall_parameter(regs, 1);
12605 +       datp = (struct strbuf *)get_syscall_parameter(regs, 2);
12606 +
12607 +       if (pmsg) {
12608 +               bandp = (int *)get_syscall_parameter(regs, 3);
12609 +               flagsp = (int *)get_syscall_parameter(regs, 4);
12610 +       } else
12611 +               flagsp = (int *)get_syscall_parameter (regs, 3);
12612 +
12613 +       if (ctlp) {
12614 +               if (copy_from_user(&ctl, ctlp, sizeof(ctl)))
12615 +                       return -EFAULT;
12616 +               if ((error = put_user(-1, &ctlp->len)))
12617 +                       return error;
12618 +       } else
12619 +               ctl.maxlen = -1;
12620 +
12621 +       if (datp) {
12622 +               if (copy_from_user(&dat, datp, sizeof(dat)))
12623 +                       return -EFAULT;
12624 +               if ((error = put_user(-1, &datp->len)))
12625 +                       return error;
12626 +       } else
12627 +               dat.maxlen = -1;
12628 +
12629 +       if ((error = get_user(flags, flagsp)))
12630 +               return error;
12631 +
12632 +#ifdef CONFIG_ABI_SPX
12633 +       if (IS_SOCKSYS(ip) && MINOR(ip->i_rdev) == 1) {
12634 +
12635 +#if defined(CONFIG_ABI_TRACE)
12636 +               abi_trace(ABI_TRACE_STREAMS,
12637 +                       "SPX: getmsg offers descriptor %d\n", fd);
12638 +#endif
12639 +
12640 +               if ((error = put_user(fd, ctl.buf)))
12641 +                       return error;
12642 +               if ((error = put_user(4, &ctlp->len)))
12643 +                       return error;
12644 +
12645 +               return 0;
12646 +       }
12647 +#endif /* CONFIG_ABI_SPX */
12648 +
12649 +#ifdef CONFIG_ABI_XTI
12650 +       if (flags == 0 || flags == MSG_HIPRI ||
12651 +           flags == MSG_ANY || flags == MSG_BAND) {
12652 +               struct file     *fp;
12653 +
12654 +               fp = fget(fd);
12655 +               error = do_getmsg(fd, regs, ctl.buf, ctl.maxlen, &ctlp->len,
12656 +                               dat.buf, dat.maxlen, &datp->len, &flags);
12657 +               fput(fp);
12658 +
12659 +               if (error >= 0)
12660 +                       error = put_user(flags, flagsp);
12661 +               return error;
12662 +       }
12663 +
12664 +#if defined(CONFIG_ABI_TRACE)
12665 +       abi_trace(ABI_TRACE_STREAMS,
12666 +                       "XTI: getmsg flags value bad (%d) for %d\n",
12667 +                       flags, fd);
12668 +#endif /* CONFIG_ABI_TRACE */
12669 +#endif /* CONFIG_ABI_XTI */
12670 +       return -EINVAL;
12671 +}
12672 +
12673 +
12674 +int
12675 +timod_putmsg(int fd, struct inode *ip, int pmsg, struct pt_regs *regs)
12676 +{
12677 +       struct strbuf           ctl, *ctlp, dat, *datp;
12678 +       int                     flags, band;
12679 +       int                     error;
12680 +
12681 +       ctlp = (struct strbuf *)get_syscall_parameter(regs, 1);
12682 +       datp = (struct strbuf *)get_syscall_parameter(regs, 2);
12683 +       if (pmsg) {
12684 +               band = get_syscall_parameter(regs, 3);
12685 +               flags = get_syscall_parameter(regs, 4);
12686 +       } else
12687 +               flags = get_syscall_parameter(regs, 3);
12688 +
12689 +       if (ctlp) {
12690 +               if (copy_from_user(&ctl, ctlp, sizeof(ctl)))
12691 +                       return -EFAULT;
12692 +               if (ctl.len < 0 && flags)
12693 +                       return -EINVAL;
12694 +       } else {
12695 +               ctl.len = 0;
12696 +               ctl.buf = NULL;
12697 +       }
12698 +
12699 +       if (datp) {
12700 +               if (copy_from_user(&dat, datp, sizeof(dat)))
12701 +                       return -EFAULT;
12702 +       } else {
12703 +               dat.len = 0;
12704 +               dat.buf = NULL;
12705 +       }
12706 +
12707 +#ifdef CONFIG_ABI_SPX
12708 +       if (IS_SOCKSYS(ip) && MINOR(ip->i_rdev) == 1) {
12709 +               int             newfd;
12710 +
12711 +               if (ctl.len != 4)
12712 +                       return -EIO;
12713 +
12714 +               error = get_user(newfd, ctl.buf);
12715 +               if (error)
12716 +                       return error;
12717 +
12718 +#if defined(CONFIG_ABI_TRACE)
12719 +               abi_trace(ABI_TRACE_STREAMS,
12720 +                               "SPX: putmsg on %d dups descriptor %d\n",
12721 +                               fd, newfd);
12722 +#endif
12723 +               error = sys_dup2(newfd, fd);
12724 +
12725 +               return (error < 0 ? error : 0);
12726 +       }
12727 +#endif /* CONFIG_ABI_SPX */
12728 +
12729 +#ifdef CONFIG_ABI_XTI
12730 +       return do_putmsg(fd, regs, ctl.buf, ctl.len,
12731 +                       dat.buf, dat.len, flags);
12732 +#endif
12733 +       return -EINVAL;
12734 +}
12735 +
12736 +int
12737 +stream_fdinsert(struct pt_regs *regs, int fd, struct strfdinsert *arg)
12738 +{
12739 +       struct strfdinsert      sfd;
12740 +
12741 +       if (copy_from_user(&sfd, arg, sizeof(sfd)))
12742 +               return -EFAULT;
12743 +
12744 +#if defined(CONFIG_ABI_TRACE)
12745 +       abi_trace(ABI_TRACE_STREAMS,
12746 +                       "%u fdinsert: flags=%ld, fildes=%u, offset=%d\n",
12747 +                       fd, sfd.flags, sfd.fildes, sfd.offset);
12748 +#endif
12749 +#ifdef CONFIG_ABI_XTI
12750 +       return do_putmsg(fd, regs, sfd.ctlbuf.buf, sfd.ctlbuf.len,
12751 +                       sfd.datbuf.buf, sfd.datbuf.len, sfd.fildes);
12752 +#else
12753 +       return -EINVAL;
12754 +#endif
12755 +}
12756 diff -Nur kernel-source-2.6.16.orig/abi/svr4/ulimit.c kernel-source-2.6.16/abi/svr4/ulimit.c
12757 --- kernel-source-2.6.16.orig/abi/svr4/ulimit.c 1970-01-01 10:00:00.000000000 +1000
12758 +++ kernel-source-2.6.16/abi/svr4/ulimit.c      2006-04-27 18:50:24.000000000 +1000
12759 @@ -0,0 +1,155 @@
12760 +/*
12761 + *  Copyright (C) 1993  Joe Portman (baron@hebron.connected.com)
12762 + *      First stab at ulimit
12763 + *
12764 + *  April 9 1994, corrected file size passed to/from setrlimit/getrlimit
12765 + *    -- Graham Adams (gadams@ddrive.demon.co.uk)
12766 + *
12767 + */
12768 +
12769 +#ident "%W% %G%"
12770 +
12771 +#include <linux/module.h>
12772 +#include <linux/errno.h>
12773 +#include <linux/sched.h>
12774 +#include <linux/kernel.h>
12775 +#include <linux/unistd.h>
12776 +#include <linux/fs.h>
12777 +#include <linux/resource.h>
12778 +#include <linux/syscalls.h>
12779 +#include <asm/uaccess.h>
12780 +
12781 +#include <abi/util/trace.h>
12782 +
12783 +
12784 +/*
12785 + * Arguments to ulimit - it's one of the stupid multipled calls...
12786 + */
12787 +#define U_GETFSIZE     (1)               /* get max file size in blocks */
12788 +#define U_SETFSIZE     (2)               /* set max file size in blocks */
12789 +#define U_GETMEMLIM    (3)               /* get process size limit */
12790 +#define U_GETMAXOPEN   (4)               /* get max open files for this process */
12791 +#define U_GTXTOFF              (64)              /* get text offset */
12792 +
12793 +/*
12794 + * Define nominal block size parameters.
12795 + */
12796 +#define ULIM_BLOCKSIZE_BITS   9           /* block size = 512 */
12797 +#define ULIM_MAX_BLOCKSIZE (INT_MAX >> ULIM_BLOCKSIZE_BITS)
12798 +
12799 +
12800 +int
12801 +svr4_ulimit (int cmd, int val)
12802 +{
12803 +       switch (cmd) {
12804 +       case U_GETFSIZE:
12805 +               return (current->signal->rlim[RLIMIT_FSIZE].rlim_cur)
12806 +                >> ULIM_BLOCKSIZE_BITS;
12807 +
12808 +       case U_SETFSIZE:
12809 +               if ((val > ULIM_MAX_BLOCKSIZE) || (val < 0))
12810 +                       return -ERANGE;
12811 +               val <<= ULIM_BLOCKSIZE_BITS;
12812 +               if (val > current->signal->rlim[RLIMIT_FSIZE].rlim_max) {
12813 +                       if (!capable(CAP_SYS_RESOURCE))
12814 +                               return -EPERM;
12815 +                       current->signal->rlim[RLIMIT_FSIZE].rlim_max = val;
12816 +               }
12817 +               current->signal->rlim[RLIMIT_FSIZE].rlim_cur = val;
12818 +               return 0;
12819 +
12820 +       case U_GETMEMLIM:
12821 +               return current->signal->rlim[RLIMIT_DATA].rlim_cur;
12822 +
12823 +       case U_GETMAXOPEN:
12824 +               return current->signal->rlim[RLIMIT_NOFILE].rlim_cur;
12825 +
12826 +       default:
12827 +#if defined(CONFIG_ABI_TRACE)
12828 +               abi_trace(ABI_TRACE_API, "unsupported ulimit call %d\n", cmd);
12829 +#endif
12830 +               return -EINVAL;
12831 +       }
12832 +}
12833 +
12834 +/*
12835 + * getrlimit/setrlimit args.
12836 + */
12837 +#define U_RLIMIT_CPU   0
12838 +#define U_RLIMIT_FSIZE 1
12839 +#define U_RLIMIT_DATA  2
12840 +#define U_RLIMIT_STACK 3
12841 +#define U_RLIMIT_CORE  4
12842 +#define U_RLIMIT_NOFILE        5
12843 +#define U_RLIMIT_AS    6
12844 +
12845 +
12846 +int
12847 +svr4_getrlimit(int cmd, void *val)
12848 +{
12849 +       switch (cmd) {
12850 +       case U_RLIMIT_CPU:
12851 +               cmd = RLIMIT_CPU;
12852 +               break;
12853 +       case U_RLIMIT_FSIZE:
12854 +               cmd = RLIMIT_FSIZE;
12855 +               break;
12856 +       case U_RLIMIT_DATA:
12857 +               cmd = RLIMIT_DATA;
12858 +               break;
12859 +       case U_RLIMIT_STACK:
12860 +               cmd = RLIMIT_STACK;
12861 +               break;
12862 +       case U_RLIMIT_CORE:
12863 +               cmd = RLIMIT_CORE;
12864 +               break;
12865 +       case U_RLIMIT_NOFILE:
12866 +               cmd = RLIMIT_NOFILE;
12867 +               break;
12868 +       case U_RLIMIT_AS:
12869 +               cmd = RLIMIT_AS;
12870 +               break;
12871 +       default:
12872 +               return -EINVAL;
12873 +       }
12874 +
12875 +       return sys_getrlimit(cmd, val);
12876 +}
12877 +
12878 +int
12879 +svr4_setrlimit(int cmd, void *val)
12880 +{
12881 +       switch (cmd) {
12882 +       case U_RLIMIT_CPU:
12883 +               cmd = RLIMIT_CPU;
12884 +               break;
12885 +       case U_RLIMIT_FSIZE:
12886 +               cmd = RLIMIT_FSIZE;
12887 +               break;
12888 +       case U_RLIMIT_DATA:
12889 +               cmd = RLIMIT_DATA;
12890 +               break;
12891 +       case U_RLIMIT_STACK:
12892 +               cmd = RLIMIT_STACK;
12893 +               break;
12894 +       case U_RLIMIT_CORE:
12895 +               cmd = RLIMIT_CORE;
12896 +               break;
12897 +       case U_RLIMIT_NOFILE:
12898 +               cmd = RLIMIT_NOFILE;
12899 +               break;
12900 +       case U_RLIMIT_AS:
12901 +               cmd = RLIMIT_AS;
12902 +               break;
12903 +       default:
12904 +               return -EINVAL;
12905 +       }
12906 +
12907 +       return sys_getrlimit(cmd, val);
12908 +}
12909 +
12910 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
12911 +EXPORT_SYMBOL(svr4_getrlimit);
12912 +EXPORT_SYMBOL(svr4_setrlimit);
12913 +EXPORT_SYMBOL(svr4_ulimit);
12914 +#endif
12915 diff -Nur kernel-source-2.6.16.orig/abi/svr4/utsname.c kernel-source-2.6.16/abi/svr4/utsname.c
12916 --- kernel-source-2.6.16.orig/abi/svr4/utsname.c        1970-01-01 10:00:00.000000000 +1000
12917 +++ kernel-source-2.6.16/abi/svr4/utsname.c     2006-04-27 18:50:24.000000000 +1000
12918 @@ -0,0 +1,99 @@
12919 +/*
12920 + * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
12921 + * Copyright (C) 1994 Eric Youngdale.
12922 + */
12923 +
12924 +#ident "%W% %G%"
12925 +
12926 +#include <linux/mm.h>
12927 +#include <linux/sched.h>
12928 +#include <linux/utsname.h>
12929 +#include <linux/module.h>
12930 +#include <asm/uaccess.h>
12931 +
12932 +
12933 +struct v7_utsname {
12934 +       char sysname[9];
12935 +       char nodename[9];
12936 +       char release[9];
12937 +       char version[9];
12938 +       char machine[9];
12939 +};
12940 +
12941 +#define SVR4_NMLN 257
12942 +struct svr4_utsname {
12943 +       char sysname[SVR4_NMLN];
12944 +       char nodename[SVR4_NMLN];
12945 +       char release[SVR4_NMLN];
12946 +       char version[SVR4_NMLN];
12947 +       char machine[SVR4_NMLN];
12948 +};
12949 +
12950 +// this function and macro design is from arch/sparc64/solaris/misc.c
12951 +static int __set_utsfield(char __user *to, int to_size,
12952 +                       const char *from, int from_size,
12953 +                       int dotchop)
12954 +{
12955 +       int len = min(from_size, to_size);
12956 +       int off;
12957 +
12958 +       if (copy_to_user(to, from, len))
12959 +               return -EFAULT;
12960 +
12961 +       off = len < to_size? len: len - 1;
12962 +       if (dotchop) {
12963 +               const char *p = strnchr(from, len, '.');
12964 +               if (p) off =  p - from;
12965 +       }
12966 +
12967 +       if (__put_user('\0', to + off))
12968 +               return -EFAULT;
12969 +
12970 +       return 0;
12971 +}
12972 +
12973 +#define set_utsfield(to, from, dotchop) \
12974 +       __set_utsfield((to), sizeof(to), \
12975 +               (from), sizeof(from), \
12976 +               (dotchop))
12977 +
12978 +int v7_utsname(unsigned long addr)
12979 +{
12980 +       int error = 0;
12981 +       struct v7_utsname *it = (struct v7_utsname *)addr;
12982 +
12983 +       down_read(&uts_sem);
12984 +       if (access_ok(VERIFY_WRITE, it, sizeof (struct v7_utsname))) {
12985 +               error |= set_utsfield(it->sysname, system_utsname.nodename, 1);
12986 +               error |= set_utsfield(it->nodename, system_utsname.nodename, 1);
12987 +               error |= set_utsfield(it->release, system_utsname.release, 0);
12988 +               error |= set_utsfield(it->version, system_utsname.version, 0);
12989 +               error |= set_utsfield(it->machine, system_utsname.machine, 0);
12990 +       }
12991 +       up_read(&uts_sem);
12992 +
12993 +       return error;
12994 +}
12995 +
12996 +int abi_utsname(unsigned long addr)
12997 +{
12998 +       int error = 0;
12999 +       struct svr4_utsname *it = (struct svr4_utsname *)addr;
13000 +
13001 +       down_read(&uts_sem);
13002 +       if (access_ok(VERIFY_WRITE, it, sizeof (struct svr4_utsname))) {
13003 +               error |= set_utsfield(it->sysname, system_utsname.sysname, 0);
13004 +               error |= set_utsfield(it->nodename, system_utsname.nodename, 0);
13005 +               error |= set_utsfield(it->release, system_utsname.release, 0);
13006 +               error |= set_utsfield(it->version, system_utsname.version, 0);
13007 +               error |= set_utsfield(it->machine, system_utsname.machine, 0);
13008 +       }
13009 +       up_read(&uts_sem);
13010 +
13011 +       return error;
13012 +}
13013 +
13014 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
13015 +EXPORT_SYMBOL(abi_utsname);
13016 +EXPORT_SYMBOL(v7_utsname);
13017 +#endif
13018 diff -Nur kernel-source-2.6.16.orig/abi/svr4/xti.c kernel-source-2.6.16/abi/svr4/xti.c
13019 --- kernel-source-2.6.16.orig/abi/svr4/xti.c    1970-01-01 10:00:00.000000000 +1000
13020 +++ kernel-source-2.6.16/abi/svr4/xti.c 2006-04-27 18:50:24.000000000 +1000
13021 @@ -0,0 +1,1571 @@
13022 +/*
13023 + * Copyright 1995, 1996  Mike Jagdis (jaggy@purplet.demon.co.uk)
13024 + */
13025 +
13026 +#ident "%W% %G%"
13027 +
13028 +#include <linux/config.h>
13029 +#include <linux/types.h>
13030 +#include <linux/errno.h>
13031 +#include <linux/fs.h>
13032 +#include <linux/ptrace.h>
13033 +#include <linux/sched.h>
13034 +#include <linux/kernel.h>
13035 +#include <linux/slab.h>
13036 +#include <linux/mm.h>
13037 +#include <linux/fcntl.h>
13038 +#include <linux/socket.h>
13039 +#include <linux/in.h>
13040 +#include <linux/un.h>
13041 +#include <linux/file.h>
13042 +#include <linux/personality.h>
13043 +#include <linux/poll.h>
13044 +#include <linux/syscalls.h>
13045 +#include <asm/uaccess.h>
13046 +
13047 +#include <net/sock.h>
13048 +
13049 +#include <abi/stream.h>
13050 +#include <abi/tli.h>
13051 +
13052 +#include <abi/socksys.h> /* for socksys_fdinit */
13053 +
13054 +#include <abi/svr4/sockio.h>
13055 +#include <abi/util/trace.h>
13056 +#include <abi/util/errno.h>
13057 +
13058 +
13059 +/*
13060 + * This is because TLI and XTI options buffers are incompatible and there
13061 + * is no clear way to detect which format we are dealing with here.
13062 + * Existing systems appear to have TLI options management implemented
13063 + * but return TNOTSUPPORT for XTI requests.
13064 + */
13065 +#if defined(CONFIG_ABI_XTI_OPTMGMT) && defined(CONFIG_ABI_TLI_OPTMGMT)
13066 +# error "unable to support _both_ TLI and XTI option management"
13067 +#endif
13068 +
13069 +
13070 +#if defined(CONFIG_ABI_TRACE)
13071 +static char *const xti_tab[] = {
13072 +       "T_CONN_REQ", "T_CONN_RES",
13073 +       "T_DISCON_REQ", "T_DATA_REQ",
13074 +       "T_EXDATA_REQ", "T_INFO_REQ",
13075 +       "T_BIND_REQ", "T_UNBIND_REQ",
13076 +       "T_UNITDATA_REQ", "T_OPTMGMT_REQ",
13077 +       "T_ORDREL_REQ","T_CONN_IND",
13078 +       "T_CONN_CON", "T_DISCON_IND",
13079 +       "T_DATA_IND", "T_EXDATA_IND",
13080 +       "T_INFO_ACK", "T_BIND_ACK",
13081 +       "T_ERROR_ACK","T_OK_ACK",
13082 +       "T_UNITDATA_IND", "T_UDERROR_IND",
13083 +       "T_OPTMGMT_ACK", "T_ORDREL_IND"
13084 +};
13085 +static char xti_unknown[] = "<unknown>";
13086 +
13087 +static char *
13088 +xti_prim(int n)
13089 +{
13090 +       if (n < 0 || n >= ARRAY_SIZE(xti_tab))
13091 +               return xti_unknown;
13092 +       return xti_tab[n];
13093 +}
13094 +#endif
13095 +
13096 +
13097 +#define timod_mkctl(len) kmalloc(sizeof(struct T_primsg)-sizeof(long)+len, \
13098 +                                       GFP_KERNEL)
13099 +
13100 +
13101 +static void
13102 +timod_socket_wakeup(struct file *fp)
13103 +{
13104 +       struct socket           *sock;
13105 +
13106 +       sock = SOCKET_I(fp->f_dentry->d_inode);
13107 +       wake_up_interruptible(&sock->wait);
13108 +
13109 +       read_lock(&sock->sk->sk_callback_lock);
13110 +       if (sock->fasync_list && !test_bit(SOCK_ASYNC_WAITDATA, &sock->flags))
13111 +               __kill_fasync(sock->fasync_list, SIGIO, POLL_IN);
13112 +       read_unlock(&sock->sk->sk_callback_lock);
13113 +}
13114 +
13115 +
13116 +static void
13117 +timod_ok(int fd, int prim)
13118 +{
13119 +       struct file             *fp;
13120 +       struct T_primsg         *it;
13121 +       struct T_ok_ack         *ok;
13122 +
13123 +#if defined(CONFIG_ABI_TRACE)
13124 +       abi_trace(ABI_TRACE_STREAMS, "TI: %u ok ack prim=%d\n", fd, prim);
13125 +#endif
13126 +
13127 +       fp = fcheck(fd);
13128 +       it = timod_mkctl(sizeof(struct T_ok_ack));
13129 +       if (!it)
13130 +               return;
13131 +
13132 +       ok = (struct T_ok_ack *)&it->type;
13133 +       ok->PRIM_type = T_OK_ACK;
13134 +       ok->CORRECT_prim = prim;
13135 +
13136 +       it->pri = MSG_HIPRI;
13137 +       it->length = sizeof(struct T_ok_ack);
13138 +       it->next = Priv(fp)->pfirst;
13139 +
13140 +       Priv(fp)->pfirst = it;
13141 +       if (!Priv(fp)->plast)
13142 +               Priv(fp)->plast = it;
13143 +       timod_socket_wakeup(fp);
13144 +}
13145 +
13146 +static void
13147 +timod_error(int fd, int prim, int terr, int uerr)
13148 +{
13149 +       struct file             *fp;
13150 +       struct T_primsg         *it;
13151 +       struct T_error_ack      *err;
13152 +
13153 +#if defined(CONFIG_ABI_TRACE)
13154 +       abi_trace(ABI_TRACE_STREAMS, "TI: %u error prim=%d, TLI=%d, UNIX=%d\n",
13155 +                       fd, prim, terr, uerr);
13156 +#endif
13157 +
13158 +       fp = fcheck(fd);
13159 +       it = timod_mkctl(sizeof(struct T_error_ack));
13160 +       if (!it)
13161 +               return;
13162 +
13163 +       err = (struct T_error_ack *)&it->type;
13164 +       err->PRIM_type = T_ERROR_ACK;
13165 +       err->ERROR_prim = prim;
13166 +       err->TLI_error = terr;
13167 +       err->UNIX_error = iABI_errors(uerr);
13168 +
13169 +       it->pri = MSG_HIPRI;
13170 +       it->length = sizeof(struct T_error_ack);
13171 +       it->next = Priv(fp)->pfirst;
13172 +
13173 +       Priv(fp)->pfirst = it;
13174 +       if (!Priv(fp)->plast)
13175 +               Priv(fp)->plast = it;
13176 +       timod_socket_wakeup(fp);
13177 +}
13178 +
13179 +
13180 +#if defined(CONFIG_ABI_XTI_OPTMGMT) || defined(CONFIG_ABI_TLI_OPTMGMT)
13181 +/*
13182 + * XXX: this function is a _horrible_ mess.
13183 + */
13184 +static int
13185 +timod_optmgmt(int fd, struct pt_regs * regs, int flag,
13186 +             char * opt_buf, int opt_len, int do_ret)
13187 +{
13188 +       struct file * fp = fcheck(fd);
13189 +       char *ret_buf, *ret_base;
13190 +       u_long old_esp, *tsp;
13191 +       int is_tli, error, failed;
13192 +       int ret_len, ret_space;
13193 +
13194 +       if (opt_buf && opt_len > 0) {
13195 +               if (!access_ok(VERIFY_READ, opt_buf, opt_len))
13196 +                       return -EFAULT;
13197 +       }
13198 +
13199 +       /*
13200 +        * FIXME:
13201 +        *   We should be able to detect the difference between
13202 +        *   TLI and XTI requests at run time?
13203 +        */
13204 +       is_tli = CONFIG_ABI_TLI_OPTMGMT;
13205 +
13206 +       if (!do_ret && (!opt_buf || opt_len <= 0))
13207 +               return 0;
13208 +
13209 +       /*
13210 +        * Grab some space on the user stack to work with. We need 6 longs
13211 +        * to build an argument frame for [gs]etsockopt calls. We also
13212 +        * need space to build the return buffer. This will be at least
13213 +        * as big as the given options buffer but the given options
13214 +        * buffer may not include space for option values so we allow two
13215 +        * longs for each option multiple of the option header size
13216 +        * and hope that big options will not exhaust our space and
13217 +        * trash the stack.
13218 +        */
13219 +       ret_space = 1024 + opt_len
13220 +               + 2*sizeof(long)*(opt_len / (is_tli ? sizeof(struct opthdr) : sizeof(struct t_opthdr)));
13221 +       ret_buf = ret_base = (char *)(regs->esp - ret_space);
13222 +       ret_len = 0;
13223 +
13224 +       old_esp = regs->esp;
13225 +       regs->esp -= ret_space + 6*sizeof(long);
13226 +       tsp = (unsigned long *)(regs->esp);
13227 +       if (!access_ok(VERIFY_WRITE, tsp, 6*sizeof(long))) {
13228 +               regs->esp = old_esp;
13229 +               return -EFAULT;
13230 +       }
13231 +
13232 +       failed = 0;
13233 +
13234 +#ifndef CONFIG_ABI_TLI_OPTMGMT
13235 +       if (is_tli) {
13236 +               printk(KERN_WARNING
13237 +                       "%d iBCS: TLI optmgmt requested but not supported\n",
13238 +                       current->pid);
13239 +       }
13240 +#else
13241 +       if (is_tli)
13242 +               while (opt_len >= sizeof(struct opthdr)) {
13243 +               struct opthdr opt;
13244 +
13245 +#if defined(CONFIG_ABI_TRACE)
13246 +               abi_trace(ABI_TRACE_STREAMS, "TLI optmgmt opt_len=%d, "
13247 +                               "ret_buf=0x%08lx, ret_len=%d, ret_space=%d\n",
13248 +                               opt_len, (unsigned long)ret_buf,
13249 +                               ret_len, ret_space);
13250 +#endif
13251 +
13252 +               if (copy_from_user(&opt, opt_buf, sizeof(struct opthdr)))
13253 +                       return -EFAULT;
13254 +
13255 +               /* Idiot check... */
13256 +               if (opt.len > opt_len) {
13257 +                       failed = TBADOPT;
13258 +                       break;
13259 +               }
13260 +
13261 +               if (abi_traced(ABI_TRACE_STREAMS)) {
13262 +                       unsigned long v;
13263 +                       get_user(v, (unsigned long *)(opt_buf+sizeof(struct opthdr)));
13264 +#if defined(CONFIG_ABI_TRACE)
13265 +                       __abi_trace("TLI optmgmt fd=%d, level=%ld, "
13266 +                                       "name=%ld, value=%ld\n",
13267 +                                       fd, opt.level, opt.name, v);
13268 +#endif
13269 +               }
13270 +
13271 +               /* Check writable space in the return buffer. */
13272 +               if (!access_ok(VERIFY_WRITE, ret_buf, sizeof(struct opthdr))) {
13273 +                       failed = TSYSERR;
13274 +                       break;
13275 +               }
13276 +
13277 +               /* Flag values:
13278 +                * T_NEGOTIATE means try and set it.
13279 +                * T_DEFAULT means get the default value.
13280 +                *           (return the current for now)
13281 +                * T_CHECK means get the current value.
13282 +                */
13283 +               error = 0;
13284 +               if (flag == T_NEGOTIATE) {
13285 +                       put_user(fd, tsp);
13286 +                       put_user(opt.level, tsp+1);
13287 +                       put_user(opt.name, tsp+2);
13288 +                       put_user((int)(opt_buf+sizeof(struct opthdr)), tsp+3);
13289 +                       put_user(opt.len, tsp+4);
13290 +                       error = abi_do_setsockopt(tsp);
13291 +
13292 +                       if (error) {
13293 +#if defined(CONFIG_ABI_TRACE)
13294 +                               abi_trace(ABI_TRACE_STREAMS,
13295 +                                       "setsockopt failed: %d\n", error);
13296 +#endif
13297 +                               failed = TBADOPT;
13298 +                               break;
13299 +                       }
13300 +               }
13301 +               if (!error) {
13302 +                       int len;
13303 +
13304 +                       put_user(fd, tsp);
13305 +                       put_user(opt.level, tsp+1);
13306 +                       put_user(opt.name, tsp+2);
13307 +                       put_user((int)(ret_buf+sizeof(struct opthdr)), tsp+3);
13308 +                       put_user((int)(tsp+5), tsp+4);
13309 +                       put_user(ret_space, tsp+5);
13310 +                       error = abi_do_getsockopt(tsp);
13311 +
13312 +                       if (error) {
13313 +#if defined(CONFIG_ABI_TRACE)
13314 +                               abi_trace(ABI_TRACE_STREAMS,
13315 +                                       "getsockopt failed: %d\n", error);
13316 +#endif
13317 +                               failed = TBADOPT;
13318 +                               break;
13319 +                       }
13320 +
13321 +                       get_user(len, tsp+5);
13322 +                       if (copy_to_user(ret_buf, &opt, sizeof(opt)))
13323 +                               return -EFAULT;
13324 +                       put_user(len,
13325 +                               &((struct opthdr *)opt_buf)->len);
13326 +                       ret_space -= sizeof(struct opthdr) + len;
13327 +                       ret_len += sizeof(struct opthdr) + len;
13328 +                       ret_buf += sizeof(struct opthdr) + len;
13329 +               }
13330 +
13331 +               opt_len -= sizeof(struct opthdr) + opt.len;
13332 +               opt_buf += sizeof(struct opthdr) + opt.len;
13333 +       }
13334 +#endif /* CONFIG_ABI_TLI_OPTMGMT */
13335 +#ifndef CONFIG_ABI_XTI_OPTMGMT
13336 +       else {
13337 +               printk(KERN_WARNING
13338 +                       "%d iBCS: XTI optmgmt requested but not supported\n",
13339 +                       current->pid);
13340 +       }
13341 +#else
13342 +       else while (opt_len >= sizeof(struct t_opthdr)) {
13343 +               struct t_opthdr opt;
13344 +
13345 +               if (copy_from_user(&opt, opt_buf, sizeof(struct t_opthdr)))
13346 +                       return -EFAULT;
13347 +               if (opt.len > opt_len) {
13348 +                       failed = 1;
13349 +                       break;
13350 +               }
13351 +
13352 +               if (abi_traced(ABI_TRACE_STREAMS)) {
13353 +                       unsigned long v;
13354 +                       get_user(v, (unsigned long *)(opt_buf+sizeof(struct t_opthdr)));
13355 +#if defined(CONFIG_ABI_TRACE)
13356 +                       __abi_trace("XTI optmgmt fd=%d, level=%ld, "
13357 +                                       "name=%ld, value=%ld\n",
13358 +                                       fd, opt.level, opt.name, v);
13359 +#endif
13360 +               }
13361 +
13362 +               /* Check writable space in the return buffer. */
13363 +               if (!access_ok(VERIFY_WRITE, ret_buf, sizeof(struct t_opthdr))) {
13364 +                       failed = 1;
13365 +                       break;
13366 +               }
13367 +
13368 +               /* Flag values:
13369 +                * T_NEGOTIATE means try and set it.
13370 +                * T_CHECK means see if we could set it.
13371 +                *         (so we just set it for now)
13372 +                * T_DEFAULT means get the default value.
13373 +                *           (return the current for now)
13374 +                * T_CURRENT means get the current value (SCO xti.h has
13375 +                * no T_CURRENT???).
13376 +                */
13377 +               error = 0;
13378 +               if (flag == T_NEGOTIATE || flag == T_CHECK) {
13379 +                       put_user(fd, tsp);
13380 +                       put_user(opt.level, tsp+1);
13381 +                       put_user(opt.name, tsp+2);
13382 +                       put_user((int)(opt_buf+sizeof(struct t_opthdr)), tsp+3);
13383 +                       put_user(opt.len-sizeof(struct t_opthdr), tsp+4);
13384 +                       error = abi_do_setsockopt(tsp);
13385 +               }
13386 +               if (!error) {
13387 +                       put_user(fd, tsp);
13388 +                       put_user(opt.level, tsp+1);
13389 +                       put_user(opt.name, tsp+2);
13390 +                       put_user((int)(ret_buf+sizeof(struct t_opthdr)), tsp+3);
13391 +                       put_user((int)(tsp+5), tsp+4);
13392 +                       put_user(ret_space, tsp+5);
13393 +                       error = abi_do_getsockopt(tsp);
13394 +                       if (!error) {
13395 +                               int len;
13396 +                               get_user(len, tsp+5);
13397 +                               /* FIXME: opt.status should be set... */
13398 +                               if (copy_to_user(ret_buf, &opt, sizeof(opt)))
13399 +                                       return -EFAULT;
13400 +                               put_user(len+sizeof(struct t_opthdr),
13401 +                                       &((struct t_opthdr *)opt_buf)->len);
13402 +                               ret_space -= sizeof(struct t_opthdr) + len;
13403 +                               ret_len += sizeof(struct t_opthdr) + len;
13404 +                               ret_buf += sizeof(struct t_opthdr) + len;
13405 +                       }
13406 +               }
13407 +
13408 +               failed |= error;
13409 +               opt_len -= opt.len;
13410 +               opt_buf += opt.len;
13411 +       }
13412 +#endif /* CONFIG_ABI_XTI_OPTMGMT */
13413 +
13414 +#if 0
13415 +       /* If there is left over data the supplied options buffer was
13416 +        * formatted incorrectly. But we might have done some work so
13417 +        * we must fall through and return an acknowledgement I think.
13418 +        */
13419 +       if (opt_len) {
13420 +               regs->esp = old_esp;
13421 +               return -EINVAL;
13422 +       }
13423 +#endif
13424 +
13425 +       if (do_ret) {
13426 +               struct T_primsg *it;
13427 +
13428 +               if (failed) {
13429 +                       timod_error(fd, T_OPTMGMT_REQ, failed, -error);
13430 +                       regs->esp = old_esp;
13431 +                       return 0;
13432 +               }
13433 +
13434 +#if defined(CONFIG_ABI_TRACE)
13435 +               abi_trace(ABI_TRACE_STREAMS,
13436 +                       "optmgmt returns %d bytes, failed=%d\n",
13437 +                       ret_len, failed);
13438 +#endif
13439 +
13440 +               /* Convert the return buffer in the user stack to a
13441 +                * T_OPTMGMT_ACK
13442 +                * message and queue it.
13443 +                */
13444 +               it = timod_mkctl(sizeof(struct T_optmgmt_ack) + ret_len);
13445 +               if (it) {
13446 +                       struct T_optmgmt_ack *ack
13447 +                               = (struct T_optmgmt_ack *)&it->type;
13448 +                       ack->PRIM_type = T_OPTMGMT_ACK;
13449 +                       ack->OPT_length = ret_len;
13450 +                       ack->OPT_offset = sizeof(struct T_optmgmt_ack);
13451 +                       ack->MGMT_flags = (failed ? T_FAILURE : flag);
13452 +                       if (copy_from_user(((char *)ack)+sizeof(struct T_optmgmt_ack),
13453 +                               ret_base, ret_len))
13454 +                               return -EFAULT;
13455 +                       it->pri = MSG_HIPRI;
13456 +                       it->length = sizeof(struct T_optmgmt_ack) + ret_len;
13457 +                       it->next = Priv(fp)->pfirst;
13458 +                       Priv(fp)->pfirst = it;
13459 +                       if (!Priv(fp)->plast)
13460 +                               Priv(fp)->plast = it;
13461 +                       timod_socket_wakeup(fp);
13462 +               }
13463 +       }
13464 +
13465 +       regs->esp = old_esp;
13466 +       return 0;
13467 +}
13468 +
13469 +#else /* no CONFIG_ABI_XTI_OPTMGMT or CONFIG_ABI_TLI_OPTMGMT */
13470 +
13471 +static int
13472 +timod_optmgmt(int fd, struct pt_regs * regs, int flag,
13473 +             char * opt_buf, int opt_len, int do_ret)
13474 +{
13475 +       return -EINVAL;
13476 +}
13477 +
13478 +#endif /* CONFIG_ABI_XTI_OPTMGMT or CONFIG_ABI_TLI_OPTMGMT */
13479 +
13480 +#define T_PRIV(fp)     Priv(fp)
13481 +
13482 +int
13483 +timod_update_socket(int fd, struct file * fp, struct pt_regs * regs)
13484 +{
13485 +       struct socket * sock;
13486 +       struct T_private * priv;
13487 +       struct T_primsg * it;
13488 +       struct T_conn_ind * ind;
13489 +       u_long old_esp, * tsp, alen;
13490 +       u_short oldflags;
13491 +       int error = 0;
13492 +
13493 +       sock = SOCKET_I(fp->f_dentry->d_inode);
13494 +       priv = T_PRIV(fp);
13495 +
13496 +       /*
13497 +        * If this a SOCK_STREAM and is in the TS_WRES_CIND state
13498 +        * we are supposed to be looking for an incoming connection.
13499 +        */
13500 +       if (sock->type != SOCK_STREAM || priv->state != TS_WRES_CIND)
13501 +               goto out;
13502 +
13503 +       old_esp = regs->esp;
13504 +       regs->esp -= 1024;
13505 +       tsp = (unsigned long *)regs->esp;
13506 +       if (!access_ok(VERIFY_WRITE, tsp,
13507 +                       3*sizeof(long)+sizeof(struct sockaddr))) {
13508 +               regs->esp = old_esp;
13509 +               error = -EFAULT;
13510 +               goto out;
13511 +       }
13512 +
13513 +       put_user(fd, tsp);
13514 +       put_user((unsigned long)(tsp+4), tsp+1);
13515 +       put_user((unsigned long)(tsp+3), tsp+2);
13516 +       put_user(sizeof(struct sockaddr), tsp+3);
13517 +
13518 +       /*
13519 +        * We don't want to block in the accept(). Any
13520 +        * blocking necessary must be handled earlier.
13521 +        */
13522 +       oldflags = fp->f_flags;
13523 +       fp->f_flags |= O_NONBLOCK;
13524 +       error = sys_socketcall(SYS_ACCEPT, tsp);
13525 +       fp->f_flags = oldflags;
13526 +
13527 +       if (error < 0)
13528 +               goto out_set;
13529 +
13530 +       /* The new fd needs to be fixed up
13531 +        * with the iBCS file functions and a
13532 +        * timod state block.
13533 +        */
13534 +       inherit_socksys_funcs(error, TS_DATA_XFER);
13535 +
13536 +       /* Generate a T_CONN_IND and queue it. */
13537 +       get_user(alen, tsp+3);
13538 +       it = timod_mkctl(sizeof(struct T_conn_ind) + alen);
13539 +       if (!it) {
13540 +               /* Oops, just drop the connection I guess. */
13541 +               sys_close(error);
13542 +               goto out_set;
13543 +       }
13544 +
13545 +       ind = (struct T_conn_ind *)&it->type;
13546 +       ind->PRIM_type = T_CONN_IND;
13547 +       ind->SRC_length = alen;
13548 +       ind->SRC_offset = sizeof(struct T_conn_ind);
13549 +       ind->OPT_length = ind->OPT_offset = 0;
13550 +       ind->SEQ_number = error;
13551 +
13552 +       if (copy_from_user(((char *)ind)+sizeof(struct T_conn_ind), tsp+4, alen))
13553 +               return -EFAULT;
13554 +#if 0
13555 +       it->pri = MSG_HIPRI;
13556 +#endif
13557 +       it->length = sizeof(struct T_conn_ind) + alen;
13558 +       it->next = Priv(fp)->pfirst;
13559 +       Priv(fp)->pfirst = it;
13560 +       if (!Priv(fp)->plast)
13561 +               Priv(fp)->plast = it;
13562 +       timod_socket_wakeup(fp);
13563 +
13564 +out_set:
13565 +       regs->esp = old_esp;
13566 +out:
13567 +       return (error);
13568 +}
13569 +
13570 +
13571 +int
13572 +do_getmsg(int fd, struct pt_regs *regs, char *ctl_buf,
13573 +         int ctl_maxlen, int *ctl_len, char *dat_buf,
13574 +         int dat_maxlen, int *dat_len, int *flags_p)
13575 +{
13576 +       int error;
13577 +       long old_esp;
13578 +       unsigned long *tsp;
13579 +       unsigned short oldflags;
13580 +       struct T_unitdata_ind udi;
13581 +       struct file *filep;
13582 +
13583 +       /*
13584 +        * It may not be obvious but we are always holding an fget(fd)
13585 +        * at this point so we can use fcheck(fd) rather than fget...fput.
13586 +        */
13587 +       filep = fcheck(fd);
13588 +
13589 +       if (!Priv(filep) && Priv(filep)->magic != XTI_MAGIC) {
13590 +               printk("putmsg on non-STREAMS fd %d by %s\n",fd, current->comm);
13591 +               return -EINVAL;
13592 +       }
13593 +
13594 +#if defined(CONFIG_ABI_TRACE)
13595 +       abi_trace(ABI_TRACE_STREAMS,
13596 +                       "getmsg %d, 0x%lx[%d], 0x%lx[%d], %x\n",
13597 +                       fd, (u_long)ctl_buf, ctl_maxlen,
13598 +                       (u_long)dat_buf, dat_maxlen, *flags_p);
13599 +#endif
13600 +
13601 +       /*
13602 +        * We need some user space to build syscall argument vectors
13603 +        * later. Set it up now and page it in if necessary. This will
13604 +        * avoid (most?) potential blocking after the select().
13605 +        */
13606 +       old_esp = regs->esp;
13607 +       regs->esp -= 1024;
13608 +       tsp = (unsigned long *)regs->esp;
13609 +       regs->esp = old_esp;
13610 +       if (!access_ok(VERIFY_WRITE, tsp, 6*sizeof(long)))
13611 +               return -EFAULT;
13612 +
13613 +       /*
13614 +        * If the TEP is not non-blocking we must test for
13615 +        * something to do. We don't necessarily know what order
13616 +        * events will be happening on the socket so we have to
13617 +        * watch for evrything at once.
13618 +        * N.B. If we weren't asked for data we should only be looking
13619 +        * for connection requests. There are socket type issues to
13620 +        * consider here.
13621 +        */
13622 +       if (!(filep->f_flags & O_NONBLOCK)) {
13623 +                struct poll_wqueues wait_queue;
13624 +               poll_table *wait;
13625 +               unsigned long mask = (POLLIN | POLLRDNORM | POLLHUP | POLLERR);
13626 +
13627 +               if (*flags_p == MSG_HIPRI)
13628 +                       mask |= POLLPRI;
13629 +
13630 +               poll_initwait(&wait_queue);
13631 +               wait = &wait_queue.pt;
13632 +
13633 +               /*
13634 +                * N.B. We need to be sure to recheck after a schedule()
13635 +                * so that when we proceed it is because there is
13636 +                * something to do and nothing else can get there
13637 +                * before us.
13638 +                */
13639 +               while (!(filep->f_op->poll(filep, wait) & mask)
13640 +                               && !signal_pending(current)) {
13641 +                       current->state = TASK_INTERRUPTIBLE;
13642 +                       wait = NULL;
13643 +                       schedule();
13644 +               }
13645 +
13646 +               current->state = TASK_RUNNING;
13647 +               poll_freewait(&wait_queue);
13648 +
13649 +               if (signal_pending(current))
13650 +                       return -EINTR;
13651 +       }
13652 +
13653 +       if (ctl_maxlen >= 0 && !Priv(filep)->pfirst)
13654 +               timod_update_socket(fd, filep, regs);
13655 +
13656 +       /*
13657 +        * If we were asked for a control part and there is an outstanding
13658 +        * message queued as a result of some other operation we'll
13659 +        * return that.
13660 +        */
13661 +       if (ctl_maxlen >= 0 && Priv(filep)->pfirst) {
13662 +               int l = ctl_maxlen <= Priv(filep)->pfirst->length
13663 +                               ? ctl_maxlen : Priv(filep)->pfirst->length;
13664 +               if (!access_ok(VERIFY_WRITE, ctl_buf, l))
13665 +                       return -EFAULT;
13666 +
13667 +#if defined(CONFIG_ABI_TRACE)
13668 +               abi_trace(ABI_TRACE_STREAMS,
13669 +                       "priority message %ld %s\n",
13670 +                       Priv(filep)->pfirst->type,
13671 +                       xti_prim(Priv(filep)->pfirst->type));
13672 +#endif
13673 +
13674 +               if (copy_to_user(ctl_buf, ((char *)&Priv(filep)->pfirst->type)
13675 +                                       + Priv(filep)->offset, l))
13676 +                       return -EFAULT;
13677 +               put_user(l, ctl_len);
13678 +               if (dat_maxlen >= 0)
13679 +                       put_user(0, dat_len);
13680 +               *flags_p = Priv(filep)->pfirst->pri;
13681 +               Priv(filep)->pfirst->length -= l;
13682 +
13683 +#if defined(CONFIG_ABI_TRACE)
13684 +               if (abi_traced(ABI_TRACE_STREAMS) && ctl_buf && l > 0) {
13685 +                       int i = -1;
13686 +
13687 +                       for (i = 0; i < l && i < 64; i += 4) {
13688 +                               u_long v;
13689 +
13690 +                               get_user(v, (u_long *)(ctl_buf + i));
13691 +                               __abi_trace("ctl: 0x%08lx\n", v);
13692 +                       }
13693 +                       if (i != l)
13694 +                               __abi_trace("ctl: ...\n");
13695 +               }
13696 +#endif
13697 +
13698 +               if (Priv(filep)->pfirst->length) {
13699 +                       Priv(filep)->offset += l;
13700 +
13701 +#if defined(CONFIG_ABI_TRACE)
13702 +                       abi_trace(ABI_TRACE_STREAMS,
13703 +                                       "MORECTL %d bytes",
13704 +                                       Priv(filep)->pfirst->length);
13705 +#endif
13706 +                       return MORECTL;
13707 +               } else {
13708 +                       struct T_primsg *it = Priv(filep)->pfirst;
13709 +                       Priv(filep)->pfirst = it->next;
13710 +                       if (!Priv(filep)->pfirst)
13711 +                               Priv(filep)->plast = NULL;
13712 +                       kfree(it);
13713 +                       Priv(filep)->offset = 0;
13714 +                       return 0;
13715 +               }
13716 +       }
13717 +
13718 +       *flags_p = 0;
13719 +
13720 +       /* If we weren't asked for data there is nothing more to do. */
13721 +       if (dat_maxlen <= 0) {
13722 +               if (dat_maxlen == 0)
13723 +                       put_user(0, dat_len);
13724 +               if (ctl_maxlen >= 0)
13725 +                       put_user(0, ctl_len);
13726 +               return -EAGAIN;
13727 +       }
13728 +
13729 +       /* If the select() slept we may have had our temp space paged
13730 +        * out. The re-verify_area is only really needed for pre-486
13731 +        * chips which don't handle write faults from kernel mode.
13732 +        */
13733 +       regs->esp = (unsigned long)tsp;
13734 +       if (!access_ok(VERIFY_WRITE, tsp, 6*sizeof(long))) {
13735 +               regs->esp = old_esp;
13736 +               return -EFAULT;
13737 +       }
13738 +       put_user(fd, tsp);
13739 +       put_user((unsigned long)dat_buf, tsp+1);
13740 +       put_user((dat_maxlen < 0 ? 0 : dat_maxlen), tsp+2);
13741 +       put_user(0, tsp+3);
13742 +       if (ctl_maxlen > (int)sizeof(udi) && Priv(filep)->state == TS_IDLE) {
13743 +               put_user((unsigned long)ctl_buf+sizeof(udi), tsp+4);
13744 +               put_user(ctl_maxlen-sizeof(udi), ctl_len);
13745 +               put_user((int)ctl_len, tsp+5);
13746 +       } else {
13747 +               put_user(0, tsp+4);
13748 +               put_user(0, ctl_len);
13749 +               put_user((int)ctl_len, tsp+5);
13750 +       }
13751 +
13752 +       /* We don't want to block in the recvfrom(). Any blocking is
13753 +        * handled by the select stuff above.
13754 +        */
13755 +       oldflags = filep->f_flags;
13756 +       filep->f_flags |= O_NONBLOCK;
13757 +       error = sys_socketcall(SYS_RECVFROM, tsp);
13758 +       filep->f_flags = oldflags;
13759 +
13760 +       regs->esp = old_esp;
13761 +       if (error < 0)
13762 +               return error;
13763 +       if (error
13764 +       && ctl_maxlen > (int)sizeof(udi)
13765 +       && Priv(filep)->state == TS_IDLE) {
13766 +               udi.PRIM_type = T_UNITDATA_IND;
13767 +               get_user(udi.SRC_length, ctl_len);
13768 +               udi.SRC_offset = sizeof(udi);
13769 +               udi.OPT_length = udi.OPT_offset = 0;
13770 +               if (copy_to_user(ctl_buf, &udi, (int)sizeof(udi)))
13771 +                       return -EFAULT;
13772 +               put_user(sizeof(udi)+udi.SRC_length, ctl_len);
13773 +#if 0
13774 +#if defined(CONFIG_ABI_TRACE)
13775 +               if (abi_traced(ABI_TRACE_STREAMS) &&
13776 +                   ctl_buf && udi.SRC_length > 0) {
13777 +                       char * buf = ctl_buf + sizeof(udi);
13778 +                       int i = -1;
13779 +
13780 +                       for (i = 0; i < udi.SRC_length &&
13781 +                            i < 64; i += 4) {
13782 +                               u_long v;
13783 +
13784 +                               get_user(v, (u_long *)(buf+i));
13785 +                               __abi_trace("dat: 0x%08lx\n", v);
13786 +                       }
13787 +                       if (i != udi.SRC_length)
13788 +                               __abi_trace("dat: ...\n");
13789 +               }
13790 +#endif
13791 +#endif
13792 +       } else {
13793 +               put_user(0, ctl_len);
13794 +       }
13795 +       put_user(error, dat_len);
13796 +
13797 +       return 0;
13798 +}
13799 +
13800 +
13801 +int
13802 +do_putmsg(int fd, struct pt_regs *regs, char *ctl_buf, int ctl_len,
13803 +       char *dat_buf, int dat_len, int flags)
13804 +{
13805 +       struct file *filep;
13806 +       int error, terror;
13807 +       unsigned long cmd;
13808 +
13809 +       /* It may not be obvious but we are always holding an fget(fd)
13810 +        * at this point so we can use fcheck(fd) rather than fget...fput.
13811 +        */
13812 +       filep = fcheck(fd);
13813 +
13814 +       if (!Priv(filep) && Priv(filep)->magic != XTI_MAGIC) {
13815 +               printk("putmsg on non-STREAMS fd %d by %s\n",fd, current->comm);
13816 +               return -EINVAL;
13817 +       }
13818 +
13819 +#if defined(CONFIG_ABI_TRACE)
13820 +       if (abi_traced(ABI_TRACE_STREAMS)) {
13821 +               u_long v;
13822 +               __abi_trace("putmsg %d, 0x%lx[%d], 0x%lx[%d], %x\n",
13823 +                       fd, (u_long)ctl_buf, ctl_len,
13824 +                       (u_long)dat_buf, dat_len, flags);
13825 +
13826 +               get_user(v, ctl_buf);
13827 +               __abi_trace("putmsg prim: %ld %s\n", v, xti_prim(v));
13828 +
13829 +               if (ctl_buf && ctl_len > 0) {
13830 +                       int i = -1;
13831 +
13832 +                       for (i = 0; i < ctl_len && i < 64; i += 4) {
13833 +                               u_long v;
13834 +
13835 +                               get_user(v, (u_long *)(ctl_buf + i));
13836 +                               __abi_trace("ctl: 0x%08lx\n", v);
13837 +                       }
13838 +                       if (i != ctl_len)
13839 +                               __abi_trace("ctl: ...\n");
13840 +               }
13841 +
13842 +               if (dat_buf && dat_len > 0) {
13843 +                       int i = -1;
13844 +
13845 +                       for (i = 0; i < dat_len && i < 64; i += 4) {
13846 +                               u_long v;
13847 +
13848 +                               get_user(v, (u_long *)(dat_buf + i));
13849 +                               __abi_trace("dat: 0x%08lx\n", v);
13850 +                       }
13851 +                       if (i != dat_len)
13852 +                               __abi_trace("dat: ...");
13853 +               }
13854 +       }
13855 +#endif
13856 +
13857 +       error = get_user(cmd, (unsigned long *)ctl_buf);
13858 +       if (error)
13859 +               return error;
13860 +
13861 +       switch (cmd) {
13862 +               case T_BIND_REQ: {
13863 +                       struct T_bind_req req;
13864 +                       long old_esp;
13865 +                       unsigned long *tsp;
13866 +
13867 +#if defined(CONFIG_ABI_TRACE)
13868 +                       abi_trace(ABI_TRACE_STREAMS, "%u bind req\n", fd);
13869 +#endif
13870 +                       if (!access_ok(VERIFY_READ, ctl_buf, sizeof(req)))
13871 +                               return -EFAULT;
13872 +
13873 +                       if (Priv(filep)->state != TS_UNBND) {
13874 +                               timod_error(fd, T_BIND_REQ, TOUTSTATE, 0);
13875 +                               return 0;
13876 +                       }
13877 +
13878 +                       old_esp = regs->esp;
13879 +                       regs->esp -= 1024;
13880 +                       tsp = (unsigned long *)(regs->esp);
13881 +                       if (!access_ok(VERIFY_WRITE, tsp, 3*sizeof(long))) {
13882 +                               timod_error(fd, T_BIND_REQ, TSYSERR, -EFAULT);
13883 +                               regs->esp = old_esp;
13884 +                               return 0;
13885 +                       }
13886 +
13887 +                       if (copy_from_user(&req, ctl_buf, sizeof(req)))
13888 +                               return -EFAULT;
13889 +                       if (req.ADDR_offset && req.ADDR_length) {
13890 +                               struct sockaddr_in *sin;
13891 +                               unsigned short family;
13892 +
13893 +#if 1                          /* Wheee... Kludge time... */
13894 +                               sin = (struct sockaddr_in *)(ctl_buf
13895 +                                       + req.ADDR_offset);
13896 +                               get_user(family, &sin->sin_family);
13897 +
13898 +                               /* Sybase seems to have set up the address
13899 +                                * struct with sa->sa_family = htons(AF_?)
13900 +                                * which is bollocks. I have no idea why it
13901 +                                * apparently works on SCO?!?
13902 +                                */
13903 +                               if (family && !(family & 0x00ff))
13904 +                                       put_user(ntohs(family), &sin->sin_family);
13905 +#endif
13906 +
13907 +                               put_user(fd, tsp);
13908 +                               put_user((unsigned long)ctl_buf
13909 +                                               + req.ADDR_offset, tsp+1);
13910 +                               /* For TLI/XTI the length may be the 8 *used*
13911 +                                * bytes, for (IP?) sockets it must be the 16
13912 +                                * *total* bytes in a sockaddr_in.
13913 +                                */
13914 +                               put_user(req.ADDR_length == 8
13915 +                                       ? 16 : req.ADDR_length,
13916 +                                       tsp+2);
13917 +                               error = sys_socketcall(SYS_BIND, tsp);
13918 +
13919 +                               if (!error) {
13920 +                                       if (req.CONIND_number) {
13921 +
13922 +#if defined(CONFIG_ABI_TRACE)
13923 +                                               abi_trace(ABI_TRACE_STREAMS,
13924 +                                                       "%u listen backlog=%lu\n",
13925 +                                                       fd, req.CONIND_number);
13926 +#endif
13927 +
13928 +                                               put_user(fd, tsp);
13929 +                                               put_user(req.CONIND_number, tsp+1);
13930 +                                               sys_socketcall(SYS_LISTEN, tsp);
13931 +                                               Priv(filep)->state = TS_WRES_CIND;
13932 +                                       } else {
13933 +                                               Priv(filep)->state = TS_IDLE;
13934 +                                       }
13935 +                               }
13936 +                       } else {
13937 +                               error = 0;
13938 +                       }
13939 +
13940 +                       regs->esp = old_esp;
13941 +
13942 +                       if (!error) {
13943 +                               struct T_primsg *it;
13944 +                               it = timod_mkctl(ctl_len);
13945 +                               if (it) {
13946 +                                       struct T_bind_ack *ack = (struct T_bind_ack *)&it->type;
13947 +                                       if (copy_from_user(ack, ctl_buf, ctl_len))
13948 +                                               return -EFAULT;
13949 +                                       ack->PRIM_type = T_BIND_ACK;
13950 +                                       it->pri = MSG_HIPRI;
13951 +                                       it->length = ctl_len;
13952 +                                       it->next = NULL;
13953 +                                       timod_ok(fd, T_BIND_REQ);
13954 +                                       Priv(filep)->plast->next = it;
13955 +                                       Priv(filep)->plast = it;
13956 +                                       return 0;
13957 +                               }
13958 +                       }
13959 +                       switch (error) {
13960 +                               case -EINVAL:
13961 +                                       terror = TOUTSTATE;
13962 +                                       error = 0;
13963 +                                       break;
13964 +                               case -EACCES:
13965 +                                       terror = TACCES;
13966 +                                       error = 0;
13967 +                                       break;
13968 +                               case -EADDRNOTAVAIL:
13969 +                               case -EADDRINUSE:
13970 +                                       terror = TNOADDR;
13971 +                                       error = 0;
13972 +                                       break;
13973 +                               default:
13974 +                                       terror = TSYSERR;
13975 +                                       break;
13976 +                       }
13977 +                       timod_error(fd, T_BIND_REQ, terror, -error);
13978 +                       return 0;
13979 +               }
13980 +               case T_CONN_RES: {
13981 +                       struct T_conn_res *res = (struct T_conn_res *)ctl_buf;
13982 +                       unsigned int conn_fd;
13983 +
13984 +                       error = get_user(conn_fd, &res->SEQ_number);
13985 +                       if (error)
13986 +                               return error;
13987 +
13988 +#if defined(CONFIG_ABI_TRACE)
13989 +                       abi_trace(ABI_TRACE_STREAMS,
13990 +                                       "%u accept: conn fd=%u, use fd=%u\n",
13991 +                                       fd, conn_fd, flags);
13992 +#endif
13993 +
13994 +                       if (conn_fd != flags) {
13995 +                               error = sys_dup2(conn_fd, flags);
13996 +                               sys_close(conn_fd);
13997 +                               if (error < 0)
13998 +                                       return error;
13999 +                       }
14000 +                       timod_ok(fd, T_CONN_RES);
14001 +                       return 0;
14002 +               }
14003 +               case T_CONN_REQ: {
14004 +                       struct T_conn_req req;
14005 +                       long old_esp;
14006 +                       unsigned short oldflags;
14007 +                       unsigned long *tsp;
14008 +                       struct T_primsg *it;
14009 +                       struct sockaddr_in *sin;
14010 +                       unsigned short family;
14011 +
14012 +#if defined(CONFIG_ABI_TRACE)
14013 +                       abi_trace(ABI_TRACE_STREAMS, "%u connect req\n", fd);
14014 +#endif
14015 +                       if (!access_ok(VERIFY_READ, ctl_buf, sizeof(req)))
14016 +                               return -EFAULT;
14017 +
14018 +                       if (Priv(filep)->state != TS_UNBND
14019 +                       && Priv(filep)->state != TS_IDLE) {
14020 +                               timod_error(fd, T_CONN_REQ, TOUTSTATE, 0);
14021 +                               return 0;
14022 +                       }
14023 +
14024 +                       old_esp = regs->esp;
14025 +                       regs->esp -= 1024;
14026 +                       tsp = (unsigned long *)(regs->esp);
14027 +                       if (!access_ok(VERIFY_WRITE, tsp, 3*sizeof(long))) {
14028 +                               timod_error(fd, T_CONN_REQ, TSYSERR, -EFAULT);
14029 +                               regs->esp = old_esp;
14030 +                               return 0;
14031 +                       }
14032 +                       if (copy_from_user(&req, ctl_buf, sizeof(req)))
14033 +                               return -EFAULT;
14034 +                       put_user(fd, tsp);
14035 +                       put_user((unsigned long)ctl_buf + req.DEST_offset, tsp+1);
14036 +                       /* For TLI/XTI the length may be the 8 *used*
14037 +                        * bytes, for (IP?) sockets it must be the 16
14038 +                        * *total* bytes in a sockaddr_in.
14039 +                        */
14040 +                       put_user(req.DEST_length == 8
14041 +                               ? 16 : req.DEST_length,
14042 +                               tsp+2);
14043 +
14044 +#if 1                  /* Wheee... Kludge time... */
14045 +                       sin = (struct sockaddr_in *)(ctl_buf
14046 +                               + req.DEST_offset);
14047 +                       get_user(family, &sin->sin_family);
14048 +
14049 +                       /* Sybase seems to have set up the address
14050 +                        * struct with sa->sa_family = htons(AF_?)
14051 +                        * which is bollocks. I have no idea why it
14052 +                        * apparently works on SCO?!?
14053 +                        */
14054 +                       if (family && !(family & 0x00ff)) {
14055 +                               family = ntohs(family);
14056 +                               put_user(family, &sin->sin_family);
14057 +                       }
14058 +
14059 +                       /* Sheesh... ISC telnet seems to give the port
14060 +                        * number low byte first as I expected but the
14061 +                        * X programs seem to be giving high byte first.
14062 +                        * One is broken of course but clearly both
14063 +                        * should work. No, I don't understand this
14064 +                        * either but I can at least try...
14065 +                        * A better solution would be for you to change
14066 +                        * the definition of xserver0 in ISC's /etc/services
14067 +                        * but then it wouldn't work out of the box...
14068 +                        */
14069 +                       if (is_cur_personality(PER_SVR4) && family == AF_INET) {
14070 +                               get_user(family, &sin->sin_port);
14071 +                               if (family == 0x1770)
14072 +                                       put_user(htons(family),
14073 +                                               &sin->sin_port);
14074 +                       }
14075 +#endif
14076 +                       /* FIXME: We should honour non-blocking mode
14077 +                        * here but that means that the select probe
14078 +                        * needs to know that if select returns ok and
14079 +                        * we are in T_OUTCON we have a connection
14080 +                        * completion. This isn't so bad but the real
14081 +                        * problem is that the connection acknowledgement
14082 +                        * is supposed to contain the destination
14083 +                        * address.
14084 +                        */
14085 +                       oldflags = filep->f_flags;
14086 +                       filep->f_flags &= ~O_NONBLOCK;
14087 +                       error = sys_socketcall(SYS_CONNECT, tsp);
14088 +                       filep->f_flags = oldflags;
14089 +                       regs->esp = old_esp;
14090 +
14091 +                       if (!error) {
14092 +                               struct T_conn_con *con;
14093 +
14094 +                               it = timod_mkctl(ctl_len);
14095 +                               if (!it)
14096 +                                       return -ENOMEM;
14097 +                               it->length = ctl_len;
14098 +                               con = (struct T_conn_con *)&it->type;
14099 +                               if (copy_from_user(con, ctl_buf, ctl_len))
14100 +                                       return -EFAULT;
14101 +                               con->PRIM_type = T_CONN_CON;
14102 +                               Priv(filep)->state = TS_DATA_XFER;
14103 +                       } else {
14104 +                               struct T_discon_ind *dis;
14105 +
14106 +#if defined(CONFIG_ABI_TRACE)
14107 +                               abi_trace(ABI_TRACE_STREAMS,
14108 +                                               "%u connect failed (errno=%d)\n",
14109 +                                               fd, error);
14110 +#endif
14111 +
14112 +                               it = timod_mkctl(sizeof(struct T_discon_ind));
14113 +                               if (!it)
14114 +                                       return -ENOMEM;
14115 +                               it->length = sizeof(struct T_discon_ind);
14116 +                               dis = (struct T_discon_ind *)&it->type;
14117 +                               dis->PRIM_type = T_DISCON_IND;
14118 +                               dis->DISCON_reason = iABI_errors(-error);
14119 +                               dis->SEQ_number = 0;
14120 +                       }
14121 +                       timod_ok(fd, T_CONN_REQ);
14122 +                       it->pri = 0;
14123 +                       it->next = NULL;
14124 +                       Priv(filep)->plast->next = it;
14125 +                       Priv(filep)->plast = it;
14126 +                       return 0;
14127 +               }
14128 +
14129 +               case T_DISCON_REQ: {
14130 +                       struct T_discon_req *req;
14131 +
14132 +                       req = (struct T_discon_req *)ctl_buf;
14133 +                       error = get_user(fd, &req->SEQ_number);
14134 +                       if (error)
14135 +                               return error;
14136 +
14137 +#if defined(CONFIG_ABI_TRACE)
14138 +                       abi_trace(ABI_TRACE_STREAMS, "disconnect %u\n", fd);
14139 +#endif
14140 +                       /* Fall through... */
14141 +               }
14142 +               case T_ORDREL_REQ: {
14143 +                       sys_close(fd);
14144 +                       return 0;
14145 +               }
14146 +
14147 +               case T_DATA_REQ: {
14148 +                       long old_esp;
14149 +                       unsigned long *tsp;
14150 +
14151 +#if defined(CONFIG_ABI_TRACE)
14152 +                       abi_trace(ABI_TRACE_STREAMS, "%u data req\n", fd);
14153 +#endif
14154 +
14155 +                       if (Priv(filep)->state != TS_DATA_XFER) {
14156 +                               return 0;
14157 +                       }
14158 +
14159 +                       old_esp = regs->esp;
14160 +                       regs->esp -= 1024;
14161 +                       tsp = (unsigned long *)(regs->esp);
14162 +                       if (!access_ok(VERIFY_WRITE, tsp, 6*sizeof(long))) {
14163 +                               regs->esp = old_esp;
14164 +                               return 0;
14165 +                       }
14166 +                       put_user(fd, tsp);
14167 +                       put_user((unsigned long)dat_buf, tsp+1);
14168 +                       put_user(dat_len, tsp+2);
14169 +                       put_user(0, tsp+3);
14170 +                       error = sys_socketcall(SYS_SEND, tsp);
14171 +                       regs->esp = old_esp;
14172 +                       return error;
14173 +               }
14174 +
14175 +               case T_UNITDATA_REQ: {
14176 +                       struct T_unitdata_req req;
14177 +                       long old_esp;
14178 +                       unsigned long *tsp;
14179 +
14180 +#if defined(CONFIG_ABI_TRACE)
14181 +                       abi_trace(ABI_TRACE_STREAMS, "%u unitdata req\n", fd);
14182 +#endif
14183 +                       if (!access_ok(VERIFY_READ, ctl_buf, sizeof(req)))
14184 +                               return -EFAULT;
14185 +
14186 +                       if (Priv(filep)->state != TS_IDLE
14187 +                       && Priv(filep)->state != TS_DATA_XFER) {
14188 +                               timod_error(fd, T_UNITDATA_REQ, TOUTSTATE, 0);
14189 +                               return 0;
14190 +                       }
14191 +
14192 +                       old_esp = regs->esp;
14193 +                       regs->esp -= 1024;
14194 +                       tsp = (unsigned long *)(regs->esp);
14195 +                       if (!access_ok(VERIFY_WRITE, tsp, 6*sizeof(long))) {
14196 +                               timod_error(fd, T_UNITDATA_REQ, TSYSERR, -EFAULT);
14197 +                               regs->esp = old_esp;
14198 +                               return 0;
14199 +                       }
14200 +                       put_user(fd, tsp);
14201 +                       put_user((unsigned long)dat_buf, tsp+1);
14202 +                       put_user(dat_len, tsp+2);
14203 +                       put_user(0, tsp+3);
14204 +                       if (copy_from_user(&req, ctl_buf, sizeof(req)))
14205 +                               return -EFAULT;
14206 +                       if (req.DEST_length > 0) {
14207 +                               put_user((unsigned long)(ctl_buf+req.DEST_offset), tsp+4);
14208 +                               put_user(req.DEST_length, tsp+5);
14209 +                               error = sys_socketcall(SYS_SENDTO, tsp);
14210 +                               regs->esp = old_esp;
14211 +                               return error;
14212 +                       }
14213 +                       error = sys_socketcall(SYS_SEND, tsp);
14214 +                       regs->esp = old_esp;
14215 +                       return error;
14216 +               }
14217 +
14218 +               case T_UNBIND_REQ:
14219 +                       Priv(filep)->state = TS_UNBND;
14220 +                       timod_ok(fd, T_UNBIND_REQ);
14221 +                       return 0;
14222 +
14223 +               case T_OPTMGMT_REQ: {
14224 +                       struct T_optmgmt_req req;
14225 +
14226 +#if defined(CONFIG_ABI_TRACE)
14227 +                       abi_trace(ABI_TRACE_STREAMS, "%u optmgmt req\n", fd);
14228 +#endif
14229 +                       if (!access_ok(VERIFY_READ, ctl_buf, sizeof(req)))
14230 +                               return -EFAULT;
14231 +                       if (copy_from_user(&req, ctl_buf, sizeof(req)))
14232 +                               return -EFAULT;
14233 +
14234 +                       return timod_optmgmt(fd, regs, req.MGMT_flags,
14235 +                                       req.OPT_offset > 0
14236 +                                               ? ctl_buf+req.OPT_offset
14237 +                                               : NULL,
14238 +                                       req.OPT_length,
14239 +                                       1);
14240 +               }
14241 +       }
14242 +
14243 +#if defined(CONFIG_ABI_TRACE)
14244 +      if (abi_traced(ABI_TRACE_STREAMS))
14245 +      {
14246 +
14247 +       if (ctl_buf && ctl_len > 0) {
14248 +               int             i;
14249 +
14250 +               for (i = 0; i < ctl_len && i < 32; i += 4) {
14251 +                       u_long  v;
14252 +
14253 +                       get_user(v, (u_long *)(ctl_buf + i));
14254 +                       __abi_trace("ctl: 0x%08lx\n", v);
14255 +               }
14256 +               if (i != ctl_len)
14257 +                       __abi_trace("ctl: ...\n");
14258 +       }
14259 +       if (dat_buf && dat_len > 0) {
14260 +               int             i;
14261 +               for (i = 0; i < dat_len && i < 32; i += 4) {
14262 +                       u_long  v;
14263 +
14264 +                       get_user(v, (u_long *)(dat_buf + i));
14265 +                       __abi_trace("dat: 0x%08lx\n", v);
14266 +               }
14267 +               if (i != dat_len)
14268 +                       __abi_trace("dat: ...\n");
14269 +       }
14270 +      }
14271 +#endif
14272 +       return -EINVAL;
14273 +}
14274 +
14275 +/* this function needs to be cleaned up badly.  --hch */
14276 +int
14277 +timod_ioctl(struct pt_regs *regs,
14278 +       int fd, unsigned int func, void *arg, int len, int *len_p)
14279 +{
14280 +       struct file *filep;
14281 +       struct inode *ino;
14282 +       int error;
14283 +
14284 +       func &= 0xff;
14285 +
14286 +       filep = fget(fd);
14287 +       if (!filep)
14288 +               return TBADF;
14289 +
14290 +       if (!access_ok(VERIFY_WRITE, len_p, sizeof(int))) {
14291 +               fput(filep);
14292 +               return (-EFAULT << 8) | TSYSERR;
14293 +       }
14294 +
14295 +       ino = filep->f_dentry->d_inode;
14296 +
14297 +       /* SCO/SVR3 starts at 100, ISC/SVR4 starts at 140. */
14298 +       switch (func >= 140 ? func-140 : func-100) {
14299 +               case 0: /* TI_GETINFO */
14300 +               {
14301 +                       struct T_info_ack it;
14302 +                       unsigned long v;
14303 +
14304 +#if defined(CONFIG_ABI_TRACE)
14305 +                       abi_trace(ABI_TRACE_STREAMS, "%u getinfo\n", fd);
14306 +#endif
14307 +                       /* The pre-SVR4 T_info_ack structure didn't have
14308 +                        * the PROVIDER_flag on the end.
14309 +                        */
14310 +                       if (!access_ok(VERIFY_WRITE, arg,
14311 +                               func == 140
14312 +                               ? sizeof(struct T_info_ack)
14313 +                               : sizeof(struct T_info_ack)-sizeof(long))) {
14314 +                               fput(filep);
14315 +                               return (-EFAULT << 8) | TSYSERR;
14316 +                       }
14317 +
14318 +                       __get_user(v, &((struct T_info_req *)arg)->PRIM_type);
14319 +                       if (v != T_INFO_REQ) {
14320 +                               fput(filep);
14321 +                               return (EINVAL << 8) | TSYSERR;
14322 +                       }
14323 +
14324 +                       it.PRIM_type = T_INFO_ACK;
14325 +                       it.CURRENT_state = Priv(filep)->state;
14326 +                       it.CDATA_size = -2;
14327 +                       it.DDATA_size = -2;
14328 +                       it.OPT_size = -1;
14329 +                       it.TIDU_size = 16384;
14330 +                       switch ((MINOR(ino->i_rdev)>>4) & 0x0f) {
14331 +                               case AF_UNIX:
14332 +                                       it.ADDR_size = sizeof(struct sockaddr_un);
14333 +                                       break;
14334 +                               case AF_INET:
14335 +                                       it.ADDR_size = sizeof(struct sockaddr_in);
14336 +                                       break;
14337 +                               default:
14338 +                                       /* Uh... dunno... play safe(?) */
14339 +                                       it.ADDR_size = 1024;
14340 +                                       break;
14341 +                       }
14342 +                       switch (SOCKET_I(ino)->type) {
14343 +                               case SOCK_STREAM:
14344 +                                       it.ETSDU_size = 1;
14345 +                                       it.TSDU_size = 0;
14346 +                                       it.SERV_type = 2;
14347 +                                       break;
14348 +                               default:
14349 +                                       it.ETSDU_size = -2;
14350 +                                       it.TSDU_size = 16384;
14351 +                                       it.SERV_type = 3;
14352 +                                       break;
14353 +                       }
14354 +
14355 +                       fput(filep);
14356 +
14357 +                       /* The pre-SVR4 T_info_ack structure didn't have
14358 +                        * the PROVIDER_flag on the end.
14359 +                        */
14360 +                       if (func == 140) {
14361 +                               it.PROVIDER_flag = 0;
14362 +                               if (copy_to_user(arg, &it, sizeof(it)))
14363 +                                       return -EFAULT;
14364 +                               put_user(sizeof(it), len_p);
14365 +                               return 0;
14366 +                       }
14367 +                       if (copy_to_user(arg, &it, sizeof(it)-sizeof(long)))
14368 +                               return -EFAULT;
14369 +                       put_user(sizeof(it)-sizeof(long), len_p);
14370 +                       return 0;
14371 +               }
14372 +
14373 +               case 2: /* TI_BIND */
14374 +               {
14375 +                       int i;
14376 +                       long prim;
14377 +
14378 +#if defined(CONFIG_ABI_TRACE)
14379 +                       abi_trace(ABI_TRACE_STREAMS, "%u bind\n", fd);
14380 +#endif
14381 +                       error = do_putmsg(fd, regs, arg, len,
14382 +                                       NULL, -1, 0);
14383 +                       if (error) {
14384 +                               fput(filep);
14385 +                               return (-error << 8) | TSYSERR;
14386 +                       }
14387 +
14388 +                       /* Get the response. This should be either
14389 +                        * T_OK_ACK or T_ERROR_ACK.
14390 +                        */
14391 +                       i = MSG_HIPRI;
14392 +                       error = do_getmsg(fd, regs,
14393 +                                       arg, len, len_p,
14394 +                                       NULL, -1, NULL,
14395 +                                       &i);
14396 +                       if (error) {
14397 +                               fput(filep);
14398 +                               return (-error << 8) | TSYSERR;
14399 +                       }
14400 +
14401 +                       get_user(prim, (unsigned long *)arg);
14402 +                       if (prim == T_ERROR_ACK) {
14403 +                               unsigned long a, b;
14404 +                               fput(filep);
14405 +                               get_user(a, ((unsigned long *)arg)+3);
14406 +                               get_user(b, ((unsigned long *)arg)+2);
14407 +                               return (a << 8) | b;
14408 +                       }
14409 +                       if (prim != T_OK_ACK) {
14410 +                               fput(filep);
14411 +                               return TBADSEQ;
14412 +                       }
14413 +
14414 +                       /* Get the response to the bind request. */
14415 +                       i = MSG_HIPRI;
14416 +                       error = do_getmsg(fd, regs,
14417 +                                       arg, len, len_p,
14418 +                                       NULL, -1, NULL,
14419 +                                       &i);
14420 +                       fput(filep);
14421 +                       if (error)
14422 +                               return (-error << 8) | TSYSERR;
14423 +
14424 +                       return 0;
14425 +               }
14426 +
14427 +               case 3: /* TI_UNBIND */
14428 +                       if (Priv(filep)->state != TS_IDLE) {
14429 +                               fput(filep);
14430 +                               return TOUTSTATE;
14431 +                       }
14432 +                       Priv(filep)->state = TS_UNBND;
14433 +                       fput(filep);
14434 +                       return 0;
14435 +
14436 +               case 1: { /* TI_OPTMGMT */
14437 +#if defined(CONFIG_ABI_XTI_OPTMGMT) || defined(CONFIG_ABI_TLI_OPTMGMT)
14438 +                       int i;
14439 +                       long prim;
14440 +
14441 +#if defined(CONFIG_ABI_TRACE)
14442 +                       abi_trace(ABI_TRACE_STREAMS, "%u optmgmt\n", fd);
14443 +#endif
14444 +                       error = do_putmsg(fd, regs, arg, len,
14445 +                                       NULL, -1, 0);
14446 +                       if (error) {
14447 +                               fput(filep);
14448 +                               return (-error << 8) | TSYSERR;
14449 +                       }
14450 +
14451 +                       /* Get the response to the optmgmt request. */
14452 +                       i = MSG_HIPRI;
14453 +                       error = do_getmsg(fd, regs,
14454 +                                       arg, len, len_p,
14455 +                                       NULL, -1, NULL,
14456 +                                       &i);
14457 +                       if (error > 0) {
14458 +                               /* If there is excess data in the response
14459 +                                * our buffer is too small which implies
14460 +                                * the application is broken. SO_LINGER
14461 +                                * is a common fault. Because it works
14462 +                                * on other systems we attempt to recover
14463 +                                * by discarding the excess.
14464 +                                */
14465 +                               struct T_primsg *it = Priv(filep)->pfirst;
14466 +                               Priv(filep)->pfirst = it->next;
14467 +                               if (!Priv(filep)->pfirst)
14468 +                                       Priv(filep)->plast = NULL;
14469 +                               kfree(it);
14470 +                               Priv(filep)->offset = 0;
14471 +
14472 +#if defined(CONFIG_ABI_TRACE)
14473 +                               abi_trace(ABI_TRACE_STREAMS,
14474 +                                               "excess discarded\n");
14475 +#endif
14476 +                       }
14477 +
14478 +                       fput(filep);
14479 +
14480 +                       if (error < 0)
14481 +                               return (-error << 8) | TSYSERR;
14482 +
14483 +                       __get_user(prim, (unsigned long *)arg);
14484 +                       if (prim == T_ERROR_ACK) {
14485 +                               unsigned long a, b;
14486 +                               __get_user(a, ((unsigned long *)arg)+3);
14487 +                               __get_user(b, ((unsigned long *)arg)+2);
14488 +                               return (a << 8) | b;
14489 +                       }
14490 +
14491 +                       return 0;
14492 +#else /* no CONFIG_ABI_XTI_OPTMGMT or CONFIG_ABI_TLI_OPTMGMT */
14493 +                       fput(filep);
14494 +                       return TNOTSUPPORT;
14495 +#endif /* CONFIG_ABI_XTI_OPTMGMT or CONFIG_ABI_TLI_OPTMGMT */
14496 +               }
14497 +
14498 +               case 4: /* TI_GETMYNAME */
14499 +               case 5: /* TI_SETPEERNAME */
14500 +               case 6: /* TI_GETMYNAME */
14501 +               case 7: /* TI_SETPEERNAME */
14502 +                        break;
14503 +       }
14504 +
14505 +#if defined(CONFIG_ABI_TRACE)
14506 +       abi_trace(ABI_TRACE_STREAMS,
14507 +                       "STREAMS timod op %d not supported\n", func);
14508 +#endif
14509 +       fput(filep);
14510 +       return TNOTSUPPORT;
14511 +}
14512 +
14513 +
14514 +int
14515 +svr4_sockmod_ioctl(int fd, u_int cmd, caddr_t data)
14516 +{
14517 +       struct file             *fp;
14518 +       struct inode            *ip;
14519 +       int                     error;
14520 +
14521 +       fp = fget(fd);
14522 +       if (!fp)
14523 +               return (TBADF);
14524 +
14525 +       ip = fp->f_dentry->d_inode;
14526 +       if (MAJOR(ip->i_rdev) == SOCKSYS_MAJOR) {
14527 +               error = socksys_fdinit(fd, 0, NULL, NULL);
14528 +               if (error < 0)
14529 +                       return -error;
14530 +               fput(fp);
14531 +               fp = fget(fd);
14532 +               if (!fp)
14533 +                       return TBADF;
14534 +               ip = fp->f_dentry->d_inode;
14535 +       }
14536 +
14537 +       switch (cmd) {
14538 +       case 101: { /* SI_GETUDATA */
14539 +               struct {
14540 +                       int tidusize, addrsize, optsize, etsdusize;
14541 +                       int servtype, so_state, so_options;
14542 +               } *it = (void *)data;
14543 +
14544 +#if defined(CONFIG_ABI_TRACE)
14545 +               abi_trace(ABI_TRACE_STREAMS, "%u getudata\n", fd);
14546 +#endif
14547 +               if (!access_ok(VERIFY_WRITE, it, sizeof(*it))) {
14548 +                       fput(fp);
14549 +                       return (-EFAULT << 8) | TSYSERR;
14550 +               }
14551 +
14552 +               __put_user(16384, &it->tidusize);
14553 +               __put_user(sizeof(struct sockaddr), &it->addrsize);
14554 +               __put_user(-1, &it->optsize);
14555 +               __put_user(0, &it->so_state);
14556 +               __put_user(0, &it->so_options);
14557 +
14558 +               switch (SOCKET_I(ip)->type) {
14559 +               case SOCK_STREAM:
14560 +                       __put_user(1, &it->etsdusize);
14561 +                       __put_user(2, &it->servtype);
14562 +                       break;
14563 +               default:
14564 +                       __put_user(-2, &it->etsdusize);
14565 +                       __put_user(3, &it->servtype);
14566 +                       break;
14567 +               }
14568 +               fput(fp);
14569 +               return 0;
14570 +       }
14571 +
14572 +       case 102: /* SI_SHUTDOWN */
14573 +       case 103: /* SI_LISTEN */
14574 +       case 104: /* SI_SETMYNAME */
14575 +       case 105: /* SI_SETPEERNAME */
14576 +       case 106: /* SI_GETINTRANSIT */
14577 +       case 107: /* SI_TCL_LINK */
14578 +       case 108: /* SI_TCL_UNLINK */
14579 +                break;
14580 +       }
14581 +
14582 +#if defined(CONFIG_ABI_TRACE)
14583 +       abi_trace(ABI_TRACE_STREAMS,
14584 +                       "STREAMS sockmod op %d not supported\n", cmd);
14585 +#endif
14586 +       fput(fp);
14587 +       return TNOTSUPPORT;
14588 +}
14589 +
14590 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
14591 +EXPORT_SYMBOL(svr4_sockmod_ioctl);
14592 +#endif
14593 diff -Nur kernel-source-2.6.16.orig/abi/util/Makefile kernel-source-2.6.16/abi/util/Makefile
14594 --- kernel-source-2.6.16.orig/abi/util/Makefile 1970-01-01 10:00:00.000000000 +1000
14595 +++ kernel-source-2.6.16/abi/util/Makefile      2006-04-27 18:50:24.000000000 +1000
14596 @@ -0,0 +1,7 @@
14597 +
14598 +abi-util-objs  := stat.o plist.o
14599 +
14600 +obj-$(CONFIG_ABI_UTIL) += abi-util.o
14601 +
14602 +abi-util.o: $(abi-util-objs)
14603 +       $(LD) -r -o $@ $(abi-util-objs)
14604 diff -Nur kernel-source-2.6.16.orig/abi/util/plist.c kernel-source-2.6.16/abi/util/plist.c
14605 --- kernel-source-2.6.16.orig/abi/util/plist.c  1970-01-01 10:00:00.000000000 +1000
14606 +++ kernel-source-2.6.16/abi/util/plist.c       2006-04-27 18:50:24.000000000 +1000
14607 @@ -0,0 +1,69 @@
14608 +#ident "%W% %G%"
14609 +
14610 +#include <linux/string.h>
14611 +#include <linux/fs.h>
14612 +#include <linux/slab.h> /* needed by putname macro */
14613 +#include <linux/sched.h> /* needed by current-> in __abi_trace() macro */
14614 +#include <linux/module.h>
14615 +
14616 +#include <abi/util/trace.h>
14617 +
14618 +
14619 +#if defined(CONFIG_ABI_TRACE)
14620 +static void
14621 +print_string(char *buf, char *str)
14622 +{
14623 +       char *tmp;
14624 +
14625 +       tmp = getname(str);
14626 +       if (!IS_ERR(tmp)) {
14627 +               /* we are debugging, we don't need to see it all */
14628 +               tmp[80] = '\0';
14629 +               sprintf(buf, "\"%s\"", tmp);
14630 +               putname(tmp);
14631 +       }
14632 +}
14633 +
14634 +void plist(char *name, char *args, int *list)
14635 +{
14636 +       char buf[512], *p = buf;
14637 +
14638 +       buf[0] = '\0';
14639 +       while (*args) {
14640 +               switch (*args++) {
14641 +               case 'd':
14642 +                       sprintf(p, "%d", *list++);
14643 +                       break;
14644 +               case 'o':
14645 +                       sprintf(p, "0%o", *list++);
14646 +                       break;
14647 +               case 'p':
14648 +                       sprintf(p, "%p", (void *)(*list++));
14649 +                       break;
14650 +               case '?':
14651 +               case 'x':
14652 +                       sprintf(p, "0x%x", *list++);
14653 +                       break;
14654 +               case 's':
14655 +                       print_string(p, (char *)(*list++));
14656 +                       break;
14657 +               default:
14658 +                       sprintf(p, "?%c%c?", '%', args[-1]);
14659 +                       break;
14660 +               }
14661 +
14662 +               while (*p)
14663 +                       ++p;
14664 +               if (*args) {
14665 +                       *p++ = ',';
14666 +                       *p++ = ' ';
14667 +                       *p = '\0';
14668 +               }
14669 +       }
14670 +       __abi_trace("%s(%s)\n", name, buf);
14671 +}
14672 +
14673 +#if CONFIG_ABI_LCALL7 == m
14674 +EXPORT_SYMBOL(plist);
14675 +#endif
14676 +#endif /* CONFIG_ABI_TRACE */
14677 diff -Nur kernel-source-2.6.16.orig/abi/util/stat.c kernel-source-2.6.16/abi/util/stat.c
14678 --- kernel-source-2.6.16.orig/abi/util/stat.c   1970-01-01 10:00:00.000000000 +1000
14679 +++ kernel-source-2.6.16/abi/util/stat.c        2006-04-27 18:50:24.000000000 +1000
14680 @@ -0,0 +1,146 @@
14681 +/*
14682 + * Mostly ripped from Al Viro's stat-a-AC9-10 patch, 2001 Christoph Hellwig.
14683 + */
14684 +
14685 +#ident "%W% %G%"
14686 +
14687 +#include <linux/module.h>              /* needed to shut up modprobe */
14688 +#include <linux/fs.h>
14689 +#include <linux/stat.h>
14690 +#include <linux/sched.h>
14691 +#include <linux/file.h>
14692 +#include <linux/namei.h>
14693 +
14694 +#include <abi/util/revalidate.h>
14695 +#include <abi/util/stat.h>
14696 +
14697 +
14698 +MODULE_DESCRIPTION("Linux-ABI helper routines");
14699 +MODULE_AUTHOR("Christoph Hellwig, ripped from kernel sources/patches");
14700 +MODULE_LICENSE("GPL");
14701 +
14702 +#if 0 /* LINUXABI_OBSOLETE */
14703 +int getattr_full(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
14704 +{
14705 +       struct inode *inode = dentry->d_inode;
14706 +       stat->dev = inode->i_rdev;
14707 +       stat->ino = inode->i_ino;
14708 +       stat->mode = inode->i_mode;
14709 +       stat->nlink = inode->i_nlink;
14710 +       stat->uid = inode->i_uid;
14711 +       stat->gid = inode->i_gid;
14712 +       stat->rdev = inode->i_rdev;
14713 +       stat->atime = inode->i_atime;
14714 +       stat->mtime = inode->i_mtime;
14715 +       stat->ctime = inode->i_ctime;
14716 +       stat->size = inode->i_size;
14717 +       stat->blocks = inode->i_blocks;
14718 +       stat->blksize = inode->i_blksize;
14719 +       return 0;
14720 +}
14721 +
14722 +/*
14723 + * Use minix fs values for the number of direct and indirect blocks.  The
14724 + * count is now exact for the minix fs except that it counts zero blocks.
14725 + * Everything is in units of BLOCK_SIZE until the assignment to
14726 + * stat->blksize.
14727 + */
14728 +int getattr_minix(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
14729 +{
14730 +       struct inode *inode = dentry->d_inode;
14731 +       unsigned int blocks, indirect;
14732 +
14733 +       stat->dev = inode->i_rdev;
14734 +       stat->ino = inode->i_ino;
14735 +       stat->mode = inode->i_mode;
14736 +       stat->nlink = inode->i_nlink;
14737 +       stat->uid = inode->i_uid;
14738 +       stat->gid = inode->i_gid;
14739 +       stat->rdev = inode->i_rdev;
14740 +       stat->atime = inode->i_atime;
14741 +       stat->mtime = inode->i_mtime;
14742 +       stat->ctime = inode->i_ctime;
14743 +       stat->size = inode->i_size;
14744 +#define D_B    7
14745 +#define I_B    (BLOCK_SIZE / sizeof(unsigned short))
14746 +
14747 +       blocks = (stat->size + BLOCK_SIZE - 1) >> BLOCK_SIZE_BITS;
14748 +       if (blocks > D_B) {
14749 +               indirect = (blocks - D_B + I_B - 1) / I_B;
14750 +               blocks += indirect;
14751 +               if (indirect > 1) {
14752 +                       indirect = (indirect - 1 + I_B - 1) / I_B;
14753 +                       blocks += indirect;
14754 +                       if (indirect > 1)
14755 +                               blocks++;
14756 +               }
14757 +       }
14758 +       stat->blocks = (BLOCK_SIZE / 512) * blocks;
14759 +       stat->blksize = BLOCK_SIZE;
14760 +       return 0;
14761 +}
14762 +
14763 +int vfs_stat(char *filename, struct kstat *stat)
14764 +{
14765 +       struct nameidata nd;
14766 +       int error;
14767 +
14768 +       error = user_path_walk(filename, &nd);
14769 +       if (error)
14770 +               return error;
14771 +
14772 +       error = do_revalidate(nd.dentry);
14773 +       if (!error) {
14774 +               struct inode *inode = nd.dentry->d_inode;
14775 +               if (!inode->i_blksize)
14776 +                       error = getattr_minix(nd.mnt, nd.dentry, stat);
14777 +               else
14778 +                       error = getattr_full(nd.mnt, nd.dentry, stat);
14779 +               path_release(&nd);
14780 +       }
14781 +
14782 +       return error;
14783 +}
14784 +
14785 +int vfs_lstat(char *filename, struct kstat *stat)
14786 +{
14787 +       struct nameidata nd;
14788 +       int error;
14789 +
14790 +       error = user_path_walk_link(filename, &nd);
14791 +       if (error)
14792 +               return error;
14793 +
14794 +       error = do_revalidate(nd.dentry);
14795 +       if (!error) {
14796 +               struct inode *inode = nd.dentry->d_inode;
14797 +               if (!inode->i_blksize)
14798 +                       error = getattr_minix(nd.mnt, nd.dentry, stat);
14799 +               else
14800 +                       error = getattr_full(nd.mnt, nd.dentry, stat);
14801 +               path_release(&nd);
14802 +       }
14803 +
14804 +       return error;
14805 +}
14806 +
14807 +int vfs_fstat(int fd, struct kstat *stat)
14808 +{
14809 +       struct file *file = fget(fd);
14810 +       int error;
14811 +
14812 +       if (!file)
14813 +               return -EBADF;
14814 +
14815 +       error = do_revalidate(file->f_dentry);
14816 +       if (!error) {
14817 +               struct inode *inode = file->f_dentry->d_inode;
14818 +               if (!inode->i_blksize)
14819 +                       error = getattr_minix(file->f_vfsmnt, file->f_dentry, stat);
14820 +               else
14821 +                       error = getattr_full(file->f_vfsmnt, file->f_dentry, stat);
14822 +               fput(file);
14823 +       }
14824 +       return error;
14825 +}
14826 +#endif
14827 diff -Nur kernel-source-2.6.16.orig/abi/uw7/access.c kernel-source-2.6.16/abi/uw7/access.c
14828 --- kernel-source-2.6.16.orig/abi/uw7/access.c  1970-01-01 10:00:00.000000000 +1000
14829 +++ kernel-source-2.6.16/abi/uw7/access.c       2006-04-27 18:50:24.000000000 +1000
14830 @@ -0,0 +1,75 @@
14831 +/*
14832 + *      abi/uw7/access.c - support for UnixWare access(2) system call.
14833 + *
14834 + *      We handle the non-POSIX EFF_ONLY_OK/EX_OK flags.
14835 + *      This software is under GPL.
14836 + */
14837 +
14838 +#include <linux/errno.h>
14839 +#include <linux/sched.h>
14840 +#include <linux/syscalls.h>
14841 +#include <linux/dcache.h>
14842 +#include <linux/namei.h>
14843 +#include <asm/uaccess.h>
14844 +
14845 +#include <abi/util/revalidate.h>
14846 +
14847 +
14848 +#undef DEBUG
14849 +
14850 +#ifdef DEBUG
14851 +#define DBG(x...)      printk(x)
14852 +#else
14853 +#define DBG(x...)
14854 +#endif
14855 +
14856 +#define UW7_R_OK       004
14857 +#define UW7_W_OK       002
14858 +#define UW7_X_OK       001
14859 +#define UW7_F_OK       000
14860 +#define UW7_EFF_ONLY_OK        010
14861 +#define UW7_EX_OK      020
14862 +
14863 +#define UW7_MODE_MSK   (UW7_R_OK|UW7_W_OK|UW7_X_OK|UW7_F_OK|UW7_EFF_ONLY_OK|UW7_EX_OK)
14864 +
14865 +int uw7_access(char * filename, int mode)
14866 +{
14867 +       struct nameidata nd;
14868 +       int error;
14869 +
14870 +       DBG(KERN_ERR "UW7[%d]: access(%p,%o)\n", current->pid, filename, mode);
14871 +
14872 +       if (mode & ~UW7_MODE_MSK)
14873 +               return -EINVAL;
14874 +
14875 +       if (mode & UW7_EX_OK) {
14876 +               error = user_path_walk(filename, &nd);
14877 +               if (!error) {
14878 +                       error = do_revalidate(nd.dentry);
14879 +                       if (error) {
14880 +                               path_release(&nd);
14881 +                               return -EIO;
14882 +                       }
14883 +                       if (!S_ISREG(nd.dentry->d_inode->i_mode)) {
14884 +                               path_release(&nd);
14885 +                               return -EACCES;
14886 +                       }
14887 +                       path_release(&nd);
14888 +               }
14889 +               mode &= ~UW7_EX_OK;
14890 +               mode |= UW7_X_OK;
14891 +       }
14892 +       if (mode & UW7_EFF_ONLY_OK) {
14893 +               uid_t old_uid = current->uid, old_gid = current->gid;
14894 +
14895 +               current->uid = current->euid;
14896 +               current->gid = current->egid;
14897 +               mode &= ~UW7_EFF_ONLY_OK;
14898 +               error =  sys_access(filename, mode);
14899 +               current->uid = old_uid;
14900 +               current->gid = old_gid;
14901 +       } else
14902 +               error = sys_access(filename, mode);
14903 +
14904 +       return error;
14905 +}
14906 diff -Nur kernel-source-2.6.16.orig/abi/uw7/context.c kernel-source-2.6.16/abi/uw7/context.c
14907 --- kernel-source-2.6.16.orig/abi/uw7/context.c 1970-01-01 10:00:00.000000000 +1000
14908 +++ kernel-source-2.6.16/abi/uw7/context.c      2006-04-27 18:50:24.000000000 +1000
14909 @@ -0,0 +1,96 @@
14910 +/*
14911 + *     abi/uw7/context.c
14912 + *
14913 + *  This software is under GPL
14914 + */
14915 +
14916 +
14917 +#include <linux/ptrace.h>
14918 +#include <linux/errno.h>
14919 +#define __KERNEL_SYSCALLS__
14920 +#include <linux/unistd.h>
14921 +#include <linux/syscalls.h>
14922 +#include <asm/uaccess.h>
14923 +
14924 +#include <asm/abi_machdep.h>
14925 +#include <abi/uw7/context.h>
14926 +
14927 +
14928 +int
14929 +uw7_sigaltstack(const uw7_stack_t *uw7_ss, uw7_stack_t *uw7_oss)
14930 +{
14931 +       stack_t ss, oss, *ssp = NULL, *ossp = NULL;
14932 +       int error;
14933 +       mm_segment_t old_fs;
14934 +
14935 +       if (uw7_ss) {
14936 +               if (!access_ok(VERIFY_READ, uw7_ss, sizeof(uw7_stack_t)))
14937 +                       return -EFAULT;
14938 +               __get_user(ss.ss_sp, &uw7_ss->ss_sp);
14939 +               __get_user(ss.ss_size, &uw7_ss->ss_size);
14940 +               __get_user(ss.ss_flags, &uw7_ss->ss_flags);
14941 +               ssp = &ss;
14942 +       }
14943 +
14944 +       if (uw7_oss) {
14945 +               if (!access_ok(VERIFY_WRITE, uw7_oss, sizeof(uw7_stack_t)))
14946 +                       return -EFAULT;
14947 +               __get_user(oss.ss_sp, &uw7_oss->ss_sp);
14948 +               __get_user(oss.ss_size, &uw7_oss->ss_size);
14949 +               __get_user(oss.ss_flags, &uw7_oss->ss_flags);
14950 +               ossp = &oss;
14951 +       }
14952 +
14953 +       old_fs = get_fs();
14954 +       set_fs(get_ds());
14955 +       error = sys_sigaltstack(ssp, ossp);
14956 +       set_fs(old_fs);
14957 +
14958 +       if (ossp) {
14959 +               __put_user(ossp->ss_sp, &uw7_oss->ss_sp);
14960 +               __put_user(ossp->ss_size, &uw7_oss->ss_size);
14961 +               __put_user(ossp->ss_flags, &uw7_oss->ss_flags);
14962 +       }
14963 +       return error;
14964 +}
14965 +
14966 +static int
14967 +getcontext(uw7_context_t * uc, struct pt_regs * regs)
14968 +{
14969 +       uw7_context_t tmp = { 0 };
14970 +
14971 +       return copy_to_user(uc, &tmp, sizeof(uw7_context_t)) ? -EFAULT : 0;
14972 +}
14973 +
14974 +static int
14975 +getxcontext(uw7_context_t * uc, struct pt_regs * regs)
14976 +{
14977 +       return 0;
14978 +}
14979 +
14980 +static int
14981 +setcontext(uw7_context_t * uc, struct pt_regs * regs)
14982 +{
14983 +       if (!uc) /* SVR4 says setcontext(NULL) => exit(0) */
14984 +               sys_exit(0);
14985 +       return 0;
14986 +}
14987 +
14988 +int
14989 +uw7_context(struct pt_regs * regs)
14990 +{
14991 +       int fcn = get_syscall_parameter(regs, 0);
14992 +       uw7_context_t * uc = (uw7_context_t *) get_syscall_parameter(regs, 1);
14993 +
14994 +       switch (fcn) {
14995 +               case UW7_GETCONTEXT:
14996 +                       return getcontext(uc, regs);
14997 +
14998 +               case UW7_GETXCONTEXT:
14999 +                       return getxcontext(uc, regs);
15000 +
15001 +               case UW7_SETCONTEXT:
15002 +                       return setcontext(uc, regs);
15003 +       }
15004 +       return -EINVAL;
15005 +}
15006 diff -Nur kernel-source-2.6.16.orig/abi/uw7/ioctl.c kernel-source-2.6.16/abi/uw7/ioctl.c
15007 --- kernel-source-2.6.16.orig/abi/uw7/ioctl.c   1970-01-01 10:00:00.000000000 +1000
15008 +++ kernel-source-2.6.16/abi/uw7/ioctl.c        2006-04-27 18:50:24.000000000 +1000
15009 @@ -0,0 +1,219 @@
15010 +/*
15011 + *   abi/uw7/ioctl.c - Support for UnixWare 7.x ioctl(2) system call.
15012 + *
15013 + *  This module provides a function uw7_ioctl() which is called indirectly
15014 + *  via uw7_funcs[] array, see abi/uw7/funcs.c.
15015 + *  This software is under GPL
15016 + */
15017 +
15018 +#include <linux/errno.h>
15019 +#include <linux/sched.h>
15020 +#include <linux/syscalls.h>
15021 +#include <linux/termios.h>
15022 +#include <asm/uaccess.h>
15023 +
15024 +#include <asm/abi_machdep.h>
15025 +
15026 +#include <abi/uw7/termbits.h>
15027 +#include <abi/uw7/termios.h>
15028 +#include <abi/svr4/ioctl.h>
15029 +
15030 +
15031 +#undef DEBUG
15032 +
15033 +#ifdef DEBUG
15034 +#define DBG(x...)      printk(x)
15035 +#else
15036 +#define DBG(x...)
15037 +#endif
15038 +
15039 +
15040 +static int tioc_tcgets(int fd, struct uw7_termios * tios);
15041 +static int tioc_tcsets(int fd, int lnx_cmd, struct uw7_termios * tios);
15042 +static int ioctl_T(int fd, unsigned int cmd, void * arg);
15043 +
15044 +
15045 +int uw7_ioctl(struct pt_regs * regs)
15046 +{
15047 +       int fd;
15048 +       unsigned int cmd, class;
15049 +       void * arg;
15050 +
15051 +       fd = (int)get_syscall_parameter(regs, 0);
15052 +       cmd = (unsigned int)get_syscall_parameter(regs, 1);
15053 +       arg = (void *)get_syscall_parameter(regs, 2);
15054 +       class = cmd >> 8;
15055 +
15056 +       switch (class) {
15057 +       case 'T':
15058 +               return ioctl_T(fd, cmd, arg);
15059 +       default:
15060 +               return __svr4_ioctl(regs, fd, cmd, arg);
15061 +       }
15062 +}
15063 +
15064 +static int tioc_tcsets(int fd, int lnx_cmd, struct uw7_termios * tios)
15065 +{
15066 +       struct termios t;
15067 +       struct uw7_termios tmp = {0, };
15068 +       mm_segment_t old_fs;
15069 +       int error;
15070 +
15071 +       DBG(KERN_ERR "UW7[%d]: tioc_tcsets(%d,%x,%p)\n",
15072 +               current->pid, fd, lnx_cmd, tios);
15073 +
15074 +       if (!access_ok(VERIFY_READ, tios, sizeof(struct uw7_termios)))
15075 +               return -EFAULT;
15076 +
15077 +       old_fs = get_fs();
15078 +       set_fs(get_ds());
15079 +       error = sys_ioctl(fd, TCGETS, (long)&t);
15080 +       set_fs(old_fs);
15081 +       if (error)
15082 +               return error;
15083 +
15084 +       if (copy_from_user(&tmp, tios, sizeof(struct uw7_termios)))
15085 +               return -EFAULT;
15086 +       t.c_iflag = tmp.c_iflag & ~UW7_DOSMODE;
15087 +       t.c_oflag = tmp.c_oflag;
15088 +       t.c_cflag = tmp.c_cflag;
15089 +       t.c_lflag = tmp.c_lflag & ~UW7_DEFECHO;
15090 +       if (tmp.c_lflag & UW7_FLUSHO)
15091 +               t.c_lflag |= FLUSHO;
15092 +       else
15093 +               t.c_lflag &= ~FLUSHO;
15094 +
15095 +       DBG(KERN_ERR
15096 +               "UW7[%d]: iflag: %lx->%lx, oflag: %lx->%lx, cflag: %lx->%lx, lflag: %lx->%lx\n",
15097 +               current->pid, tmp.c_iflag, t.c_iflag, tmp.c_oflag, t.c_oflag,
15098 +               tmp.c_cflag, t.c_cflag, tmp.c_lflag, t.c_lflag);
15099 +
15100 +       t.c_cc[VINTR] = tmp.c_cc[UW7_VINTR];
15101 +       t.c_cc[VQUIT] = tmp.c_cc[UW7_VQUIT];
15102 +       t.c_cc[VERASE] = tmp.c_cc[UW7_VERASE];
15103 +       t.c_cc[VKILL] = tmp.c_cc[UW7_VKILL];
15104 +       t.c_cc[VEOL2] = tmp.c_cc[UW7_VEOL2];
15105 +       t.c_cc[VSWTC] = tmp.c_cc[UW7_VSWTCH];
15106 +       t.c_cc[VSTART] = tmp.c_cc[UW7_VSTART];
15107 +       t.c_cc[VSTOP] = tmp.c_cc[UW7_VSTOP];
15108 +       t.c_cc[VSUSP] = tmp.c_cc[UW7_VSUSP];
15109 +       t.c_cc[VREPRINT] = tmp.c_cc[UW7_VREPRINT];
15110 +       t.c_cc[VDISCARD] = tmp.c_cc[UW7_VDISCARD];
15111 +       t.c_cc[VWERASE] = tmp.c_cc[UW7_VWERASE];
15112 +       t.c_cc[VLNEXT] = tmp.c_cc[UW7_VLNEXT];
15113 +       if (t.c_lflag & ICANON) {
15114 +               t.c_cc[VEOF] = tmp.c_cc[UW7_VEOF];
15115 +               t.c_cc[VEOL] = tmp.c_cc[UW7_VEOL];
15116 +       } else {
15117 +               t.c_cc[VMIN] = tmp.c_cc[UW7_VMIN];
15118 +               t.c_cc[VTIME] = tmp.c_cc[UW7_VTIME];
15119 +               t.c_cc[VEOL] = tmp.c_cc[UW7_VEOL2];
15120 +       }
15121 +
15122 +
15123 +       DBG(KERN_ERR
15124 +               "UW7[%d]: "
15125 +               "VINTR: %x->%x, VQUIT: %x->%x, VERASE: %x->%x, VKILL: %x->%x\n"
15126 +               "VEOL2: %x->%x\n",
15127 +               current->pid, tmp.c_cc[UW7_VINTR], t.c_cc[VINTR],
15128 +               tmp.c_cc[UW7_VQUIT], t.c_cc[VQUIT],
15129 +               tmp.c_cc[UW7_VERASE], t.c_cc[VERASE],
15130 +               tmp.c_cc[UW7_VKILL], t.c_cc[VKILL],
15131 +               tmp.c_cc[UW7_VEOL2], t.c_cc[VEOL2]);
15132 +
15133 +       old_fs = get_fs();
15134 +       set_fs(get_ds());
15135 +       error = sys_ioctl(fd, lnx_cmd, (long)&t);
15136 +       set_fs(old_fs);
15137 +       return error;
15138 +}
15139 +
15140 +static int tioc_tcgets(int fd, struct uw7_termios * tios)
15141 +{
15142 +       struct termios t;
15143 +       struct uw7_termios tmp = { 0 };
15144 +       mm_segment_t old_fs;
15145 +       int error;
15146 +
15147 +       DBG(KERN_ERR "UW7[%d]: tioc_tcgets(%d,%p)\n", current->pid, fd, tios);
15148 +
15149 +       old_fs = get_fs();
15150 +       set_fs(get_ds());
15151 +       error = sys_ioctl(fd, TCGETS, (long)&t);
15152 +       set_fs(old_fs);
15153 +       if (error)
15154 +               return error;
15155 +
15156 +       tmp.c_iflag = UW7_IFLAG_MSK & (t.c_iflag & ~UW7_DOSMODE);
15157 +       tmp.c_oflag = UW7_OFLAG_MSK & t.c_oflag;
15158 +       tmp.c_cflag = UW7_CFLAG_MSK & t.c_cflag;
15159 +       tmp.c_lflag = UW7_LFLAG_MSK & (t.c_lflag & ~UW7_DEFECHO);
15160 +       if (t.c_lflag & FLUSHO)
15161 +               tmp.c_lflag |= UW7_FLUSHO;
15162 +       else
15163 +               tmp.c_lflag &= ~UW7_FLUSHO;
15164 +
15165 +       DBG(KERN_ERR
15166 +               "UW7[%d]: iflag: %lx->%lx, oflag: %lx->%lx, cflag: %lx->%lx, lflag: %lx->%lx\n",
15167 +               current->pid, tmp.c_iflag, t.c_iflag, tmp.c_oflag, t.c_oflag,
15168 +               tmp.c_cflag, t.c_cflag, tmp.c_lflag, t.c_lflag);
15169 +
15170 +       if (t.c_lflag & ICANON) {
15171 +               tmp.c_cc[UW7_VEOF] = t.c_cc[VEOF];
15172 +               tmp.c_cc[UW7_VEOL] = t.c_cc[VEOL];
15173 +       } else {
15174 +               tmp.c_cc[UW7_VMIN] = t.c_cc[VMIN];
15175 +               tmp.c_cc[UW7_VTIME] = t.c_cc[VTIME];
15176 +       }
15177 +
15178 +       tmp.c_cc[UW7_VINTR] = t.c_cc[VINTR];
15179 +       tmp.c_cc[UW7_VQUIT] = t.c_cc[VQUIT];
15180 +       tmp.c_cc[UW7_VERASE] = t.c_cc[VERASE];
15181 +       tmp.c_cc[UW7_VKILL] = t.c_cc[VKILL];
15182 +       tmp.c_cc[UW7_VEOL2] = t.c_cc[VEOL2];
15183 +       tmp.c_cc[UW7_VSWTCH] = t.c_cc[VSWTC];
15184 +       tmp.c_cc[UW7_VSTART] = t.c_cc[VSTART];
15185 +       tmp.c_cc[UW7_VSTOP] = t.c_cc[VSTOP];
15186 +       tmp.c_cc[UW7_VSUSP] = tmp.c_cc[UW7_VDSUSP] = t.c_cc[VSUSP];
15187 +       tmp.c_cc[UW7_VREPRINT] = t.c_cc[VREPRINT];
15188 +       tmp.c_cc[UW7_VDISCARD] = t.c_cc[VDISCARD];
15189 +       tmp.c_cc[UW7_VWERASE] = t.c_cc[VWERASE];
15190 +       tmp.c_cc[UW7_VLNEXT] = t.c_cc[VLNEXT];
15191 +
15192 +       return copy_to_user(tios, &tmp, sizeof(struct uw7_termios)) ? -EFAULT : 0;
15193 +}
15194 +
15195 +static int ioctl_T(int fd, unsigned int cmd, void * arg)
15196 +{
15197 +       DBG(KERN_ERR "ioctl_T(%d,%x,%p)\n", fd, cmd, arg);
15198 +
15199 +       switch (cmd) {
15200 +               case UW7_TCSBRK:
15201 +                       return sys_ioctl(fd, TCSBRK, (long)arg);
15202 +
15203 +               case UW7_TCXONC:
15204 +                       return sys_ioctl(fd, TCXONC, (long)arg);
15205 +
15206 +               case UW7_TCFLSH:
15207 +                       return sys_ioctl(fd, TCFLSH, (long)arg);
15208 +
15209 +               case UW7_TIOCSWINSZ:
15210 +                       return sys_ioctl(fd, TIOCSWINSZ, (long)arg);
15211 +
15212 +               case UW7_TIOCGWINSZ:
15213 +                       return sys_ioctl(fd, TIOCGWINSZ, (long)arg);
15214 +
15215 +               case UW7_TCGETS:
15216 +                       return tioc_tcgets(fd, arg);
15217 +
15218 +               case UW7_TCSETS:
15219 +                       return tioc_tcsets(fd, TCSETS, arg);
15220 +
15221 +               case UW7_TCSETSW:
15222 +                       return tioc_tcsets(fd, TCSETSW, arg);
15223 +
15224 +               case UW7_TCSETSF:
15225 +                       return tioc_tcsets(fd, TCSETSF, arg);
15226 +       }
15227 +       return -EINVAL;
15228 +}
15229 diff -Nur kernel-source-2.6.16.orig/abi/uw7/lfs.c kernel-source-2.6.16/abi/uw7/lfs.c
15230 --- kernel-source-2.6.16.orig/abi/uw7/lfs.c     1970-01-01 10:00:00.000000000 +1000
15231 +++ kernel-source-2.6.16/abi/uw7/lfs.c  2006-04-27 18:50:24.000000000 +1000
15232 @@ -0,0 +1,241 @@
15233 +/*
15234 + * Copyright (c) 1999 Tigran Aivazian.
15235 + * Copyright (c) 2001 Christoph Hellwig.
15236 + * All rights reserved.
15237 + *
15238 + * This program is free software; you can redistribute it and/or modify
15239 + * it under the terms of the GNU General Public License as published by
15240 + * the Free Software Foundation; either version 2 of the License, or
15241 + * (at your option) any later version.
15242 + *
15243 + * This program is distributed in the hope that it will be useful,
15244 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
15245 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15246 + * GNU General Public License for more details.
15247 + *
15248 + * You should have received a copy of the GNU General Public License
15249 + * along with this program; if not, write to the Free Software
15250 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15251 + */
15252 +
15253 +#ident "%W% %G%"
15254 +
15255 +/*
15256 + * Support for the UnixWare 7.x LFS (Large File Summit) syscalls.
15257 + */
15258 +#include <linux/sched.h>
15259 +#include <linux/file.h>
15260 +#include <linux/fs.h>
15261 +#include <linux/statfs.h>
15262 +#include <linux/kernel.h>
15263 +#include <linux/unistd.h>
15264 +#include <linux/syscalls.h>
15265 +#include <linux/namei.h>
15266 +#include <asm/uaccess.h>
15267 +
15268 +#include <abi/uw7/resource.h>
15269 +#include <abi/uw7/statvfs.h>
15270 +
15271 +
15272 +/*
15273 + * The UnixWare 7 truncate64/fruncate64 syscalls are the same as in
15274 + * Linux, but we can't easily handle long long syscall parameters for
15275 + * lcall7, thus we have to fake two 32bit arguments instead.
15276 + *
15277 + * XXX: if do_sys_truncate/do_sys_ftruncate in fs/open.c were exported
15278 + *     we could get rid of one function call.
15279 + */
15280 +int
15281 +uw7_truncate64(const char *filename, u_int len, u_int len_hi)
15282 +{
15283 +       return sys_truncate64(filename, (len | (loff_t)len_hi << 32));
15284 +}
15285 +
15286 +int
15287 +uw7_ftruncate64(int fd, u_int len, u_int len_hi)
15288 +{
15289 +       return sys_ftruncate64(fd, (len | (loff_t)len_hi << 32));
15290 +}
15291 +
15292 +/*
15293 + * The SVR4 statvfs is basically our statfs, but of course only
15294 + * basically ....
15295 + */
15296 +static int
15297 +cp_uw7_statvfs64(struct super_block *sbp, struct kstatfs *srcp,
15298 +               struct uw7_statvfs64 *dstp)
15299 +{
15300 +       struct uw7_statvfs64    tmp;
15301 +
15302 +       memset(&tmp, 0, sizeof(struct uw7_statvfs64));
15303 +
15304 +       tmp.f_bsize  = srcp->f_bsize;
15305 +       tmp.f_frsize = srcp->f_bsize;
15306 +       tmp.f_blocks = srcp->f_blocks;
15307 +       tmp.f_bfree  = srcp->f_bfree;
15308 +       tmp.f_bavail = srcp->f_bavail;
15309 +       tmp.f_files  = srcp->f_files;
15310 +       tmp.f_ffree  = srcp->f_ffree;
15311 +       tmp.f_favail = srcp->f_ffree;
15312 +       tmp.f_fsid   = sbp->s_dev;
15313 +
15314 +       strcpy(tmp.f_basetype, sbp->s_type->name);
15315 +
15316 +       tmp.f_namemax = srcp->f_namelen;
15317 +
15318 +       if (copy_to_user(dstp, &tmp, sizeof(struct uw7_statvfs64)))
15319 +               return -EFAULT;
15320 +       return 0;
15321 +}
15322 +
15323 +int
15324 +uw7_statvfs64(char *filename, struct uw7_statvfs64 *stvfsp)
15325 +{
15326 +       struct nameidata        nd;
15327 +       int                     error;
15328 +
15329 +       error = user_path_walk(filename, &nd);
15330 +       if (!error) {
15331 +               struct super_block      *sbp = nd.dentry->d_inode->i_sb;
15332 +               struct kstatfs          tmp;
15333 +
15334 +               error = vfs_statfs(sbp, &tmp);
15335 +               if (!error && cp_uw7_statvfs64(sbp, &tmp, stvfsp))
15336 +                       error = -EFAULT;
15337 +               path_release(&nd);
15338 +       }
15339 +
15340 +       return (error);
15341 +}
15342 +
15343 +
15344 +int
15345 +uw7_fstatvfs64(int fd, struct uw7_statvfs64 *stvfsp)
15346 +{
15347 +       struct file             *fp;
15348 +       int                     error = -EBADF;
15349 +
15350 +       fp = fget(fd);
15351 +       if (fp) {
15352 +               struct super_block      *sbp = fp->f_dentry->d_inode->i_sb;
15353 +               struct kstatfs          tmp;
15354 +
15355 +               error = vfs_statfs(sbp, &tmp);
15356 +               if (!error && cp_uw7_statvfs64(sbp, &tmp, stvfsp))
15357 +                       error = -EFAULT;
15358 +               fput(fp);
15359 +       }
15360 +
15361 +       return (error);
15362 +}
15363 +
15364 +static __inline__ int
15365 +uw7_rlim64_to_user(int resource, struct uw7_rlim64 *rlimp)
15366 +{
15367 +       struct rlimit           *lxrlim = current->signal->rlim + resource;
15368 +       struct uw7_rlim64       rlim;
15369 +
15370 +       rlim.rlim_cur = lxrlim->rlim_cur;
15371 +       rlim.rlim_max = lxrlim->rlim_max;
15372 +
15373 +       if (copy_to_user(rlimp, &rlim, sizeof(struct uw7_rlim64)))
15374 +               return -EFAULT;
15375 +       return 0;
15376 +}
15377 +
15378 +int
15379 +uw7_getrlimit64(int resource, struct uw7_rlim64 *rlimp)
15380 +{
15381 +       if (resource > ARRAY_SIZE(uw7_to_linux_rlimit))
15382 +               return -EINVAL;
15383 +
15384 +       return (uw7_rlim64_to_user(uw7_to_linux_rlimit[resource], rlimp));
15385 +}
15386 +
15387 +static __inline__ int
15388 +uw7_check_rlimit64(int resource, const struct uw7_rlim64 *rlimp,
15389 +                  struct rlimit *lxrlimp)
15390 +{
15391 +       if ((rlimp->rlim_cur > RLIM_INFINITY) ||
15392 +           (rlimp->rlim_max > RLIM_INFINITY))
15393 +               return -EPERM;  /* XXX: actually this is wrong */
15394 +
15395 +       if (((rlimp->rlim_cur > lxrlimp->rlim_max) ||
15396 +            (rlimp->rlim_max > lxrlimp->rlim_max)) &&
15397 +             !capable(CAP_SYS_RESOURCE))
15398 +               return -EPERM;
15399 +
15400 +       if (resource == RLIMIT_NOFILE &&
15401 +           (rlimp->rlim_cur > NR_OPEN || rlimp->rlim_max > NR_OPEN))
15402 +               return -EPERM;
15403 +
15404 +       return 0;
15405 +}
15406 +
15407 +int
15408 +uw7_setrlimit64(int resource, const struct uw7_rlim64 *rlimp)
15409 +{
15410 +       struct rlimit           *lxrlim = current->signal->rlim + resource;
15411 +       struct uw7_rlim64       rlim;
15412 +
15413 +       if (resource > ARRAY_SIZE(uw7_to_linux_rlimit))
15414 +               return -EINVAL;
15415 +       if (copy_from_user(&rlim, rlimp, sizeof(struct uw7_rlim64)))
15416 +               return -EFAULT;
15417 +       if (uw7_check_rlimit64(resource, &rlim, lxrlim))
15418 +               return -EPERM;
15419 +
15420 +       /* XXX: this is non-atomic. */
15421 +       lxrlim->rlim_cur = rlim.rlim_cur;
15422 +       lxrlim->rlim_max = rlim.rlim_max;
15423 +
15424 +       return 0;
15425 +}
15426 +
15427 +/*
15428 + * 64bit lseek for UnixWare.
15429 + */
15430 +int
15431 +uw7_lseek64(int fd, u_int off, u_int off_hi, int orig)
15432 +{
15433 +       loff_t                  result;
15434 +       int                     err;
15435 +
15436 +       if (off_hi == (u_int)-1)
15437 +               off_hi = 0;
15438 +
15439 +       err  = sys_llseek(fd, (off_t) off_hi, off, &result, orig);
15440 +       if (err)
15441 +               return err;
15442 +       return (long)result; /* XXX: how does UnixWare return large results? */
15443 +}
15444 +
15445 +/*
15446 + * The UnixWare 7 pread64/pwrite64 syscalls are the same as in Linux,
15447 + * but we can't easily handle long long syscall parameters for lcall7,
15448 + * thus we have to fake two 32bit arguments instead.
15449 + */
15450 +ssize_t
15451 +uw7_pread64(int fd, char *bufp, int count, u_int pos, u_int pos_hi)
15452 +{
15453 +       return sys_pread64(fd, bufp, count, (pos | (loff_t)pos_hi << 32));
15454 +}
15455 +
15456 +ssize_t
15457 +uw7_pwrite64(int fd, char *bufp, int count, u_int pos, u_int pos_hi)
15458 +{
15459 +       return sys_pwrite64(fd, bufp, count, (pos | (loff_t)pos_hi << 32));
15460 +}
15461 +
15462 +/*
15463 + * Unlike Linux UnixWare 7 does not simply add O_LARGEFILE to flags in
15464 + * libc, so we have to do it.
15465 + * We call sys_open directly as sys_creat is just yet another wrapper.
15466 + */
15467 +#define UW7_CREAT64_FLAGS \
15468 +       (O_LARGEFILE | O_CREAT | O_WRONLY | O_TRUNC)
15469 +int
15470 +uw7_creat64(const char *filename, int mode)
15471 +{
15472 +       return sys_open(filename, UW7_CREAT64_FLAGS, mode);
15473 +}
15474 diff -Nur kernel-source-2.6.16.orig/abi/uw7/mac.c kernel-source-2.6.16/abi/uw7/mac.c
15475 --- kernel-source-2.6.16.orig/abi/uw7/mac.c     1970-01-01 10:00:00.000000000 +1000
15476 +++ kernel-source-2.6.16/abi/uw7/mac.c  2006-04-27 18:50:24.000000000 +1000
15477 @@ -0,0 +1,41 @@
15478 +/*
15479 + *   abi/uw7/mac.c - mldmode(2) and friends.
15480 + *
15481 + *  This software is under GPL
15482 + */
15483 +
15484 +#include <linux/sched.h>
15485 +#include <linux/errno.h>
15486 +
15487 +#undef DEBUG
15488 +
15489 +#ifdef DEBUG
15490 +#define DBG(x...)      printk(x)
15491 +#else
15492 +#define DBG(x...)
15493 +#endif
15494 +
15495 +#define UW7_MLD_REAL   1
15496 +#define UW7_MLD_VIRT   0
15497 +#define UW7_MLD_QUERY  2
15498 +
15499 +int uw7_mldmode(int mldmode)
15500 +{
15501 +       switch (mldmode) {
15502 +               case UW7_MLD_REAL:
15503 +                       DBG(KERN_ERR "UW7[%d]: mldmode(MLD_REAL)\n", current->pid);
15504 +                       break;
15505 +
15506 +               case UW7_MLD_VIRT:
15507 +                       DBG(KERN_ERR "UW7[%d]: mldmode(MLD_VIRT)\n", current->pid);
15508 +                       break;
15509 +
15510 +               case UW7_MLD_QUERY:
15511 +                       DBG(KERN_ERR "UW7[%d]: mldmode(MLD_QUERY)\n", current->pid);
15512 +                       return UW7_MLD_REAL;
15513 +
15514 +               default:
15515 +                       return -EINVAL;
15516 +       }
15517 +       return 0;
15518 +}
15519 diff -Nur kernel-source-2.6.16.orig/abi/uw7/Makefile kernel-source-2.6.16/abi/uw7/Makefile
15520 --- kernel-source-2.6.16.orig/abi/uw7/Makefile  1970-01-01 10:00:00.000000000 +1000
15521 +++ kernel-source-2.6.16/abi/uw7/Makefile       2006-04-27 18:50:24.000000000 +1000
15522 @@ -0,0 +1,8 @@
15523 +
15524 +abi-uw7-objs   := access.o context.o ioctl.o lfs.o mac.o \
15525 +                  misc.o mmap.o stat.o sysent.o
15526 +
15527 +obj-$(CONFIG_ABI_UW7)  += abi-uw7.o
15528 +
15529 +abi-uw7.o: $(abi-uw7-objs)
15530 +       $(LD) -r -o $@ $(abi-uw7-objs)
15531 diff -Nur kernel-source-2.6.16.orig/abi/uw7/misc.c kernel-source-2.6.16/abi/uw7/misc.c
15532 --- kernel-source-2.6.16.orig/abi/uw7/misc.c    1970-01-01 10:00:00.000000000 +1000
15533 +++ kernel-source-2.6.16/abi/uw7/misc.c 2006-04-27 18:50:24.000000000 +1000
15534 @@ -0,0 +1,66 @@
15535 +/*
15536 + *   abi/uw7/misc.c - various UW7 system calls.
15537 + *
15538 + *  This software is under GPL
15539 + */
15540 +
15541 +#include <linux/errno.h>
15542 +#include <linux/kernel.h>
15543 +#include <linux/sched.h>
15544 +#include <linux/file.h>
15545 +#include <linux/syscalls.h>
15546 +#include <asm/uaccess.h>
15547 +
15548 +
15549 +int uw7_sleep(int seconds)
15550 +{
15551 +       struct timespec t;
15552 +       mm_segment_t old_fs;
15553 +       int error;
15554 +
15555 +       t.tv_sec = seconds;
15556 +       t.tv_nsec = 0;
15557 +       old_fs = get_fs();
15558 +       set_fs(get_ds());
15559 +       error = sys_nanosleep(&t, NULL);
15560 +       set_fs(old_fs);
15561 +       return error;
15562 +}
15563 +
15564 +#define UW7_MAXUID      60002
15565 +
15566 +int uw7_seteuid(int uid)
15567 +{
15568 +       if (uid < 0 || uid > UW7_MAXUID)
15569 +               return -EINVAL;
15570 +       return sys_setreuid16(-1, uid);
15571 +}
15572 +
15573 +int uw7_setegid(int gid)
15574 +{
15575 +       if (gid < 0 || gid > UW7_MAXUID)
15576 +               return -EINVAL;
15577 +       return sys_setreuid16(-1, gid);
15578 +}
15579 +
15580 +/* can't call sys_pread64() directly because off is 32bit on UW7 */
15581 +int uw7_pread(unsigned int fd, char * buf, int count, long off)
15582 +{
15583 +       return sys_pread64(fd, buf, count, (loff_t)off);
15584 +}
15585 +
15586 +/* can't call sys_pwrite64() directly because off is 32bit on UW7 */
15587 +int uw7_pwrite(unsigned int fd, char * buf, int count, long off)
15588 +{
15589 +       return sys_pwrite64(fd, buf, count, (loff_t)off);
15590 +}
15591 +
15592 +int uw7_stty(int fd, int cmd)
15593 +{
15594 +       return -EIO;
15595 +}
15596 +
15597 +int uw7_gtty(int fd, int cmd)
15598 +{
15599 +       return -EIO;
15600 +}
15601 diff -Nur kernel-source-2.6.16.orig/abi/uw7/mmap.c kernel-source-2.6.16/abi/uw7/mmap.c
15602 --- kernel-source-2.6.16.orig/abi/uw7/mmap.c    1970-01-01 10:00:00.000000000 +1000
15603 +++ kernel-source-2.6.16/abi/uw7/mmap.c 2006-04-27 18:50:24.000000000 +1000
15604 @@ -0,0 +1,71 @@
15605 +/*
15606 + * Copyright (c) 1999 Tigran Aivazian.
15607 + * Copyright (c) 2001 Christoph Hellwig.
15608 + * All rights reserved.
15609 + *
15610 + * This program is free software; you can redistribute it and/or modify
15611 + * it under the terms of the GNU General Public License as published by
15612 + * the Free Software Foundation; either version 2 of the License, or
15613 + * (at your option) any later version.
15614 + *
15615 + * This program is distributed in the hope that it will be useful,
15616 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
15617 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15618 + * GNU General Public License for more details.
15619 + *
15620 + * You should have received a copy of the GNU General Public License
15621 + * along with this program; if not, write to the Free Software
15622 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15623 + */
15624 +
15625 +#ident "%W% %G%"
15626 +
15627 +/*
15628 + * Support for mmap on UnixWare 7.
15629 + */
15630 +#include <linux/mm.h>
15631 +#include <linux/errno.h>
15632 +#include <linux/file.h>
15633 +#include <linux/mman.h>
15634 +
15635 +#include <asm/uaccess.h>
15636 +
15637 +
15638 +/* the other MAP_XXX values are the same as on Linux/i386 */
15639 +#define UW7_MAP_ANONYMOUS      0x100
15640 +
15641 +int
15642 +uw7_mmap64(u_long addr, size_t len, int prot, int flags,
15643 +          int fd, u_int off, u_int off_hi)
15644 +{
15645 +       loff_t                  off64 = (off | ((loff_t)off_hi << 32));
15646 +       u_long                  pgoff = (off64 >> PAGE_SHIFT);
15647 +       int                     error = -EBADF;
15648 +       struct file             *fp = NULL;
15649 +
15650 +       if ((off64 + PAGE_ALIGN(len)) < off64)
15651 +               return -EINVAL;
15652 +
15653 +       if (!(off64 & ~PAGE_MASK))
15654 +               return -EINVAL;
15655 +
15656 +       if (flags & UW7_MAP_ANONYMOUS) {
15657 +               flags |= MAP_ANONYMOUS;
15658 +               flags &= ~UW7_MAP_ANONYMOUS;
15659 +       }
15660 +
15661 +       flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
15662 +       if (!(flags & MAP_ANONYMOUS)) {
15663 +               if (!(fp = fget(fd)))
15664 +                       goto out;
15665 +       }
15666 +
15667 +       down_write(&current->mm->mmap_sem);
15668 +       error = do_mmap_pgoff(fp, addr, len, prot, flags, pgoff);
15669 +       up_write(&current->mm->mmap_sem);
15670 +
15671 +       if (fp)
15672 +               fput(fp);
15673 +out:
15674 +       return (error);
15675 +}
15676 diff -Nur kernel-source-2.6.16.orig/abi/uw7/stat.c kernel-source-2.6.16/abi/uw7/stat.c
15677 --- kernel-source-2.6.16.orig/abi/uw7/stat.c    1970-01-01 10:00:00.000000000 +1000
15678 +++ kernel-source-2.6.16/abi/uw7/stat.c 2006-04-27 18:50:24.000000000 +1000
15679 @@ -0,0 +1,145 @@
15680 +/*
15681 + * Copyright (c) 2001 Christoph Hellwig.
15682 + * All rights reserved.
15683 + *
15684 + * This program is free software; you can redistribute it and/or modify
15685 + * it under the terms of the GNU General Public License as published by
15686 + * the Free Software Foundation; either version 2 of the License, or
15687 + * (at your option) any later version.
15688 + *
15689 + * This program is distributed in the hope that it will be useful,
15690 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
15691 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15692 + * GNU General Public License for more details.
15693 + *
15694 + * You should have received a copy of the GNU General Public License
15695 + * aint32_t with this program; if not, write to the Free Software
15696 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15697 + */
15698 +
15699 +#ident "%W% %G%"
15700 +
15701 +/*
15702 + * UnixWare 7.x xstat support.
15703 + */
15704 +#include <linux/kernel.h>
15705 +#include <linux/fs.h>
15706 +#include <linux/sched.h>
15707 +#include <linux/file.h>
15708 +#include <linux/string.h>
15709 +#include <asm/uaccess.h>
15710 +
15711 +#include <abi/uw7/types.h>
15712 +#include <abi/uw7/stat.h>
15713 +#include <abi/svr4/stat.h>
15714 +
15715 +#include <abi/util/trace.h>
15716 +#include <abi/util/stat.h>
15717 +
15718 +
15719 +enum {SVR4_stat = 1, SVR4_xstat = 2, UW7_stat64 = 4};
15720 +
15721 +int
15722 +report_uw7_stat64(struct kstat *stp, struct uw7_stat64 *bufp)
15723 +{
15724 +       struct uw7_stat64 buf;
15725 +
15726 +       memset(&buf, 0, sizeof(struct uw7_stat64));
15727 +
15728 +       buf.st_dev      = linux_to_uw7_dev_t(stp->dev);
15729 +       buf.st_ino      = linux_to_uw7_ino_t(stp->ino);
15730 +       buf.st_mode     = stp->mode;
15731 +       buf.st_nlink    = stp->nlink;
15732 +       buf.st_uid      = linux_to_uw7_uid_t(stp->uid);
15733 +       buf.st_gid      = linux_to_uw7_gid_t(stp->gid);
15734 +       buf.st_rdev     = linux_to_uw7_dev_t(stp->rdev);
15735 +       buf.st_size     = stp->size;
15736 +
15737 +       buf.st_atime.tv_sec = stp->atime.tv_sec;
15738 +       buf.st_mtime.tv_sec = stp->mtime.tv_sec;
15739 +       buf.st_ctime.tv_sec = stp->ctime.tv_sec;
15740 +
15741 +       buf.st_blksize  = stp->blksize;
15742 +       buf.st_blocks   = stp->blocks;
15743 +
15744 +       strcpy(buf.st_fstype, "ext2");
15745 +
15746 +       if (copy_to_user(bufp, &buf, sizeof(struct uw7_stat64)))
15747 +               return -EFAULT;
15748 +       return 0;
15749 +}
15750 +
15751 +int
15752 +uw7_xstat(int vers, char *filename, void *bufp)
15753 +{
15754 +       struct kstat st;
15755 +       int error;
15756 +
15757 +       error = vfs_stat(filename, &st);
15758 +       if (error)
15759 +               return error;
15760 +
15761 +       switch (vers) {
15762 +       case SVR4_stat:
15763 +               return report_svr4_stat(&st, bufp);
15764 +       case SVR4_xstat:
15765 +               return report_svr4_xstat(&st, bufp);
15766 +       case UW7_stat64:
15767 +               return report_uw7_stat64(&st, bufp);
15768 +       }
15769 +
15770 +#if defined(CONFIG_ABI_TRACE)
15771 +       abi_trace(ABI_TRACE_API, "xstat version %d not supported\n", vers);
15772 +#endif
15773 +       return -EINVAL;
15774 +}
15775 +
15776 +int
15777 +uw7_lxstat(int vers, char *filename, void *bufp)
15778 +{
15779 +       struct kstat st;
15780 +       int error;
15781 +
15782 +       error = vfs_lstat(filename, &st);
15783 +       if (error)
15784 +               return error;
15785 +
15786 +       switch (vers) {
15787 +       case SVR4_stat:
15788 +               return report_svr4_stat(&st, bufp);
15789 +       case SVR4_xstat:
15790 +               return report_svr4_xstat(&st, bufp);
15791 +       case UW7_stat64:
15792 +               return report_uw7_stat64(&st, bufp);
15793 +       }
15794 +
15795 +#if defined(CONFIG_ABI_TRACE)
15796 +       abi_trace(ABI_TRACE_API, "lxstat version %d not supported\n", vers);
15797 +#endif
15798 +       return -EINVAL;
15799 +}
15800 +
15801 +int
15802 +uw7_fxstat(int vers, int fd, void *bufp)
15803 +{
15804 +       struct kstat st;
15805 +       int error;
15806 +
15807 +       error = vfs_fstat(fd, &st);
15808 +       if (error)
15809 +               return error;
15810 +
15811 +       switch (vers) {
15812 +       case SVR4_stat:
15813 +               return report_svr4_stat(&st, bufp);
15814 +       case SVR4_xstat:
15815 +               return report_svr4_xstat(&st, bufp);
15816 +       case UW7_stat64:
15817 +               return report_uw7_stat64(&st, bufp);
15818 +       }
15819 +
15820 +#if defined(CONFIG_ABI_TRACE)
15821 +       abi_trace(ABI_TRACE_API, "fxstat version %d not supported\n", vers);
15822 +#endif
15823 +       return -EINVAL;
15824 +}
15825 diff -Nur kernel-source-2.6.16.orig/abi/uw7/sysent.c kernel-source-2.6.16/abi/uw7/sysent.c
15826 --- kernel-source-2.6.16.orig/abi/uw7/sysent.c  1970-01-01 10:00:00.000000000 +1000
15827 +++ kernel-source-2.6.16/abi/uw7/sysent.c       2006-04-27 18:50:24.000000000 +1000
15828 @@ -0,0 +1,478 @@
15829 +/*
15830 + * Copyright (c) 1999 Tigran Aivazian.
15831 + * Copyright (c) 2000, 2001 Christoph Hellwig.
15832 + * All rights reserved.
15833 + *
15834 + * This program is free software; you can redistribute it and/or modify
15835 + * it under the terms of the GNU General Public License as published by
15836 + * the Free Software Foundation; either version 2 of the License, or
15837 + * (at your option) any later version.
15838 + *
15839 + * This program is distributed in the hope that it will be useful,
15840 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
15841 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15842 + * GNU General Public License for more details.
15843 + *
15844 + * You should have received a copy of the GNU General Public License
15845 + * along with this program; if not, write to the Free Software
15846 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15847 + */
15848 +
15849 +#ident "%W% %G%"
15850 +
15851 +/*
15852 + * UnixWare 7/OpenUnix 8 personality switch.
15853 + */
15854 +
15855 +#include <linux/config.h>
15856 +#include <linux/module.h>
15857 +#include <linux/init.h>
15858 +#include <linux/kernel.h>
15859 +#include <linux/personality.h>
15860 +#include <linux/syscalls.h>
15861 +#include <linux/socket.h>
15862 +#include <linux/net.h>
15863 +#include <asm/uaccess.h>
15864 +
15865 +#include <abi/signal.h>
15866 +
15867 +#include <abi/svr4/sysent.h>
15868 +#include <abi/uw7/sysent.h>
15869 +
15870 +#include <abi/util/errno.h>
15871 +#include <abi/util/sysent.h>
15872 +#include <abi/util/socket.h>
15873 +
15874 +MODULE_DESCRIPTION("UnixWare7/OpenUnix8 personality");
15875 +MODULE_AUTHOR("Tigran Aivazian, Christoph Hellwig");
15876 +MODULE_LICENSE("GPL");
15877 +
15878 +
15879 +/*
15880 + * We could remove some of the long identity mapped runs but at the
15881 + * expense of extra comparisons for each mapping at run time...
15882 + */
15883 +static u_char uw7_err_table[] = {
15884 +/*   0 -   9 */   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,
15885 +/*  10 -  19 */  10,  11,  12,  13,  14,  15,  16,  17,  18,  19,
15886 +/*  20 -  29 */  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
15887 +/*  30 -  39 */  30,  31,  32,  33,  34,  45,  78,  46,  89,  93,
15888 +/*  40 -  49 */  90,  90,  35,  36,  37,  38,  39,  40,  41,  42,
15889 +/*  50 -  59 */  43,  44,  50,  51,  52,  53,  54,  55,  56,  57,
15890 +/*  60 -  69 */  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,
15891 +/*  70 -  79 */  70,  71,  74,  76,  77,  79,  80,  81,  82,  83,
15892 +/*  80 -  89 */  84,  85,  86,  87,  88,  91,  92,  94,  95,  96,
15893 +/*  90 -  99 */  97,  98,  99, 120, 121, 122, 123, 124, 125, 126,
15894 +/* 100 - 109 */ 127, 128, 129, 130, 131, 132, 133, 134, 143, 144,
15895 +/* 110 - 119 */ 145, 146, 147, 148, 149, 150,  22, 135, 137, 138,
15896 +/* 120 - 122 */ 139, 140,  28
15897 +};
15898 +
15899 +/*
15900 + * Map Linux RESTART* values (512,513,514) to EINTR
15901 + */
15902 +static u_char lnx_err_table[] = {
15903 +/* 512 - 514 */ EINTR, EINTR, EINTR
15904 +};
15905 +
15906 +struct map_segment uw7_err_map[] = {
15907 +       { 0,    0+sizeof(uw7_err_table)-1,      uw7_err_table },
15908 +       { 512,  512+sizeof(lnx_err_table)-1,    lnx_err_table },
15909 +       { -1 }
15910 +};
15911 +
15912 +static long linux_to_uw7_signals[NSIGNALS+1] = {
15913 +/*  0 -  3 */  0,              IBCS_SIGHUP,    IBCS_SIGINT,    IBCS_SIGQUIT,
15914 +/*  4 -  7 */  IBCS_SIGILL,    IBCS_SIGTRAP,   IBCS_SIGABRT,   -1,
15915 +/*  8 - 11 */  IBCS_SIGFPE,    IBCS_SIGKILL,   IBCS_SIGUSR1,   IBCS_SIGSEGV,
15916 +/* 12 - 15 */  IBCS_SIGUSR2,   IBCS_SIGPIPE,   IBCS_SIGALRM,   IBCS_SIGTERM,
15917 +/* 16 - 19 */  IBCS_SIGSEGV,   IBCS_SIGCHLD,   IBCS_SIGCONT,   IBCS_SIGSTOP,
15918 +/* 20 - 23 */  IBCS_SIGTSTP,   IBCS_SIGTTIN,   IBCS_SIGTTOU,   IBCS_SIGURG,
15919 +/* 24 - 27 */  IBCS_SIGGXCPU,  IBCS_SIGGXFSZ,  IBCS_SIGVTALRM, IBCS_SIGPROF,
15920 +/* 28 - 31 */  IBCS_SIGWINCH,  IBCS_SIGIO,     IBCS_SIGPWR,    -1,
15921 +/*     32 */   -1
15922 +};
15923 +
15924 +static long uw7_to_linux_signals[NSIGNALS+1] = {
15925 +/*  0 -  3 */  0,              SIGHUP,         SIGINT,         SIGQUIT,
15926 +/*  4 -  7 */  SIGILL,         SIGTRAP,        SIGIOT,         SIGUNUSED,
15927 +/*  8 - 11 */  SIGFPE,         SIGKILL,        SIGUNUSED,      SIGSEGV,
15928 +/* 12 - 15 */  SIGUNUSED,      SIGPIPE,        SIGALRM,        SIGTERM,
15929 +/* 16 - 19 */  SIGUSR1,        SIGUSR2,        SIGCHLD,        SIGPWR,
15930 +/* 20 - 23 */  SIGWINCH,       SIGURG,         SIGPOLL,        SIGSTOP,
15931 +/* 24 - 27 */  SIGTSTP,        SIGCONT,        SIGTTIN,        SIGTTOU,
15932 +/* 28 - 31 */  SIGVTALRM,      SIGPROF,        SIGXCPU,        SIGXFSZ,
15933 +/*     32 */   -1
15934 +};
15935 +
15936 +static char uw7_socktype[] = {
15937 +       SOCK_STREAM,
15938 +       SOCK_DGRAM,
15939 +       0,
15940 +       SOCK_RAW,
15941 +       SOCK_RDM,
15942 +       SOCK_SEQPACKET
15943 +};
15944 +
15945 +static struct map_segment uw7_socktype_map[] = {
15946 +       { 1, 6, uw7_socktype },
15947 +       { -1 }
15948 +};
15949 +
15950 +static struct map_segment uw7_sockopt_map[] =  {
15951 +       { 0x0001, 0x0001, (char *)SO_DEBUG },
15952 +       { 0x0002, 0x0002, (char *)__SO_ACCEPTCON },
15953 +       { 0x0004, 0x0004, (char *)SO_REUSEADDR },
15954 +       { 0x0008, 0x0008, (char *)SO_KEEPALIVE },
15955 +       { 0x0010, 0x0010, (char *)SO_DONTROUTE },
15956 +       { 0x0020, 0x0020, (char *)SO_BROADCAST },
15957 +       { 0x0040, 0x0040, (char *)SO_USELOOPBACK },
15958 +       { 0x0080, 0x0080, (char *)SO_LINGER },
15959 +       { 0x0100, 0x0100, (char *)SO_OOBINLINE },
15960 +       { 0x0200, 0x0200, (char *)SO_ORDREL },
15961 +       { 0x0400, 0x0400, (char *)SO_IMASOCKET },
15962 +       { 0x1001, 0x1001, (char *)SO_SNDBUF },
15963 +       { 0x1002, 0x1002, (char *)SO_RCVBUF },
15964 +       { 0x1003, 0x1003, (char *)SO_SNDLOWAT },
15965 +       { 0x1004, 0x1004, (char *)SO_RCVLOWAT },
15966 +       { 0x1005, 0x1005, (char *)SO_SNDTIMEO },
15967 +       { 0x1006, 0x1006, (char *)SO_RCVTIMEO },
15968 +       { 0x1007, 0x1007, (char *)SO_ERROR },
15969 +       { 0x1008, 0x1008, (char *)SO_TYPE },
15970 +       { 0x1009, 0x1009, (char *)SO_PROTOTYPE },
15971 +       { -1 }
15972 +};
15973 +
15974 +static struct map_segment uw7_af_map[] =  {
15975 +       { 0, 2, NULL },
15976 +       { -1 }
15977 +};
15978 +
15979 +
15980 +static struct sysent uw7_syscall_table[] = {
15981 +/*   0 */      { abi_syscall,          Fast,   "syscall",      ""      },
15982 +/*   2 */      { sys_exit,             1,      "exit",         "d"     },
15983 +/*   3 */      { abi_fork,             Spl,    "fork",         ""      },
15984 +/*   4 */      { abi_read,             3,      "read",         "dpd"   },
15985 +/*   5 */      { sys_write,            3,      "write",        "dpd"   },
15986 +/*   6 */      { svr4_open,            3,      "open",         "soo"   },
15987 +/*   7 */      { sys_close,            1,      "close",        "d"     },
15988 +/*   8 */      { abi_wait,             Spl,    "wait",         "xxx"   },
15989 +/*   9 */      { sys_creat,            2,      "creat",        "so"    },
15990 +/*  10 */      { sys_link,             2,      "link",         "ss"    },
15991 +/*  11 */      { sys_unlink,           1,      "unlink",       "s"     },
15992 +/*  12 */      { abi_exec,             Spl,    "exec",         "sxx"   },
15993 +/*  13 */      { sys_chdir,            1,      "chdir",        "s"     },
15994 +/*  14 */      { abi_time,             0,      "time",         ""      },
15995 +/*  15 */      { svr4_mknod,           3,      "mknod",        "soo"   },
15996 +/*  16 */      { sys_chmod,            2,      "chmod",        "so"    },
15997 +/*  17 */      { sys_chown,            3,      "chown",        "sdd"   },
15998 +/*  18 */      { abi_brk,              1,      "brk/break",    "x"     },
15999 +/*  19 */      { svr4_stat,            2,      "stat",         "sp"    },
16000 +/*  21 */      { sys_lseek,            3,      "seek/lseek",   "ddd"   },
16001 +/*  20 */      { abi_getpid,           Spl,    "getpid",       ""      },
16002 +/*  21 */      { 0,                    Ukn,    "mount",        ""      },
16003 +/*  22 */      { sys_umount,           1,      "umount",       "s"     },
16004 +/*  23 */      { sys_setuid,           1,      "setuid",       "d"     },
16005 +/*  24 */      { abi_getuid,           Spl,    "getuid",       ""      },
16006 +/*  25 */      { sys_stime,            1,      "stime",        "d"     },
16007 +/*  26 */      { 0,                    4,      "ptrace",       ""      },
16008 +/*  27 */      { sys_alarm,            1,      "alarm",        "d"     },
16009 +/*  28 */      { svr4_fstat,           2,      "fstat",        "dp"    },
16010 +/*  21 */      { sys_pause,            0,      "pause",        ""      },
16011 +/*  30 */      { sys_utime,            2,      "utime",        "xx"    },
16012 +/*  31 */      { uw7_stty,             2,      "stty",         "dd"    },
16013 +/*  32 */      { uw7_gtty,             2,      "gtty",         "dd"    },
16014 +/*  33 */      { uw7_access,           2,      "access",       "so"    },
16015 +/*  34 */      { sys_nice,             1,      "nice",         "d"     },
16016 +/*  35 */      { svr4_statfs,          4,      "statfs",       "spdd"  },
16017 +/*  36 */      { sys_sync,             0,      "sync",         ""      },
16018 +/*  37 */      { abi_kill,             2,      "kill",         "dd"    },
16019 +/*  38 */      { svr4_fstatfs,         4,      "fstatfs",      "dpdd"  },
16020 +/*  39 */      { abi_procids,          Spl,    "procids",      "d"     },
16021 +/*  40 */      { 0,                    Ukn,    "cxenix",       ""      },
16022 +/*  41 */      { sys_dup,              1,      "dup",          "d"     },
16023 +/*  42 */      { abi_pipe,             Spl,    "pipe",         ""      },
16024 +/*  43 */      { sys_times,            1,      "times",        "p"     },
16025 +/*  44 */      { 0,                    4,      "",             ""      },
16026 +/*  45 */      { 0,                    Ukn,    "plock",        ""      },
16027 +/*  46 */      { sys_setgid,           1,      "setgid",       "d"     },
16028 +/*  47 */      { abi_getgid,           Spl,    "getgid",       ""      },
16029 +/*  48 */      { abi_sigfunc,          Fast,   "sigfunc",      "xxx"   },
16030 +/*  49 */      { svr4_msgsys,          Spl,    "msgsys",       "dxddd" },
16031 +/*  50 */      { svr4_sysi86,          3,      "sysi86/sys3b", "d"     },
16032 +/*  51 */      { sys_acct,             1,      "acct/sysacct", "x"     },
16033 +/*  52 */      { svr4_shmsys,          Fast,   "shmsys",       "ddxo"  },
16034 +/*  53 */      { svr4_semsys,          Spl,    "semsys",       "dddx"  },
16035 +/*  54 */      { uw7_ioctl,            Spl,    "ioctl",        "dxx"   },
16036 +/*  55 */      { 0,                    3,      "uadmin",       "xxx"   },
16037 +/*  56 */      { 0,                    Ukn,    "unimpl/exch",  ""      },
16038 +/*  57 */      { v7_utsname,           1,      "utsys",        "x"     },
16039 +/*  58 */      { sys_fsync,            1,      "fsync",        "d"     },
16040 +/*  59 */      { abi_exec,             Spl,    "execv",        "spp"   },
16041 +/*  60 */      { sys_umask,            1,      "umask",        "o"     },
16042 +/*  61 */      { sys_chroot,           1,      "chroot",       "s"     },
16043 +/*  62 */      { svr4_fcntl,           3,      "fcntl",        "dxx"   },
16044 +/*  63 */      { svr4_ulimit,          2,      "ulimit",       "xx"    },
16045 +
16046 +/*
16047 + *     64-69 were reserved for the UNIX PC, and are now use for NUMA calls.
16048 + */
16049 +/*  64 */      { 0,                    Ukn,    "cg_ids",       ""      },
16050 +/*  65 */      { 0,                    Ukn,    "cg_processors",""      },
16051 +/*  66 */      { 0,                    Ukn,    "cg_info",      ""      },
16052 +/*  67 */      { 0,                    Ukn,    "cg_bind",      ""      },
16053 +/*  68 */      { 0,                    Ukn,    "cg_current",   ""      },
16054 +/*  69 */      { 0,                    Ukn,    "cg_memloc",    ""      },
16055 +/*  70 */      { 0,                    Ukn,    "unimpl/advfs", ""      },
16056 +/*  71 */      { 0,                    Ukn,    "unimpl/unadvfs",""     },
16057 +/*  72 */      { 0,                    Ukn,    "unimpl/rmount",""      },
16058 +/*  73 */      { 0,                    Ukn,    "unimpl/rumount",""     },
16059 +/*  74 */      { 0,                    Ukn,    "unimpl/rfstart",""     },
16060 +/*  75 */      { 0,                    Ukn,    "unimpl 75",    ""      },
16061 +/*  76 */      { 0,                    Ukn,    "unimpl/rdebug",""      },
16062 +/*  77 */      { 0,                    Ukn,    "unimpl/rfstop",""      },
16063 +/*  78 */      { 0,                    Ukn,    "rfsys",        ""      },
16064 +/*  89 */      { sys_rmdir,            1,      "rmdir",        "s"     },
16065 +/*  80 */      { sys_mkdir,            2,      "mkdir",        "so"    },
16066 +/*  81 */      { svr4_getdents,        3,      "getdents",     "dxd"   },
16067 +/*  82 */      { 0,                    Ukn,    "unimpl/libattach",""   },
16068 +/*  83 */      { 0,                    Ukn,    "unimpl/libdetach",""   },
16069 +/*  84 */      { svr4_sysfs,           3,      "sysfs",        "dxx"   },
16070 +/*  85 */      { svr4_getmsg,          Spl,    "getmsg",       "dxxx"  },
16071 +/*  86 */      { svr4_putmsg,          Spl,    "putmsg",       "dxxd"  },
16072 +/*  87 */      { sys_poll,             3,      "poll",         "xdd"   },
16073 +/*  88 */      { svr4_lstat,           2,      "lstat",        "sp"    },
16074 +/*  89 */      { sys_symlink,          2,      "symlink",      "ss"    },
16075 +/*  90 */      { sys_readlink,         3,      "readlink",     "spd"   },
16076 +/*  91 */      { sys_setgroups,        2,      "setgroups",    "dp"    },
16077 +/*  92 */      { sys_getgroups,        2,      "getgroups",    "dp"    },
16078 +/*  93 */      { sys_fchmod,           2,      "fchmod",       "do"    },
16079 +/*  94 */      { sys_fchown,           3,      "fchown",       "ddd"   },
16080 +/*  95 */      { abi_sigprocmask,      3,      "sigprocmask",  "dxx"   },
16081 +/*  96 */      { abi_sigsuspend,       Spl,    "sigsuspend",   "x"     },
16082 +/*  97 */      { uw7_sigaltstack,      2,      "sigaltstack",  "xx"    },
16083 +/*  98 */      { abi_sigaction,        3,      "sigaction",    "dxx"   },
16084 +/*  99 */      { svr4_sigpending,      2,      "sigpending",   "dp"    },
16085 +/* 100 */      { uw7_context,          Spl,    "ucontext",     ""      },
16086 +/* 101 */      { 0,                    Ukn,    "evsys",        ""      },
16087 +/* 102 */      { 0,                    Ukn,    "evtrapret",    ""      },
16088 +/* 103 */      { svr4_statvfs,         2,      "statvfs",      "sp"    },
16089 +/* 104 */      { svr4_fstatvfs,        2,      "fstatvfs",     "dp"    },
16090 +/* 105 */      { 0,                    Ukn,    "reserved 105", ""      },
16091 +/* 106 */      { 0,                    Ukn,    "nfssys",       ""      },
16092 +/* 107 */      { svr4_waitid,          4,      "waitid",       "ddxd"  },
16093 +/* 108 */      { 0,                    3,      "sigsendsys",   "ddd"   },
16094 +/* 109 */      { svr4_hrtsys,          Spl,    "hrtsys",       "xxx"   },
16095 +/* 110 */      { 0,                    3,      "acancel",      "dxd"   },
16096 +/* 111 */      { 0,                    Ukn,    "async",        ""      },
16097 +/* 112 */      { 0,                    Ukn,    "priocntlsys",  ""      },
16098 +/* 113 */      { svr4_pathconf,        2,      "pathconf",     "sd"    },
16099 +/* 114 */      { 0,                    3,      "mincore",      "xdx"   },
16100 +/* 115 */      { svr4_mmap,            6,      "mmap",         "xxxxdx"},
16101 +/* 116 */      { sys_mprotect,         3,      "mprotect",     "xdx"   },
16102 +/* 117 */      { sys_munmap,           2,      "munmap",       "xd"    },
16103 +/* 118 */      { svr4_fpathconf,       2,      "fpathconf",    "dd"    },
16104 +/* 119 */      { abi_fork,             Spl,    "vfork",        ""      },
16105 +/* 120 */      { sys_fchdir,           1,      "fchdir",       "d"     },
16106 +/* 121 */      { sys_readv,            3,      "readv",        "dxd"   },
16107 +/* 122 */      { sys_writev,           3,      "writev",       "dxd"   },
16108 +/* 123 */      { uw7_xstat,            3,      "xstat",        "dsx"   },
16109 +/* 124 */      { uw7_lxstat,           3,      "lxstat",       "dsx"   },
16110 +/* 125 */      { uw7_fxstat,           3,      "fxstat",       "ddx"   },
16111 +/* 126 */      { svr4_xmknod,          4,      "xmknod",       "dsox"  },
16112 +/* 127 */      { 0,                    Spl,    "syslocal",     "d"     },
16113 +/* 128 */      { svr4_getrlimit,       2,      "setrlimit",    "dx"    },
16114 +/* 129 */      { svr4_setrlimit,       2,      "getrlimit",    "dx"    },
16115 +/* 130 */      { sys_lchown,           3,      "lchown",       "sdd"   },
16116 +/* 131 */      { 0,                    Ukn,    "memcntl",      ""      },
16117 +#if defined(CONFIG_ABI_XTI)
16118 +/* 132 */      { svr4_getpmsg,         5,      "getpmsg",      "dxxxx" },
16119 +/* 133 */      { svr4_putpmsg,         5,      "putpmsg",      "dxxdd" },
16120 +#else
16121 +/* 132 */      { 0,                    5,      "getpmsg",      "dxxxx" },
16122 +/* 133 */      { 0,                    5,      "putpmsg",      "dxxdd" },
16123 +#endif
16124 +/* 134 */      { sys_rename,           2,      "rename",       "ss"    },
16125 +/* 135 */      { abi_utsname,          1,      "uname",        "x"     },
16126 +/* 136 */      { uw7_setegid,          1,      "setegid",      "d"     },
16127 +/* 137 */      { svr4_sysconfig,       1,      "sysconfig",    "d"     },
16128 +/* 138 */      { 0,                    Ukn,    "adjtime",      ""      },
16129 +/* 139 */      { svr4_sysinfo,         3,      "systeminfo",   "dsd"   },
16130 +/* 140 */      { socksys_syscall,      1,      "socksys_syscall","x"   },
16131 +/* 141 */      { uw7_seteuid,          1,      "seteuid",      "d"     },
16132 +/* 142 */      { 0,                    Ukn,    "unimpl 142",   ""      },
16133 +/* 143 */      { 0,                    Ukn,    "keyctl",       ""      },
16134 +/* 144 */      { 0,                    2,      "secsys",       "dx"    },
16135 +/* 145 */      { 0,                    4,      "filepriv",     "sdxd"  },
16136 +/* 146 */      { 0,                    3,      "procpriv",     "dxd"   },
16137 +/* 147 */      { 0,                    3,      "devstat",      "sdx"   },
16138 +/* 148 */      { 0,                    5,      "aclipc",       "ddddx" },
16139 +/* 149 */      { 0,                    3,      "fdevstat",     "ddx"   },
16140 +/* 150 */      { 0,                    3,      "flvlfile",     "ddx"   },
16141 +/* 151 */      { 0,                    3,      "lvlfile",      "sdx"   },
16142 +/* 152 */      { 0,                    Ukn,    "sendv",        ""      },
16143 +/* 153 */      { 0,                    2,      "lvlequal",     "xx"    },
16144 +/* 154 */      { 0,                    2,      "lvlproc",      "dx"    },
16145 +/* 155 */      { 0,                    Ukn,    "unimpl 155",   ""      },
16146 +/* 156 */      { 0,                    4,      "lvlipc",       "dddx"  },
16147 +/* 157 */      { 0,                    4,      "acl",          "sddx"  },
16148 +/* 158 */      { 0,                    Ukn,    "auditevt",     ""      },
16149 +/* 159 */      { 0,                    Ukn,    "auditctl",     ""      },
16150 +/* 160 */      { 0,                    Ukn,    "auditdmp",     ""      },
16151 +/* 161 */      { 0,                    Ukn,    "auditlog",     ""      },
16152 +/* 162 */      { 0,                    Ukn,    "auditbuf",     ""      },
16153 +/* 163 */      { 0,                    2,      "lvldom",       "xx"    },
16154 +/* 164 */      { 0,                    Ukn,    "lvlvfs",       ""      },
16155 +/* 165 */      { 0,                    2,      "mkmld",        "so"    },
16156 +/* 166 */      { uw7_mldmode,          1,      "mldmode",      "d"     },
16157 +/* 167 */      { 0,                    2,      "secadvise",    "xx"    },
16158 +/* 168 */      { 0,                    Ukn,    "online",       ""      },
16159 +/* 169 */      { sys_setitimer,        3,      "setitimer",    "dxx"   },
16160 +/* 170 */      { sys_getitimer,        2,      "getitimer",    "dx"    },
16161 +/* 171 */      { sys_gettimeofday,     2,      "gettimeofday", "xx"    },
16162 +/* 172 */      { sys_settimeofday,     2,      "settimeofday", "xx"    },
16163 +/* 173 */      { 0,                    Ukn,    "lwpcreate",    ""      },
16164 +/* 174 */      { 0,                    Ukn,    "lwpexit",      ""      },
16165 +/* 175 */      { 0,                    Ukn,    "lwpwait",      ""      },
16166 +/* 176 */      { 0,                    Ukn,    "lwpself",      ""      },
16167 +/* 177 */      { 0,                    Ukn,    "lwpinfo",      ""      },
16168 +/* 178 */      { 0,                    Ukn,    "lwpprivate",   ""      },
16169 +/* 179 */      { 0,                    Ukn,    "processorbind",""      },
16170 +/* 180 */      { 0,                    Ukn,    "processorexbind",""    },
16171 +/* 181 */      { 0,                    Ukn,    "unimpl 181",   ""      },
16172 +/* 182 */      { 0,                    Ukn,    "sendv64",      ""      },
16173 +/* 183 */      { 0,                    Ukn,    "prepblock",    ""      },
16174 +/* 184 */      { 0,                    Ukn,    "block",        ""      },
16175 +/* 185 */      { 0,                    Ukn,    "rdblock",      ""      },
16176 +/* 186 */      { 0,                    Ukn,    "unblock",      ""      },
16177 +/* 187 */      { 0,                    Ukn,    "cancelblock",  ""      },
16178 +/* 188 */      { 0,                    Ukn,    "unimpl 188",   ""      },
16179 +/* 189 */      { uw7_pread,            4,      "pread",        "dsdd"  },
16180 +/* 190 */      { uw7_pwrite,           4,      "pwrite",       "dsdd"  },
16181 +/* 191 */      { sys_truncate,         2,      "truncate",     "sd"    },
16182 +/* 192 */      { sys_ftruncate,        2,      "ftruncate",    "dd"    },
16183 +/* 193 */      { 0,                    Ukn,    "lwpkill",      ""      },
16184 +/* 194 */      { 0,                    Ukn,    "sigwait",      ""      },
16185 +/* 195 */      { abi_fork,             Spl,    "fork1",        ""      },
16186 +/* 196 */      { abi_fork,             Spl,    "forkall",      ""      },
16187 +
16188 +/*
16189 + *     197-202 are for loadable kernel module support.
16190 + */
16191 +/* 197 */      { 0,                    Ukn,    "modload",      ""      },
16192 +/* 198 */      { 0,                    Ukn,    "moduload",     ""      },
16193 +/* 199 */      { 0,                    Ukn,    "modpath",      ""      },
16194 +/* 200 */      { 0,                    Ukn,    "modstat",      ""      },
16195 +/* 201 */      { 0,                    Ukn,    "modadm",       ""      },
16196 +/* 202 */      { 0,                    Ukn,    "getksym",      ""      },
16197 +
16198 +/* 203 */      { 0,                    Ukn,    "lwpsuspend",   ""      },
16199 +/* 204 */      { 0,                    Ukn,    "lwpcontinue",  ""      },
16200 +/* 205 */      { 0,                    Ukn,    "priocntllst",  ""      },
16201 +/* 206 */      { uw7_sleep,            1,      "sleep",        "d"     },
16202 +
16203 +/*
16204 + *     207-209 are for post/wait synchronisation.
16205 + */
16206 +/* 207 */      { 0,                    Ukn,    "lwp_sema_wait",""      },
16207 +/* 208 */      { 0,                    Ukn,    "lwp_sema_post",""      },
16208 +/* 209 */      { 0,                    Ukn,    "lwp_sema_trywait",""   },
16209 +
16210 +/* 210 */      { 0,                    Ukn,    "reserved 210", ""      },
16211 +/* 211 */      { 0,                    Ukn,    "unused 211",   ""      },
16212 +/* 212 */      { 0,                    Ukn,    "unused 212",   ""      },
16213 +/* 213 */      { 0,                    Ukn,    "unused 213",   ""      },
16214 +/* 214 */      { 0,                    Ukn,    "unused 214",   ""      },
16215 +/* 215 */      { 0,                    Ukn,    "unused 215",   ""      },
16216 +
16217 +/*
16218 + *     216-226 are for LFS (Large File Summit) support
16219 + */
16220 +/* 216 */      { uw7_fstatvfs64,       2,      "fstatvfs64",   "dp"    },
16221 +/* 217 */      { uw7_statvfs64,        2,      "statvfs64",    "sp"    },
16222 +/* 218 */      { uw7_ftruncate64,      3,      "ftruncate64",  "sdd"   },
16223 +/* 219 */      { uw7_truncate64,       3,      "truncate64",   "ddd"   },
16224 +/* 220 */      { uw7_getrlimit64,      2,      "getrlimit64",  "dp"    },
16225 +/* 221 */      { uw7_setrlimit64,      2,      "setrlimit64",  "dp"    },
16226 +/* 222 */      { uw7_lseek64,          4,      "lseek64",      "dddd"  },
16227 +/* 223 */      { uw7_mmap64,           7,      "mmap64",      "xxxxdxx"},
16228 +/* 224 */      { uw7_pread64,          5,      "pread64",      "dsddd" },
16229 +/* 225 */      { uw7_pwrite64,         5,      "pwrite64",     "dsddd" },
16230 +/* 226 */      { uw7_creat64,          2,      "creat64",      "so"    },
16231 +
16232 +/* 227 */      { 0,                    Ukn,    "dshmsys",      ""      },
16233 +/* 228 */      { 0,                    Ukn,    "invlpg",       ""      },
16234 +
16235 +/*
16236 + *     229-234 are used for SSI clustering (Nonstop cluster)
16237 + */
16238 +/* 229 */   { 0,                       Ukn,    "rfork1",       ""      },
16239 +/* 230 */   { 0,                       Ukn,    "rforkall",     ""      },
16240 +/* 231 */   { 0,                       Ukn,    "rexecve",      ""      },
16241 +/* 232 */   { 0,                       Ukn,    "migrate",      ""      },
16242 +/* 233 */   { 0,                       Ukn,    "kill3",        ""      },
16243 +/* 234 */   { 0,                       Ukn,    "ssisys",       ""      },
16244 +
16245 +/*
16246 + *     235-248 are for kernel-based sockets (Yeah, SVR5 finally got sockets)
16247 + */
16248 +/* 235 */   { 0,                       Ukn,    "xaccept",      ""      },
16249 +/* 236 */   { 0,                       Ukn,    "xbind",        ""      },
16250 +/* 237 */   { 0,                       Ukn,    "xbindresvport",""      },
16251 +/* 238 */   { 0,                       Ukn,    "xconnect",     ""      },
16252 +/* 239 */   { 0,                       Ukn,    "xgetsockaddr", ""      },
16253 +/* 240 */   { 0,                       Ukn,    "xgetsockopt",  ""      },
16254 +/* 241 */   { 0,                       Ukn,    "xlisten",      ""      },
16255 +/* 242 */   { 0,                       Ukn,    "xrecvmsg",     ""      },
16256 +/* 243 */   { 0,                       Ukn,    "xsendmsg",     ""      },
16257 +/* 244 */   { 0,                       Ukn,    "xsetsockaddr", ""      },
16258 +/* 245 */   { 0,                       Ukn,    "xsetsockopt",  ""      },
16259 +/* 246 */   { 0,                       Ukn,    "xshutdown",    ""      },
16260 +/* 247 */   { 0,                       Ukn,    "xsocket",      ""      },
16261 +/* 248 */   { 0,                       Ukn,    "xsocketpair",  ""      },
16262 +
16263 +/* 249 */   { 0,                       Ukn,    "unused 249",   ""      },
16264 +/* 250 */   { 0,                       Ukn,    "unused 250",   ""      },
16265 +};
16266 +
16267 +
16268 +static void
16269 +uw7_lcall7(int segment, struct pt_regs *regs)
16270 +{
16271 +       int sysno = regs->eax & 0xff;
16272 +
16273 +       if (sysno >= ARRAY_SIZE(uw7_syscall_table))
16274 +               set_error(regs, iABI_errors(-EINVAL));
16275 +       else
16276 +               lcall7_dispatch(regs, &uw7_syscall_table[sysno], 1);
16277 +}
16278 +
16279 +static struct exec_domain uw7_exec_domain = {
16280 +       name:           "UnixWare 7",
16281 +       handler:        uw7_lcall7,
16282 +       pers_low:       14 /* PER_UW7 */,
16283 +       pers_high:      14 /* PER_UW7 */,
16284 +       signal_map:     uw7_to_linux_signals,
16285 +       signal_invmap:  linux_to_uw7_signals,
16286 +       err_map:        uw7_err_map,
16287 +       socktype_map:   uw7_socktype_map,
16288 +       sockopt_map:    uw7_sockopt_map,
16289 +       af_map:         uw7_af_map,
16290 +       module:         THIS_MODULE
16291 +};
16292 +
16293 +static int __init
16294 +init_uw7(void)
16295 +{
16296 +       return register_exec_domain(&uw7_exec_domain);
16297 +}
16298 +
16299 +static void __exit
16300 +cleanup_uw7(void)
16301 +{
16302 +       unregister_exec_domain(&uw7_exec_domain);
16303 +}
16304 +
16305 +module_init(init_uw7);
16306 +module_exit(cleanup_uw7);
16307 diff -Nur kernel-source-2.6.16.orig/abi/wyse/Makefile kernel-source-2.6.16/abi/wyse/Makefile
16308 --- kernel-source-2.6.16.orig/abi/wyse/Makefile 1970-01-01 10:00:00.000000000 +1000
16309 +++ kernel-source-2.6.16/abi/wyse/Makefile      2006-04-27 18:50:24.000000000 +1000
16310 @@ -0,0 +1,7 @@
16311 +
16312 +abi-wyse-objs  := sysent.o ptrace.o socket.o
16313 +
16314 +obj-$(CONFIG_ABI_WYSE)         += abi-wyse.o
16315 +
16316 +abi-wyse.o: $(abi-wyse-objs)
16317 +       $(LD) -r -o $@ $(abi-wyse-objs)
16318 diff -Nur kernel-source-2.6.16.orig/abi/wyse/ptrace.c kernel-source-2.6.16/abi/wyse/ptrace.c
16319 --- kernel-source-2.6.16.orig/abi/wyse/ptrace.c 1970-01-01 10:00:00.000000000 +1000
16320 +++ kernel-source-2.6.16/abi/wyse/ptrace.c      2006-04-27 18:50:24.000000000 +1000
16321 @@ -0,0 +1,113 @@
16322 +/*
16323 + * ptrace.c - Wyse V/386 ptrace(2) support.
16324 + *
16325 + * Copyright (c) 1995 Mike Jagdis (jaggy@purplet.demon.co.uk)
16326 + */
16327 +
16328 +#ident "%W% %G%"
16329 +
16330 +/*
16331 + * This file is nearly identical to abi/sco/ptrace.c, please keep it in sync.
16332 + */
16333 +#include <linux/module.h>
16334 +#include <linux/errno.h>
16335 +#include <linux/sched.h>
16336 +#include <linux/ptrace.h>
16337 +#include <linux/kernel.h>
16338 +#include <linux/mm.h>
16339 +#include <linux/personality.h>
16340 +#include <linux/user.h>
16341 +#define __KERNEL_SYSCALLS__
16342 +#include <linux/unistd.h>
16343 +
16344 +#include <asm/uaccess.h>
16345 +
16346 +#include <abi/signal.h>
16347 +#include <abi/util/trace.h>
16348 +
16349 +
16350 +#define NREGS  19
16351 +#define U(X)   ((unsigned long)&((struct user *)0)->X)
16352 +
16353 +
16354 +static unsigned long wysev386_to_linux_reg[NREGS] = {
16355 +       U(regs.es),     U(regs.ds),     U(regs.edi),    U(regs.esi),
16356 +       U(regs.ebp),    U(regs.esp),
16357 +       U(regs.ebx),    U(regs.edx),    U(regs.ecx),    U(regs.eax),
16358 +       U(signal        /* Trap */),
16359 +       U(reserved      /* ERR */),
16360 +       U(regs.eip),    U(regs.cs),
16361 +       U(regs.eflags),
16362 +       U(regs.esp      /* UESP */),
16363 +       U(regs.ss),
16364 +       U(regs.fs),     U(regs.gs)
16365 +};
16366 +
16367 +static const char *regnam[] = {
16368 +       "EBX", "ECX", "EDX", "ESI", "EDI", "EBP", "EAX",
16369 +       "DS", "ES", "FS", "GS", "ORIG_EAX", "EIP", "CS",
16370 +       "EFL", "UESP", "SS"
16371 +};
16372 +
16373 +
16374 +int
16375 +wyse_ptrace(int req, int pid, u_long addr, u_long data)
16376 +{
16377 +       u_long                  res;
16378 +
16379 +       /*
16380 +        * Slight variations between iBCS and Linux codes.
16381 +        */
16382 +       if (req == PTRACE_ATTACH)
16383 +               req = 10;
16384 +       else if (req == PTRACE_DETACH)
16385 +               req = 11;
16386 +
16387 +       if (req == 3 || req == 6) {
16388 +               /* get offset of u_ar0 */
16389 +               if (addr == 0x1292)
16390 +                       return 0x4000;
16391 +
16392 +               /* remap access to the registers. */
16393 +               if ((addr & 0xff00) == 0x4000) { /* Registers */
16394 +                       addr = (addr & 0xff) >> 2;
16395 +                       if (addr > NREGS)
16396 +                               return -EIO;
16397 +                       addr = wysev386_to_linux_reg[addr];
16398 +                       if (addr == -1)
16399 +                               return -EIO;
16400 +               }
16401 +       }
16402 +
16403 +       if (req == 7 && data > 0) {
16404 +               if (data > NSIGNALS)
16405 +                       return -EIO;
16406 +               data = current_thread_info()->exec_domain->signal_map[data];
16407 +       }
16408 +
16409 +       if (req == 1 || req == 2 || req == 3) {
16410 +               mm_segment_t    old_fs = get_fs();
16411 +               int             error;
16412 +
16413 +               set_fs(get_ds());
16414 +               error = sys_ptrace(req, pid, addr, (long)&res);
16415 +               set_fs(old_fs);
16416 +
16417 +               if (error)
16418 +                       return (error);
16419 +       }
16420 +
16421 +#if defined(CONFIG_ABI_TRACE)
16422 +       if (req == 3 || req == 6) {
16423 +               abi_trace(ABI_TRACE_API, "%ld [%s] = 0x%08lx\n",
16424 +                       addr >> 2, (addr >> 2) < ARRAY_SIZE(regnam) ?
16425 +                               regnam[addr >> 2] : "???",
16426 +                       req == 3 ? res : data);
16427 +       }
16428 +#endif
16429 +
16430 +       if (req == 1 || req == 2 || req == 3)
16431 +               return (res);
16432 +
16433 +       return sys_ptrace(req, pid, addr, data);
16434 +}
16435 diff -Nur kernel-source-2.6.16.orig/abi/wyse/socket.c kernel-source-2.6.16/abi/wyse/socket.c
16436 --- kernel-source-2.6.16.orig/abi/wyse/socket.c 1970-01-01 10:00:00.000000000 +1000
16437 +++ kernel-source-2.6.16/abi/wyse/socket.c      2006-04-27 18:50:24.000000000 +1000
16438 @@ -0,0 +1,307 @@
16439 +/*
16440 + * Copyright (c) 1994,1996 Mike Jagdis.
16441 + * Copyright (c) 2001 Christoph Hellwig.
16442 + * All rights reserved.
16443 + *
16444 + * This program is free software; you can redistribute it and/or modify
16445 + * it under the terms of the GNU General Public License as published by
16446 + * the Free Software Foundation; either version 2 of the License, or
16447 + * (at your option) any later version.
16448 + *
16449 + * This program is distributed in the hope that it will be useful,
16450 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
16451 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16452 + * GNU General Public License for more details.
16453 + *
16454 + * You should have received a copy of the GNU General Public License
16455 + * along with this program; if not, write to the Free Software
16456 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16457 + *
16458 + */
16459 +
16460 +#ident "%W% %G%"
16461 +
16462 +/*
16463 + * BSD-style socket support for Wyse/V386.
16464 + */
16465 +#include <linux/net.h>
16466 +#include <linux/personality.h>
16467 +#include <linux/syscalls.h>
16468 +#include <linux/utsname.h>
16469 +#include <linux/signal.h>
16470 +#include <linux/wait.h>
16471 +#include <linux/socket.h>
16472 +#include <linux/net.h>
16473 +#include <asm/uaccess.h>
16474 +
16475 +#include <abi/util/map.h>
16476 +#include <abi/util/socket.h>
16477 +#include <abi/wyse/sysent.h>
16478 +
16479 +
16480 +int wyse_gethostname(char *name, int len)
16481 +{
16482 +       int error = 0;
16483 +       char *p;
16484 +
16485 +       down_read(&uts_sem);
16486 +       if (!access_ok(VERIFY_WRITE, name, len)) {
16487 +               error = -EFAULT;
16488 +               --len;
16489 +               for (p = system_utsname.nodename; *p && len; p++,len--) {
16490 +                       __put_user(*p, name);
16491 +                       name++;
16492 +               }
16493 +               __put_user('\0', name);
16494 +       }
16495 +       up_read(&uts_sem);
16496 +       return error;
16497 +}
16498 +
16499 +int wyse_getdomainname(char *name, int len)
16500 +{
16501 +       int error;
16502 +       char *p;
16503 +
16504 +       down_read(&uts_sem);
16505 +       if (!access_ok(VERIFY_WRITE, name, len)) {
16506 +               error = -EFAULT;
16507 +               --len;
16508 +               for (p = system_utsname.domainname; *p && len; p++,len--) {
16509 +                       __put_user(*p, name);
16510 +                       name++;
16511 +               }
16512 +               __put_user('\0', name);
16513 +       }
16514 +       up_read(&uts_sem);
16515 +       return error;
16516 +}
16517 +
16518 +int wyse_wait3(int *loc)
16519 +{
16520 +       pid_t pid;
16521 +       int res;
16522 +
16523 +       pid = sys_wait4(-1, loc, WNOHANG, 0);
16524 +       if (!loc)
16525 +               return pid;
16526 +
16527 +       get_user(res, (unsigned long *)loc);
16528 +
16529 +       if ((res & 0xff) == 0x7f) {
16530 +               int sig = (res >> 8) & 0xff;
16531 +
16532 +               sig = current_thread_info()->exec_domain->signal_map[sig];
16533 +               res = (res & (~0xff00)) | (sig << 8);
16534 +               put_user(res, (unsigned long *)loc);
16535 +       } else if (res && res == (res & 0xff)) {
16536 +               res = current_thread_info()->exec_domain->signal_map[res & 0x7f];
16537 +               put_user(res, (unsigned long *)loc);
16538 +       }
16539 +
16540 +       return pid;
16541 +}
16542 +
16543 +int wyse_socket(int family, int type, int protocol)
16544 +{
16545 +       family = map_value(current_thread_info()->exec_domain->af_map, family, 0);
16546 +       type = map_value(current_thread_info()->exec_domain->socktype_map, family, 0);
16547 +
16548 +       return sys_socket(family, type, protocol);
16549 +}
16550 +
16551 +int wyse_setsockopt(int fd, int level, int optname, char *optval, int optlen)
16552 +{
16553 +       switch (level) {
16554 +       case 0: /* IPPROTO_IP aka SOL_IP */
16555 +               if (--optname == 0)
16556 +                       optname = 4;
16557 +               if (optname > 4) {
16558 +                       optname += 24;
16559 +                       if (optname <= 33)
16560 +                               optname--;
16561 +                       if (optname < 32 || optname > 36)
16562 +                               return -EINVAL;
16563 +                       break;
16564 +               }
16565 +       case 0xffff:
16566 +               level = SOL_SOCKET;
16567 +               optname = map_value(current_thread_info()->exec_domain->sockopt_map, optname, 0);
16568 +               switch (optname) {
16569 +               case SO_LINGER:
16570 +                       /*
16571 +                        * SO_LINGER takes a struct linger as the argument
16572 +                        * but some code uses an int and expects to get
16573 +                        * away without an error. Sigh...
16574 +                        */
16575 +                       if (optlen == sizeof(int))
16576 +                               return 0;
16577 +                       break;
16578 +               /*
16579 +                * The following are not currently implemented under Linux
16580 +                * so we must fake them in reasonable ways.
16581 +                * (Only SO_PROTOTYPE is documented in SCO's man page).
16582 +                */
16583 +               case SO_PROTOTYPE:
16584 +               case SO_ORDREL:
16585 +               case SO_SNDTIMEO:
16586 +               case SO_RCVTIMEO:
16587 +                       return -ENOPROTOOPT;
16588 +
16589 +               case SO_USELOOPBACK:
16590 +               case SO_SNDLOWAT:
16591 +               case SO_RCVLOWAT:
16592 +                       return 0;
16593 +
16594 +               /*
16595 +                * The following are not currenty implemented under Linux
16596 +                * and probably aren't settable anyway.
16597 +                */
16598 +               case SO_IMASOCKET:
16599 +                       return -ENOPROTOOPT;
16600 +               default:
16601 +                       break;
16602 +               }
16603 +       default:
16604 +               /*
16605 +                * XXX We assume everything else uses the same level and
16606 +                * XXX option numbers.  This is true for IPPROTO_TCP(/SOL_TCP)
16607 +                * XXX and TCP_NDELAY but is known to be incorrect for other
16608 +                * XXX potential options :-(.
16609 +                */
16610 +               break;
16611 +       }
16612 +
16613 +       return sys_setsockopt(fd, level, optname, optval, optlen);
16614 +}
16615 +
16616 +int wyse_getsockopt(int fd, int level, int optname, char *optval, int *optlen)
16617 +{
16618 +       unsigned int len;
16619 +       int val;
16620 +
16621 +       if (get_user(len,optlen))
16622 +               return -EFAULT;
16623 +       if (len < 0)
16624 +               return -EINVAL;
16625 +
16626 +       switch (level) {
16627 +       case 0: /* IPPROTO_IP aka SOL_IP */
16628 +               if (--optname == 0)
16629 +                       optname = 4;
16630 +               if (optname > 4) {
16631 +                       optname += 24;
16632 +                       if (optname <= 33)
16633 +                               optname--;
16634 +                       if (optname < 32 || optname > 36)
16635 +                               return -EINVAL;
16636 +                       break;
16637 +               }
16638 +       case 0xffff:
16639 +               level = SOL_SOCKET;
16640 +               optname = map_value(current_thread_info()->exec_domain->sockopt_map, optname, 0);
16641 +               switch (optname) {
16642 +               case SO_LINGER:
16643 +                       /*
16644 +                        * SO_LINGER takes a struct linger as the argument
16645 +                        * but some code uses an int and expects to get
16646 +                        * away without an error. Sigh...
16647 +                        */
16648 +                       if (len != sizeof(int))
16649 +                               goto native;
16650 +
16651 +                       val = 0;
16652 +                       break;
16653 +               /*
16654 +                * The following are not currently implemented under Linux
16655 +                * so we must fake them in reasonable ways.
16656 +                * (Only SO_PROTOTYPE is documented in SCO's man page).
16657 +                */
16658 +               case SO_PROTOTYPE:
16659 +                       val = 0;
16660 +                       break;
16661 +
16662 +               case SO_ORDREL:
16663 +               case SO_SNDTIMEO:
16664 +               case SO_RCVTIMEO:
16665 +                       return -ENOPROTOOPT;
16666 +
16667 +               case SO_USELOOPBACK:
16668 +               case SO_SNDLOWAT:
16669 +               case SO_RCVLOWAT:
16670 +                       return 0;
16671 +
16672 +               /*
16673 +                * The following are not currenty implemented under Linux
16674 +                * and probably aren't settable anyway.
16675 +                */
16676 +               case SO_IMASOCKET:
16677 +                       val = 1;
16678 +                       break;
16679 +               default:
16680 +                       goto native;
16681 +               }
16682 +
16683 +               if (len > sizeof(int))
16684 +                       len = sizeof(int);
16685 +               if (copy_to_user(optval, &val, len))
16686 +                       return -EFAULT;
16687 +               if (put_user(len, optlen))
16688 +                        return -EFAULT;
16689 +               return 0;
16690 +
16691 +       default:
16692 +               /*
16693 +                * XXX We assume everything else uses the same level and
16694 +                * XXX option numbers.  This is true for IPPROTO_TCP(/SOL_TCP)
16695 +                * XXX and TCP_NDELAY but is known to be incorrect for other
16696 +                * XXX potential options :-(.
16697 +                */
16698 +               break;
16699 +       }
16700 +
16701 +native:
16702 +       return sys_getsockopt(fd, level, optname, optval, optlen);
16703 +}
16704 +
16705 +int wyse_recvfrom(int fd, void *buff, size_t size, unsigned flags,
16706 +                 struct sockaddr *addr, int *addr_len)
16707 +{
16708 +       int error;
16709 +
16710 +       error = sys_recvfrom(fd, buff, size, flags, addr, addr_len);
16711 +       if (error == -EAGAIN)
16712 +               error = -EWOULDBLOCK;
16713 +       return error;
16714 +}
16715 +
16716 +int wyse_recv(int fd, void *buff, size_t size, unsigned flags)
16717 +{
16718 +       int error;
16719 +
16720 +       error = sys_recvfrom(fd, buff, size, flags, NULL, NULL);
16721 +       if (error == -EAGAIN)
16722 +               error = -EWOULDBLOCK;
16723 +       return error;
16724 +}
16725 +
16726 +int wyse_sendto(int fd, void *buff, size_t len, unsigned flags,
16727 +               struct sockaddr *addr, int addr_len)
16728 +{
16729 +       int error;
16730 +
16731 +       error = sys_sendto(fd, buff, len, flags, addr, addr_len);
16732 +       if (error == -EAGAIN)
16733 +               error = -EWOULDBLOCK;
16734 +       return error;
16735 +}
16736 +
16737 +int wyse_send(int fd, void *buff, size_t len, unsigned flags)
16738 +{
16739 +       int error;
16740 +
16741 +       error = sys_sendto(fd, buff, len, flags, NULL, 0);
16742 +       if (error == -EAGAIN)
16743 +               error = -EWOULDBLOCK;
16744 +       return error;
16745 +}
16746 diff -Nur kernel-source-2.6.16.orig/abi/wyse/sysent.c kernel-source-2.6.16/abi/wyse/sysent.c
16747 --- kernel-source-2.6.16.orig/abi/wyse/sysent.c 1970-01-01 10:00:00.000000000 +1000
16748 +++ kernel-source-2.6.16/abi/wyse/sysent.c      2006-04-27 18:50:24.000000000 +1000
16749 @@ -0,0 +1,394 @@
16750 +/*
16751 + * Copyright (c) 2001 Christoph Hellwig.
16752 + * All rights reserved.
16753 + *
16754 + * This program is free software; you can redistribute it and/or modify
16755 + * it under the terms of the GNU General Public License as published by
16756 + * the Free Software Foundation; either version 2 of the License, or
16757 + * (at your option) any later version.
16758 + *
16759 + * This program is distributed in the hope that it will be useful,
16760 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
16761 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16762 + * GNU General Public License for more details.
16763 + *
16764 + * You should have received a copy of the GNU General Public License
16765 + * along with this program; if not, write to the Free Software
16766 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16767 + *
16768 + */
16769 +
16770 +#ident "%W% %G%"
16771 +
16772 +/*
16773 + * Wyse/V386 personality switch.
16774 + */
16775 +#include <linux/module.h>
16776 +#include <linux/init.h>
16777 +#include <linux/kernel.h>
16778 +#include <linux/personality.h>
16779 +#include <linux/sched.h>
16780 +#include <linux/syscalls.h>
16781 +#include <linux/socket.h>
16782 +#include <linux/net.h>
16783 +#include <asm/uaccess.h>
16784 +
16785 +#include <abi/svr4/sysent.h>
16786 +#include <abi/wyse/sysent.h>
16787 +
16788 +#include <abi/signal.h>
16789 +
16790 +#include <abi/util/errno.h>
16791 +#include <abi/util/sysent.h>
16792 +#include <abi/util/socket.h>
16793 +
16794 +
16795 +MODULE_DESCRIPTION("Wyse/V386 personality");
16796 +MODULE_AUTHOR("Christoph Hellwig, partially taken from iBCS");
16797 +MODULE_LICENSE("GPL");
16798 +
16799 +
16800 +/*
16801 + * local functions
16802 + */
16803 +static void    wyse_class_nfs(struct pt_regs *);
16804 +static void    wyse_class_tcp(struct pt_regs *);
16805 +
16806 +
16807 +/*
16808 + * local variables
16809 + */
16810 +static u_char wyse_err_table[] = {
16811 +       /*   0 -   9 */   0,   1,   2,    3,   4,   5,   6,   7,   8,   9,
16812 +       /*  10 -  19 */   10,  11,  12,  13,  14,  15,  16,  17,  18,  19,
16813 +       /*  20 -  29 */   20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
16814 +       /*  30 -  39 */   30,  31,  32,  33,  34,  45,  78,  46,  228, 46,
16815 +       /*  40 -  49 */   22, 231, 227, 200,  37,  38,  39,  40,  41,  42,
16816 +       /*  50 -  59 */   43,  44,  50,  51,  52,  53,  54,  55,  56,  57,
16817 +       /*  60 -  69 */   60,  61,  62,  63,  64,  65,  66,  67,  68,  69,
16818 +       /*  70 -  79 */   70,  71,  74,  76,  77,  22,  80,  81,  82,  83,
16819 +       /*  80 -  89 */   84,  85,  86,  87,  22,   4,  22, 233, 203, 204,
16820 +       /*  90 -  99 */  205, 206, 207, 208, 209, 210, 211, 212, 213, 214,
16821 +       /* 100 - 109 */  215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
16822 +       /* 110 - 119 */  225, 226, 229, 230, 202, 201, 237, 135, 137, 138,
16823 +       /* 120 - 122 */  139, 140, 234
16824 +};
16825 +
16826 +/*
16827 + * Map Linux RESTART* values (512,513,514) to EINTR
16828 + */
16829 +static u_char lnx_err_table[] = {
16830 +       /* 512 - 514 */ EINTR, EINTR, EINTR
16831 +};
16832 +
16833 +static struct map_segment wyse_err_map[] = {
16834 +       { 0,    0 + sizeof(wyse_err_table) - 1,         wyse_err_table },
16835 +       { 512,  512 + sizeof(lnx_err_table) - 1,        lnx_err_table },
16836 +       { -1 }
16837 +};
16838 +
16839 +static long linux_to_wyse_signals[NSIGNALS+1] = {
16840 +/*  0 -  3 */  0,              IBCS_SIGHUP,    IBCS_SIGINT,    IBCS_SIGQUIT,
16841 +/*  4 -  7 */  IBCS_SIGILL,    IBCS_SIGTRAP,   IBCS_SIGABRT,   -1,
16842 +/*  8 - 11 */  IBCS_SIGFPE,    IBCS_SIGKILL,   IBCS_SIGUSR1,   IBCS_SIGSEGV,
16843 +/* 12 - 15 */  IBCS_SIGUSR2,   IBCS_SIGPIPE,   IBCS_SIGALRM,   IBCS_SIGTERM,
16844 +/* 16 - 19 */  IBCS_SIGSEGV,   IBCS_SIGCHLD,   IBCS_SIGCONT,   IBCS_SIGSTOP,
16845 +/* 20 - 23 */  IBCS_SIGTSTP,   IBCS_SIGTTIN,   IBCS_SIGTTOU,   IBCS_SIGURG,
16846 +/* 24 - 27 */  IBCS_SIGGXCPU,  IBCS_SIGGXFSZ,  IBCS_SIGVTALRM, IBCS_SIGPROF,
16847 +/* 28 - 31 */  IBCS_SIGWINCH,  IBCS_SIGIO,     IBCS_SIGPWR,    -1,
16848 +/*     32 */   -1
16849 +};
16850 +
16851 +static long wyse_to_linux_signals[NSIGNALS+1] = {
16852 +/*  0 -  3 */  0,              SIGHUP,         SIGINT,         SIGQUIT,
16853 +/*  4 -  7 */  SIGILL,         SIGTRAP,        SIGIOT,         SIGUNUSED,
16854 +/*  8 - 11 */  SIGFPE,         SIGKILL,        SIGUNUSED,      SIGSEGV,
16855 +/* 12 - 15 */  SIGUNUSED,      SIGPIPE,        SIGALRM,        SIGTERM,
16856 +/* 16 - 19 */  SIGUSR1,        SIGUSR2,        SIGCHLD,        SIGPWR,
16857 +/* 20 - 23 */  SIGWINCH,       SIGURG,         SIGPOLL,        SIGSTOP,
16858 +/* 24 - 27 */  SIGTSTP,        SIGCONT,        SIGTTIN,        SIGTTOU,
16859 +/* 28 - 31 */  SIGVTALRM,      SIGPROF,        SIGXCPU,        SIGXFSZ,
16860 +/*     32 */   -1
16861 +};
16862 +
16863 +static char wyse_socktype[] = {
16864 +       SOCK_STREAM,
16865 +       SOCK_DGRAM,
16866 +       0,
16867 +       SOCK_RAW,
16868 +       SOCK_RDM,
16869 +       SOCK_SEQPACKET
16870 +};
16871 +
16872 +static struct map_segment wyse_socktype_map[] = {
16873 +       { 1, 6, wyse_socktype },
16874 +       { -1 }
16875 +};
16876 +
16877 +static struct map_segment wyse_sockopt_map[] =  {
16878 +       { 0x0001, 0x0001, (char *)SO_DEBUG },
16879 +       { 0x0002, 0x0002, (char *)__SO_ACCEPTCON },
16880 +       { 0x0004, 0x0004, (char *)SO_REUSEADDR },
16881 +       { 0x0008, 0x0008, (char *)SO_KEEPALIVE },
16882 +       { 0x0010, 0x0010, (char *)SO_DONTROUTE },
16883 +       { 0x0020, 0x0020, (char *)SO_BROADCAST },
16884 +       { 0x0040, 0x0040, (char *)SO_USELOOPBACK },
16885 +       { 0x0080, 0x0080, (char *)SO_LINGER },
16886 +       { 0x0100, 0x0100, (char *)SO_OOBINLINE },
16887 +       { 0x0200, 0x0200, (char *)SO_ORDREL },
16888 +       { 0x0400, 0x0400, (char *)SO_IMASOCKET },
16889 +       { 0x1001, 0x1001, (char *)SO_SNDBUF },
16890 +       { 0x1002, 0x1002, (char *)SO_RCVBUF },
16891 +       { 0x1003, 0x1003, (char *)SO_SNDLOWAT },
16892 +       { 0x1004, 0x1004, (char *)SO_RCVLOWAT },
16893 +       { 0x1005, 0x1005, (char *)SO_SNDTIMEO },
16894 +       { 0x1006, 0x1006, (char *)SO_RCVTIMEO },
16895 +       { 0x1007, 0x1007, (char *)SO_ERROR },
16896 +       { 0x1008, 0x1008, (char *)SO_TYPE },
16897 +       { 0x1009, 0x1009, (char *)SO_PROTOTYPE },
16898 +       { -1 }
16899 +};
16900 +
16901 +static struct map_segment wyse_af_map[] =  {
16902 +       { 0, 2, NULL },
16903 +       { -1 }
16904 +};
16905 +
16906 +
16907 +static struct sysent wyse_nfscall_table[] = {
16908 +/*   0 */      { 0,                    Ukn,    "nfs_svc",      ""      },
16909 +/*   1 */      { 0,                    Ukn,    "async_daemon", ""      },
16910 +/*   2 */      { 0,                    Ukn,    "nfs_getfh",    ""      },
16911 +/*   3 */      { 0,                    Ukn,    "nfsmount",     ""      },
16912 +};
16913 +
16914 +static struct sysent wyse_tcpcall_table[] = {
16915 +/*   0 */      { sys_select,           5,      "select",       "dxxxx" },
16916 +/*   1 */      { wyse_socket,          3,      "socket",       "ddd"   },
16917 +/*   2 */      { sys_connect,          3,      "connect",      "dxd"   },
16918 +/*   3 */      { sys_accept,           3,      "accept",       "dxx"   },
16919 +/*   4 */      { wyse_send,            4,      "send",         "dxdd"  },
16920 +/*   5 */      { wyse_recv,            4,      "recv",         "dxdd"  },
16921 +/*   6 */      { sys_bind,             3,      "bind",         "dxd"   },
16922 +/*   7 */      { wyse_setsockopt,      5,      "setsockopt",   "dddxx" },
16923 +/*   8 */      { sys_listen,           2,      "listen",       "dd"    },
16924 +/*   9 */      { 0,                    3,      "recvmsg",      "dxd"   },
16925 +/*  10 */      { 0,                    3,      "sendmsg",      "dxd"   },
16926 +/*  11 */      { wyse_getsockopt,      5,      "getsockopt",   "dddxx" },
16927 +/*  12 */      { wyse_recvfrom,        6,      "recvfrom",     "dxddxd"},
16928 +/*  13 */      { wyse_sendto,          6,      "sendto",       "dxddxd"},
16929 +/*  14 */      { sys_shutdown,         2,      "shutdown",     "dd"    },
16930 +/*  15 */      { sys_socketpair,       4,      "socketpair",   "dddx"  },
16931 +/*  16 */      { 0,                    Ukn,    "trace",        ""      },
16932 +/*  17 */      { sys_getpeername,      3,      "getpeername",  "dxx"   },
16933 +/*  18 */      { sys_getsockname,      Spl,    "getsockname",  "dxx"   },
16934 +/*  19 */      { wyse_wait3,           1,      "wait3",        "x"     },
16935 +};
16936 +
16937 +
16938 +static struct sysent wyse_syscall_table[] = {
16939 +/*   0 */      { abi_syscall,          Fast,   "syscall",      ""      },
16940 +/*   1 */      { sys_exit,             1,      "exit",         "d"     },
16941 +/*   2 */      { abi_fork,             Spl,    "fork",         ""      },
16942 +/*   3 */      { abi_read,             3,      "read",         "dpd"   },
16943 +/*   4 */      { sys_write,            3,      "write",        "dpd"   },
16944 +/*   5 */      { svr4_open,            3,      "open",         "soo"   },
16945 +/*   6 */      { sys_close,            1,      "close",        "d"     },
16946 +/*   7 */      { abi_wait,             Spl,    "wait",         "xxx"   },
16947 +/*   8 */      { sys_creat,            2,      "creat",        "so"    },
16948 +/*   9 */      { sys_link,             2,      "link",         "ss"    },
16949 +/*  10 */      { sys_unlink,           1,      "unlink",       "s"     },
16950 +/*  11 */      { abi_exec,             Spl,    "exec",         "sxx"   },
16951 +/*  12 */      { sys_chdir,            1,      "chdir",        "s"     },
16952 +/*  13 */      { abi_time,             0,      "time",         ""      },
16953 +/*  14 */      { svr4_mknod,           3,      "mknod",        "soo"   },
16954 +/*  15 */      { sys_chmod,            2,      "chmod",        "so"    },
16955 +/*  16 */      { sys_chown,            3,      "chown",        "sdd"   },
16956 +/*  17 */      { abi_brk,              1,      "brk/break",    "x"     },
16957 +/*  18 */      { svr4_stat,            2,      "stat",         "sp"    },
16958 +/*  19 */      { sys_lseek,            3,      "seek/lseek",   "ddd"   },
16959 +/*  20 */      { abi_getpid,           Spl,    "getpid",       ""      },
16960 +/*  21 */      { 0,                    Ukn,    "mount",        ""      },
16961 +/*  22 */      { sys_umount,           1,      "umount",       "s"     },
16962 +/*  23 */      { sys_setuid,           1,      "setuid",       "d"     },
16963 +/*  24 */      { abi_getuid,           Spl,    "getuid",       ""      },
16964 +/*  25 */      { sys_stime,            1,      "stime",        "d"     },
16965 +/*  26 */      { wyse_ptrace,          4,      "ptrace",       "xdxx"  },
16966 +/*  27 */      { sys_alarm,            1,      "alarm",        "d"     },
16967 +/*  28 */      { svr4_fstat,           2,      "fstat",        "dp"    },
16968 +/*  29 */      { sys_pause,            0,      "pause",        ""      },
16969 +/*  30 */      { sys_utime,            2,      "utime",        "xx"    },
16970 +/*  31 */      { 0,                    Ukn,    "stty",         ""      }, /*   31 */
16971 +/*  32 */      { 0,                    Ukn,    "gtty",         ""      },
16972 +/*  33 */      { sys_access,           2,      "access",       "so"    },
16973 +/*  34 */      { sys_nice,             1,      "nice",         "d"     },
16974 +/*  35 */      { svr4_statfs,          4,      "statfs",       "spdd"  },
16975 +/*  36 */      { sys_sync,             0,      "sync",         ""      },
16976 +/*  37 */      { abi_kill,             2,      "kill",         "dd"    },
16977 +/*  38 */      { svr4_fstatfs,         4,      "fstatfs",      "dpdd"  },
16978 +/*  39 */      { abi_procids,          Spl,    "procids",      "d"     },
16979 +/*  40 */      { 0,                    Ukn,    "cxenix",       ""      },
16980 +/*  41 */      { sys_dup,              1,      "dup",          "d"     },
16981 +/*  42 */      { abi_pipe,             Spl,    "pipe",         ""      },
16982 +/*  43 */      { sys_times,            1,      "times",        "p"     },
16983 +/*  44 */      { 0,                    4,      "prof",         "xxxx"  },
16984 +/*  45 */      { 0,                    Ukn,    "lock/plock",   ""      },
16985 +/*  46 */      { sys_setgid,           1,      "setgid",       "d"     },
16986 +/*  47 */      { abi_getgid,           Spl,    "getgid",       ""      },
16987 +/*  48 */      { abi_sigfunc,          Fast,   "sigfunc",      "xxx"   },
16988 +/*  49 */      { svr4_msgsys,          Spl,    "msgsys",       "dxddd" },
16989 +/*  50 */      { svr4_sysi86,          3,      "sysi86/sys3b", "d"     },
16990 +/*  51 */      { sys_acct,             1,      "acct/sysacct", "x"     },
16991 +/*  52 */      { svr4_shmsys,          Fast,   "shmsys",       "ddxo"  },
16992 +/*  53 */      { svr4_semsys,          Spl,    "semsys",       "dddx"  },
16993 +/*  54 */      { svr4_ioctl,           Spl,    "ioctl",        "dxx"   },
16994 +/*  55 */      { 0,                    3,      "uadmin",       "xxx"   },
16995 +/*  56 */      { 0,                    Ukn,    "?",            ""      },
16996 +/*  57 */      { v7_utsname,           1,      "utsys",        "x"     },
16997 +/*  58 */      { sys_fsync,            1,      "fsync",        "d"     },
16998 +/*  59 */      { abi_exec,             Spl,    "execv",        "spp"   },
16999 +/*  60 */      { sys_umask,            1,      "umask",        "o"     },
17000 +/*  61 */      { sys_chroot,           1,      "chroot",       "s"     },
17001 +/*  62 */      { svr4_fcntl,           3,      "fcntl",        "dxx"   },
17002 +/*  63 */      { svr4_ulimit,          2,      "ulimit",       "xx"    },
17003 +/*  64 */      { 0,                    Ukn,    "?",            ""      },
17004 +/*  65 */      { 0,                    Ukn,    "?",            ""      },
17005 +/*  66 */      { 0,                    Ukn,    "?",            ""      },
17006 +/*  67 */      { 0,                    Ukn,    "?",            ""      },
17007 +/*  68 */      { 0,                    Ukn,    "?",            ""      },
17008 +/*  69 */      { 0,                    Ukn,    "?",            ""      },
17009 +/*  70 */      { 0,                    Ukn,    "advfs",        ""      },
17010 +/*  71 */      { 0,                    Ukn,    "unadvfs",      ""      },
17011 +/*  72 */      { 0,                    Ukn,    "rmount",       ""      },
17012 +/*  73 */      { 0,                    Ukn,    "rumount",      ""      },
17013 +/*  74 */      { 0,                    Ukn,    "rfstart",      ""      },
17014 +/*  75 */      { 0,                    Ukn,    "?",            ""      },
17015 +/*  76 */      { 0,                    Ukn,    "rdebug",       ""      },
17016 +/*  77 */      { 0,                    Ukn,    "rfstop",       ""      },
17017 +/*  78 */      { 0,                    Ukn,    "rfsys",        ""      },
17018 +/*  79 */      { sys_rmdir,            1,      "rmdir",        "s"     },
17019 +/*  80 */      { abi_mkdir,            2,      "mkdir",        "so"    },
17020 +/*  81 */      { svr4_getdents,        3,      "getdents",     "dxd"   },
17021 +/*  82 */      { 0,                    Ukn,    "libattach",    ""      },
17022 +/*  83 */      { 0,                    Ukn,    "libdetach",    ""      },
17023 +/*  84 */      { svr4_sysfs,           3,      "sysfs",        "dxx"   },
17024 +/*  85 */      { svr4_getmsg,          Spl,    "getmsg",       "dxxx"  },
17025 +/*  86 */      { svr4_putmsg,          Spl,    "putmsg",       "dxxd"  },
17026 +/*  87 */      { sys_poll,             3,      "poll",         "xdd"   },
17027 +/*  88 */      { 0,                    Ukn,    "nosys88",      ""      },
17028 +/*  89 */      { 0,                    Ukn,    "nosys89",      ""      },
17029 +/*  90 */      { 0,                    Ukn,    "nosys90",      ""      },
17030 +/*  91 */      { 0,                    Ukn,    "nosys91",      ""      },
17031 +/*  92 */      { 0,                    Ukn,    "nosys92",      ""      },
17032 +/*  93 */      { 0,                    Ukn,    "nosys93",      ""      },
17033 +/*  94 */      { 0,                    Ukn,    "nosys94",      ""      },
17034 +/*  95 */      { 0,                    Ukn,    "nosys95",      ""      },
17035 +/*  96 */      { 0,                    Ukn,    "nosys96",      ""      },
17036 +/*  97 */      { 0,                    Ukn,    "nosys97",      ""      },
17037 +/*  98 */      { 0,                    Ukn,    "nosys98",      ""      },
17038 +/*  99 */      { 0,                    Ukn,    "nosys99",      ""      },
17039 +/* 100 */      { 0,                    Ukn,    "nosys100",     ""      },
17040 +/* 101 */      { 0,                    Ukn,    "nosys101",     ""      },
17041 +/* 102 */      { 0,                    Ukn,    "nosys102",     ""      },
17042 +/* 103 */      { 0,                    Ukn,    "nosys103",     ""      },
17043 +/* 104 */      { 0,                    Ukn,    "nosys104",     ""      },
17044 +/* 105 */      { 0,                    Ukn,    "nosys105",     ""      },
17045 +/* 106 */      { 0,                    Ukn,    "nosys106",     ""      },
17046 +/* 107 */      { 0,                    Ukn,    "nosys107",     ""      },
17047 +/* 108 */      { 0,                    Ukn,    "nosys108",     ""      },
17048 +/* 109 */      { 0,                    Ukn,    "nosys109",     ""      },
17049 +/* 110 */      { 0,                    Ukn,    "nosys110",     ""      },
17050 +/* 111 */      { 0,                    Ukn,    "nosys111",     ""      },
17051 +/* 112 */      { 0,                    Ukn,    "nosys112",     ""      },
17052 +/* 113 */      { 0,                    Ukn,    "nosys113",     ""      },
17053 +/* 114 */      { 0,                    Ukn,    "nosys114",     ""      },
17054 +/* 115 */      { 0,                    Ukn,    "nosys115",     ""      },
17055 +/* 116 */      { 0,                    Ukn,    "nosys116",     ""      },
17056 +/* 117 */      { 0,                    Ukn,    "nosys117",     ""      },
17057 +/* 118 */      { 0,                    Ukn,    "nosys118",     ""      },
17058 +/* 119 */      { 0,                    Ukn,    "nosys119",     ""      },
17059 +/* 120 */      { 0,                    Ukn,    "nosys120",     ""      },
17060 +/* 121 */      { 0,                    Ukn,    "nosys121",     ""      },
17061 +/* 122 */      { 0,                    Ukn,    "nosys122",     ""      },
17062 +/* 123 */      { 0,                    Ukn,    "nosys123",     ""      },
17063 +/* 124 */      { 0,                    Ukn,    "nosys124",     ""      },
17064 +/* 125 */      { 0,                    Ukn,    "nosys125",     ""      },
17065 +/* 126 */      { 0,                    Ukn,    "nosys126",     ""      },
17066 +/* 127 */      { 0,                    Ukn,    "nosys127",     ""      },
17067 +/* 128 */      { svr4_lstat,           2,      "lstat",        "sp"    },
17068 +/* 129 */      { sys_readlink,         3,      "readlink",     "spd"   },
17069 +/* 130 */      { sys_symlink,          2,      "symlink",      "ss"    },
17070 +/* 131 */      { wyse_class_tcp,       Fast,   "",             ""      },
17071 +/* 132 */      { wyse_class_nfs,       Fast,   "",             ""      },
17072 +/* 133 */      { wyse_gethostname,     2,      "gethostname",  "xd"    },
17073 +/* 134 */      { sys_sethostname,      2,      "sethostname",  "sd"    },
17074 +/* 135 */      { wyse_getdomainname,   2,      "getdomainname","xd"    },
17075 +/* 136 */      { sys_setdomainname,    2,      "setdomainname","sd"    },
17076 +/* 137 */      { 0,                    Ukn,    "?",            ""      },
17077 +/* 138 */      { sys_setreuid,         2,      "setreuid",     "dd"    },
17078 +/* 139 */      { sys_setregid,         2,      "setregid",     "dd"    },
17079 +};
17080 +
17081 +static void
17082 +wyse_class_nfs(struct pt_regs *regs)
17083 +{
17084 +
17085 +       int sysno = regs->eax >> 8;
17086 +
17087 +       if (sysno >= ARRAY_SIZE(wyse_nfscall_table))
17088 +               set_error(regs, iABI_errors(-EINVAL));
17089 +       else
17090 +               lcall7_dispatch(regs, &wyse_nfscall_table[sysno], 1);
17091 +}
17092 +
17093 +static void
17094 +wyse_class_tcp(struct pt_regs *regs)
17095 +{
17096 +       int sysno = regs->eax >> 8;
17097 +
17098 +       if (sysno >= ARRAY_SIZE(wyse_tcpcall_table))
17099 +               set_error(regs, iABI_errors(-EINVAL));
17100 +       else
17101 +               lcall7_dispatch(regs, &wyse_tcpcall_table[sysno], 1);
17102 +}
17103 +
17104 +static void
17105 +wyse_lcall7(int segment, struct pt_regs *regs)
17106 +{
17107 +       int sysno = regs->eax & 0xff;
17108 +
17109 +       if (sysno >= ARRAY_SIZE(wyse_syscall_table))
17110 +               set_error(regs, iABI_errors(-EINVAL));
17111 +       else
17112 +               lcall7_dispatch(regs, &wyse_syscall_table[sysno], 1);
17113 +}
17114 +
17115 +static struct exec_domain wyse_exec_domain = {
17116 +       name:           "Wyse/386",
17117 +       handler:        wyse_lcall7,
17118 +       pers_low:       4 /* PER_WYSEV386 */,
17119 +       pers_high:      4 /* PER_WYSEV386 */,
17120 +       signal_map:     wyse_to_linux_signals,
17121 +       signal_invmap:  linux_to_wyse_signals,
17122 +       err_map:        wyse_err_map,
17123 +       socktype_map:   wyse_socktype_map,
17124 +       sockopt_map:    wyse_sockopt_map,
17125 +       af_map:         wyse_af_map,
17126 +       module:         THIS_MODULE
17127 +};
17128 +
17129 +
17130 +static int __init
17131 +wyse_module_init(void)
17132 +{
17133 +       return register_exec_domain(&wyse_exec_domain);
17134 +}
17135 +
17136 +static void __exit
17137 +wyse_module_exit(void)
17138 +{
17139 +       unregister_exec_domain(&wyse_exec_domain);
17140 +}
17141 +
17142 +module_init(wyse_module_init);
17143 +module_exit(wyse_module_exit);
17144 diff -Nur kernel-source-2.6.16.orig/abi/wyse/syslocal.c kernel-source-2.6.16/abi/wyse/syslocal.c
17145 --- kernel-source-2.6.16.orig/abi/wyse/syslocal.c       1970-01-01 10:00:00.000000000 +1000
17146 +++ kernel-source-2.6.16/abi/wyse/syslocal.c    2006-04-27 18:50:24.000000000 +1000
17147 @@ -0,0 +1,55 @@
17148 +/*
17149 + * Copyright (C) 1994  Mike Jagdis (jaggy@purplet.demon.co.uk)
17150 + */
17151 +
17152 +#ident "%W% %G%"
17153 +
17154 +#include <linux/module.h>
17155 +#include <linux/errno.h>
17156 +#include <asm/uaccess.h>
17157 +
17158 +#include <abi/util/trace.h>
17159 +
17160 +
17161 +/*
17162 + * The syslocal() call is used for machine specific functions. For
17163 + * instance on a Wyse 9000 it give information and control of the
17164 + * available processors.
17165 + */
17166 +#define SL_ONLINE      0       /* Turn processor online                */
17167 +#define SL_OFFLINE     1       /* Turn processor offline               */
17168 +#define SL_QUERY       2       /* Query processor status               */
17169 +#define SL_NENG                3       /* Return No. of processors configured  */
17170 +#define SL_AFFINITY    4       /* processor binding                    */
17171 +#define SL_CMC_STAT    7       /* gather CMC performance counters info */
17172 +#define SL_KACC                8       /* make kernel data readable by user    */
17173 +#define SL_MACHTYPE    9       /* return machine type (MP/AT)          */
17174 +#define SL_BOOTNAME    10      /* return name of booted kernel         */
17175 +#define SL_BOOTDEV     11      /* return type of booted device         */
17176 +#define SL_UQUERY      12      /* query user status                    */
17177 +
17178 +#define SL_MACH_MP     0
17179 +#define SL_MACH_AT     1
17180 +#define SL_MACH_EISA   2
17181 +#define SL_MACH_EMP    3
17182 +
17183 +
17184 +int
17185 +wyse_syslocal(struct pt_regs *regp)
17186 +{
17187 +       int                     cmd = get_syscall_parameter(regp, 0);
17188 +
17189 +       switch (cmd) {
17190 +       case SL_QUERY:
17191 +               return 0;
17192 +       case SL_NENG:
17193 +               return 1;
17194 +       case SL_MACHTYPE:
17195 +               return (EISA_bus ? SL_MACH_EISA : SL_MACH_AT);
17196 +       }
17197 +
17198 +#if defined(CONFIG_ABI_TRACE)
17199 +       abi_trace(ABI_TRACE_UNIMPL, "unsupported syslocal call %d\n", cmd);
17200 +#endif
17201 +       return -EINVAL;
17202 +}
17203 diff -Nur kernel-source-2.6.16.orig/arch/i386/kernel/entry.S kernel-source-2.6.16/arch/i386/kernel/entry.S
17204 --- kernel-source-2.6.16.orig/arch/i386/kernel/entry.S  2006-03-20 15:53:29.000000000 +1000
17205 +++ kernel-source-2.6.16/arch/i386/kernel/entry.S       2006-04-27 18:50:24.000000000 +1000
17206 @@ -123,6 +123,39 @@
17207  .previous
17208  
17209  
17210 +ENTRY(lcall7)
17211 +       pushfl                  # We get a different stack layout with call
17212 +                               # gates, which has to be cleaned up later..
17213 +       pushl %eax
17214 +       SAVE_ALL
17215 +       movl %esp, %ebp
17216 +       pushl %ebp
17217 +       pushl $0x7
17218 +do_lcall:
17219 +       movl EIP(%ebp), %eax    # due to call gates, this is eflags, not eip..
17220 +       movl CS(%ebp), %edx     # this is eip..
17221 +       movl EFLAGS(%ebp), %ecx # and this is cs..
17222 +       movl %eax,EFLAGS(%ebp)  #
17223 +       movl %edx,EIP(%ebp)     # Now we move them to their "normal" places
17224 +       movl %ecx,CS(%ebp)      #
17225 +       GET_THREAD_INFO_WITH_ESP(%ebp)  # GET_THREAD_INFO
17226 +       movl TI_exec_domain(%ebp), %edx # Get the execution domain
17227 +       call *EXEC_DOMAIN_handler(%edx) # Call the handler for the domain
17228 +       addl $4, %esp
17229 +       popl %eax
17230 +       jmp resume_userspace
17231 +
17232 +ENTRY(lcall27)
17233 +       pushfl                  # We get a different stack layout with call
17234 +                               # gates, which has to be cleaned up later..
17235 +       pushl %eax
17236 +       SAVE_ALL
17237 +       movl %esp, %ebp
17238 +       pushl %ebp
17239 +       pushl $0x27
17240 +       jmp do_lcall
17241 +
17242 +
17243  ENTRY(ret_from_fork)
17244         pushl %eax
17245         call schedule_tail
17246 diff -Nur kernel-source-2.6.16.orig/arch/i386/kernel/i386_ksyms.c kernel-source-2.6.16/arch/i386/kernel/i386_ksyms.c
17247 --- kernel-source-2.6.16.orig/arch/i386/kernel/i386_ksyms.c     2006-04-27 18:29:59.000000000 +1000
17248 +++ kernel-source-2.6.16/arch/i386/kernel/i386_ksyms.c  2006-04-27 18:50:24.000000000 +1000
17249 @@ -1,3 +1,8 @@
17250 +#define __KERNEL_SYSCALLS__
17251 +#include <linux/unistd.h>
17252 +#include <linux/syscalls.h>
17253 +#include <asm/signal.h>
17254 +
17255  #include <linux/config.h>
17256  #include <linux/module.h>
17257  #include <linux/nmi.h>
17258 @@ -24,6 +29,12 @@
17259  EXPORT_SYMBOL(strpbrk);
17260  EXPORT_SYMBOL(strstr);
17261  
17262 +EXPORT_SYMBOL(sys_modify_ldt);
17263 +EXPORT_SYMBOL(sys_ptrace);
17264 +EXPORT_SYMBOL(sys_ipc);
17265 +EXPORT_SYMBOL(sys_pause);
17266 +EXPORT_SYMBOL(signal_suspend);
17267 +
17268  #ifdef CONFIG_SMP
17269  extern void FASTCALL( __write_lock_failed(rwlock_t *rw));
17270  extern void FASTCALL( __read_lock_failed(rwlock_t *rw));
17271 diff -Nur kernel-source-2.6.16.orig/arch/i386/kernel/lcall7.c kernel-source-2.6.16/arch/i386/kernel/lcall7.c
17272 --- kernel-source-2.6.16.orig/arch/i386/kernel/lcall7.c 1970-01-01 10:00:00.000000000 +1000
17273 +++ kernel-source-2.6.16/arch/i386/kernel/lcall7.c      2006-04-27 18:50:24.000000000 +1000
17274 @@ -0,0 +1,184 @@
17275 +/*
17276 + * Copyright (c) 2000,2001 Christoph Hellwig.
17277 + * Copyright (c) 2001 Caldera Deutschland GmbH.
17278 + * All rights resered.
17279 + *
17280 + * This program is free software; you can redistribute it and/or modify
17281 + * it under the terms of the GNU General Public License as published by
17282 + * the Free Software Foundation; either version 2 of the License, or
17283 + * (at your option) any later version.
17284 + *
17285 + * This program is distributed in the hope that it will be useful,
17286 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
17287 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17288 + * GNU General Public License for more details.
17289 + *
17290 + * You should have received a copy of the GNU General Public License
17291 + * along with this program; if not, write to the Free Software
17292 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17293 + */
17294 +
17295 +#ident "%W% %G%"
17296 +
17297 +/*
17298 + * Lowlevel handler for lcall7-based syscalls.
17299 + */
17300 +#include <linux/module.h>
17301 +#include <linux/errno.h>
17302 +#include <linux/sched.h>
17303 +#include <linux/kernel.h>
17304 +#include <linux/mm.h>
17305 +#include <linux/ptrace.h>
17306 +#include <linux/init.h>
17307 +#include <linux/personality.h>
17308 +#include <asm/uaccess.h>
17309 +
17310 +#include <abi/util/errno.h>
17311 +#include <abi/util/trace.h>
17312 +#include <abi/util/sysent.h>
17313 +
17314 +MODULE_AUTHOR("Christoph Hellwig");
17315 +MODULE_DESCRIPTION("Lowlevel handler for lcall7-based syscalls");
17316 +MODULE_LICENSE("GPL");
17317 +
17318 +
17319 +static void get_args(int args[], struct pt_regs *regs, int of, int n)
17320 +{
17321 +       int i;
17322 +
17323 +       for (i = 0; i < n; i++)
17324 +               get_user(args[i], ((unsigned long *)regs->esp) + (i+of));
17325 +}
17326 +
17327 +/*
17328 + *     lcall7_syscall    -    indirect syscall for the lcall7 entry point
17329 + *
17330 + *     @regs:          saved user registers
17331 + *
17332 + *     This function implements syscall(2) in kernelspace for the lcall7-
17333 + *     based personalities.
17334 + */
17335 +
17336 +int lcall7_syscall(struct pt_regs *regs)
17337 +{
17338 +       __get_user(regs->eax, ((unsigned long *)regs->esp)+1);
17339 +
17340 +       ++regs->esp;
17341 +       current_thread_info()->exec_domain->handler(-1,regs);
17342 +       --regs->esp;
17343 +
17344 +       return 0;
17345 +}
17346 +
17347 +/**
17348 + *     lcall7_dispatch    -    handle lcall7-based syscall entry
17349 + *
17350 + *     @regs:          saved user registers
17351 + *     @ap:            syscall table entry
17352 + *     @off:           argument offset
17353 + *
17354 + *     This function handles lcall7-based syscalls after the personality-
17355 + *     specific rountine selected the right syscall table entry.
17356 + */
17357 +
17358 +void lcall7_dispatch(struct pt_regs *regs, struct sysent *ap, int off)
17359 +{
17360 +       short nargs = ap->se_nargs;
17361 +       int args[8], error;
17362 +
17363 +       if (!ap->se_syscall) /* XXX kludge XXX */
17364 +               nargs = Unimpl;
17365 +
17366 +       if (nargs <= ARRAY_SIZE(args))
17367 +               get_args(args, regs, off, nargs);
17368 +
17369 +#if defined(CONFIG_ABI_TRACE)
17370 +       if (abi_traced(ABI_TRACE_API)) {
17371 +               if (nargs == Spl)
17372 +                       get_args(args, regs, off, strlen(ap->se_args));
17373 +               plist(ap->se_name, ap->se_args, args);
17374 +       }
17375 +#endif
17376 +
17377 +       switch (nargs) {
17378 +       case Fast:
17379 +               SYSCALL_PREGS(ap->se_syscall, regs);
17380 +               goto show_signals;
17381 +       case Spl:
17382 +               error = SYSCALL_PREGS(ap->se_syscall, regs);
17383 +               break;
17384 +       case 0:
17385 +               error = SYSCALL_VOID(ap->se_syscall);
17386 +               break;
17387 +       case 1:
17388 +               error = SYSCALL_1ARG(ap->se_syscall, args);
17389 +               break;
17390 +       case 2:
17391 +               error = SYSCALL_2ARG(ap->se_syscall, args);
17392 +               break;
17393 +       case 3:
17394 +               error = SYSCALL_3ARG(ap->se_syscall, args);
17395 +               break;
17396 +       case 4:
17397 +               error = SYSCALL_4ARG(ap->se_syscall, args);
17398 +               break;
17399 +       case 5:
17400 +               error = SYSCALL_5ARG(ap->se_syscall, args);
17401 +               break;
17402 +       case 6:
17403 +               error = SYSCALL_6ARG(ap->se_syscall, args);
17404 +               break;
17405 +       case 7:
17406 +               error = SYSCALL_7ARG(ap->se_syscall, args);
17407 +               break;
17408 +       default:
17409 +#if defined(CONFIG_ABI_TRACE)
17410 +               abi_trace(ABI_TRACE_UNIMPL,
17411 +                       "Unsupported ABI function 0x%lx (%s)\n",
17412 +                       regs->eax, ap->se_name);
17413 +#endif
17414 +               error = -ENOSYS;
17415 +       }
17416 +
17417 +       if (error > -ENOIOCTLCMD && error < 0) {
17418 +               set_error(regs, iABI_errors(-error));
17419 +
17420 +#if defined(CONFIG_ABI_TRACE)
17421 +               abi_trace(ABI_TRACE_API,
17422 +                   "%s error return %d/%ld\n",
17423 +                   ap->se_name, error, regs->eax);
17424 +#endif
17425 +       } else {
17426 +               clear_error(regs);
17427 +               set_result(regs, error);
17428 +
17429 +#if defined(CONFIG_ABI_TRACE)
17430 +               abi_trace(ABI_TRACE_API,
17431 +                   "%s returns %ld (edx:%ld)\n",
17432 +                   ap->se_name, regs->eax, regs->edx);
17433 +#endif
17434 +       }
17435 +
17436 +show_signals:
17437 +#if defined(CONFIG_ABI_TRACE)
17438 +       if (signal_pending(current) && abi_traced(ABI_TRACE_SIGNAL)) {
17439 +               unsigned long signr;
17440 +
17441 +               signr = current->pending.signal.sig[0] &
17442 +                       ~current->blocked.sig[0];
17443 +
17444 +               __asm__("bsf %1,%0\n\t"
17445 +                               :"=r" (signr)
17446 +                               :"0" (signr));
17447 +
17448 +               __abi_trace("SIGNAL %lu, queued 0x%08lx\n",
17449 +                       signr+1, current->pending.signal.sig[0]);
17450 +       }
17451 +#endif
17452 +        return;
17453 +}
17454 +
17455 +#if defined(CONFIG_ABI_SYSCALL_MODULES)
17456 +EXPORT_SYMBOL(lcall7_syscall);
17457 +EXPORT_SYMBOL(lcall7_dispatch);
17458 +#endif
17459 diff -Nur kernel-source-2.6.16.orig/arch/i386/kernel/Makefile kernel-source-2.6.16/arch/i386/kernel/Makefile
17460 --- kernel-source-2.6.16.orig/arch/i386/kernel/Makefile 2006-03-20 15:53:29.000000000 +1000
17461 +++ kernel-source-2.6.16/arch/i386/kernel/Makefile      2006-04-27 18:50:24.000000000 +1000
17462 @@ -28,6 +28,7 @@
17463  obj-$(CONFIG_CRASH_DUMP)       += crash_dump.o
17464  obj-$(CONFIG_X86_NUMAQ)                += numaq.o
17465  obj-$(CONFIG_X86_SUMMIT_NUMA)  += summit.o
17466 +obj-$(CONFIG_ABI_LCALL7)               += lcall7.o
17467  obj-$(CONFIG_KPROBES)          += kprobes.o
17468  obj-$(CONFIG_MODULES)          += module.o
17469  obj-y                          += sysenter.o vsyscall.o
17470 diff -Nur kernel-source-2.6.16.orig/arch/i386/kernel/signal.c kernel-source-2.6.16/arch/i386/kernel/signal.c
17471 --- kernel-source-2.6.16.orig/arch/i386/kernel/signal.c 2006-03-20 15:53:29.000000000 +1000
17472 +++ kernel-source-2.6.16/arch/i386/kernel/signal.c      2006-04-27 18:50:24.000000000 +1000
17473 @@ -37,6 +37,12 @@
17474  asmlinkage int
17475  sys_sigsuspend(int history0, int history1, old_sigset_t mask)
17476  {
17477 +       return signal_suspend((struct pt_regs *)&history0, mask);
17478 +}
17479 +
17480 +asmlinkage int
17481 +signal_suspend(struct pt_regs * regs, old_sigset_t mask)
17482 +{
17483         mask &= _BLOCKABLE;
17484         spin_lock_irq(&current->sighand->siglock);
17485         current->saved_sigmask = current->blocked;
17486 diff -Nur kernel-source-2.6.16.orig/arch/i386/kernel/traps.c kernel-source-2.6.16/arch/i386/kernel/traps.c
17487 --- kernel-source-2.6.16.orig/arch/i386/kernel/traps.c  2006-04-27 18:30:01.000000000 +1000
17488 +++ kernel-source-2.6.16/arch/i386/kernel/traps.c       2006-04-27 18:50:24.000000000 +1000
17489 @@ -60,6 +60,8 @@
17490  #include "mach_traps.h"
17491  
17492  asmlinkage int system_call(void);
17493 +asmlinkage void lcall7(void);
17494 +asmlinkage void lcall27(void);
17495  
17496  struct desc_struct default_ldt[] = { { 0, 0 }, { 0, 0 }, { 0, 0 },
17497                 { 0, 0 }, { 0, 0 } };
17498 @@ -759,6 +761,27 @@
17499         if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
17500                                         SIGTRAP) == NOTIFY_STOP)
17501                 return;
17502 +
17503 +       /*
17504 +        * Entering the kernel via lcall7 or lcall27 does not clear the TF bit.
17505 +        * Leaving it set in kernel code will stop the machine.  The first
17506 +        * instructions of lcall7 and lcall27 in entry.S save the CPU flags.
17507 +        * The saved flags should have the TF bit set, so we ignore this trap.
17508 +        */
17509 +  if (regs->eip == (unsigned long) &lcall7 ||
17510 +               regs->eip == (unsigned long) &lcall27)
17511 +               return;
17512 +
17513 +       /*
17514 +        * After having saved the flags, TF will fire the single step trap
17515 +        * again.  This time TF should be cleared. It will be restored by the
17516 +        * iret instruction returning to user mode.  This way, the very next
17517 +        * instruction after lcall in the user programm will not be stopped at.
17518 +        */
17519 +       if (regs->eip - 1 == (unsigned long) &lcall7 || /* pushfl is a one-byte op */
17520 +               regs->eip - 1 == (unsigned long) &lcall27)
17521 +               goto clear_TF_reenable;
17522 +
17523         /* It's safe to allow irq's after DR6 has been saved */
17524         if (regs->eflags & X86_EFLAGS_IF)
17525                 local_irq_enable();
17526 @@ -1096,6 +1119,11 @@
17527         _set_gate(idt_table+n,15,3,addr,__KERNEL_CS);
17528  }
17529  
17530 +static void __init set_call_gate(void *a, void *addr)
17531 +{
17532 +       _set_gate(a,12,3,addr,__KERNEL_CS);
17533 +}
17534 +
17535  static void __init set_task_gate(unsigned int n, unsigned int gdt_entry)
17536  {
17537         _set_gate(idt_table+n,5,0,0,(gdt_entry<<3));
17538 @@ -1164,6 +1192,13 @@
17539         set_system_gate(SYSCALL_VECTOR,&system_call);
17540  
17541         /*
17542 +        * default LDT is a single-entry callgate to lcall7 for iBCS
17543 +        * and a callgate to lcall27 for Solaris/x86 binaries
17544 +        */
17545 +       set_call_gate(&default_ldt[0],lcall7);
17546 +       set_call_gate(&default_ldt[4],lcall27);
17547 +
17548 +       /*
17549          * Should be a barrier for any external CPU state.
17550          */
17551         cpu_init();
17552 diff -Nur kernel-source-2.6.16.orig/arch/ia64/ia32/ia32priv.h kernel-source-2.6.16/arch/ia64/ia32/ia32priv.h
17553 --- kernel-source-2.6.16.orig/arch/ia64/ia32/ia32priv.h 2006-03-20 15:53:29.000000000 +1000
17554 +++ kernel-source-2.6.16/arch/ia64/ia32/ia32priv.h      2006-04-27 18:50:24.000000000 +1000
17555 @@ -344,7 +344,7 @@
17556  
17557  #ifdef __KERNEL__
17558  # define SET_PERSONALITY(EX,IBCS2)                             \
17559 -       (current->personality = (IBCS2) ? PER_SVR4 : PER_LINUX)
17560 +       (is_cur_personality((IBCS2)) ? PER_SVR4 : PER_LINUX)
17561  #endif
17562  
17563  #define IA32_EFLAG     0x200
17564 diff -Nur kernel-source-2.6.16.orig/arch/parisc/kernel/signal.c kernel-source-2.6.16/arch/parisc/kernel/signal.c
17565 --- kernel-source-2.6.16.orig/arch/parisc/kernel/signal.c       2006-03-20 15:53:29.000000000 +1000
17566 +++ kernel-source-2.6.16/arch/parisc/kernel/signal.c    2006-04-27 18:50:24.000000000 +1000
17567 @@ -76,7 +76,7 @@
17568  #ifdef __LP64__
17569         compat_sigset_t newset32;
17570  
17571 -       if(personality(current->personality) == PER_LINUX32){
17572 +       if(is_cur_personality_id(PERID_LINUX32)){
17573                 /* XXX: Don't preclude handling different sized sigset_t's.  */
17574                 if (sigsetsize != sizeof(compat_sigset_t))
17575                         return -EINVAL;
17576 @@ -186,7 +186,7 @@
17577  
17578         /* Good thing we saved the old gr[30], eh? */
17579  #ifdef __LP64__
17580 -       if(personality(current->personality) == PER_LINUX32){
17581 +       if(is_cur_personality_id(PERID_LINUX32)){
17582                 DBG(1,"sys_rt_sigreturn: compat_frame->uc.uc_mcontext 0x%p\n",
17583                                 &compat_frame->uc.uc_mcontext);
17584  // FIXME: Load upper half from register file
17585 @@ -392,7 +392,7 @@
17586         haddr = A(ka->sa.sa_handler);
17587         /* The sa_handler may be a pointer to a function descriptor */
17588  #ifdef __LP64__
17589 -       if(personality(current->personality) == PER_LINUX32) {
17590 +       if(is_cur_personality_id(PERID_LINUX32)) {
17591  #endif
17592                 if (haddr & PA_PLABEL_FDESC) {
17593                         Elf32_Fdesc fdesc;
17594 @@ -427,19 +427,19 @@
17595          */
17596         sigframe_size = PARISC_RT_SIGFRAME_SIZE;
17597  #ifdef __LP64__
17598 -       if(personality(current->personality) == PER_LINUX32)
17599 +       if(is_cur_personality_id(PERID_LINUX32))
17600                 sigframe_size = PARISC_RT_SIGFRAME_SIZE32;
17601  #endif
17602         if (in_syscall) {
17603                 regs->gr[31] = haddr;
17604  #ifdef __LP64__
17605 -               if(personality(current->personality) == PER_LINUX)
17606 +               if(is_cur_personality_id(PERID_LINUX))
17607                         sigframe_size |= 1;
17608  #endif
17609         } else {
17610                 unsigned long psw = USER_PSW;
17611  #ifdef __LP64__
17612 -               if(personality(current->personality) == PER_LINUX)
17613 +               if(is_cur_personality_id(PERID_LINUX))
17614                         psw |= PSW_W;
17615  #endif
17616  
17617 @@ -464,7 +464,7 @@
17618         regs->gr[26] = sig;               /* signal number */
17619         
17620  #ifdef __LP64__
17621 -       if(personality(current->personality) == PER_LINUX32){
17622 +       if(is_cur_personality_id(PERID_LINUX32)){
17623                 regs->gr[25] = A(&compat_frame->info); /* siginfo pointer */
17624                 regs->gr[24] = A(&compat_frame->uc);   /* ucontext pointer */
17625         } else
17626 diff -Nur kernel-source-2.6.16.orig/arch/x86_64/ia32/sys_ia32.c kernel-source-2.6.16/arch/x86_64/ia32/sys_ia32.c
17627 --- kernel-source-2.6.16.orig/arch/x86_64/ia32/sys_ia32.c       2006-04-27 18:30:01.000000000 +1000
17628 +++ kernel-source-2.6.16/arch/x86_64/ia32/sys_ia32.c    2006-04-27 18:50:24.000000000 +1000
17629 @@ -751,12 +751,15 @@
17630  sys32_personality(unsigned long personality)
17631  {
17632         int ret;
17633 -       if (personality(current->personality) == PER_LINUX32 && 
17634 +
17635 +       if (is_personality_id(PERID_LINUX32) &&
17636                 personality == PER_LINUX)
17637                 personality = PER_LINUX32;
17638         ret = sys_personality(personality);
17639 +
17640         if (ret == PER_LINUX32)
17641                 ret = PER_LINUX;
17642 +
17643         return ret;
17644  }
17645  
17646 @@ -903,7 +906,7 @@
17647          __put_user(0,name->version+__OLD_UTS_LEN);
17648          { 
17649                  char *arch = "x86_64";
17650 -                if (personality(current->personality) == PER_LINUX32)
17651 +                if (is_cur_personality_id(PERID_LINUX32))
17652                          arch = "i686";
17653                  
17654                  __copy_to_user(&name->machine,arch,strlen(arch)+1);
17655 @@ -924,7 +927,7 @@
17656         down_read(&uts_sem);
17657         err=copy_to_user(name, vx_new_utsname(), sizeof (*name));
17658         up_read(&uts_sem);
17659 -       if (personality(current->personality) == PER_LINUX32) 
17660 +       if (is_cur_personality_id(PERID_LINUX32))
17661                 err |= copy_to_user(&name->machine, "i686", 5);
17662         return err?-EFAULT:0;
17663  }
17664 diff -Nur kernel-source-2.6.16.orig/arch/x86_64/kernel/sys_x86_64.c kernel-source-2.6.16/arch/x86_64/kernel/sys_x86_64.c
17665 --- kernel-source-2.6.16.orig/arch/x86_64/kernel/sys_x86_64.c   2006-04-27 18:30:01.000000000 +1000
17666 +++ kernel-source-2.6.16/arch/x86_64/kernel/sys_x86_64.c        2006-04-27 18:50:24.000000000 +1000
17667 @@ -151,7 +151,7 @@
17668         down_read(&uts_sem);
17669         err = copy_to_user(name, vx_new_utsname(), sizeof (*name));
17670         up_read(&uts_sem);
17671 -       if (personality(current->personality) == PER_LINUX32) 
17672 +       if (is_cur_personality_id(PERID_LINUX32))
17673                 err |= copy_to_user(&name->machine, "i686", 5);                 
17674         return err ? -EFAULT : 0;
17675  }
17676 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/00-INDEX kernel-source-2.6.16/Documentation/abi/00-INDEX
17677 --- kernel-source-2.6.16.orig/Documentation/abi/00-INDEX        1970-01-01 10:00:00.000000000 +1000
17678 +++ kernel-source-2.6.16/Documentation/abi/00-INDEX     2006-04-27 18:50:24.000000000 +1000
17679 @@ -0,0 +1,30 @@
17680 +00-INDEX
17681 +       - this file
17682 +COMPAT
17683 +       - a list of software that has run succesfull under iBCS
17684 +CREDITS
17685 +       - a list of people that have contributed to linux-abi or iBCS
17686 +ChangeLog
17687 +       - changelog of linux-abi
17688 +ChangeLog.ibcs
17689 +       - changelog of the iBCS project (up to 1998)
17690 +Error.map
17691 +       - mapping of error codes from Linux to various personalities
17692 +HINTS
17693 +       - FAQ-style Q&A
17694 +Local-X
17695 +       - help on local X interfaces
17696 +Notes.Signal
17697 +       - some notes on signal handling
17698 +Personality
17699 +       - an introduction into Linux personality support
17700 +README.first
17701 +       - read this first!
17702 +Syscall.map
17703 +       - the syscall mapping for certain personalities
17704 +TODO.ibcs
17705 +       - things to be done, leftovers from iBCS
17706 +autoload.txt
17707 +       - autoloading personality modules under Linux-ABI
17708 +modules.txt
17709 +       - a brief overview of the Linux-ABI modules
17710 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/autoload.txt kernel-source-2.6.16/Documentation/abi/autoload.txt
17711 --- kernel-source-2.6.16.orig/Documentation/abi/autoload.txt    1970-01-01 10:00:00.000000000 +1000
17712 +++ kernel-source-2.6.16/Documentation/abi/autoload.txt 2006-04-27 18:50:24.000000000 +1000
17713 @@ -0,0 +1,49 @@
17714 +Autoloading personality modules under Linux-ABI
17715 +2001-July-19
17716 +Christoph Hellwig, <hch@caldera.de>
17717 +
17718 +Linux-ABI can automatically load binary format modules (see modules.txt
17719 +for information on what binary format modules are).  This file explains
17720 +how to setup a system to automatically load the binary format modules
17721 +on demand.
17722 +
17723 +Automatic module loading is done in Linux using a facility called 'kmod'
17724 +which is - unlike the name suggests - _not_ a system daemon, but a kernel-
17725 +facility to make userspace upcalls to te module loading program 'modprobe'.
17726 +
17727 +Linux-ABI uses the function request_module that is exported by kmod to
17728 +request modules for personalities that are currently not available but
17729 +requested by one of the binary fomrat detection heuristics.  For a missing
17730 +personality, request_module is called for the module-string
17731 +
17732 +       personality-<personality-number>
17733 +
17734 +To get the right modules loaded you have to alias these string to the
17735 +actually wanted modules in /etc/modules.conf.  To do that you have to know
17736 +which personality number maps to what module.  Here is a table for the
17737 +personalities supported by Linux-ABI:
17738 +
17739 +
17740 +         personalities         module
17741 +       -----------------------------------
17742 +         1,2,5,7               abi-ibcs
17743 +         3                     abi-sco
17744 +         4                     abi-wyse
17745 +         13                    abi-solaris
17746 +         14                    abi-uw7
17747 +
17748 +Below is an example snipplet from modules.conf for such a setup:
17749 +
17750 +------------------- snip --------------------
17751 +
17752 +alias personality-1    abi-ibcs
17753 +alias personality-2    abi-ibcs
17754 +alias personality-3    abi-sco
17755 +alias personality-4    abi-wyse
17756 +alias personality-5    abi-ibcs
17757 +alias personality-7    abi-ibcs
17758 +alias personality-13   abi-solaris
17759 +alias personality-14   abi-uw7
17760 +
17761 +------------------- snip --------------------
17762 +
17763 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/ChangeLog kernel-source-2.6.16/Documentation/abi/ChangeLog
17764 --- kernel-source-2.6.16.orig/Documentation/abi/ChangeLog       1970-01-01 10:00:00.000000000 +1000
17765 +++ kernel-source-2.6.16/Documentation/abi/ChangeLog    2006-04-27 18:50:24.000000000 +1000
17766 @@ -0,0 +1,135 @@
17767 +2002-01-03  Christoph Hellwig  <hch@caldera.de>
17768 +
17769 +       linux-abi­2.4.17.0
17770 +
17771 +       * rework/cleanup lcall7 syscall handling
17772 +       * make sure x.out sections aren't loaded into illegal areas
17773 +       * fix SVR4 mmap() to always assume post-SunOS4 behaviour
17774 +
17775 +2001-11-24  Christoph Hellwig  <hch@caldera.de>
17776 +
17777 +       linux-abi-2.4.15.0
17778 +
17779 +       * simplify wyse socket handling, use native syscalls directly where
17780 +         possibles else use normal calling conventions
17781 +       * fix <linux/syscall.h> compilation for non-i386 machines (Olaf Hering)
17782 +       * fix alignment checks in binfmt_xout (based on patch by Joerg Ahrens)
17783 +       * rewrite abi_brk: fix (theoretical) races, check for page alignment
17784 +       * don't try to take a non-existant lock in xnx_nap, cleanup xnx_nap.
17785 +       * fix value reported by sysi86(SI86MEM).
17786 +
17787 +2001-11-18  Christoph Hellwig  <hch@sb.bsdonline.org>
17788 +
17789 +       linux-abi 2.4.14.0
17790 +
17791 +       * small binfmt_xout bugfixes (Joerg Ahrens)
17792 +       * move isc into it's own personality
17793 +       * make all personalities independant of abi-ibcs
17794 +       * merge socket handling into abi-wyse
17795 +
17796 +2001-10-22  Christoph Hellwig  <hch@sb.bsdonline.org>
17797 +
17798 +       linux-abi 2.4.12.0
17799 +
17800 +       * big mmap rewrite
17801 +         | correctly check for flags in svr4_mmap
17802 +         | use svr4_mmap for the UnixWare personality as well
17803 +         | OpenServer has it's own implementation now as it supports
17804 +           rather different flags than SVR4 & derivates
17805 +       * more header cleanups - all helper routines are now in abi/util/*.h
17806 +
17807 +2001-10-04  Christoph Hellwig  <hch@sb.bsdonline.org>
17808 +
17809 +       linux-abi 2.4.10.0
17810 +
17811 +       * add MODULE_DESCRIPTION/MODULE_AUTHOR/MODULE_LICENSE tags
17812 +       * don't use alternate prefix for directories (David Mosberger)
17813 +       * fix non-modular buil
17814 +       * cleanup stat handling
17815 +         | use Alexander Viro's kstat concept
17816 +         | all emulations now have their own xstat implementations
17817 +         | fixed overflows
17818 +       * add full-fledged types.h headers for all peronalities
17819 +
17820 +2001-08-06  Christoph Hellwig  <hch@sb.bsdonline.org>
17821 +
17822 +       linux-abi 2.4.9.0
17823 +
17824 +       * fix missing solaris socket exports
17825 +       * move Xenix support from ibcs to sco module,
17826 +               make unconditional
17827 +       * UnixWare LFS fixes
17828 +       * make the actual code work on the Alan Cox tree
17829 +
17830 +2001-08-06  Christoph Hellwig  <hch@sb.bsdonline.org>
17831 +
17832 +       linux-abi 2.4.7.0
17833 +
17834 +       * some final polishing for segmented 286 x.out binaries (Joerg Ahrens)
17835 +       * fix SPX handling (again)
17836 +       * fix setpgrp and cleanup procids while we're at it
17837 +       * update SCO syscall table to match OSR506a
17838 +
17839 +2001-07-19  Christoph Hellwig  <hch@sb.bsdonline.org>
17840 +
17841 +       linux-abi 2.4.6.1
17842 +
17843 +       * rewritten /dev/socksys handling
17844 +       * fix more non-x86 breakage (Olaf Hering)
17845 +       * port solaris native sockets from sparc64
17846 +       * add sysctl support for runtime-tweaking
17847 +       * add cxenix to the ibcs sysent table for Xenix/386 (Jürgen Günther)
17848 +       * (re)add support for segmented x.out binaries (Joerg Ahrens)
17849 +         | I probably broke it while rebasing against -CURRENT
17850 +       * reject IRIX binaries on mips32 (David Woodhouse)
17851 +
17852 +2001-07-09  Christoph Hellwig  <hch@sb.bsdonline.org>
17853 +
17854 +       linux-abi 2.4.6.0
17855 +
17856 +       * svr4/signal.c typo fix
17857 +       * make cxenix debug printk's less verbose (Christian Lademann)
17858 +       * misc small bugfixes (Christian Lademann)
17859 +       * compile fixes for !CONFIG_ABI on non-x86 architectures
17860 +
17861 +2001-06-18  Christoph Hellwig  <hch@sb.bsdonline.org>
17862 +
17863 +       linux-abi 2.4.5.1
17864 +
17865 +       * rewrite of abi_sigsuspend() to make it work as expected
17866 +       * fix cxenix syscall table
17867 +       * actually initialize socksys
17868 +
17869 +2001-06-09  Christoph Hellwig  <hch@sb.bsdonline.org>
17870 +
17871 +       linux-abi 2.4.5.0
17872 +
17873 +       * rewrite of kernel exec_domain support
17874 +       * make faking of SCO utsname information configurable
17875 +       * get rid of SYS() and sysfunc_p (Arjan van de Ven)
17876 +       * fix socket families (Stephan Springl)
17877 +       * fix SCO signal mapping (Stephan Springl)
17878 +       * fix SCO (and Wyse) error mapping
17879 +       * continued source tree restructuring
17880 +
17881 +2001-04-31  Christoph Hellwig  <hch@sb.bsdonline.org>
17882 +
17883 +       linux-abi 2.4.4.0
17884 +
17885 +       * disable tracing by default
17886 +       * rewrite of the SYSV IPC code
17887 +       * add support for SCO OpenServer 5 ELF binaries
17888 +       * fix an error in binfmt_coff that does not clear the return value
17889 +       * provide generic template macros for stat and friends
17890 +       * start of source tree reorganization
17891 +
17892 +2001-03-30  Christoph Hellwig  <hch@sb.bsdonline.org>
17893 +
17894 +       linux-abi 2.4.3.0
17895 +
17896 +       * fix shared library support for COFF
17897 +       * x.out is now supported (again)
17898 +       * redo setting of personality based on ELF headers
17899 +       * get rid of CONFIG_ABI_TRACE (and a lot of nasty ifdefs)
17900 +       * added documentation, mostly from iBCS
17901 +
17902 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/ChangeLog.ibcs kernel-source-2.6.16/Documentation/abi/ChangeLog.ibcs
17903 --- kernel-source-2.6.16.orig/Documentation/abi/ChangeLog.ibcs  1970-01-01 10:00:00.000000000 +1000
17904 +++ kernel-source-2.6.16/Documentation/abi/ChangeLog.ibcs       2006-04-27 18:50:24.000000000 +1000
17905 @@ -0,0 +1,2769 @@
17906 +Thu Nov  5 21:45:41 GMT 1998
17907 +
17908 +       * Fixed the bug that lets reads and writes on /dev/socksys
17909 +         take out the kernel.
17910 +         -- Mike
17911 +
17912 +       * Added a kludge around for Sybase isql which appears to
17913 +         have initialised a struct sockaddr using:
17914 +                sa.sa_family = htons(AF_INET);
17915 +         I guess this works on SCO?
17916 +         -- Mike
17917 +
17918 +
17919 +Sat Oct 31 14:15:44 GMT 1998
17920 +
17921 +       * Documentation update.
17922 +
17923 +       * If we are doing a T_BIND_REQ with a null address we can
17924 +         ignore the connection backlog. Listening makes no sense
17925 +         but some software seems to set it 1 for the hell of it.
17926 +         -- Mike
17927 +
17928 +
17929 +Tue Oct 20 20:34:20 BST 1998
17930 +
17931 +       * Changed the debug messages printed when exec tracing
17932 +         sees a pointer error on an arg or env entry. It may not
17933 +         be a "real" error. It could be that we just cannot get
17934 +         a free page or perhaps the entry is too long for getname().
17935 +         Whatever, we do not really care at this point anyway.
17936 +         -- Mike
17937 +
17938 +
17939 +Sat Oct 17 20:24:59 BST 1998
17940 +
17941 +       * Documentation update for today's release.
17942 +         -- Mike
17943 +
17944 +
17945 +Thu Oct 15 21:39:16 BST 1998
17946 +
17947 +       * When checking personality only look at the base personality
17948 +         and ignore the flags. There is at least one case I can
17949 +         think of, PER_SHORT_INODE, where the personality should
17950 +         be considered the same even when the flags are different.
17951 +         -- Mike
17952 +
17953 +       * Added the location of the kernel source as an option
17954 +         in the CONFIG. Hopefully this will make it a little
17955 +         more obvious that iBCS is *dependant* on the kernel.
17956 +         -- Mike
17957 +
17958 +       * Set SO_BSDCOMPAT on sockets. SYSV has BSD handling of
17959 +         ICMP errors on UDP sockets rather than RFC conformance.
17960 +         I think...
17961 +         -- Mike
17962 +
17963 +
17964 +Wed Oct 14 22:50:48 BST 1998
17965 +
17966 +       * When using some user stack as temporary work space we
17967 +         only leave 1k between the work space and the real user
17968 +         stack. This is because Informix Dynamic Server uses
17969 +         threads with limited stack space and the idea of dropping
17970 +         16k below what would normally be touched on a SCO system
17971 +         worries me a bit.
17972 +         -- Mike
17973 +
17974 +
17975 +Sun Oct 11 11:58:58 BST 1998
17976 +
17977 +       * Changed the Tools Makefile to install mkmnttab in
17978 +         /usr/bin. Informix Dynamic Server _requires_ a
17979 +         valid /etc/mnttab.
17980 +         -- Mike
17981 +
17982 +
17983 +Sun Oct 11 11:44:58 BST 1998
17984 +
17985 +       * When doing an I_PEEK or I_NREAD STREAMS ioctl we have
17986 +         to do a probe on sockets in case we need to generate
17987 +         a control message (e.g. T_CONN_IND) which should then
17988 +         be offered. This also allows T_CONN_IND messages to be
17989 +         returned in several MORECTL divided pieces should it
17990 +         ever be necessary. This is required by Informix Dynamic
17991 +         Server which does a poll then I_PEEK on a listening
17992 +         socket before actually picking up the connection. Dynamic
17993 +         Server is system call hell :-).
17994 +         -- Mike
17995 +
17996 +       * When we do a timod operation via an ioctl there seems
17997 +         to be no way to cope if the returned message is larger
17998 +         than the original request. We can't expect the app to
17999 +         come back for the extra and returning MORECTL to the
18000 +         app seems to confuse things. Therefore we just discard
18001 +         the excess. This case is required when an app (e.g.
18002 +         Informix Dynamic Server) tries to set SO_LINGER using
18003 +         an int instead of a struct linger via an ioctl.
18004 +         -- Mike
18005 +
18006 +       * Added some debug to the poll handler so we can see what
18007 +         is being polled.
18008 +         -- Mike
18009 +
18010 +       * More debug message changes.
18011 +         -- Mike
18012 +
18013 +       * Wrap SO_LINGER handling so we can survive if an int is
18014 +         passed instead of s struct linger. It seems that other
18015 +         systems do not do such robust error checking as Linux.
18016 +         Note that if an int is passed we probably do not do what
18017 +         other systems would but at least we don't give unexpected
18018 +         errors to broken applications.
18019 +         -- Mike
18020 +
18021 +
18022 +Sat Oct 10 15:58:29 BST 1998
18023 +
18024 +       * Added an entry to Doc/HINTS noting the the Informix
18025 +         Dynamic Server install requires an /etc/mnttab.
18026 +         -- Mike
18027 +
18028 +       * Wrong option length being passed through to setsockopt()
18029 +         from the TLI/XTI optmgmt routine.
18030 +         -- Mike
18031 +
18032 +       * When stating files only map "ext2" to "HTFS" for SCO
18033 +         programs - and then only if the filesystem name really
18034 +         was "ext2".
18035 +         -- Mike
18036 +
18037 +       * SCO has a different value for the _SC_PAGESIZE argument
18038 +         to sysconf() than SVR4. Informix wants it to work.
18039 +         -- Mike
18040 +
18041 +       * Hmmm, Informix Dynamic Server may or may not be looking
18042 +         at the major number on a socket. (I _think_ it does
18043 +         sometimes). It definitely checks that sockets have
18044 +         S_IFCHR set in their file modes though...
18045 +         -- Mike
18046 +
18047 +       * Changed some debug messages to make it easier to read
18048 +         logs when more than one iBCS handled process is running.
18049 +         -- Mike
18050 +
18051 +       * If we get a STREAMS ioctl on a file descriptor only
18052 +         initialize the socksys handler on it if it is not
18053 +         already a socket but does belong to the socksys device.
18054 +         -- Mike
18055 +
18056 +
18057 +Thu Oct  8 21:20:43 BST 1998
18058 +
18059 +       * When punting a pseudo device transport provider to a
18060 +         socket copy the device numbers between the inodes. This
18061 +         is because Informix Dynamic Server stats the pseudo
18062 +         device node (/dev/socksys) then stats the socket it
18063 +         gets and compares the major numbers. Sheesh...
18064 +         -- Mike
18065 +
18066 +       * If socksys_close gets something that is not a socket
18067 +         it is probably the original pseudo device which was
18068 +         opened just for an ioctl or two. This is not an error.
18069 +         -- Mike
18070 +
18071 +       * Some programs, notably the Informix Dynamic Server
18072 +         install program compare the filesystem name from a
18073 +         stat or sysfs against their own hard coded list of
18074 +         known "real" filesystems. Hence we call "ext2" "HTFS"
18075 +         instead for SCO processes.
18076 +         -- Mike
18077 +
18078 +       * Informix DS also checks the release part of the utsname
18079 +         data to make sure it says "3.2v5.0.0". So now the
18080 +         utsname struct looks even more like SCO.
18081 +         -- Mike
18082 +
18083 +       * Only dump the ctl part of messages in timod if
18084 +         tracing is enabled.
18085 +         -- Mike
18086 +
18087 +       * SCO has statvfs in the same place as SVR4 but they have
18088 +         added a field slap bang in the middle of the struct to
18089 +         allow some inodes to be reserved for root in much the
18090 +         same way that some blocks may be reserved.
18091 +         -- Mike
18092 +
18093 +
18094 +Thu Oct  8 20:48:46 BST 1998
18095 +
18096 +       * On timod bind and connect the size of the address is
18097 +         allowed to be the _used_ bytes whereas the underlying
18098 +         socket functions require the _total_ bytes. This is
18099 +         a problem for Sybase.
18100 +         -- Mike
18101 +
18102 +
18103 +Sun Aug 30 21:49:46 BST 1998
18104 +
18105 +       * Changed socksys.c to handle new file_operations struct
18106 +         in kernel 2.1.119 and later.
18107 +         -- Mike
18108 +
18109 +
18110 +Sat Aug 22 19:57:01 BST 1998
18111 +
18112 +       * Fixes and additions to user pointer checking in ipc.c
18113 +         -- Mike
18114 +
18115 +       * Changed some more KERN_ERRs to KERN_DEBUGs in the
18116 +         STREAMS ioctl support.
18117 +         -- Mike
18118 +
18119 +
18120 +Fri Aug 21 20:24:32 BST 1998
18121 +
18122 +       * Somehow fchdir had been missed from the main iBCS call
18123 +         map even though it had been put in the BSD map. Oops.
18124 +         -- Mike
18125 +
18126 +
18127 +Wed Aug 19 23:12:47 BST 1998
18128 +
18129 +       * ALPHA 2.1 release number 2...
18130 +         -- Mike
18131 +
18132 +
18133 +Wed Aug 19 20:43:09 BST 1998
18134 +
18135 +       * Avoid calling rt_sigaction if the mapped signal number
18136 +         is -1. It is not strictly necessary but why bother?
18137 +         -- Mike
18138 +
18139 +       * Added David Bruce's updated x286emul.
18140 +         -- Mike
18141 +
18142 +
18143 +Mon Aug 17 21:29:53 BST 1998
18144 +
18145 +       * Avoid calling fput with a NULL file pointer.
18146 +         -- Mike
18147 +
18148 +
18149 +Sun Aug 16 17:32:20 BST 1998
18150 +
18151 +       * Fix to copy_{to,from}_user return checking. In many
18152 +         cases we do not care because they are behind verify_area
18153 +         checks but in some we do - and copy_{to,from}_user
18154 +         returns the number of bytes _uncopied_.
18155 +         -- Mike
18156 +
18157 +
18158 +Sat Aug 15 23:39:42 BST 1998
18159 +
18160 +       * Change the flock handling to bounce the flock struct
18161 +         through kernel space rather than using an in place
18162 +         modification. The assumptions we were making about
18163 +         segment registers seem to have become invalid at some
18164 +         point. We could go to put_user(get_user()) but moving
18165 +         the whole struct is probably more robust. Which is
18166 +         faster? I dunno...
18167 +         -- Mike
18168 +
18169 +
18170 +Sat Aug 15 22:30:41 BST 1998
18171 +
18172 +       * Changes to signal functions. Previous code confused old and
18173 +         new sigsets and could have lead to memory corruption and
18174 +         was likely the cause of signals getting blocked unexpectedly.
18175 +         Now we use the rt_sig* and new sigset interface to the
18176 +         kernel exclusively (in a few years the old stuff may be
18177 +         removed). This does means that a non-Linux program may
18178 +         now operate on signals >32 which may not have existed
18179 +         (and therefore would have errored) in the native environment.
18180 +         This may be considered a bug or a feature as appropriate...
18181 +         -- Mike
18182 +
18183 +
18184 +Mon Jul 20 22:23:14 BST 1998
18185 +
18186 +       * ALPHA 2.1 release...
18187 +         -- Mike
18188 +
18189 +
18190 +Mon Jul 20 20:55:47 BST 1998
18191 +
18192 +       * Added support for I_FDINSERT in the STREAMS/TLI message
18193 +         protocol handling. This allows TLI server code to work
18194 +         using a _real_ libnsl_s (tested briefly) but will break
18195 +         server code using my replacement libnsl_s until I update
18196 +         it. (It should probably use an I_FDINSERT simply so it
18197 +         can still run under SYSV if ever necessary.)
18198 +         -- Mike
18199 +
18200 +       * Use TIOCINQ instead of FIONREAD in the STREAMS ioctl handler.
18201 +         FIONREAD isn't actually supported on sockets. The socksys
18202 +         code already had this right.
18203 +         -- Mike
18204 +
18205 +       * Do the MOD_INC, MOD_DEC calls for sockets in the inherit
18206 +         and release handling only to reduce the opportunity for,
18207 +         ah, "oversights".
18208 +         -- Mike
18209 +
18210 +
18211 +Thu Jul 16 22:11:48 BST 1998
18212 +
18213 +       * Finally got round to adding a GNU CopyLeft!
18214 +         -- Mike
18215 +
18216 +       * Set up an XTI/TLI private state struct on all sockets at
18217 +         the same time we plug our own file operations in. This
18218 +         costs a small amount of extra memory per socket. However
18219 +         this is strictly correct (although unlikely to be actually
18220 +         _required_ by anything). It also allows us to set up TEPs
18221 +         created by XTI/TLI listen/accept easily so they have a
18222 +         chance of working.
18223 +         -- Mike
18224 +
18225 +       * XTI/TLI fixes:
18226 +         Do not auto-listen in getmsg() - listen() after connect()
18227 +         appears to crash some 2.1 kernels(?).
18228 +         Change the probe for activity in getmsg() to use the
18229 +         new poll handler directly.
18230 +         Handle listening TEPs slightly better.
18231 +         -- Mike
18232 +
18233 +       * Changed a stray KERN_ERR to KERN_DEBUG in ioctl.c
18234 +         -- Mike
18235 +
18236 +
18237 +Fri Jul  3 23:20:37 BST 1998
18238 +
18239 +       * Fixed the initial set up of the argument and environment
18240 +         lists which were broken during the change to 2.1 style
18241 +         user memory access.
18242 +         -- Mike
18243 +
18244 +
18245 +Mon Jun 29 22:50:11 BST 1998
18246 +
18247 +       * Put kernel_version definition back in emulate.c
18248 +         -- Mike
18249 +
18250 +       * Change loaders to set start_text, end_text, start_data,
18251 +         end_data, start_brk, brk fully.
18252 +         -- Mike
18253 +
18254 +
18255 +Thu Jun 25 21:18:11 BST 1998
18256 +
18257 +       * Added support for the "fat" IPC structures which use
18258 +         32 bit uids, gids etc.
18259 +         -- Mike
18260 +
18261 +
18262 +Wed Jun 24 21:30:09 BST 1998
18263 +
18264 +       * Change suser() checks to use the new capable() calls.
18265 +         -- Mike
18266 +
18267 +       * Changed the CONFIG default to NOT support Xenix 286. It
18268 +         is an ever increasing build problem. It needs a volunteer
18269 +         to rewrite it.
18270 +         -- Mike
18271 +
18272 +       * Add locking around system_utsname data using the uts_sem.
18273 +         -- Mike
18274 +
18275 +       * Changed to use dentry stuff. Use fget()/fput() to get
18276 +         file pointers rather than accessing task fd tables
18277 +         directly. Use poll interface for SYSV poll and timod
18278 +         blocking checks. Use lock_kernel()/unlock_kernel()
18279 +         around stat routines and other namei stuff. Use dput()
18280 +         to release dentries obtained with namei(). Other
18281 +         incidental fixes to what went before as I noticed them.
18282 +         -- Mike
18283 +
18284 +
18285 +Tue Jun  9 20:02:56 BST 1998
18286 +
18287 +       * More changes for new module conventions.
18288 +         -- Mike
18289 +
18290 +       * Changed signal stuff to new conventions.
18291 +         -- Mike
18292 +
18293 +       * Changed getname() calling convention.
18294 +         -- Mike
18295 +
18296 +       * Changed fs type to mm_segment_t.
18297 +         -- Mike
18298 +
18299 +       * Changed user VM accesses to use new conventions.
18300 +         -- Mike
18301 +
18302 +
18303 +Sat Jun  6 20:30:00 BST 1998
18304 +
18305 +       * Changed to new module conventions.
18306 +         -- Mike
18307 +
18308 +
18309 +Thu May 28 22:30:45 BST 1998
18310 +
18311 +       * Removed VM_STACK_FLAGS tests.
18312 +         -- Mike
18313 +
18314 +       * Remove VM_GROWSDOWN tests.
18315 +         -- Mike
18316 +
18317 +       * Removed MAP_EXECUTABLE tests.
18318 +         -- Mike
18319 +
18320 +       * Removed MAP_DENYWRITE tests.
18321 +         -- Mike
18322 +
18323 +       * Removed STACK_TOP tests.
18324 +         -- Mike
18325 +
18326 +       * Removed FORKNOEXEC tests.
18327 +         -- Mike
18328 +
18329 +       * Removed INIT_MM tests.
18330 +         -- Mike
18331 +
18332 +
18333 +Mon May 18 22:49:56 BST 1998
18334 +
18335 +       * Fixed xnx_rdchk() return value.
18336 +         -- Mike
18337 +
18338 +       * The serial number returned in the SCO utsname struct
18339 +         can now be set with sco_serial="..." as a module
18340 +         option. Some program apparently want to find a real,
18341 +         believable serial number there. This should be documented
18342 +         somewhere other than here I guess...
18343 +         -- Mike
18344 +
18345 +
18346 +Mon May 18 22:03:49 BST 1998
18347 +
18348 +       * A class 't' ioctl with no arg type stuff in the top
18349 +         word is either an SVR4 tape ioctl a Coherent BSD-ish
18350 +         termios ioctl.
18351 +         -- Mike
18352 +
18353 +
18354 +Mon Feb  2 22:57:45 GMT 1998
18355 +
18356 +       * Other relatively minor changes to allow compilation
18357 +         under glibc (specifically 2.0.6 but it shouldn't
18358 +         matter).
18359 +         -- Mike
18360 +
18361 +       * Added an explicit -I flag to search /usr/src/linux/include
18362 +         since glibc doesn't necessarily require the kernel
18363 +         includes to be symlinked under /usr/include.
18364 +         -- Mike
18365 +
18366 +       * The personality defaults in binfmt_coff should probably
18367 +         select short inodes on the assumption that newer stuff
18368 +         is likely to be built as ELF anyway. I hope.
18369 +         -- Mike
18370 +
18371 +
18372 +Wed Nov 19 19:28:07 GMT/BST 1997
18373 +
18374 +       * Attempt to work around problems with sign extension
18375 +         when programs believe that the fs magic in a sysfs()
18376 +         call is short rather than long.
18377 +         -- Mike
18378 +
18379 +       * Added IPPROTO_IP/SOL_IP option name mapping for
18380 +         {get,set}sockopt. This is correct for SCO OS5 and
18381 +         hopefully for other SYSV derived Unices. Note that
18382 +         SCO OS5 ping still doesn't work because it uses an
18383 +         unsigned char for the IP_TTL value whereas Linux
18384 +         wants an int - and it objects to getting an error
18385 +         return. Apparently POSIX 1003g says IP_TTL should
18386 +         be an unsigned char so OS5, or at least its ping,
18387 +         is at fault. This probably isn't worth hacking
18388 +         around unless someone _really_ needs it.
18389 +         -- Mike
18390 +
18391 +
18392 +Wed Nov 12 22:28:19 GMT/BST 1997
18393 +
18394 +       * Added the SCO-ish syscall shortcut to the socksys
18395 +         networking code.
18396 +         -- Mike
18397 +
18398 +
18399 +Fri Nov  7 20:13:05 GMT/BST 1997
18400 +
18401 +       * Oops, I installed the SCO signal tables in the old
18402 +         personality mapping but forgot to create a specific
18403 +         SCO personality using them.
18404 +         -- Mike
18405 +
18406 +
18407 +Thu Nov  6 08:04:37 GMT/BST 1997
18408 +
18409 +       * No, it really should be USR1 for URG under SCO, not
18410 +         USR2. This is according to the SCO Network Programmer's
18411 +         documentation. The previous problem was because
18412 +         confusion between the SVR4 and SCO/SVR3 requirements
18413 +         prevented a SCO program from registering a handler
18414 +         for the right signal, I think.
18415 +         -- Mike
18416 +
18417 +
18418 +Wed Nov  5 14:23:22 GMT/BST 1997
18419 +
18420 +       * Created a new signal mapping for SCO and mapped
18421 +         Linux SIGURG to SCO SIGUSR2. Also changed the
18422 +         plain ibcs mapping for SIGURG back to IBCS_SIGURG.
18423 +         Previously I had SIGURG mapped to SIGUSR1 for
18424 +         what my subconscious says was a good reason but
18425 +         I can't figure out where I got it from. The USR2
18426 +         mapping is according to Peter Brueckner - and if
18427 +         it works for him...
18428 +         -- Mike
18429 +
18430 +
18431 +Wed Nov  5 09:14:27 GMT/BST 1997
18432 +
18433 +       * Repair the STREAMS based socket code. The new socket
18434 +         hashing in 2.0.30 and beyond means the old code no
18435 +         longer works. We now delay replacing the fd with
18436 +         a socket until the first read, write or ioctl. Since
18437 +         the open has completed at this stage and the fd is
18438 +         fully initialized we can then use dup() to do the
18439 +         fd switch, which should always work. As a side effect
18440 +         this allows us to auto-connect an SPX pipe to X :0
18441 +         if the first operation is other than a single character
18442 +         write - which should allow us to handle v. old SVR3
18443 +         X programs side by side with their more modern, and
18444 +         common, multi-SPX pipe descendants.
18445 +           This does mean that some error returns from an
18446 +         open of a TLI special file might be delayed until
18447 +         the first operation, however a) these are unlikely
18448 +         to occur (they are things like no such protocol)
18449 +         and b) most opens of such files are hidden in
18450 +         functions like t_open() anyway so if there is a
18451 +         problem a simple fix to libnsl to check the first
18452 +         ioctl is all that is needed.
18453 +         -- Mike
18454 +
18455 +       * sysfs() used to enumerate available filesystems seems
18456 +         to be 0 based on Linux but 1 based on SYSV.
18457 +         -- Mike
18458 +
18459 +
18460 +Sun Oct 12 00:18:33 GMT/BST 1997
18461 +       * Ioctls on the NFS pseudo device need to go via the
18462 +         emulation code rather than the native ioctl handler.
18463 +         -- Mike
18464 +
18465 +
18466 +Sat Aug 16 14:56:24 GMT/BST 1997
18467 +
18468 +       * Changed the use of errno in a prototype in ibcs.h to
18469 +         avoid possible conflict with an SMP errno definition
18470 +         which could get inherited from an include file if we
18471 +         aren't careful.
18472 +         -- Mike
18473 +
18474 +
18475 +Sat Jul 12 01:00:00 GMT/BST 1997
18476 +
18477 +       * Added Xenix locking() modes 5, 6, 7 as per patch from
18478 +         David Bruce <admin@hulcote.com> (there were others
18479 +         too). I rewrote it to be a bit cleaner but I haven't
18480 +         tested it (it's late...). Some one will tell me I guess.
18481 +         -- Mike
18482 +
18483 +Fri Jul 11 22:27:13 GMT/BST 1997
18484 +
18485 +       * Added more console ioctl traps to discourage programs
18486 +         from trying to do funky stuff with the console without
18487 +         logging unsupported ioctl messages.
18488 +         -- Mike
18489 +
18490 +       * sysfs() can, apparently, map an fs magic number to
18491 +         an fs name. We do this outside the kernel sysfs()
18492 +         because there seems no clean way to do it. We simply
18493 +         have a list of known magic numbers hard coded :-(.
18494 +         -- Mike
18495 +
18496 +       * Implemented sysconfig(). This is appears to be the SVR4
18497 +         forerunner to the POSIX sysconf().
18498 +         -- Mike
18499 +
18500 +
18501 +Tue May 13 20:52:05 GMT/BST 1997
18502 +
18503 +       * Hand off xmknod calls via ibcs_mknod so that we can
18504 +         create a directory if that is what the flags imply.
18505 +         I have not tested to see if xmknod is allowed to create
18506 +         directories - I just noticed it in passing.
18507 +         -- Mike
18508 +
18509 +       * Added SCO's F_GETHFDO (get highest fd open) fcntl. This is
18510 +         used by /bin/csh on SCO OS5 to save a few syscalls.
18511 +         -- Mike
18512 +
18513 +
18514 +Tue May 13 00:10:09 GMT/BST 1997
18515 +
18516 +       * More changes to handle long/short inode environments
18517 +         plus more explanation in the code. Are we having fun yet?
18518 +         -- Mike
18519 +
18520 +
18521 +Sat May 10 15:19:39 GMT/BST 1997
18522 +
18523 +       * Added socketpair() to the socksys emulation. This is
18524 +         as implemented by SCO OpenServer 5.
18525 +         -- Mike
18526 +
18527 +       * Change binfmt_coff.c to recognise programs compiled for
18528 +         SCO OpenServer 5, programs compiled for SCO 3.2.4 and
18529 +         programs compiled under SCO OpenServer 5 but with
18530 +         compatibility for ODT3.0. Why? Well, sometimes we
18531 +         should be giving long inodes in returns from getdents,
18532 +         sometimes short inodes. We don't just want to mask
18533 +         off the high part because that can lead to some
18534 +         things becoming invisible. We don't want that.
18535 +         -- Mike
18536 +
18537 +
18538 +Fri May  9 23:29:37 GMT/BST 1997
18539 +
18540 +       * Added some more tape ioctls.
18541 +         -- Mike
18542 +
18543 +
18544 +Wed Apr 16 23:12:37 GMT/BST 1997
18545 +
18546 +       * Fix memory leaks in poll.c and change ENOMEM return
18547 +         to EAGAIN.
18548 +         -- Mike
18549 +
18550 +
18551 +Tue Mar 11 21:29:15 GMT/BST 1997
18552 +
18553 +       * Add {get,set}rlimit to the SYSV personalities.
18554 +         -- Mike
18555 +
18556 +
18557 +Fri Mar  7 21:04:24 GMT/BST 1997
18558 +
18559 +       * Only build x286emul if EMU_X286 is enabled in CONFIG. There
18560 +         are many insallations which appear to either not have the
18561 +         a.out compiler support or have it installed incorrectly.
18562 +         -- Mike
18563 +
18564 +
18565 +Tue Feb 18 22:04:39 GMT/BST 1997
18566 +
18567 +       * Removed unnecessary and incorrect includes.
18568 +         -- Mike
18569 +
18570 +
18571 +Wed Feb 12 22:03:13 GMT/BST 1997
18572 +
18573 +       * Documentation updates for release.
18574 +         -- Mike
18575 +
18576 +
18577 +Mon Feb 10 22:36:27 GMT/BST 1997
18578 +
18579 +       * Dammit! The inode folding in stat() and getdents() was
18580 +         out of step _again_ :-(.
18581 +         -- Mike
18582 +
18583 +
18584 +Sun Jan  5 17:20:20 GMT/BST 1997
18585 +
18586 +       * sysconf(_SC_CLK_TCK) should return the value of HZ.
18587 +         -- Mike
18588 +
18589 +       * Small clarification to README concerning shared libraries.
18590 +         -- Mike
18591 +
18592 +       * Removed the bit about UnixWare X binaries not working from
18593 +         Doc/HINTS. Now we have STREAMS/TLI emulation this is no
18594 +         longer true (and hasn't been for a while).
18595 +         -- Mike
18596 +
18597 +
18598 +Sat Jan  4 19:31:26 GMT/BST 1997
18599 +
18600 +       * If we open() something that is really a socket we close
18601 +         it and reopen it using socket(), connect(). This allows
18602 +         a Unix domain socket to look like a named pipe which
18603 +         enables more SYSV X clients to connect to a local X
18604 +         server using the local method (with suitable symlinks
18605 +         to map the pathnames).
18606 +         -- Mike
18607 +
18608 +
18609 +Fri Jan  3 22:39:15 GMT/BST 1997
18610 +
18611 +       * Added a (simplistic) implementation of the I_CANPUT SVR4
18612 +         STREAMS ioctl.
18613 +         -- Mike
18614 +
18615 +       * Changed CONFIG.i386 to note that a correct setting of SMP
18616 +         is now necessary.
18617 +         -- Mike
18618 +
18619 +
18620 +Wed Oct  2 16:28:39 GMT/BST 1996
18621 +
18622 +       * Intercept mknod() and allow it to create directories. Linux
18623 +         doesn't allow this but SYSV does. (What about BSD?)
18624 +         -- Mike
18625 +
18626 +
18627 +Wed Oct  2 15:56:57 GMT/BST 1996
18628 +
18629 +       * Separated out the spx connect code so we can support old,
18630 +         single connection spx implementations once we know how to
18631 +         recognise them.
18632 +         -- Mike
18633 +
18634 +Wed Oct  2 15:54:45 GMT/BST 1996
18635 +
18636 +       * At some stage I add some binfmt_elf.c changes that were
18637 +         made to the kernel ELF loader in some 2.0.x patch. I forget
18638 +         which now but no one should be using the iBCS ELF loader
18639 +         currently anyway.
18640 +         -- Mike
18641 +
18642 +
18643 +Fri Aug 23 15:42:04 GMT/BST 1996
18644 +
18645 +       * Moved svr4sig to the right place.
18646 +         -- Mike
18647 +
18648 +       * Moved error message strings to a separate file so they can
18649 +         be shared by emulate.c and solaris.c.
18650 +         -- Mike
18651 +
18652 +       * CONFIG files now define ARCH to be the CPU architecture. This
18653 +         is used to ensure that architecture specific files are only
18654 +         used when necessary.
18655 +         -- Mike
18656 +
18657 +       * Changed the getdents routine in open.c to use the same
18658 +         rules for folding 32 bit inodes to 16 as stat and read.
18659 +         -- Mike
18660 +
18661 +
18662 +Mon Aug 19 13:33:42 GMT/BST 1996
18663 +
18664 +       * Correct IPC problem introduced with Sparc changes.
18665 +         -- Mike
18666 +
18667 +
18668 +Fri Aug  9 13:27:49 GMT/BST 1996
18669 +
18670 +       * Fix the inode swapping for /dev/spx and XTI/TLI transports.
18671 +         -- Mike
18672 +
18673 +       * If a COFF binary doesn't have a .comment section we have no
18674 +         way to tell what personality we should be using. Switch to
18675 +         SCO anyway - odds on it is.
18676 +         -- Mike
18677 +
18678 +
18679 +Wed Aug  7 14:22:11 GMT/BST 1996
18680 +
18681 +       * On SCO at least lseek on a character or block device
18682 +         returns 0 not -ESPIPE.
18683 +         -- C.A. Lademann <cal@zls.com>
18684 +
18685 +       * Some problems with /dev/spx and TLI end point handling that
18686 +         could leak descriptors, memory and leave the lists of file
18687 +         locks in an inconsistent state. Not to mention the fact that
18688 +         the socket data in an inode also contains a pointer back to
18689 +         the process' file structure. I _think_ I have this sorted
18690 +         out now...
18691 +         -- Mike
18692 +
18693 +       * Sparc changes broke select. While I was at it I changed it
18694 +         to use the newselect Linux call as well. If we build without
18695 +         tracing we'll save a few more bytes of code now too.
18696 +         -- Mike
18697 +
18698 +
18699 +Wed Jul 31 14:16:38 GMT/BST 1996
18700 +
18701 +       * Map EAGAIN to EWOULDBLOCK for recv*() and send*() syscalls.
18702 +         Linux seems to return EAGAIN. X/Open allows either EAGAIN
18703 +         or EWOULDBLOCK. SVR4 and Wyse V/386 specify EWOULDBLOCK in
18704 +         their man pages. SCO doesn't admit to non-blocking possibilities
18705 +         in their man pages but some code seems to expect only
18706 +         EWOULDBLOCK.
18707 +         -- Mike
18708 +
18709 +
18710 +Mon Jul 29 16:58:11 GMT/BST 1996
18711 +
18712 +       * Added a CONFIG option for SMP. This is enabled by default.
18713 +         I don't think this is a problem for non-SMP systems?
18714 +         -- Mike
18715 +
18716 +       * Minor change to the SCO error map.
18717 +         -- Mike
18718 +
18719 +
18720 +Fri Jul 26 09:13:43 GMT/BST 1996
18721 +
18722 +       * Updated README and RELEASE
18723 +         -- Mike
18724 +
18725 +       * Merged Sparc patches from:
18726 +               Miguel de Icaza <miguel@roxanne.nuclecu.unam.mx>
18727 +         -- Mike
18728 +
18729 +
18730 +Thu Jul  4 12:24:06 GMT/BST 1996
18731 +
18732 +       * The default is now *not* to build a versioned module. I got
18733 +         too many questions about why it wouldn't compile.
18734 +         -- Mike
18735 +
18736 +       * Fix to binfmt_xout.c when Xenix 286 is emulation is not
18737 +         configured.
18738 +         -- Mike
18739 +
18740 +
18741 +Fri Jun 14 13:36:18 GMT/BST 1996
18742 +
18743 +       * Added code to explicitly fail the SCO LD?MAP ioctls used
18744 +         for channel mapping.
18745 +         -- Mike
18746 +
18747 +
18748 +Thu Jun  6 17:21:00 GMT/BST 1996
18749 +
18750 +       * Cleaned up Stephans SCO tape ioctls and added the
18751 +         corresponding SVR4 versions (untested).
18752 +         -- Mike
18753 +
18754 +
18755 +Wed Jun  5 10:47:24 GMT/BST 1996
18756 +
18757 +       * Rewritten the Xenix locking() syscall. The previous one
18758 +         was crap.
18759 +         -- Mike
18760 +
18761 +       * Change the read on directory emulation to fold long inodes
18762 +         to shorts in the same way as stat and getdents. This may
18763 +         help old programs that use stat and read to do a getcwd
18764 +         rather than a stat and getdents.
18765 +         -- Mike
18766 +
18767 +       * Use __get_free_page instead of get_free_page in getdents
18768 +         since we don't need the buffer cleared initially (I think).
18769 +         -- Mike
18770 +
18771 +
18772 +Sat Jun  1 09:50:30 MET DST 1996
18773 +        * Added some tape ioctrls for SCO to iBCSemul/ioctl.c.
18774 +          -- Stephan
18775 +
18776 +
18777 +Fri May 31 08:44:51 GMT/BST 1996
18778 +
18779 +       * Move bsdioctl.c to the main group of source files from
18780 +         than the BSD specifics. Just about everything else has
18781 +         BSD style sgtty stuff and some seemingly modern code
18782 +         actually depends on it (e.g. ISC SVR4 telnet)!
18783 +         -- Mike
18784 +
18785 +       * Add CONFIG option to build a versioned module.
18786 +         -- Mike
18787 +
18788 +       * Install the modules in /lib/modules/`uname -r`/misc for
18789 +         compatibility with the modules tools.
18790 +         -- Mike
18791 +
18792 +       * If the requested connection indications in a bind request
18793 +         is greater than zero do a listen() if the bind is successful.
18794 +         We still also do a listen() if the program selects() on
18795 +         a bound but unconnected stream. This may help some broken
18796 +         programs. It may also break some broken programs. It's
18797 +         debatable whether this should now be in or out.
18798 +         -- Mike
18799 +
18800 +       * The bit vector mapping used for converting vectors of
18801 +         signal flags had an off by one error. The signal maps
18802 +         themselves were also one entry short.
18803 +         -- Mike
18804 +
18805 +       * At some stage I changed the I_SETOWN STREAMS ioctl but
18806 +         never committed it?
18807 +         -- Mike
18808 +
18809 +
18810 +Thu May  9 12:51:10 GMT/BST 1996
18811 +
18812 +       * Change to install in /lib/modules/`uname -r`/misc instead
18813 +         of /usr/lib/modules for compatibility with the way the
18814 +         modules tools have gone.
18815 +         -- Mike
18816 +
18817 +
18818 +Thu Apr 25 12:34:06 GMT/BST 1996
18819 +
18820 +       * Use the CONIND_number in a T_BIND_REQ to decide whether
18821 +         or not we should listen() on the socket.
18822 +         -- Mike
18823 +
18824 +
18825 +Mon Apr 22 15:42:47 GMT/BST 1996
18826 +
18827 +       * Added a simple loader that will attempt to pass scripts
18828 +         that start with ":" and things that look like simple text
18829 +         to /bin/sh. Hopefully this isn't going to conflict with
18830 +         magic for other needed formats...
18831 +         -- Mike
18832 +
18833 +
18834 +Fri Mar 29 17:11:35 GMT/BST 1996
18835 +
18836 +       * Committing the all new TLI/XTI options handling. Note that
18837 +         TLI and XTI option handling is mutually exclusive at the
18838 +         moment. The default is to enable TLI options handling since
18839 +         that is what existing SVR3/4 systems use. I haven't found
18840 +         one that actually handles X/Open format (they use the
18841 +         TNOTSUPPORT cop out) so I don't know how the stack is
18842 +         told to use XTI format instead of TLI.
18843 +           Note that only SOL_SOCKET/* and SOL_TCP/TCP_NDELAY are
18844 +         known to work to any extent at the moment. Others may (or
18845 +         may not need mapping) but I can't find the motivation to
18846 +         wade through the headers and create yet another table of
18847 +         magic numbers. Hopefully everyone just nicked the BSD
18848 +         reference code...
18849 +         -- Mike
18850 +
18851 +       * Some more 1.3.7x changes related to process accounting
18852 +         (fork but no exec etc.).
18853 +         -- Mike
18854 +
18855 +
18856 +Wed Mar 20 13:36:07 GMT/BST 1996
18857 +
18858 +       * I seem to have forgotten to add a comment about merging
18859 +         changes from mid 1.3.7x kernels.
18860 +         -- Mike
18861 +
18862 +
18863 +Wed Feb 28 14:53:00 GMT/BST 1996
18864 +
18865 +       * Fix to shared library loader in binfmt_aout.c from kernel
18866 +         patch 1.3.69.
18867 +         -- Mike
18868 +
18869 +
18870 +Wed Jan 24 09:58:34 GMT/BST 1996
18871 +
18872 +       * Implemented I_PEEK.
18873 +         -- Mike
18874 +
18875 +       * Changed I_NREAD to understand that control messages constitute
18876 +         queued data.
18877 +         -- Mike
18878 +
18879 +
18880 +Fri Jan 19 11:57:20 GMT/BST 1996
18881 +
18882 +       * Make the socket level connect in timod.c happen synchronously
18883 +         always. Allowing the async possibility is a little harder.
18884 +         -- Mike
18885 +
18886 +
18887 +Thu Jan 18 16:06:13 GMT/BST 1996
18888 +
18889 +       * Added (some of) the intial framework for option management.
18890 +         This is documented by X/Open but many XTI stacks don't
18891 +         seem to implement it. Certainly the man page for t_optmgmt
18892 +         in SCO OS5 says it isn't yet implemented. There do seem
18893 +         to be programs out there that make options requests though.
18894 +         Unfortunately I don't have one right now so this is currently
18895 +         disabled and MAY CAUSE KERNEL FAULTS. I don't know...
18896 +         -- Mike
18897 +
18898 +
18899 +Tue Jan 16 12:35:21 GMT/BST 1996
18900 +
18901 +       * Added a slight change to mmap.c. The SVR4 headers describe
18902 +         a slight change in functionality which is specified with
18903 +         a special flag that is supposedly set by the C library
18904 +         interface. I haven't actually seen this flag set by the
18905 +         SVR4 dynamic loader (which is the only mmapper I've seen)
18906 +         and things seem to work with or without this change. It
18907 +         may not be necessary at all?
18908 +         -- Mike
18909 +
18910 +
18911 +Fri Jan 12 14:56:38 GMT/BST 1996
18912 +
18913 +       * Remove trace flag from context() in the callmaps. SVR4's
18914 +         /bin/sh seems to use it but doesn't care if it fails.
18915 +         -- Mike
18916 +
18917 +       * Added the SCO OS5 SI86GETFEATURES request to sysi86(). OS5
18918 +         uses this to establish what "features" are available when
18919 +         a program starts (i.e. in crt*.o). Currently we just return
18920 +         the same vector as OS5 itself. I haven't found what the
18921 +         flags mean - but one of them indicates xstat extensions
18922 +         which I have added to iBCS.
18923 +         -- Mike
18924 +
18925 +       * Change .comment parsers in binfmt_coff.c and binfmt_elf.c
18926 +         so we only grab a single page (asking for two contiguous
18927 +         pages is antisocial) and then roll through the comment
18928 +         section in stages.
18929 +         -- Mike
18930 +
18931 +       * Fixes to binfmt_elf.c and binfmt_aout.c so they compile
18932 +         and load with 1.3 kernels.
18933 +         -- Mike
18934 +
18935 +
18936 +Tue Jan  9 14:29:49 GMT/BST 1996
18937 +
18938 +       * Add a kludge to the TLI connect code. For some reason, under
18939 +         ISC SVR4, telnet seems to gve the port number in network
18940 +         byte order ok but the X programs give it in host byte order.
18941 +         One of them is wrong but presumably both work on ISC (I don't
18942 +         have the hardware to actually install it). We kludge around
18943 +         it here by checking if we are SVR4, AF_INET, port 6000 (host
18944 +         order) and, if so, change it to port 6000 (network order).
18945 +         This will break anything that wants to make an outgoing
18946 +         call to port 28695. There are probably other things that
18947 +         expect incorrect port numbers to work but there seems to
18948 +         be no easy solution here.
18949 +         -- Mike
18950 +
18951 +
18952 +Fri Jan  5 13:34:43 GMT/BST 1996
18953 +
18954 +       * First draft of code to handle select/poll on transport end
18955 +         points correctly. This isn't well tested but should be good
18956 +         enough to support normal timod usage.
18957 +         -- Mike
18958 +
18959 +
18960 +Thu Jan  4 13:52:25 GMT/BST 1996
18961 +
18962 +       * TLI changes to get error returns from connects correctly.
18963 +         -- Mike
18964 +
18965 +
18966 +Wed Jan  3 17:06:07 GMT/BST 1996
18967 +
18968 +       * Added a manual page in the Doc directory. This is not
18969 +         installed by default.
18970 +         -- Mike
18971 +
18972 +       * Fixed a problem in the .comment parsers in binfmt_elf.c
18973 +         and binfmt_coff.c where a number of pages was passed to
18974 +         __get_free_pages() instead of a binary power. This has
18975 +         been in release versions of binfmt_coff.c for a long
18976 +         time but exactly one person has reported anything that
18977 +         might be attributable to it. Strange, since the bug should
18978 +         have manifested itself as insidious memory leakage and
18979 +         corruption...
18980 +         -- Mike
18981 +
18982 +
18983 +Wed Jan  3 12:16:47 GMT/BST 1996
18984 +
18985 +       * Removed all kernel patches in the Patches directory. None
18986 +         should be need for kernels 1.3.50 (or earlier?) and onwards.
18987 +         None should be essential for 1.2.13 - although some capability
18988 +         is lost notably SCO OpenServer 5 ELF binaries (if the kernel
18989 +         ELF loader is present) and BSD a.out binaries.
18990 +         -- Mike
18991 +
18992 +       * Another fix to termio[s] ioctls to get the control character
18993 +         settings right for SVR4. Previously this was just copied
18994 +         from the SCO mapping and just never got changed.
18995 +         -- Mike
18996 +
18997 +
18998 +Thu Dec 14 10:41:36 GMT 1995
18999 +
19000 +       * Added basic getpmsg/putpmsg support. It doesn't do anything
19001 +         with bands but we don't have anyway to use them.
19002 +         -- Mike
19003 +
19004 +
19005 +Tue Dec 12 09:38:01 GMT 1995
19006 +
19007 +       * First commit of the major TLI rewrite for Eric Sixt. This
19008 +         should be enough for normal TCP & UDP clients. It may be
19009 +         sufficient for servers as well but this is untested so far.
19010 +         The client stuff has been tested with SCO cu, ISC telnet
19011 +         and custom test code down to the getmsg/putmsg level. A shared
19012 +         libnsl_s is also included. This has the functions needed for
19013 +         clients but lacks some needed for servers currently. It has
19014 +         been tested on a real SCO system. It could be done better
19015 +         (and should be) but for now we are interested in making existing
19016 +         programs work rather than handling all the error conditions
19017 +         by the book. The library uses SVR3 shared library tools and
19018 +         needs to be built on an SVR3 system (I used SCO).
19019 +           Included is a rewrite of the /dev/spx kludging (the old didn't
19020 +         work if TLI was enabled). This now allows connections to other
19021 +         than /tmp/.X11-unix/X0 (if configured) so you can run multiple
19022 +         X servers on the VCs and display SCO X programs on all of them.
19023 +           The major/minor numbers used for the emulation devices have
19024 +         (necessarily) changed. The top level Makefile will (re)create
19025 +         them on a "make install" or "make devices".
19026 +           Oh yeah, I built stubs for other libraries as well (specifically
19027 +         SCO/SecureWare protlib_s) but don't expect it to have any real
19028 +         support. If programs _really_ need stuff from there they are
19029 +         like to have reduced or completely broken functionality on
19030 +         Linux!
19031 +           The script I used to generate the skeleton APIs for the
19032 +         shared libraries is libs/mkltab if anyone feels the urge to
19033 +         look at other libraries...
19034 +         -- Mike
19035 +
19036 +       * Removed the old quota compile option. It isn't compatible with
19037 +         the quota stuff in 1.3.46 and would only cause confusion. This
19038 +         means you can't use iBCS if you have the old quota patches
19039 +         in a pre-1.3.46 kernel. Tough :-).
19040 +         -- Mike
19041 +
19042 +
19043 +Mon Dec 11 15:14:46 GMT 1995
19044 +
19045 +       * Map I_SETSIG/I_GETSIG to FIOSETOWN/FIOGETOWN and pray...
19046 +         -- Mike
19047 +
19048 +       * Fixed possible memory leak in COFF & ELF personality recognition
19049 +         when the offset/size of the .comments section is invalid. This
19050 +         could leak when the .comments section exists but is zero bytes
19051 +         long I think.
19052 +         -- Mike
19053 +
19054 +
19055 +Wed Dec  6 11:31:27 GMT 1995
19056 +
19057 +       * A stat of a file must give an inode that matches what we get
19058 +         from a read of the directory since code that figures out cwd
19059 +         needs the inodes to match. Mind you, if there are several inode
19060 +         numbers greater than 65534 in the directory we are going to get
19061 +         some strange paths. I don't know if this is fixable properly at
19062 +         all?
19063 +         -- Mike
19064 +
19065 +       * Yes it is. We just mask off the high word to get the short
19066 +         inode number for the stat structure.
19067 +         -- Mike
19068 +
19069 +
19070 +Thu Nov 30 16:21:32 GMT 1995
19071 +
19072 +       * Fix the SVR4 additions to the V7 terminal ioctls. Add handling
19073 +         of TIOC[GS]ETD. Have TIOCL[GS]ET trivially succeed (I can't
19074 +         find the documentation for the arguments).
19075 +         -- Mike
19076 +
19077 +
19078 +Wed Nov 29 12:57:42 GMT 1995
19079 +
19080 +       * Changed the guesswork svr4_waitsys to implement the correct
19081 +         waitid syscall.
19082 +         -- Mike
19083 +
19084 +       * Enable the i486-linuxaout option in x286emul/Makefile by
19085 +         default. There seem to be significant numbers of people
19086 +         using ELF compilers now. This may be a mistake...
19087 +         -- Mike
19088 +
19089 +       * Fixes to sigsuspend and sigpause in signal.c. The previous
19090 +         invocations of the Linux sigsuspend syscall were wrong and
19091 +         liable to lead to random freeze ups of programs which used
19092 +         sigsuspend() or sigpause().
19093 +         -- Mike
19094 +
19095 +
19096 +Fri Nov 24 11:03:01 GMT 1995
19097 +
19098 +       * Interactive SVR4 seems to be overloading the BSD termio
19099 +         ioctls with its own.
19100 +         -- Mike
19101 +
19102 +       * The SVR4 procid subcodes don't match the SCO ones. Or, at
19103 +         least, I seem to remember I got the orignal set from SCO
19104 +         and UnixWare and Interactive SVR4 are different (but match
19105 +         each other).
19106 +         -- Mike
19107 +
19108 +
19109 +Thu Nov 23 17:21:56 GMT 1995
19110 +
19111 +       * Interactive SVR4's /bin/sh calls access(..., 011) but Linux
19112 +         returns EINVAL if the access mode has any other bits than
19113 +         007 set. So we have to wrap it and mask it :-(.
19114 +         -- Mike
19115 +
19116 +
19117 +Wed Nov 22 10:11:49 GMT 1995
19118 +
19119 +       * Change to binfmt_elf.c to set total_vm value introduced in
19120 +         kernel 1.3.43.
19121 +         -- Mike
19122 +
19123 +
19124 +Thu Nov 16 15:02:58 GMT 1995
19125 +
19126 +       * Added support for SCO OpenServer 5 binaries using .comment
19127 +         section parsing as with COFF.
19128 +           Built a BSD capable a.out loader as part of iBCS.
19129 +           The iBCS ELF loader is only used for recognised (using
19130 +         .comments) binaries if the standard ELF loader is configured
19131 +         in the kernel iBCS is built against. If the ELF loader is
19132 +         not configured in the kernel iBCS is built against the iBCS
19133 +         ELF loader is used for all ELF binaries. This prevents the
19134 +         iBCS module from becoming un-unloadable on ELF based Linux
19135 +         systems.
19136 +           Similarly the iBCS a.out loader tries to avoid dealing
19137 +         with anything other than BSD binaries for the same reasons.
19138 +           This requires a kernel 1.3.42 or greater to allow iBCS
19139 +         to insert its loaders into the list before the standard
19140 +         kernel ones. Kernels 1.3.39(~) to 1.3.41 have some support
19141 +         but there are bugs which will likely prevent you running
19142 +         *anything* as soon as iBCS is loaded. Mea culpa. Tough.
19143 +         -- Mike
19144 +
19145 +
19146 +Thu Nov 16 11:00:08 GMT 1995
19147 +
19148 +       * Minor clean up in binfmt_coff.c and fix a minor bug in
19149 +         parse_comments that caused it to miss checking a string
19150 +         if there was a zero length string in among.
19151 +         -- Mike
19152 +
19153 +
19154 +Fri Nov 10 12:22:05 GMT 1995
19155 +
19156 +       * Changes for latest module bogosities (~1.3.38). We need to
19157 +         define __NO_VERSION__ to avoid linux/module.h putting
19158 +         a kernel_version in *every* damn file.
19159 +         -- Mike
19160 +
19161 +
19162 +Tue Nov  7 10:55:05 GMT 1995
19163 +
19164 +       * When stealing temp space from the stack we have to actually
19165 +         move esp down and then restore it as the 1.3.x kernels add
19166 +         a check to trap out of bounds stack accesses. This is not
19167 +         tested but I think it only affects the TLI emulation code
19168 +         which is disabled by default.
19169 +         -- Mike
19170 +
19171 +
19172 +Mon Oct  9 11:22:29 BST 1995
19173 +
19174 +       * Use kernel readv/writev if available.
19175 +         -- Mike
19176 +
19177 +
19178 +Thu Sep 14 12:21:48 BST 1995
19179 +
19180 +       * Changed references to current->sigaction to allow for the
19181 +         changes in kernel patch 1.3.26 which allow sharing of signal
19182 +         state between clone processes.
19183 +         -- Mike
19184 +
19185 +
19186 +Mon Sep  4 10:04:22 BST 1995
19187 +         Originally: Wed Aug  2 09:57:56 GMT 1995
19188 +
19189 +       * Removed Xenix interrupt bug, created wait() workaround
19190 +         for INFORMIX-SQL and built the locking() to fcntl()
19191 +         mapping.
19192 +         -- Peter <polte@bbtt.com>
19193 +
19194 +
19195 +Wed Aug 30 09:19:54 BST 1995
19196 +
19197 +       * Merged kernel patch for binfmt_elf.c from 1.3.21 which sets
19198 +         EDX to zero on process start up. See the comment in the code
19199 +         for reasons.
19200 +         -- Mike
19201 +
19202 +
19203 +Tue Aug 29 08:44:50 BST 1995
19204 +
19205 +       * Workaround. Local X won't work because a putmsg occurs
19206 +         after we have already swapped the open descriptor for a
19207 +         Unix domain socket. We either need to peek at socket
19208 +         internals or actually implement the messages for passing
19209 +         file descriptors. This quick fix enables local X connections
19210 +         if we build without XTI support.
19211 +         -- Mike
19212 +
19213 +
19214 +Tue Aug  8 11:36:41 BST 1995
19215 +
19216 +       * Fix streams kludging so local X works again (should do
19217 +         anyway - it's untested as yet due to hard disk collapse.
19218 +         Hopefully someone will tell me if it doesn't work.)
19219 +         -- Mike
19220 +
19221 +
19222 +Mon Jul 31 13:25:58 BST 1995
19223 +
19224 +       * Changes to allow compilation in the presence of a kernel
19225 +         built with the quota patches.
19226 +         -- Dimitrios Mpougoulias <dbougo@leon.nrcps.ariadne-t.gr>
19227 +
19228 +
19229 +Tue Jul 18 09:01:53 BST 1995
19230 +
19231 +       * Fixed timod getinfo ioctl. This functionality should move
19232 +         into the message handling as bind has.
19233 +         -- Mike
19234 +
19235 +
19236 +Mon Jul 17 10:16:43 BST 1995
19237 +
19238 +       * Added handling of BSD-ish sgtty ioctls. For some reason the
19239 +         SVR4 network programs such as telnet have been modified to
19240 +         pushd the ttold STREAMS modules and use sgtty calls instead
19241 +         of simply using termio[s]. Don't blame me! :-)
19242 +         -- Mike
19243 +
19244 +       * Restructuring of timod.c complete. Timod ioctls now use
19245 +         message routines to avoid duplicating code.
19246 +         -- Mike
19247 +
19248 +
19249 +Wed Jul 12 14:44:30 BST 1995
19250 +
19251 +       * Made debug output in binfmt_coff.c less verbose. We only
19252 +         really care about matched comment strings. If we dump them
19253 +         all here we overrun the kernel message buffer and miss
19254 +         interesting stuff when the program actually starts running.
19255 +         -- Mike
19256 +
19257 +       * Changed __get_free_pages in binfmt_coff.c to give the extra
19258 +         argument required in 1.3 kernels.
19259 +         -- Mike
19260 +
19261 +
19262 +Tue Jul  4 11:48:27 BST 1995
19263 +
19264 +       * Restructure timod.c ready to rewrite timod_ioctl to use
19265 +         putmsg/getmsg rather than reimplementing the same message
19266 +         protocol again.
19267 +         -- Mike
19268 +
19269 +
19270 +Mon Jul  3 13:41:49 BST 1995
19271 +
19272 +       * Initial TLI support for outgoing TCP and UDP. Merged BSD/Wyse
19273 +         socket ioctl handling with the socksys handler. Fixed (some)
19274 +         bugs in poll() emulation. Devices in /dev/inet have changed
19275 +         to support TLI access. See README for details.
19276 +         -- Mike
19277 +
19278 +
19279 +Tue Jun 27 09:00:02 BST 1995
19280 +
19281 +       * Don't export symbols from iBCS. I'm not sure when register_symtab
19282 +         was introduced so we only drop our symbol table in 1.3
19283 +         and later.
19284 +         -- Mike
19285 +
19286 +       * Added missing brackets in binfmt_elf.c as per kernel
19287 +         patch 1.3.4.
19288 +         -- Mike
19289 +
19290 +
19291 +Thu Jun 22 13:09:49 BST 1995
19292 +
19293 +       * Big step forward with TLI. I now seem to understand what is
19294 +         happening when and have enough to do the initial open and
19295 +         get info requests. This may one day actually work...
19296 +         -- Mike
19297 +
19298 +       * Trap EUC ioctls and return EINVAL. We don't do EUC :-).
19299 +         -- Mike
19300 +
19301 +       * Changes for the 1.3 development kernel. This compiles but is
19302 +         as yet untested. It still seems ok with 1.2.10.
19303 +         -- Mike
19304 +
19305 +
19306 +Wed Jun 14 09:15:39 BST 1995
19307 +
19308 +       * Added Eric's protection mapping fixes to binfmt_elf.c
19309 +         from 1.2.10.
19310 +         -- Mike
19311 +
19312 +
19313 +Fri Jun  9 12:31:53 BST 1995
19314 +
19315 +       * Linux can't stat unmounted filesystems but SCO can (by
19316 +         specifying the pathname/fd of a block device and the
19317 +         filesystem type. Linux will just stat the filesystem
19318 +         that the device node is on (i.e. the root filesystem).
19319 +         There isn't much we can do about it. I just lie and
19320 +         claim there is 100MB free of 1GB. I hope this won't
19321 +         cause too much grief...
19322 +         -- Mike
19323 +
19324 +
19325 +Thu May 18 12:06:50 BST 1995
19326 +
19327 +       * When trying to get an IP domain name don't try the utsname
19328 +         domainname if it is "(none)". If we get that far we have to
19329 +         give in and return a blank domain name.
19330 +         -- Mike
19331 +
19332 +
19333 +Wed May 17 10:15:42 BST 1995
19334 +
19335 +       * Recheck the socket functions when accept returns a new socket.
19336 +         This is pedantic at this stage since we must have had a
19337 +         socket initially and the current kernel code isn't likely
19338 +         to handle removal and reloading of in use modules. iBCS
19339 +         can handle this happening to it though :-).
19340 +         -- Mike
19341 +
19342 +       * Fix timod faking to correctly return an error if given an
19343 +         invalid file descriptor rather than trying to dereference
19344 +         a null pointer in kernel mode.
19345 +         -- Mike
19346 +
19347 +
19348 +Tue Apr 25 11:35:43 BST 1995
19349 +
19350 +       * If nap() is given a zero timeout return immediately rather
19351 +         than blocking indefinitely. Ensure that SIGALRM is not ignored
19352 +         during the pause or we never get woken up by the timeout.
19353 +         -- Mike
19354 +
19355 +
19356 +Mon Apr 24 09:21:30 BST 1995
19357 +
19358 +       * Various documentation updates from Eric.
19359 +         -- Mike
19360 +
19361 +
19362 +Fri Apr 21 14:34:25 BST 1995
19363 +
19364 +       * Fixes to IPC. Now it really *should* work...
19365 +         -- Mike
19366 +
19367 +
19368 +Thu Apr 13 14:03:45 BST 1995
19369 +
19370 +       * Tidy up documentation ready for new release.
19371 +         -- Mike
19372 +
19373 +
19374 +Wed Apr 12 11:07:52 BST 1995
19375 +
19376 +       * Moved to an ELF development system with a GCC 2.6.4 snapshot.
19377 +         This pointed out a few signed/unsigned mismatches so I
19378 +         fixed them. We also have to ensure that x286emul is built
19379 +         as a QMAGIC a.out because it won't work any other way. It
19380 +         isn't likely to work any other way unless someone pays for
19381 +         for it to be done - it isn't what you might call a "sexy"
19382 +         project...
19383 +         -- Mike
19384 +
19385 +
19386 +Wed Apr 12 08:53:22 BST 1995
19387 +
19388 +       * Added the kernel patch to handle statically linked SVR4 ELF
19389 +         binaries to the Patches directory since it doesn't seem to
19390 +         have made any of the 1.2.x patches yet.
19391 +         -- Mike
19392 +
19393 +
19394 +Tue Mar 28 09:55:38 BST 1995
19395 +
19396 +       * Made the ISC specific stuff optional via CONFIG.
19397 +         -- Mike
19398 +
19399 +       * 1.    INTERACTIVE UNIX signal numbers are different from IBCS2.
19400 +               I added new signalmaps and exec_domains.
19401 +         2.    setpgrp does not deattach the controlling terminal.
19402 +               Try the setpgrp test program included here after the patch
19403 +               on real SCO or xxxx and Linux/IBCS2.
19404 +         3.    sigset behavior is incorrect. Test program also included.
19405 +               Short description: signal handlers registered whith sigset
19406 +               should run with the signal blocked, and after return
19407 +               the handler must be restored, so sa_flags = 0
19408 +               is the correct setting.
19409 +               Calling sigset should remove the signal from the
19410 +               blocked set.
19411 +         -- Remete Gabor <rg@tomx.elte.hu>
19412 +
19413 +
19414 +Fri Mar 24 10:20:57 GMT 1995
19415 +
19416 +       * Set the fragment size to zero for [f]statfs() just to be
19417 +         pedantic (SCO does this).
19418 +         -- Mike
19419 +
19420 +
19421 +Tue Mar 21 10:24:14 GMT 1995
19422 +
19423 +       * Fixes to 286 overlay and x.out loader by Don Camp
19424 +         <don@funsoft.com>.
19425 +         -- Mike
19426 +
19427 +       * New code for SVR4 {get,set}groups since SVR4 uses longs
19428 +         for gids whereas Linux uses shorts.
19429 +         -- Mike
19430 +
19431 +
19432 +Mon Mar 20 17:06:23 GMT 1995
19433 +
19434 +       * Added code for waitsys(). This is guesswork at this stage
19435 +         but appears sufficient for ISC 4.0 ksh to do something
19436 +         reasonable in the simplest case.
19437 +         -- Mike
19438 +
19439 +
19440 +Tue Mar 14 09:44:13 GMT 1995
19441 +
19442 +       * Initial implementation of ptrace. This allows programs
19443 +         (SCO and Wyse V/386 programs) to access a process'
19444 +         registers but actual tracing semantics will be difficult
19445 +         to make functional.
19446 +         -- Mike
19447 +
19448 +       * Alter emulate return to allow return of numbers > 2^^31
19449 +         which don't fall in the error code space.
19450 +         -- Mike
19451 +
19452 +       * Added signal mapping to wait() syscalls.
19453 +         -- Mike
19454 +
19455 +       * Updated the main README with the vger mailing list details
19456 +         and a few other tidy ups.
19457 +         -- Mike
19458 +
19459 +
19460 +Thu Mar  9 10:10:53 GMT 1995
19461 +
19462 +       * Added a load more system calls to the SVR4 tables (these
19463 +         match UnixWare at least I think). Some of these may work,
19464 +         some are just marked to shut up run time warnings.
19465 +         -- Mike
19466 +
19467 +       * Increased the size of the buffer used for parsing comment
19468 +         sections in binfmt_coff.c to 8k (from 1k). There are
19469 +         programs out there that need it.
19470 +         -- Mike
19471 +
19472 +
19473 +Tue Mar  7 16:12:36 GMT 1995
19474 +
19475 +       * More XLI/TLI changes - mostly fixes.
19476 +         -- Mike
19477 +
19478 +       * Added basic handling of the termiox extension used by SVR4
19479 +         to give access to hardware flow control. Only RTS & CTS
19480 +         or nothing is allowed because that's all Linux does. The
19481 +         same comments as below apply to the status of this.
19482 +         -- Mike
19483 +
19484 +       * Rework ioctl handling for termios. SCO uses short in a termios
19485 +         structure, SVR4 uses longs. The bit shuffling used for SVR4 is
19486 +         the same as for SCO - there are known to be some slight
19487 +         differences but these are not believed to be critical for
19488 +         most things. A large amount of guesswork went in to this.
19489 +         One day I may be able to test it...
19490 +         -- Mike
19491 +
19492 +
19493 +Mon Mar  6 12:31:05 GMT 1995
19494 +
19495 +       * Added a -DMODULE to iBCSemul/Makefile to make new style kernel
19496 +         modules work.
19497 +         -- Mike
19498 +
19499 +
19500 +Fri Mar  3 15:04:14 GMT 1995
19501 +
19502 +       * Patches from Eric. (Use Eric's [f]statvfs instead of mine).
19503 +         -- Mike
19504 +
19505 +
19506 +Thu Mar  2 11:46:03 GMT 1995
19507 +
19508 +       * Fixed a silly in the handling of SO_IMASOCKET and SO_PROTOTYPE
19509 +         plus added a check on the given buffer length.
19510 +         -- Mike
19511 +
19512 +       * Fixed a silly in the sockopt.inc options mapping.
19513 +         -- Mike
19514 +
19515 +
19516 +Wed Mar  1 14:20:06 GMT 1995
19517 +
19518 +       * Added SVR4 console keyboard mapping and termcap/terminfo
19519 +         options to the PROD.Patches directory.
19520 +         -- Mike
19521 +
19522 +
19523 +Mon Feb 27 13:30:17 GMT 1995
19524 +
19525 +       * Added simpleminded implementation of [f]statvfs().
19526 +         -- Mike
19527 +
19528 +       * [f]statfs() now respects the length argument to allow for
19529 +         older/smartass code which uses a smaller buffer size.
19530 +         -- Mike
19531 +
19532 +
19533 +Fri Feb 17 10:33:23 GMT 1995
19534 +
19535 +       * More tidy up, a little more work on TLI/XTI (still nowhere
19536 +         near usable), fixed the signal debugging messages so it
19537 +         makes more sense.
19538 +         -- Mike
19539 +
19540 +
19541 +Thu Feb  2 12:45:25 GMT 1995
19542 +
19543 +       * Changed the BSD termio ioctl handler to recognise the fact
19544 +         that some provide V7 compatibility and may be invoked from
19545 +         non-BSD binaries - possibly without BSD size encoding.
19546 +         -- Mike
19547 +
19548 +       * Changes for 1.1.88. More definitions moved around in the
19549 +         Linux header files :-).
19550 +         -- Mike
19551 +
19552 +
19553 +Fri Jan 27 10:12:51 GMT 1995
19554 +
19555 +       * Also mapped new Linux SIGIO to iBCS SIGIO and changed Linux
19556 +         SIGURG to map to SIGUSR1 as documented in SCO's TCP/IP
19557 +         programmer's guide. Is SVR4 the same? How badly do we care?
19558 +         -- Mike
19559 +
19560 +       * Had to add a new personality for Xenix binaries since they
19561 +         have a different number for SIGPOLL - sigh...
19562 +         -- Mike
19563 +
19564 +
19565 +Mon Jan 23 15:34:01 GMT 1995
19566 +
19567 +       * Changes to includes for 1.1.84.
19568 +         -- Mike
19569 +
19570 +       * Change to binfmt_elf.c from kernel patch 1.1.84.
19571 +         -- Mike
19572 +
19573 +
19574 +Tue Jan 17 17:10:25 GMT 1995
19575 +
19576 +       * Added tracing of argument and environment vectors passed
19577 +         to exec().
19578 +         -- Mike
19579 +
19580 +
19581 +Mon Jan 16 11:34:58 GMT 1995
19582 +
19583 +       * Change socksys.c for 1.1.81. There doesn't seem to be a
19584 +         convenient define to test but I intended to roll out
19585 +         most of the "magic" define testing for 1.2 to clean
19586 +         things up.
19587 +         -- Mike
19588 +
19589 +       * Ensure the segment registers are correctly set up when we
19590 +         exec a new program - the LDT we may have been using before
19591 +         no longer exists.
19592 +         -- Mike
19593 +
19594 +
19595 +Fri Jan  6 11:32:52 GMT 1995
19596 +
19597 +       * Fixed a problem where the Xenix 286 emultor wasn't getting
19598 +         the correct return and error codes from lcall7s.
19599 +         -- Mike
19600 +
19601 +       * Added support for exec() in the Xenix 286 emulator.
19602 +         -- Mike
19603 +
19604 +       * Made the spin-before-launch trap in binfmt_xout.c settable
19605 +         via a trace option, "xout-block". This is used to attach
19606 +         gdb to a 286 process to debug the emulator.
19607 +         -- Mike
19608 +
19609 +       * Fixed a problem with binfmt_xout.c setting the wrong intial
19610 +         brk value for impure segmented binaries. The checks for brk
19611 +         collisions with mapped space were failing brk changes. Before
19612 +         the brk checks were introduced I image we simply trashed
19613 +         text or data...
19614 +         -- Mike
19615 +
19616 +
19617 +Thu Jan  5 11:21:51 GMT 1995
19618 +
19619 +       * Added some debug to the STREAMS I_PUSH and I_POP. Also made
19620 +         them succeed without actually doing anything. We may be able
19621 +         to work round some instances of STREAMS usage one day...
19622 +         -- Mike
19623 +
19624 +
19625 +Wed Jan  4 11:17:14 GMT 1995
19626 +
19627 +       * Change yesterday's mkdir to use getname()/putname() to
19628 +         fetch the pathname from user space. I hadn't realised
19629 +         these were already in ksyms.c (although how long have they
19630 +         been there? This breaks compatibility with older versions
19631 +         of the kernel I guess).
19632 +         -- Mike
19633 +
19634 +       * Implement the NIOC ioctls for getting file handles since
19635 +         Oracle's TCP server seems to be wanting to do this for some
19636 +         reason (why???). This is a simple implementation that simply
19637 +         fills in the device number of the filesystem and the inode
19638 +         number of the file. This seems to agree with what SCO is
19639 +         doing. I don't know what the "exported" fields are or should be.
19640 +         -- Mike
19641 +
19642 +
19643 +Tue Jan  3 14:31:13 GMT 1995
19644 +
19645 +       * POSIX says that a pathname ending with a '/' means the current
19646 +         directory whereas SYSV drops the trailing slash. This is only
19647 +         a problem with mkdir() I think.
19648 +         -- Mike
19649 +
19650 +
19651 +Fri Dec 16 16:25:44 GMT 1994
19652 +
19653 +       * Added basic support for Wyse V/386 MPX syslocal().
19654 +         -- Mike
19655 +
19656 +
19657 +Fri Dec  9 09:14:04 GMT 1994
19658 +
19659 +       * Changed eaccess() again. We should always set the uid/gid
19660 +         rather than fsuid/fsgid since the Linux access() call is
19661 +         getting fsuid/fsgid from the current uid/gid.
19662 +         -- Mike
19663 +
19664 +       * Don't bother trying to read x.out segments which have no
19665 +         data in the executable.
19666 +         -- Mike
19667 +
19668 +
19669 +Thu Dec  8 11:51:06 GMT 1994
19670 +
19671 +       * Only include <linux/segment.h> if <asm/segment.h> hasn't
19672 +         defined KERNEL_DS. The header in the linux subdirectory
19673 +         was obsoleted in 1.1.69.
19674 +         -- Mike
19675 +
19676 +
19677 +Fri Dec  2 13:50:03 GMT 1994
19678 +
19679 +       * Force QMAGIC format when building x286emul.
19680 +         -- Mike
19681 +
19682 +       * Patches for 1.1.69.
19683 +         -- Mike
19684 +
19685 +
19686 +Thu Dec  1 13:50:37 GMT 1994
19687 +
19688 +       * Binfmt_xout.c now checks the trace flag to see if debug messages
19689 +         should be produced. Trace now has an "xout" option. Trace is
19690 +         now a Linux binary which uses a personality() syscall to enable
19691 +         emulation so the iBCS trace syscall becomes accessible.
19692 +         -- Mike
19693 +
19694 +       * Changed binfmt_xout.c to use 0x1020 as the entry point for
19695 +         the x286emul kludge overlay. This is the expected value
19696 +         for a QMAGIC binary which is the default with the newest
19697 +         compiler. Really I think uselib() should return something
19698 +         useful but I haven't decided what.
19699 +         -- Mike
19700 +
19701 +       * Made the schedule() trap (so gdb can be attached before the
19702 +         process starts running) in binfmt_xout.c a CONFIG option
19703 +         controlled by the XOUT_TRACE setting.
19704 +         -- Mike
19705 +
19706 +       * Moved the configuration for the optional items out of Makefile
19707 +         and into CONFIG.
19708 +         -- Mike
19709 +
19710 +
19711 +Wed Nov 30 17:08:05 GMT 1994
19712 +
19713 +       * Fixed a nasty bug in binfmt_coff.c where an extra page was
19714 +         being allocated in the bss causing brk() checks in 1.1.64
19715 +         and later to fail _in_certain_circumstances_.
19716 +         -- Mike
19717 +
19718 +
19719 +Wed Nov 30 13:58:46 GMT 1994
19720 +
19721 +       * Added support for unpacking ioctls passed via the STREAMS
19722 +         interface and forwarding them to the file descriptor. With
19723 +         a slight change to socksys so that devices with minor 2 get
19724 +         an anonymous dgram socket immediately they are opened this
19725 +         allows many more network programs to work. Thanks to an old
19726 +         piece of code from Chip Rosenthal for revealing how it all
19727 +         worked - it isn't in the documentation :-).
19728 +         -- Mike
19729 +
19730 +
19731 +Wed Nov 30 11:27:56 GMT 1994
19732 +
19733 +       * Fixed handling of brk and BSD sbrk so error returns are
19734 +         handled correctly.
19735 +
19736 +
19737 +Mon Nov 28 10:48:25 GMT 1994
19738 +
19739 +       * When doing an IPC_STAT on a semaphore force the semaphore
19740 +         number to be zero as the kernel code erroneously checks
19741 +         it.
19742 +         -- Mike
19743 +
19744 +
19745 +Fri Nov 25 14:26:41 GMT 1994
19746 +
19747 +       * Massive rework of ipc.c. The previous one was buggy as hell.
19748 +         This one works with all the demo programs from the Wyse V/386
19749 +         IPC documentation. Hopefully someone is going to test it with
19750 +         some *real* applications!
19751 +         -- Mike
19752 +
19753 +
19754 +Tue Nov 22 09:11:46 GMT 1994
19755 +
19756 +       * Change the TTYDEVTYPE ioctl to say we on a pseudo terminal
19757 +         rather than a console. Anything calling this is likely to
19758 +         want to try fancy stuff like mapping the console memory
19759 +         and playing with I/O ports if it thinks we are on a console.
19760 +         -- Mike
19761 +
19762 +
19763 +Tue Nov 22 09:07:04 GMT 1994
19764 +
19765 +       * Allow direct usage of 57600 and 115200 serial speeds from
19766 +         the BSD domain with kernels 1.1.65 and later.
19767 +         The mask-and-merge for iBCS<->Linux termios should be checked
19768 +         as we tend to try and preserve unmappable bits where there
19769 +         is no other conflict. In 99% of cases we won't see a problem
19770 +         though...
19771 +         -- Mike
19772 +
19773 +
19774 +Mon Nov 21 10:05:19 GMT 1994
19775 +
19776 +       * Slight change to previous patch. Confusion over which struct
19777 +         size we should be using for the verify_area plus we need to
19778 +         do a VERIFY_WRITE as we will rewrite the data before returning.
19779 +         -- Mike
19780 +
19781 +       * Changes to ipc.c for reading structures from user space.
19782 +         -- Roberto Bagnara <bagnara@di.unipi.it>
19783 +
19784 +
19785 +Thu Nov 17 15:24:23 GMT 1994
19786 +
19787 +       * Some of the unused KD ioctls were removed from Linux 1.1.64
19788 +         (or was it 63?). Changed vtkd.c accordingly.
19789 +         -- Mike
19790 +
19791 +
19792 +Fri Nov 11 14:15:09 GMT 1994
19793 +
19794 +       * Moved the x286emul overlay to /usr/lib instead of /lib. There
19795 +         is no real need for this to be on the root filesystem.
19796 +         -- Mike
19797 +
19798 +
19799 +Mon Nov  7 13:51:55 GMT 1994
19800 +
19801 +       * Added a version of the BSD exec.c patch for Linux 1.1.62.
19802 +         -- Mike
19803 +
19804 +       * Extended SCO keyboard mapping for new kbd.
19805 +         -- Mike
19806 +
19807 +
19808 +Tue Nov  1 10:57:18 GMT 1994
19809 +
19810 +       * Changed the personality test in the BSD kernel patch. Apparently
19811 +         FreeBSD uses a machtype of 134 so it's safer to test for Linux
19812 +         rather than BSD.
19813 +         -- Mike
19814 +
19815 +
19816 +Fri Oct 28 11:25:43 GMT 1994
19817 +
19818 +       * General clean up of the configuration options in the Makefile
19819 +         and elsewhere. It is now possible to choose which loaders are
19820 +         included and whether or not BSD or Xenix 286 emulation is
19821 +         required.
19822 +         -- Mike
19823 +
19824 +       * Added the x286emul overlay library. This is still very alpha
19825 +         but SCO's /bin/masm seems to do the things expected of it :-).
19826 +         -- Mike
19827 +
19828 +
19829 +Wed Oct  5 17:00:13 BST 1994
19830 +
19831 +       * Fleshed out the F_CHSIZE and F_RDCHK fcntls. I still don't
19832 +         know if these are ever used from the user layer.
19833 +         -- Mike
19834 +
19835 +
19836 +Tue Oct  4 13:17:32 BST 1994
19837 +
19838 +       * Fixed the BSD termios mappings. This _looks_ ok from the
19839 +         point of view of the NetBSD stty.
19840 +         -- Mike
19841 +
19842 +
19843 +Fri Sep 23 11:08:31 BST 1994
19844 +
19845 +       * Add SCO ODT version of CorelDraw to COMPAT file.
19846 +         -- Doug Ledford
19847 +
19848 +
19849 +Thu Sep 22 09:25:04 BST 1994
19850 +
19851 +       * Added the phone numbers of McGraw Hill's order desk to the
19852 +         README file.
19853 +         -- Mike
19854 +
19855 +       * chsize() was causing a segment error. The callmap entry punted
19856 +         to a Linux system call but the argument count was not negative
19857 +         resulting in a call to a bad function pointer.
19858 +         -- Mike
19859 +
19860 +       * Linux doesn't have the l_sysid field in struct flock so we need
19861 +         to slide the l_pid field down a word after doing a locking
19862 +         fcntl.
19863 +         -- Mike
19864 +
19865 +
19866 +Tue Sep 20 10:31:01 BST 1994
19867 +
19868 +       * Added a simplistic implementation of writev since BSD seems
19869 +         so keen to use it as much as possible.
19870 +         -- Mike
19871 +
19872 +       * Fixed the x.out loader (mostly). This requires a minor patch
19873 +         to the kernel. Expect this to be put in to the kernel itself
19874 +         sometime after 1.1.51. Segment support is still buggy and
19875 +         therefore disabled. If programs assume they know what segments
19876 +         exist it they are broken anyway!
19877 +         -- Mike
19878 +
19879 +
19880 +Wed Sep 14 11:24:18 BST 1994
19881 +
19882 +       * Added extra fcntl code 14 (used by SVR4 for GETLCK).
19883 +         -- Mike
19884 +
19885 +
19886 +Tue Sep  6 10:58:49 BST 1994
19887 +
19888 +       * Added setting of fsuid/fsgid to the loaders and changed the
19889 +         eaccess() function in xnx.c to flip fsuid/fsgid rather than
19890 +         uid/gid. If you were having problems with setuid/setgid iBCS
19891 +         binaries this is likely to help.
19892 +         -- Mike
19893 +
19894 +
19895 +Mon Sep  5 15:07:06 BST 1994
19896 +
19897 +       * Fixed the bad initialisation of howcnv in signal.c.
19898 +         -- Mike
19899 +
19900 +
19901 +Fri Sep  2 11:01:26 BST 1994
19902 +
19903 +       * Added a little program to the Tools subdirectory which will
19904 +         restamp old binaries with the Linux machine type rather than
19905 +         zero which is used by BSD. Once this is done you can reliably
19906 +         distinguish between BSD and Linux binaries (the current Linux
19907 +         linker will set the correct machine type on all new binaries).
19908 +         -- Mike
19909 +
19910 +       * Updated the BSD patch.
19911 +         -- Mike
19912 +
19913 +       * Changed binfmt_coff to avoid passing meaningless MAP_DENYWRITE
19914 +         and MAP_EXECUTABLE flags to mmap when we are not actually
19915 +         mapping from a file. It would probably never be a problem...
19916 +         -- Mike
19917 +
19918 +
19919 +Tue Aug 23 17:21:45 BST 1994
19920 +
19921 +       * Added my device trace stub in case anyone needs to investigate
19922 +         and emulate some special device.
19923 +         -- Mike
19924 +
19925 +
19926 +Wed Aug 17 14:06:34 BST 1994
19927 +
19928 +       * Added an extern definition of the formats list needed by
19929 +         the 1.0.x hooks. Presumably this went AWOL at some stage?
19930 +         -- Mike
19931 +
19932 +
19933 +Fri Aug 12 09:52:38 BST 1994
19934 +
19935 +       * Slight change to the socksys major allocation. Removed
19936 +         redundant error message.
19937 +         -- Mike
19938 +
19939 +
19940 +Wed Aug 10 08:57:32 BST 1994
19941 +
19942 +       * Added the spelling corrections from the 1.1.42 kernel patch.
19943 +         -- Mike
19944 +
19945 +
19946 +Fri Aug  5 10:05:14 BST 1994
19947 +
19948 +       * Added Scott Michel's SCO multiscreen patches.
19949 +         -- Mike
19950 +
19951 +       * More changes to loaders for latest kernel changes.
19952 +         -- Mike
19953 +
19954 +
19955 +Wed Jul 27 10:59:14 BST 1994
19956 +
19957 +       * Changes for 1.1.36 vm/mprotect.
19958 +         -- Mike
19959 +
19960 +
19961 +Tue Jul 26 14:20:27 BST 1994
19962 +
19963 +       * Tidied up the system call maps a little. ISC is now handled
19964 +         by the same maps as SCO.
19965 +         -- Mike
19966 +
19967 +
19968 +Wed Jul 20 12:39:55 BST 1994
19969 +
19970 +       * Removed the lock.patch. This is in the latest kernels.
19971 +         -- Mike
19972 +
19973 +       * Changed the socksys/SCO utsname stuff to do the right thing
19974 +         if we have the hostname set to the fqdn and the domainname
19975 +         set to the NIS domain. If hostname is not an fqdn we assume
19976 +         we are using the domainname == IP domain convention.
19977 +         -- Mike
19978 +
19979 +
19980 +Wed Jun 29 13:34:34 BST 1994
19981 +
19982 +       * Revised the lock.patch to fix the unlock problem and allow
19983 +         locks on devices. This should go to Linus (and probably has).
19984 +         -- Mike
19985 +
19986 +       * Removed the kernel 1.1.20 patch. This isn't needed as of
19987 +         1.1.22.
19988 +         -- Mike
19989 +
19990 +
19991 +Mon Jun 27 09:26:24 BST 1994
19992 +
19993 +       * Can't use select() for nap() since the Linux select system
19994 +         call expects to pull its arguments from the user stack.
19995 +         Rewritten nap() using itimers.
19996 +         -- Mike
19997 +
19998 +       * More fixes from Eric for 1.0 compatibility.
19999 +         -- Mike
20000 +
20001 +
20002 +Fri Jun 24 09:37:50 BST 1994
20003 +
20004 +       * Added a bit about time zones to the HINTS file.
20005 +         -- Mike
20006 +
20007 +       * First draft of BSD termios mapping. Still buggy. Needs
20008 +         work to be useful.
20009 +         -- Mike
20010 +
20011 +       * Fixed BSD getdirentries() to align dirents on long word
20012 +         boundaries. 'ls' now works and 'tcsh' finds and executes
20013 +         commands successfully.
20014 +         -- Mike
20015 +
20016 +       * ibcs_exit should be listed in callmap.inc with arg count 1
20017 +         not -1.
20018 +         -- Mike
20019 +
20020 +Thu Jun 23 09:48:43 BST 1994
20021 +
20022 +       * Lots more BSD-ish stuff. Commit now for release since there is
20023 +         confusion over versions at the moment.
20024 +         -- Mike
20025 +
20026 +       * List Xess MOTIF spreadsheet in COMPAT file.
20027 +         -- Michael K.Johnson <johnsonm@merengue.oit.unc.edu>
20028 +
20029 +       * When slurping in mis-aligned COFF binaries we shouldn't be
20030 +         aligning the file offset and virtual address to a page
20031 +         boundary!
20032 +         -- Mike
20033 +
20034 +       * Merged Eric's latest patches for 1.0 compatibility and Linux
20035 +         ELF capability. This was done by hand. I think it's perfect...
20036 +         -- Mike
20037 +
20038 +
20039 +Wed Jun 22 14:28:38 BST 1994
20040 +
20041 +       * Many sigsuspend entries in the callmap had argumetn counts
20042 +         of 1 instead of Spl. This caused kernel faults.
20043 +         -- Mike
20044 +
20045 +       * Implemented the ioctls for the pseudo nfs device which under
20046 +         SCO is used to get/set the NIS domain. You need to link
20047 +         /dev/nfsd to /dev/socksys.
20048 +         -- Mike
20049 +
20050 +       * The socksys getdomainname() was doing the same write null to
20051 +         kernel space instead of user space as the wysev386 version.
20052 +         -- Mike
20053 +
20054 +
20055 +Tue Jun 21 08:54:34 BST 1994
20056 +
20057 +       * Use the map_bitvec() function (added as part of the BSD changes)
20058 +         in signal.c. Note that there were quite a few mapping bugs in
20059 +         the old code. I think I got them all but few would have been
20060 +         triggered by my SCO and Wyse stuff.
20061 +         -- Mike
20062 +
20063 +       * Snapshot BSD stuff again ready for release.
20064 +         -- Mike
20065 +
20066 +       * binfmt_coff.c and binfmt_xout.c should be using mmap(NULL,...)
20067 +         instead of zeromap_page_range as this will create the vm area
20068 +         descriptor as well as mapping the pages. This is needed for
20069 +         the verify_area() in 1.1.20 which has tighter checks than
20070 +         previous versions.
20071 +         -- Mike
20072 +
20073 +       * Map stack region as a GROWSDOWN vm area in binfmt_elf.c
20074 +         -- Mike
20075 +
20076 +
20077 +Fri Jun 17 16:42:59 BST 1994
20078 +
20079 +       * Major and on going work to add BSD support (optional - see the
20080 +         Makefile). I'm committing this now so I have a current tree
20081 +         ready for release when Linus goes to 1.1.20.
20082 +         -- Mike
20083 +
20084 +       * Wyse get{host,domain}name were using direct assignment to add
20085 +         a trailing null instead of put_fs_byte(). Oops...
20086 +         -- Mike
20087 +
20088 +       * Changes for execution domain support which will be in the main
20089 +         kernel as of 1.1.20. This allows easy registration of lcall7
20090 +         handlers, binary loaders etc. for different personalities.
20091 +         -- Mike
20092 +
20093 +
20094 +Fri Jun 10 10:12:55 BST 1994
20095 +
20096 +       * Added patch file for kernel locking from Niklas Hallqvist
20097 +         <niklas@appli.se>. This (or something very similar) should
20098 +         end up in the kernel at some stage.
20099 +         -- Mike
20100 +
20101 +       * Merged Eric's changes for 1.0 compatibilty - or rather didn't.
20102 +         After playing with diff for quite a while I finally realised
20103 +         we'd both done exactly the same changes :-). However Eric
20104 +         has tested them...
20105 +         -- Mike
20106 +
20107 +       * Added Brandon's iBCS trace binary from Eric's 1.0 compatibility
20108 +         release.
20109 +         -- Mike
20110 +
20111 +
20112 +Thu Jun  9 10:22:56 BST 1994
20113 +
20114 +       * Mapped msgsys to ibcs_msgsys in callmap.inc. It existed, we
20115 +         just didn't admit it before :-).
20116 +         -- Mike
20117 +
20118 +
20119 +Tue Jun  7 08:50:34 BST 1994
20120 +
20121 +       * Sorted out some more ioctl stuff and added a handler for the
20122 +         STREAMS ioctl set. This is needed for I_NREAD (number of
20123 +         characters readable). Some SYSV X libraries contain implicit
20124 +         assumptions that the X connection is via a STREAM and use
20125 +         I_NREAD in preference to BSD/socket FIONREAD.
20126 +         -- Mike
20127 +
20128 +       * Oh, Jeez... The changes made for the official kernel patches
20129 +         completely shafted the 1.0 compatibility. I've remerged the
20130 +         previous code with the new code - there may still be some
20131 +         things that need pulling back though. At this point I don't
20132 +         have a 1.0 kernel tree around to test against.
20133 +         -- Mike
20134 +
20135 +       * If a COFF program is not correctly aligned disable demand
20136 +         paging and resort to slurping the whole lot in at start up.
20137 +         -- Mike
20138 +
20139 +       * Added missing -I../include to the Tools Makefile.
20140 +         -- Mike
20141 +
20142 +
20143 +Fri Jun  3 11:53:21 BST 1994
20144 +
20145 +       * Added my virtual system tools. A virtualised SCO 3.2.4
20146 +         system is usable for real work for me...
20147 +         -- Mike
20148 +
20149 +       * Added the synchronous ioctl set. This conflicts with the
20150 +         SCO 3.2.x (x < 4) ioctl for getting the video map so it should
20151 +         be dependent on the file descriptor it is applied to but since
20152 +         we don't currently support either...
20153 +         -- Mike
20154 +
20155 +
20156 +Thu Jun  2 17:02:26 BST 1994
20157 +
20158 +       * Added support for FIORDCHK ioctl. SCO says it's there for
20159 +         "backward compatibility" but the system programs still
20160 +         seem to use it (notably ksh).
20161 +         -- Mike
20162 +
20163 +
20164 +Tue May 31 13:39:34 BST 1994
20165 +
20166 +       * Patches to sysfs.c for 1.0.x compatibility from Tor with
20167 +         some extra clean up.
20168 +         -- Mike
20169 +
20170 +
20171 +Fri May 27 09:15:21 BST 1994
20172 +
20173 +       * Ensure we set up signal() handlers as SA_ONESHOT and sigaction()
20174 +         handlers as sticky - similar to patch from Remete Gabor.
20175 +         -- Mike
20176 +
20177 +       * Added the SCO cxenix sigaction extensions. Barely tested...
20178 +         -- Mike
20179 +
20180 +       * Added the cxenix {get,set}itimer calls discovered on SCO by
20181 +         Brandon. Currently these are directly mapped to the Linux
20182 +         syscalls. They are undocumented by SCO (as far as we know)
20183 +         and untested by us (for now).
20184 +         -- Mike
20185 +
20186 +
20187 +Thu May 26 11:58:18 BST 1994
20188 +
20189 +       * Don't include the 0.0.0.0 to localhost address mapping if we
20190 +         are building for 1.1.15+. This is mapped in the kernel as of
20191 +         1.1.6 and since we don't support 1.1 kernels before 15...
20192 +         -- Mike
20193 +
20194 +       * Type of signal map vectors should be unsigned long not int.
20195 +         -- Mike
20196 +
20197 +       * Allow tracing to be compiled in to the COFF loader and turned
20198 +         on and off with the Tools/trace program.
20199 +         -- Mike
20200 +
20201 +       * Signal maps moved out to maps/signal.inc. The only special
20202 +         mapping that happens is for ISC which has a problem with
20203 +         Oracle sending SIGSTOP to its backend when SIGSTOP doesn't
20204 +         appear to be defined for ISC. We just map SIGSTOP to 0 so
20205 +         it appears to work but does nothing.
20206 +         -- Mike
20207 +
20208 +       * Changes for 1.1.15. This will not work with kernels between
20209 +         1.1.10 and 1.1.14 inclusive - guaranteed. It should still
20210 +         work with the 1.0.x series but has not been tested recently.
20211 +         It probably works against 1.1.0 to 1.1.13 inclusive but that
20212 +         is purely coincidence - you shouldn't be using old 1.1.x
20213 +         kernels as it's a development series.
20214 +         -- Mike
20215 +
20216 +
20217 +Tue May 24 17:27:54 1994  Eric Youngdale  (eric@tantalus)
20218 +
20219 +       * binfmt_xout.c: Use linux_binfmt struct, register_binfmt,
20220 +         unregister_binfmt as in pl14.
20221 +
20222 +       * binfmt_elf.c, binfmt_xout.c: Likewise.
20223 +
20224 +       * signals.c: Make signals[] and lsignals[] global variables.
20225 +
20226 +       * ibcs/include/ibcs.h: Add prototypes for signals[] and lsignals[].
20227 +
20228 +
20229 +Tue May 24 10:37:01 BST 1994
20230 +
20231 +       * Added map entries for the ISC personality to all the maps
20232 +         files. Must be more careful adding personalities.
20233 +         -- Mike
20234 +
20235 +       * Added Oracle to the COMPAT file.
20236 +         -- Mike
20237 +
20238 +       * Remember the problem with interrupting an Informix 4GL program
20239 +         causing it to go psycho because of I/O errors from the tty?
20240 +         Well, this doesn't happen with the new tty drivers in 1.1.13.
20241 +         I never found why it happened...
20242 +         -- Mike
20243 +
20244 +       * Noted that the 1.1.11 kernel patches are still ok with 1.1.13.
20245 +         -- Mike
20246 +
20247 +
20248 +Mon May 23 08:50:21 BST 1994
20249 +
20250 +       * Mapped ISC sysconf() to the existing Xenix sysconf(). This
20251 +         looks right but isn't checked at all.
20252 +         -- Mike
20253 +
20254 +       * Added ISC TCSETPGRP and TCGETPGRP ioctl traps.
20255 +         -- Mike
20256 +
20257 +
20258 +Thu May 19 09:26:34 BST 1994
20259 +
20260 +       * Added a bug hunting section to the README.
20261 +         -- Mike
20262 +
20263 +       * Always access the socket layer by picking up the file operations
20264 +         from an open socket descriptor. This removes the need for
20265 +         kernel socket functions to be global and should be friendlier
20266 +         towards a loadable socket layer one day.
20267 +         -- Mike
20268 +
20269 +
20270 +Mon May 16 10:20:38 BST 1994
20271 +
20272 +       * Always access system calls via the system call table regardless
20273 +         of whether we are using a loadable module or linking directly
20274 +         to the kernel. This allows other things to be loadable too.
20275 +         -- Mike
20276 +
20277 +
20278 +Wed May 11 13:52:12 BST 1994
20279 +
20280 +       * Added a tip on how to fix X font problems to the HINTS file.
20281 +         Other "soft" changes welcome. Does anyone read the ChangeLog?
20282 +         -- Mike
20283 +
20284 +       * Introduced the PROD.Patches directory and put the WP install
20285 +         fixes in there. Documented in COMPAT and README.
20286 +         -- Mike
20287 +
20288 +       * Added some hints on incompatible shell behaviour.
20289 +         -- Mike
20290 +
20291 +
20292 +Mon May  9 11:07:52 BST 1994
20293 +
20294 +       * Updated the 1.1 patch file for 1.1.11.
20295 +         -- Mike
20296 +
20297 +       * Additions for Interactive 4.0
20298 +         -- Karl Kiniger (ki@kretz.co.at)
20299 +
20300 +
20301 +Fri May  6 12:03:00 BST 1994
20302 +
20303 +       * Merged old sysfs.c with the new sysfs.c. The code will now
20304 +         work against any kernel - 1.0, 1.1, 1.1.9, 1.1.10...
20305 +         -- Mike
20306 +
20307 +
20308 +Thu May  5 10:39:52 BST 1994
20309 +
20310 +       * Reworked for compatibility with 1.1.10. Kernel patches
20311 +         are *not* updated yet. We expect the kernel changes to go
20312 +         in to the official distribution any time now...
20313 +         -- Mike
20314 +
20315 +
20316 +Tue May  3 12:03:31 BST 1994
20317 +
20318 +       * Joe/Brad's IPC additions.
20319 +
20320 +
20321 +Fri Apr 29 10:06:10 BST 1994
20322 +
20323 +       * Updated the README to explain the difference between sysfs.c
20324 +         and sysfs.c.old
20325 +         -- Mike
20326 +
20327 +
20328 +Wed Apr 27 11:38:52 BST 1994
20329 +
20330 +       * Added mapping of chsize() to ftruncate(). Implemented nap()
20331 +         using select().
20332 +         -- Mike
20333 +
20334 +       * Further fix to termios mapping for iexten and tostop.
20335 +         -- Mike
20336 +
20337 +       * Updated the 1.1.? patch. New ksyms.c with fewer symbols plus
20338 +         removed all the socket patches. Sockfunc.h is no longer
20339 +         required. The 1.0 patch isn't updated but the extra cruft
20340 +         that's in there now shouldn't be any problem.
20341 +         -- Mike
20342 +
20343 +
20344 +Tue Apr 26 11:49:07 BST 1994
20345 +
20346 +       * Removed references to linux/sockfunc.h. We seem to have run
20347 +         out of internal socket functions to put in it finally.
20348 +         -- Mike
20349 +
20350 +       * Removed use of socki_lookup(). This just wraps some checks
20351 +         around inode->i_socket. We assume the socket layer is stable
20352 +         by now...
20353 +         -- Mike
20354 +
20355 +       * Access [gs]etsockopt via the socketcall interface.
20356 +         -- Mike
20357 +
20358 +       * If we have to use our own CFLAGS look in the include directory
20359 +         above in case we have been dropped in to the kernel.
20360 +         -- Eric
20361 +
20362 +       * Grab socket file operations when we create a socket rather
20363 +         than linking against them directly. Similar to Eric's
20364 +         changes but different...
20365 +         -- Mike
20366 +
20367 +
20368 +Fri Apr 22 11:10:18 BST 1994
20369 +
20370 +       * The 'x' class of ioctls are back to being termios rather
20371 +         than termio. The problem was that the field size in iBCS
20372 +         termios and Linux termios is different.
20373 +         -- Mike
20374 +
20375 +       * Added iBCS <-> Linux termios mapping. This is untested and
20376 +         probably imperfect at this stage but nothing crashes with
20377 +         this code...
20378 +         -- Mike
20379 +
20380 +       * The iBCS time() syscall doesn't take an argument, the save,
20381 +         if any, is handled in the interface library.
20382 +         -- Mike
20383 +
20384 +       * Updated the 1.1 kernel patch to be against 1.1.8. It won't
20385 +         work with anything less than 1.1.8 but then if you are
20386 +         playing with 1.1 you should be playing with the latest...
20387 +         This involves a change in the way sysfs() works. If you
20388 +         are using 1.0 and have applications that call sysfs()
20389 +         (practically none do) then you need to build with sysfs.c.old.
20390 +         -- Mike
20391 +
20392 +       * The Linux kernel 1.1.8 replaces the static file_systems
20393 +         table with a linked list ready for loadable file systems.
20394 +         Naturally, I was ready for this... :-(
20395 +         -- Mike
20396 +
20397 +
20398 +Thu Apr 21 10:34:34 BST 1994
20399 +
20400 +       * sysfs.c should be including linux/string.h to get the
20401 +         inline string functions rather than needing library
20402 +         functions.
20403 +         -- Mike
20404 +
20405 +       * Added code to map between Linux termio structs and SCO/iBCS
20406 +         termio structs. There are slight differences. Mapping needs
20407 +         to be done for termios structs too. Anything that uses termios
20408 +         at this stage is likely to ge a nasty shock!
20409 +         -- Mike
20410 +
20411 +
20412 +Tue Apr 19 22:56:55 1994  Eric Youngdale  (eric@esp22)
20413 +
20414 +       * ibcs.h: Put declaration of sys_call_table outside of ifdef.
20415 +         (So can be compiled into kernel instead as a module).
20416 +
20417 +
20418 +Tue Apr 19 10:21:17 BST 1994
20419 +
20420 +       * It looks as though the 'x' class of ioctls should be termio
20421 +         ioctls rather than termios. At least this is the case as far
20422 +         as SCO 3.2.4 stty appears to be concerned.
20423 +         -- Mike
20424 +
20425 +       * Avoid copying the entire lock structure backwards and forwards
20426 +         just to increment one field in open.c. There could be a problem
20427 +         here - SCO has a sysid field *before* the pid field but only
20428 +         if _XOPEN_SOURCE or _POSIX_SOURCE is defined at compile time.
20429 +         There appears to be no obvious way to know what is being used???
20430 +         -- Mike
20431 +
20432 +
20433 +Mon Apr 18 08:49:37 BST 1994
20434 +
20435 +       * There appear to odd little niceties involved with SYSV which
20436 +         depend on system configuration and the way users do things.
20437 +         Added a HINTS file with known problems/workarounds.
20438 +         -- Mike
20439 +
20440 +       * Changed some annoying KERN_ERRs to KERN_DEBUGs in signal.c
20441 +         -- Mike
20442 +
20443 +       * Watch out for (mis)use of INADDR_ANY instead of localhost
20444 +         (primarily by syslog() code?) and replace it with the
20445 +         localhost address. We should perhaps do this for sendto()
20446 +         as well? (Eric spotted this one on CorelDraw but it's a
20447 +         problem with the standard libsocket.c)
20448 +         -- Mike
20449 +
20450 +       * Processes should be allowed to reduce their file size
20451 +         limit but only increase it if they have root privileges.
20452 +         -- Mike
20453 +
20454 +       * Fixed the bug in [f]statfs where the first two arguments
20455 +         to memcpt_tofs() were exchanged (spotted by Eric).
20456 +         -- Mike
20457 +
20458 +       * SCO seems to like utsys (v7_utsname) to return the same
20459 +         thing for sysname and nodename fields just like the SCO
20460 +         extended utsname structure has. The SVR4 (abi_utsname)
20461 +         return is unknown at this time.
20462 +         -- Mike
20463 +
20464 +       * Removed comments on IPC from README. It *is* fixed?
20465 +         -- Mike
20466 +
20467 +       * Fix IPC which was broken by syscall changes. Also fix
20468 +         structure mappings.
20469 +         -- Joseph L. Portman III <baron@hebron.connected.com>
20470 +
20471 +
20472 +Thu Apr 14 11:27:24 BST 1994
20473 +
20474 +       * At some stage SCO managed to build some of their binaries
20475 +         with the copyright comment string in quotes so we have a
20476 +         new recognition string in the COFF loader. (Seen in uname
20477 +         on a 3.2.2 system).
20478 +         -- Mike
20479 +
20480 +       * If we have tracing compiled in then only give unsupported
20481 +         syscall messages if we are tracing the API or the syscall
20482 +         in question. This allows us to quieten unsupported but
20483 +         unimportant syscalls.
20484 +         -- Mike
20485 +
20486 +       * Comment on the IPC limitations in the README file.
20487 +         -- Mike
20488 +
20489 +       * Added implementation of xnx_pathconf(). Actually it doesn't
20490 +         look as if we really need it. The Microsoft C compiler seems
20491 +         to be misusing it anyway and doesn't even care that it gets
20492 +         an error.
20493 +         -- Mike
20494 +
20495 +
20496 +Wed Apr 13 09:14:50 BST 1994
20497 +
20498 +       * Added handling of TIOC[GS]PGRP.
20499 +         -- Mike
20500 +
20501 +       * Added implementation of xnx_eaccess(). This is currently
20502 +         simpleminded because Linux access() is. My eaccess() may
20503 +         even be wrong.
20504 +         -- Mike
20505 +
20506 +       * When tracing signal delivery we shouldn't be clearing the
20507 +         signal flag after reporting it or the signal is never actually
20508 +         delivered. I copied the assembler from the kernel and forgot
20509 +         to deleted an opcode...
20510 +         -- Mike
20511 +
20512 +       * Signal 0 should have been identity mapped so kill 0 works.
20513 +         -- Brandon S. Allbery (kf8nh@kf8nh.ampr.org) (bsa@kf8nh.wariat.org)
20514 +
20515 +Tue Apr 12 14:30:25 BST 1994
20516 +
20517 +       * Corrected file size passed to/from setrlimit/getrlimit
20518 +         -- Graham Adams (gadams@ddrive.demon.co.uk)
20519 +
20520 +
20521 +Tue Apr 12 11:16:45 BST 1994
20522 +
20523 +       * Added support for an obscure SCO extension that is used
20524 +         to get SCO's extended utsname information.
20525 +         -- Mike
20526 +
20527 +       * Changed ipc.c to always go via the ipc syscall rather than
20528 +         direct to internal functions. This should survive if ipc
20529 +         isn't in the kernel. It should even do sensible things if
20530 +         the ipc module is loaded/unloaded on us.
20531 +         -- Mike
20532 +
20533 +       * Initial changes to access system calls via sys_call_table
20534 +         -- Mike
20535 +
20536 +
20537 +05 April 1994
20538 +
20539 +       * Eric's pre-release fixes.
20540 +
20541 +
20542 +Wed Mar 30 22:35:28 1994  Eric Youngdale  (eric@esp22)
20543 +
20544 +       * ioctl.c: Change 'F' to 'f' for SVr4 FIONREAD ioctl.
20545 +
20546 +       * Makefile: Add svr4.c.
20547 +
20548 +       * svr4.c: New file (sort of - it got lost in shuffle before).
20549 +
20550 +       * include/ibcs/ibcs.h: Include prototypes for abi_uname.
20551 +
20552 +       * maps/callmap.inc: Insert abi_uname in syscall number 135.
20553 +       Add sys_rename in slot 134 (emacs v18 requires this).
20554 +
20555 +
20556 +Tue Mar 29 23:32:35 1994  Eric Youngdale  (eric@esp22)
20557 +
20558 +       * Makefile: Fix so that we do not need uname.  Use symbol from
20559 +       .config instead.
20560 +
20561 +       * README: Update a bit.
20562 +
20563 +
20564 +28 March 1994
20565 +
20566 +       * Preparation for release:
20567 +         Tidy up documentation and create CREDITS file from the old
20568 +         ToDo list.
20569 +         -- Mike
20570 +
20571 +
20572 +27 March 1994
20573 +
20574 +       * Preparation for release:
20575 +         Move headers into a subdirectory.
20576 +         Move maps into a subdirectory.
20577 +         -- Mike
20578 +
20579 +
20580 +25 March 1994
20581 +
20582 +       * Changed the COFF loader so that if the filesystem doesn't
20583 +         support mmap we read in the whole lot initially and let
20584 +         it page to swap if necessary. This is already in the x.out
20585 +         loader, it should go in the ELF loader too at some point.
20586 +         -- Mike
20587 +
20588 +
20589 +24 March 1994
20590 +
20591 +       * Added a loader for x.out i386 small model binaries - i.e 386
20592 +         Xenix programs. <=286, non-small model binaries are not
20593 +         supported and not likely to be in the near future.
20594 +         -- Mike
20595 +
20596 +
20597 +Wed Mar 23 23:12:54 1994  Eric Youngdale  (eric@esp22)
20598 +
20599 +       * Add ioctl for 0x4004667f (FIONREAD) (used by SVr4).
20600 +
20601 +       * map.h (map_segment.map): Make unsigned.
20602 +
20603 +       * hrtsys.c: New file implementing parts of the hrtsys syscall.
20604 +
20605 +
20606 +02 March 1994
20607 +
20608 +       * Add socket value mappings. This meant a general move round
20609 +         to tidy things up and group map functions/tables.
20610 +         There is a new kernel patch in the Patches directory called
20611 +         net.patch which gives us access to the sock_*sockopts
20612 +         functions directly.
20613 +         -- Mike
20614 +
20615 +
20616 +28 February 1994
20617 +
20618 +       * Implementation of poll().
20619 +         -- Eric
20620 +
20621 +
20622 +25 February 1994
20623 +
20624 +       * Pedantic change to call maps so that IBCS_function contains
20625 +         a void * instead of a function pointer - we cast it as
20626 +         necessary later in emulate.c. The warnings were annoying me.
20627 +
20628 +       * Moved struct abi_sigaction from signal.c to abi4.h so it is
20629 +         available for prototype declarations. Changed prototype for
20630 +         abi_sigsuspend to correspond to implementation in signal.c.
20631 +         -- Mike
20632 +
20633 +       * Reversed out Eric's earlier signal patches and added new ones.
20634 +         -- Mike
20635 +
20636 +       * Updated trace code and trace control program to be useful.
20637 +         Control of tracing individual functions is still not there
20638 +         yet - perhaps another day.
20639 +         Default trace mode is now none (i.e. only functions with
20640 +         the trace flag set are traced). Use the trace program to
20641 +         change the trace level.
20642 +         -- Mike
20643 +
20644 +       * File modes (open/fcntl flags) are different between Linux and
20645 +         iBCS so we need to map between them. Open also requires this
20646 +         so fcntl.c is now merged with open.c. Failure to set and reset
20647 +         non-blocking mode was what was breaking Unipox.
20648 +         -- Mike
20649 +
20650 +       * Signal handling function changes to map to and from the Linux
20651 +         signal set and sigaction flags correctly.
20652 +         -- Eric
20653 +
20654 +
20655 +24 February 1994
20656 +
20657 +       * Added code to the emulate() function to let us know when we
20658 +         are about to process a signal on exit from the syscall.
20659 +         -- Mike
20660 +
20661 +       * Implemented proctl() as a no-op. It's not really relevent
20662 +         under Linux.
20663 +         -- Mike
20664 +
20665 +       * Added argument count and type for eaccess()
20666 +         -- Mike
20667 +
20668 +       * Have emulate.c return -ENOSYS for unimplemented system calls
20669 +         rather than zero.
20670 +         -- Mike
20671 +
20672 +       * Added Eric's patches to waitpid.
20673 +
20674 +       * Created the ChangeLog!
20675 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/COMPAT kernel-source-2.6.16/Documentation/abi/COMPAT
20676 --- kernel-source-2.6.16.orig/Documentation/abi/COMPAT  1970-01-01 10:00:00.000000000 +1000
20677 +++ kernel-source-2.6.16/Documentation/abi/COMPAT       2006-04-27 18:50:24.000000000 +1000
20678 @@ -0,0 +1,181 @@
20679 +C: This file contains details of programs that have been run under
20680 +C: Linux using the iBCS emulator. An entry here is no guarantee that
20681 +C: the program works 100% but does indicate that the major elements
20682 +C: of the program have been unable to exercise bugs in the emulator
20683 +C: unless otherwise noted.
20684 +C:
20685 +C: An entry in this file does not necessarily indicate that the vendor
20686 +C: or anyone else actually supports the package under Linux unless
20687 +C: there is a specific entry to that effect.
20688 +C:
20689 +C: Please add to this file - new entries, other releases, amendments
20690 +C: to existing entries etc.
20691 +C:
20692 +C: The layout of this file is intended to be both easy to browse and
20693 +C: easy to parse, allowing it to be formatted into documents in the
20694 +C: future. This hasn't happened yet though and might never happen :-).
20695 +C:
20696 +C: Key:
20697 +C:     C = Comment
20698 +C:     V = Vendor
20699 +C:     S = Support details
20700 +C:     O = Operating system compiled for
20701 +C:     P = Product
20702 +C:     R = Release(s) known to work
20703 +C:     L = Libraries required
20704 +C:     D = Description
20705 +C:     N = Notes
20706 +C:     T = Tester
20707 +
20708 +V: Applied Information Systems, Inc. (info@ais.com)
20709 +O:     SCO
20710 +P:             Xess (MOTIF Spreadsheet)
20711 +R:             current
20712 +L:             statically linked
20713 +N:             A save-disabled demo is available in ftp.uu.net:/vendor/ais/
20714 +N:             Get three files: README, gen.tar, and sco.tar.
20715 +N:             Don't add a .Z or .gz to the end of the filenames; the files
20716 +N:             inside are compressed.  ~300K of online documentation is in
20717 +N:             gen.tar.
20718 +N:             If anyone decides to actually *buy* this product, *please*
20719 +N:             mention that you will be running it under Linux.  I promise
20720 +N:             you that you will still get technical support (the majority
20721 +N:             of our technical support staff run Linux at home) -- but if
20722 +N:             enough people buy the product asking for a Linux version, my
20723 +N:             employer will be willing to make the investment.  Pass the
20724 +N:             word on if you want to see a native-mode, high-quality
20725 +N:             spreadsheet for Linux as much as I do...
20726 +N:                     michaelkjohnson
20727 +T:             Michael K.Johnson <johnsonm@merengue.oit.unc.edu>
20728 +
20729 +V: Corel
20730 +O:     SCO ODT
20731 +P:             CorelDraw! 3.0 and friends.
20732 +R:             3.0
20733 +N:             Requires X11, no character versions of these apps.
20734 +N:             Everything seems to be statically linked, no extra libs
20735 +N:             necessary.  I had a few problems with my .xmodmap file
20736 +N:             since CorelDraw wants all of the lower function keys to
20737 +N:             be mapped to functions in the CorelDraw program.  Uses a
20738 +N:             networked license manager, it worked fine.  My programs
20739 +N:             did not install properly due to an install bug.  The dir.
20740 +N:             that contains the washes.3fx file and others must be hand
20741 +N:             changed to mode 777 for CorelChart to work (This from
20742 +N:             Corel tech support).
20743 +T:             Doug Ledford <gdl297s@cnas.smsu.edu>
20744 +
20745 +V: Informix
20746 +O:     SCO
20747 +P:             Informix SQL Standard Engine
20748 +R:             4.00 & 5.01
20749 +L:             /shlib/libc_s
20750 +T:             Mike Jagdis <jaggy@purplet.demon.co.uk>
20751 +
20752 +V: Informix
20753 +O:     SCO
20754 +P:             Informix SQL Online Dynamic Server
20755 +R:             7.20.UD5
20756 +T:             Mike Jagdis <jaggy@purplet.demon.co.uk>
20757 +
20758 +P:             Informix INET
20759 +R:             ???
20760 +N:             INET is reputed to work too but I can't remember who
20761 +N:             said that...
20762 +T:             ???
20763 +
20764 +V: IXI
20765 +O:     SCO
20766 +P:             X.desktop
20767 +R:             ???
20768 +L:             /shlib/libnsl_s
20769 +N:             The version of X.desktop tested is that shipped with
20770 +N:             Uniplex Windows. Functionality is at least enough to
20771 +N:             support Uniplex Windows.
20772 +T:             Mike Jagdis <jaggy@purplet.demon.co.uk>
20773 +
20774 +V: Oracle
20775 +O:     Interactive
20776 +P:             Oracle
20777 +R:             V6
20778 +L:             /shlib/libnsl_s
20779 +T:             Remete Gabor <rg@tomx.elte.hu>
20780 +
20781 +V: Soft-Tek
20782 +O:     SCO
20783 +P:             Tactician Plus (character and X)
20784 +R:             3.0
20785 +T:             Brandon S. Allbery <bsa@kf8nh.wariat.org>
20786 +
20787 +V: SPSS Inc.
20788 +O:     SCO
20789 +P:             SPSS 5.0 for SCO UNIX
20790 +L:             Motif, if you want to use the GUI
20791 +D:             Statistical Package for the Social Sciences
20792 +N:             SCO's cpio is not compatible with GNU's -- I had to dd all
20793 +N:             floppys onto my hd and to concatenate them into one file.
20794 +N:             I couldn't test the GUI since I had no Motif available.
20795 +T:             Joerg Rade <jr@petz.han.de>
20796 +
20797 +V: Uniplex Limited
20798 +O:     SCO
20799 +P:             Uniplex / Uniplex Windows
20800 +R:             7.02
20801 +L:             statically linked (Uniplex Windows requires libnsl_s)
20802 +N:             Uniplex Windows is implemented using a version of IXI
20803 +N:             X.desktop. It is this that requires libnsl_s.
20804 +T:             Mike Jagdis <jaggy@purplet.demon.co.uk>
20805 +
20806 +V: V-Systems, Inc.
20807 +O:     SCO
20808 +P:             VSI*FAX (FxServer, FxScript, FxVision) (character and X)
20809 +R:             FxServer 2.0.19, FxScript 1.1.05, FxVision 1.0.16
20810 +L:             Statically linked
20811 +N:             Needs localhost in the X server's access control list
20812 +N:             even when using a local X connection.
20813 +N:             This has not been tested with a modem connected as I
20814 +N:             don't have a Multitech...
20815 +T:             Mike Jagdis <jaggy@purplet.demon.co.uk>
20816 +
20817 +V: ViaCrypt
20818 +O:     SCO
20819 +P:             ViaCrypt PGP
20820 +R:             2.4
20821 +T:             Mark C. Henderson <mch@sqwest.wimsey.bc.ca>
20822 +
20823 +V: WordPerfect Corporation
20824 +O:     SCO
20825 +P:             WordPerfect (character and X)
20826 +R:             5.1
20827 +L:             Statically linked
20828 +N:             Installation under Linux may require changes to some of
20829 +N:             the WP install scripts. See the PROD.Patches/WP file
20830 +N:             for details.
20831 +N:
20832 +N:             WP uses a network license manager.
20833 +N:
20834 +N:             For some reason WP use a partition floppy device rather
20835 +N:             than the full block device. Linux does not have this so
20836 +N:             you need to use dd to skip the first cylinder (track?)
20837 +N:             when loading the floppies under Linux. See the HINTS
20838 +N:             file for details.
20839 +N:
20840 +N:             Fonts appear corrupt. See the HINTS file for a cure.
20841 +T:             Mike Jagdis <jaggy@purplet.demon.co.uk>
20842 +
20843 +V: Z-Code Inc
20844 +O:     SCO
20845 +P:             Z-Mail
20846 +R:             3.2
20847 +L:             Statically linked - Motif based.
20848 +N:             Installation scripts work correctly.
20849 +N:
20850 +N:             ZMail can use a network license manager or a license file.
20851 +N:             Both are known to work.
20852 +N:
20853 +N:             ZMail is a GUI-based mail program.
20854 +N:
20855 +N:             You can download the binaries for ZMail via anonymous ftp
20856 +N:                     ftp@ncd.com
20857 +N:             You will have to contact Z-Code to obtain an evaluation
20858 +N:             license if you wish to try it out.
20859 +T:             Eric Youngdale <eric@aib.com>
20860 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/CREDITS kernel-source-2.6.16/Documentation/abi/CREDITS
20861 --- kernel-source-2.6.16.orig/Documentation/abi/CREDITS 1970-01-01 10:00:00.000000000 +1000
20862 +++ kernel-source-2.6.16/Documentation/abi/CREDITS      2006-04-27 18:50:24.000000000 +1000
20863 @@ -0,0 +1,79 @@
20864 +A (non-definitive) list of people who appear to have worked on the
20865 +emulator and, in some cases, what they appear to have done.
20866 +
20867 +This list is in no particular order.
20868 +
20869 +This list should probably be better maintained :-).
20870 +
20871 +If anyone feels that they are not properly credited here, send diffs to
20872 +this file.
20873 +
20874 +
20875 +========================================================================
20876 +
20877 +Brandon S. Allbery <bsa@kf8nh.wariat.org> or <kf8nh@kf8nh.ampr.org>
20878 +
20879 +Graham Adams <gadams@ddrive.demon.co.uk>
20880 +
20881 +Tor Arntsen <tor@tss.no> or <tor@spacetec.no>
20882 +       Emulator as of pl13
20883 +
20884 +Philip Balister <balister@vt.edu>
20885 +       Emulator as of pl13
20886 +       gdb for coff
20887 +
20888 +Alfred Longyear <longyear@netcom.com>
20889 +       COFF loader
20890 +       Emulator as of pl12
20891 +       Original author of libc_s. COFF version.
20892 +
20893 +Mike Jagdis <jaggy@purplet.demon.co.uk>
20894 +       Changes for loadable module version of the emulator.
20895 +       Multi-personality detection and syscall mapping.
20896 +       Error code mapping.
20897 +       Wyse V/386 socket interface.
20898 +       /dev/socksys socket interface.
20899 +       /dev/spx to Unix domain socket for local X connections.
20900 +       Named pipe to Unix domain socket open kludge.
20901 +       XTI/TLI STREAMS based networking interface.
20902 +       X.out loader for 386 Xenix binaries.
20903 +       BSD support.
20904 +       Trace dummy device.
20905 +       Segment (LDT) mapping for x.out binaries.
20906 +       Xenix 286 emulator overlay.
20907 +       Current source maintainer and primary developer.
20908 +
20909 +Joseph L. Portman III <baron@hebron.connected.com>
20910 +       Major emulator developer.
20911 +       libc_s
20912 +
20913 +Drew Sullivan <drew@lethe.north.net>
20914 +       Past emulator source maintainer.
20915 +
20916 +Eric Youngdale <eric@aib.com> (prev. <eric@cais.com> & <ericy@gnu.ai.mit.edu>)
20917 +       First cut of the emulator.
20918 +       ELF loader, plus memory manager and fs/exec.c modifications
20919 +               to allow multiple binary formats to be loaded.
20920 +       Keeper of the tsx-11 archive.
20921 +       libc_s (elf version), plus bugfixes, reorganization, etc.
20922 +       SVr4 portions of emulator.
20923 +
20924 +Karl Kiniger <ki@kretz.co.at>
20925 +       Interactive 4.0 binary recognition and special support.
20926 +
20927 +Remete Gabor <rg@tomx.elte.hu>
20928 +       Miscellaneous patches.
20929 +
20930 +Scott Michel <scottm@intime.com>
20931 +       SCO multiscreen ioctls.
20932 +
20933 +Stephan Riess <Stephan.Riess@Physik.TU-Muenchen.de>
20934 +       SCO tape ioctls.
20935 +
20936 +Peter Polte <peter@cat-productions.de>
20937 +       Xenix fcntl() file locking facilities.
20938 +
20939 +C.A. Lademann <cal@zls.com>
20940 +
20941 +Miguel de Icaza <miguel@roxanne.nuclecu.unam.mx>
20942 +       Sparc support.
20943 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/Error.map kernel-source-2.6.16/Documentation/abi/Error.map
20944 --- kernel-source-2.6.16.orig/Documentation/abi/Error.map       1970-01-01 10:00:00.000000000 +1000
20945 +++ kernel-source-2.6.16/Documentation/abi/Error.map    2006-04-27 18:50:24.000000000 +1000
20946 @@ -0,0 +1,143 @@
20947 +Mapping of error codes from Linux to various personalities. Codes which Linux
20948 +may generate but which can't be mapped directly in a given personality must
20949 +be mapped to the nearest equivalent which may invoke the correct behaviour
20950 +in the application. This is especially true for things like the ERESTART*
20951 +set of error returns!
20952 +
20953 +NOTES:
20954 +
20955 +The Xenix set was built with reference to an old SCO Xenix manual rather
20956 +than by reference to a real system. It may be incomplete or wrong. If anyone
20957 +has access to the Xenix TCP/IP kit we need to add mappings for the TCP/IP
20958 +error codes.
20959 +
20960 +Other personalities may need adding. COFF binaries default
20961 +
20962 +Linux Name     Linux   ABI     SCO     Wyse    Xenix   386bsd
20963 +
20964 +EPERM           1                                              /* Operation not permitted */
20965 +ENOENT          2                                              /* No such file or directory */
20966 +ESRCH           3                                              /* No such process */
20967 +EINTR           4                                              /* Interrupted system call */
20968 +EIO             5                                              /* I/O error */
20969 +ENXIO           6                                              /* No such device or address */
20970 +E2BIG           7                                              /* Arg list too long */
20971 +ENOEXEC                 8                                              /* Exec format error */
20972 +EBADF           9                                              /* Bad file number */
20973 +ECHILD         10                                              /* No child processes */
20974 +EAGAIN         11                                      35      /* Try again */
20975 +ENOMEM         12                                              /* Out of memory */
20976 +EACCES         13                                              /* Permission denied */
20977 +EFAULT         14                                              /* Bad address */
20978 +ENOTBLK                15                                              /* Block device required */
20979 +EBUSY          16                                              /* Device or resource busy */
20980 +EEXIST         17                                              /* File exists */
20981 +EXDEV          18                                              /* Cross-device link */
20982 +ENODEV         19                                              /* No such device */
20983 +ENOTDIR                20                                              /* Not a directory */
20984 +EISDIR         21                                              /* Is a directory */
20985 +EINVAL         22                                              /* Invalid argument */
20986 +ENFILE         23                                              /* File table overflow */
20987 +EMFILE         24                                              /* Too many open files */
20988 +ENOTTY         25                                              /* Not a typewriter */
20989 +ETXTBSY                26                                              /* Text file busy */
20990 +EFBIG          27                                              /* File too large */
20991 +ENOSPC         28                                              /* No space left on device */
20992 +ESPIPE         29                                              /* Illegal seek */
20993 +EROFS          30                                              /* Read-only file system */
20994 +EMLINK         31                                              /* Too many links */
20995 +EPIPE          32                                              /* Broken pipe */
20996 +EDOM           33                                              /* Math argument out of domain of func */
20997 +ERANGE         34                                              /* Math result not representable */
20998 +EDEADLK                35      45      45      45      36      11      /* Resource deadlock would occur */
20999 +ENAMETOOLONG   36      78      78      228     EINVAL  63      /* File name too long */
21000 +ENOLCK         37      46      46      46      45      77      /* No record locks available */
21001 +ENOSYS         38      89      89      EINVAL  EINVAL  78      /* Function not implemented */
21002 +ENOTEMPTY      39      93      145     231     EINVAL  66      /* Directory not empty */
21003 +ELOOP          40      90      150     227     EINVAL  62      /* Too many symbolic links encountered */
21004 +EWOULDBLOCK    EAGAIN  90      90      200     EINVAL  35      /* Operation would block */
21005 +ENOMSG         42      35      35      35      43      ?       /* No message of desired type */
21006 +EIDRM          43      36      36      36      44      ?       /* Identifier removed */
21007 +ECHRNG         44      37      37      37      EINVAL  ?       /* Channel number out of range */
21008 +EL2NSYNC       45      38      38      38      EINVAL  ?       /* Level 2 not synchronized */
21009 +EL3HLT         46      39      39      39      EINVAL  ?       /* Level 3 halted */
21010 +EL3RST         47      40      40      40      EINVAL  ?       /* Level 3 reset */
21011 +ELNRNG         48      41      41      41      EINVAL  ?       /* Link number out of range */
21012 +EUNATCH                49      42      42      42      EINVAL  ?       /* Protocol driver not attached */
21013 +ENOCSI         50      43      43      43      EINVAL  ?       /* No CSI structure available */
21014 +EL2HLT         51      44      44      44      EINVAL  ?       /* Level 2 halted */
21015 +EBADE          52      ?       50      50      EINVAL  ?       /* Invalid exchange */
21016 +EBADR          53      ?       51      51      EINVAL  ?       /* Invalid request descriptor */
21017 +EXFULL         54      ?       52      52      EINVAL  ?       /* Exchange full */
21018 +ENOANO         55      ?       53      53      EINVAL  ?       /* No anode */
21019 +EBADRQC                56      ?       54      54      EINVAL  ?       /* Invalid request code */
21020 +EBADSLT                57      ?       55      55      EINVAL  ?       /* Invalid slot */
21021 +EDEADLOCK      58      ?       56      56      36      11      /* File locking deadlock error */
21022 +EBFONT         59      ?       57      57      EINVAL  ?       /* Bad font file format */
21023 +ENOSTR         60                              EINVAL  ?       /* Device not a stream */
21024 +ENODATA                61                              EINVAL  ?       /* No data available */
21025 +ETIME          62                              EINVAL  ?       /* Timer expired */
21026 +ENOSR          63                              EINVAL  ?       /* Out of streams resources */
21027 +ENONET         64                              EINVAL  ?       /* Machine is not on the network */
21028 +ENOPKG         65                              EINVAL  ?       /* Package not installed */
21029 +EREMOTE                66                              EINVAL  71      /* Object is remote */
21030 +ENOLINK                67                              EINVAL  ?       /* Link has been severed */
21031 +EADV           68                              EINVAL  ?       /* Advertise error */
21032 +ESRMNT         69                              EINVAL  ?       /* Srmount error */
21033 +ECOMM          70                              EINVAL  ?       /* Communication error on send */
21034 +EPROTO         71                              ?       ?       /* Protocol error */
21035 +EMULTIHOP      72      74      74      74      ?       ?       /* Multihop attempted */
21036 +EDOTDOT                73      76      76      76      ?       ?       /* RFS specific error */
21037 +EBADMSG                74      77      77      77      ?       ?       /* Not a data message */
21038 +EOVERFLOW      75      79      EINVAL  EINVAL  ?       ?       /* Value too large for defined data type */
21039 +ENOTUNIQ       76      80      80      80      ?       ?       /* Name not unique on network */
21040 +EBADFD         77      81      81      81      ?       ?       /* File descriptor in bad state */
21041 +EREMCHG                78      82      82      82      ?       ?       /* Remote address changed */
21042 +ELIBACC                79      83      83      83      ?       ?       /* Can not access a needed shared library */
21043 +ELIBBAD                80      84      84      84      ?       ?       /* Accessing a corrupted shared library */
21044 +ELIBSCN                81      85      85      85      ?       ?       /* .lib section in a.out corrupted */
21045 +ELIBMAX                82      86      86      86      ?       ?       /* Attempting to link in too many shared libraries */
21046 +ELIBEXEC       83      87      87      87      ?       ?       /* Cannot exec a shared library directly */
21047 +EILSEQ         84      88      EINVAL  EINVAL  ?       ?       /* Illegal byte sequence */
21048 +ERESTART       85      91      EINTR   EINTR   ?       ?       /* Interrupted system call should be restarted */
21049 +ESTRPIPE       86      92      EINVAL  EINVAL  ?       ?       /* Streams pipe error */
21050 +EUSERS         87      94      EINVAL  233     ?       68      /* Too many users */
21051 +ENOTSOCK       88      95      93      203     ?       38      /* Socket operation on non-socket */
21052 +EDESTADDRREQ   89      96      94      204     ?       39      /* Destination address required */
21053 +EMSGSIZE       90      97      95      205     ?       40      /* Message too long */
21054 +EPROTOTYPE     91      98      96      206     ?       41      /* Protocol wrong type for socket */
21055 +ENOPROTOOPT    92      99      EINVAL  207     ?       42      /* Protocol not available */
21056 +EPROTONOSUPPORT        93      120     97      208     ?       43      /* Protocol not supported */
21057 +ESOCKTNOSUPPORT        94      121     98      209     ?       44      /* Socket type not supported */
21058 +EOPNOTSUPP     95      122     99      210     ?       45      /* Operation not supported on transport endpoint */
21059 +EPFNOSUPPORT   96      123     100     211     ?       46      /* Protocol family not supported */
21060 +EAFNOSUPPORT   97      124     101     212     ?       47      /* Address family not supported by protocol */
21061 +EADDRINUSE     98      125     102     213     ?       48      /* Address already in use */
21062 +EADDRNOTAVAIL  99      126     103     214     ?       49      /* Cannot assign requested address */
21063 +ENETDOWN       100     127     104     215     ?       50      /* Network is down */
21064 +ENETUNREACH    101     128     105     216     ?       51      /* Network is unreachable */
21065 +ENETRESET      102     129     106     217     ?       52      /* Network dropped connection because of reset */
21066 +ECONNABORTED   103     130     107     218     ?       53      /* Software caused connection abort */
21067 +ECONNRESET     104     131     108     219     ?       54      /* Connection reset by peer */
21068 +ENOBUFS                105     132     63      220     ?       55      /* No buffer space available */
21069 +EISCONN                106     133     110     221     ?       56      /* Transport endpoint is already connected */
21070 +ENOTCONN       107     134     111     222     ?       57      /* Transport endpoint is not connected */
21071 +ESHUTDOWN      108     143     112     223     ?       58      /* Cannot send after transport endpoint shutdown */
21072 +ETOOMANYREFS   109     144     113     224     ?       59      /* Too many references: cannot splice */
21073 +ETIMEDOUT      110     145     114     225     ?       60      /* Connection timed out */
21074 +ECONNREFUSED   111     146     115     226     ?       61      /* Connection refused */
21075 +EHOSTDOWN      112     147     116     229     ?       64      /* Host is down */
21076 +EHOSTUNREACH   113     148     117     230     ?       65      /* No route to host */
21077 +EALREADY       114     149     92      202     ?       37      /* Operation already in progress */
21078 +EINPROGRESS    115     150     91      201     ?       36      /* Operation now in progress */
21079 +ESTALE         116     EINVAL  EINVAL  237     ?       70      /* Stale NFS file handle */
21080 +EUCLEAN                117     ?       135     135     35      ?       /* Structure needs cleaning */
21081 +ENOTNAM                118     ?       137     137     37      ?       /* Not a XENIX named type file */
21082 +ENAVAIL                119     ?       138     138     38      ?       /* No XENIX semaphores available */
21083 +EISNAM         120     ?       139     139     39      ?       /* Is a named type file */
21084 +EREMOTEIO      121     ?       140     140     EINVAL  ?       /* Remote I/O error */
21085 +EDQUOT         122     ?       ENOSPC  234     ENOSPC  69      /* Quota exceeded */
21086 +
21087 +ERESTARTSYS    512     EINTR   EINTR   EINTR   EINTR   EINTR
21088 +ERESTARTNOINTR 513     EINTR   EINTR   EINTR   EINTR   EINTR
21089 +ERESTARTNOHAND 514     EINTR   EINTR   EINTR   EINTR   EINTR   /* restart if no handler.. */
21090 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/HINTS kernel-source-2.6.16/Documentation/abi/HINTS
21091 --- kernel-source-2.6.16.orig/Documentation/abi/HINTS   1970-01-01 10:00:00.000000000 +1000
21092 +++ kernel-source-2.6.16/Documentation/abi/HINTS        2006-04-27 18:50:24.000000000 +1000
21093 @@ -0,0 +1,245 @@
21094 +PROBLEM:
21095 +       Cannot determine user name by reference to /etc/passwd. Failure
21096 +       to determine the user name causes some programs (notably programs
21097 +       built with Informix 4GL) to exit.
21098 +
21099 +REASON:
21100 +       The functions that parse /etc/passwd are sensitive under SCO
21101 +       at least. A corrupt line is taken to be the end of the file
21102 +       and further entries are ignored. Any line which has a null
21103 +       home directory counts as a corrupt line for SCO.
21104 +
21105 +SOLUTION:
21106 +       Ensure that all lines in /etc/passwd have home directories
21107 +       specified. Simply edit /etc/passwd with an editor.
21108 +
21109 +
21110 +# -----------------------------------------------------------------------
21111 +
21112 +PROBLEM:
21113 +       Cannot connect to X server using local connection.
21114 +
21115 +REASON:
21116 +       Some versions of X libraries seem to require 'localhost' to be
21117 +       allowed to connect to the X server even if we aren't using a
21118 +       TCP/IP connection. The X libraries used for VSI*FAX require
21119 +       this, the X libraries used for WordPerfect don't.
21120 +
21121 +SOLUTION:
21122 +       Explicitly allow 'localhost' to connect to the X server using
21123 +       'xhost localhost'.
21124 +
21125 +
21126 +# -----------------------------------------------------------------------
21127 +
21128 +PROBLEM:
21129 +       Installation disks claim to be Unix tar format but they appear
21130 +       to be blank MS-DOS format disks!
21131 +
21132 +REASON:
21133 +       Unix provides two floppy devices, the normal floppy devices
21134 +       that we all know and love (and which are listed as the Xenix
21135 +       compatible devices in the man page) and a second set which
21136 +       skips the first track of the disk. For some reason a few vendors
21137 +       seem to use this second set when preparing distribution disks.
21138 +       WordPerfect seem to do this. Linux currently only supports
21139 +       the normal floppy devices.
21140 +
21141 +SOLUTION:
21142 +       You have to skip the first track by hand and read each disk
21143 +       individually. Try 'dd if=/dev/fd0 bs=18k skip=1 | tar xfv -'
21144 +       for a 3.5" high density disk. Change the 18k to 15k for a
21145 +       5.25" high density disk.
21146 +
21147 +# -----------------------------------------------------------------------
21148 +
21149 +PROBLEM:
21150 +       A script bombs out with an unexpected EOF looking for "'". This
21151 +       only happens on Linux.
21152 +
21153 +REASON:
21154 +       There is a bug in the script which is only a problem on Linux.
21155 +       Take the following example:
21156 +
21157 +               count=`ls | wc | awk '{ printf "%05d", $1 }`
21158 +
21159 +       Note the missing "'" at the end of the awk statment. The /bin/sh
21160 +       supplied with SCO will assume (in this case correctly) that the
21161 +       "'" should have occurred immediately before the closing "`" and
21162 +       the expression will succeed. The /bin/sh used with Linux (normally
21163 +       bash) does not make this assumption and gives an error message.
21164 +
21165 +SOLUTION:
21166 +       Either fix the script or arrange to have it run by a SYSV shell
21167 +       rather than bash.
21168 +
21169 +# -----------------------------------------------------------------------
21170 +
21171 +PROBLEM:
21172 +       Test complains that a numeric argument is required before -eq, -le
21173 +       etc.
21174 +
21175 +REASON:
21176 +       The GNU shellutils test and the test built in to bash which are
21177 +       the versions of test used under Linux do not accept a null
21178 +       argument as equivalent to 0 so 'test "" -le 5' will give an error.
21179 +       Under SCO a null argument is taken as equivalent to 0 so the
21180 +       statement would be evaluated as 'test 0 -le 5'.
21181 +
21182 +SOLUTION:
21183 +       Fix the script to check arguments for validity before using them
21184 +       or provide a fixed version of test and ensure that it is used in
21185 +       preference to any shell built in.
21186 +
21187 +# -----------------------------------------------------------------------
21188 +
21189 +PROBLEM:
21190 +       Some X fonts supplied with packages appear corrupt.
21191 +
21192 +REASON:
21193 +       These are probably snf fonts. The XFree86 X server used with
21194 +       Linux appears to fail to load some snf fonts silently and displays
21195 +       garbage. Pcf fonts work ok and should be used where possible.
21196 +
21197 +SOLUTION:
21198 +       If you only have the snf fonts all you can do is to try asking the
21199 +       vendor for pcf versions or the bdf definitions.
21200 +
21201 +       If you have the bdf definitions (WordPerfect ship them) then you
21202 +       can build a pcf set using:
21203 +
21204 +               # for bdffn in *.bdf
21205 +               > do
21206 +               >   fn=`basename $bdffn .bdf`
21207 +               >   [ -r $fn.snf ] && mv $fn.snf $fn.snf.old
21208 +               >   bdftopcf -o $fn.pcf $bdffn
21209 +               > done
21210 +               # mkfontdir .
21211 +               # xset fp rehash
21212 +
21213 +# -----------------------------------------------------------------------
21214 +
21215 +PROBLEM:
21216 +       Function keys don't work.
21217 +
21218 +REASON:
21219 +       The default sequences for function keys under Linux are "sort of"
21220 +       VT10x like whereas you have probably told your application that
21221 +       you are running on an ansi or SCO console.
21222 +
21223 +SOLUTION:
21224 +       It is probably best to run as an ansi screen - especially if
21225 +       colour is used - so use the "loadkeys" program to load the
21226 +       SCO.map keyboard description from the PROD.Patches directory.
21227 +       This directory also contains flexible termcap and terminfo
21228 +       descriptions which will allow you run permanently with a SCO
21229 +       or SVR4-like console.
21230 +
21231 +# -----------------------------------------------------------------------
21232 +
21233 +PROBLEM:
21234 +       Line drawing characters come out as weird symbols.
21235 +
21236 +REASON:
21237 +       The application believes you are using a console screen with a
21238 +       PC character set and is using 8-bit codes rather than escape
21239 +       sequences. Linux defaults to an ISO8859-1 character set though.
21240 +
21241 +SOLUTION:
21242 +       Linux can be switched to PC character set mode with the escape
21243 +       sequence ESC-(-U. Arrange to have this sequence sent either
21244 +       before the application is started or as part of the initialisation
21245 +       that the application does. You can restore the ISO character
21246 +       set afterwards with ESC-(-K.
21247 +
21248 +# -----------------------------------------------------------------------
21249 +
21250 +PROBLEM:
21251 +       SYSV binaries see the wrong time zone.
21252 +
21253 +REASON:
21254 +       SYSV binaries establish the time zone from the TZ environment
21255 +       variable whereas Linux uses BSD style zoneinfo files generally.
21256 +
21257 +SOLUTION:
21258 +       Set the TZ environment variable to reflect your time zone. Note
21259 +       that the zoneinfo mechanism can also use TZ in preference to
21260 +       the /usr/lib/zoneinfo/localtime file if you wish. For this to
21261 +       work you must have /usr/lib/zoneinfo/posixrules linked to one
21262 +       of the US timezone files. The posixrules file defines how the
21263 +       zoneinfo functions interpret TZ and this information is only
21264 +       found in the US data files. See the documentation for the
21265 +       timezone/zoneinfo package for details.
21266 +
21267 +# -----------------------------------------------------------------------
21268 +
21269 +PROBLEM:
21270 +       BSD binaries don't see the right time zone.
21271 +
21272 +REASON:
21273 +       Although BSD binaries use the same timezone handling method as
21274 +       Linux they expect the zoneinfo information in different places.
21275 +
21276 +SOLUTION:
21277 +       Make the links:
21278 +
21279 +               # ln -s /usr/lib/zoneinfo /etc/localtime
21280 +               # ln -s /usr/lib/zoneinfo /usr/share/zoneinfo
21281 +
21282 +# -----------------------------------------------------------------------
21283 +
21284 +PROBLEM:
21285 +       BSD binaries complain that they can't find /etc/termcap.
21286 +
21287 +REASON:
21288 +       They may be lying. BSD sometimes uses /usr/share/misc/termcap
21289 +       or ~/.termcap (if it exists).
21290 +
21291 +SOLUTION:
21292 +       Either move termcap to /usr/share/misc and make /etc/termcap
21293 +       a link to it or make /usr/share/misc/termcap a link to /etc/termcap.
21294 +       The use of /usr/share/misc/termcap may be useful in a networked
21295 +       environment.
21296 +# -----------------------------------------------------------------------
21297 +
21298 +PROBLEM:
21299 +       SVr4 binaries cannot locate shared libraries, or fail to start.
21300 +
21301 +REASON:
21302 +       The shared libraries are not in the correct location, or the dynamic
21303 +       loader cannot be located by the kernel.
21304 +
21305 +SOLUTION:
21306 +       Put all SVr4 shared libraries in the directory /usr/i486-sysv4/lib.
21307 +       Then create two symbolic links:
21308 +
21309 +       ln -s /usr/i486-sysv4/lib/libc.so.1 /usr/lib/libc.so.1
21310 +       ln -s /usr/i486-sysv4/lib/ld.so.1 /usr/lib/ld.so.1
21311 +# -----------------------------------------------------------------------
21312 +
21313 +PROBLEM:
21314 +       SVr4 binaries want to access terminfo instead of termcap
21315 +
21316 +REASON:
21317 +       SVr4 traditionally uses something called terminfo instead of
21318 +       termcap to specify terminal characteristics.
21319 +
21320 +SOLUTION:
21321 +       The ncurses distribution (available on many fine ftp sites)
21322 +       contains a terminfo database.  Just install this, and you
21323 +       should be all set.
21324 +# -----------------------------------------------------------------------
21325 +
21326 +PROBLEM:
21327 +       The Informix Dynamic Server installation for SCO says
21328 +       invalid INFORMIXDIR or insufficient space.
21329 +
21330 +REASON:
21331 +       It wants to scan /etc/mnttab to find all possible
21332 +       filesystems. Since Linux uses /etc/mtab instead the
21333 +       installation program is under the impression you have
21334 +       no filesystems and no space(!).
21335 +
21336 +SOLUTION:
21337 +       Run the perl script Tools/mkmnttab which will build an
21338 +       /etc/mnttab from /etc/mtab.
21339 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/Local-X kernel-source-2.6.16/Documentation/abi/Local-X
21340 --- kernel-source-2.6.16.orig/Documentation/abi/Local-X 1970-01-01 10:00:00.000000000 +1000
21341 +++ kernel-source-2.6.16/Documentation/abi/Local-X      2006-04-27 18:50:24.000000000 +1000
21342 @@ -0,0 +1,22 @@
21343 +** Local X interface
21344 +
21345 +The local X interface is simplistic. It assumes only one local X server
21346 +exists and assumes that the pathname of the Unix domain socket for
21347 +local connections is always /tmp/.X11-unix/X0.
21348 +
21349 +  The SCO code opens both /dev/X0R and /dev/spx, writes a single byte
21350 +to /dev/X0R, reads a message from /dev/X0R with getmsg then writes this
21351 +message to /dev/spx with putmsg and closes /dev/X0R. This establishes
21352 +the /dev/spx file descriptor as a connection to the X server listening
21353 +on /dev/X0R.
21354 +
21355 +  We ignore all activity on the /dev/X0R device (hence it is a link to
21356 +/dev/null), getmsg and putmsg are stubbed so don't do anything and opens
21357 +on the /dev/spx simply replace the open inode with a socket connected
21358 +to the X server's Unix domain socket.
21359 +
21360 +  At some point in the future we will implement a simple minded /dev/X*
21361 +driver that returns some form of id via the getmsg which can then be
21362 +passed to /dev/spx with putmsg and which will allow /dev/spx to connect
21363 +to the relevant X server. This will only happen if someone actually
21364 +*needs* multiple local X servers...
21365 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/modules.txt kernel-source-2.6.16/Documentation/abi/modules.txt
21366 --- kernel-source-2.6.16.orig/Documentation/abi/modules.txt     1970-01-01 10:00:00.000000000 +1000
21367 +++ kernel-source-2.6.16/Documentation/abi/modules.txt  2006-04-27 18:50:24.000000000 +1000
21368 @@ -0,0 +1,80 @@
21369 +A brief overview of the Linux-ABI modules
21370 +2001-July-19
21371 +Christoph Hellwig, <hch@caldera.de>
21372 +
21373 +Linux-ABI consists of a number of loadable kernel modules (you can also
21374 +compile it directly into the kernel, but no one actually does).   This
21375 +document is intended to give a brief overview on the aviable modules
21376 +and how they can be classified in groups.
21377 +
21378 +
21379 +=== Binary format modules
21380 +
21381 +Some of the personalities supported by Linux-ABI use different binary
21382 +formats than the ELF format that is used by Linux native binaries.
21383 +The follwoing binary format modules do exists:
21384 +
21385 +  o binfmt_coff
21386 +
21387 +       This modules supports the COFF binary format as used by elder
21388 +       SysV-derivate operating systems.  It is used by the SVR3,
21389 +       SCOSVR3, ISC and Wyse personalities.
21390 +
21391 +  o binfmt_xout
21392 +
21393 +       This module is intended for loading X.out binaries generated for
21394 +       the Xenix operating system.
21395 +
21396 +These modules have to be loaded manually before using them.
21397 +
21398 +
21399 +
21400 +=== Personality modules
21401 +
21402 +Personality modules contain the the personality implementation and are
21403 +thus the hearts of Linux-ABI.  Additionally most personality modules
21404 +contain syscalls only used by that particular personality.  There are
21405 +a lot of personality modules:
21406 +
21407 +  o abi-ibcs
21408 +
21409 +       Support for plain SVR3/SVR4 as specified in iBCS2 or iABI4.
21410 +       Additionally this module contains the Xenix and ISC personalities,
21411 +       but these should be moved away from here.
21412 +
21413 +  o abi-sco
21414 +
21415 +       This module implements the SCO Unix 3.x/ODT and OSR5 personalities.
21416 +
21417 +  o abi-solaris
21418 +
21419 +       The Solaris 2 emulator.
21420 +
21421 +  o abi-uw7
21422 +
21423 +       SCO UnixWare 7 / Caldera OpenUnix 8 emulator.
21424 +
21425 +  o abi-wyse
21426 +
21427 +       Support for Wyse V/386 ant it's multiprocessor variant.
21428 +
21429 +
21430 +=== Backend modules
21431 +
21432 +As a lot of the functionality provided by the binary format modules is
21433 +common to more than one of those, most of this functionality is moved to
21434 +backend modules. There are only a few backend modules:
21435 +
21436 +  o abi-machdep
21437 +
21438 +       The machine depandand part of Linux-ABI (in fact currently
21439 +       Linux-ABI is i386-specific, but that _will_ change).
21440 +
21441 +  o abi-svr4
21442 +
21443 +       Most of the syscalls used by all or many of the SVR3/SVR4 derivates.
21444 +
21445 +  o abi-socket
21446 +
21447 +       4BSD-style socket interface, currently only used by the Wyse
21448 +       emulation.  This will probably go away.
21449 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/Notes.Signal kernel-source-2.6.16/Documentation/abi/Notes.Signal
21450 --- kernel-source-2.6.16.orig/Documentation/abi/Notes.Signal    1970-01-01 10:00:00.000000000 +1000
21451 +++ kernel-source-2.6.16/Documentation/abi/Notes.Signal 2006-04-27 18:50:24.000000000 +1000
21452 @@ -0,0 +1,42 @@
21453 +Drew, Joe, and Brandon.
21454 +
21455 +This file contains my code for the signal functions. I realized that the
21456 +existing signal functions will not suffice. This module should do the
21457 +proper processing for iBCS signals.
21458 +
21459 +There are patches to the emulate module offered by Drew in his pl14n code
21460 +release. The Makefile was changed to include the module.
21461 +
21462 +In addition, I have include a signal.doc file which contains the text from
21463 +my UNIX S5 manual describing the functions used by iBCS. I based the
21464 +emulator code on this document. Please look it over and see if I have
21465 +messed up. I believe it to be correct. However, it never hurts to have
21466 +someone check the work before we can trust it.
21467 +
21468 +It follows what I believe to be the proper calling sequence for signals. I
21469 +sent a message to the IBSC2 group with the text from the McGraw Hill book
21470 +concerning signals. If you would like a copy of the message, then let me
21471 +know.
21472 +
21473 +Of couse, this could be totally wrong. That is the whole point about
21474 +sending this out to a limited distribution.
21475 +
21476 +In addition to the processing for the various function requests, you may
21477 +have noticed that the signal _numbers_ must be changed between the values
21478 +used by iBCS and Linux.
21479 +
21480 +I have had to modify the emulate.c module to export an additional
21481 +procedure (and for emulate.c to use the procedure itself.) In addition, I
21482 +change the branch table to re-direct the signal processing to the signal.c
21483 +module.
21484 +
21485 +I hope that this will help the project when it has been proven workable.
21486 +Please let me know how this turns out -- one way or the other.
21487 +
21488 +If it does work, then I'll give the final code to Drew to merge into the
21489 +master code. That is unless, Drew, you already have it. :-)
21490 +
21491 +Thanks much.
21492 +
21493 +--
21494 +Al Longyear           longyear@netcom.com         longyear@sii.com
21495 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/Personality kernel-source-2.6.16/Documentation/abi/Personality
21496 --- kernel-source-2.6.16.orig/Documentation/abi/Personality     1970-01-01 10:00:00.000000000 +1000
21497 +++ kernel-source-2.6.16/Documentation/abi/Personality  2006-04-27 18:50:24.000000000 +1000
21498 @@ -0,0 +1,88 @@
21499 +*** Why are multiple personalities necessary?
21500 +
21501 +Personalities are used to provide the expected set of syscalls and error
21502 +code mapping for non-Linux processes. In theory the set of syscalls and
21503 +error codes should be standardised across all SYSV systems. In practice
21504 +this is the case for SVR4, however SVR3 is a much older code base and
21505 +many vendors have extended it leading to incompatibilities between the
21506 +expected interfaces. Personalities allow us to vary the interface presented
21507 +on a per-process basis thus allowing Linux to run binaries created for
21508 +different vendor's extended SVR3s simultaneously.
21509 +
21510 +
21511 +*** How are personalities implemented?
21512 +
21513 +The per-process task structure contains a field "personality". This defaults
21514 +to 0 for Linux binaries, 1 (SVR4) for ELF binaries and 2 (SVR3) for COFF
21515 +binaries. However when the COFF loader is called on to load a new binary
21516 +it looks at the first 1k of data in each .comment section and compares
21517 +the strings it finds with a built in table. If it finds a match it will
21518 +set the personality appropriately.
21519 +
21520 +  When the application makes a system call the iBCS emulation layer uses
21521 +the personality code in the per-process task structure to determine which
21522 +system call mappings to use to locate the correct function.
21523 +
21524 +  If the function returns an (Linux) error code the iBCS emulation layer
21525 +uses the personality code to determine which error code mappings to use
21526 +to translate the error code in to a value the application will understand.
21527 +
21528 +
21529 +*** What personalities are implemented?
21530 +
21531 +Currently the implemented personalities are SVR4, SVR3 (as a direct
21532 +subset of SVR4), SCO 3.[24] and Wyse V/386 3.2.1. Of these the Wyse
21533 +emulation is the most complete at this time. Rather than using the
21534 +more common streams based TCP/IP stack on their SVR3, Wyse used a BSD
21535 +implementation with a system call interface. Currently the Wyse emulation
21536 +is the only one capable of running non-Linux TCP/IP binaries.
21537 +
21538 +
21539 +*** When do I need to add a personality rather than use the default?
21540 +
21541 +When your applications start failing for inexplicable reasons! Seriously,
21542 +if you have an SVR3 based Unix which does not currently have its own
21543 +personality defined then you should check some things very carefully.
21544 +
21545 +  Firstly compare your system's /usr/include/sys/errno.h with the data
21546 +in the Error.map file. If the values defined in your errno.h do not
21547 +match those in the ABI column then you will need to create a new
21548 +personality in order to map error codes to the correct values.
21549 +
21550 +  Next compare your system's /usr/include/sys.s with the data in the
21551 +Syscall.map file. If there are system calls in your sys.s that don't
21552 +do the same thing as those in the ABI column (other than ones that
21553 +simply aren't implemented on your system) then you will need to create
21554 +a new personality in order to mapp system calls to the correct functions.
21555 +
21556 +
21557 +*** How do I add a new personality?
21558 +
21559 +The first step is to find a way for the COFF loader to recognise your
21560 +binaries as being different. To do this you need to examine the comments
21561 +embedded in a range of binaries, system executables, bought programs of
21562 +various ages and locally compiled programs, using "mcs -p" to list the
21563 +.comments sections. If you don't have "mcs" use "strings" and look for
21564 +version or copyright messages. You are looking for one or more strings
21565 +near the top which uniquely identify the system.
21566 +
21567 +  Once you have your identifying strings you must add a value for the
21568 +new personality to linux/include/linux/personality.h (just use the
21569 +next highest number) and add the strings to the table in the COFF loader
21570 +linux/fs/binfmt_coff.c.
21571 +
21572 +  The next step is to modify the error map. Edit the file errmap.inc and
21573 +look at the end of the file where there is an array of pointers to error
21574 +maps call err_map. There is one entry for each personality. Add a new
21575 +entry to the end for your personality. If your personality is compatible
21576 +with an exising personality you can simply reuse the same error map (see
21577 +the duplicate entries for the SVR4 map which is use for both SVR4 and
21578 +SVR3 personalities), otherwise you must figure out how to create a new
21579 +error mapping. One day it may be documented here :-).
21580 +
21581 +  Next you must modify the syscall mapping. Edit the file callmap.inc
21582 +and look at the end of the file where there is an array containg one
21583 +pointer for each personality. Add a new entry to the end. If your syscalls
21584 +match one of the existing personalities you may reuse the existing map.
21585 +Otherwise you have to build a new one. Again, one day it may be documented
21586 +here...
21587 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/README.first kernel-source-2.6.16/Documentation/abi/README.first
21588 --- kernel-source-2.6.16.orig/Documentation/abi/README.first    1970-01-01 10:00:00.000000000 +1000
21589 +++ kernel-source-2.6.16/Documentation/abi/README.first 2006-04-27 18:50:24.000000000 +1000
21590 @@ -0,0 +1,12 @@
21591 +First notes on Linux-ABI documentation
21592 +2001-March-30
21593 +Christoph Hellwig, <hch@caldera.de>
21594 +
21595 +
21596 +Please note that most files in this directory are leftovers from iBCS, which is
21597 +dead since 1998.  Do not expect this files to uptodate or complete.
21598 +
21599 +I will update the files and add new onces from time to time.
21600 +
21601 +       --hch
21602 +
21603 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/Syscall.map kernel-source-2.6.16/Documentation/abi/Syscall.map
21604 --- kernel-source-2.6.16.orig/Documentation/abi/Syscall.map     1970-01-01 10:00:00.000000000 +1000
21605 +++ kernel-source-2.6.16/Documentation/abi/Syscall.map  2006-04-27 18:50:24.000000000 +1000
21606 @@ -0,0 +1,185 @@
21607 +Call   ABI             SCO 3.2         SCO 3.4         Wyse V/386 3.2.1        386bsd
21608 +
21609 +  1    exit
21610 +  2    fork
21611 +  3    read
21612 +  4    write
21613 +  5    open
21614 +  6    close
21615 +  7    wait
21616 +  8    creat
21617 +  9    link
21618 + 10    unlink
21619 + 11    exec
21620 + 12    chdir
21621 + 13    time                                                                    fchdir
21622 + 14    mknod
21623 + 15    chmod
21624 + 16    chown
21625 + 17    brk/break
21626 + 18    stat                                                                    getfsstat
21627 + 19    seek/seek
21628 + 20    getpid
21629 + 21    mount
21630 + 22    umount
21631 + 23    setuid
21632 + 24    getuid
21633 + 25    stime                                                                   geteuid
21634 + 26    ptrace
21635 + 27    alarm                                                                   recvmsg
21636 + 28    fstat                                                                   sendmsg
21637 + 29    pause                                                                   recvfrom
21638 + 30    utime                                                                   accept
21639 + 31    stty                                                                    getpeername
21640 + 32    gtty                                                                    getsockname
21641 + 33    access
21642 + 34    nice                                                                    chflags
21643 + 35    statfs                                                                  fchflags
21644 + 36    sync
21645 + 37    kill
21646 + 38    fstatfs                                                                 stat
21647 + 39    setpgrp                                                                 getppid
21648 + 40    cxenix                                                                  lstat
21649 + 41    dup
21650 + 42    pipe
21651 + 43    times                                                                   getegid
21652 + 44    prof
21653 + 45    lock/plock                                                              ktrace
21654 + 46    setgid                                                                  sigaction
21655 + 47    getgid
21656 + 48    signal                                                                  sigprocmask
21657 + 49    msgsys                                                                  getlogin
21658 + 50    sysi86/sys3b                                                            setlogin
21659 + 51    sysacct/acct
21660 + 52    shmsys                                                                  sigpending
21661 + 53    semsys                                                                  sigaltstack
21662 + 54    ioctl
21663 + 55    uadmin                                                                  reboot
21664 + 56    ???                                                                     revoke
21665 + 57    utssys                                                                  symlink
21666 + 58    ???                                                                     readlink
21667 + 59    execv
21668 + 60    umask
21669 + 61    chroot
21670 + 62    fcntl                                                                   fstat
21671 + 63    ulimit                                                                  getkerninfo
21672 + 64    ???                                                                     getpagesize
21673 + 65    ???                                                                     msync
21674 + 66    ???                                                                     vfork
21675 + 67    ???                                                                     vread
21676 + 68    ???                                                                     vwrite
21677 + 69    ???                                                                     sbrk
21678 + 70    advfs                                                                   sstk
21679 + 71    unadvfs                                                                 mmap
21680 + 72    rmount                                                                  vadvise
21681 + 73    rumount                                                                 munmap
21682 + 74    rfstart                                                                 mprotect
21683 + 75    ???                                                                     madvise
21684 + 76    rdebug                                                                  vhangup
21685 + 77    rfstop                                                                  vlimit
21686 + 78    rfsys                                                                   mincore
21687 + 79    rmdir                                                                   getgroups
21688 + 80    mkdir                                                                   setgroups
21689 + 81    getdents                                                                getpgrp
21690 + 82    libattach                                                               setpgid
21691 + 83    libdetach                                                               setitimer
21692 + 84    sysfs                                                                   wait
21693 + 85    getmsg                                                                  swapon
21694 + 86    putmsg                                                                  getitimer
21695 + 87    poll                                                                    gethostname
21696 + 88    lstat           ---             ---             ---                     sethostname
21697 + 89    symlink         ---             ---             ---                     getdtablesize
21698 + 90    readlink        ---             symlink         ---                     dup2
21699 + 91    setgroups       ---             lstat           ---                     ---
21700 + 92    getgroups       ---             readlink        ---                     fcntl
21701 + 93    fchmod          ---             ---             ---                     select
21702 + 94    fchown          ---             ---             ---                     ---
21703 + 95    sigprocmask     ---             ---             ---                     fsync
21704 + 96    sigsuspend      ---             ---             ---                     setpriority
21705 + 97    sigaltstack     ---             ---             ---                     socket
21706 + 98    sigaction       ---             ---             ---                     connect
21707 + 99    sigpending      ---             ---             ---                     accept
21708 +100    context         ---             ---             ---                     getpriority
21709 +101    evsys           ---             ---             ---                     send
21710 +102    evtrapret       ---             ---             ---                     recv
21711 +103    statvfs         ---             ---             ---                     sigreturn
21712 +104    fstatvfs        ---             ---             ---                     bind
21713 +105    ???                                                                     setsockopt
21714 +106    nfssys          ---             ---             ---                     listen
21715 +107    waitsys         ---             ---             ---                     vtimes
21716 +108    sigsendsys      ---             ---             ---                     sigvec
21717 +109    hrtsys          ---             ---             ---                     sigblock
21718 +110    acancel         ---             ---             ---                     sigsetmask
21719 +111    async           ---             ---             ---                     sigsuspend
21720 +112    priocntlsys     ---             ---             ---                     sigstack
21721 +113    pathconf        ---             ---             ---                     recvmsg
21722 +114    mincore         ---             ---             ---                     sendmsg
21723 +115    mmap            ---             ---             ---                     vtrace
21724 +116    mprotect        ---             ---             ---                     gettimeofday
21725 +117    munmap          ---             ---             ---                     getrusage
21726 +118    fpathconf       ---             ---             ---                     getsockopt
21727 +119    vfork           ---             ---             ---                     resuba
21728 +120    fchdir          ---             ---             ---                     readv
21729 +121    readv           ---             ---             ---                     writev
21730 +122    writev          ---             ---             ---                     settimeofday
21731 +123    xstat           ---             ---             ---                     fchown
21732 +124    lxstat          ---             ---             ---                     fchmod
21733 +125    fxstat          ---             ---             ---                     recvfrom
21734 +126    xmknod          ---             ---             ---                     setreuid
21735 +127    clocal                                                                  setregid
21736 +128    setrlimit       ---             ---             lstat                   rename
21737 +129    getrlimit       ---             ---             readlink                truncate
21738 +130    lchown          ---             ---             symlink                 ftruncate
21739 +131    memcntl         ---             ---             ---                     flock
21740 +132    getpmsg         ---             ---             ---                     mkfifo
21741 +133    putpmsg         ---             ---             gethostname             sendto
21742 +134    rename          ---             ---             sethostname             shutdown
21743 +135    uname           ---             ---             getdomainname           socketpair
21744 +136    setegid         ---             ---             setdomainname           mkdir
21745 +137    sysconfig       ---             ---             ---                     rmdir
21746 +138    adjtime         ---             ---             setreuid                utimes
21747 +139    systeminfo      ---             ---             setregid                sigreturn
21748 +140    ???                                                                     adjtime
21749 +141    seteuid         ---             ---             ---                     getpeername
21750 +142    ---             ---             ---             ---                     gethostid
21751 +143    ---             ---             ---             ---                     sethostid
21752 +144    ---             ---             ---             ---                     getrlimit
21753 +145    ---             ---             ---             ---                     setrlimit
21754 +146    ---             ---             ---             ---                     killpg
21755 +147    ---             ---             ---             ---                     setsid
21756 +148    ---             ---             ---             ---                     quotactl
21757 +149    ---             ---             ---             ---                     quota
21758 +150    ---             ---             ---             ---                     getsockname
21759 +151    ---             ---             ---             ---
21760 +152    ---             ---             ---             ---
21761 +153    ---             ---             ---             ---
21762 +154    ---             ---             ---             ---
21763 +155    ---             ---             ---             ---                     nfssvc
21764 +156    ---             ---             ---             ---                     getdirentries
21765 +157    ---             ---             ---             ---                     statfs
21766 +158    ---             ---             ---             ---                     fstatfs
21767 +159    ---             ---             ---             ---
21768 +160    ---             ---             ---             ---                     async_daemon
21769 +161    ---             ---             ---             ---                     getfh
21770 +162    ---             ---             ---             ---                     getdomainname
21771 +163    ---             ---             ---             ---                     setdomainname
21772 +164    ---             ---             ---             ---                     uname
21773 +165    ---             ---             ---             ---                     sysarch
21774 +166    ---             ---             ---             ---
21775 +167    ---             ---             ---             ---
21776 +168    ---             ---             ---             ---
21777 +169    ---             ---             ---             ---                     semsys
21778 +170    ---             ---             ---             ---                     msgsys
21779 +171    ---             ---             ---             ---                     shmsys
21780 +172    ---             ---             ---             ---
21781 +173    ---             ---             ---             ---
21782 +174    ---             ---             ---             ---
21783 +175    ---             ---             ---             ---                     ntp_gettime
21784 +176    ---             ---             ---             ---                     ntp_adjtime
21785 +177    ---             ---             ---             ---                     vm_allocate
21786 +178    ---             ---             ---             ---                     vm_deallocate
21787 +179    ---             ---             ---             ---                     vm_inherit
21788 +180    ---             ---             ---             ---                     vm_protect
21789 +181    ---             ---             ---             ---                     setgid
21790 +182    ---             ---             ---             ---                     setegid
21791 +183    ---             ---             ---             ---                     seteuid
21792 diff -Nur kernel-source-2.6.16.orig/Documentation/abi/TODO.ibcs kernel-source-2.6.16/Documentation/abi/TODO.ibcs
21793 --- kernel-source-2.6.16.orig/Documentation/abi/TODO.ibcs       1970-01-01 10:00:00.000000000 +1000
21794 +++ kernel-source-2.6.16/Documentation/abi/TODO.ibcs    2006-04-27 18:50:24.000000000 +1000
21795 @@ -0,0 +1,61 @@
21796 +
21797 +       These are leftovers from iBCS, I just removed what is already
21798 +       done in linux-abi or isn't relevant for us.  --hch
21799 +
21800 +
21801 +^Z disconnects but the next read seems to return an error instead
21802 +of blocking? (Fixed?)
21803 +
21804 +SIOGIFFLAGS seems to get passed an empty string as the interface name
21805 +(ISC ping). What is supposed to be happening?
21806 +
21807 +If a timod putmsg fails we should set an error status on the socket and
21808 +return it on future calls for strict compatibility. Currently we recover
21809 +from things such as protocol errors rather more than we should.
21810 +
21811 +Getmsg() - when select returns we may not be the first process to wake
21812 +up and handle the event. So the recvfrom ought to be non-blocking (not
21813 +possible?). If it would block we should go back to the select (unless
21814 +the descriptor is in non-blocking mode). (DONE?)
21815 +
21816 +How should we go about returning TLOOK? Currently we are only working
21817 +synchronously so it isn't essential yet. It looks like it's all handled
21818 +in libnsl_s.
21819 +
21820 +The T_MORE flag on t_snd() and t_rcv() marks message boundaries. Strictly
21821 +these should be preserved end-to-end. Possible across sockets?
21822 +(X/Open specify that message boundaries shouldn't be relied on with TCP)
21823 +
21824 +Need I_SETSIG ioctl to enable SIGPOLL on available input etc. Note that
21825 +a control message counts as input. This should interface with poll() too.
21826 +
21827 +getmsg() returns EINTR if a signal interrupts it but the t_*() functions
21828 +don't seem to propogate this back to the application. Presumably they
21829 +loop round?
21830 +
21831 +The SCO timod doesn't seem to pay much attention to the TI_* command
21832 +in an ioctl but uses the T_* primitive in the message block. i.e. if
21833 +you have T_BIND_REQ in the message but TI_GETINFO as the ioctl command
21834 +timod will do a bind. Currently we use the TI_* by preference. This
21835 +needs to change to avoid breaking programs that worked on SCO even
21836 +though broken. It shouldn't be _essential_ though as all this is
21837 +normally hidden in libnsl_s so should be consistent.
21838 +
21839 +Connects are currently forced synchronous. It wouldn't be too much
21840 +to allow them to happen asynchronously but the async confirmation
21841 +is supposed to contain the address we connected to and that is only
21842 +available from the connection request message. Unless we save it
21843 +somewhere or look it up from the socket. Hang on, we have getpeername()
21844 +capabilities...
21845 +
21846 +There are slight semantic differences between O_NDELAY and O_NONBLOCK
21847 +which cause different behaviour on SCO at least. For instance O_NDELAY
21848 +does cause t_connect to work asynchronously but O_NONBLOCK doesn't.
21849 +Under Linux O_NDELAY and O_NONBLOCK are the same. This could cause
21850 +problems at some point I guess...
21851 +
21852 +Under SCO at least poll and select are different. Poll works on things
21853 +that select can be used on but select cannot necessarily work on things
21854 +that can be polled. Specifically you can poll a transport end point
21855 +but not select on it. Badly written programs could block when they
21856 +wouldn't normally.
21857 diff -Nur kernel-source-2.6.16.orig/fs/binfmt_coff.c kernel-source-2.6.16/fs/binfmt_coff.c
21858 --- kernel-source-2.6.16.orig/fs/binfmt_coff.c  1970-01-01 10:00:00.000000000 +1000
21859 +++ kernel-source-2.6.16/fs/binfmt_coff.c       2006-04-27 18:50:24.000000000 +1000
21860 @@ -0,0 +1,850 @@
21861 +/*
21862 + * These are the functions used to load COFF IBCS style executables.
21863 + * Information on COFF format may be obtained in either the Intel Binary
21864 + * Compatibility Specification 2 or O'Rilley's book on COFF. The shared
21865 + * libraries are defined only the in the Intel book.
21866 + *
21867 + * This file is based upon code written by Eric Youngdale for the ELF object
21868 + * file format.
21869 + *
21870 + * Author: Al Longyear (longyear@sii.com)
21871 + */
21872 +
21873 +#ident "%W% %G%"
21874 +
21875 +#include <linux/module.h>
21876 +#include <linux/fs.h>
21877 +#include <linux/stat.h>
21878 +#include <linux/sched.h>
21879 +#include <linux/init.h>
21880 +#include <linux/kernel.h>
21881 +#include <linux/mm.h>
21882 +#include <linux/mman.h>
21883 +#include <linux/a.out.h>
21884 +#include <linux/errno.h>
21885 +#include <linux/signal.h>
21886 +#include <linux/binfmts.h>
21887 +#include <linux/string.h>
21888 +#include <linux/fcntl.h>
21889 +#include <linux/ptrace.h>
21890 +#include <linux/coff.h>
21891 +#include <linux/slab.h>
21892 +#include <linux/personality.h>
21893 +#include <linux/file.h>
21894 +#include <linux/unistd.h>
21895 +#include <linux/syscalls.h>
21896 +#include <asm/uaccess.h>
21897 +
21898 +
21899 +#ifndef EXPORT_NO_SYMBOLS
21900 +#define EXPORT_NO_SYMBOLS
21901 +#endif
21902 +
21903 +MODULE_DESCRIPTION("Support for the SVR3 COFF binary format");
21904 +MODULE_AUTHOR("Al Longyear, Christoph Hellwig");
21905 +MODULE_LICENSE("GPL");
21906 +
21907 +EXPORT_NO_SYMBOLS;
21908 +
21909 +
21910 +static int     coff_load_binary(struct linux_binprm *, struct pt_regs *);
21911 +static int     coff_load_shlib(struct file *);
21912 +static int     coff_preload_shlibs(struct linux_binprm *, COFF_SCNHDR *, int);
21913 +static int     coff_parse_comments(struct file *, COFF_SCNHDR *, long *);
21914 +
21915 +
21916 +static struct linux_binfmt coff_format = {
21917 +       NULL, THIS_MODULE, coff_load_binary, coff_load_shlib, NULL, PAGE_SIZE
21918 +};
21919 +
21920 +
21921 +typedef struct coff_section {
21922 +       long    scnptr;
21923 +       long    size;
21924 +       long    vaddr;
21925 +} coff_section;
21926 +
21927 +typedef struct coff_clue {
21928 +       short   terminal;       /* non-zero to stop parsing with this entry */
21929 +       short   len;            /* negative number uses strstr for lookup   */
21930 +       char    *text;          /* text to search for                       */
21931 +       u_long  mask_and, mask_or;
21932 +} coff_clue;
21933 +
21934 +
21935 +/*
21936 + * The following table gives clues to the "personality" of the executable
21937 + * which we hope to find in the .comment sections of the binary.
21938 + * The set here may not be comprehensive even for those systems listed.
21939 + * Use 'mcs -p' to list the .comments sections of a binary to see what
21940 + * clues might be there. Or use 'strings' if you don't have mcs.
21941 + */
21942 +static coff_clue coff_clues[] = {
21943 +       /*
21944 +        * Wyse Unix V/386 3.2.1[A].
21945 +        */
21946 +       {1, 36, "@(#) UNIX System V/386 Release 3.2.1", 0, PER_WYSEV386},
21947 +
21948 +       /*
21949 +        * SCO Unix V 3.2, 3.2.2, 3.2.4, 3.2.4.2 etc.
21950 +        */
21951 +       {1, 23, "@(#) crt1.s 1.8 89/05/30", 0, PER_SCOSVR3},
21952 +       {1, 16, "@(#)SCO UNIX 3.2", 0, PER_SCOSVR3},
21953 +       {1, 18, "\"@(#) SCO UNIX 3.2", 0, PER_SCOSVR3},
21954 +       {1, 17, "@(#) SCO UNIX 3.2", 0, PER_SCOSVR3},
21955 +       {1, 11, "@(#)SCO 3.2", 0, PER_SCOSVR3},
21956 +
21957 +       /*
21958 +        * SCO Unix 3.2.4.2 OpenServer 5 gives 32 bit inodes except
21959 +        * programs compiled with ods30 compatibilty. In fact OS5
21960 +        * always gives 32 bits but the library drops the top 16 in
21961 +        * odt30 mode. We know what should happen and do it however.
21962 +        */
21963 +       {0, 32, "@(#) crt1.s.source 20.1 94/12/04", 0, PER_SCOSVR3},
21964 +       {1, 13, "ods_30_compat", ~0, PERF_SHORT_INODE},
21965 +
21966 +       /*
21967 +        * Interactive (ISC) 4.0.
21968 +        */
21969 +       {1, -1, "INTERACTIVE", 0, PER_ISCR4},
21970 +
21971 +       /*
21972 +        * End of table.
21973 +        */
21974 +       {0, 0, 0, 0, 0}
21975 +};
21976 +
21977 +/*
21978 + * Parse a comments section looking for clues as to the system this
21979 + * was compiled on so we can get the system call interface right.
21980 + */
21981 +static int
21982 +coff_parse_comments(struct file *fp, COFF_SCNHDR *sect, long *personality)
21983 +{
21984 +       u_long                  offset, nbytes;
21985 +       int                     hits = 0, err;
21986 +       char                    *buffer;
21987 +
21988 +       if (!(buffer = (char *)__get_free_page(GFP_KERNEL)))
21989 +               return 0;
21990 +
21991 +       /*
21992 +        * Fetch the size of the section.  There must be something in there
21993 +        * or the section wouldn't exist at all.  We only bother with the
21994 +        * first 8192 characters though.  There isn't any point getting too
21995 +        * carried away!
21996 +        */
21997 +       if ((nbytes = COFF_LONG(sect->s_size)) > 8192)
21998 +               nbytes = 8192;
21999 +
22000 +       offset = COFF_LONG(sect->s_scnptr);
22001 +       while (nbytes > 0) {
22002 +               u_long          count, start = 0;
22003 +               char            *p;
22004 +
22005 +               err = kernel_read(fp, offset, buffer,
22006 +                               nbytes > PAGE_SIZE ? PAGE_SIZE : nbytes);
22007 +
22008 +               if (err <= 0) {
22009 +                        free_page((u_long) buffer);
22010 +                        return 0;
22011 +               }
22012 +
22013 +               p = buffer;
22014 +               for (count = 0; count < err; count++) {
22015 +                       coff_clue               *clue;
22016 +                       char                    c;
22017 +
22018 +                       c = *(buffer + PAGE_SIZE - 1);
22019 +                       *(buffer + PAGE_SIZE - 1) = '\0';
22020 +
22021 +                       for (clue = coff_clues; clue->len; clue++) {
22022 +                               if ((clue->len < 0 && strstr(p, clue->text)) ||
22023 +                                   (clue->len > 0 && !strncmp(p, clue->text, clue->len))) {
22024 +                                       *personality &= clue->mask_and;
22025 +                                       *personality |= clue->mask_or;
22026 +                                       if (clue->terminal) {
22027 +                                               free_page((u_long)buffer);
22028 +                                               return 1;
22029 +                                       }
22030 +                                       hits++;
22031 +                               }
22032 +                       }
22033 +                       *(buffer + PAGE_SIZE - 1) = c;
22034 +
22035 +                       while (*p && count < err)
22036 +                               p++, count++;
22037 +                       if (count < err) {
22038 +                               p++;
22039 +                               count++;
22040 +                               start = count;
22041 +                       }
22042 +               }
22043 +
22044 +               /*
22045 +                * If we didn't find an end ofstring at all this page
22046 +                * probably isn't useful string data.
22047 +                */
22048 +               if (start == 0)
22049 +                       start = err;
22050 +
22051 +               nbytes -= start;
22052 +               offset += start;
22053 +       }
22054 +
22055 +       free_page((u_long)buffer);
22056 +       return (hits);
22057 +}
22058 +
22059 +/*
22060 + * Small procedure to test for the proper file alignment.
22061 + * Return the error code if the section is not properly aligned.
22062 + */
22063 +static __inline__ int
22064 +coff_isaligned(COFF_SCNHDR *sectp)
22065 +{
22066 +       long                    scnptr = COFF_LONG(sectp->s_scnptr);
22067 +       long                    vaddr = COFF_LONG(sectp->s_vaddr);
22068 +
22069 +       if ((vaddr - scnptr) & ~PAGE_MASK)
22070 +               return -ENOEXEC;
22071 +       return 0;
22072 +}
22073 +
22074 +/*
22075 + * Clear the bytes in the last page of data.
22076 + */
22077 +static int
22078 +coff_clear_memory(u_long addr, u_long size)
22079 +{
22080 +       int                     err = 0;
22081 +
22082 +       if ((size = (PAGE_SIZE - (addr & ~PAGE_MASK)) & ~PAGE_MASK) == 0)
22083 +               goto out;
22084 +       if (!access_ok(VERIFY_WRITE, (void *)addr, size))
22085 +       {
22086 +               err = -EFAULT;
22087 +               goto out;
22088 +       }
22089 +
22090 +       while (size-- != 0) {
22091 +               __put_user(0, (char *)addr);
22092 +               addr++;
22093 +       }
22094 +
22095 +out:
22096 +       return (err);
22097 +}
22098 +
22099 +static inline unsigned long
22100 +map_coff(struct file *file, coff_section *sect, unsigned long prot,
22101 +       unsigned long flag, unsigned long offset)
22102 +{
22103 +       unsigned long map_addr;
22104 +
22105 +       down_write(&current->mm->mmap_sem);
22106 +       map_addr = do_mmap(file,
22107 +               sect->vaddr & PAGE_MASK,
22108 +               sect->size + (sect->vaddr & ~PAGE_MASK),
22109 +               prot, flag, offset);
22110 +       up_write(&current->mm->mmap_sem);
22111 +
22112 +       return (map_addr);
22113 +}
22114 +
22115 +
22116 +static u_long *
22117 +coff_mktables(char *p, int argc, int envc)
22118 +{
22119 +       u_long                  *argv, *envp;
22120 +       u_long                  *sp;
22121 +
22122 +       sp = (u_long *) ((-(u_long)sizeof(char *)) & (u_long)p);
22123 +
22124 +       sp -= envc + 1;
22125 +       envp = sp;
22126 +       sp -= argc + 1;
22127 +       argv = sp;
22128 +
22129 +       put_user(argc, --sp);
22130 +       current->mm->arg_start = (u_long)p;
22131 +
22132 +       while (argc-- > 0) {
22133 +               __put_user(p, argv++);
22134 +               p += strlen_user(p);
22135 +       }
22136 +
22137 +       __put_user(NULL, argv);
22138 +       current->mm->arg_end = current->mm->env_start = (u_long)p;
22139 +
22140 +       while (envc-- > 0) {
22141 +               __put_user(p, envp++);
22142 +               p += strlen_user(p);
22143 +       }
22144 +
22145 +       __put_user(NULL, envp);
22146 +       current->mm->env_end = (u_long) p;
22147 +
22148 +       return (sp);
22149 +}
22150 +
22151 +/*
22152 + * Helper function to process the load operation.
22153 + */
22154 +static int
22155 +coff_load_object(struct linux_binprm *bprm, struct pt_regs *regs, int binary)
22156 +{
22157 +       COFF_FILHDR             *coff_hdr = NULL;
22158 +       COFF_SCNHDR             *text_sect = NULL, *data_sect = NULL,
22159 +                               *bss_sect = NULL, *sect_bufr = NULL,
22160 +                               *sect_ptr = NULL;
22161 +       int                     text_count = 0, data_count = 0,
22162 +                               bss_count = 0, lib_count = 0;
22163 +       coff_section            text, data, bss;
22164 +       u_long                  start_addr = 0, p = bprm->p;
22165 +       short                   flags, aout_size = 0;
22166 +       int                     pageable = 1, sections = 0, status = 0, i;
22167 +       int                     coff_exec_fileno;
22168 +       mm_segment_t            old_fs;
22169 +
22170 +
22171 +       coff_hdr = (COFF_FILHDR *)bprm->buf;
22172 +
22173 +       /*
22174 +        * Validate the magic value for the object file.
22175 +        */
22176 +       if (COFF_I386BADMAG(*coff_hdr))
22177 +               return -ENOEXEC;
22178 +
22179 +       flags = COFF_SHORT(coff_hdr->f_flags);
22180 +
22181 +       /*
22182 +        * The object file should have 32 BIT little endian format. Do not allow
22183 +        * it to have the 16 bit object file flag set as Linux is not able to run
22184 +        * on the 80286/80186/8086.
22185 +        */
22186 +       if ((flags & (COFF_F_AR32WR | COFF_F_AR16WR)) != COFF_F_AR32WR)
22187 +               return -ENOEXEC;
22188 +
22189 +       /*
22190 +        * If the file is not executable then reject the execution. This means
22191 +        * that there must not be external references.
22192 +        */
22193 +       if ((flags & COFF_F_EXEC) == 0)
22194 +               return -ENOEXEC;
22195 +
22196 +       /*
22197 +        * Extract the header information which we need.
22198 +        */
22199 +       sections = COFF_SHORT(coff_hdr->f_nscns);       /* Number of sections */
22200 +       aout_size = COFF_SHORT(coff_hdr->f_opthdr);     /* Size of opt. headr */
22201 +
22202 +       /*
22203 +        * There must be at least one section.
22204 +        */
22205 +       if (!sections)
22206 +               return -ENOEXEC;
22207 +
22208 +       if (!bprm->file->f_op->mmap)
22209 +               pageable = 0;
22210 +
22211 +       if (!(sect_bufr = kmalloc(sections * COFF_SCNHSZ, GFP_KERNEL))) {
22212 +               printk(KERN_WARNING "coff: kmalloc failed\n");
22213 +               return -ENOMEM;
22214 +       }
22215 +
22216 +       status = kernel_read(bprm->file, aout_size + COFF_FILHSZ,
22217 +                       (char *)sect_bufr, sections * COFF_SCNHSZ);
22218 +       if (status < 0) {
22219 +               printk(KERN_WARNING "coff: unable to read\n");
22220 +               goto out_free_buf;
22221 +       }
22222 +
22223 +       status = get_unused_fd();
22224 +       if (status < 0) {
22225 +               printk(KERN_WARNING "coff: unable to get free fs\n");
22226 +               goto out_free_buf;
22227 +       }
22228 +
22229 +       get_file(bprm->file);
22230 +       fd_install(coff_exec_fileno = status, bprm->file);
22231 +
22232 +       /*
22233 +        *  Loop through the sections and find the various types
22234 +        */
22235 +       sect_ptr = sect_bufr;
22236 +
22237 +       for (i = 0; i < sections; i++) {
22238 +               long int sect_flags = COFF_LONG(sect_ptr->s_flags);
22239 +
22240 +               switch (sect_flags) {
22241 +               case COFF_STYP_TEXT:
22242 +                       status |= coff_isaligned(sect_ptr);
22243 +                       text_sect = sect_ptr;
22244 +                       text_count++;
22245 +                       break;
22246 +
22247 +               case COFF_STYP_DATA:
22248 +                       status |= coff_isaligned(sect_ptr);
22249 +                       data_sect = sect_ptr;
22250 +                       data_count++;
22251 +                       break;
22252 +
22253 +               case COFF_STYP_BSS:
22254 +                       bss_sect = sect_ptr;
22255 +                       bss_count++;
22256 +                       break;
22257 +
22258 +               case COFF_STYP_LIB:
22259 +                       lib_count++;
22260 +                       break;
22261 +
22262 +               default:
22263 +                       break;
22264 +               }
22265 +
22266 +               sect_ptr = (COFF_SCNHDR *) & ((char *) sect_ptr)[COFF_SCNHSZ];
22267 +       }
22268 +
22269 +       /*
22270 +        * If any of the sections weren't properly aligned we aren't
22271 +        * going to be able to demand page this executable. Note that
22272 +        * at this stage the *only* excuse for having status <= 0 is if
22273 +        * the alignment test failed.
22274 +        */
22275 +       if (status < 0)
22276 +               pageable = 0;
22277 +
22278 +       /*
22279 +        * Ensure that there are the required sections.  There must be one
22280 +        * text sections and one each of the data and bss sections for an
22281 +        * executable.  A library may or may not have a data / bss section.
22282 +        */
22283 +       if (text_count != 1) {
22284 +               status = -ENOEXEC;
22285 +               goto out_free_file;
22286 +       }
22287 +       if (binary && (data_count != 1 || bss_count != 1)) {
22288 +               status = -ENOEXEC;
22289 +               goto out_free_file;
22290 +       }
22291 +
22292 +       /*
22293 +        * If there is no additional header then assume the file starts
22294 +        * at the first byte of the text section.  This may not be the
22295 +        * proper place, so the best solution is to include the optional
22296 +        * header.  A shared library __MUST__ have an optional header to
22297 +        * indicate that it is a shared library.
22298 +        */
22299 +       if (aout_size == 0) {
22300 +               if (!binary) {
22301 +                       status = -ENOEXEC;
22302 +                       goto out_free_file;
22303 +               }
22304 +               start_addr = COFF_LONG(text_sect->s_vaddr);
22305 +       } else if (aout_size < (short) COFF_AOUTSZ) {
22306 +               status = -ENOEXEC;
22307 +               goto out_free_file;
22308 +       } else {
22309 +               COFF_AOUTHDR    *aout_hdr;
22310 +               short           aout_magic;
22311 +
22312 +               aout_hdr = (COFF_AOUTHDR *) &((char *)coff_hdr)[COFF_FILHSZ];
22313 +               aout_magic = COFF_SHORT(aout_hdr->magic);
22314 +
22315 +               /*
22316 +                * Validate the magic number in the a.out header. If it is valid then
22317 +                * update the starting symbol location. Do not accept these file formats
22318 +                * when loading a shared library.
22319 +                */
22320 +               switch (aout_magic) {
22321 +               case COFF_OMAGIC:
22322 +               case COFF_ZMAGIC:
22323 +               case COFF_STMAGIC:
22324 +                       if (!binary) {
22325 +                               status = -ENOEXEC;
22326 +                               goto out_free_file;
22327 +                       }
22328 +                       start_addr = (u_int)COFF_LONG(aout_hdr->entry);
22329 +                       break;
22330 +               /*
22331 +                * Magic value for a shared library. This is valid only when
22332 +                * loading a shared library.
22333 +                *
22334 +                * (There is no need for a start_addr. It won't be used.)
22335 +                */
22336 +               case COFF_SHMAGIC:
22337 +                       if (!binary)
22338 +                               break;
22339 +                       /* FALLTHROUGH */
22340 +               default:
22341 +                       status = -ENOEXEC;
22342 +                       goto out_free_file;
22343 +               }
22344 +       }
22345 +
22346 +       /*
22347 +        *  Generate the proper values for the text fields
22348 +        *
22349 +        *  THIS IS THE POINT OF NO RETURN. THE NEW PROCESS WILL TRAP OUT SHOULD
22350 +        *  SOMETHING FAIL IN THE LOAD SEQUENCE FROM THIS POINT ONWARD.
22351 +        */
22352 +
22353 +       text.scnptr = COFF_LONG(text_sect->s_scnptr);
22354 +       text.size = COFF_LONG(text_sect->s_size);
22355 +       text.vaddr = COFF_LONG(text_sect->s_vaddr);
22356 +
22357 +       /*
22358 +        *  Generate the proper values for the data fields
22359 +        */
22360 +
22361 +       if (data_sect != NULL) {
22362 +               data.scnptr = COFF_LONG(data_sect->s_scnptr);
22363 +               data.size = COFF_LONG(data_sect->s_size);
22364 +               data.vaddr = COFF_LONG(data_sect->s_vaddr);
22365 +       } else {
22366 +               data.scnptr = 0;
22367 +               data.size = 0;
22368 +               data.vaddr = 0;
22369 +       }
22370 +
22371 +       /*
22372 +        *  Generate the proper values for the bss fields
22373 +        */
22374 +
22375 +       if (bss_sect != NULL) {
22376 +               bss.size = COFF_LONG(bss_sect->s_size);
22377 +               bss.vaddr = COFF_LONG(bss_sect->s_vaddr);
22378 +       } else {
22379 +               bss.size = 0;
22380 +               bss.vaddr = 0;
22381 +       }
22382 +
22383 +       /*
22384 +        * Flush the executable from memory. At this point the executable is
22385 +        * committed to being defined or a segmentation violation will occur.
22386 +        */
22387 +
22388 +       if (binary) {
22389 +               COFF_SCNHDR     *sect_ptr2 = sect_bufr;
22390 +               u_long          personality = PER_SVR3;
22391 +               int             i;
22392 +
22393 +               if ((status = flush_old_exec(bprm)))
22394 +                       goto out_free_file;
22395 +
22396 +               /*
22397 +                * Look for clues as to the system this binary was compiled
22398 +                * on in the comments section(s).
22399 +                *
22400 +                * Only look at the main binary, not the shared libraries
22401 +                * (or would it be better to prefer shared libraries over
22402 +                * binaries?  Or could they be different???)
22403 +                */
22404 +               for (i = 0; i < sections; i++) {
22405 +                       long    sect_flags = COFF_LONG(sect_ptr2->s_flags);
22406 +
22407 +                       if (sect_flags == COFF_STYP_INFO &&
22408 +                          (status = coff_parse_comments(bprm->file,
22409 +                                               sect_ptr2, &personality)) > 0)
22410 +                               goto found;
22411 +
22412 +                       sect_ptr2 = (COFF_SCNHDR *) &((char *)sect_ptr2)[COFF_SCNHSZ];
22413 +               }
22414 +
22415 +               /*
22416 +                * If no .comments section was found there is no way to
22417 +                * figure out the personality. Odds on it is SCO though...
22418 +                */
22419 +               personality = abi_defhandler_coff;
22420 +
22421 +found:
22422 +               set_personality(personality);
22423 +
22424 +               current->mm->start_data = 0;
22425 +               current->mm->end_data = 0;
22426 +               current->mm->end_code = 0;
22427 +               current->mm->mmap = NULL;
22428 +               current->flags &= ~PF_FORKNOEXEC;
22429 +               atomic_long_set(&current->mm->_file_rss, 0);
22430 +
22431 +               /*
22432 +                * Construct the parameter and environment
22433 +                * string table entries.
22434 +                */
22435 +               if ((status = setup_arg_pages(bprm, STACK_TOP, EXSTACK_DEFAULT)) < 0)
22436 +                       goto sigsegv;
22437 +
22438 +               p = (u_long)coff_mktables((char *)bprm->p,
22439 +                               bprm->argc, bprm->envc);
22440 +
22441 +               current->mm->end_code = text.size +
22442 +                   (current->mm->start_code = text.vaddr);
22443 +               current->mm->end_data = data.size +
22444 +                   (current->mm->start_data = data.vaddr);
22445 +               current->mm->brk = bss.size +
22446 +                   (current->mm->start_brk = bss.vaddr);
22447 +
22448 +               current->mm->start_stack = p;
22449 +               compute_creds(bprm);
22450 +               start_thread(regs, start_addr, p);
22451 +       }
22452 +
22453 +       old_fs = get_fs();
22454 +       set_fs(get_ds());
22455 +
22456 +       if (!pageable) {
22457 +               /*
22458 +                * Read the file from disk...
22459 +                *
22460 +                * XXX: untested.
22461 +                */
22462 +               loff_t pos = data.scnptr;
22463 +               status = do_brk(text.vaddr, text.size);
22464 +               bprm->file->f_op->read(bprm->file,
22465 +                               (char *)data.vaddr, data.scnptr, &pos);
22466 +               status = do_brk(data.vaddr, data.size);
22467 +               bprm->file->f_op->read(bprm->file,
22468 +                               (char *)text.vaddr, text.scnptr, &pos);
22469 +               status = 0;
22470 +       } else {
22471 +               /* map the text pages...*/
22472 +               status = map_coff(bprm->file, &text, PROT_READ | PROT_EXEC,
22473 +                       MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
22474 +                       text.scnptr & PAGE_MASK);
22475 +
22476 +               if (status != (text.vaddr & PAGE_MASK)) {
22477 +                       status = -ENOEXEC;
22478 +                       goto out_free_file;
22479 +               }
22480 +
22481 +               /* map the data pages */
22482 +               if (data.size != 0) {
22483 +                       status = map_coff(bprm->file, &data,
22484 +                           PROT_READ | PROT_WRITE | PROT_EXEC,
22485 +                           MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
22486 +                           data.scnptr & PAGE_MASK);
22487 +
22488 +                       if (status != (data.vaddr & PAGE_MASK)) {
22489 +                               status = -ENOEXEC;
22490 +                               goto out_free_file;
22491 +                       }
22492 +               }
22493 +
22494 +               status = 0;
22495 +       }
22496 +
22497 +       /*
22498 +        * Construct the bss data for the process. The bss ranges from the
22499 +        * end of the data (which may not be on a page boundary) to the end
22500 +        * of the bss section. Allocate any necessary pages for the data.
22501 +        */
22502 +       if (bss.size != 0) {
22503 +               down_write(&current->mm->mmap_sem);
22504 +               do_mmap(NULL, PAGE_ALIGN(bss.vaddr),
22505 +                       bss.size + bss.vaddr -
22506 +                       PAGE_ALIGN(bss.vaddr),
22507 +                       PROT_READ | PROT_WRITE | PROT_EXEC,
22508 +                       MAP_FIXED | MAP_PRIVATE, 0);
22509 +               up_write(&current->mm->mmap_sem);
22510 +
22511 +               if ((status = coff_clear_memory(bss.vaddr, bss.size)) < 0)
22512 +                       goto out_free_file;
22513 +       }
22514 +
22515 +       set_fs(old_fs);
22516 +
22517 +       if (!binary)
22518 +               goto out_free_file;
22519 +
22520 +       /*
22521 +        * Load any shared library for the executable.
22522 +        */
22523 +       if (lib_count)
22524 +               status = coff_preload_shlibs(bprm, sect_bufr, sections);
22525 +
22526 +       set_binfmt(&coff_format);
22527 +
22528 +       /*
22529 +        * Generate any needed trap for this process. If an error occured then
22530 +        * generate a segmentation violation. If the process is being debugged
22531 +        * then generate the load trap. (Note: If this is a library load then
22532 +        * do not generate the trap here. Pass the error to the caller who
22533 +        * will do it for the process in the outer lay of this procedure call.)
22534 +        */
22535 +       if (status < 0) {
22536 +sigsegv:
22537 +               printk(KERN_WARNING "coff: trapping process with SEGV\n");
22538 +               send_sig(SIGSEGV, current, 0);  /* Generate the error trap  */
22539 +       } else if (current->ptrace & PT_PTRACED)
22540 +               send_sig(SIGTRAP, current, 0);
22541 +
22542 +       /* We are committed. It can't fail */
22543 +       status = 0;
22544 +
22545 +out_free_file:
22546 +       sys_close(coff_exec_fileno);
22547 +
22548 +out_free_buf:
22549 +       kfree(sect_bufr);
22550 +       return (status);
22551 +}
22552 +
22553 +/*
22554 + * This procedure is called to load a library section. The various
22555 + * libraries are loaded from the list given in the section data.
22556 + */
22557 +static int
22558 +coff_preload_shlib(struct linux_binprm *exe_bprm, COFF_SCNHDR *sect)
22559 +{
22560 +       COFF_SLIBHD             *phdr;
22561 +       char                    *buffer;
22562 +       long                    nbytes;
22563 +       int                     err = 0;
22564 +
22565 +       /*
22566 +        * Fetch the size of the section. There must be
22567 +        * enough room for at least one entry.
22568 +        */
22569 +       nbytes = (long)COFF_LONG(sect->s_size);
22570 +       if (nbytes < (long)COFF_SLIBSZ)
22571 +               return -ENOEXEC;
22572 +
22573 +       if (!(buffer = kmalloc(nbytes, GFP_KERNEL))) {
22574 +               printk(KERN_WARNING "coff: unable to allocate shlib buffer\n");
22575 +               return -ENOMEM;
22576 +       }
22577 +
22578 +       err = kernel_read(exe_bprm->file,
22579 +                       COFF_LONG(sect->s_scnptr), buffer, nbytes);
22580 +
22581 +       if (err < 0)
22582 +               goto out;
22583 +       if (err != nbytes)
22584 +               goto enoexec;
22585 +
22586 +       /*
22587 +        * Go through the list of libraries in the data area.
22588 +        */
22589 +       phdr = (COFF_SLIBHD *)buffer;
22590 +       while (nbytes > (long)COFF_SLIBSZ) {
22591 +               int             entry_size, header_size;
22592 +               mm_segment_t    old_fs = get_fs();
22593 +
22594 +               entry_size = COFF_LONG(phdr->sl_entsz) * sizeof(long);
22595 +               header_size = COFF_LONG(phdr->sl_pathndx) * sizeof(long);
22596 +
22597 +               /*
22598 +                * Validate the sizes of the various items.
22599 +                * I don't trust the linker!!
22600 +                */
22601 +               if ((u_int)header_size >= (u_int)nbytes)
22602 +                       goto enoexec;
22603 +               if ((u_int)entry_size <= (u_int)header_size)
22604 +                       goto enoexec;
22605 +               if (entry_size <= 0)
22606 +                       goto enoexec;
22607 +
22608 +               set_fs(get_ds());
22609 +               err = sys_uselib(&((char *)phdr)[header_size]);
22610 +               set_fs(old_fs);
22611 +
22612 +               if (err < 0)
22613 +                       goto out;
22614 +
22615 +               /*
22616 +                * Point to the next library in the section data.
22617 +                */
22618 +               nbytes -= entry_size;
22619 +               phdr = (COFF_SLIBHD *) & ((char *) phdr)[entry_size];
22620 +       }
22621 +
22622 +out:
22623 +       kfree(buffer);
22624 +       return (err);
22625 +enoexec:
22626 +       err = -ENOEXEC;
22627 +       goto out;
22628 +}
22629 +
22630 +/*
22631 + * Find all library sections and preload the shared libraries.
22632 + *
22633 + * This will eventually recurse to our code and load the shared
22634 + * library with our own procedures.
22635 + */
22636 +static int
22637 +coff_preload_shlibs(struct linux_binprm *bpp, COFF_SCNHDR *sp, int sections)
22638 +{
22639 +       long                    flags;
22640 +       int                     err = 0, i;
22641 +
22642 +       for (i = 0; i < sections; i++) {
22643 +               flags = COFF_LONG(sp->s_flags);
22644 +               if (flags == COFF_STYP_LIB) {
22645 +                       if ((err = coff_preload_shlib(bpp, sp)))
22646 +                                       break;
22647 +               }
22648 +               sp = (COFF_SCNHDR *)&((char *)sp)[COFF_SCNHSZ];
22649 +       }
22650 +
22651 +       return (err);
22652 +}
22653 +
22654 +/*
22655 + * Load the image for an (coff) binary.
22656 + *
22657 + *   => this procedure is called by the main load sequence,
22658 + *      it will load the executable and prepare it for execution
22659 + */
22660 +static int
22661 +coff_load_binary(struct linux_binprm *bpp, struct pt_regs *rp)
22662 +{
22663 +       return (coff_load_object(bpp, rp, 1));
22664 +}
22665 +
22666 +/*
22667 + * Load the image for a (coff) shared library.
22668 + *
22669 + *   => this is called when we need to load a library based upon a file name.
22670 + *   => also called through coff_preload_shlib
22671 + */
22672 +static int
22673 +coff_load_shlib(struct file *fp)
22674 +{
22675 +       struct linux_binprm             *bpp;
22676 +       struct pt_regs                  regs;
22677 +       int                             err = -ENOMEM;
22678 +
22679 +       if (!(bpp = kmalloc(sizeof(struct linux_binprm), GFP_KERNEL))) {
22680 +               printk(KERN_WARNING "coff: kmalloc failed\n");
22681 +               goto out;
22682 +       }
22683 +
22684 +       memset(bpp, 0, sizeof(struct linux_binprm));
22685 +       bpp->file = fp;
22686 +
22687 +       if ((err = kernel_read(fp, 0L, bpp->buf, sizeof(bpp->buf))) < 0)
22688 +               printk(KERN_WARNING "coff: unable to read library header\n");
22689 +       else
22690 +               err = coff_load_object(bpp, &regs, 0);
22691 +
22692 +       kfree(bpp);
22693 +out:
22694 +       return (err);
22695 +}
22696 +
22697 +static int __init
22698 +coff_module_init(void)
22699 +{
22700 +       return (register_binfmt(&coff_format));
22701 +}
22702 +
22703 +static void __exit
22704 +coff_module_exit(void)
22705 +{
22706 +       unregister_binfmt(&coff_format);
22707 +}
22708 +
22709 +module_init(coff_module_init);
22710 +module_exit(coff_module_exit);
22711 diff -Nur kernel-source-2.6.16.orig/fs/binfmt_xout.c kernel-source-2.6.16/fs/binfmt_xout.c
22712 --- kernel-source-2.6.16.orig/fs/binfmt_xout.c  1970-01-01 10:00:00.000000000 +1000
22713 +++ kernel-source-2.6.16/fs/binfmt_xout.c       2006-04-27 18:50:24.000000000 +1000
22714 @@ -0,0 +1,862 @@
22715 +/*
22716 + * Copyright (c) 1994  Mike Jagdis (jaggy@purplet.demon.co.uk)
22717 + * Copyright (c) 2001  Christoph Hellwig (hch@caldera.de)
22718 + */
22719 +
22720 +#ident "%W% %G%"
22721 +
22722 +/*
22723 + * This file is based upon code written by Al Longyear for the COFF file
22724 + * format which is in turn based upon code written by Eric Youngdale for
22725 + * the ELF object file format. Any errors are most likely my own however.
22726 + */
22727 +#define __KERNEL_SYSCALLS__
22728 +#include <linux/config.h>
22729 +#include <linux/module.h>
22730 +#include <linux/init.h>
22731 +#include <linux/fs.h>
22732 +#include <linux/sched.h>
22733 +#include <linux/mm.h>
22734 +#include <linux/mman.h>
22735 +#include <linux/a.out.h>
22736 +#include <linux/errno.h>
22737 +#include <linux/signal.h>
22738 +#include <linux/binfmts.h>
22739 +#include <linux/string.h>
22740 +#include <linux/fcntl.h>
22741 +#include <linux/ptrace.h>
22742 +#include <linux/personality.h>
22743 +#include <linux/file.h>
22744 +#include <linux/slab.h>
22745 +#include <linux/unistd.h>
22746 +#include <linux/syscalls.h>
22747 +#include <linux/xout.h>
22748 +
22749 +#include <asm/uaccess.h>
22750 +#include <asm/desc.h>
22751 +
22752 +
22753 +MODULE_DESCRIPTION("Support for the Microsoft a.out (x.out) binary format");
22754 +MODULE_AUTHOR("Mike Jagdis, Christoph Hellwig");
22755 +MODULE_LICENSE("GPL");
22756 +
22757 +
22758 +/*
22759 + * This is the name of the overlay library used for handling
22760 + * Xenix/286 binaries.  Usually there is no need to change this.
22761 + */
22762 +#define _PATH_X286EMUL "/usr/lib/x286emul"
22763 +
22764 +/*
22765 + * If you compile with XOUT_DEBUG defined you will get additional
22766 + * debugging messages from the x.out module.
22767 + */
22768 +#undef XOUT_DEBUG
22769 +
22770 +/*
22771 + * If you compile with XOUT_SEGMENTS defined the loader will take care
22772 + * to set up the LDT as would "real" Xenix. This shouldn't be necessary
22773 + * for most programs but it is just possible that something out there
22774 + * makes assumptions about its environment and uses segment overrides.
22775 + *
22776 + * The default is not to bother setting up the LDT unless we need support
22777 + * for Xenix 286 binaries.
22778 + */
22779 +#undef XOUT_SEGMENTS
22780 +
22781 +/*
22782 + * Xenix 286 requires segment handling.
22783 + */
22784 +#if defined(CONFIG_BINFMT_XOUT_X286)
22785 +#define XOUT_SEGMENTS
22786 +#endif
22787 +
22788 +/*
22789 + * Be verbose if XOUT_DEBUG is defined.
22790 + */
22791 +#if defined(XOUT_DEBUG)
22792 +#define dprintk(x...)  printk(x)
22793 +#else
22794 +#define dprintk(x...)
22795 +#endif
22796 +
22797 +
22798 +static int     xout_load_binary(struct linux_binprm *, struct pt_regs *);
22799 +static int     xout_load_library(struct file *);
22800 +
22801 +static struct linux_binfmt xout_format = {
22802 +       NULL, THIS_MODULE, xout_load_binary, xout_load_library, NULL, PAGE_SIZE
22803 +};
22804 +
22805 +#if defined(XOUT_DEBUG) && defined(XOUT_SEGMENTS)
22806 +
22807 +static u_long __gdt[2];
22808 +
22809 +/*
22810 + * This is borrowed (with minor variations since we are in kernel mode)
22811 + * from the DPMI code for DOSEMU. I don't claim to understand LDTs :-).
22812 + */
22813 +void
22814 +print_desc(int which)
22815 +{
22816 +       u_long                  base_addr, limit;
22817 +       u_long                  *lp;
22818 +       int                     count, type, dpl, i;
22819 +
22820 +       if (which) {
22821 +               lp = (u_long *)((struct desc_struct*)
22822 +                               (current->mm->context.segments));
22823 +               count = LDT_ENTRIES;
22824 +               printk(KERN_DEBUG "xout: LDT\n");
22825 +       } else {
22826 +               /* joerg from david bruce */
22827 +               asm volatile ("sgdt __gdt+2");
22828 +               lp = (u_long *)__gdt[1];
22829 +               count = 8;
22830 +               printk(KERN_DEBUG "xout: GDT\n");
22831 +       }
22832 +
22833 +       if (!lp)
22834 +               return;
22835 +
22836 +       printk(KERN_DEBUG "XOUT: SLOT  BASE/SEL    LIM/OFF     TYPE  DPL  ACCESSBITS\n");
22837 +       for (i=0; i < count; i++, lp++) {
22838 +               /* First 32 bits of descriptor */
22839 +               base_addr = (*lp >> 16) & 0x0000FFFF;
22840 +               limit = *lp & 0x0000FFFF;
22841 +               lp++;
22842 +
22843 +               /* First 32 bits of descriptor */
22844 +               base_addr |= (*lp & 0xFF000000) | ((*lp << 16) & 0x00FF0000);
22845 +               limit |= (*lp & 0x000F0000);
22846 +               type = (*lp >> 10) & 7;
22847 +               dpl = (*lp >> 13) & 3;
22848 +               if ((base_addr > 0) || (limit > 0 )) {
22849 +                       printk(KERN_DEBUG "XOUT: %03d   0x%08lx  0x%08lx  0x%02x  %03d %s%s%s%s%s%s%s\n",
22850 +                               i,
22851 +                               base_addr, limit, type, dpl,
22852 +                               (*lp & 0x100) ? " ACCS'D" : "",
22853 +                               (*lp & 0x200) ? " R&W" : " R&X",
22854 +                               (*lp & 0x8000) ? " PRESENT" : "",
22855 +                               (*lp & 0x100000) ? " USER" : "",
22856 +                               (*lp & 0x200000) ? " X" : "",
22857 +                               (*lp & 0x400000) ? " 32" : "",
22858 +                               (*lp & 0x800000) ? " PAGES" : "");
22859 +               }
22860 +       }
22861 +}
22862 +#endif
22863 +
22864 +
22865 +static u_long *
22866 +xout_create_tables(char *p, struct linux_binprm *bprm, int ibcs)
22867 +{
22868 +        int                            argc = bprm->argc, envc = bprm->envc;
22869 +        u_long                         *argv,*envp;
22870 +        u_long                         *sp;
22871 +
22872 +        sp = (u_long *) ((-(u_long)sizeof(char *)) & (u_long) p);
22873 +        sp -= envc+1;
22874 +        envp = sp;
22875 +        sp -= argc+1;
22876 +        argv = sp;
22877 +        if (!ibcs) {
22878 +                sp--;
22879 +                put_user(envp, sp);
22880 +                sp--;
22881 +                put_user(argv, sp);
22882 +        }
22883 +        sp--;
22884 +        put_user(argc, sp);
22885 +        current->mm->arg_start = (u_long) p;
22886 +        while (argc-->0) {
22887 +                put_user(p, argv); argv++;
22888 +                p += strlen_user(p);
22889 +        }
22890 +        put_user(NULL,argv);
22891 +        current->mm->arg_end = current->mm->env_start = (u_long) p;
22892 +        while (envc-->0) {
22893 +                put_user(p, envp); envp++;
22894 +                p += strlen_user(p);
22895 +        }
22896 +        put_user(NULL,envp);
22897 +        current->mm->env_end = (u_long) p;
22898 +        return (sp);
22899 +}
22900 +
22901 +static __inline int
22902 +isnotaligned(struct xseg *seg)
22903 +{
22904 +       dprintk(KERN_DEBUG
22905 +               "xout: %04x %04x %04x %02x %08lx %08lx %08lx %08lx\n",
22906 +               seg->xs_type, seg->xs_attr, seg->xs_seg, seg->xs_align,
22907 +               seg->xs_filpos, seg->xs_psize, seg->xs_vsize, seg->xs_rbase);
22908 +
22909 +#if defined(XOUT_DEBUG)
22910 +       if ((seg->xs_filpos - seg->xs_rbase) & ~PAGE_MASK) {
22911 +               printk(KERN_DEBUG
22912 +                       "xout: bad alignment - demand paging disabled\n");
22913 +       }
22914 +#endif
22915 +       return ((seg->xs_filpos & ~PAGE_MASK) | (seg->xs_rbase & ~PAGE_MASK));
22916 +}
22917 +
22918 +static __inline__ void
22919 +clear_memory(u_long addr, u_long size)
22920 +{
22921 +       while (size-- != 0)
22922 +               put_user(0, (char *)addr++);
22923 +}
22924 +
22925 +#if defined(XOUT_SEGMENTS)
22926 +#if defined(CONFIG_X86)
22927 +/* from linux-2.4.25/include/asm-i386/ldt.h */
22928 +struct modify_ldt_ldt_s {
22929 +        unsigned int  entry_number;
22930 +        unsigned long base_addr;
22931 +        unsigned int  limit;
22932 +        unsigned int  seg_32bit:1;
22933 +        unsigned int  contents:2;
22934 +        unsigned int  read_exec_only:1;
22935 +        unsigned int  limit_in_pages:1;
22936 +        unsigned int  seg_not_present:1;
22937 +        unsigned int  useable:1;
22938 +};
22939 +#endif
22940 +#endif
22941 +
22942 +static int
22943 +xout_amen(struct file *fp, struct xseg *sp, int pageable, u_long *addrp,
22944 +               struct xexec *xexec, struct pt_regs *regs, int impure)
22945 +{
22946 +#if defined(XOUT_SEGMENTS)
22947 +       struct xext             *xext = (struct xext *)(xexec + 1);
22948 +       struct desc_struct      def_ldt;
22949 +       struct modify_ldt_ldt_s ldt_info;
22950 +       mm_segment_t            old_fs;
22951 +       u_long                  mirror_addr = 0;
22952 +       int                     l;
22953 +#endif
22954 +       u_long                  bss_size, bss_base;
22955 +       int                     err = 0;
22956 +
22957 +#if defined(XOUT_SEGMENTS)
22958 +       old_fs = get_fs();
22959 +
22960 +seg_again:
22961 +       l = 0;
22962 +
22963 +       /*
22964 +        * Xenix 386 segments simply map the whole address
22965 +        * space either read-exec only or read-write.
22966 +        */
22967 +       ldt_info.entry_number = sp->xs_seg >> 3;
22968 +       ldt_info.read_exec_only = 0 /* ((s->xs_attr & XS_APURE) ? 1 : 0) */;
22969 +       ldt_info.contents = ((sp->xs_type == XS_TTEXT) ? 2 : 0);
22970 +       ldt_info.seg_not_present = 0;
22971 +       ldt_info.seg_32bit = ((sp->xs_attr & XS_A32BIT) ? 1 : 0);
22972 +       if (!ldt_info.seg_32bit) {
22973 +               ldt_info.base_addr = *addrp;
22974 +               *addrp = PAGE_ALIGN(*addrp + sp->xs_vsize);
22975 +               sp->xs_rbase = ldt_info.base_addr;
22976 +       } else
22977 +               ldt_info.base_addr = 0;
22978 +#endif
22979 +
22980 +       bss_size = sp->xs_vsize - sp->xs_psize;
22981 +       bss_base = sp->xs_rbase + sp->xs_psize;
22982 +
22983 +       /*
22984 +        * If it is a text segment update the code boundary
22985 +        * markers. If it is a data segment update the data
22986 +        * boundary markers.
22987 +        */
22988 +       if (sp->xs_type == XS_TTEXT) {
22989 +               if ((sp->xs_rbase + sp->xs_psize) > current->mm->end_code)
22990 +                       current->mm->end_code = (sp->xs_rbase + sp->xs_psize);
22991 +       } else if (sp->xs_type == XS_TDATA) {
22992 +#if defined(XOUT_SEGMENTS)
22993 +               /*
22994 +                * If it is the first data segment note that
22995 +                * this is the segment we start in. If this
22996 +                * isn't a 386 binary add the stack to the
22997 +                * top of this segment.
22998 +                */
22999 +               if ((xexec->x_cpu & XC_CPU) != XC_386) {
23000 +                       if (regs->ebx == regs->ecx) {
23001 +                               regs->ecx = sp->xs_seg;
23002 +                               regs->edx = sp->xs_vsize;
23003 +                               sp->xs_vsize = 0x10000;
23004 +                               *addrp = PAGE_ALIGN(ldt_info.base_addr + sp->xs_vsize);
23005 +                       }
23006 +               } else {
23007 +                       if (regs->xds == regs->xcs)
23008 +                               regs->xds = regs->xes = regs->xss = sp->xs_seg;
23009 +               }
23010 +#endif
23011 +               if ((sp->xs_rbase + sp->xs_psize) > current->mm->end_data)
23012 +                       current->mm->end_data = (sp->xs_rbase + sp->xs_psize);
23013 +       }
23014 +
23015 +       if ((sp->xs_rbase + sp->xs_vsize) > current->mm->brk) {
23016 +               current->mm->start_brk =
23017 +                       current->mm->brk = PAGE_ALIGN(sp->xs_rbase + sp->xs_vsize);
23018 +       }
23019 +
23020 +#if defined(XOUT_SEGMENTS)
23021 +       if (ldt_info.seg_32bit) {
23022 +               ldt_info.limit = (TASK_SIZE-1) >> 12;
23023 +               ldt_info.limit_in_pages = 1;
23024 +       } else {
23025 +               ldt_info.limit = sp->xs_vsize-1;
23026 +               ldt_info.limit_in_pages = 0;
23027 +       }
23028 +
23029 +       dprintk(KERN_DEBUG "xout: ldt %02x, type=%d, base=0x%08lx, "
23030 +                       "limit=0x%08x, pages=%d, 32bit=%d\n",
23031 +                       ldt_info.entry_number, ldt_info.contents,
23032 +                       ldt_info.base_addr, ldt_info.limit,
23033 +                       ldt_info.limit_in_pages, ldt_info.seg_32bit);
23034 +
23035 +       /*
23036 +        * Use the modify_ldt syscall since this allocates
23037 +        * the initial space for the LDT table, tweaks the
23038 +        * GDT etc. We need to read the current LDT first
23039 +        * since we need to copy the lcall7 call gate.
23040 +        */
23041 +       set_fs(get_ds());
23042 +       if (!current->mm->context.size) {
23043 +               sys_modify_ldt(2, &def_ldt, sizeof(def_ldt));
23044 +
23045 +               dprintk(KERN_DEBUG
23046 +                       "x.out: def_ldt.a 0x%08lx, def_ldt.b 0x%08lx\n",
23047 +                       def_ldt.a, def_ldt.b);
23048 +
23049 +               l = 1;
23050 +       }
23051 +
23052 +       err = sys_modify_ldt(1, &ldt_info, sizeof(ldt_info));
23053 +#if 0
23054 +       if (status >= 0 && !ntext && s->xs_seg == 0x47) {
23055 +               /* Uh oh, impure binary... */
23056 +               ldt_info.entry_number = 0x3f >> 3;
23057 +#if 0
23058 +               ldt_info.read_exec_only = 1;
23059 +#else
23060 +               ldt_info.read_exec_only = 0;
23061 +#endif
23062 +               ldt_info.contents = 2;
23063 +               status = sys_modify_ldt)(1, &ldt_info, sizeof(ldt_info));
23064 +       }
23065 +#endif
23066 +       set_fs(old_fs);
23067 +       if (l == 1) {
23068 +               struct desc_struct *ldt;
23069 +
23070 +               ldt = (struct desc_struct *)current->mm->context.ldt;
23071 +               ldt->a = def_ldt.a;
23072 +               ldt->b = def_ldt.b;
23073 +
23074 +               l = 0;
23075 +       }
23076 +       if (err < 0)
23077 +               printk(KERN_INFO "xout: modify_ldt returned %d\n", err);
23078 +#endif
23079 +
23080 +       if (err < 0)
23081 +               goto out;
23082 +
23083 +       if (!pageable) {
23084 +               dprintk(KERN_DEBUG "xout: Null map 0x%08lx, length 0x%08lx\n",
23085 +                               sp->xs_rbase, sp->xs_vsize);
23086 +               down_write(&current->mm->mmap_sem);
23087 +               err = do_mmap(NULL, sp->xs_rbase, sp->xs_vsize,
23088 +                               PROT_READ|PROT_WRITE|PROT_EXEC,
23089 +                               MAP_FIXED|MAP_PRIVATE, 0);
23090 +               up_write(&current->mm->mmap_sem);
23091 +               goto out;
23092 +       }
23093 +
23094 +       dprintk(KERN_DEBUG "xout: mmap to 0x%08lx from 0x%08lx, length 0x%08lx\n",
23095 +                       sp->xs_rbase, sp->xs_filpos, sp->xs_psize);
23096 +       if (sp->xs_attr & XS_APURE) {
23097 +               down_write(&current->mm->mmap_sem);
23098 +               err = do_mmap(fp, sp->xs_rbase, sp->xs_psize,
23099 +                               PROT_READ|PROT_EXEC, MAP_FIXED|MAP_SHARED,
23100 +                               sp->xs_filpos);
23101 +               up_write(&current->mm->mmap_sem);
23102 +       } else {
23103 +               down_write(&current->mm->mmap_sem);
23104 +               err = do_mmap(fp, sp->xs_rbase, sp->xs_psize,
23105 +                               PROT_READ|PROT_WRITE|PROT_EXEC,
23106 +                               MAP_FIXED|MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
23107 +                               sp->xs_filpos);
23108 +               up_write(&current->mm->mmap_sem);
23109 +       }
23110 +
23111 +       if (err > TASK_SIZE || err < 0)
23112 +               goto out;
23113 +
23114 +       /*
23115 +        * Map uninitialised data.
23116 +        */
23117 +       if (bss_size) {
23118 +               if (bss_base & PAGE_MASK) {
23119 +                       clear_memory(bss_base, PAGE_ALIGN(bss_base)-bss_base);
23120 +                       bss_size -= (PAGE_ALIGN(bss_base) - bss_base);
23121 +                       bss_base = PAGE_ALIGN(bss_base);
23122 +               }
23123 +
23124 +               dprintk(KERN_DEBUG "xout: Null map 0x%08lx, length 0x%08lx\n",
23125 +                               bss_base, bss_size);
23126 +
23127 +               down_write(&current->mm->mmap_sem);
23128 +               err = do_mmap(NULL, bss_base, bss_size,
23129 +                               PROT_READ | PROT_WRITE | PROT_EXEC,
23130 +                               MAP_FIXED | MAP_PRIVATE, 0);
23131 +               up_write(&current->mm->mmap_sem);
23132 +       }
23133 +
23134 +out:
23135 +       if (err > TASK_SIZE)
23136 +               return -EINVAL;
23137 +#if defined(XOUT_SEGMENTS)
23138 +       if (err >= 0 && impure && sp->xs_seg >= 0x47) {
23139 +               /*
23140 +                * Uh oh, impure binary.
23141 +                * Mirror this data segment to the text segment
23142 +                */
23143 +               *addrp = mirror_addr = sp->xs_rbase;
23144 +               sp->xs_seg = xext->xe_eseg;
23145 +               sp->xs_type = XS_TTEXT;
23146 +               goto seg_again;
23147 +       }
23148 +#endif
23149 +       return (err);
23150 +}
23151 +
23152 +/*
23153 + * Helper function to process the load operation.
23154 + */
23155 +static int
23156 +xout_load_object(struct linux_binprm * bpp, struct pt_regs *rp, int executable)
23157 +{
23158 +       struct xexec                    *xexec = (struct xexec *)bpp->buf;
23159 +       struct xext                     *xext = (struct xext *)(xexec + 1);
23160 +       struct xseg                     *seglist;
23161 +       struct file                     *fp = NULL;
23162 +       u_long                          addr;
23163 +       int                             nsegs, ntext, ndata;
23164 +       int                             pageable = 1, err = 0;
23165 +       int                             i;
23166 +
23167 +       dprintk(KERN_DEBUG "xout: binfmt_xout entry: %s\n",
23168 +                       bpp->file->f_dentry->d_name.name);
23169 +
23170 +       if (xexec->x_magic != X_MAGIC) {
23171 +               dprintk(KERN_DEBUG "xout: bad magic %04x\n", xexec->x_magic);
23172 +               return -ENOEXEC;
23173 +       }
23174 +
23175 +       switch (xexec->x_cpu & XC_CPU) {
23176 +               case XC_386:
23177 +                       break;
23178 +#if defined(CONFIG_BINFMT_XOUT_X286)
23179 +               case XC_8086:
23180 +               case XC_286:
23181 +               case XC_286V:
23182 +               case XC_186:
23183 +                       break;
23184 +#endif
23185 +               default:
23186 +                       dprintk(KERN_DEBUG "xout: unsupported CPU type (%02x)\n",
23187 +                                       xexec->x_cpu);
23188 +                       return -ENOEXEC;
23189 +       }
23190 +
23191 +       /*
23192 +        * We can't handle byte or word swapped headers. Well, we
23193 +        * *could* but they should never happen surely?
23194 +        */
23195 +       if ((xexec->x_cpu & (XC_BSWAP | XC_WSWAP)) != XC_WSWAP) {
23196 +               dprintk(KERN_DEBUG "xout: wrong byte or word sex (%02x)\n",
23197 +                               xexec->x_cpu);
23198 +               return -ENOEXEC;
23199 +       }
23200 +
23201 +       /* Check it's an executable. */
23202 +       if (!(xexec->x_renv & XE_EXEC)) {
23203 +               dprintk(KERN_DEBUG "xout: not executable\n");
23204 +               return -ENOEXEC;
23205 +       }
23206 +
23207 +       /*
23208 +        * There should be an extended header and there should be
23209 +        * some segments. At this stage we don't handle non-segmented
23210 +        * binaries. I'm not sure you can get them under Xenix anyway.
23211 +        */
23212 +       if (xexec->x_ext != sizeof(struct xext)) {
23213 +               dprintk(KERN_DEBUG "xout: bad extended header\n");
23214 +               return -ENOEXEC;
23215 +       }
23216 +
23217 +       if (!(xexec->x_renv & XE_SEG) || !xext->xe_segsize) {
23218 +               dprintk(KERN_DEBUG "xout: not segmented\n");
23219 +               return -ENOEXEC;
23220 +       }
23221 +
23222 +       if (!(seglist = kmalloc(xext->xe_segsize, GFP_KERNEL))) {
23223 +               printk(KERN_WARNING "xout: allocating segment list failed\n");
23224 +               return -ENOMEM;
23225 +       }
23226 +
23227 +       err = kernel_read(bpp->file, xext->xe_segpos,
23228 +                       (char *)seglist, xext->xe_segsize);
23229 +       if (err < 0) {
23230 +               dprintk(KERN_DEBUG "xout: problem reading segment table\n");
23231 +               goto out;
23232 +       }
23233 +
23234 +       if (!bpp->file->f_op->mmap)
23235 +               pageable = 0;
23236 +
23237 +       nsegs = xext->xe_segsize / sizeof(struct xseg);
23238 +
23239 +       ntext = ndata = 0;
23240 +       for (i = 0; i < nsegs; i++) {
23241 +               switch (seglist[i].xs_type) {
23242 +                       case XS_TTEXT:
23243 +                               if (isnotaligned(seglist+i))
23244 +                                       pageable = 0;
23245 +                               ntext++;
23246 +                               break;
23247 +                       case XS_TDATA:
23248 +                               if (isnotaligned(seglist+i))
23249 +                                       pageable = 0;
23250 +                               ndata++;
23251 +                               break;
23252 +               }
23253 +       }
23254 +
23255 +       if (!ndata)
23256 +               goto out;
23257 +
23258 +       /*
23259 +        * Generate the proper values for the text fields
23260 +        *
23261 +        * THIS IS THE POINT OF NO RETURN. THE NEW PROCESS WILL TRAP OUT SHOULD
23262 +        * SOMETHING FAIL IN THE LOAD SEQUENCE FROM THIS POINT ONWARD.
23263 +        */
23264 +
23265 +       /*
23266 +        *  Flush the executable from memory. At this point the executable is
23267 +        *  committed to being defined or a segmentation violation will occur.
23268 +        */
23269 +       if (executable) {
23270 +               dprintk(KERN_DEBUG "xout: flushing executable\n");
23271 +
23272 +               flush_old_exec(bpp);
23273 +
23274 +               current->mm->mmap        = NULL;
23275 +               atomic_long_set(&current->mm->_file_rss, 0);
23276 +
23277 +               if ((err = setup_arg_pages(bpp, STACK_TOP, EXSTACK_DEFAULT)) < 0) {
23278 +                       send_sig(SIGSEGV, current, 1);
23279 +                       return (err);
23280 +               }
23281 +
23282 +               bpp->p = (u_long)xout_create_tables((char *)bpp->p, bpp,
23283 +                               (xexec->x_cpu & XC_CPU) == XC_386 ? 1 : 0);
23284 +
23285 +#if defined(XOUT_SEGMENTS)
23286 +               /*
23287 +                * These will be set up later once we've seen the
23288 +                * segments that make the program up.
23289 +                */
23290 +               current->mm->start_code  = 0;
23291 +               current->mm->start_data  = 0;
23292 +               current->mm->end_code    = 0;
23293 +               current->mm->end_data    = 0;
23294 +               current->mm->start_brk   = 0;
23295 +               current->mm->brk         = 0;
23296 +
23297 +               compute_creds(bpp);
23298 +               current->flags &= ~PF_FORKNOEXEC;
23299 +
23300 +               /*
23301 +                * The code selector is advertised in the header.
23302 +                */
23303 +               if ((xexec->x_cpu & XC_CPU) != XC_386) {
23304 +                       rp->ebx = rp->ecx = xext->xe_eseg;
23305 +                       rp->eax = xexec->x_entry;
23306 +               } else {
23307 +                       rp->xcs = rp->xds = rp->xes = rp->xss = xext->xe_eseg;
23308 +                       rp->eip = xexec->x_entry;
23309 +               }
23310 +#else /* XOUT_SEGMENTS */
23311 +               current->mm->start_code  = 0;
23312 +               current->mm->end_code    = xexec->x_text;
23313 +               current->mm->end_data    = xexec->x_text + xexec->x_data;
23314 +               current->mm->start_brk   =
23315 +               current->mm->brk         = xexec->x_text + xexec->x_data + xexec->x_bss;
23316 +
23317 +               compute_creds(bpp);
23318 +               current->flags &= ~PF_FORKNOEXEC;
23319 +
23320 +               rp->xcs = __USER_CS;
23321 +               rp->xds = rp->xes = rp->xss = __USER_DS;
23322 +               rp->eip = xexec->x_entry;
23323 +#endif /* XOUT_SEGMENTS */
23324 +
23325 +               dprintk(KERN_DEBUG "xout: entry point = 0x%x:0x%08lx\n",
23326 +                               xext->xe_eseg, xexec->x_entry);
23327 +
23328 +               rp->esp = current->mm->start_stack = bpp->p;
23329 +
23330 +               set_personality(PER_XENIX);
23331 +       }
23332 +
23333 +       /*
23334 +        * Base address for mapping 16bit segments. This should lie above
23335 +        * the emulator overlay.
23336 +        */
23337 +       addr = X286_MAP_ADDR;
23338 +
23339 +#if defined(CONFIG_BINFMT_XOUT_X286)
23340 +       /*
23341 +        * If this isn't a 386 executable we need to load the overlay
23342 +        * library to emulate a [2]86 environment and save the binary
23343 +        * headers for later reference by the emulator.
23344 +        */
23345 +       if ((xexec->x_cpu & XC_CPU) != XC_386) {
23346 +               mm_segment_t fs = get_fs();
23347 +
23348 +               set_fs(get_ds());
23349 +               err = sys_uselib(_PATH_X286EMUL);
23350 +               set_fs(fs);
23351 +               if (err < 0) {
23352 +                       printk(KERN_ERR
23353 +                           "xout: loading of %s failed with error %d\n",
23354 +                           _PATH_X286EMUL, err);
23355 +                       goto out;
23356 +               }
23357 +
23358 +               down_write(&current->mm->mmap_sem);
23359 +               err = do_mmap(NULL,
23360 +                       addr, sizeof(struct xexec)+sizeof(struct xext),
23361 +                       PROT_READ|PROT_WRITE|PROT_EXEC,
23362 +                       MAP_FIXED|MAP_PRIVATE,
23363 +                       0);
23364 +               up_write(&current->mm->mmap_sem);
23365 +
23366 +               if (err > TASK_SIZE)
23367 +                       goto Einval;
23368 +               if (err >= 0) {
23369 +                       if (copy_to_user((char *)addr, xexec, sizeof(struct xexec)))
23370 +                       {       err = -EFAULT;
23371 +                               goto out;
23372 +                       }
23373 +                       if (copy_to_user((char *)addr+sizeof(struct xexec), xext, sizeof(struct xext)))
23374 +                       {       err = -EFAULT;
23375 +                               goto out;
23376 +                       }
23377 +                       addr = PAGE_ALIGN(addr+sizeof(struct xexec)+sizeof(struct xext));
23378 +               }
23379 +       }
23380 +#endif
23381 +
23382 +       /*
23383 +        * Scan the segments and map them into the process space. If this
23384 +        * executable is pageable (unlikely since Xenix aligns to 1k
23385 +        * boundaries and we want it aligned to 4k boundaries) this is
23386 +        * all we need to do. If it isn't pageable we go round again
23387 +        * afterwards and load the data. We have to do this in two steps
23388 +        * because if segments overlap within a 4K page we'll lose the
23389 +        * first instance when we remap the page. Hope that's clear...
23390 +        */
23391 +       for (i = 0; err >= 0 && i < nsegs; i++) {
23392 +               struct xseg             *sp = seglist+i;
23393 +
23394 +               if (sp->xs_attr & XS_AMEM) {
23395 +                       err = xout_amen(fp, sp, pageable, &addr,
23396 +                               xexec, rp, (!ntext && ndata == 1));
23397 +               }
23398 +
23399 +       }
23400 +
23401 +       /*
23402 +        * We better fix start_data because sys_brk looks there to
23403 +        * calculate data size.
23404 +        * Kernel 2.2 did look at end_code so this is reasonable.
23405 +        */
23406 +       if (current->mm->start_data == current->mm->start_code)
23407 +               current->mm->start_data = current->mm->end_code;
23408 +
23409 +       dprintk(KERN_DEBUG "xout: start code 0x%08lx, end code 0x%08lx,"
23410 +           " start data 0x%08lx, end data 0x%08lx, brk 0x%08lx\n",
23411 +           current->mm->start_code, current->mm->end_code,
23412 +           current->mm->start_data, current->mm->end_data,
23413 +           current->mm->brk);
23414 +
23415 +#if defined(XOUT_DEBUG) && defined(XOUT_SEGMENTS)
23416 +       print_desc(1);
23417 +       print_desc(0);
23418 +#endif
23419 +
23420 +       if (pageable)
23421 +               goto trap;
23422 +       if (err < 0)
23423 +               goto trap;
23424 +
23425 +       for (i = 0; (err >= 0) && (i < nsegs); i++) {
23426 +               struct xseg             *sp = seglist + i;
23427 +               u_long                  psize;
23428 +
23429 +               if (sp->xs_type == XS_TTEXT || sp->xs_type == XS_TDATA) {
23430 +                       dprintk(KERN_DEBUG "xout: read to 0x%08lx from 0x%08lx,"
23431 +                                       " length 0x%08lx\n", sp->xs_rbase,
23432 +                                       sp->xs_filpos, sp->xs_psize);
23433 +
23434 +                       if (sp->xs_psize < 0)
23435 +                               continue;
23436 +
23437 +                       /*
23438 +                        * Do we still get the size ? Yes! [joerg]
23439 +                        */
23440 +                       psize = kernel_read(bpp->file, sp->xs_filpos,
23441 +                                       (char *)sp->xs_rbase, sp->xs_psize);
23442 +
23443 +                       if (psize != sp->xs_psize) {
23444 +                               dprintk(KERN_DEBUG "xout: short read\n");
23445 +                               err = -1;
23446 +                               break;
23447 +                       }
23448 +               }
23449 +       }
23450 +
23451 +       /*
23452 +        * Generate any needed trap for this process. If an error occured then
23453 +        * generate a segmentation violation. If the process is being debugged
23454 +        * then generate the load trap. (Note: If this is a library load then
23455 +        * do not generate the trap here. Pass the error to the caller who
23456 +        * will do it for the process in the outer lay of this procedure call.)
23457 +        */
23458 +trap:
23459 +       if (executable) {
23460 +               if (err < 0) {
23461 +                       dprintk(KERN_DEBUG "xout: loader forces seg fault "
23462 +                                       "(err = %d)\n", err);
23463 +                       send_sig(SIGSEGV, current, 0);
23464 +               } else if (current->ptrace & PT_PTRACED)
23465 +                       send_sig(SIGTRAP, current, 0);
23466 +               err = 0;
23467 +       }
23468 +
23469 +out:
23470 +       kfree(seglist);
23471 +
23472 +       dprintk(KERN_DEBUG "xout: binfmt_xout: result = %d\n", err);
23473 +
23474 +       /*
23475 +        * If we are using the [2]86 emulation overlay we enter this
23476 +        * rather than the real program and give it the information
23477 +        * it needs to start the ball rolling.
23478 +        */
23479 +       if ((xexec->x_cpu & XC_CPU) != XC_386) {
23480 +#if 0
23481 +               regs->eax = regs->eip;
23482 +               regs->ebx = regs->xcs;
23483 +               regs->ecx = regs->xds;
23484 +               regs->xcs = __USER_CS;
23485 +               regs->xds = regs->xes = regs->xss = __USER_DS;
23486 +#endif
23487 +               rp->eip = 0x1020;
23488 +               dprintk(KERN_DEBUG "xout: x286emul 0x%02lx:0x%04lx,"
23489 +                               " ds=0x%02lx, stack 0x%02lx:0x%04lx\n",
23490 +                               rp->ebx, rp->eax, rp->ecx, rp->ecx,
23491 +                               rp->edx);
23492 +#ifdef notdef
23493 +               while (!signal_pending(current))
23494 +                       schedule();
23495 +#endif
23496 +               return (err < 0 ? err : rp->eax);
23497 +       }
23498 +
23499 +#ifdef notdef
23500 +       while (!signal_pending(current))
23501 +               schedule();
23502 +#endif
23503 +       /*
23504 +        * Xenix 386 programs expect the initial brk value to be in eax
23505 +        * on start up. Hence if we succeeded we need to pass back
23506 +        * the brk value rather than the status. Ultimately the
23507 +        * ret_from_sys_call assembly will place this in eax before
23508 +        * resuming (starting) the process.
23509 +        */
23510 +       return (err < 0 ? err : current->mm->brk);
23511 +
23512 +#if defined(CONFIG_BINFMT_XOUT_X286)
23513 +Einval:
23514 +       kfree(seglist);
23515 +       return -EINVAL;
23516 +#endif
23517 +}
23518 +
23519 +
23520 +/*
23521 + *  This procedure is called by the main load sequence. It will load
23522 + *  the executable and prepare it for execution. It provides the additional
23523 + *  parameters used by the recursive xout loader and tells the loader that
23524 + *  this is the main executable. How simple it is . . . .
23525 + */
23526 +static int
23527 +xout_load_binary(struct linux_binprm *bpp, struct pt_regs *rp)
23528 +{
23529 +       return (xout_load_object(bpp, rp, 1));
23530 +}
23531 +
23532 +/*
23533 + * Load the image for any shared library.  This is called when
23534 + * we need to load a library based upon a file name.
23535 + *
23536 + * XXX: I have never seen a Xenix shared library...  --hch
23537 + */
23538 +static int
23539 +xout_load_library(struct file *fp)
23540 +{
23541 +       struct linux_binprm             *bpp;
23542 +       struct pt_regs                  regs;
23543 +       int                             err = -ENOMEM;
23544 +
23545 +       if (!(bpp = kmalloc(sizeof(struct linux_binprm), GFP_KERNEL))) {
23546 +               printk(KERN_WARNING "xout: kmalloc failed\n");
23547 +               goto out;
23548 +       }
23549 +
23550 +       memset(bpp, 0, sizeof(struct linux_binprm));
23551 +       bpp->file = fp;
23552 +
23553 +       if ((err = kernel_read(fp, 0L, bpp->buf, sizeof(bpp->buf))) < 0)
23554 +               printk(KERN_WARNING "xout: unable to read library header\n");
23555 +       else
23556 +               err = xout_load_object(bpp, &regs, 0);
23557 +
23558 +       kfree(bpp);
23559 +out:
23560 +       return (err);
23561 +}
23562 +
23563 +static int __init
23564 +binfmt_xout_init(void)
23565 +{
23566 +       return register_binfmt(&xout_format);
23567 +}
23568 +
23569 +static void __exit
23570 +binfmt_xout_exit(void)
23571 +{
23572 +       unregister_binfmt(&xout_format);
23573 +}
23574 +
23575 +module_init(binfmt_xout_init);
23576 +module_exit(binfmt_xout_exit);
23577 diff -Nur kernel-source-2.6.16.orig/fs/exec.c kernel-source-2.6.16/fs/exec.c
23578 --- kernel-source-2.6.16.orig/fs/exec.c 2006-04-27 18:30:01.000000000 +1000
23579 +++ kernel-source-2.6.16/fs/exec.c      2006-04-27 18:50:24.000000000 +1000
23580 @@ -1240,6 +1240,8 @@
23581         return retval;
23582  }
23583  
23584 +EXPORT_SYMBOL(do_execve);
23585 +
23586  int set_binfmt(struct linux_binfmt *new)
23587  {
23588         struct linux_binfmt *old = current->binfmt;
23589 diff -Nur kernel-source-2.6.16.orig/fs/Kconfig.binfmt kernel-source-2.6.16/fs/Kconfig.binfmt
23590 --- kernel-source-2.6.16.orig/fs/Kconfig.binfmt 2006-03-20 15:53:29.000000000 +1000
23591 +++ kernel-source-2.6.16/fs/Kconfig.binfmt      2006-04-27 18:50:24.000000000 +1000
23592 @@ -132,3 +132,5 @@
23593           You may say M here for module support and later load the module when
23594           you have use for it; the module is called binfmt_misc. If you
23595           don't know what to answer at this point, say Y.
23596 +
23597 +source "abi/Kconfig"
23598 diff -Nur kernel-source-2.6.16.orig/fs/Makefile kernel-source-2.6.16/fs/Makefile
23599 --- kernel-source-2.6.16.orig/fs/Makefile       2006-04-27 18:16:04.000000000 +1000
23600 +++ kernel-source-2.6.16/fs/Makefile    2006-04-27 18:50:24.000000000 +1000
23601 @@ -20,6 +20,8 @@
23602  obj-y                          += $(nfsd-y) $(nfsd-m)
23603  
23604  obj-$(CONFIG_BINFMT_AOUT)      += binfmt_aout.o
23605 +obj-$(CONFIG_BINFMT_XOUT)      += binfmt_xout.o
23606 +obj-$(CONFIG_BINFMT_COFF)      += binfmt_coff.o
23607  obj-$(CONFIG_BINFMT_EM86)      += binfmt_em86.o
23608  obj-$(CONFIG_BINFMT_MISC)      += binfmt_misc.o
23609  
23610 diff -Nur kernel-source-2.6.16.orig/fs/pipe.c kernel-source-2.6.16/fs/pipe.c
23611 --- kernel-source-2.6.16.orig/fs/pipe.c 2006-03-20 15:53:29.000000000 +1000
23612 +++ kernel-source-2.6.16/fs/pipe.c      2006-04-27 18:50:24.000000000 +1000
23613 @@ -838,3 +838,9 @@
23614  
23615  fs_initcall(init_pipe_fs);
23616  module_exit(exit_pipe_fs);
23617 +
23618 +/* symbol exports for LinuxABI Sytem V R4 support */                          
23619 +/* for ease of use we are exporting those needed symbols permanently */       
23620 +/* #if CONFIG_ABI_SVR4 == m */                                                
23621 +EXPORT_SYMBOL(do_pipe);                                                       
23622 +/* #endif */
23623 diff -Nur kernel-source-2.6.16.orig/fs/readdir.c kernel-source-2.6.16/fs/readdir.c
23624 --- kernel-source-2.6.16.orig/fs/readdir.c      2006-03-20 15:53:29.000000000 +1000
23625 +++ kernel-source-2.6.16/fs/readdir.c   2006-04-27 18:50:24.000000000 +1000
23626 @@ -56,13 +56,6 @@
23627  
23628  #ifdef __ARCH_WANT_OLD_READDIR
23629  
23630 -struct old_linux_dirent {
23631 -       unsigned long   d_ino;
23632 -       unsigned long   d_offset;
23633 -       unsigned short  d_namlen;
23634 -       char            d_name[1];
23635 -};
23636 -
23637  struct readdir_callback {
23638         struct old_linux_dirent __user * dirent;
23639         int result;
23640 diff -Nur kernel-source-2.6.16.orig/include/abi/cxenix/signal.h kernel-source-2.6.16/include/abi/cxenix/signal.h
23641 --- kernel-source-2.6.16.orig/include/abi/cxenix/signal.h       1970-01-01 10:00:00.000000000 +1000
23642 +++ kernel-source-2.6.16/include/abi/cxenix/signal.h    2006-04-27 18:50:24.000000000 +1000
23643 @@ -0,0 +1,16 @@
23644 +#ifndef _ABI_CXENIX_SIGNAL_H
23645 +#define _ABI_CXENIX_SIGNAL_H
23646 +
23647 +enum {
23648 +       SCO_SA_NOCLDSTOP =      0x001,
23649 +       SCO_SA_COMPAT =         0x080, /* 3.2.2 compatibilty. */
23650 +       SCO_SA_SIGNAL =         0x100,
23651 +};
23652 +
23653 +struct sco_sigaction {
23654 +       void            (*sa_handler)(int);
23655 +       unsigned long   sa_mask;
23656 +       int             sa_flags;
23657 +};
23658 +
23659 +#endif /* _ABI_CXENIX_SIGNAL_H */
23660 diff -Nur kernel-source-2.6.16.orig/include/abi/cxenix/sysent.h kernel-source-2.6.16/include/abi/cxenix/sysent.h
23661 --- kernel-source-2.6.16.orig/include/abi/cxenix/sysent.h       1970-01-01 10:00:00.000000000 +1000
23662 +++ kernel-source-2.6.16/include/abi/cxenix/sysent.h    2006-04-27 18:50:24.000000000 +1000
23663 @@ -0,0 +1,47 @@
23664 +/*
23665 + *   include/abi/xnx.h -- xenix ibcs interface
23666 + *
23667 + * Copyright (C) 1993  Drew Sullivan
23668 + * Released for general use as long as this copyright remains.
23669 + */
23670 +
23671 +#ident "%W% %G%"
23672 +
23673 +struct sco_sigaction;
23674 +struct timeb;
23675 +
23676 +typedef unsigned short excode_t;
23677 +
23678 +extern int xnx_locking(int fd, int mode, unsigned long size);
23679 +extern int xnx_creatsem(char *sem_name, int mode);
23680 +extern int xnx_opensem(char *sem_name);
23681 +extern int xnx_sigsem(int sem_num);
23682 +extern int xnx_waitsem(int sem_num);
23683 +extern int xnx_nbwaitsem(int sem_num);
23684 +extern int xnx_rdchk(int fd);
23685 +extern int xnx_ftime(struct timeb * tp);
23686 +extern int xnx_nap(long period);
23687 +extern int xnx_sdget(char *path, int flags, long size, int mode);
23688 +extern int xnx_sdfree(char* addr);
23689 +extern int xnx_sdenter(char *addr, int flags);
23690 +extern int xnx_sdleave(char *addr);
23691 +extern int xnx_sdgetv(char *addr);
23692 +extern int xnx_sdwaitv(char *addr, int vnum);
23693 +extern int xnx_proctl(int pid, int command, char *arg);
23694 +extern int xnx_execseg(excode_t oldaddr, unsigned size);
23695 +extern int xnx_unexecseg(excode_t addr);
23696 +extern int xnx_eaccess(char *path, int mode);
23697 +extern int xnx_paccess(int pid, int cmd, int offset, int count, char *ptr);
23698 +extern int xnx_sigpending(unsigned long *set);
23699 +extern int xnx_pathconf(char *path, int name);
23700 +extern int xnx_fpathconf(int fildes, int name);
23701 +
23702 +/* signal.c */
23703 +extern int     xnx_sigaction(int, const struct sco_sigaction *,
23704 +                       struct sco_sigaction *);
23705 +
23706 +/* utsname.c */
23707 +extern int     xnx_utsname(u_long addr);
23708 +
23709 +/* sysent.h */
23710 +extern void     cxenix(struct pt_regs *);
23711 diff -Nur kernel-source-2.6.16.orig/include/abi/ioctl.h kernel-source-2.6.16/include/abi/ioctl.h
23712 --- kernel-source-2.6.16.orig/include/abi/ioctl.h       1970-01-01 10:00:00.000000000 +1000
23713 +++ kernel-source-2.6.16/include/abi/ioctl.h    2006-04-27 18:50:24.000000000 +1000
23714 @@ -0,0 +1,43 @@
23715 +/*
23716 + * Copyright (C) 1994  Mike Jagdis (jaggy@purplet.demon.co.uk)
23717 + * Copyright (C) 2001  Caldera Deutschland GmbH
23718 + */
23719 +#ifndef _ABI_IOCTL_H
23720 +#define _ABI_IOCTL_H
23721 +
23722 +#ident "%W% %G%"
23723 +
23724 +/*
23725 + * Ioctl's have the command encoded in the lower word, and the size of
23726 + * any in or out parameters in the upper word.  The high 3 bits of the
23727 + * upper word are used to encode the in/out status of the parameter.
23728 + *
23729 + * Note that Linux does the same but has the IOC_IN and IOC_OUT values
23730 + * round the other way and uses 0 for IOC_VOID.
23731 + */
23732 +enum {
23733 +       /* parameter length, at most 13 bits */
23734 +       BSD_IOCPARM_MASK        = 0x1fff,
23735 +       /* no parameters */
23736 +       BSD_IOC_VOID            = 0x20000000,
23737 +       /* copy out parameters */
23738 +       BSD_IOC_OUT             = 0x40000000,
23739 +       /* copy in parameters */
23740 +       BSD_IOC_IN              = 0x80000000,
23741 +       /* possibly copy in and out parameters */
23742 +       BSD_IOC_INOUT           = BSD_IOC_IN|BSD_IOC_OUT,
23743 +};
23744 +
23745 +
23746 +#define BSD__IOC(inout,group,num,len) \
23747 +       (inout | ((len & BSD_IOCPARM_MASK) << 16) | ((group) << 8) | (num))
23748 +
23749 +#define        BSD__IO(g,n)            BSD__IOC(BSD_IOC_VOID, (g), (n), 0)
23750 +#define        BSD__IOR(g,n,t)         BSD__IOC(BSD_IOC_OUT, (g), (n), sizeof(t))
23751 +#define        BSD__IOW(g,n,t)         BSD__IOC(BSD_IOC_IN, (g), (n), sizeof(t))
23752 +#define        BSD__IOWR(g,n,t)        BSD__IOC(BSD_IOC_INOUT, (g), (n), sizeof(t))
23753 +
23754 +/* Some SYSV systems exhibit "compatible" BSD ioctls without the bumf. */
23755 +#define BSD__IOV(c,d)  (((c) << 8) | (d))
23756 +
23757 +#endif /* _ABI_IOCTL_H */
23758 diff -Nur kernel-source-2.6.16.orig/include/abi/sco/ioctl.h kernel-source-2.6.16/include/abi/sco/ioctl.h
23759 --- kernel-source-2.6.16.orig/include/abi/sco/ioctl.h   1970-01-01 10:00:00.000000000 +1000
23760 +++ kernel-source-2.6.16/include/abi/sco/ioctl.h        2006-04-27 18:50:24.000000000 +1000
23761 @@ -0,0 +1,13 @@
23762 +#ifndef _ABI_SCO_IOCTL_H
23763 +#define _ABI_SCO_IOCTL_H
23764 +
23765 +/* tapeio.c */
23766 +extern int     sco_tape_ioctl(int, u_int, caddr_t);
23767 +
23768 +/* termios.c */
23769 +extern int     sco_term_ioctl(int, u_int, caddr_t);
23770 +
23771 +/* From vtkd.c */
23772 +extern int     sco_vtkbd_ioctl(int, u_int, caddr_t);
23773 +
23774 +#endif /* _ABI_SCO_IOCTL_H */
23775 diff -Nur kernel-source-2.6.16.orig/include/abi/sco/mman.h kernel-source-2.6.16/include/abi/sco/mman.h
23776 --- kernel-source-2.6.16.orig/include/abi/sco/mman.h    1970-01-01 10:00:00.000000000 +1000
23777 +++ kernel-source-2.6.16/include/abi/sco/mman.h 2006-04-27 18:50:24.000000000 +1000
23778 @@ -0,0 +1,66 @@
23779 +/*
23780 + * Copyright (c) 2001 Caldera Deutschland GmbH.
23781 + * All rights reserved.
23782 + *
23783 + * This program is free software; you can redistribute it and/or modify
23784 + * it under the terms of the GNU General Public License as published by
23785 + * the Free Software Foundation; either version 2 of the License, or
23786 + * (at your option) any later version.
23787 + *
23788 + * This program is distributed in the hope that it will be useful,
23789 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
23790 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23791 + * GNU General Public License for more details.
23792 + *
23793 + * You should have received a copy of the GNU General Public License
23794 + * along with this program; if not, write to the Free Software
23795 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23796 + */
23797 +#ifndef _ABI_SCO_MMAN_H
23798 +#define _ABI_SCO_MMAN_H
23799 +
23800 +#ident "%W% %G%"
23801 +
23802 +/*
23803 + * SCO OpenServer memory mapped files declarations
23804 + */
23805 +
23806 +#define SCO_MAP_FAILED         ((void *)-1)
23807 +
23808 +/* protections flags for mmap() and mprotect() */
23809 +#define SCO_PROT_NONE          0x0000
23810 +#define SCO_PROT_READ          0x0001
23811 +#define SCO_PROT_WRITE         0x0002
23812 +#define SCO_PROT_EXEC          0x0004
23813 +
23814 +/* sharing types for mmap() */
23815 +#define SCO_MAP_SHARED         0x0001
23816 +#define SCO_MAP_PRIVATE                0x0002
23817 +#define SCO_MAP_FIXED          0x0010
23818 +#define SCO_MAP_PHMEM          0x1000
23819 +#define SCO_MAP_KVMEM          0x2000
23820 +#define SCO_MAP_ANCESTRAL      0x4000
23821 +#define SCO_MAP_NOEOF          0x8000
23822 +
23823 +#define SCO_MAP_UNIMPL \
23824 +       (SCO_MAP_PHMEM|SCO_MAP_KVMEM|SCO_MAP_ANCESTRAL|SCO_MAP_NOEOF)
23825 +
23826 +/* memcntl() subfunctions */
23827 +#define SCO_MC_SYNC            0x0001
23828 +#define SCO_MC_LOCK            0x0002
23829 +#define SCO_MC_UNLOCK          0x0003
23830 +#define SCO_MC_LOCKAS          0x0005
23831 +#define SCO_MC_UNLOCKAS                0x0006
23832 +#define SCO_MC_MAPCPU          0x8000
23833 +#define SCO_MC_MAPUBLK         0x8001
23834 +
23835 +/* msync() flags */
23836 +#define SCO_MS_SYNC            0x0000
23837 +#define SCO_MS_ASYNC           0x0001
23838 +#define SCO_MS_INVALIDATE      0x0002
23839 +
23840 +/* mlockall() flags */
23841 +#define SCO_MCL_CURRENT                0x0001
23842 +#define SCO_MCL_FUTURE         0x0002
23843 +
23844 +#endif /* _ABI_SCO_MMAN_H */
23845 diff -Nur kernel-source-2.6.16.orig/include/abi/sco/signal.h kernel-source-2.6.16/include/abi/sco/signal.h
23846 --- kernel-source-2.6.16.orig/include/abi/sco/signal.h  1970-01-01 10:00:00.000000000 +1000
23847 +++ kernel-source-2.6.16/include/abi/sco/signal.h       2006-04-27 18:50:24.000000000 +1000
23848 @@ -0,0 +1,43 @@
23849 +#ifndef _ABI_SCO_SIGNAL_H
23850 +#define _ABI_SCO_SIGNAL_H
23851 +
23852 +/*
23853 + * Signal numbers for the SCO emulator.
23854 + */
23855 +
23856 +#ident "%W% %G%"
23857 +
23858 +#define SCO_SIGHUP  1          /* hangup */
23859 +#define SCO_SIGINT  2          /* interrupt (rubout) */
23860 +#define SCO_SIGQUIT 3          /* quit (ASCII FS) */
23861 +#define SCO_SIGILL  4          /* illegal instruction (not reset when caught) */
23862 +#define SCO_SIGTRAP 5          /* trace trap (not reset when caught) */
23863 +#define SCO_SIGIOT  6          /* IOT instruction */
23864 +#define SCO_SIGABRT 6          /* used by abort, replace SIGIOT in the future */
23865 +#define SCO_SIGEMT  7          /* EMT instruction */
23866 +#define SCO_SIGFPE  8          /* floating point exception */
23867 +#define SCO_SIGKILL 9          /* kill (cannot be caught or ignored) */
23868 +#define SCO_SIGBUS  10         /* bus error */
23869 +#define SCO_SIGSEGV 11         /* segmentation violation */
23870 +#define SCO_SIGSYS  12         /* bad argument to system call */
23871 +#define SCO_SIGPIPE 13         /* write on a pipe with no one to read it */
23872 +#define SCO_SIGALRM 14         /* alarm clock */
23873 +#define SCO_SIGTERM 15         /* software termination signal from kill */
23874 +#define SCO_SIGUSR1 16         /* user defined signal 1 */
23875 +#define SCO_SIGUSR2 17         /* user defined signal 2 */
23876 +#define SCO_SIGCLD  18         /* death of a child */
23877 +#define SCO_SIGPWR  19         /* power-fail restart */
23878 +#define SCO_SIGWINCH 20                /* window change */
23879 +#define SCO_SIGURG  21         /* urgent socket condition */
23880 +#define SCO_SIGPOLL 22         /* pollable event occurred */
23881 +#define SCO_SIGSTOP 23         /* sendable stop signal not from tty */
23882 +#define SCO_SIGTSTP 24         /* stop signal from tty */
23883 +#define SCO_SIGCONT 25         /* continue a stopped process */
23884 +#define SCO_SIGTTIN 26         /* to readers pgrp upon background tty read */
23885 +#define SCO_SIGTTOU 27         /* like TTIN for output if tp->t_local&TOSTOP */
23886 +#define SCO_SIGVTALRM 28       /* virtual timer alarm */
23887 +#define SCO_SIGPROF 29         /* profile alarm */
23888 +#define SCO_SIGXCPU 30         /* CPU time limit exceeded */
23889 +#define SCO_SIGXFSZ 31         /* File size limit exceeded */
23890 +
23891 +#endif /* _ABI_SCO_SIGNAL_H */
23892 diff -Nur kernel-source-2.6.16.orig/include/abi/sco/stat.h kernel-source-2.6.16/include/abi/sco/stat.h
23893 --- kernel-source-2.6.16.orig/include/abi/sco/stat.h    1970-01-01 10:00:00.000000000 +1000
23894 +++ kernel-source-2.6.16/include/abi/sco/stat.h 2006-04-27 18:50:24.000000000 +1000
23895 @@ -0,0 +1,31 @@
23896 +#ifndef _ABI_SCO_STAT_H
23897 +#define _ABI_SCO_STAT_H
23898 +
23899 +#ident "%W% %G%"
23900 +
23901 +#include <abi/sco/types.h>
23902 +
23903 +
23904 +struct sco_xstat {
23905 +       sco_dev_t       st_dev;
23906 +       u_int32_t       __pad1[3];
23907 +       sco_ino_t       st_ino;
23908 +       sco_mode_t      st_mode;
23909 +       sco_nlink_t     st_nlink;
23910 +       sco_uid_t       st_uid;
23911 +       sco_gid_t       st_gid;
23912 +       sco_dev_t       st_rdev;
23913 +       u_int32_t       __pad2[2];
23914 +       sco_off_t       st_size;
23915 +       u_int32_t       __pad3;
23916 +       sco_time_t      st_atime;
23917 +       sco_time_t      st_mtime;
23918 +       sco_time_t      st_ctime;
23919 +       int32_t         st_blksize;
23920 +       int32_t         st_blocks;
23921 +       char            st_fstype[16];
23922 +       u_int32_t       __pad4[7];
23923 +       int32_t         st_sco_flags;
23924 +};
23925 +
23926 +#endif /* _ABI_SCO_STAT_H */
23927 diff -Nur kernel-source-2.6.16.orig/include/abi/sco/sysent.h kernel-source-2.6.16/include/abi/sco/sysent.h
23928 --- kernel-source-2.6.16.orig/include/abi/sco/sysent.h  1970-01-01 10:00:00.000000000 +1000
23929 +++ kernel-source-2.6.16/include/abi/sco/sysent.h       2006-04-27 18:50:24.000000000 +1000
23930 @@ -0,0 +1,59 @@
23931 +/*
23932 + * Copyright (c) 2001 Christoph Hellwig.
23933 + * All rights reserved.
23934 + *
23935 + * This program is free software; you can redistribute it and/or modify
23936 + * it under the terms of the GNU General Public License as published by
23937 + * the Free Software Foundation; either version 2 of the License, or
23938 + * (at your option) any later version.
23939 + *
23940 + * This program is distributed in the hope that it will be useful,
23941 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
23942 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23943 + * GNU General Public License for more details.
23944 + *
23945 + * You should have received a copy of the GNU General Public License
23946 + * along with this program; if not, write to the Free Software
23947 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23948 + */
23949 +#ifndef _ABI_SCO_SYSENT_H
23950 +#define _ABI_SCO_SYSENT_H
23951 +
23952 +#ident "%W% %G%"
23953 +
23954 +/*
23955 + * External function declarations for the SCO OpenServer syscall table.
23956 + */
23957 +
23958 +#include <abi/sco/types.h>
23959 +
23960 +struct sco_statvfs;
23961 +
23962 +
23963 +/* ioctl.c */
23964 +extern int     sco_ioctl(struct pt_regs *);
23965 +
23966 +/* misc.c */
23967 +extern int     sco_lseek(int, u_long, int);
23968 +extern int     sco_fcntl(int, u_int, u_long);
23969 +extern int     sco_sysi86(int, void *, int);
23970 +
23971 +/* mmap.c */
23972 +extern int     sco_mmap(u_long, size_t, int, int, int, sco_off_t);
23973 +
23974 +/* ptrace.c */
23975 +extern int     sco_ptrace(int, int, u_long, u_long);
23976 +
23977 +/* secureware.c */
23978 +extern int     sw_security(int, void *, void *, void *, void *, void *);
23979 +
23980 +/* stat.c */
23981 +extern int     sco_xstat(int, char *, void *);
23982 +extern int     sco_lxstat(int, char *, void *);
23983 +extern int     sco_fxstat(int, int, void *);
23984 +
23985 +/* statvfs.c */
23986 +extern int     sco_statvfs(char *, struct sco_statvfs *);
23987 +extern int     sco_fstatvfs(int, struct sco_statvfs *);
23988 +
23989 +#endif /* _ABI_SCO_SYSENT_H */
23990 diff -Nur kernel-source-2.6.16.orig/include/abi/sco/types.h kernel-source-2.6.16/include/abi/sco/types.h
23991 --- kernel-source-2.6.16.orig/include/abi/sco/types.h   1970-01-01 10:00:00.000000000 +1000
23992 +++ kernel-source-2.6.16/include/abi/sco/types.h        2006-04-27 18:50:24.000000000 +1000
23993 @@ -0,0 +1,105 @@
23994 +/*
23995 + * Copyright (c) 2001 Caldera Deutschland GmbH.
23996 + * Copyright (c) 2001 Christoph Hellwig.
23997 + * All rights reserved.
23998 + *
23999 + * This program is free software; you can redistribute it and/or modify
24000 + * it under the terms of the GNU General Public License as published by
24001 + * the Free Software Foundation; either version 2 of the License, or
24002 + * (at your option) any later version.
24003 + *
24004 + * This program is distributed in the hope that it will be useful,
24005 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
24006 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24007 + * GNU General Public License for more details.
24008 + *
24009 + * You should have received a copy of the GNU General Public License
24010 + * along with this program; if not, write to the Free Software
24011 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24012 + */
24013 +#ifndef _ABI_SCO_TYPES_H
24014 +#define _ABI_SCO_TYPES_H
24015 +
24016 +#ident "%W% %G%"
24017 +
24018 +/*
24019 + * SCO OpenServer type declarations.
24020 + */
24021 +#include <linux/highuid.h>
24022 +#include <linux/personality.h>
24023 +#include <linux/sched.h>
24024 +#include <linux/types.h>
24025 +
24026 +
24027 +typedef int16_t                sco_dev_t;
24028 +typedef u_int32_t      sco_ino_t;
24029 +typedef u_int16_t      sco_mode_t;
24030 +typedef int16_t                sco_nlink_t;
24031 +typedef u_int16_t      sco_uid_t;
24032 +typedef u_int16_t      sco_gid_t;
24033 +typedef int32_t                sco_off_t;
24034 +typedef int32_t                sco_time_t;
24035 +
24036 +
24037 +struct sco_statvfs {
24038 +       u_int32_t       f_bsize;
24039 +       u_int32_t       f_frsize;
24040 +       u_int32_t       f_blocks;
24041 +       u_int32_t       f_bfree;
24042 +       u_int32_t       f_bavail;
24043 +       u_int32_t       f_files;
24044 +       u_int32_t       f_free;
24045 +       u_int32_t       f_favail;
24046 +       u_int32_t       f_sid;
24047 +       char            f_basetype[16];
24048 +       u_int32_t       f_flag;
24049 +       u_int32_t       f_namemax;
24050 +       char            f_fstr[32];
24051 +       u_int32_t       f_filler[16];
24052 +};
24053 +
24054 +
24055 +/*
24056 + * Stub for now, as we still have a 16 bit dev_t.
24057 + */
24058 +static __inline sco_dev_t
24059 +linux_to_sco_dev_t(dev_t dev)
24060 +{
24061 +       return dev;
24062 +}
24063 +
24064 +/*
24065 + * If we thought we were in a short inode environment we are
24066 + * probably already too late - getdents() will have likely
24067 + * already assumed short inodes and "fixed" anything with
24068 + * a zero low word (because it must match stat() which must
24069 + * match read() on a directory).
24070 + *
24071 + * We will just have to go along with it.
24072 + */
24073 +static __inline sco_ino_t
24074 +linux_to_sco_ino_t(ino_t ino)
24075 +{
24076 +       if (!is_cur_personality_flag(PERF_SHORT_INODE))
24077 +               return ino;
24078 +       if ((u_long)ino & 0xffff)
24079 +               return ino;
24080 +       return 0xfffffffe;
24081 +}
24082 +
24083 +/*
24084 + * SCO user/group IDs are the same as the old linux ones.
24085 + */
24086 +static __inline sco_uid_t
24087 +linux_to_sco_uid_t(uid_t uid)
24088 +{
24089 +       return high2lowuid(uid);
24090 +}
24091 +
24092 +static __inline sco_gid_t
24093 +linux_to_sco_gid_t(gid_t gid)
24094 +{
24095 +       return high2lowgid(gid);
24096 +}
24097 +
24098 +#endif /* _ABI_SCO_TYPES_H */
24099 diff -Nur kernel-source-2.6.16.orig/include/abi/signal.h kernel-source-2.6.16/include/abi/signal.h
24100 --- kernel-source-2.6.16.orig/include/abi/signal.h      1970-01-01 10:00:00.000000000 +1000
24101 +++ kernel-source-2.6.16/include/abi/signal.h   2006-04-27 18:50:24.000000000 +1000
24102 @@ -0,0 +1,76 @@
24103 +#define NSIGNALS       32
24104 +
24105 +
24106 +/* These are the signal numbers for the SVr4 signal handling */
24107 +#define IBCS_SIGHUP    1
24108 +#define IBCS_SIGINT    2
24109 +#define IBCS_SIGQUIT   3
24110 +#define IBCS_SIGILL    4
24111 +#define IBCS_SIGTRAP   5
24112 +#define IBCS_SIGIOT    6
24113 +#define IBCS_SIGABRT   6
24114 +#define IBCS_SIGEMT    7
24115 +#define IBCS_SIGFPE    8
24116 +#define IBCS_SIGKILL   9
24117 +#define IBCS_SIGBUS    10
24118 +#define IBCS_SIGSEGV   11
24119 +#define IBCS_SIGSYS    12
24120 +#define IBCS_SIGPIPE   13
24121 +#define IBCS_SIGALRM   14
24122 +#define IBCS_SIGTERM   15
24123 +#define IBCS_SIGUSR1   16
24124 +#define IBCS_SIGUSR2   17
24125 +#define IBCS_SIGCLD    18
24126 +#define IBCS_SIGCHLD   18
24127 +#define IBCS_SIGPWR    19
24128 +#define IBCS_SIGWINCH  20
24129 +#define IBCS_SIGURG    21      /* not SCO, SCO uses SIGUSR2 for SIGURG */
24130 +#define IBCS_SIGPOLL   22
24131 +#define IBCS_SIGIO     22
24132 +#define IBCS_SIGSTOP   23
24133 +#define IBCS_SIGTSTP   24
24134 +#define IBCS_SIGCONT   25
24135 +#define IBCS_SIGTTIN   26
24136 +#define IBCS_SIGTTOU   27
24137 +#define IBCS_SIGVTALRM 28
24138 +#define IBCS_SIGPROF   29
24139 +#define IBCS_SIGGXCPU  30
24140 +#define IBCS_SIGGXFSZ  31
24141 +
24142 +#define ISC_SIGSTOP    24
24143 +#define ISC_SIGTSTP    25
24144 +#define ISC_SIGCONT    23
24145 +
24146 +/* These are the signal numbers used by BSD. */
24147 +#define        BSD_SIGHUP      1
24148 +#define        BSD_SIGINT      2
24149 +#define        BSD_SIGQUIT     3
24150 +#define        BSD_SIGILL      4
24151 +#define        BSD_SIGTRAP     5
24152 +#define        BSD_SIGABRT     6
24153 +#define        BSD_SIGEMT      7
24154 +#define        BSD_SIGFPE      8
24155 +#define        BSD_SIGKILL     9
24156 +#define        BSD_SIGBUS      10
24157 +#define        BSD_SIGSEGV     11
24158 +#define        BSD_SIGSYS      12
24159 +#define        BSD_SIGPIPE     13
24160 +#define        BSD_SIGALRM     14
24161 +#define        BSD_SIGTERM     15
24162 +#define        BSD_SIGURG      16
24163 +#define        BSD_SIGSTOP     17
24164 +#define        BSD_SIGTSTP     18
24165 +#define        BSD_SIGCONT     19
24166 +#define        BSD_SIGCHLD     20
24167 +#define        BSD_SIGTTIN     21
24168 +#define        BSD_SIGTTOU     22
24169 +#define        BSD_SIGIO       23
24170 +#define        BSD_SIGXCPU     24
24171 +#define        BSD_SIGXFSZ     25
24172 +#define        BSD_SIGVTALRM 26
24173 +#define        BSD_SIGPROF     27
24174 +#define BSD_SIGWINCH 28
24175 +#define BSD_SIGINFO    29
24176 +#define BSD_SIGUSR1 30
24177 +#define BSD_SIGUSR2 31
24178 +
24179 diff -Nur kernel-source-2.6.16.orig/include/abi/socksys.h kernel-source-2.6.16/include/abi/socksys.h
24180 --- kernel-source-2.6.16.orig/include/abi/socksys.h     1970-01-01 10:00:00.000000000 +1000
24181 +++ kernel-source-2.6.16/include/abi/socksys.h  2006-04-27 18:50:24.000000000 +1000
24182 @@ -0,0 +1,272 @@
24183 +/*
24184 + * Copyright (C) 1994  Mike Jagdis (jaggy@purplet.demon.co.uk)
24185 + */
24186 +
24187 +#ident "%W% %G%"
24188 +
24189 +#include <linux/netdevice.h>
24190 +/* Get struct rtentry from linux/route.h - this should be compatible. */
24191 +#include <linux/route.h>
24192 +/* Get struct arpreq from linux/if_arp.h - this should be compatible. */
24193 +#include <linux/if_arp.h>
24194 +/* Get struct ifreq and struct ifconf from linux/if.h - these should
24195 + * be compatible. */
24196 +#include <linux/if.h>
24197 +
24198 +
24199 +struct socksysreq {
24200 +       int             args[7];
24201 +};
24202 +
24203 +
24204 +struct socknewproto {
24205 +       int             family; /* address family (AF_INET, etc.) */
24206 +       int             type;   /* protocol type (SOCK_STREAM, etc.) */
24207 +       int             proto;  /* per family proto number */
24208 +       dev_t           dev;    /* major/minor to use (must be a clone) */
24209 +       int             flags;  /* protosw flags */
24210 +};
24211 +
24212 +
24213 +/* These are nothing to do with what we know as SO_*. I think they
24214 + * are the command requests which appear in socksysreq structures?
24215 + */
24216 +#define  SSYS_SO_ACCEPT                1
24217 +#define  SSYS_SO_BIND          2
24218 +#define  SSYS_SO_CONNECT       3
24219 +#define  SSYS_SO_GETPEERNAME   4
24220 +#define  SSYS_SO_GETSOCKNAME   5
24221 +#define  SSYS_SO_GETSOCKOPT    6
24222 +#define  SSYS_SO_LISTEN                7
24223 +#define  SSYS_SO_RECV          8
24224 +#define  SSYS_SO_RECVFROM      9
24225 +#define  SSYS_SO_SEND          10
24226 +#define  SSYS_SO_SENDTO                11
24227 +#define  SSYS_SO_SETSOCKOPT    12
24228 +#define  SSYS_SO_SHUTDOWN      13
24229 +#define  SSYS_SO_SOCKET                14
24230 +#define  SSYS_SO_SELECT                15
24231 +#define  SSYS_SO_GETIPDOMAIN   16
24232 +#define  SSYS_SO_SETIPDOMAIN   17
24233 +#define  SSYS_SO_ADJTIME       18
24234 +#define  SSYS_SO_SETREUID      19
24235 +#define  SSYS_SO_SETREGID      20
24236 +#define  SSYS_SO_GETTIME       21
24237 +#define  SSYS_SO_SETTIME       22
24238 +#define  SSYS_SO_GETITIMER     23
24239 +#define  SSYS_SO_SETITIMER     24
24240 +#define  SSYS_SO_RECVMSG       25      /* Here down is SCO 3.2v5 and up */
24241 +#define  SSYS_SO_SENDMSG       26
24242 +#define  SSYS_SO_SOCKPAIR      27
24243 +
24244 +
24245 +/* We encode the ioctl numbers using the argument size as part of
24246 + * the number. This will warn us if we haven't got compatible
24247 + * structures :-).
24248 + *   Naturally the SVR3/Lachman ioctl numbers are different from the
24249 + * BSD/SVR4-XTI ioctl numbers. What more would you expect?
24250 + */
24251 +
24252 +#define        SSYS_IOCPARM_MASK       0xff            /* parameters must be < 256 bytes */
24253 +#define        SSYS_IOC_VOID           0x20000000      /* no parameters */
24254 +#define        SSYS_IOC_OUT            0x40000000      /* copy out parameters */
24255 +#define        SSYS_IOC_IN             0x80000000      /* copy in parameters */
24256 +#define        SSYS_IOC_INOUT          (SSYS_IOC_IN|SSYS_IOC_OUT)
24257 +
24258 +#define        SSYS_IOS(x,y)           (SSYS_IOC_VOID|(x<<8)|y)
24259 +#define        SSYS_IOSR(x,y,t)        (SSYS_IOC_OUT|((sizeof(t)&SSYS_IOCPARM_MASK)<<16)|(x<<8)|y)
24260 +#define        SSYS_IOSW(x,y,t)        (SSYS_IOC_IN|((sizeof(t)&SSYS_IOCPARM_MASK)<<16)|(x<<8)|y)
24261 +#define        SSYS_IOSWR(x,y,t)       (SSYS_IOC_INOUT|((sizeof(t)&SSYS_IOCPARM_MASK)<<16)|(x<<8)|y)
24262 +
24263 +#define SSYS_SIOCSHIWAT                SSYS_IOSW('S', 1, int)  /* set high watermark */
24264 +#define SSYS_SIOCGHIWAT                SSYS_IOSR('S', 2, int)  /* get high watermark */
24265 +#define SSYS_SIOCSLOWAT                SSYS_IOSW('S', 3, int)  /* set low watermark */
24266 +#define SSYS_SIOCGLOWAT                SSYS_IOSR('S', 4, int)  /* get low watermark */
24267 +#define SSYS_SIOCATMARK                SSYS_IOSR('S', 5, int)  /* at oob mark? */
24268 +#define SSYS_SIOCSPGRP         SSYS_IOSW('S', 6, int)  /* set process group */
24269 +#define SSYS_SIOCGPGRP         SSYS_IOSR('S', 7, int)  /* get process group */
24270 +
24271 +
24272 +#define SSYS_FIONREAD          SSYS_IOSR('S', 8, int)  /* BSD compatibilty */
24273 +#define SSYS_FIONBIO           SSYS_IOSW('S', 9, int)  /* BSD compatibilty */
24274 +#define SSYS_FIOASYNC          SSYS_IOSW('S', 10, int) /* BSD compatibilty */
24275 +#define SSYS_SIOCPROTO         SSYS_IOSW('S', 11, struct socknewproto) /* link proto */
24276 +#define SSYS_SIOCGETNAME       SSYS_IOSR('S', 12, struct sockaddr)     /* getsockname */
24277 +#define SSYS_SIOCGETPEER       SSYS_IOSR('S', 13, struct sockaddr)     /* getpeername */
24278 +#define SSYS_IF_UNITSEL                SSYS_IOSW('S', 14, int) /* set unit number */
24279 +#define SSYS_SIOCXPROTO                SSYS_IOS('S', 15)       /* empty proto table */
24280 +
24281 +#define        SSYS_SIOCADDRT          SSYS_IOSW('R', 9, struct rtentry)       /* add route */
24282 +#define        SSYS_SIOCDELRT          SSYS_IOSW('R', 10, struct rtentry)      /* delete route */
24283 +
24284 +#define        SSYS_SIOCSIFADDR        SSYS_IOSW('I', 11, struct ifreq)        /* set ifnet address */
24285 +#define        SSYS_SIOCGIFADDR        SSYS_IOSWR('I', 12, struct ifreq)       /* get ifnet address */
24286 +#define        SSYS_SIOCSIFDSTADDR     SSYS_IOSW('I', 13, struct ifreq)        /* set p-p address */
24287 +#define        SSYS_SIOCGIFDSTADDR     SSYS_IOSWR('I', 14, struct ifreq)       /* get p-p address */
24288 +#define        SSYS_SIOCSIFFLAGS       SSYS_IOSW('I', 15, struct ifreq)        /* set ifnet flags */
24289 +#define        SSYS_SIOCGIFFLAGS       SSYS_IOSWR('I', 16, struct ifreq)       /* get ifnet flags */
24290 +#define        SSYS_SIOCGIFCONF        SSYS_IOSWR('I', 17, struct ifconf)      /* get ifnet list */
24291 +
24292 +#define        SSYS_SIOCSIFMTU         SSYS_IOSW('I', 21, struct ifreq)        /* get if_mtu */
24293 +#define        SSYS_SIOCGIFMTU         SSYS_IOSWR('I', 22, struct ifreq)       /* set if_mtu */
24294 +
24295 +#define SSYS_SIOCIFDETACH      SSYS_IOSW('I', 26, struct ifreq)        /* detach interface */
24296 +#define SSYS_SIOCGENPSTATS     SSYS_IOSWR('I', 27, struct ifreq)       /* get ENP stats */
24297 +
24298 +#define SSYS_SIOCX25XMT                SSYS_IOSWR('I', 29, struct ifreq)       /* start a slp proc in
24299 +                                                        * x25if */
24300 +#define SSYS_SIOCX25RCV                SSYS_IOSWR('I', 30, struct ifreq)       /* start a slp proc in
24301 +                                                        * x25if */
24302 +#define SSYS_SIOCX25TBL                SSYS_IOSWR('I', 31, struct ifreq)       /* xfer lun table to
24303 +                                                        * kernel */
24304 +
24305 +#define        SSYS_SIOCGIFBRDADDR     SSYS_IOSWR('I', 32, struct ifreq)       /* get broadcast addr */
24306 +#define        SSYS_SIOCSIFBRDADDR     SSYS_IOSW('I', 33, struct ifreq)        /* set broadcast addr */
24307 +#define        SSYS_SIOCGIFNETMASK     SSYS_IOSWR('I', 34, struct ifreq)       /* get net addr mask */
24308 +#define        SSYS_SIOCSIFNETMASK     SSYS_IOSW('I', 35, struct ifreq)        /* set net addr mask */
24309 +#define        SSYS_SIOCGIFMETRIC      SSYS_IOSWR('I', 36, struct ifreq)       /* get IF metric */
24310 +#define        SSYS_SIOCSIFMETRIC      SSYS_IOSW('I', 37, struct ifreq)        /* set IF metric */
24311 +
24312 +#define        SSYS_SIOCSARP           SSYS_IOSW('I', 38, struct arpreq)       /* set arp entry */
24313 +#define        SSYS_SIOCGARP           SSYS_IOSWR('I', 39, struct arpreq)      /* get arp entry */
24314 +#define        SSYS_SIOCDARP           SSYS_IOSW('I', 40, struct arpreq)       /* delete arp entry */
24315 +
24316 +#define SSYS_SIOCSIFNAME       SSYS_IOSW('I', 41, struct ifreq)        /* set interface name */
24317 +#define        SSYS_SIOCGIFONEP        SSYS_IOSWR('I', 42, struct ifreq)       /* get one-packet params */
24318 +#define        SSYS_SIOCSIFONEP        SSYS_IOSW('I', 43, struct ifreq)        /* set one-packet params */
24319 +
24320 +#define SSYS_SIOCGENADDR       SSYS_IOSWR('I', 65, struct ifreq)       /* Get ethernet addr */
24321 +
24322 +#define SSYS_SIOCSOCKSYS       SSYS_IOSW('I', 66, struct socksysreq)   /* Pseudo socket syscall */
24323 +
24324 +
24325 +#define        SVR4_SIOCSHIWAT         SSYS_IOSW('s',  0, int) /* set high watermark */
24326 +#define        SVR4_SIOCGHIWAT         SSYS_IOSR('s',  1, int) /* get high watermark */
24327 +#define        SVR4_SIOCSLOWAT         SSYS_IOSW('s',  2, int) /* set low watermark */
24328 +#define        SVR4_SIOCGLOWAT         SSYS_IOSR('s',  3, int) /* get low watermark */
24329 +#define        SVR4_SIOCATMARK         SSYS_IOSR('s',  7, int) /* at oob mark? */
24330 +#define        SVR4_SIOCSPGRP          SSYS_IOSW('s',  8, int) /* set process group */
24331 +#define        SVR4_SIOCGPGRP          SSYS_IOSR('s',  9, int)         /* get process group */
24332 +
24333 +#define        SVR4_SIOCADDRT          SSYS_IOSW('r', 10, struct rtentry)      /* add route */
24334 +#define        SVR4_SIOCDELRT          SSYS_IOSW('r', 11, struct rtentry)      /* delete route */
24335 +
24336 +#define        SVR4_SIOCSIFADDR        SSYS_IOSW('i', 12, struct ifreq)        /* set ifnet address */
24337 +#define        SVR4_SIOCGIFADDR        SSYS_IOSWR('i',13, struct ifreq)        /* get ifnet address */
24338 +#define        SVR4_SIOCSIFDSTADDR     SSYS_IOSW('i', 14, struct ifreq)        /* set p-p address */
24339 +#define        SVR4_SIOCGIFDSTADDR     SSYS_IOSWR('i',15, struct ifreq)        /* get p-p address */
24340 +#define        SVR4_SIOCSIFFLAGS       SSYS_IOSW('i', 16, struct ifreq)        /* set ifnet flags */
24341 +#define        SVR4_SIOCGIFFLAGS       SSYS_IOSWR('i',17, struct ifreq)        /* get ifnet flags */
24342 +#define        SVR4_SIOCSIFMEM         SSYS_IOSW('i', 18, struct ifreq)        /* set interface mem */
24343 +#define        SVR4_SIOCGIFMEM         SSYS_IOSWR('i',19, struct ifreq)        /* get interface mem */
24344 +#define        SVR4_SIOCGIFCONF        SSYS_IOSWR('i',20, struct ifconf)       /* get ifnet list */
24345 +#define        SVR4_SIOCSIFMTU         SSYS_IOSW('i', 21, struct ifreq)        /* set if_mtu */
24346 +#define        SVR4_SIOCGIFMTU         SSYS_IOSWR('i',22, struct ifreq)        /* get if_mtu */
24347 +
24348 +       /* from 4.3BSD */
24349 +#define        SVR4_SIOCGIFBRDADDR     SSYS_IOSWR('i',23, struct ifreq)        /* get broadcast addr */
24350 +#define        SVR4_SIOCSIFBRDADDR     SSYS_IOSW('i',24, struct ifreq) /* set broadcast addr */
24351 +#define        SVR4_SIOCGIFNETMASK     SSYS_IOSWR('i',25, struct ifreq)        /* get net addr mask */
24352 +#define        SVR4_SIOCSIFNETMASK     SSYS_IOSW('i',26, struct ifreq) /* set net addr mask */
24353 +#define        SVR4_SIOCGIFMETRIC      SSYS_IOSWR('i',27, struct ifreq)        /* get IF metric */
24354 +#define        SVR4_SIOCSIFMETRIC      SSYS_IOSW('i',28, struct ifreq) /* set IF metric */
24355 +
24356 +#define        SVR4_SIOCSARP           SSYS_IOSW('i', 30, struct arpreq)       /* set arp entry */
24357 +#define        SVR4_SIOCGARP           SSYS_IOSWR('i',31, struct arpreq)       /* get arp entry */
24358 +#define        SVR4_SIOCDARP           SSYS_IOSW('i', 32, struct arpreq)       /* delete arp entry */
24359 +#define        SVR4_SIOCUPPER          SSYS_IOSW('i', 40, struct ifreq)       /* attach upper layer */
24360 +#define        SVR4_SIOCLOWER          SSYS_IOSW('i', 41, struct ifreq)       /* attach lower layer */
24361 +#define        SVR4_SIOCSETSYNC        SSYS_IOSW('i',  44, struct ifreq)       /* set syncmode */
24362 +#define        SVR4_SIOCGETSYNC        SSYS_IOSWR('i', 45, struct ifreq)       /* get syncmode */
24363 +#define        SVR4_SIOCSSDSTATS       SSYS_IOSWR('i', 46, struct ifreq)       /* sync data stats */
24364 +#define        SVR4_SIOCSSESTATS       SSYS_IOSWR('i', 47, struct ifreq)       /* sync error stats */
24365 +
24366 +#define        SVR4_SIOCSPROMISC       SSYS_IOSW('i', 48, int)         /* request promisc mode
24367 +                                                          on/off */
24368 +#define        SVR4_SIOCADDMULTI       SSYS_IOSW('i', 49, struct ifreq)        /* set m/c address */
24369 +#define        SVR4_SIOCDELMULTI       SSYS_IOSW('i', 50, struct ifreq)        /* clr m/c address */
24370 +
24371 +/* protocol i/o controls */
24372 +#define        SVR4_SIOCSNIT           SSYS_IOSW('p',  0, struct nit_ioc)      /* set nit modes */
24373 +#define        SVR4_SIOCGNIT           SSYS_IOSWR('p', 1, struct nit_ioc)      /* get nit modes */
24374 +
24375 +/* STREAMS based socket emulation */
24376 +
24377 +#define SVR4_SIOCPROTO         SSYS_IOSW('s', 51, struct socknewproto) /* link proto */
24378 +#define SVR4_SIOCGETNAME       SSYS_IOSR('s', 52, struct sockaddr)     /* getsockname */
24379 +#define SVR4_SIOCGETPEER       SSYS_IOSR('s', 53, struct sockaddr)     /* getpeername */
24380 +#define SVR4_IF_UNITSEL                SSYS_IOSW('s', 54, int) /* set unit number */
24381 +#define SVR4_SIOCXPROTO                SSYS_IOS('s', 55)       /* empty proto table */
24382 +
24383 +#define SVR4_SIOCIFDETACH      SSYS_IOSW('i', 56, struct ifreq)        /* detach interface */
24384 +#define SVR4_SIOCGENPSTATS     SSYS_IOSWR('i', 57, struct ifreq)       /* get ENP stats */
24385 +#define SVR4_SIOCX25XMT                SSYS_IOSWR('i', 59, struct ifreq)       /* start a slp proc in
24386 +                                                        * x25if */
24387 +#define SVR4_SIOCX25RCV                SSYS_IOSWR('i', 60, struct ifreq)       /* start a slp proc in
24388 +                                                        * x25if */
24389 +#define SVR4_SIOCX25TBL                SSYS_IOSWR('i', 61, struct ifreq)       /* xfer lun table to
24390 +                                                        * kernel */
24391 +#define SVR4_SIOCSLGETREQ      SSYS_IOSWR('i', 71, struct ifreq)       /* wait for switched
24392 +                                                        * SLIP request */
24393 +#define SVR4_SIOCSLSTAT                SSYS_IOSW('i', 72, struct ifreq)        /* pass SLIP info to
24394 +                                                        * kernel */
24395 +#define SVR4_SIOCSIFNAME       SSYS_IOSW('i', 73, struct ifreq)        /* set interface name */
24396 +#define SVR4_SIOCGENADDR       SSYS_IOSWR('i', 85, struct ifreq)       /* Get ethernet addr */
24397 +#define SVR4_SIOCSOCKSYS       SSYS_IOSW('i', 86, struct socksysreq)   /* Pseudo socket syscall */
24398 +
24399 +
24400 +#if 0
24401 +/* Strange, there also seem to be two byte SVR4 ioctls used which are
24402 + * not simply the BSD style ioctl with the high word masked out. i.e the
24403 + * class character doesn't match what I expect.
24404 + */
24405 +#define SVRX_SIOCGIFCONF       0x8912
24406 +#define SVRX_SIOCGIFFLAGS      0x8913
24407 +#endif
24408 +
24409 +
24410 +/* With NFS/NIS there is also a pseudo device /dev/nfsd which understands
24411 + * some ioctls. Since these don't conflict with the socksys ioctls we
24412 + * just link nfsd to socksys and let socksys handle both sets.
24413 + */
24414 +#define NIOCNFSD       1
24415 +#define NIOCOLDGETFH   2
24416 +#define NIOCASYNCD     3
24417 +#define NIOCSETDOMNAM  4
24418 +#define NIOCGETDOMNAM  5
24419 +#define NIOCCLNTHAND   6
24420 +#define NIOCEXPORTFS   7
24421 +#define NIOCGETFH      8
24422 +#define NIOCLSTAT      9
24423 +
24424 +/* These ioctls take argument structures... */
24425 +struct domnam_args {
24426 +       char *name;
24427 +       int namelen;
24428 +};
24429 +
24430 +struct lstat_args {
24431 +       char *fname;
24432 +       void *statb;
24433 +};
24434 +
24435 +#define NFS_FHSIZE     32
24436 +typedef union {
24437 +       struct {
24438 +               unsigned short  fsid;           /* filesystem id (device) */
24439 +               unsigned long   fno;            /* file number (inode) */
24440 +               unsigned long   fgen;           /* file generation */
24441 +               unsigned short  ex_fsid;        /* exported fs id (device) */
24442 +               unsigned long   ex_fno;         /* exported file no (inode) */
24443 +               unsigned long   ex_fgen;        /* exported file gen */
24444 +       } fh;
24445 +       char pad[NFS_FHSIZE];
24446 +} fhandle_t;
24447 +
24448 +struct getfh_args {
24449 +       char *fname;
24450 +       fhandle_t *fhp;
24451 +};
24452 +
24453 +extern void            inherit_socksys_funcs(unsigned int fd, int state);
24454 +extern int             socksys_fdinit(int fd, int rw, const char *buf, int *count);
24455 diff -Nur kernel-source-2.6.16.orig/include/abi/solaris/stat.h kernel-source-2.6.16/include/abi/solaris/stat.h
24456 --- kernel-source-2.6.16.orig/include/abi/solaris/stat.h        1970-01-01 10:00:00.000000000 +1000
24457 +++ kernel-source-2.6.16/include/abi/solaris/stat.h     2006-04-27 18:50:24.000000000 +1000
24458 @@ -0,0 +1,29 @@
24459 +#ifndef _ABI_SOLARIS_STAT_H
24460 +#define _ABI_SOLARIS_STAT_H
24461 +
24462 +#ident "%W% %G%"
24463 +
24464 +#include <abi/solaris/types.h>
24465 +
24466 +
24467 +struct sol_stat64 {
24468 +       sol_dev_t       st_dev;
24469 +       u_int32_t       st_pad1[3];
24470 +       sol_ino_t       st_ino;
24471 +       sol_mode_t      st_mode;
24472 +       sol_nlink_t     st_nlink;
24473 +       sol_uid_t       st_uid;
24474 +       sol_gid_t       st_gid;
24475 +       sol_dev_t       st_rdev;
24476 +       u_int32_t       st_pad2[2];
24477 +       sol_off_t       st_size;
24478 +       sol_time_t      st_atime;
24479 +       sol_time_t      st_mtime;
24480 +       sol_time_t      st_ctime;
24481 +       int32_t         st_blksize;
24482 +       int64_t         st_blocks;
24483 +       char            st_fstype[16];
24484 +       u_int32_t       st_pad4[4];
24485 +};
24486 +
24487 +#endif /* _ABI_SOLARIS_STAT_H */
24488 diff -Nur kernel-source-2.6.16.orig/include/abi/solaris/sysent.h kernel-source-2.6.16/include/abi/solaris/sysent.h
24489 --- kernel-source-2.6.16.orig/include/abi/solaris/sysent.h      1970-01-01 10:00:00.000000000 +1000
24490 +++ kernel-source-2.6.16/include/abi/solaris/sysent.h   2006-04-27 18:50:24.000000000 +1000
24491 @@ -0,0 +1,54 @@
24492 +#ifndef _ABI_SOLARIS_SYSENT_H
24493 +#define _ABI_SOLARIS_SYSENT_H
24494 +
24495 +#ident "%W% %G%"
24496 +
24497 +struct sol_stat64;
24498 +struct sol_nmsghdr;
24499 +struct sockaddr;
24500 +
24501 +
24502 +/* lfs.c */
24503 +extern int     sol_open64(const char *, int, int);
24504 +extern int     sol_getdents64(int fd, char *, int);
24505 +extern int     sol_mmap64(u_int, u_int, int, int, int, u_int, u_int);
24506 +
24507 +/* socket.c */
24508 +extern int     solaris_socket(int family, int type, int protocol);
24509 +extern int     solaris_socketpair(int *usockvec);
24510 +extern int     solaris_bind(int fd, struct sockaddr *addr, int addrlen);
24511 +extern int     solaris_setsockopt(int fd, int level, int optname,
24512 +                       u32 optval, int optlen);
24513 +extern int     solaris_getsockopt(int fd, int level, int optname,
24514 +                       u32 optval, u32 optlen);
24515 +extern int     solaris_connect(int fd, struct sockaddr *addr, int addrlen);
24516 +extern int     solaris_accept(int fd, struct sockaddr *addr, int *addrlen);
24517 +extern int     solaris_listen(int fd, int backlog);
24518 +extern int     solaris_shutdown(int fd, int how);
24519 +extern int     solaris_recvfrom(int s, char *buf, int len, int flags,
24520 +                       u32 from, u32 fromlen);
24521 +extern int     solaris_recv(int s, char *buf, int len, int flags);
24522 +extern int     solaris_sendto(int s, char *buf, int len, int flags,
24523 +                       u32 to, u32 tolen);
24524 +extern int     solaris_send(int s, char *buf, int len, int flags);
24525 +extern int     solaris_getpeername(int fd, struct sockaddr *addr,
24526 +                       int *addrlen);
24527 +extern int     solaris_getsockname(int fd, struct sockaddr *addr,
24528 +                       int *addrlen);
24529 +extern int     solaris_sendmsg(int fd, struct sol_nmsghdr *user_msg,
24530 +                       unsigned user_flags);
24531 +extern int     solaris_recvmsg(int fd, struct sol_nmsghdr *user_msg,
24532 +                       unsigned user_flags);
24533 +
24534 +/* solarisx86.c */
24535 +extern int     sol_llseek(struct pt_regs *regs);
24536 +extern int     sol_memcntl(unsigned addr, unsigned len, int cmd,
24537 +                       unsigned arg, int attr, int mask);
24538 +extern int     sol_acl(char *pathp, int cmd, int nentries, void *aclbufp);
24539 +
24540 +/* stat.c */
24541 +extern int     sol_stat64(char *, struct sol_stat64 *);
24542 +extern int     sol_lstat64(char *, struct sol_stat64 *);
24543 +extern int     sol_fstat64(u_int fd, struct sol_stat64 *);
24544 +
24545 +#endif /* _ABI_SOLARIS_SYSENT_H */
24546 diff -Nur kernel-source-2.6.16.orig/include/abi/solaris/types.h kernel-source-2.6.16/include/abi/solaris/types.h
24547 --- kernel-source-2.6.16.orig/include/abi/solaris/types.h       1970-01-01 10:00:00.000000000 +1000
24548 +++ kernel-source-2.6.16/include/abi/solaris/types.h    2006-04-27 18:50:24.000000000 +1000
24549 @@ -0,0 +1,54 @@
24550 +/*
24551 + * Copyright (c) 2001 Christoph Hellwig.
24552 + * All rights reserved.
24553 + *
24554 + * This program is free software; you can redistribute it and/or modify
24555 + * it under the terms of the GNU General Public License as published by
24556 + * the Free Software Foundation; either version 2 of the License, or
24557 + * (at your option) any later version.
24558 + *
24559 + * This program is distributed in the hope that it will be useful,
24560 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
24561 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24562 + * GNU General Public License for more details.
24563 + *
24564 + * You should have received a copy of the GNU General Public License
24565 + * along with this program; if not, write to the Free Software
24566 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24567 + */
24568 +#ifndef _ABI_SOLARIS_TYPES_H
24569 +#define _ABI_SOLARIS_TYPES_H
24570 +
24571 +#ident "%W% %G%"
24572 +
24573 +/*
24574 + * Solaris 2 type declarations.
24575 + */
24576 +#include <abi/svr4/types.h>    /* Solaris 2 is based on SVR4 */
24577 +
24578 +typedef svr4_dev_t     sol_dev_t;
24579 +typedef u_int64_t      sol_ino_t;
24580 +typedef svr4_mode_t    sol_mode_t;
24581 +typedef svr4_nlink_t   sol_nlink_t;
24582 +typedef svr4_uid_t     sol_uid_t;
24583 +typedef svr4_gid_t     sol_gid_t;
24584 +typedef int64_t                sol_off_t;
24585 +typedef svr4_time_t    sol_time_t;
24586 +
24587 +typedef u_int64_t      sol_fsblkcnt64_t;
24588 +typedef u_int64_t      sol_fsfilcnt64_t;
24589 +
24590 +
24591 +#define linux_to_sol_dev_t(dev) \
24592 +       linux_to_svr4_dev_t(dev)
24593 +
24594 +#define linux_to_sol_ino_t(ino) \
24595 +       linux_to_svr4_ino_t(ino)
24596 +
24597 +#define linux_to_sol_uid_t(uid) \
24598 +       linux_to_svr4_uid_t(uid)
24599 +
24600 +#define linux_to_sol_gid_t(gid) \
24601 +       linux_to_svr4_gid_t(gid)
24602 +
24603 +#endif /* _ABI_SOLARIS_TYPES_H */
24604 diff -Nur kernel-source-2.6.16.orig/include/abi/stream.h kernel-source-2.6.16/include/abi/stream.h
24605 --- kernel-source-2.6.16.orig/include/abi/stream.h      1970-01-01 10:00:00.000000000 +1000
24606 +++ kernel-source-2.6.16/include/abi/stream.h   2006-04-27 18:50:24.000000000 +1000
24607 @@ -0,0 +1,42 @@
24608 +/*
24609 + * Copyright (C) 1994  Mike Jagdis (jaggy@purplet.demon.co.uk)
24610 + */
24611 +#ifndef _IBCS_STREAM_H_
24612 +#define _IBCS_STREAM_H_
24613 +
24614 +#ident "%W% %G%"
24615 +
24616 +#define MSG_HIPRI      1
24617 +#define RS_HIPRI       MSG_HIPRI
24618 +#define MSG_ANY                2
24619 +#define MSG_BAND       4
24620 +
24621 +#define MORECTL                1
24622 +#define MOREDATA       2
24623 +
24624 +struct strbuf {
24625 +       int     maxlen;         /* size of buffer */
24626 +       int     len;            /* number of bytes in buffer */
24627 +       char    *buf;           /* pointer to buffer */
24628 +};
24629 +
24630 +/* Used for the I_PEEK STREAMS ioctl. */
24631 +struct strpeek {
24632 +       struct strbuf ctl;
24633 +       struct strbuf dat;
24634 +       long flags;
24635 +};
24636 +
24637 +/* Used for the I_FDINSERT STREAMS ioctl. */
24638 +struct strfdinsert {
24639 +       struct strbuf   ctlbuf;
24640 +       struct strbuf   datbuf;
24641 +       long            flags;
24642 +       unsigned int    fildes;
24643 +       int             offset;
24644 +};
24645 +
24646 +extern int stream_fdinsert(struct pt_regs *regs, int fd,
24647 +                               struct strfdinsert *arg);
24648 +
24649 +#endif
24650 diff -Nur kernel-source-2.6.16.orig/include/abi/svr4/ioctl.h kernel-source-2.6.16/include/abi/svr4/ioctl.h
24651 --- kernel-source-2.6.16.orig/include/abi/svr4/ioctl.h  1970-01-01 10:00:00.000000000 +1000
24652 +++ kernel-source-2.6.16/include/abi/svr4/ioctl.h       2006-04-27 18:50:24.000000000 +1000
24653 @@ -0,0 +1,40 @@
24654 +#ifndef _ABI_SVR4_IOCTL_H
24655 +#define _ABI_SVR4_IOCTL_H
24656 +
24657 +/*
24658 + *  Function prototypes used for SVR4 ioctl emulation.
24659 + */
24660 +
24661 +#ident "%W% %G%"
24662 +
24663 +extern int      __svr4_ioctl(struct pt_regs *, int, unsigned long, void *);
24664 +
24665 +/* consio.c */
24666 +extern int     svr4_console_ioctl(int, u_int, caddr_t);
24667 +extern int     svr4_video_ioctl(int, u_int, caddr_t);
24668 +
24669 +/* filio.c */
24670 +extern int     svr4_fil_ioctl(int, u_int, caddr_t);
24671 +
24672 +/* sockio.c */
24673 +extern int     svr4_stream_ioctl(struct pt_regs *regs, int, u_int, caddr_t);
24674 +
24675 +/* socksys.c */
24676 +extern int     abi_ioctl_socksys(int, u_int, caddr_t);
24677 +
24678 +/* tapeio.c */
24679 +extern int     svr4_tape_ioctl(int, u_int, caddr_t);
24680 +
24681 +/* termios.c */
24682 +extern int     bsd_ioctl_termios(int, u_int, void *);
24683 +extern int     svr4_term_ioctl(int, u_int, caddr_t);
24684 +extern int     svr4_termiox_ioctl(int, u_int, caddr_t);
24685 +
24686 +/* timod.c */
24687 +extern int     svr4_sockmod_ioctl(int, u_int, caddr_t);
24688 +extern int      do_getmsg(int, struct pt_regs *, char *, int,
24689 +                        int *, char *, int, int *, int *);
24690 +extern int      do_putmsg(int, struct pt_regs *, char *, int,
24691 +                        char *, int, int);
24692 +
24693 +#endif /* _ABI_SVR4_IOCTL_H */
24694 diff -Nur kernel-source-2.6.16.orig/include/abi/svr4/ipc.h kernel-source-2.6.16/include/abi/svr4/ipc.h
24695 --- kernel-source-2.6.16.orig/include/abi/svr4/ipc.h    1970-01-01 10:00:00.000000000 +1000
24696 +++ kernel-source-2.6.16/include/abi/svr4/ipc.h 2006-04-27 18:50:24.000000000 +1000
24697 @@ -0,0 +1,214 @@
24698 +/*
24699 + * Copyright (c) 1994 Mike Jagdis.
24700 + * Copyright (c) 2001 Christoph Hellwig.
24701 + * All rights reserved.
24702 + *
24703 + * This program is free software; you can redistribute it and/or modify
24704 + * it under the terms of the GNU General Public License as published by
24705 + * the Free Software Foundation; either version 2 of the License, or
24706 + * (at your option) any later version.
24707 + *
24708 + * This program is distributed in the hope that it will be useful,
24709 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
24710 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24711 + * GNU General Public License for more details.
24712 + *
24713 + * You should have received a copy of the GNU General Public License
24714 + * along with this program; if not, write to the Free Software
24715 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24716 + */
24717 +#ifndef _ABI_SVR4_IPC_H
24718 +#define _ABI_SVR4_IPC_H
24719 +
24720 +#ident "%W% %G%"
24721 +
24722 +/*
24723 + * General IPC
24724 + */
24725 +enum {
24726 +       SVR4_IPC_RMID =         0,
24727 +       SVR4_IPC_SET =          1,
24728 +       SVR4_IPC_STAT =         2,
24729 +       SVR4_IPC_RMID_L =       10,
24730 +       SVR4_IPC_SET_L =        11,
24731 +       SVR4_IPC_STAT_L =       12,
24732 +};
24733 +
24734 +struct ibcs2_ipc_perm {
24735 +       u_int16_t               uid;    /* owner's user id */
24736 +       u_int16_t               gid;    /* owner's group id */
24737 +       u_int16_t               cuid;   /* creator's user id */
24738 +       u_int16_t               cgid;   /* creator's group id */
24739 +       u_int16_t               mode;   /* access modes */
24740 +       u_int16_t               seq;    /* slot usage sequence number */
24741 +       int32_t                 key;    /* key */
24742 +};
24743 +
24744 +struct abi4_ipc_perm {
24745 +       u_int32_t               uid;    /* owner's user id */
24746 +       u_int32_t               gid;    /* owner's group id */
24747 +       u_int32_t               cuid;   /* creator's user id */
24748 +       u_int32_t               cgid;   /* creator's group id */
24749 +       u_int32_t               mode;   /* access modes */
24750 +       u_int32_t               seq;    /* slot usage sequence number */
24751 +       int32_t                 key;    /* key */
24752 +       int32_t                 pad[4]; /* reserved */
24753 +};
24754 +
24755 +/*
24756 + * Message queues
24757 + */
24758 +enum {
24759 +       SVR4_msgget =   0,
24760 +       SVR4_msgctl =   1,
24761 +       SVR4_msgrcv =   2,
24762 +       SVR4_msgsnd =   3,
24763 +};
24764 +
24765 +struct ibcs2_msqid_ds {
24766 +       struct ibcs2_ipc_perm   msg_perm;
24767 +       struct msg              *msg_first;
24768 +       struct msg              *msg_last;
24769 +       u_int16_t               msg_cbytes;
24770 +       u_int16_t               msg_qnum;
24771 +       u_int16_t               msg_qbytes;
24772 +       u_int16_t               msg_lspid;
24773 +       u_int16_t               msg_lrpid;
24774 +       time_t                  msg_stime;
24775 +       time_t                  msg_rtime;
24776 +       time_t                  msg_ctime;
24777 +};
24778 +
24779 +struct abi4_msg {
24780 +       struct abi4_msg         *msg_next;
24781 +       int32_t                 msg_type;
24782 +       u_int16_t               msg_ts;
24783 +       int16_t                 msg_spot;
24784 +};
24785 +
24786 +struct abi4_msqid_ds {
24787 +       struct abi4_ipc_perm    msg_perm;
24788 +       struct msg              *msg_first;
24789 +       struct msg              *msg_last;
24790 +       u_int32_t               msg_cbytes;
24791 +       u_int32_t               msg_qnum;
24792 +       u_int32_t               msg_qbytes;
24793 +       u_int32_t               msg_lspid;
24794 +       u_int32_t               msg_lrpid;
24795 +       u_int32_t               msg_stime;
24796 +       u_int32_t               msg_pad1;
24797 +       u_int32_t               msg_rtime;
24798 +       u_int32_t               msg_pad2;
24799 +       u_int32_t               msg_ctime;
24800 +       u_int32_t               msg_pad3;
24801 +       u_int32_t               msg_pad4[4];
24802 +};
24803 +
24804 +/*
24805 + * Shared memory
24806 + */
24807 +enum {
24808 +       SVR4_shmat =    0,
24809 +       SVR4_shmctl =   1,
24810 +       SVR4_shmdt =    2,
24811 +       SVR4_shmget =   3,
24812 +};
24813 +
24814 +/* shmctl() operations */
24815 +enum {
24816 +       SVR4_SHM_LOCK =         3,
24817 +       SVR4_SHM_UNLOCK =       4,
24818 +};
24819 +
24820 +struct ibcs2_shmid_ds {
24821 +       struct ibcs2_ipc_perm   shm_perm;       /* operation permissions */
24822 +       int32_t                 shm_segsz;      /* size of segment in bytes */
24823 +       struct region           *__pad1;        /* ptr to region structure */
24824 +       char                    __pad2[4];      /* for swap compatibility */
24825 +       u_int16_t               shm_lpid;       /* pid of last shmop */
24826 +       u_int16_t               shm_cpid;       /* pid of creator */
24827 +       u_int16_t               shm_nattch;     /* used only for shminfo */
24828 +       u_int16_t                __pad3;
24829 +       time_t                  shm_atime;      /* last shmat time */
24830 +       time_t                  shm_dtime;      /* last shmdt time */
24831 +       time_t                  shm_ctime;      /* last change time */
24832 +};
24833 +
24834 +struct abi4_shmid_ds {
24835 +       struct abi4_ipc_perm    shm_perm;       /* operation permissions */
24836 +       int32_t                 shm_segsz;      /* size of segment in bytes */
24837 +       struct region           *__pad1;        /* ptr to region structure */
24838 +       u_int16_t               shm_lckcnt;     /* number of locks */
24839 +       char                    __pad2[2];      /* for swap compatibility */
24840 +       u_int32_t               shm_lpid;       /* pid of last shmop */
24841 +       u_int32_t               shm_cpid;       /* pid of creator */
24842 +       u_int32_t               shm_nattch;/* used only for shminfo */
24843 +       u_int32_t               shm_cnattch;
24844 +       u_int32_t               shm_atime;      /* last shmat time */
24845 +       u_int32_t               shm_pad1;
24846 +       u_int32_t               shm_dtime;      /* last shmdt time */
24847 +       u_int32_t               shm_pad2;
24848 +       u_int32_t               shm_ctime;      /* last change time */
24849 +       u_int32_t               shm_pad3;
24850 +       u_int32_t               shm_pad4[4];
24851 +};
24852 +
24853 +/*
24854 + * Semaphores
24855 + */
24856 +enum {
24857 +       SVR4_semctl =   0,
24858 +       SVR4_semget =   1,
24859 +       SVR4_semop =    2,
24860 +};
24861 +
24862 +/* semctl() operations */
24863 +enum {
24864 +       SVR4_SEM_GETNCNT =      3,
24865 +       SVR4_SEM_GETPID =       4,
24866 +       SVR4_SEM_GETVAL =       5,
24867 +       SVR4_SEM_GETALL =       6,
24868 +       SVR4_SEM_GETZCNT =      7,
24869 +       SVR4_SEM_SETVAL =       8,
24870 +       SVR4_SEM_SETALL =       9,
24871 +};
24872 +
24873 +/* mapping of svr4 semaphore operations to Linux (if available) */
24874 +static int svr4sem2linux[] = {
24875 +       [SVR4_IPC_RMID] =       IPC_RMID,
24876 +       [SVR4_IPC_SET] =        IPC_SET,
24877 +       [SVR4_IPC_STAT] =       IPC_STAT,
24878 +       [SVR4_SEM_GETNCNT] =    GETNCNT,
24879 +       [SVR4_SEM_GETPID] =     GETPID,
24880 +       [SVR4_SEM_GETVAL] =     GETVAL,
24881 +       [SVR4_SEM_GETALL] =     GETALL,
24882 +       [SVR4_SEM_GETZCNT] =    GETZCNT,
24883 +       [SVR4_SEM_SETVAL] =     SETVAL,
24884 +       [SVR4_SEM_SETALL] =     SETALL,
24885 +       [SVR4_IPC_RMID_L] =     IPC_RMID,
24886 +       [SVR4_IPC_SET_L] =      IPC_SET,
24887 +       [SVR4_IPC_STAT_L] =     IPC_STAT,
24888 +};
24889 +
24890 +struct ibcs2_semid_ds {
24891 +       struct ibcs2_ipc_perm   sem_perm;
24892 +       struct sem              *sem_base;
24893 +       u_int16_t               sem_nsems;
24894 +       char                    __pad[2];
24895 +       u_int32_t               sem_otime;
24896 +       u_int32_t               sem_ctime;
24897 +};
24898 +
24899 +struct abi4_semid_ds {
24900 +       struct abi4_ipc_perm    sem_perm;
24901 +       struct sem              *sem_base;
24902 +       u_int16_t               sem_nsems;
24903 +       char                    __pad[2]; /* this pad is not in the abi doc! */
24904 +       u_int32_t               sem_otime;
24905 +       u_int32_t               sem_pad1;
24906 +       u_int32_t               sem_ctime;
24907 +       u_int32_t               sem_pad2;
24908 +       u_int32_t               sem_pad3[4];
24909 +};
24910 +
24911 +#endif /* _ABI_SVR4_IPC_H */
24912 diff -Nur kernel-source-2.6.16.orig/include/abi/svr4/mman.h kernel-source-2.6.16/include/abi/svr4/mman.h
24913 --- kernel-source-2.6.16.orig/include/abi/svr4/mman.h   1970-01-01 10:00:00.000000000 +1000
24914 +++ kernel-source-2.6.16/include/abi/svr4/mman.h        2006-04-27 18:50:24.000000000 +1000
24915 @@ -0,0 +1,71 @@
24916 +/*
24917 + * Copyright (c) 2001 Christoph Hellwig.
24918 + * All rights reserved.
24919 + *
24920 + * This program is free software; you can redistribute it and/or modify
24921 + * it under the terms of the GNU General Public License as published by
24922 + * the Free Software Foundation; either version 2 of the License, or
24923 + * (at your option) any later version.
24924 + *
24925 + * This program is distributed in the hope that it will be useful,
24926 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
24927 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24928 + * GNU General Public License for more details.
24929 + *
24930 + * You should have received a copy of the GNU General Public License
24931 + * along with this program; if not, write to the Free Software
24932 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24933 + */
24934 +#ifndef _ABI_SVR4_MMAN_H
24935 +#define _ABI_SVR4_MMAN_H
24936 +
24937 +#ident "%W% %G%"
24938 +
24939 +/*
24940 + * SVR4 memory mapped files declarations
24941 + */
24942 +
24943 +#define SVR4_MAP_FAILED                ((void *)-1)
24944 +
24945 +/* protections flags for mmap() and mprotect() */
24946 +#define SVR4_PROT_NONE         0x0000
24947 +#define SVR4_PROT_READ         0x0001
24948 +#define SVR4_PROT_WRITE                0x0002
24949 +#define SVR4_PROT_EXEC         0x0004
24950 +
24951 +/* sharing types for mmap() */
24952 +#define SVR4_MAP_SHARED                0x0001
24953 +#define SVR4_MAP_PRIVATE       0x0002
24954 +#define SVR4_MAP_FIXED         0x0010
24955 +#define SVR4_MAP_RENAME                0x0020
24956 +#define SVR4_MAP_NORESERVE     0x0040
24957 +#define SVR4_MAP_ANONYMOUS     0x0100
24958 +#define SVR4__MAP_NEW          0x80000000
24959 +
24960 +#define SVR4_MAP_UNIMPL                (SVR4_MAP_RENAME|SVR4__MAP_NEW)
24961 +
24962 +/* memcntl() subfunctions */
24963 +#define SVR4_MC_SYNC           0x0001
24964 +#define SVR4_MC_LOCK           0x0002
24965 +#define SVR4_MC_UNLOCK         0x0003
24966 +#define SVR4_MC_ADVISE         0x0004
24967 +#define SVR4_MC_LOCKAS         0x0005
24968 +#define SVR4_MC_UNLOCKAS       0x0006
24969 +
24970 +/* msync() flags */
24971 +#define SVR4_MS_SYNC           0x0000
24972 +#define SVR4_MS_ASYNC          0x0001
24973 +#define SVR4_MS_INVALIDATE     0x0002
24974 +
24975 +/* mlockall() flags */
24976 +#define SVR4_MCL_CURRENT       0x0001
24977 +#define SVR4_MCL_FUTURE                0x0002
24978 +
24979 +/* madvice() advices */
24980 +#define SVR4_MADV_NORMAL       0x0000
24981 +#define SVR4_MADV_RANDOM       0x0001
24982 +#define SVR4_MADV_SEQUENTIAL   0x0002
24983 +#define SVR4_MADV_WILLNEED     0x0003
24984 +#define SVR4_MADV_DONTNEED     0x0004
24985 +
24986 +#endif /* _ABI_SVR4_MMAN_H */
24987 diff -Nur kernel-source-2.6.16.orig/include/abi/svr4/sigaction.h kernel-source-2.6.16/include/abi/svr4/sigaction.h
24988 --- kernel-source-2.6.16.orig/include/abi/svr4/sigaction.h      1970-01-01 10:00:00.000000000 +1000
24989 +++ kernel-source-2.6.16/include/abi/svr4/sigaction.h   2006-04-27 18:50:24.000000000 +1000
24990 @@ -0,0 +1,24 @@
24991 +#ifndef _ABI_SVR4_SIGACTION_H
24992 +#define _ABI_SVR4_SIGACTION_H
24993 +
24994 +#ident "%W% %G%"
24995 +
24996 +/* signal.c */
24997 +struct task_struct;
24998 +extern void deactivate_signal(struct task_struct *, int);
24999 +
25000 +struct abi_sigaction {
25001 +       int          sa_flags;
25002 +       __sighandler_t sa_handler;
25003 +       unsigned long sa_mask;
25004 +       int         sa_resv[2];  /* Reserved for something or another */
25005 +};
25006 +#define ABI_SA_ONSTACK   1
25007 +#define ABI_SA_RESETHAND 2
25008 +#define ABI_SA_RESTART   4
25009 +#define ABI_SA_SIGINFO   8
25010 +#define ABI_SA_NODEFER  16
25011 +#define ABI_SA_NOCLDWAIT 0x10000
25012 +#define ABI_SA_NOCLDSTOP 0x20000
25013 +
25014 +#endif /* _ABI_SVR4_SIGACTION_H */
25015 diff -Nur kernel-source-2.6.16.orig/include/abi/svr4/siginfo.h kernel-source-2.6.16/include/abi/svr4/siginfo.h
25016 --- kernel-source-2.6.16.orig/include/abi/svr4/siginfo.h        1970-01-01 10:00:00.000000000 +1000
25017 +++ kernel-source-2.6.16/include/abi/svr4/siginfo.h     2006-04-27 18:50:24.000000000 +1000
25018 @@ -0,0 +1,32 @@
25019 +#ifndef _ABI_SVR4_SIGINFO_H
25020 +#define _ABI_SVR4_SIGINFO_H
25021 +
25022 +struct svr4_siginfo {
25023 +       int     si_signo;
25024 +       int     si_code;
25025 +       int     si_errno;
25026 +       union {
25027 +               struct {        /* kill(), SIGCLD */
25028 +                       long            _pid;
25029 +                       union {
25030 +                               struct {
25031 +                                       long    _uid;
25032 +                               } _kill;
25033 +                               struct {
25034 +                                       long    _utime;
25035 +                                       int     _status;
25036 +                                       long    _stime;
25037 +                               } _cld;
25038 +                       } _pdata;
25039 +               } _proc;
25040 +               struct {        /* SIGSEGV, SIGBUS, SIGILL, SIGFPE */
25041 +                       char *  _addr;
25042 +               } _fault;
25043 +               struct {        /* SIGPOLL, SIGXFSZ */
25044 +                       int     _fd;
25045 +                       long    _band;
25046 +               } _file;
25047 +       } _data;
25048 +};
25049 +
25050 +#endif /* _ABI_SVR4_SIGINFO_H */
25051 diff -Nur kernel-source-2.6.16.orig/include/abi/svr4/sigset.h kernel-source-2.6.16/include/abi/svr4/sigset.h
25052 --- kernel-source-2.6.16.orig/include/abi/svr4/sigset.h 1970-01-01 10:00:00.000000000 +1000
25053 +++ kernel-source-2.6.16/include/abi/svr4/sigset.h      2006-04-27 18:50:24.000000000 +1000
25054 @@ -0,0 +1,9 @@
25055 +#ifndef _ABI_SVR4_SIGSET_H
25056 +#define _ABI_SVR4_SIGSET_H
25057 +
25058 +typedef void (*svr4_sig_t)(int, void *, void *);
25059 +typedef struct svr4_sigset {
25060 +       u_int   setbits[4];
25061 +} svr4_sigset_t;
25062 +
25063 +#endif /* _ABI_SVR4_SIGSET_H */
25064 diff -Nur kernel-source-2.6.16.orig/include/abi/svr4/sockio.h kernel-source-2.6.16/include/abi/svr4/sockio.h
25065 --- kernel-source-2.6.16.orig/include/abi/svr4/sockio.h 1970-01-01 10:00:00.000000000 +1000
25066 +++ kernel-source-2.6.16/include/abi/svr4/sockio.h      2006-04-27 18:50:24.000000000 +1000
25067 @@ -0,0 +1,119 @@
25068 +/*
25069 + * Copyright (c) 2001 Caldera Deutschland GmbH.
25070 + * Copyright (c) 2001 Christoph Hellwig.
25071 + * All rights reserved.
25072 + *
25073 + * This program is free software; you can redistribute it and/or modify
25074 + * it under the terms of the GNU General Public License as published by
25075 + * the Free Software Foundation; either version 2 of the License, or
25076 + * (at your option) any later version.
25077 + *
25078 + * This program is distributed in the hope that it will be useful,
25079 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
25080 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25081 + * GNU General Public License for more details.
25082 + *
25083 + * You should have received a copy of the GNU General Public License
25084 + * along with this program; if not, write to the Free Software
25085 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25086 + */
25087 +#ifndef _ABI_SVR4_SOCKIO_H
25088 +#define _ABI_SVR4_SOCKIO_H
25089 +
25090 +#ident "%W% %G%"
25091 +
25092 +#include <linux/socket.h>      /* for "struct sockaddr" et al  */
25093 +#include <abi/svr4/types.h>    /* for "svr4_caddr_t" et al */
25094 +
25095 +
25096 +#define SVR4_IFF_UP            0x0001
25097 +#define SVR4_IFF_BROADCAST     0x0002
25098 +#define SVR4_IFF_DEBUG         0x0004
25099 +#define SVR4_IFF_LOOPBACK      0x0008
25100 +#define SVR4_IFF_POINTOPOINT   0x0010
25101 +#define SVR4_IFF_NOTRAILERS    0x0020
25102 +#define SVR4_IFF_RUNNING       0x0040
25103 +#define SVR4_IFF_NOARP         0x0080
25104 +#define SVR4_IFF_PROMISC       0x0100
25105 +#define SVR4_IFF_ALLMULTI      0x0200
25106 +#define SVR4_IFF_INTELLIGENT   0x0400
25107 +#define SVR4_IFF_MULTICAST     0x0800
25108 +#define SVR4_IFF_MULTI_BCAST   0x1000
25109 +#define SVR4_IFF_UNNUMBERED    0x2000
25110 +#define SVR4_IFF_PRIVATE       0x8000
25111 +
25112 +
25113 +/*
25114 + * Struct used for one-packet mode params in if ioctls
25115 + */
25116 +struct svr4_onepacket {
25117 +       u_int   spsize;         /* short packet size */
25118 +       u_int   spthresh;       /* short packet threshold */
25119 +};
25120 +
25121 +/*
25122 + * Interface specific tuning information that TCP can use to its
25123 + * advantage.
25124 + */
25125 +struct svr4_ifperf {
25126 +       u_int   ip_recvspace;   /* Receive window to use */
25127 +       u_int   ip_sendspace;   /* Send window to use */
25128 +       u_int   ip_fullsize;    /* use full-size frames */
25129 +};
25130 +
25131 +#if 0
25132 +/*
25133 + * Interface request structure used for socket ioctl's.  All interface
25134 + * ioctl's must have parameter definitions which begin with ifr_name.  The
25135 + * remainder may be interface specific.
25136 + */
25137 +struct svr4_ifreq {
25138 +#define SVR4_IFNAMSIZ        16
25139 +       union {
25140 +               char    ifrn_name[SVR4_IFNAMSIZ];
25141 +       } ifr_ifrn;
25142 +       union {
25143 +               struct sockaddr         ifru_addr;
25144 +               struct sockaddr         ifru_dstaddr;
25145 +               struct sockaddr         ifru_broadaddr;
25146 +               int                     ifru_int[2];
25147 +               svr4_caddr_t            ifru_data;
25148 +               char                    ifru_enaddr[6];
25149 +               struct svr4_onepacket   ifru_onepacket;
25150 +               struct svr4_ifperf      ifru_perf;
25151 +       }               ifr_ifru;
25152 +#define svr4_ifr_name      ifr_ifrn.ifrn_name      /* if name, e.g. "en0" */
25153 +#define svr4_ifr_addr      ifr_ifru.ifru_addr      /* address */
25154 +#define svr4_ifr_dstaddr    ifr_ifru.ifru_dstaddr   /* other end of ptp link */
25155 +#define svr4_ifr_broadaddr  ifr_ifru.ifru_broadaddr /* broadcast address */
25156 +#define svr4_ifr_flags     ifr_ifru.ifru_int[0]    /* flags */
25157 +#define svr4_ifr_metric            ifr_ifru.ifru_int[1]    /* metric */
25158 +#define svr4_ifr_mtu       ifr_ifru.ifru_int[1]    /* mtu */
25159 +#define svr4_ifr_ifindex    ifr_ifru.ifru_int[1]    /* ifindex */
25160 +#define svr4_ifr_nif       ifr_ifru.ifru_int[1]    /* # of interfaces */
25161 +#define svr4_ifr_naddr     ifr_ifru.ifru_int[1]    /* # of addresses */
25162 +#define svr4_ifr_type      ifr_ifru.ifru_int[1]    /* type of interface */
25163 +#define svr4_ifr_debug     ifr_ifru.ifru_int[1]    /* debug level */
25164 +#define svr4_ifr_muxid     ifr_ifru.ifru_int[1]    /* multiplexor id */
25165 +#define svr4_ifr_data      ifr_ifru.ifru_data      /* for use by interface */
25166 +#define svr4_ifr_enaddr            ifr_ifru.ifru_enaddr    /* ethernet address */
25167 +#define svr4_ifr_onepacket  ifr_ifru.ifru_onepacket /* one-packet mode params */
25168 +#define svr4_ifr_perf      ifr_ifru.ifru_perf      /* tuning parameters */
25169 +};
25170 +#endif
25171 +
25172 +/* socket.c */
25173 +extern int abi_do_setsockopt(unsigned long *sp);
25174 +extern int abi_do_getsockopt(unsigned long *sp);
25175 +
25176 +/* socksys.c */
25177 +/*
25178 + * The original Linux socket file operations.
25179 + * We use it for two thing:
25180 + *  o initializing the socksys socket file operations
25181 + *  o to make calls to the original poll and release routines
25182 + *    from our implementations.
25183 + */
25184 +extern struct file_operations socket_file_ops;
25185 +
25186 +#endif /* _ABI_SVR4_SOCKIO_H */
25187 diff -Nur kernel-source-2.6.16.orig/include/abi/svr4/statfs.h kernel-source-2.6.16/include/abi/svr4/statfs.h
25188 --- kernel-source-2.6.16.orig/include/abi/svr4/statfs.h 1970-01-01 10:00:00.000000000 +1000
25189 +++ kernel-source-2.6.16/include/abi/svr4/statfs.h      2006-04-27 18:50:24.000000000 +1000
25190 @@ -0,0 +1,21 @@
25191 +#ifndef _ABI_SVR4_STATFS_H
25192 +#define _ABI_SVR4_STATFS_H
25193 +
25194 +#ident "%W% %G%"
25195 +
25196 +#include <linux/types.h>
25197 +
25198 +
25199 +struct svr4_statfs {
25200 +       int16_t f_type;
25201 +       int32_t f_bsize;
25202 +       int32_t f_frsize;
25203 +       int32_t f_blocks;
25204 +       int32_t f_bfree;
25205 +       int32_t f_files;
25206 +       int32_t f_ffree;
25207 +       char f_fname[6];
25208 +       char f_fpack[6];
25209 +};
25210 +
25211 +#endif /* _ABI_SVR4_STATFS_H */
25212 diff -Nur kernel-source-2.6.16.orig/include/abi/svr4/stat.h kernel-source-2.6.16/include/abi/svr4/stat.h
25213 --- kernel-source-2.6.16.orig/include/abi/svr4/stat.h   1970-01-01 10:00:00.000000000 +1000
25214 +++ kernel-source-2.6.16/include/abi/svr4/stat.h        2006-04-27 18:50:24.000000000 +1000
25215 @@ -0,0 +1,56 @@
25216 +#ifndef _ABI_SVR4_STAT_H
25217 +#define _ABI_SVR4_STAT_H
25218 +
25219 +#ident "%W% %G%"
25220 +
25221 +#include <abi/svr4/types.h>
25222 +
25223 +/*
25224 + * XXX this will need additions if we support emulation of
25225 + * XXX 64bit SVR4 on 64bit Linux
25226 + */
25227 +
25228 +struct svr4_stat {
25229 +       svr4_o_dev_t      st_dev;
25230 +       svr4_o_ino_t      st_ino;
25231 +       svr4_o_mode_t     st_mode;
25232 +       svr4_o_nlink_t    st_nlink;
25233 +       svr4_o_uid_t      st_uid;
25234 +       svr4_o_gid_t      st_gid;
25235 +       svr4_o_dev_t      st_rdev;
25236 +       svr4_off_t        st_size;
25237 +       svr4_time_t       st_atime;
25238 +       svr4_time_t       st_mtime;
25239 +       svr4_time_t       st_ctime;
25240 +};
25241 +
25242 +struct svr4_xstat {
25243 +       svr4_dev_t        st_dev;
25244 +       u_int32_t         st_pad1[3];
25245 +       svr4_ino_t        st_ino;
25246 +       svr4_mode_t       st_mode;
25247 +       svr4_nlink_t      st_nlink;
25248 +       svr4_uid_t        st_uid;
25249 +       svr4_uid_t        st_gid;
25250 +       svr4_dev_t        st_rdev;
25251 +       u_int32_t         st_pad2[2];
25252 +       svr4_off_t        st_size;
25253 +       u_int32_t         st_pad3;
25254 +       svr4_timestruc_t  st_atim;
25255 +       svr4_timestruc_t  st_mtim;
25256 +       svr4_timestruc_t  st_ctim;
25257 +       u_int32_t         st_blksize;
25258 +       u_int32_t         st_blocks;
25259 +       char              st_fstype[16];
25260 +       u_int32_t         st_pad4[8];
25261 +};
25262 +
25263 +/*
25264 + * Helpers that are used for other xstat implementations as well.
25265 + */
25266 +struct kstat;
25267 +
25268 +extern int report_svr4_stat(struct kstat *, struct svr4_stat *);
25269 +extern int report_svr4_xstat(struct kstat *, struct svr4_xstat *);
25270 +
25271 +#endif /* _ABI_SVR4_STAT_H */
25272 diff -Nur kernel-source-2.6.16.orig/include/abi/svr4/sysconf.h kernel-source-2.6.16/include/abi/svr4/sysconf.h
25273 --- kernel-source-2.6.16.orig/include/abi/svr4/sysconf.h        1970-01-01 10:00:00.000000000 +1000
25274 +++ kernel-source-2.6.16/include/abi/svr4/sysconf.h     2006-04-27 18:50:24.000000000 +1000
25275 @@ -0,0 +1,33 @@
25276 +#ifndef _ABI_SVR4_SYSCONF_H
25277 +#define _ABI_SVR4_SYSCONF_H
25278 +
25279 +#ident "%W% %G%"
25280 +
25281 +/*
25282 + * Possible SVR4 sysconf parameters.
25283 + */
25284 +
25285 +#define _CONFIG_NGROUPS          2       /* # configured supplemental groups */
25286 +#define _CONFIG_CHILD_MAX        3       /* max # of processes per uid session */
25287 +#define _CONFIG_OPEN_FILES       4       /* max # of open files per process */
25288 +#define _CONFIG_POSIX_VER        5       /* POSIX version */
25289 +#define _CONFIG_PAGESIZE         6       /* system page size */
25290 +#define _CONFIG_CLK_TCK          7       /* ticks per second */
25291 +#define _CONFIG_XOPEN_VER        8       /* XOPEN version */
25292 +#define _CONFIG_NACLS_MAX        9       /* for Enhanced Security */
25293 +#define _CONFIG_ARG_MAX          10      /* max length of exec args */
25294 +#define _CONFIG_NPROC            11      /* # processes system is config for */
25295 +#define _CONFIG_NENGINE          12      /* # configured processors (CPUs) */
25296 +#define _CONFIG_NENGINE_ONLN     13      /* # online processors (CPUs) */
25297 +#define _CONFIG_TOTAL_MEMORY     14      /* total memory */
25298 +#define _CONFIG_USEABLE_MEMORY   15      /* user + system memory */
25299 +#define _CONFIG_GENERAL_MEMORY   16      /* user only memory */
25300 +#define _CONFIG_DEDICATED_MEMORY 17     /* dedicated memory */
25301 +#define _CONFIG_NCGS_CONF        18      /* # CGs in system */
25302 +#define _CONFIG_NCGS_ONLN        19      /* # CGs online now */
25303 +#define _CONFIG_MAX_ENG_PER_CG   20      /* max engines per CG */
25304 +#define _CONFIG_CACHE_LINE       21      /* memory cache line size */
25305 +#define _CONFIG_SYSTEM_ID        22      /* system id assigned at ISL */
25306 +#define _CONFIG_KERNEL_VM        23      /* size of kernel virtual memory */
25307 +
25308 +#endif /* _ABI_SVR4_SYSCONF_H */
25309 diff -Nur kernel-source-2.6.16.orig/include/abi/svr4/sysent.h kernel-source-2.6.16/include/abi/svr4/sysent.h
25310 --- kernel-source-2.6.16.orig/include/abi/svr4/sysent.h 1970-01-01 10:00:00.000000000 +1000
25311 +++ kernel-source-2.6.16/include/abi/svr4/sysent.h      2006-04-27 18:50:24.000000000 +1000
25312 @@ -0,0 +1,134 @@
25313 +#ifndef _ABI_SVR4_SYSENT_H
25314 +#define _ABI_SVR4_SYSENT_H
25315 +
25316 +#ident "%W% %G%"
25317 +
25318 +/*
25319 + *  Function prototypes used for the SVR4 emulator.
25320 + */
25321 +
25322 +#include <abi/svr4/types.h>
25323 +#include <abi/svr4/statfs.h>
25324 +
25325 +struct abi_sigaction;
25326 +struct ibcs_statfs;
25327 +struct svr4_stat;
25328 +struct svr4_siginfo;
25329 +struct svr4_sigset;
25330 +struct svr4_statvfs;
25331 +struct pt_regs;
25332 +struct timeval;
25333 +
25334 +
25335 +/* MD (lcall7.c for i386) */
25336 +extern int     lcall7_syscall(struct pt_regs *);
25337 +#define abi_syscall lcall7_syscall
25338 +
25339 +/* fcntl.c */
25340 +extern unsigned short fl_svr4_to_linux[];
25341 +extern int     svr4_fcntl(int, unsigned int, unsigned long);
25342 +
25343 +/* hrtsys.c */
25344 +extern int     svr4_hrtsys(struct pt_regs *);
25345 +
25346 +/* ioctl.c */
25347 +extern int     svr4_ioctl(struct pt_regs *);
25348 +
25349 +/* ipc.c */
25350 +extern int     svr4_semsys(struct pt_regs *);
25351 +extern int     svr4_shmsys(struct pt_regs *);
25352 +extern int     svr4_msgsys(struct pt_regs *);
25353 +
25354 +/* misc.c */
25355 +extern int     abi_brk(u_long);
25356 +extern int     abi_exec(struct pt_regs *);
25357 +extern int     abi_fork(struct pt_regs *);
25358 +extern int     abi_getpid(struct pt_regs *);
25359 +extern int     abi_getuid(struct pt_regs *);
25360 +extern int     abi_getgid(struct pt_regs *);
25361 +extern int     abi_mkdir(const char *, int);
25362 +extern int     svr4_mknod(char *, svr4_o_mode_t, svr4_o_dev_t);
25363 +extern int     svr4_xmknod(int, char *, svr4_mode_t, svr4_dev_t);
25364 +extern int     abi_kill(int, int);
25365 +extern int     abi_pipe(struct pt_regs *);
25366 +extern int     abi_procids(struct pt_regs *);
25367 +extern int     abi_read(int, char *, int);
25368 +extern int     abi_select(int, void *, void *, void *, struct timeval *);
25369 +extern int     abi_time(void);
25370 +extern int     abi_wait(struct pt_regs *);
25371 +
25372 +/* mmap.c */
25373 +extern u_long  svr4_mmap(u_long, size_t, int, int, int, svr4_off_t);
25374 +
25375 +/* open.c */
25376 +extern int     svr4_open(const char *, int, int);
25377 +extern int     svr4_statfs(const char *, struct svr4_statfs *, int, int);
25378 +extern int     svr4_fstatfs(unsigned int, struct svr4_statfs *, int, int);
25379 +extern int     svr4_getdents(int, char *, int);
25380 +
25381 +/* signal.c */
25382 +extern int     abi_sigsuspend(struct pt_regs *);
25383 +extern int     abi_sigfunc(struct pt_regs *);
25384 +extern int     abi_sigaction(int, const struct abi_sigaction *,
25385 +                       struct abi_sigaction *);
25386 +extern int     abi_sigprocmask(int, u_long *, u_long *);
25387 +extern int     abi_sigsuspend(struct pt_regs *);
25388 +
25389 +/* socksys.c */
25390 +extern int     socksys_syscall(u_long *);
25391 +
25392 +/* stream.c */
25393 +extern int     svr4_getmsg(struct pt_regs *);
25394 +extern int     svr4_putmsg(struct pt_regs *);
25395 +extern int     svr4_getpmsg(struct pt_regs *);
25396 +extern int     svr4_putpmsg(struct pt_regs *);
25397 +
25398 +/* svr4.c */
25399 +extern int     svr4_access(char *, int);
25400 +extern int     svr4_waitid(int, int, struct svr4_siginfo *, int);
25401 +extern int     svr4_waitsys(struct pt_regs *);
25402 +extern int     svr4_seteuid(int);
25403 +extern int     svr4_setegid(int);
25404 +extern int     svr4_fpathconf(int, int);
25405 +extern int     svr4_pathconf(char *, int);
25406 +extern int     svr4_sigpending(int, struct svr4_sigset *);
25407 +extern int     svr4_context(struct pt_regs *);
25408 +
25409 +/* sysconf.c */
25410 +extern int     ibcs_sysconf(int);
25411 +
25412 +/* sysfs.c */
25413 +extern int     svr4_sysfs(int, int, int);
25414 +
25415 +/* sysinfo.c */
25416 +extern int     svr4_sysinfo(int, char *, long);
25417 +
25418 +/* ulimit.c */
25419 +extern int     svr4_ulimit(int, int);
25420 +extern int     svr4_getrlimit(int, void *);
25421 +extern int     svr4_setrlimit(int, void *);
25422 +
25423 +/* stat.c */
25424 +extern int     svr4_stat(char *, struct svr4_stat *);
25425 +extern int     svr4_lstat(char *, struct svr4_stat *);
25426 +extern int     svr4_fstat(u_int, struct svr4_stat *);
25427 +extern int     svr4_xstat(int, char *, void *);
25428 +extern int     svr4_fxstat(int, int, void *);
25429 +extern int     svr4_lxstat(int, char *, void *);
25430 +
25431 +/* sysconf.c */
25432 +extern int     svr4_sysconfig(int);
25433 +
25434 +/* sysi86.c */
25435 +extern int     svr4_sysi86(int, void *, int);
25436 +
25437 +/* utsname.c */
25438 +extern int     abi_utsname(u_long);
25439 +extern int     v7_utsname(u_long);
25440 +
25441 +/* statvfs.c */
25442 +extern int     svr4_statvfs(char *, struct svr4_statvfs *);
25443 +extern int     svr4_fstatvfs(int, struct svr4_statvfs *);
25444 +
25445 +
25446 +#endif /* _ABI_SVR4_SYSENT_H */
25447 diff -Nur kernel-source-2.6.16.orig/include/abi/svr4/termios.h kernel-source-2.6.16/include/abi/svr4/termios.h
25448 --- kernel-source-2.6.16.orig/include/abi/svr4/termios.h        1970-01-01 10:00:00.000000000 +1000
25449 +++ kernel-source-2.6.16/include/abi/svr4/termios.h     2006-04-27 18:50:24.000000000 +1000
25450 @@ -0,0 +1,29 @@
25451 +#ifndef _ABI_SVR4_TERMIOS_H
25452 +#define _ABI_SVR4_TERMIOS_H
25453 +
25454 +#ident "%W% %G%"
25455 +
25456 +/*
25457 + * SVR4 termios declarations.
25458 + */
25459 +
25460 +#define SVR_NCC 8
25461 +struct svr_termio {
25462 +       u_int16_t       c_iflag;
25463 +       u_int16_t       c_oflag;
25464 +       u_int16_t       c_cflag;
25465 +       u_int16_t       c_lflag;
25466 +       char            c_line;
25467 +       u_char          c_cc[SVR_NCC];
25468 +};
25469 +
25470 +#define SVR4_NCCS (19)
25471 +struct svr4_termios {
25472 +       u_long          c_iflag;
25473 +       u_long          c_oflag;
25474 +       u_long          c_cflag;
25475 +       u_long          c_lflag;
25476 +       u_char          c_cc[SVR4_NCCS];
25477 +};
25478 +
25479 +#endif /* _ABI_SVR4_TERMIOS_H */
25480 diff -Nur kernel-source-2.6.16.orig/include/abi/svr4/types.h kernel-source-2.6.16/include/abi/svr4/types.h
25481 --- kernel-source-2.6.16.orig/include/abi/svr4/types.h  1970-01-01 10:00:00.000000000 +1000
25482 +++ kernel-source-2.6.16/include/abi/svr4/types.h       2006-04-27 18:50:24.000000000 +1000
25483 @@ -0,0 +1,146 @@
25484 +/*
25485 + * Copyright (c) 2001 Caldera Deutschland GmbH.
25486 + * Copyright (c) 2001 Christoph Hellwig.
25487 + * All rights reserved.
25488 + *
25489 + * This program is free software; you can redistribute it and/or modify
25490 + * it under the terms of the GNU General Public License as published by
25491 + * the Free Software Foundation; either version 2 of the License, or
25492 + * (at your option) any later version.
25493 + *
25494 + * This program is distributed in the hope that it will be useful,
25495 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
25496 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25497 + * GNU General Public License for more details.
25498 + *
25499 + * You should have received a copy of the GNU General Public License
25500 + * along with this program; if not, write to the Free Software
25501 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25502 + */
25503 +#ifndef _ABI_SVR4_TYPES_H
25504 +#define _ABI_SVR4_TYPES_H
25505 +
25506 +#ident "%W% %G%"
25507 +
25508 +/*
25509 + * SVR4 type declarations.
25510 + */
25511 +#include <linux/highuid.h>
25512 +#include <linux/kdev_t.h>
25513 +#include <linux/personality.h>
25514 +#include <linux/sched.h>
25515 +#include <linux/types.h>
25516 +
25517 +/*
25518 + * XXX this will need additions if we support emulation of
25519 + * XXX 64bit SVR4 on 64bit Linux
25520 + */
25521 +
25522 +/* SVR4 (32bit) data types */
25523 +#define SVR4_MINORBITS 18
25524 +#define SVR4_MINORMASK ((1U << SVR4_MINORBITS) - 1)
25525 +#define SVR4_MAJOR(dev) ((unsigned int) ((dev) >> SVR4_MINORBITS))
25526 +#define SVR4_MINOR(dev) ((unsigned int) ((dev) & SVR4_MINORBITS))
25527 +#define SVR4_MKDEV(ma,mi) (((ma) << SVR4_MINORBITS) | (mi))
25528 +typedef u_int32_t      svr4_dev_t; /* Major:Minor = 14:18 */
25529 +typedef u_int32_t      svr4_ino_t;
25530 +typedef u_int32_t      svr4_mode_t;
25531 +typedef u_int32_t      svr4_nlink_t;
25532 +typedef int32_t                svr4_uid_t;
25533 +typedef int32_t                svr4_gid_t;
25534 +typedef int32_t                svr4_off_t;
25535 +typedef int32_t                svr4_time_t;
25536 +typedef struct timeval svr4_timestruc_t;
25537 +
25538 +/* SVR4 old == SVR3 data types */
25539 +#define SVR4_O_MINORBITS 8
25540 +#define SVR4_O_MINORMASK ((1U << SVR4_O_MINORBITS) - 1)
25541 +#define SVR4_O_MAJOR(dev) ((unsigned int) ((dev) >> SVR4_O_MINORBITS))
25542 +#define SVR4_O_MINOR(dev) ((unsigned int) ((dev) & SVR4_O_MINORBITS))
25543 +#define SVR4_O_MKDEV(ma,mi) (((ma) << SVR4_O_MINORBITS) | (mi))
25544 +typedef int16_t                svr4_o_dev_t; /* Major:Minor = 8:8 */
25545 +typedef int16_t                svr4_o_pid_t;
25546 +typedef u_int16_t      svr4_o_ino_t;
25547 +typedef u_int16_t      svr4_o_mode_t;
25548 +typedef int16_t                svr4_o_nlink_t;
25549 +typedef u_int16_t      svr4_o_uid_t;
25550 +typedef u_int16_t      svr4_o_gid_t;
25551 +
25552 +/*
25553 + * Convert a linux dev number into the SVR4 equivalent.
25554 + */
25555 +static __inline svr4_dev_t
25556 +linux_to_svr4_dev_t(dev_t dev)
25557 +{
25558 +       return SVR4_MKDEV (MAJOR (dev), MINOR (dev));
25559 +}
25560 +
25561 +/*
25562 + * SVR4 old (=SVR3) dev_t
25563 + * This is the same as linux 2.4.xx but different from linux 2.6.xx.
25564 + */
25565 +static __inline svr4_o_dev_t
25566 +linux_to_svr4_o_dev_t(dev_t dev)
25567 +{
25568 +       return SVR4_O_MKDEV (MAJOR (dev), MINOR (dev));
25569 +}
25570 +
25571 +/*
25572 + * If we thought we were in a short inode environment we are
25573 + * probably already too late - getdents() will have likely
25574 + * already assumed short inodes and "fixed" anything with
25575 + * a zero low word (because it must match stat() which must
25576 + * match read() on a directory).
25577 + *
25578 + * We will just have to go along with it.
25579 + */
25580 +static __inline svr4_ino_t
25581 +linux_to_svr4_ino_t(ino_t ino)
25582 +{
25583 +       if (!is_cur_personality_flag(PERF_SHORT_INODE))
25584 +               return ino;
25585 +       if ((u_long)ino & 0xffff)
25586 +               return ino;
25587 +       return 0xfffffffe;
25588 +}
25589 +
25590 +/*
25591 + * Old SVR4 ino_t _must_ be in a short inode enviroment.
25592 + */
25593 +static __inline svr4_o_ino_t
25594 +linux_to_svr4_o_ino_t(ino_t ino)
25595 +{
25596 +       if ((u_long)ino & 0xffff)
25597 +               return (svr4_o_ino_t)ino;
25598 +       return 0xfffe;
25599 +}
25600 +
25601 +/*
25602 + * SVR4 UIDs/GIDs are the same as current Linux ones,
25603 + * old (SVR3) ones are the same as old Linux ones.
25604 + */
25605 +static __inline svr4_uid_t
25606 +linux_to_svr4_uid_t(uid_t uid)
25607 +{
25608 +       return uid;
25609 +}
25610 +
25611 +static __inline svr4_o_uid_t
25612 +linux_to_svr4_o_uid_t(uid_t uid)
25613 +{
25614 +       return high2lowuid(uid);
25615 +}
25616 +
25617 +static __inline svr4_gid_t
25618 +linux_to_svr4_gid_t(gid_t gid)
25619 +{
25620 +       return gid;
25621 +}
25622 +
25623 +static __inline svr4_o_gid_t
25624 +linux_to_svr4_o_gid_t(gid_t gid)
25625 +{
25626 +       return high2lowgid(gid);
25627 +}
25628 +
25629 +#endif /* _ABI_SVR4_TYPES_H */
25630 diff -Nur kernel-source-2.6.16.orig/include/abi/tli.h kernel-source-2.6.16/include/abi/tli.h
25631 --- kernel-source-2.6.16.orig/include/abi/tli.h 1970-01-01 10:00:00.000000000 +1000
25632 +++ kernel-source-2.6.16/include/abi/tli.h      2006-04-27 18:50:24.000000000 +1000
25633 @@ -0,0 +1,355 @@
25634 +#ifndef __TLI_H
25635 +#define __TLI_H
25636 +
25637 +
25638 +struct t_info {
25639 +       long addr;
25640 +       long options;
25641 +       long tsdu;
25642 +       long etsdu;
25643 +       long connect;
25644 +       long discon;
25645 +       long servtype;
25646 +};
25647 +
25648 +
25649 +/* Error codes used by TLI transport providers. */
25650 +#define        TBADADDR                1
25651 +#define        TBADOPT                 2
25652 +#define        TACCES                  3
25653 +#define TBADF                  4
25654 +#define TNOADDR                        5
25655 +#define TOUTSTATE              6
25656 +#define TBADSEQ                        7
25657 +#define TSYSERR                        8
25658 +#define TLOOK                  9
25659 +#define TBADDATA              10
25660 +#define TBUFOVFLW             11
25661 +#define TFLOW                 12
25662 +#define        TNODATA                13
25663 +#define TNODIS                14
25664 +#define TNOUDERR              15
25665 +#define TBADFLAG              16
25666 +#define TNOREL                17
25667 +#define TNOTSUPPORT           18
25668 +#define TSTATECHNG            19
25669 +
25670 +
25671 +/* User level states (maintained internally by libnsl_s). */
25672 +#define T_UNINIT       0
25673 +#define T_UNBND                1
25674 +#define T_IDLE         2
25675 +#define T_OUTCON       3
25676 +#define T_INCON                4
25677 +#define T_DATAXFER     5
25678 +#define T_OUTREL       6
25679 +#define T_INREL                7
25680 +#define T_FAKE         8
25681 +#define T_HACK         12
25682 +
25683 +/* Kernel level states of a transport end point. */
25684 +#define TS_UNBND       0       /* unbound */
25685 +#define        TS_WACK_BREQ    1       /* waiting for T_BIND_REQ ack  */
25686 +#define TS_WACK_UREQ   2       /* waiting for T_UNBIND_REQ ack */
25687 +#define TS_IDLE                3       /* idle */
25688 +#define TS_WACK_OPTREQ 4       /* waiting for T_OPTMGMT_REQ ack */
25689 +#define TS_WACK_CREQ   5       /* waiting for T_CONN_REQ ack */
25690 +#define TS_WCON_CREQ   6       /* waiting for T_CONN_REQ confirmation */
25691 +#define        TS_WRES_CIND    7       /* waiting for T_CONN_IND */
25692 +#define TS_WACK_CRES   8       /* waiting for T_CONN_RES ack */
25693 +#define TS_DATA_XFER   9       /* data transfer */
25694 +#define TS_WIND_ORDREL 10      /* releasing read but not write */
25695 +#define TS_WREQ_ORDREL 11      /* wait to release write but not read */
25696 +#define TS_WACK_DREQ6  12      /* waiting for T_DISCON_REQ ack */
25697 +#define TS_WACK_DREQ7  13      /* waiting for T_DISCON_REQ ack */
25698 +#define TS_WACK_DREQ9  14      /* waiting for T_DISCON_REQ ack */
25699 +#define TS_WACK_DREQ10 15      /* waiting for T_DISCON_REQ ack */
25700 +#define TS_WACK_DREQ11 16      /* waiting for T_DISCON_REQ ack */
25701 +#define TS_NOSTATES    17
25702 +
25703 +
25704 +/* Messages used by "timod". */
25705 +#define        T_CONN_REQ      0
25706 +#define T_CONN_RES     1
25707 +#define T_DISCON_REQ   2
25708 +#define T_DATA_REQ     3
25709 +#define T_EXDATA_REQ   4
25710 +#define T_INFO_REQ     5
25711 +#define T_BIND_REQ     6
25712 +#define T_UNBIND_REQ   7
25713 +#define T_UNITDATA_REQ 8
25714 +#define T_OPTMGMT_REQ   9
25715 +#define T_ORDREL_REQ   10
25716 +
25717 +#define T_CONN_IND     11
25718 +#define T_CONN_CON     12
25719 +#define T_DISCON_IND   13
25720 +#define T_DATA_IND     14
25721 +#define T_EXDATA_IND   15
25722 +#define T_INFO_ACK     16
25723 +#define T_BIND_ACK     17
25724 +#define T_ERROR_ACK    18
25725 +#define T_OK_ACK       19
25726 +#define T_UNITDATA_IND 20
25727 +#define T_UDERROR_IND  21
25728 +#define T_OPTMGMT_ACK   22
25729 +#define T_ORDREL_IND    23
25730 +
25731 +/* Flags used from user level library routines. */
25732 +#define T_MORE         0x0001
25733 +#define T_EXPEDITED    0x0002
25734 +#define T_NEGOTIATE    0x0004
25735 +#define T_CHECK                0x0008
25736 +#define T_DEFAULT      0x0010
25737 +#define T_SUCCESS      0x0020
25738 +#define T_FAILURE      0x0040
25739 +#define T_CURRENT      0x0080
25740 +#define T_PARTSUCCESS  0x0100
25741 +#define T_READONLY     0x0200
25742 +#define T_NOTSUPPORT   0x0400
25743 +
25744 +
25745 +struct T_conn_req {
25746 +       long    PRIM_type;      /* T_CONN_REQ */
25747 +       long    DEST_length;
25748 +       long    DEST_offset;
25749 +       long    OPT_length;
25750 +       long    OPT_offset;
25751 +};
25752 +
25753 +struct T_conn_res {
25754 +       long    PRIM_type;      /* T_CONN_RES */
25755 +       void    *QUEUE_ptr;
25756 +       long    OPT_length;
25757 +       long    OPT_offset;
25758 +       long    SEQ_number;
25759 +};
25760 +
25761 +struct T_discon_req {
25762 +       long    PRIM_type;      /* T_DISCON_REQ */
25763 +       long    SEQ_number;
25764 +};
25765 +
25766 +struct T_data_req {
25767 +       long    PRIM_type;      /* T_DATA_REQ */
25768 +       long    MORE_flag;
25769 +};
25770 +
25771 +struct T_exdata_req {
25772 +       long    PRIM_type;      /* T_EXDATA_REQ */
25773 +       long    MORE_flag;
25774 +};
25775 +
25776 +struct T_info_req {
25777 +       long    PRIM_type;      /* T_INFO_REQ */
25778 +};
25779 +
25780 +struct T_bind_req {
25781 +       long    PRIM_type;      /* T_BIND_REQ */
25782 +       long    ADDR_length;
25783 +       long    ADDR_offset;
25784 +       unsigned long CONIND_number;
25785 +};
25786 +
25787 +struct T_unbind_req {
25788 +       long    PRIM_type;      /* T_UNBIND_REQ */
25789 +};
25790 +
25791 +struct T_unitdata_req {
25792 +       long    PRIM_type;      /* T_UNITDATA_REQ */
25793 +       long    DEST_length;
25794 +       long    DEST_offset;
25795 +       long    OPT_length;
25796 +       long    OPT_offset;
25797 +};
25798 +
25799 +struct T_optmgmt_req {
25800 +       long    PRIM_type;      /* T_OPTMGMT_REQ */
25801 +       long    OPT_length;
25802 +       long    OPT_offset;
25803 +       long    MGMT_flags;
25804 +};
25805 +
25806 +struct T_ordrel_req {
25807 +       long    PRIM_type;      /* T_ORDREL_REQ */
25808 +};
25809 +
25810 +
25811 +struct T_conn_ind {
25812 +       long    PRIM_type;      /* T_CONN_IND */
25813 +       long    SRC_length;
25814 +       long    SRC_offset;
25815 +       long    OPT_length;
25816 +       long    OPT_offset;
25817 +       long    SEQ_number;
25818 +};
25819 +
25820 +struct T_conn_con {
25821 +       long    PRIM_type;      /* T_CONN_CON */
25822 +       long    RES_length;
25823 +       long    RES_offset;
25824 +       long    OPT_length;
25825 +       long    OPT_offset;
25826 +};
25827 +
25828 +struct T_discon_ind {
25829 +       long    PRIM_type;      /* T_DISCON_IND */
25830 +       long    DISCON_reason;
25831 +       long    SEQ_number;
25832 +};
25833 +
25834 +struct T_data_ind {
25835 +       long    PRIM_type;      /* T_DATA_IND */
25836 +       long    MORE_flag;
25837 +};
25838 +
25839 +struct T_exdata_ind {
25840 +       long    PRIM_type;      /* T_EXDATA_IND */
25841 +       long    MORE_flag;
25842 +};
25843 +
25844 +/* information acknowledgment */
25845 +
25846 +struct T_info_ack {
25847 +       long    PRIM_type;      /* T_INFO_ACK */
25848 +       long    TSDU_size;
25849 +       long    ETSDU_size;
25850 +       long    CDATA_size;
25851 +       long    DDATA_size;
25852 +       long    ADDR_size;
25853 +       long    OPT_size;
25854 +       long    TIDU_size;
25855 +       long    SERV_type;
25856 +       long    CURRENT_state;
25857 +       long    PROVIDER_flag;
25858 +};
25859 +
25860 +struct T_bind_ack {
25861 +       long            PRIM_type;      /* T_BIND_ACK */
25862 +       long            ADDR_length;
25863 +       long            ADDR_offset;
25864 +       unsigned long   CONIND_number;
25865 +};
25866 +
25867 +struct T_error_ack {
25868 +       long    PRIM_type;      /* T_ERROR_ACK */
25869 +       long    ERROR_prim;
25870 +       long    TLI_error;
25871 +       long    UNIX_error;
25872 +};
25873 +
25874 +struct T_ok_ack {
25875 +       long    PRIM_type;      /* T_OK_ACK */
25876 +       long    CORRECT_prim;
25877 +};
25878 +
25879 +struct T_unitdata_ind {
25880 +       long    PRIM_type;      /* T_UNITDATA_IND */
25881 +       long    SRC_length;
25882 +       long    SRC_offset;
25883 +       long    OPT_length;
25884 +       long    OPT_offset;
25885 +};
25886 +
25887 +struct T_uderror_ind {
25888 +       long    PRIM_type;      /* T_UDERROR_IND */
25889 +       long    DEST_length;
25890 +       long    DEST_offset;
25891 +       long    OPT_length;
25892 +       long    OPT_offset;
25893 +       long    ERROR_type;
25894 +};
25895 +
25896 +struct T_optmgmt_ack {
25897 +       long    PRIM_type;      /* T_OPTMGMT_ACK */
25898 +       long    OPT_length;
25899 +       long    OPT_offset;
25900 +       long    MGMT_flags;
25901 +};
25902 +
25903 +struct T_ordrel_ind {
25904 +       long    PRIM_type;      /* T_ORDREL_IND */
25905 +};
25906 +
25907 +
25908 +union T_primitives {
25909 +       long                    type;
25910 +       struct T_conn_req       conn_req;
25911 +       struct T_conn_res       conn_res;
25912 +       struct T_discon_req     discon_req;
25913 +       struct T_data_req       data_req;
25914 +       struct T_exdata_req     exdata_req;
25915 +       struct T_info_req       info_req;
25916 +       struct T_bind_req       bind_req;
25917 +       struct T_unbind_req     unbind_req;
25918 +       struct T_unitdata_req   unitdata_req;
25919 +       struct T_optmgmt_req    optmgmt_req;
25920 +       struct T_ordrel_req     ordrel_req;
25921 +       struct T_conn_ind       conn_ind;
25922 +       struct T_conn_con       conn_con;
25923 +       struct T_discon_ind     discon_ind;
25924 +       struct T_data_ind       data_ind;
25925 +       struct T_exdata_ind     exdata_ind;
25926 +       struct T_info_ack       info_ack;
25927 +       struct T_bind_ack       bind_ack;
25928 +       struct T_error_ack      error_ack;
25929 +       struct T_ok_ack         ok_ack;
25930 +       struct T_unitdata_ind   unitdata_ind;
25931 +       struct T_uderror_ind    uderror_ind;
25932 +       struct T_optmgmt_ack    optmgmt_ack;
25933 +       struct T_ordrel_ind     ordrel_ind;
25934 +};
25935 +
25936 +
25937 +/* The t_opthdr structure defines the layout of options in a T_OPTMGMT_*
25938 + * data buffer. This is specified in the X/Open specs but does not
25939 + * appear to exist in SCO 3.2.x, SCO OS5, Interactive SVR4 or UnixWare 1.x.
25940 + * There are programs that make options request however.
25941 + * The older TLI uses struct opthdr which is different and incompatible
25942 + * (see below).
25943 + */
25944 +struct t_opthdr {
25945 +       unsigned long len;      /* *Total* length including header */
25946 +       unsigned long level;
25947 +       unsigned long name;
25948 +       unsigned long status;
25949 +       char value[0];          /* and onwards... */
25950 +};
25951 +
25952 +struct opthdr {
25953 +       long level;
25954 +       long name;
25955 +       long len;               /* Length of option value */
25956 +       char value[0];          /* and onwards... */
25957 +};
25958 +
25959 +
25960 +struct T_primsg {
25961 +       struct T_primsg *next;
25962 +       unsigned char pri;
25963 +       unsigned char band;
25964 +       int length;
25965 +       long type;
25966 +};
25967 +
25968 +#define XTI_MAGIC 638654838
25969 +
25970 +struct T_private {
25971 +       int magic;
25972 +       long state;
25973 +       int offset;
25974 +       struct T_primsg *pfirst, *plast;
25975 +};
25976 +
25977 +#define Priv(file)     ((struct T_private *)(file->private_data))
25978 +
25979 +extern int timod_ioctl(struct pt_regs *, int, unsigned int, void *, int, int *);
25980 +extern int timod_putmsg(int, struct inode *, int, struct pt_regs *);
25981 +extern int timod_getmsg(int, struct inode *, int, struct pt_regs *);
25982 +extern int timod_update_socket(int, struct file *, struct pt_regs *);
25983 +
25984 +#ifndef SOCKSYS_MAJOR
25985 +#define SOCKSYS_MAJOR  30
25986 +#endif
25987 +
25988 +#endif /* __TLI_H */
25989 diff -Nur kernel-source-2.6.16.orig/include/abi/unused-termios.h kernel-source-2.6.16/include/abi/unused-termios.h
25990 --- kernel-source-2.6.16.orig/include/abi/unused-termios.h      1970-01-01 10:00:00.000000000 +1000
25991 +++ kernel-source-2.6.16/include/abi/unused-termios.h   2006-04-27 18:50:24.000000000 +1000
25992 @@ -0,0 +1,199 @@
25993 +/*
25994 + *  This file was entered from the book
25995 + *     Intel386 Family Binary Compatability Specification 2
25996 + *     McGraw-Hill Book company
25997 + *     ISBN 0-07-031219-2
25998 + */
25999 +
26000 +#ident "%W% %G%"
26001 +
26002 +#define NCC                8
26003 +#define NCCS               13
26004 +
26005 +typedef unsigned short     tcflag_t;
26006 +typesef unsigned char      cc_t;
26007 +typedef unsigned long      speed_t;
26008 +
26009 +struct termio {
26010 +       unsigned short      c_iflag;
26011 +       unsigned short      c_oflag;
26012 +       unsigned short      c_cflag;
26013 +       unsigned short      c_lflag;
26014 +       char                c_line;
26015 +       unsigned char       c_cc[NC];
26016 +};
26017 +
26018 +struct termios {
26019 +       tcflag_t            c_iflag;
26020 +       tcflag_t            c_oflag;
26021 +       tcflag_t            c_cflag;
26022 +       tcflag_t            c_lflag;
26023 +       char                c_line;
26024 +       cc_t                c_cc[NCCS];
26025 +       char                c_ispeed;
26026 +       char                c_ospeed;
26027 +};
26028 +
26029 +#define VINTR      0
26030 +#define VQUIT      1
26031 +#define VERASE     2
26032 +#define VKILL      3
26033 +#define VEOF       4
26034 +#define VEOL       5
26035 +#define VEOL2      6
26036 +#define VMIN       4
26037 +#define VTIME      5
26038 +#define VSWTCH     7
26039 +#define VSUSP      10
26040 +#define VSTART     11
26041 +#define VSTOP      12
26042 +
26043 +#define CNUL       0
26044 +#define CDEL       0377
26045 +#define CESC       '\\'
26046 +#define CINTR      0177
26047 +#define CQUIT      034
26048 +#define CERASE     '#'
26049 +#define CKILL      '@'
26050 +#define CSTART     021
26051 +#define CSTOP      023
26052 +#define CSWTCH     032
26053 +#define CNSWTCH    0
26054 +#define CSUSP      032
26055 +
26056 +#define IGNBRK     0000001
26057 +#define BRKINT     0000002
26058 +#define IGNPAR     0000004
26059 +#define PARMRK     0000010
26060 +#define INPCK      0000020
26061 +#define ISTRIP     0000040
26062 +#define INLCR      0000100
26063 +#define IGNCR      0000200
26064 +#define ICRNL      0000400
26065 +#define IUCLC      0001000
26066 +#define IXON       0002000
26067 +#define IXANY      0004000
26068 +#define IXOFF      0010000
26069 +#define IMAXBEL    0020000    /* RESERVED */
26070 +#define DOSMODE    0100000
26071 +
26072 +#define OPOST      00000001
26073 +#define OLCUC      00000002
26074 +#define ONLCR      00000004
26075 +#define OCRNL      00000010
26076 +#define ONOCR      00000020
26077 +#define ONLRET     00000040
26078 +#define OFILL      00000100
26079 +#define OFDEL      00000200
26080 +#define NLDLY      00000400
26081 +#define NL0        0
26082 +#define NL1        00000400
26083 +#define CRDLY      00003000
26084 +#define CR0        0
26085 +#define CR1        00001000
26086 +#define CR2        00002000
26087 +#define CR3        00003000
26088 +#define TABDLY     00014000
26089 +#define TAB0       0
26090 +#define TAB1       00004000
26091 +#define TAB2       00010000
26092 +#define TAB3       00014000
26093 +#define BSDLY      00200000
26094 +#define BS0        0
26095 +#define BS1        00200000
26096 +#define VTDLY      00400000
26097 +#define VT0        0
26098 +#define VT1        00400000
26099 +#define FFDLY      01000000
26100 +#define FF0        0
26101 +#define FF1        01000000
26102 +
26103 +#define CBAUD      0000017
26104 +#define CSIZE      0000060
26105 +#define CS5        0
26106 +#define CS6        0000020
26107 +#define CS7        0000040
26108 +#define CS8        0000060
26109 +#define CSTOPB     0000100
26110 +#define CREAD      0000200
26111 +#define PARENB     0000400
26112 +#define PARODD     0001000
26113 +#define HUPCL      0002000
26114 +#define CLOCAL     0004000
26115 +#define RCV1EN     0010000
26116 +#define XMT1EN     0020000
26117 +#define LOBLK      0040000
26118 +#define XCLUDE     0100000
26119 +
26120 +#define ISIG       0000001
26121 +#define ICANON     0000002
26122 +#define XCASE      0000004
26123 +#define ECHO       0000010
26124 +#define ECHOE      0000020
26125 +#define ECHOK      0000040
26126 +#define ECHONL     0000100
26127 +#define NOFLSH     0000200
26128 +#define IEXTEN     0000400
26129 +#defien TOSTOP     0001000
26130 +
26131 +/* Bits 10-15 (0176000) in the c_lflag field are RESERVED */
26132 +
26133 +/*
26134 +#define XIOC       ('x'<<8) Level 2
26135 +*/
26136 +#define XIOC       (('i'<<8)|('X'<<16))
26137 +#define XCGETA     (XIOC|1)
26138 +#define XCSETA     (XIOC|2)
26139 +#define XCSETAW    (XIOC|3)
26140 +#define XCSETAF    (XIOC|4)
26141 +
26142 +#define TIOC       ('T'<<8)
26143 +
26144 +#define TCGETA     (TIOC|1)
26145 +#define TCSETA     (TIOC|2)
26146 +#define TCSETAW    (TIOC|3)
26147 +#define TCSETAF    (TIOC|4)
26148 +#define TCSBRK     (TIOC|5)
26149 +#define TCXONC     (TIOC|6)
26150 +#define TCFLSH     (TIOC|7)
26151 +
26152 +#define TIOCGWINSZ (TIOC|104)
26153 +#define TIOCSWINSZ (TIOC|103)
26154 +
26155 +#define TCSANOW    XCSETA
26156 +#define TCSADRAIN  XCSETAW
26157 +#define TCSAFLUSH  XCSETAF
26158 +#define TCSADFLUSH XCSETAF
26159 +
26160 +#define TCIFLUSH   0
26161 +#define TCOFLUSH   1
26162 +#define TCIOFLUSH  2
26163 +
26164 +#define TCOOFF     0
26165 +#define TCOON      1
26166 +#define TCIOFF     2
26167 +#define TCION      3
26168 +
26169 +#define B0         0
26170 +#define B50        1
26171 +#define B75        2
26172 +#define B110       3
26173 +#define B134       4
26174 +#define B150       5
26175 +#define B200       6
26176 +#define B300       7
26177 +#define B600       8
26178 +#define B1200      9
26179 +#define B1800      10
26180 +#define B2400      11
26181 +#define B4800      12
26182 +#define B9600      13
26183 +#define B19200     14
26184 +#define B38400     15
26185 +
26186 +struct winsize {
26187 +        unsigned short     ws_row;
26188 +        unsigned short     ws_col;
26189 +        unsigned short     ws_xpixel;
26190 +        unsigned short     ws_ypixel;
26191 +};
26192 diff -Nur kernel-source-2.6.16.orig/include/abi/util/errno.h kernel-source-2.6.16/include/abi/util/errno.h
26193 --- kernel-source-2.6.16.orig/include/abi/util/errno.h  1970-01-01 10:00:00.000000000 +1000
26194 +++ kernel-source-2.6.16/include/abi/util/errno.h       2006-04-27 18:50:24.000000000 +1000
26195 @@ -0,0 +1,17 @@
26196 +#ifndef _ABI_UTIL_ERRNO_H
26197 +#define _ABI_UTIL_ERRNO_H
26198 +
26199 +#ident "%W% %G%"
26200 +
26201 +#include <asm/abi_machdep.h>
26202 +#include <abi/util/map.h>
26203 +
26204 +/*
26205 + * Translate the errno numbers from linux to current personality.
26206 + * This should be removed and all other sources changed to call the
26207 + * map function above directly.
26208 + */
26209 +#define iABI_errors(errno) \
26210 +        (map_value(current_thread_info()->exec_domain->err_map, errno, 1))
26211 +
26212 +#endif /* _ABI_UTIL_ERRNO_H */
26213 diff -Nur kernel-source-2.6.16.orig/include/abi/util/map.h kernel-source-2.6.16/include/abi/util/map.h
26214 --- kernel-source-2.6.16.orig/include/abi/util/map.h    1970-01-01 10:00:00.000000000 +1000
26215 +++ kernel-source-2.6.16/include/abi/util/map.h 2006-04-27 18:50:24.000000000 +1000
26216 @@ -0,0 +1,113 @@
26217 +#ifndef _ABI_MAP_H
26218 +#define _ABI_MAP_H
26219 +
26220 +#ident "%W% %G%"
26221 +
26222 +/*
26223 + *  Copyright (C) 1994  Mike Jagdis (jaggy@purplet.demon.co.uk)
26224 + */
26225 +
26226 +
26227 +struct map_segment {
26228 +       int     start, end;
26229 +       u_char  *map;
26230 +};
26231 +
26232 +
26233 +static __inline u_short
26234 +map_flags(u_short f, u_short map[])
26235 +{
26236 +        u_short m, r = 0;
26237 +        int i;
26238 +
26239 +        for (i = 0, m = 1; i < 16; i++) {
26240 +                if (f & m)
26241 +                        r |= map[i];
26242 +               m <<= 1;
26243 +       }
26244 +
26245 +        return r;
26246 +}
26247 +
26248 +static __inline long
26249 +map_bitvec(u_long vec, long map[])
26250 +{
26251 +       u_long newvec = 0, m = 1;
26252 +       int i;
26253 +
26254 +       for (i = 1; i <= 32; i++) {
26255 +               if ((vec & m) && map[i] != -1 && map[i] != 0)
26256 +                       newvec |= (1 << (map[i] - 1));
26257 +               m <<= 1;
26258 +       }
26259 +
26260 +       return newvec;
26261 +}
26262 +
26263 +static __inline u_long
26264 +map_sigvec_from_kernel(sigset_t vec, u_long map[])
26265 +{
26266 +       u_long newvec = 0;
26267 +       int i;
26268 +
26269 +       for (i = 1; i <= 32; i++) {
26270 +               if (sigismember(&vec, i) && map[i] != -1 && map[i] != 0)
26271 +                       newvec |= (1 << (map[i] - 1));
26272 +       }
26273 +
26274 +       return newvec;
26275 +}
26276 +
26277 +static __inline sigset_t
26278 +map_sigvec_to_kernel(u_long vec, u_long map[])
26279 +{
26280 +       sigset_t newvec;
26281 +       u_long m = 1;
26282 +       int i;
26283 +
26284 +       sigemptyset(&newvec);
26285 +       for (i = 1; i <= 32; i++) {
26286 +               if ((vec & m) && map[i] != -1)
26287 +                       sigaddset(&newvec, map[i]);
26288 +               m <<= 1;
26289 +       }
26290 +
26291 +       return newvec;
26292 +}
26293 +
26294 +static __inline int
26295 +map_value(struct map_segment *m, int val, int def)
26296 +{
26297 +       struct map_segment *seg;
26298 +
26299 +       /*
26300 +        * If no mapping exists in this personality just return the
26301 +        * number we were given.
26302 +        */
26303 +       if (!m)
26304 +               return val;
26305 +
26306 +       /*
26307 +        * Search the map looking for a mapping for the given number.
26308 +        */
26309 +       for (seg = m; seg->start != -1; seg++) {
26310 +               if (seg->start <= val && val <= seg->end) {
26311 +                       /*
26312 +                        * If the start and end are the same then this
26313 +                        * segment has one entry and the map is the value
26314 +                        * it maps to. Otherwise if we have a vector we
26315 +                        * pick out the relevant value, if we don't have
26316 +                        * a vector we give identity mapping.
26317 +                        */
26318 +                       if (seg->start == seg->end)
26319 +                               return (int)seg->map;
26320 +                       else
26321 +                               return (seg->map ? seg->map[val-seg->start] : val);
26322 +               }
26323 +       }
26324 +
26325 +       /* Number isn't mapped. Returned the requested default. */
26326 +       return def;
26327 +}
26328 +
26329 +#endif /* ABI_MAP_H */
26330 diff -Nur kernel-source-2.6.16.orig/include/abi/util/revalidate.h kernel-source-2.6.16/include/abi/util/revalidate.h
26331 --- kernel-source-2.6.16.orig/include/abi/util/revalidate.h     1970-01-01 10:00:00.000000000 +1000
26332 +++ kernel-source-2.6.16/include/abi/util/revalidate.h  2006-04-27 18:50:24.000000000 +1000
26333 @@ -0,0 +1,31 @@
26334 +/*
26335 + * This is straight from linux/fs/stat.c.
26336 + */
26337 +#ifndef _ABI_UTIL_REVALIDATE_H
26338 +#define _ABI_UTIL_REVALIDATE_H
26339 +
26340 +#ident "%W% %G%"
26341 +
26342 +#include <linux/fs.h>
26343 +
26344 +/* LINUXABI_TODO */
26345 +/*
26346 + * This is required for proper NFS attribute caching (so it says there).
26347 + * Maybe the kernel should export it - but it is basically simple...
26348 + */
26349 +static __inline int
26350 +do_revalidate(struct dentry *dentry)
26351 +{
26352 +       struct inode *inode = dentry->d_inode;
26353 +        struct iattr attr;
26354 +        int error;
26355 +
26356 +        attr.ia_valid = 0; /* setup an empty flag for the inode attribute change */
26357 +
26358 +        mutex_lock(&inode->i_mutex);
26359 +        error = notify_change(dentry, &attr);
26360 +        mutex_unlock(&inode->i_mutex);
26361 +       return error;
26362 +}
26363 +
26364 +#endif /* _ABI_UTIL_REVALIDATE_H */
26365 diff -Nur kernel-source-2.6.16.orig/include/abi/util/socket.h kernel-source-2.6.16/include/abi/util/socket.h
26366 --- kernel-source-2.6.16.orig/include/abi/util/socket.h 1970-01-01 10:00:00.000000000 +1000
26367 +++ kernel-source-2.6.16/include/abi/util/socket.h      2006-04-27 18:50:24.000000000 +1000
26368 @@ -0,0 +1,13 @@
26369 +#ifndef _ABI_UTIL_SOCKET_H
26370 +#define _ABI_UTIL_SOCKET_H
26371 +
26372 +/*
26373 + * These aren't (currently) defined by Linux. Watch out for warnings
26374 + * about redefinitions...
26375 + */
26376 +#define SO_USELOOPBACK 0xff02
26377 +#define SO_ORDREL      0xff03
26378 +#define SO_IMASOCKET   0xff04
26379 +#define SO_PROTOTYPE   0xff09
26380 +
26381 +#endif /* _ABI_UTIL_SOCKET_H */
26382 diff -Nur kernel-source-2.6.16.orig/include/abi/util/stat.h kernel-source-2.6.16/include/abi/util/stat.h
26383 --- kernel-source-2.6.16.orig/include/abi/util/stat.h   1970-01-01 10:00:00.000000000 +1000
26384 +++ kernel-source-2.6.16/include/abi/util/stat.h        2006-04-27 18:50:24.000000000 +1000
26385 @@ -0,0 +1,36 @@
26386 +/*
26387 + * Mostly ripped from Al Viro's stat-a-AC9-10 patch, 2001 Christoph Hellwig.
26388 + */
26389 +#ifndef _ABI_UTIL_STAT_H
26390 +#define _ABI_UTIL_STAT_H
26391 +
26392 +#ident "%W% %G%"
26393 +
26394 +#if 0
26395 +/* gone to ./include/linux/stat.h */
26396 +struct kstat {
26397 +       ino_t           ino;
26398 +       atomic_t        count;
26399 +       dev_t           dev;
26400 +       umode_t         mode;
26401 +       nlink_t         nlink;
26402 +       uid_t           uid;
26403 +       gid_t           gid;
26404 +       dev_t           rdev;
26405 +       loff_t          size;
26406 +       time_t          atime;
26407 +       time_t          mtime;
26408 +       time_t          ctime;
26409 +       unsigned long   blksize;
26410 +       unsigned long   blocks;
26411 +};
26412 +#endif
26413 +
26414 +#if 0
26415 +/* gone to ./include/linux/fs.h */
26416 +extern int vfs_stat(char *, struct kstat *);
26417 +extern int vfs_lstat(char *, struct kstat *);
26418 +extern int vfs_fstat(int, struct kstat *);
26419 +#endif
26420 +
26421 +#endif /* _ABI_UTIL_STAT_H */
26422 diff -Nur kernel-source-2.6.16.orig/include/abi/util/sysent.h kernel-source-2.6.16/include/abi/util/sysent.h
26423 --- kernel-source-2.6.16.orig/include/abi/util/sysent.h 1970-01-01 10:00:00.000000000 +1000
26424 +++ kernel-source-2.6.16/include/abi/util/sysent.h      2006-04-27 18:50:24.000000000 +1000
26425 @@ -0,0 +1,83 @@
26426 +#ifndef _ABI_SYSENT_H
26427 +#define _ABI_SYSENT_H
26428 +
26429 +#ident "%W% %G%"
26430 +
26431 +
26432 +#include <asm/abi_machdep.h>
26433 +
26434 +struct pt_regs;
26435 +struct sysent;
26436 +
26437 +/*
26438 + * This is needed for subdispatchers like cxenix().
26439 + */
26440 +extern void    lcall7_dispatch(struct pt_regs *, struct sysent *, int);
26441 +
26442 +
26443 +/*
26444 + *  - If an entry is 'Ukn' we don't know how to handle it yet.
26445 + *  - Spl means that we need to do special processing for this syscall.
26446 + *  - Fast means that even the error return handling is done by the function.
26447 + *  - Unimpl means the syscall is not implemented at all.
26448 + */
26449 +enum {
26450 +       Spl = 0x65,     /* pass the regs structure down */
26451 +       Fast = 0x66,    /* same as above + regs already setup at return */
26452 +       Unimpl = 0x67,  /* syscall is not implemented yet */
26453 +       Ukn = Unimpl,   /* source compat (XXX: kill me!) */
26454 +};
26455 +
26456 +/*
26457 + * Every entry in the systen tables is described by this structure.
26458 + */
26459 +struct sysent {
26460 +       void    *se_syscall;    /* function to call */
26461 +       short   se_nargs;       /* number of aguments */
26462 +
26463 +       /*
26464 +        * Theses are only used for syscall tracing.
26465 +        */
26466 +       char    *se_name;       /* name of function */
26467 +       char    *se_args;       /* how to print the argument list */
26468 +};
26469 +
26470 +/*
26471 + * Types for syscall pointers.
26472 + */
26473 +typedef int (*syscall_t)(struct pt_regs *);
26474 +typedef int (*syscallv_t)(void);
26475 +typedef int (*syscall1_t)(int);
26476 +typedef int (*syscall2_t)(int, int);
26477 +typedef int (*syscall3_t)(int, int, int);
26478 +typedef int (*syscall4_t)(int, int, int, int);
26479 +typedef int (*syscall5_t)(int, int, int, int, int);
26480 +typedef int (*syscall6_t)(int, int, int, int, int, int);
26481 +typedef int (*syscall7_t)(int, int, int, int, int, int, int);
26482 +
26483 +/*
26484 + * Marcos to call syscall pointers.
26485 + */
26486 +#define SYSCALL_VOID(sys) \
26487 +       ((syscallv_t)(sys))();
26488 +#define SYSCALL_PREGS(sys, regs) \
26489 +       ((syscall_t)(sys))((regs))
26490 +#define SYSCALL_1ARG(sys, args) \
26491 +       ((syscall1_t)(sys))((args)[0])
26492 +#define SYSCALL_2ARG(sys, args) \
26493 +       ((syscall2_t)(sys))((args)[0], (args)[1])
26494 +#define SYSCALL_3ARG(sys, args) \
26495 +       ((syscall3_t)(sys))((args)[0], (args)[1], (args)[2])
26496 +#define SYSCALL_4ARG(sys, args) \
26497 +       ((syscall4_t)(sys))((args)[0], (args)[1], (args)[2], (args)[3])
26498 +#define SYSCALL_5ARG(sys, args) \
26499 +       ((syscall5_t)(sys))((args)[0], (args)[1], (args)[2], \
26500 +                           (args)[3], (args)[4])
26501 +#define SYSCALL_6ARG(sys, args) \
26502 +       ((syscall6_t)(sys))((args)[0], (args)[1], (args)[2], \
26503 +                           (args)[3], (args)[4], (args)[5])
26504 +#define SYSCALL_7ARG(sys, args) \
26505 +       ((syscall7_t)(sys))((args)[0], (args)[1], (args)[2], \
26506 +                           (args)[3], (args)[4], (args)[5], (args)[6])
26507 +
26508 +#endif /* _ABI_SYSENT_H */
26509 diff -Nur kernel-source-2.6.16.orig/include/abi/util/trace.h kernel-source-2.6.16/include/abi/util/trace.h
26510 --- kernel-source-2.6.16.orig/include/abi/util/trace.h  1970-01-01 10:00:00.000000000 +1000
26511 +++ kernel-source-2.6.16/include/abi/util/trace.h       2006-04-27 18:50:24.000000000 +1000
26512 @@ -0,0 +1,72 @@
26513 +/*
26514 + * Copyright (c) 2001 Christoph Hellwig.
26515 + * All rights resered.
26516 + *
26517 + * This program is free software; you can redistribute it and/or modify
26518 + * it under the terms of the GNU General Public License as published by
26519 + * the Free Software Foundation; either version 2 of the License, or
26520 + * (at your option) any later version.
26521 + *
26522 + * This program is distributed in the hope that it will be useful,
26523 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
26524 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26525 + * GNU General Public License for more details.
26526 + *
26527 + * You should have received a copy of the GNU General Public License
26528 + * along with this program; if not, write to the Free Software
26529 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26530 + */
26531 +#ifndef _ABI_TRACE_H_
26532 +#define _ABI_TRACE_H_
26533 +
26534 +#ident "%W% %G%"
26535 +
26536 +/*
26537 + * Linux-ABI tracing helpers.
26538 + */
26539 +#include <linux/types.h>
26540 +
26541 +
26542 +/*
26543 + * Tracing flags.
26544 + */
26545 +enum {
26546 +       ABI_TRACE_API =         0x00000001, /* all call/return values   */
26547 +       ABI_TRACE_IOCTL =       0x00000002, /* all ioctl calls          */
26548 +       ABI_TRACE_IOCTL_F =     0x00000004, /* ioctl calls that fail    */
26549 +       ABI_TRACE_SIGNAL =      0x00000008, /* all signal calls         */
26550 +       ABI_TRACE_SIGNAL_F =    0x00000010, /* signal calls that fail   */
26551 +       ABI_TRACE_SOCKSYS =     0x00000020, /* socksys and spx devices  */
26552 +       ABI_TRACE_STREAMS =     0x00000040, /* STREAMS faking           */
26553 +       ABI_TRACE_UNIMPL =      0x00000100, /* unimplemened functions   */
26554 +};
26555 +extern u_int   abi_traceflg;
26556 +
26557 +
26558 +/*
26559 + * Check if a syscall needs tracing.
26560 + */
26561 +#define abi_traced(res)                (abi_traceflg & (res))
26562 +
26563 +/*
26564 + * Unconditinal trace.
26565 + */
26566 +#define __abi_trace(fmt...)                                            \
26567 +do {                                                                   \
26568 +       printk(KERN_DEBUG "[%s:%d]: ", current->comm, current->pid);    \
26569 +       printk(fmt);                                                    \
26570 +} while(0)
26571 +
26572 +/*
26573 + * Trace depending on reason.
26574 + */
26575 +#define abi_trace(res, fmt...)                                         \
26576 +do {                                                                   \
26577 +       if (abi_traced(res))                                            \
26578 +               __abi_trace(fmt);                                       \
26579 +} while(0)
26580 +
26581 +/* prototype for ./abi/util/plist.h */
26582 +extern void plist(char *, char *, int *);
26583 +
26584 +#endif /* _ABI_TRACE_H_ */
26585 diff -Nur kernel-source-2.6.16.orig/include/abi/uw7/acl.h kernel-source-2.6.16/include/abi/uw7/acl.h
26586 --- kernel-source-2.6.16.orig/include/abi/uw7/acl.h     1970-01-01 10:00:00.000000000 +1000
26587 +++ kernel-source-2.6.16/include/abi/uw7/acl.h  2006-04-27 18:50:24.000000000 +1000
26588 @@ -0,0 +1,25 @@
26589 +#ifndef _ABI_UW7_ACL_H
26590 +#define _ABI_UW7_ACL_H
26591 +
26592 +#ident "%W% %G%"
26593 +
26594 +/*
26595 + * UnixWare 7 ACL bits (unused so far).
26596 + */
26597 +
26598 +enum {
26599 +       GETACL =        1,
26600 +       SETACL =        2,
26601 +       GETACLCNT =     3,
26602 +};
26603 +
26604 +struct uw7_acl {
26605 +       int             a_type;
26606 +       uid_t           a_id;
26607 +        u_int16_t      a_perm;
26608 +};
26609 +
26610 +
26611 +/* int uw7_acl(char * path, int cmd, int nentries, struct acl * aclp); */
26612 +
26613 +#endif /* _ABI_UW7_ACL_H */
26614 diff -Nur kernel-source-2.6.16.orig/include/abi/uw7/context.h kernel-source-2.6.16/include/abi/uw7/context.h
26615 --- kernel-source-2.6.16.orig/include/abi/uw7/context.h 1970-01-01 10:00:00.000000000 +1000
26616 +++ kernel-source-2.6.16/include/abi/uw7/context.h      2006-04-27 18:50:24.000000000 +1000
26617 @@ -0,0 +1,43 @@
26618 +#ifndef _ABI_UW7_CONTEXT_H
26619 +#define _ABI_UW7_CONTEXT_H
26620 +
26621 +#ident "%W% %G%"
26622 +
26623 +/*
26624 + * UnixWare context bits.
26625 + */
26626 +
26627 +/* ss_size <-> ss_flags which is why we can't use native Linux stack_t :( */
26628 +typedef struct uw7_stack {
26629 +       void    *ss_sp;
26630 +       int     ss_size;
26631 +       int     ss_flags;
26632 +} uw7_stack_t;
26633 +
26634 +/* XXX more registers, please */
26635 +typedef struct uw7_mcontext {
26636 +       unsigned short gs, __gsh;
26637 +       unsigned short fs, __fsh;
26638 +       unsigned short es, __esh;
26639 +       unsigned short ds, __dsh;
26640 +} uw7_mcontext_t;
26641 +
26642 +typedef struct uw7_sigset {
26643 +       unsigned int sigbits[4];
26644 +} uw7_sigset_t;
26645 +
26646 +typedef struct uw7_context {
26647 +       unsigned long           uc_flags;
26648 +       struct uw7_context      *uc_link;
26649 +       uw7_sigset_t            uc_sigmask;
26650 +       uw7_stack_t             uc_stack;
26651 +       uw7_mcontext_t          uc_mcontext;
26652 +       void                    *uc_pdata;
26653 +       char                    uc_unused[16];
26654 +} uw7_context_t;
26655 +
26656 +#define UW7_GETCONTEXT         0
26657 +#define UW7_SETCONTEXT         1
26658 +#define UW7_GETXCONTEXT                2
26659 +
26660 +#endif /* _ABI_UW7_CONTEXT_H */
26661 diff -Nur kernel-source-2.6.16.orig/include/abi/uw7/resource.h kernel-source-2.6.16/include/abi/uw7/resource.h
26662 --- kernel-source-2.6.16.orig/include/abi/uw7/resource.h        1970-01-01 10:00:00.000000000 +1000
26663 +++ kernel-source-2.6.16/include/abi/uw7/resource.h     2006-04-27 18:50:24.000000000 +1000
26664 @@ -0,0 +1,36 @@
26665 +#ifndef _ABI_UW7_RESOURCE_H
26666 +#define _ABI_UW7_RESOURCE_H
26667 +
26668 +#ident "%W% %G%"
26669 +
26670 +/*
26671 + * UnixWare 7 resource limit handling.
26672 + */
26673 +
26674 +typedef u_int64_t      uw7_rlim64_t;
26675 +
26676 +struct uw7_rlim64 {
26677 +       uw7_rlim64_t    rlim_cur;       /* current limit */
26678 +       uw7_rlim64_t    rlim_max;       /* maximum value for rlim_cur */
26679 +};
26680 +
26681 +enum {
26682 +       UW7_RLIMIT_CPU =        0,      /* cpu time in milliseconds */
26683 +       UW7_RLIMIT_FSIZE =      1,      /* maximum file size */
26684 +       UW7_RLIMIT_DATA =       2,      /* data size */
26685 +       UW7_RLIMIT_STACK =      3,      /* stack size */
26686 +       UW7_RLIMIT_CORE =       4,      /* core file size */
26687 +       UW7_RLIMIT_NOFILE =     5,      /* file descriptors */
26688 +       UW7_RLIMIT_VMEM =       6,      /* maximum mapped memory */
26689 +};
26690 +
26691 +static int uw7_to_linux_rlimit[] = {
26692 +       RLIMIT_CPU,
26693 +       RLIMIT_DATA,
26694 +       RLIMIT_STACK,
26695 +       RLIMIT_CORE,
26696 +       RLIMIT_NOFILE,
26697 +       RLIMIT_AS
26698 +};
26699 +
26700 +#endif /* _ABI_UW7_RESOURCE_H */
26701 diff -Nur kernel-source-2.6.16.orig/include/abi/uw7/stat.h kernel-source-2.6.16/include/abi/uw7/stat.h
26702 --- kernel-source-2.6.16.orig/include/abi/uw7/stat.h    1970-01-01 10:00:00.000000000 +1000
26703 +++ kernel-source-2.6.16/include/abi/uw7/stat.h 2006-04-27 18:50:24.000000000 +1000
26704 @@ -0,0 +1,33 @@
26705 +#ifndef _ABI_UW7_STAT_H
26706 +#define _ABI_UW7_STAT_H
26707 +
26708 +#ident "%W% %G%"
26709 +
26710 +
26711 +#include <abi/uw7/types.h>
26712 +
26713 +struct uw7_stat64 {
26714 +       uw7_dev_t       st_dev;
26715 +       u_int32_t       st_pad1[3];
26716 +       uw7_ino_t       st_ino;
26717 +       uw7_mode_t      st_mode;
26718 +       uw7_nlink_t     st_nlink;
26719 +       uw7_uid_t       st_uid;
26720 +       uw7_gid_t       st_gid;
26721 +       uw7_dev_t       st_rdev;
26722 +       u_int32_t       st_pad2[2];
26723 +       uw7_off_t       st_size;
26724 +       struct timeval  st_atime;
26725 +       struct timeval  st_mtime;
26726 +       struct timeval  st_ctime;
26727 +       int32_t         st_blksize;
26728 +       int64_t         st_blocks;
26729 +       char            st_fstype[16];
26730 +       int32_t         st_aclcnt;
26731 +       u_int32_t       st_level;
26732 +       u_int32_t       st_flags;
26733 +       u_int32_t       st_cmwlevel;
26734 +       u_int32_t       st_pad4[4];
26735 +};
26736 +
26737 +#endif /* _ABI_UW7_STAT_H */
26738 diff -Nur kernel-source-2.6.16.orig/include/abi/uw7/statvfs.h kernel-source-2.6.16/include/abi/uw7/statvfs.h
26739 --- kernel-source-2.6.16.orig/include/abi/uw7/statvfs.h 1970-01-01 10:00:00.000000000 +1000
26740 +++ kernel-source-2.6.16/include/abi/uw7/statvfs.h      2006-04-27 18:50:24.000000000 +1000
26741 @@ -0,0 +1,26 @@
26742 +#ifndef _ABI_UW7_STATVFS_H
26743 +#define _ABI_UW7_STATVFS_H
26744 +
26745 +#ident "%W% %G%"
26746 +
26747 +#include <abi/uw7/types.h>
26748 +
26749 +
26750 +struct uw7_statvfs64 {
26751 +       u_int32_t               f_bsize;        /* file system block size */
26752 +       u_int32_t               f_frsize;       /* file system fragment size */
26753 +       uw7_fsblkcnt64_t        f_blocks;       /* total # of fragments */
26754 +       uw7_fsblkcnt64_t        f_bfree;        /* total # of free fragments */
26755 +       uw7_fsblkcnt64_t        f_bavail;       /* # of free fragments avail */
26756 +       uw7_fsfilcnt64_t        f_files;        /* total # of inodes */
26757 +       uw7_fsfilcnt64_t        f_ffree;        /* total # of free inodes */
26758 +       uw7_fsfilcnt64_t        f_favail;       /* # of free inodes avail */
26759 +       u_int32_t               f_fsid;         /* file system id */
26760 +       char                    f_basetype[16]; /* target fs type name */
26761 +       u_int32_t               f_flag;         /* bit-mask of flags */
26762 +       u_int32_t               f_namemax;      /* maximum file name length */
26763 +       char                    f_fstr[32];     /* filesystem string */
26764 +       u_int32_t               f_filler[16];   /* reserved */
26765 +};
26766 +
26767 +#endif /* _ABI_UW7_STATVFS_H */
26768 diff -Nur kernel-source-2.6.16.orig/include/abi/uw7/sysent.h kernel-source-2.6.16/include/abi/uw7/sysent.h
26769 --- kernel-source-2.6.16.orig/include/abi/uw7/sysent.h  1970-01-01 10:00:00.000000000 +1000
26770 +++ kernel-source-2.6.16/include/abi/uw7/sysent.h       2006-04-27 18:50:24.000000000 +1000
26771 @@ -0,0 +1,58 @@
26772 +#ifndef _ABI_UW7_SYSENT_H
26773 +#define _ABI_UW7_SYSENT_H
26774 +
26775 +#ident "%W% %G%"
26776 +
26777 +/*
26778 + * External function declarations for the SCO UnixWare 7 syscall table.
26779 + */
26780 +
26781 +struct pt_regs;
26782 +struct uw7_rlimit64;
26783 +struct uw7_stack;
26784 +struct uw7_statvfs64;
26785 +
26786 +
26787 +/* access.c */
26788 +extern int     uw7_access(char *, int);
26789 +
26790 +/* context.c */
26791 +extern int     uw7_context(struct pt_regs *);
26792 +extern int     uw7_sigaltstack(const struct uw7_stack *, struct uw7_stack *);
26793 +
26794 +/* misc.c */
26795 +extern int     uw7_sleep(int);
26796 +extern int     uw7_seteuid(int);
26797 +extern int     uw7_setegid(int);
26798 +extern int     uw7_pread(u_int, char *, int, long);
26799 +extern int     uw7_pwrite(u_int, char *, int, long);
26800 +extern int     uw7_stty(int, int);
26801 +extern int     uw7_gtty(int, int);
26802 +
26803 +/* ioctl.c */
26804 +extern int     uw7_ioctl(struct pt_regs *);
26805 +
26806 +/* lfs.c */
26807 +extern int     uw7_truncate64(const char *, u_long, u_long);
26808 +extern int     uw7_ftruncate64(int, u_long, u_long);
26809 +extern int     uw7_statvfs64(char *, struct uw7_statvfs64 *);
26810 +extern int     uw7_fstatvfs64(int, struct uw7_statvfs64 *);
26811 +extern int     uw7_getrlimit64(int, struct uw7_rlimit64 *);
26812 +extern int     uw7_setrlimit64(int, const struct uw7_rlimit64 *);
26813 +extern int     uw7_lseek64(int, u_int, u_int, int);
26814 +extern ssize_t uw7_pread64(int, char *, int, u_int, u_int);
26815 +extern ssize_t uw7_pwrite64(int, char *, int, u_int, u_int);
26816 +extern int     uw7_creat64(const char *, int);
26817 +
26818 +/* mac.c */
26819 +extern int     uw7_mldmode(int);
26820 +
26821 +/* mmap.c */
26822 +extern int     uw7_mmap64(u_long, size_t, int, int, int, u_long, u_long);
26823 +
26824 +/* stat.c */
26825 +extern int     uw7_xstat(int, char *, void *);
26826 +extern int     uw7_lxstat(int, char *, void *);
26827 +extern int     uw7_fxstat(int, int, void *);
26828 +
26829 +#endif /* _ABI_UW7_SYSENT_H */
26830 diff -Nur kernel-source-2.6.16.orig/include/abi/uw7/termbits.h kernel-source-2.6.16/include/abi/uw7/termbits.h
26831 --- kernel-source-2.6.16.orig/include/abi/uw7/termbits.h        1970-01-01 10:00:00.000000000 +1000
26832 +++ kernel-source-2.6.16/include/abi/uw7/termbits.h     2006-04-27 18:50:24.000000000 +1000
26833 @@ -0,0 +1,147 @@
26834 +#ifndef _ABI_UW7_TERMBITS_H
26835 +#define _ABI_UW7_TERMBITS_H
26836 +
26837 +#define UW7_TIOC               ('T'<<8)
26838 +#define UW7_TCGETA             (UW7_TIOC|1)
26839 +#define UW7_TCSETA             (UW7_TIOC|2)
26840 +#define UW7_TCSETAW            (UW7_TIOC|3)
26841 +#define UW7_TCSETAF            (UW7_TIOC|4)
26842 +#define UW7_TCSBRK             (UW7_TIOC|5)
26843 +#define UW7_TCXONC             (UW7_TIOC|6)
26844 +#define UW7_TCFLSH             (UW7_TIOC|7)
26845 +#define UW7_TCDSET             (UW7_TIOC|32)
26846 +#define UW7_RTS_TOG            (UW7_TIOC|33)
26847 +#define UW7_TIOCGWINSZ         (UW7_TIOC|104)
26848 +#define UW7_TIOCSWINSZ         (UW7_TIOC|103)
26849 +#define UW7_TCGETS             (UW7_TIOC|13)
26850 +#define UW7_TCSETS             (UW7_TIOC|14)
26851 +#define        UW7_TCSANOW             UW7_TCSETS
26852 +#define UW7_TCSETSW            (UW7_TIOC|15)
26853 +#define UW7_TCSADRAIN          UW7_TCSETSW
26854 +#define UW7_TCSETSF            (UW7_TIOC|16)
26855 +#define UW7_TCSAFLUSH          UW7_TCSETSF
26856 +
26857 +/*
26858 + * VEOF/VEOL and VMIN/VTIME are overloaded.
26859 + * VEOF/VEOL are used in canonical mode (ICANON),
26860 + * otherwise VMIN/VTIME are used.
26861 + */
26862 +#define UW7_VINTR              0
26863 +#define UW7_VQUIT              1
26864 +#define UW7_VERASE             2
26865 +#define UW7_VKILL              3
26866 +#define UW7_VEOF               4
26867 +#define UW7_VEOL               5
26868 +#define UW7_VEOL2              6
26869 +#define UW7_VMIN               4
26870 +#define UW7_VTIME              5
26871 +#define UW7_VSWTCH             7
26872 +#define UW7_VSTART             8
26873 +#define UW7_VSTOP              9
26874 +#define UW7_VSUSP              10
26875 +#define UW7_VDSUSP             11
26876 +#define UW7_VREPRINT           12
26877 +#define UW7_VDISCARD           13
26878 +#define UW7_VWERASE            14
26879 +#define UW7_VLNEXT             15
26880 +
26881 +/*
26882 + * Input modes (c_iflag), same as Linux bits, except DOSMODE (obsolete).
26883 + */
26884 +#define UW7_IFLAG_MSK  0017777
26885 +#define UW7_IGNBRK     0000001
26886 +#define UW7_BRKINT     0000002
26887 +#define UW7_IGNPAR     0000004
26888 +#define UW7_PARMRK     0000010
26889 +#define UW7_INPCK      0000020
26890 +#define UW7_ISTRIP     0000040
26891 +#define UW7_INLCR      0000100
26892 +#define UW7_IGNCR      0000200
26893 +#define UW7_ICRNL      0000400
26894 +#define UW7_IUCLC      0001000
26895 +#define UW7_IXON       0002000
26896 +#define UW7_IXANY      0004000
26897 +#define UW7_IXOFF      0010000
26898 +#define UW7_IMAXBEL    0020000
26899 +#define UW7_DOSMODE    0100000
26900 +
26901 +/*
26902 + * Output modes (c_oflag), exactly the same as Linux bits.
26903 + */
26904 +#define UW7_OFLAG_MSK  0177777
26905 +#define UW7_OPOST      0000001
26906 +#define UW7_OLCUC      0000002
26907 +#define UW7_ONLCR      0000004
26908 +#define UW7_OCRNL      0000010
26909 +#define UW7_ONOCR      0000020
26910 +#define UW7_ONLRET     0000040
26911 +#define UW7_OFILL      0000100
26912 +#define UW7_OFDEL      0000200
26913 +#define UW7_NLDLY      0000400
26914 +#define   UW7_NL0      0000000
26915 +#define   UW7_NL1      0000400
26916 +#define UW7_CRDLY      0003000
26917 +#define   UW7_CR0      0000000
26918 +#define   UW7_CR1      0001000
26919 +#define   UW7_CR2      0002000
26920 +#define   UW7_CR3      0003000
26921 +#define UW7_TABDLY     0014000
26922 +#define   UW7_TAB0     0000000
26923 +#define   UW7_TAB1     0004000
26924 +#define   UW7_TAB2     0010000
26925 +#define   UW7_TAB3     0014000
26926 +#define   UW7_XTABS    UW7_TAB3
26927 +#define UW7_BSDLY      0020000
26928 +#define   UW7_BS0      0000000
26929 +#define   UW7_BS1      0020000
26930 +#define UW7_VTDLY      0040000
26931 +#define   UW7_VT0      0000000
26932 +#define   UW7_VT1      0040000
26933 +#define UW7_FFDLY      0100000
26934 +#define   UW7_FF0      0000000
26935 +#define   UW7_FF1      0100000
26936 +
26937 +/*
26938 + * Control modes (c_cflag).
26939 + */
26940 +#define UW7_CFLAG_MSK  0177777
26941 +#define UW7_CBAUD      0000017
26942 +#define UW7_CSIZE      0000060
26943 +#define   UW7_CS5      0000000
26944 +#define   UW7_CS6      0000020
26945 +#define   UW7_CS7      0000040
26946 +#define   UW7_CS8      0000060
26947 +#define UW7_CSTOPB     0000100
26948 +#define UW7_CREAD      0000200
26949 +#define UW7_PARENB     0000400
26950 +#define UW7_PARODD     0001000
26951 +#define UW7_HUPCL      0002000
26952 +#define UW7_CLOCAL     0004000
26953 +#define UW7_XCLUDE     0100000
26954 +#define UW7_CIBAUD     000003600000
26955 +#define UW7_IBSHIFT    16
26956 +#define UW7_PAREXT     000004000000
26957 +
26958 +/*
26959 + * Local modes (c_lflag), same as Linux except
26960 + * UW7_FLUSHO is different and UW7_DEFECHO is obsolete (set to 0).
26961 + */
26962 +#define UW7_LFLAG_MSK  0001777
26963 +#define UW7_ISIG       0000001
26964 +#define UW7_ICANON     0000002
26965 +#define UW7_XCASE      0000004
26966 +#define UW7_ECHO       0000010
26967 +#define UW7_ECHOE      0000020
26968 +#define UW7_ECHOK      0000040
26969 +#define UW7_ECHONL     0000100
26970 +#define UW7_NOFLSH     0000200
26971 +#define UW7_TOSTOP     0000400
26972 +#define UW7_ECHOCTL    0001000
26973 +#define UW7_ECHOPRT    0002000
26974 +#define UW7_ECHOKE     0004000
26975 +#define UW7_DEFECHO    0010000
26976 +#define UW7_FLUSHO     0020000
26977 +#define UW7_PENDIN     0040000
26978 +#define UW7_IEXTEN     0100000
26979 +
26980 +#endif /* _ABI_UW7_TERMBITS_H */
26981 diff -Nur kernel-source-2.6.16.orig/include/abi/uw7/termios.h kernel-source-2.6.16/include/abi/uw7/termios.h
26982 --- kernel-source-2.6.16.orig/include/abi/uw7/termios.h 1970-01-01 10:00:00.000000000 +1000
26983 +++ kernel-source-2.6.16/include/abi/uw7/termios.h      2006-04-27 18:50:24.000000000 +1000
26984 @@ -0,0 +1,13 @@
26985 +#ifndef _ABI_UW7_TERMIOS_H
26986 +#define _ABI_UW7_TERMIOS_H
26987 +
26988 +#define UW7_NCCS               (19)
26989 +struct uw7_termios {
26990 +       unsigned long c_iflag;
26991 +       unsigned long c_oflag;
26992 +       unsigned long c_cflag;
26993 +       unsigned long c_lflag;
26994 +       unsigned char c_cc[UW7_NCCS];
26995 +};
26996 +
26997 +#endif /* _ABI_UW7_TERMIOS_H */
26998 diff -Nur kernel-source-2.6.16.orig/include/abi/uw7/types.h kernel-source-2.6.16/include/abi/uw7/types.h
26999 --- kernel-source-2.6.16.orig/include/abi/uw7/types.h   1970-01-01 10:00:00.000000000 +1000
27000 +++ kernel-source-2.6.16/include/abi/uw7/types.h        2006-04-27 18:50:24.000000000 +1000
27001 @@ -0,0 +1,54 @@
27002 +/*
27003 + * Copyright (c) 2001 Christoph Hellwig.
27004 + * All rights reserved.
27005 + *
27006 + * This program is free software; you can redistribute it and/or modify
27007 + * it under the terms of the GNU General Public License as published by
27008 + * the Free Software Foundation; either version 2 of the License, or
27009 + * (at your option) any later version.
27010 + *
27011 + * This program is distributed in the hope that it will be useful,
27012 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
27013 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27014 + * GNU General Public License for more details.
27015 + *
27016 + * You should have received a copy of the GNU General Public License
27017 + * along with this program; if not, write to the Free Software
27018 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27019 + */
27020 +#ifndef _ABI_UW7_TYPES_H
27021 +#define _ABI_UW7_TYPES_H
27022 +
27023 +#ident "%W% %G%"
27024 +
27025 +/*
27026 + * UnixWare 7 type declarations.
27027 + */
27028 +#include <abi/svr4/types.h>    /* UnixWare is based on SVR4 */
27029 +
27030 +typedef svr4_dev_t     uw7_dev_t;
27031 +typedef u_int64_t      uw7_ino_t;
27032 +typedef svr4_mode_t    uw7_mode_t;
27033 +typedef svr4_nlink_t   uw7_nlink_t;
27034 +typedef svr4_uid_t     uw7_uid_t;
27035 +typedef svr4_gid_t     uw7_gid_t;
27036 +typedef int64_t                uw7_off_t;
27037 +typedef struct timeval uw7_timestruc_t;
27038 +
27039 +typedef u_int64_t      uw7_fsblkcnt64_t;
27040 +typedef u_int64_t      uw7_fsfilcnt64_t;
27041 +
27042 +
27043 +#define linux_to_uw7_dev_t(dev) \
27044 +       linux_to_svr4_dev_t(dev)
27045 +
27046 +#define linux_to_uw7_ino_t(ino) \
27047 +       linux_to_svr4_ino_t(ino)
27048 +
27049 +#define linux_to_uw7_uid_t(uid) \
27050 +       linux_to_svr4_uid_t(uid)
27051 +
27052 +#define linux_to_uw7_gid_t(gid) \
27053 +       linux_to_svr4_gid_t(gid)
27054 +
27055 +#endif /* _ABI_UW7_TYPES_H */
27056 diff -Nur kernel-source-2.6.16.orig/include/abi/wyse/net.h kernel-source-2.6.16/include/abi/wyse/net.h
27057 --- kernel-source-2.6.16.orig/include/abi/wyse/net.h    1970-01-01 10:00:00.000000000 +1000
27058 +++ kernel-source-2.6.16/include/abi/wyse/net.h 2006-04-27 18:50:24.000000000 +1000
27059 @@ -0,0 +1,59 @@
27060 +/*
27061 + *  Copyright (C) 1994  Mike Jagdis (jaggy@purplet.demon.co.uk)
27062 + */
27063 +
27064 +#ident "%W% %G%"
27065 +
27066 +/*
27067 + * Wyse extensions for 4.3 BSD TCP/IP in V/386 3.2.1A
27068 + */
27069 +#include <linux/ioctl.h>
27070 +
27071 +/* Get struct rtentry from linux/route.h - this should be compatible. */
27072 +#include <linux/route.h>
27073 +/* Get struct arpreq from linux/if_arp.h - this should be compatible. */
27074 +#include <linux/if_arp.h>
27075 +/* Get struct ifreq and struct ifconf from linux/if.h - these should
27076 + * be compatible. */
27077 +#include <linux/if.h>
27078 +
27079 +
27080 +/* Wyse use BSD style ioctls. This will warn us if we haven't got compatible
27081 + * structures :-).
27082 + */
27083 +
27084 +/* socket i/o controls */
27085 +#define        WVR3_SIOCSHIWAT         BSD__IOW('s',  0, int)  /* set high watermark */
27086 +#define        WVR3_SIOCGHIWAT         BSD__IOR('s',  1, int)  /* get high watermark */
27087 +#define        WVR3_SIOCSLOWAT         BSD__IOW('s',  2, int)  /* set low watermark */
27088 +#define        WVR3_SIOCGLOWAT         BSD__IOR('s',  3, int)  /* get low watermark */
27089 +#define        WVR3_SIOCATMARK         BSD__IOR('s',  7, int)  /* at oob mark? */
27090 +#define        WVR3_SIOCSPGRP          BSD__IOW('s',  8, int)  /* set process group */
27091 +#define        WVR3_SIOCGPGRP          BSD__IOR('s',  9, int)  /* get process group */
27092 +
27093 +#define        WVR3_SIOCADDRT          BSD__IOW('r', 10, struct rtentry)       /* add route */
27094 +#define        WVR3_SIOCDELRT          BSD__IOW('r', 11, struct rtentry)       /* delete route */
27095 +
27096 +#define        WVR3_SIOCSIFADDR        BSD__IOW('i', 12, struct ifreq) /* set ifnet address */
27097 +#define        WVR3_SIOCGIFADDR        BSD__IOWR('i',13, struct ifreq) /* get ifnet address */
27098 +#define        WVR3_SIOCSIFDSTADDR     BSD__IOW('i', 14, struct ifreq) /* set p-p address */
27099 +#define        WVR3_SIOCGIFDSTADDR     BSD__IOWR('i',15, struct ifreq) /* get p-p address */
27100 +#define        WVR3_SIOCSIFFLAGS       BSD__IOW('i', 16, struct ifreq) /* set ifnet flags */
27101 +#define        WVR3_SIOCGIFFLAGS       BSD__IOWR('i',17, struct ifreq) /* get ifnet flags */
27102 +#define        WVR3_SIOCGIFBRDADDR     BSD__IOWR('i',18, struct ifreq) /* get broadcast addr */
27103 +#define        WVR3_SIOCSIFBRDADDR     BSD__IOW('i',19, struct ifreq)  /* set broadcast addr */
27104 +#define        WVR3_SIOCGIFCONF        BSD__IOWR('i',20, struct ifconf)        /* get ifnet list */
27105 +#define        WVR3_SIOCGIFNETMASK     BSD__IOWR('i',21, struct ifreq) /* get net addr mask */
27106 +#define        WVR3_SIOCSIFNETMASK     BSD__IOW('i',22, struct ifreq)  /* set net addr mask */
27107 +#define        WVR3_SIOCGIFMETRIC      BSD__IOWR('i',23, struct ifreq) /* get IF metric */
27108 +#define        WVR3_SIOCSIFMETRIC      BSD__IOW('i',24, struct ifreq)  /* set IF metric */
27109 +#define        WVR3_SIOCSIFHADDR       BSD__IOW('i', 25, struct ifreq) /* set hardware addr */
27110 +#define        WVR3_SIOCGIFHADDR       BSD__IOWR('i',26, struct ifreq) /* get hardware addr */
27111 +#define        WVR3_SIOCRIFHADDR       BSD__IOW('i', 27, struct ifreq)     /* reset hardware addr */
27112 +
27113 +#define        WVR3_SIOCSARP           BSD__IOW('i', 30, struct arpreq)        /* set arp entry */
27114 +#define        WVR3_SIOCGARP           BSD__IOWR('i',31, struct arpreq)        /* get arp entry */
27115 +#define        WVR3_SIOCDARP           BSD__IOW('i', 32, struct arpreq)        /* delete arp entry */
27116 +
27117 +#define        WVR3_SIOCADDMULTI       BSD__IOW('i', 33, struct ifreq) /* set multicast addr */
27118 +#define        WVR3_SIOCDELMULTI       BSD__IOW('i', 34, struct ifreq) /* set multicast addr */
27119 diff -Nur kernel-source-2.6.16.orig/include/abi/wyse/sysent.h kernel-source-2.6.16/include/abi/wyse/sysent.h
27120 --- kernel-source-2.6.16.orig/include/abi/wyse/sysent.h 1970-01-01 10:00:00.000000000 +1000
27121 +++ kernel-source-2.6.16/include/abi/wyse/sysent.h      2006-04-27 18:50:24.000000000 +1000
27122 @@ -0,0 +1,51 @@
27123 +/*
27124 + * Copyright (c) 2001 Christoph Hellwig.
27125 + * All rights reserved.
27126 + *
27127 + * This program is free software; you can redistribute it and/or modify
27128 + * it under the terms of the GNU General Public License as published by
27129 + * the Free Software Foundation; either version 2 of the License, or
27130 + * (at your option) any later version.
27131 + *
27132 + * This program is distributed in the hope that it will be useful,
27133 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
27134 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27135 + * GNU General Public License for more details.
27136 + *
27137 + * You should have received a copy of the GNU General Public License
27138 + * along with this program; if not, write to the Free Software
27139 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27140 + */
27141 +#ifndef _ABI_WYSE_SYSENT_H
27142 +#define _ABI_WYSE_SYSENT_H
27143 +
27144 +#ident "%W% %G%"
27145 +
27146 +/*
27147 + * External function declarations for the Wyse V/386 syscall table.
27148 + */
27149 +
27150 +struct sockaddr;
27151 +
27152 +
27153 +/* ptrace.c */
27154 +extern int wyse_ptrace(int, int, u_long, u_long);
27155 +
27156 +/* socket.c */
27157 +extern int wyse_gethostname(char *, int);
27158 +extern int wyse_getdomainname(char *, int);
27159 +extern int wyse_wait3(int *);
27160 +extern int wyse_socket(int, int, int);
27161 +extern int wyse_setsockopt(int, int, int, char *, int);
27162 +extern int wyse_getsockopt(int, int, int, char *, int *);
27163 +extern int wyse_recvfrom(int, void *, size_t, unsigned,
27164 +               struct sockaddr *, int *);
27165 +extern int wyse_recv(int, void *, size_t, unsigned);
27166 +extern int wyse_sendto(int, void *, size_t, unsigned,
27167 +               struct sockaddr *, int);
27168 +extern int wyse_send(int, void *, size_t, unsigned);
27169 +
27170 +/* syslocal.c */
27171 +extern int wyse_syslocal(struct pt_regs *);
27172 +
27173 +#endif /* _ABI_WYSE_SYSENT_H */
27174 diff -Nur kernel-source-2.6.16.orig/include/asm-i386/abi_machdep.h kernel-source-2.6.16/include/asm-i386/abi_machdep.h
27175 --- kernel-source-2.6.16.orig/include/asm-i386/abi_machdep.h    1970-01-01 10:00:00.000000000 +1000
27176 +++ kernel-source-2.6.16/include/asm-i386/abi_machdep.h 2006-04-27 18:50:24.000000000 +1000
27177 @@ -0,0 +1,97 @@
27178 +/*
27179 + * Copyright (c) 2001 Caldera Deutschland GmbH.
27180 + * Copyright (c) 2001 Christoph Hellwig.
27181 + * All rights reserved.
27182 + *
27183 + * This program is free software; you can redistribute it and/or modify
27184 + * it under the terms of the GNU General Public License as published by
27185 + * the Free Software Foundation; either version 2 of the License, or
27186 + * (at your option) any later version.
27187 + *
27188 + * This program is distributed in the hope that it will be useful,
27189 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
27190 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27191 + * GNU General Public License for more details.
27192 + *
27193 + * You should have received a copy of the GNU General Public License
27194 + * along with this program; if not, write to the Free Software
27195 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27196 + */
27197 +#ifndef _ASM_ABI_MACHDEP_H
27198 +#define _ASM_ABI_MACHDEP_H
27199 +
27200 +#include <linux/ptrace.h>
27201 +
27202 +/**
27203 + * get_syscall_parameter - get syscall parameter
27204 + * @regs: saved register contents
27205 + * @n: nth syscall to get
27206 + *
27207 + * This function gets the nth syscall parameter if
27208 + * the syscall got a &struct pt_regs * passed instead
27209 + * of the traditional C calling convention.
27210 + */
27211 +static __inline unsigned long
27212 +get_syscall_parameter(struct pt_regs *regs, int n)
27213 +{
27214 +       unsigned long r;
27215 +
27216 +       __get_user(r, ((unsigned long *)regs->esp)+(n+1));
27217 +       return r;
27218 +}
27219 +
27220 +/**
27221 + * set_error - set error number
27222 + * @regs: saved register contents
27223 + * @errno: error number
27224 + *
27225 + * This function sets the syscall error return for lcall7
27226 + * calling conventions to @errno.
27227 + */
27228 +static __inline void
27229 +set_error(struct pt_regs *regs, int errno)
27230 +{
27231 +       regs->eax = errno;
27232 +       regs->eflags |= 1;
27233 +}
27234 +
27235 +/**
27236 + * clear_error - clear error return flag
27237 + * @regs: saved register contents
27238 + *
27239 + * This funtion clears the flag that indicates an error
27240 + * return for lcall7-based syscalls.
27241 + */
27242 +static __inline void
27243 +clear_error(struct pt_regs *regs)
27244 +{
27245 +       regs->eflags &= ~1;
27246 +}
27247 +
27248 +/**
27249 + * set_result - set syscall return value
27250 + * @regs: saved register contents
27251 + *
27252 + * This funtion sets the return value for syscalls
27253 + * that have the saved register set calling convention.
27254 + */
27255 +static __inline void
27256 +set_result(struct pt_regs *regs, int r)
27257 +{
27258 +       regs->eax = r;
27259 +}
27260 +
27261 +/**
27262 + * get_result - get syscall return value
27263 + * @regs: saved register contents
27264 + *
27265 + * This funtion gets the return value for syscalls
27266 + * that have the saved register set calling convention.
27267 + */
27268 +static __inline int
27269 +get_result(struct pt_regs *regs)
27270 +{
27271 +       return regs->eax;
27272 +}
27273 +
27274 +#endif /* _ASM_ABI_MACHDEP_H */
27275 diff -Nur kernel-source-2.6.16.orig/include/asm-i386/elf.h kernel-source-2.6.16/include/asm-i386/elf.h
27276 --- kernel-source-2.6.16.orig/include/asm-i386/elf.h    2006-04-27 18:30:02.000000000 +1000
27277 +++ kernel-source-2.6.16/include/asm-i386/elf.h 2006-04-27 18:50:24.000000000 +1000
27278 @@ -111,7 +111,20 @@
27279  #define ELF_PLATFORM  (system_utsname.machine)
27280  
27281  #ifdef __KERNEL__
27282 -#define SET_PERSONALITY(ex, ibcs2) do { } while (0)
27283 +
27284 +#include <asm/elfmark.h>
27285 +
27286 +#define SET_PERSONALITY(ex, ibcs2) \
27287 +do { \
27288 +      unsigned long personality = abi_defhandler_elf; \
27289 +      if ((ex).e_flags == EF_386_UW7) \
27290 +              personality = PER_UW7; \
27291 +      else if ((ex).e_flags == EF_386_OSR5) \
27292 +              personality = PER_OSR5; \
27293 +      else if (ibcs2) \
27294 +              personality = abi_defhandler_libcso; \
27295 +      set_personality(personality); \
27296 +} while (0)
27297  
27298  /*
27299   * An executable for which elf_read_implies_exec() returns TRUE will
27300 diff -Nur kernel-source-2.6.16.orig/include/asm-i386/elfmark.h kernel-source-2.6.16/include/asm-i386/elfmark.h
27301 --- kernel-source-2.6.16.orig/include/asm-i386/elfmark.h        1970-01-01 10:00:00.000000000 +1000
27302 +++ kernel-source-2.6.16/include/asm-i386/elfmark.h     2006-04-27 18:50:24.000000000 +1000
27303 @@ -0,0 +1,37 @@
27304 +/*
27305 + * elfmark - set ELF header e_flags value to an abi-specific value.
27306 + *
27307 + * This utility is used for marking ELF binaries (including shared libraries)
27308 + * for use by the UW Linux kernel module that provides exec domain for PER_UW7
27309 + * personality. Run only on IA32 architectures.
27310 + *
27311 + * Authors - Tigran Aivazian <tigran@veritas.com>,
27312 + *             Christoph Hellwig <hch@caldera.de>
27313 + *
27314 + * This software is under GPL
27315 + */
27316 +#ifndef _ELFMARK_H
27317 +#define _ELFMARK_H
27318 +
27319 +/*
27320 + * The e_flags value for SCO UnixWare 7/UDK binaries
27321 + */
27322 +#ifndef EF_386_UW7
27323 +#define EF_386_UW7     0x314B4455
27324 +#endif
27325 +
27326 +/*
27327 + * The e_flags value for SCO OpenServer 5 binaries.
27328 + */
27329 +#ifndef EF_386_OSR5
27330 +#define EF_386_OSR5    0x3552534f
27331 +#endif
27332 +
27333 +/*
27334 + * e_flags value with no special meaning.
27335 + */
27336 +#ifndef EF_386_NONE
27337 +#define EF_386_NONE    0
27338 +#endif
27339 +
27340 +#endif /* _ELFMARK_H */
27341 diff -Nur kernel-source-2.6.16.orig/include/asm-i386/namei.h kernel-source-2.6.16/include/asm-i386/namei.h
27342 --- kernel-source-2.6.16.orig/include/asm-i386/namei.h  2006-03-20 15:53:29.000000000 +1000
27343 +++ kernel-source-2.6.16/include/asm-i386/namei.h       2006-04-27 18:50:24.000000000 +1000
27344 @@ -1,4 +1,4 @@
27345 -/* $Id$
27346 +/* $Id$
27347   * linux/include/asm-i386/namei.h
27348   *
27349   * Included from linux/fs/namei.c
27350 @@ -7,11 +7,55 @@
27351  #ifndef __I386_NAMEI_H
27352  #define __I386_NAMEI_H
27353  
27354 -/* This dummy routine maybe changed to something useful
27355 - * for /usr/gnemul/ emulation stuff.
27356 - * Look at asm-sparc/namei.h for details.
27357 +#include <linux/config.h>
27358 +
27359 +/*
27360 + * The base directory for our emulations.
27361 + *  - sparc uses usr/gmemul here.
27362 + */
27363 +#define I386_EMUL_BASE         "emul/"
27364 +
27365 +/*
27366 + * We emulate quite a lot operting systems...
27367   */
27368 +#define I386_SVR4_EMUL         I386_EMUL_BASE "/svr4/"
27369 +#define I386_SVR3_EMUL         I386_EMUL_BASE "/svr3/"
27370 +#define I386_SCOSVR3_EMUL      I386_EMUL_BASE "/sco/"
27371 +#define I386_OSR5_EMUL         I386_EMUL_BASE "/osr5/"
27372 +#define I386_WYSEV386_EMUL     I386_EMUL_BASE "/wyse/"
27373 +#define I386_ISCR4_EMUL                I386_EMUL_BASE "/isc/"
27374 +#define I386_BSD_EMUL          I386_EMUL_BASE "/bsd/"
27375 +#define I386_XENIX_EMUL                I386_EMUL_BASE "/xenix/"
27376 +#define I386_SOLARIS_EMUL      I386_EMUL_BASE "/solaris/"
27377 +#define I386_UW7_EMUL          I386_EMUL_BASE "/uw7/"
27378  
27379 -#define __emul_prefix() NULL
27380 +static inline char *__emul_prefix(void)
27381 +{
27382 +#if defined(CONFIG_ABI) || defined (CONFIG_ABI_MODULE)
27383 +       switch (get_cur_personality()) {
27384 +       case PER_SVR4:
27385 +               return I386_SVR4_EMUL;
27386 +       case PER_SVR3:
27387 +               return I386_SVR3_EMUL;
27388 +       case PER_SCOSVR3:
27389 +               return I386_SCOSVR3_EMUL;
27390 +       case PER_OSR5:
27391 +               return I386_OSR5_EMUL;
27392 +       case PER_WYSEV386:
27393 +               return I386_WYSEV386_EMUL;
27394 +       case PER_ISCR4:
27395 +               return I386_ISCR4_EMUL;
27396 +       case PER_BSD:
27397 +               return I386_BSD_EMUL;
27398 +       case PER_XENIX:
27399 +               return I386_XENIX_EMUL;
27400 +       case PER_SOLARIS:
27401 +               return I386_SOLARIS_EMUL;
27402 +       case PER_UW7:
27403 +               return I386_UW7_EMUL;
27404 +       }
27405 +#endif /* CONFIG_ABI || CONFIG_ABI_MODULE */
27406 +       return NULL;
27407 +}
27408  
27409  #endif /* __I386_NAMEI_H */
27410 diff -Nur kernel-source-2.6.16.orig/include/asm-i386/signal.h kernel-source-2.6.16/include/asm-i386/signal.h
27411 --- kernel-source-2.6.16.orig/include/asm-i386/signal.h 2006-03-20 15:53:29.000000000 +1000
27412 +++ kernel-source-2.6.16/include/asm-i386/signal.h      2006-04-27 18:50:24.000000000 +1000
27413 @@ -218,6 +218,7 @@
27414  }
27415  
27416  struct pt_regs;
27417 +extern asmlinkage int signal_suspend(struct pt_regs * regs, old_sigset_t mask);
27418  
27419  #define ptrace_signal_deliver(regs, cookie)            \
27420         do {                                            \
27421 diff -Nur kernel-source-2.6.16.orig/include/asm-i386/unistd.h kernel-source-2.6.16/include/asm-i386/unistd.h
27422 --- kernel-source-2.6.16.orig/include/asm-i386/unistd.h 2006-03-20 15:53:29.000000000 +1000
27423 +++ kernel-source-2.6.16/include/asm-i386/unistd.h      2006-04-27 18:50:24.000000000 +1000
27424 @@ -442,6 +442,7 @@
27425  #include <linux/types.h>
27426  #include <linux/linkage.h>
27427  #include <asm/ptrace.h>
27428 +#include <asm/signal.h>         /* for old_sigset_t */
27429  
27430  /*
27431   * we need this inline - forking from kernel space will result
27432 @@ -472,7 +473,11 @@
27433                                 const struct sigaction __user *act,
27434                                 struct sigaction __user *oact,
27435                                 size_t sigsetsize);
27436 -
27437 +extern asmlinkage int sys_ipc(uint call, int first, int second,
27438 +                              int third, void *ptr, long fifth);
27439 +extern asmlinkage long sys_sigaltstack(const stack_t *uss, stack_t *uoss);
27440 +extern asmlinkage int sys_sigsuspend(int history0, int history1,
27441 +                                     old_sigset_t mask);
27442  #endif
27443  
27444  /*
27445 diff -Nur kernel-source-2.6.16.orig/include/asm-parisc/processor.h kernel-source-2.6.16/include/asm-parisc/processor.h
27446 --- kernel-source-2.6.16.orig/include/asm-parisc/processor.h    2006-03-20 15:53:29.000000000 +1000
27447 +++ kernel-source-2.6.16/include/asm-parisc/processor.h 2006-04-27 18:50:24.000000000 +1000
27448 @@ -279,7 +279,7 @@
27449   */
27450  
27451  #ifdef __LP64__
27452 -#define USER_WIDE_MODE (personality(current->personality) == PER_LINUX)
27453 +#define USER_WIDE_MODE (is_cur_personality_id(PERID_LINUX))
27454  #else
27455  #define USER_WIDE_MODE 0
27456  #endif
27457 diff -Nur kernel-source-2.6.16.orig/include/linux/fs.h kernel-source-2.6.16/include/linux/fs.h
27458 --- kernel-source-2.6.16.orig/include/linux/fs.h        2006-04-27 18:30:02.000000000 +1000
27459 +++ kernel-source-2.6.16/include/linux/fs.h     2006-04-27 18:50:24.000000000 +1000
27460 @@ -1702,6 +1702,18 @@
27461  
27462  extern int vfs_readdir(struct file *, filldir_t, void *);
27463  
27464 +#ifndef __ia64__
27465 +struct old_linux_dirent {
27466 +        unsigned long   d_ino;
27467 +        unsigned long   d_offset;
27468 +        unsigned short  d_namlen;
27469 +        char            d_name[1];
27470 +};
27471 +
27472 +extern asmlinkage long old_readdir(unsigned int fd,
27473 +                struct old_linux_dirent __user * dirent, unsigned int count);
27474 +#endif
27475 +
27476  extern int vfs_stat(char __user *, struct kstat *);
27477  extern int vfs_lstat(char __user *, struct kstat *);
27478  extern int vfs_stat_fd(int dfd, char __user *, struct kstat *);
27479 diff -Nur kernel-source-2.6.16.orig/include/linux/major.h kernel-source-2.6.16/include/linux/major.h
27480 --- kernel-source-2.6.16.orig/include/linux/major.h     2006-04-27 18:30:02.000000000 +1000
27481 +++ kernel-source-2.6.16/include/linux/major.h  2006-04-27 18:50:24.000000000 +1000
27482 @@ -55,6 +55,7 @@
27483  #define ACSI_MAJOR             28
27484  #define AZTECH_CDROM_MAJOR     29
27485  #define GRAPHDEV_MAJOR         29   /* SparcLinux & Linux/68k /dev/fb */
27486 +#define SOCKSYS_MAJOR          30   /* iBCS needs this for STREAMS-based TCP/IP */
27487  #define CM206_CDROM_MAJOR      32
27488  #define IDE2_MAJOR             33
27489  #define IDE3_MAJOR             34
27490 diff -Nur kernel-source-2.6.16.orig/include/linux/personality.h kernel-source-2.6.16/include/linux/personality.h
27491 --- kernel-source-2.6.16.orig/include/linux/personality.h       2006-03-20 15:53:29.000000000 +1000
27492 +++ kernel-source-2.6.16/include/linux/personality.h    2006-04-27 18:50:24.000000000 +1000
27493 @@ -8,16 +8,57 @@
27494  struct exec_domain;
27495  struct pt_regs;
27496  
27497 +typedef unsigned long personality_t;  /* type for full personality value */
27498 +typedef unsigned char per_id_t;/* type for base per id */
27499 +
27500  extern int             register_exec_domain(struct exec_domain *);
27501  extern int             unregister_exec_domain(struct exec_domain *);
27502  extern int             __set_personality(unsigned long);
27503  
27504  /*
27505 - * Flags for bug emulation.
27506 + * Sysctl variables related to binary emulation.
27507 + */
27508 +extern unsigned long abi_defhandler_coff;
27509 +extern unsigned long abi_defhandler_elf;
27510 +extern unsigned long abi_defhandler_lcall7;
27511 +extern unsigned long abi_defhandler_libcso;
27512 +extern int abi_fake_utsname;
27513 +
27514 +/*
27515 + * Basic personality ids (per_id).
27516 + *
27517 + * The per_id is occupying byte 0.
27518 + * (It has to fit into an unsigned char! -> per_id_t)
27519 + */
27520 +enum {
27521 +      PERID_LINUX =           0x00, /* native execution mode of os platform */
27522 +      PERID_SVR4 =            0x01,
27523 +      PERID_SVR3 =            0x02,
27524 +      PERID_SCOSVR3 =         0x03, /* and SCO-OS-R5 */
27525 +      PERID_WYSEV386 =        0x04,
27526 +      PERID_ISCR4 =           0x05,
27527 +      PERID_BSD =             0x06, /* and SUN OS */
27528 +      PERID_XENIX =           0x07,
27529 +      PERID_LINUX32 =         0x08, /* 32 bit mode on non-32 bit platforms */
27530 +      PERID_IRIX32 =          0x09, /* IRIX5 32-bit */
27531 +      PERID_IRIXN32 =         0x0a, /* IRIX6 new 32-bit */
27532 +      PERID_IRIX64 =          0x0b, /* IRIX6 64-bit */
27533 +      PERID_RISCOS =          0x0c,
27534 +      PERID_SOLARIS =         0x0d,
27535 +      PERID_UW7 =             0x0e,
27536 +      PERID_OSF4 =            0x0f, /* OSF/1 v4 */
27537 +      PERID_HPUX =            0x10,
27538 +      PERID_MASK =            0xff,
27539 +};
27540 +  
27541 +/*
27542 + * Flags for customizing the behaviour of a base personality id.
27543   *
27544 - * These occupy the top three bytes.
27545 + * The flags occupy bytes 1 trough 3. Byte 0 is for the base personality id.
27546 + * (Avoid defining the top bit, it will conflict with error returns.)
27547   */
27548  enum {
27549 +#if 1 /* only for compatibilty with old code */        
27550         ADDR_NO_RANDOMIZE =     0x0040000,      /* disable randomization of VA space */
27551         FDPIC_FUNCPTRS =        0x0080000,      /* userspace function ptrs point to descriptors
27552                                                  * (signal handling)
27553 @@ -28,8 +69,19 @@
27554         ADDR_LIMIT_32BIT =      0x0800000,
27555         SHORT_INODE =           0x1000000,
27556         WHOLE_SECONDS =         0x2000000,
27557 -       STICKY_TIMEOUTS =       0x4000000,
27558 +       STICKY_TIMEOUTS =       0x4000000,
27559         ADDR_LIMIT_3GB =        0x8000000,
27560 +#endif
27561 +        /*                              ffffffpp */
27562 +       PERF_MMAP_PAGE_ZERO =           0x00100000,
27563 +       PERF_ADDR_COMPAT_LAYOUT =       0x00200000,
27564 +       PERF_READ_IMPLIES_EXEC =        0x00400000,
27565 +       PERF_ADDR_LIMIT_32BIT =         0x00800000,
27566 +       PERF_SHORT_INODE =              0x01000000,
27567 +       PERF_WHOLE_SECONDS =            0x02000000,
27568 +       PERF_STICKY_TIMEOUTS =          0x04000000,
27569 +       PERF_ADDR_LIMIT_3GB =           0x08000000,
27570 +       PERF_MASK =                     0xFFFFFF00,
27571  };
27572  
27573  /*
27574 @@ -39,36 +91,34 @@
27575  #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC|ADDR_NO_RANDOMIZE)
27576  
27577  /*
27578 - * Personality types.
27579 - *
27580 - * These go in the low byte.  Avoid using the top bit, it will
27581 - * conflict with error returns.
27582 + * Predefined personality profiles.
27583   */
27584  enum {
27585 -       PER_LINUX =             0x0000,
27586 -       PER_LINUX_32BIT =       0x0000 | ADDR_LIMIT_32BIT,
27587 +       PER_LINUX =             PERID_LINUX,
27588 +       PER_LINUX_32BIT =       PERID_LINUX    | PERF_ADDR_LIMIT_32BIT,
27589 +       PER_SVR4 =              PERID_SVR4     | PERF_STICKY_TIMEOUTS | PERF_MMAP_PAGE_ZERO,
27590 +       PER_SVR3 =              PERID_SVR3     | PERF_STICKY_TIMEOUTS | PERF_SHORT_INODE,
27591 +       PER_SCOSVR3 =           PERID_SCOSVR3  | PERF_STICKY_TIMEOUTS |
27592 +                                                 PERF_WHOLE_SECONDS | PERF_SHORT_INODE,
27593         PER_LINUX_FDPIC =       0x0000 | FDPIC_FUNCPTRS,
27594 -       PER_SVR4 =              0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
27595 -       PER_SVR3 =              0x0002 | STICKY_TIMEOUTS | SHORT_INODE,
27596 -       PER_SCOSVR3 =           0x0003 | STICKY_TIMEOUTS |
27597 -                                        WHOLE_SECONDS | SHORT_INODE,
27598 -       PER_OSR5 =              0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS,
27599 -       PER_WYSEV386 =          0x0004 | STICKY_TIMEOUTS | SHORT_INODE,
27600 -       PER_ISCR4 =             0x0005 | STICKY_TIMEOUTS,
27601 -       PER_BSD =               0x0006,
27602 -       PER_SUNOS =             0x0006 | STICKY_TIMEOUTS,
27603 -       PER_XENIX =             0x0007 | STICKY_TIMEOUTS | SHORT_INODE,
27604 -       PER_LINUX32 =           0x0008,
27605 -       PER_LINUX32_3GB =       0x0008 | ADDR_LIMIT_3GB,
27606 -       PER_IRIX32 =            0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit */
27607 -       PER_IRIXN32 =           0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32-bit */
27608 -       PER_IRIX64 =            0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit */
27609 -       PER_RISCOS =            0x000c,
27610 -       PER_SOLARIS =           0x000d | STICKY_TIMEOUTS,
27611 -       PER_UW7 =               0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
27612 -       PER_OSF4 =              0x000f,                  /* OSF/1 v4 */
27613 -       PER_HPUX =              0x0010,
27614 -       PER_MASK =              0x00ff,
27615 +       PER_OSR5 =              PERID_SCOSVR3  | PERF_STICKY_TIMEOUTS | PERF_WHOLE_SECONDS,
27616 +       PER_WYSEV386 =          PERID_WYSEV386 | PERF_STICKY_TIMEOUTS | PERF_SHORT_INODE,
27617 +       PER_ISCR4 =             PERID_ISCR4    | PERF_STICKY_TIMEOUTS,
27618 +       PER_BSD =               PERID_BSD,
27619 +       PER_SUNOS =             PERID_BSD      | PERF_STICKY_TIMEOUTS,
27620 +       PER_XENIX =             PERID_XENIX    | PERF_STICKY_TIMEOUTS | PERF_SHORT_INODE,
27621 +       PER_LINUX32 =           PERID_LINUX32,
27622 +       PER_LINUX32_3GB =       PERID_LINUX32  | PERF_ADDR_LIMIT_3GB,
27623 +       PER_IRIX32 =            PERID_IRIX32   | PERF_STICKY_TIMEOUTS,/* IRIX5 32-bit */
27624 +       PER_IRIXN32 =           PERID_IRIXN32  | PERF_STICKY_TIMEOUTS,/* IRIX6 new 32-bit */
27625 +       PER_IRIX64 =            PERID_IRIX64   | PERF_STICKY_TIMEOUTS,/* IRIX6 64-bit */
27626 +       PER_RISCOS =            PERID_RISCOS,
27627 +       PER_SOLARIS =           PERID_SOLARIS  | PERF_STICKY_TIMEOUTS,
27628 +       PER_UW7 =               PERID_UW7      | PERF_STICKY_TIMEOUTS | PERF_MMAP_PAGE_ZERO,
27629 +       PER_OSF4 =              PERID_OSF4,/* OSF/1 v4 */
27630 +       PER_HPUX =              PERID_HPUX,
27631 +       PER_MASK =              PERID_MASK     | PERF_MASK,
27632 +       PER_QUERY =             0xffffffff, /* indicates query when passed to sys_personality */
27633  };
27634  
27635  
27636 @@ -83,8 +133,8 @@
27637  struct exec_domain {
27638         const char              *name;          /* name of the execdomain */
27639         handler_t               handler;        /* handler for syscalls */
27640 -       unsigned char           pers_low;       /* lowest personality */
27641 -       unsigned char           pers_high;      /* highest personality */
27642 +       per_id_t                pers_low;       /* lowest personality id for this execdomain */
27643 +       per_id_t                pers_high;      /* highest personality id for this execdomain */
27644         unsigned long           *signal_map;    /* signal mapping */
27645         unsigned long           *signal_invmap; /* reverse signal mapping */
27646         struct map_segment      *err_map;       /* error mapping */
27647 @@ -96,19 +146,72 @@
27648  };
27649  
27650  /*
27651 - * Return the base personality without flags.
27652 + * Return the base personality id of the given personality.
27653 + */
27654 +#define get_personality_id(personality)         ((personality) & PERID_MASK)
27655 +/* compatibility with old naming */
27656 +#define personality(personality)                get_personality_id(personality)
27657 +
27658 +/*
27659 + * Return the flags of the given personality.
27660   */
27661 -#define personality(pers)      (pers & PER_MASK)
27662 +#define get_personality_flags(personality)      ((personality) & PERF_MASK)
27663  
27664  /*
27665   * Personality of the currently running process.
27666   */
27667 -#define get_personality                (current->personality)
27668 +#define get_cur_personality()          (current->personality)
27669 +
27670 +/*
27671 + * Return the base personality id of current process.
27672 + */
27673 +#define get_cur_personality_id()       get_personality_id(get_cur_personality())
27674 +
27675 +/*
27676 + * Return the flags of the personality of current process.
27677 + */
27678 +#define get_cur_personality_flags()    get_personality_flags(get_cur_personality())
27679 +
27680 +/*
27681 + * Check if the personality of the current process matches with the given value.
27682 + */
27683 +#define is_cur_personality(personality) \
27684 +        (get_cur_personality() == (personality))
27685 +
27686 +/*
27687 + * Check if the pers id of the current userland process matches the given.
27688 + * No masking does apply to the given id!
27689 + */
27690 +#define is_cur_personality_id(per_id) \
27691 +        (get_cur_personality_id() == (per_id))
27692 +
27693 +/*
27694 + * Check if the personality id of the current userland process
27695 + * matches the personality id of the given personality code value.
27696 + */
27697 +#define is_cur_same_personality_id_as(personality) \
27698 +        (get_cur_personality_id() == get_personality_id(personality))
27699 +
27700 +/*
27701 + * Check if the current userland process has set one or more of the given flags.
27702 + * This macro works only with single flags!
27703 + */
27704 +#define is_cur_personality_flag(per_flag) \
27705 +        (get_cur_personality_flags() & (per_flag))
27706 +
27707 +/*
27708 + * Check if the current userland process has all of the given flags set.
27709 + * This macro works only with single flags!
27710 + */
27711 +#define is_cur_personality_all_flags(per_flags) \
27712 +        (get_cur_personality_flags() & (per_flags) == (per_flags))
27713  
27714  /*
27715 - * Change personality of the currently running process.
27716 + * Set a new personality for the current userland process (if not already set).
27717   */
27718 -#define set_personality(pers) \
27719 -       ((current->personality == pers) ? 0 : __set_personality(pers))
27720 +#define set_cur_personality(personality) \
27721 +        (is_cur_personality(personality) ? 0 : __set_personality(personality))
27722 +/* compatibility with old naming */
27723 +#define set_personality(personality) set_cur_personality(personality)
27724  
27725  #endif /* _LINUX_PERSONALITY_H */
27726 diff -Nur kernel-source-2.6.16.orig/include/linux/xout.h kernel-source-2.6.16/include/linux/xout.h
27727 --- kernel-source-2.6.16.orig/include/linux/xout.h      1970-01-01 10:00:00.000000000 +1000
27728 +++ kernel-source-2.6.16/include/linux/xout.h   2006-04-27 18:50:24.000000000 +1000
27729 @@ -0,0 +1,192 @@
27730 +/*
27731 + * Copyright (c) 1994  Mike Jagdis (jaggy@purplet.demon.co.uk)
27732 + */
27733 +#ifndef _ABI_XOUT_H_
27734 +#define _ABI_XOUT_H_
27735 +
27736 +#ident "%W% %G%"
27737 +
27738 +/*
27739 + * This file is based on available documentation for the Xenix x.out
27740 + * format. Much is missing here. There is just enough to allow us to
27741 + * support 386 small model and not a lot more.
27742 + */
27743 +
27744 +/*
27745 + * X.out header
27746 + */
27747 +struct xexec {
27748 +       u_short         x_magic;        /* magic number                 */
27749 +       u_short         x_ext;          /* size of header extension     */
27750 +
27751 +       /*
27752 +        * For segmented binaries the following sizes are the sums
27753 +        * of the segment sizes.
27754 +        */
27755 +       long            x_text;         /* size of text segments        */
27756 +       long            x_data;         /* size of initialized data     */
27757 +       long            x_bss;          /* size of uninitialized data   */
27758 +       long            x_syms;         /* size of symbol table         */
27759 +       long            x_reloc;        /* relocation table length      */
27760 +
27761 +       long            x_entry;        /* entry point                  */
27762 +       char            x_cpu;          /* cpu type and byte/word order */
27763 +       char            x_relsym;       /* undefined                    */
27764 +       u_short         x_renv;         /* run-time environment         */
27765 +};
27766 +
27767 +/*
27768 + * X.out header extension
27769 + */
27770 +struct xext {
27771 +       /*
27772 +        * These are unused.
27773 +        * */
27774 +       long            xe_trsize;      /* ???                          */
27775 +       long            xe_drsize;      /* ???                          */
27776 +       long            xe_tbase;       /* ???                          */
27777 +       long            xe_dbase;       /* ???                          */
27778 +
27779 +       long            xe_stksize;     /* stack size (if XE_FS set)    */
27780 +
27781 +       /*
27782 +        * The following are present if XE_SEG is set.
27783 +        */
27784 +       long            xe_segpos;      /* offset to segment table      */
27785 +       long            xe_segsize;     /* segment table size           */
27786 +       long            xe_mdtpos;      /* offset to machdep table      */
27787 +       long            xe_mdtsize;     /* machine dependent table size */
27788 +       char            xe_mdttype;     /* machine dependent table type */
27789 +       char            xe_pagesize;    /* file pagesize, in 512 units  */
27790 +       char            xe_ostype;      /* operating system type        */
27791 +       char            xe_osvers;      /* operating system version     */
27792 +       u_short         xe_eseg;        /* entry segment, machdep       */
27793 +       u_short         xe_sres;        /* reserved                     */
27794 +};
27795 +
27796 +/*
27797 + * X.out segment description.
27798 + */
27799 +struct xseg {
27800 +       u_short         xs_type;        /* segment type                 */
27801 +       u_short         xs_attr;        /* segment attributes           */
27802 +       u_short         xs_seg;         /* segment number               */
27803 +       char            xs_align;       /* log base 2 of alignment      */
27804 +       char            xs_cres;        /* unused                       */
27805 +       u_long          xs_filpos;      /* file position                */
27806 +       u_long          xs_psize;       /* physical size (in file)      */
27807 +       u_long          xs_vsize;       /* virtual size (in core)       */
27808 +       u_long          xs_rbase;       /* relocation base addr/offset  */
27809 +       u_short         xs_noff;        /* segment name table offset    */
27810 +       u_short         xs_sres;        /* unused                       */
27811 +       long            xs_lres;        /* unused                       */
27812 +};
27813 +
27814 +
27815 +/*
27816 + * Magic number for an x.out header.
27817 + */
27818 +#define X_MAGIC                0x0206  /* indicates x.out header */
27819 +
27820 +/*
27821 + * Codes for x_cpu.
27822 + */
27823 +#define XC_BSWAP       0x80    /* bytes swapped */
27824 +#define XC_WSWAP       0x40    /* words swapped */
27825 +#define XC_8086                0x04    /* I8086 */
27826 +#define XC_286         0x09    /* iAPX 80286 */
27827 +#define XC_286V                0x29    /* iAPX 80286, use xe_osver for version */
27828 +#define XC_386         0x0a    /* iAPX 80386 */
27829 +#define XC_186         0x0b    /* iAPX 80186 */
27830 +#define XC_CPU         0x3f    /* cpu mask */
27831 +
27832 +/*
27833 + * Flags for the run-time environment.
27834 + */
27835 +#define XE_V2          0x4000          /* version 2.x */
27836 +#define XE_V3          0x8000          /* version 3.x */
27837 +#define XE_OSV         0xc000          /* if XE_SEG use xe_osvers ... */
27838 +#define XE_V5          XE_OSV          /* else assume v5.x */
27839 +#define XE_VERS                0xc000          /* version mask */
27840 +
27841 +#define XE_5_3         0x2000          /* binary needs 5.3 functionality */
27842 +#define XE_LOCK                0x1000          /* Use Advisory locking */
27843 +#define XE_SEG         0x0800          /* segment table present */
27844 +#define XE_ABS         0x0400          /* absolute memory image (standalone) */
27845 +#define XE_ITER                0x0200          /* iterated text/data present */
27846 +#define XE_HDATA       0x0100          /* huge model data (never used) */
27847 +#define XE_VMOD                XE_HDATA        /* virtual module */
27848 +#define XE_FPH         0x0080          /* floating point hardware required */
27849 +#define XE_LTEXT       0x0040          /* large model text */
27850 +#define XE_LDATA       0x0020          /* large model data */
27851 +#define XE_OVER                0x0010          /* text overlay */
27852 +#define XE_FS          0x0008          /* fixed stack */
27853 +#define XE_PURE                0x0004          /* pure text */
27854 +#define XE_SEP         0x0002          /* separate I & D */
27855 +#define XE_EXEC                0x0001          /* executable */
27856 +
27857 +
27858 +/*
27859 + * Segment types.
27860 + */
27861 +#define        XS_TNULL        0       /* unused segment */
27862 +#define        XS_TTEXT        1       /* text segment */
27863 +#define        XS_TDATA        2       /* data segment */
27864 +#define        XS_TSYMS        3       /* symbol table segment */
27865 +#define        XS_TREL         4       /* relocation segment */
27866 +#define        XS_TSESTR       5       /* segment table's string table segment */
27867 +#define        XS_TGRPS        6       /* group definitions segment */
27868 +
27869 +#define        XS_TIDATA       64      /* iterated data */
27870 +#define        XS_TTSS         65      /* tss */
27871 +#define        XS_TLFIX        66      /* lodfix */
27872 +#define        XS_TDNAME       67      /* descriptor names */
27873 +#define        XS_TDTEXT       68      /* debug text segment */
27874 +#define        XS_TIDBG        XS_TDTEXT
27875 +#define        XS_TDFIX        69      /* debug relocation */
27876 +#define        XS_TOVTAB       70      /* overlay table */
27877 +#define        XS_T71          71
27878 +#define        XS_TSYSTR       72      /* symbol string table */
27879 +
27880 +/*
27881 + * Segment attributes.
27882 + */
27883 +#define XS_AMEM                0x8000  /* is a memory image */
27884 +
27885 +/*
27886 + * For text and data segment types
27887 + */
27888 +#define XS_AITER       0x0001  /* contains iteration records */
27889 +#define XS_AHUGE       0x0002  /* contains huge element */
27890 +#define XS_ABSS                0x0004  /* contains implicit BSS */
27891 +#define XS_APURE       0x0008  /* read only, shareable */
27892 +#define XS_AEDOWN      0x0010  /* expands downward (stack) */
27893 +#define XS_APRIV       0x0020  /* may not be combined */
27894 +#define XS_A32BIT      0x0040  /* is 32 bit */
27895 +
27896 +/*
27897 + * File position macros, valid only if !XE_SEG.
27898 + */
27899 +#define XEXTPOS(xp)    ((long) sizeof(struct xexec))
27900 +#define XTEXTPOS(xp)   (XEXTPOS(xp) + (long) (xp)->x_ext)
27901 +#define XDATAPOS(xp)   (XTEXTPOS(xp) + (xp)->x_text)
27902 +#define XBSSPOS(xp)    (XDATAPOS(xp) + (xp)->x_data)
27903 +#define XSYMPOS(xp)    (XDATAPOS(xp) + (xp)->x_data)
27904 +#define XRELPOS(xp)    (XSYMPOS(xp) + (xp)->x_syms)
27905 +#define XENDPOS(xp)    (XRELPOS(xp) + (xp)->x_reloc)
27906 +
27907 +#define XRTEXTPOS(xp, ep)      (XRELPOS(xp))
27908 +#define XRDATAPOS(xp, ep)      (XRELPOS(xp) + (ep)->xe_trsize)
27909 +
27910 +
27911 +/*
27912 + * Specials for the Linux Xenix 286 emulator.
27913 + *
27914 + * The base address that 286 segments are loaded above. This should be
27915 + * above memory used by the emulator overlay. Actual segment data
27916 + * starts slightly higher than this since we map the xexec and xext
27917 + * structures of the executable to this address.
27918 + */
27919 +#define X286_MAP_ADDR  0x4000000
27920 +
27921 +#endif /* _ABI_XOUT_H_ */
27922 diff -Nur kernel-source-2.6.16.orig/include/net/sock.h kernel-source-2.6.16/include/net/sock.h
27923 --- kernel-source-2.6.16.orig/include/net/sock.h        2006-04-27 18:30:02.000000000 +1000
27924 +++ kernel-source-2.6.16/include/net/sock.h     2006-04-27 18:50:24.000000000 +1000
27925 @@ -393,6 +393,7 @@
27926         SOCK_NO_LARGESEND, /* whether to sent large segments or not */
27927         SOCK_LOCALROUTE, /* route locally only, %SO_DONTROUTE setting */
27928         SOCK_QUEUE_SHRUNK, /* write queue has been shrunk recently */
27929 +       SOCK_BSDISM,
27930  };
27931  
27932  static inline void sock_copy_flags(struct sock *nsk, struct sock *osk)
27933 diff -Nur kernel-source-2.6.16.orig/init/main.c kernel-source-2.6.16/init/main.c
27934 --- kernel-source-2.6.16.orig/init/main.c       2006-04-27 18:29:59.000000000 +1000
27935 +++ kernel-source-2.6.16/init/main.c    2006-04-27 18:50:24.000000000 +1000
27936 @@ -47,6 +47,7 @@
27937  #include <linux/rmap.h>
27938  #include <linux/mempolicy.h>
27939  #include <linux/key.h>
27940 +#include <linux/hrtimer.h>
27941  
27942  #include <asm/io.h>
27943  #include <asm/bugs.h>
27944 diff -Nur kernel-source-2.6.16.orig/kernel/exec_domain.c kernel-source-2.6.16/kernel/exec_domain.c
27945 --- kernel-source-2.6.16.orig/kernel/exec_domain.c      2006-04-27 18:16:04.000000000 +1000
27946 +++ kernel-source-2.6.16/kernel/exec_domain.c   2006-04-27 18:52:46.000000000 +1000
27947 @@ -19,10 +19,14 @@
27948  #include <linux/types.h>
27949  
27950  
27951 -static void default_handler(int, struct pt_regs *);
27952 +#if !defined(CONFIG_ABI_LATE_PROBING)
27953 +static void lcall_default_handler(int, struct pt_regs *);
27954 +#else
27955 +static void lcall_autodetect_handler(int, struct pt_regs *);
27956 +#endif
27957  
27958 -static struct exec_domain *exec_domains = &default_exec_domain;
27959 -static DEFINE_RWLOCK(exec_domains_lock);
27960 +static struct exec_domain *exec_domains = &default_exec_domain; /* linked list of registered exed domains */
27961 +static DEFINE_RWLOCK(exec_domains_lock);                       /* access lock for linked list */
27962  
27963  
27964  static u_long ident_map[32] = {
27965 @@ -32,55 +36,127 @@
27966         24,     25,     26,     27,     28,     29,     30,     31
27967  };
27968  
27969 +#define PERID_DEFAULT           PERID_LINUX     /* Linux personality id. */
27970 +
27971  struct exec_domain default_exec_domain = {
27972         .name           = "Linux",              /* name */
27973 -       .handler        = default_handler,      /* lcall7 causes a seg fault. */
27974 -       .pers_low       = 0,                    /* PER_LINUX personality. */
27975 -       .pers_high      = 0,                    /* PER_LINUX personality. */
27976 +#if !defined(CONFIG_ABI_LATE_PROBING)
27977 +       .handler        = lcall_default_handler,/* any unknown lcall raises a segmentation fault */
27978 +#else
27979 +       .handler        = lcall_autodetect_handler,/* lcall 0x07 & 0x27 causes autoconfig or a seg fault. */
27980 +#endif
27981 +       .pers_low       = PERID_DEFAULT,        /* low personality id */
27982 +       .pers_high      = PERID_DEFAULT,        /* high personality id */
27983         .signal_map     = ident_map,            /* Identity map signals. */
27984         .signal_invmap  = ident_map,            /*  - both ways. */
27985  };
27986  
27987  
27988 +#if !defined(CONFIG_ABI_LATE_PROBING)
27989 +static void
27990 +lcall_default_handler(int segment, struct pt_regs *regp)
27991 +{
27992 +       /* raise a segfault for the current process */
27993 +       send_sig(SIGSEGV, current, 1);
27994 +}
27995 +#else
27996  static void
27997 -default_handler(int segment, struct pt_regs *regp)
27998 +lcall_autodetect_handler(int segment, struct pt_regs *regp)
27999  {
28000 -       set_personality(0);
28001 +       personality_t personality = PER_LINUX;
28002  
28003 -       if (current_thread_info()->exec_domain->handler != default_handler)
28004 -               current_thread_info()->exec_domain->handler(segment, regp);
28005 -       else
28006 +       /*
28007 +        * This may have been a static linked SVr4 binary, so we would
28008 +        * have the personality set incorrectly. Or it might have been
28009 +        * a Solaris/x86 binary. We can tell which because the former
28010 +        * uses lcall7, while the latter used lcall 0x27.
28011 +        * Try to find or load the appropriate personality, and fall back
28012 +        * to just forcing a SEGV.
28013 +        * Try to find or load the appropriate personality on first invocation.
28014 +        * If loading failed and handler is still default then raise a SEGV.
28015 +        *
28016 +        * XXX: this is IA32-specific and should be moved to the MD-tree.
28017 +        */
28018 +       switch (segment) {
28019 +#ifdef __i386__
28020 +       case 0x07:
28021 +               personality = abi_defhandler_lcall7;
28022 +               break;
28023 +       case 0x27:
28024 +               personality = PER_SOLARIS;
28025 +               break;
28026 +#endif
28027 +       }
28028 +       set_personality(personality);
28029 +
28030 +       if (current_thread_info()->exec_domain->handler == lcall_autodetect_handler)
28031 +       {
28032 +               /* we are still at the same handler - recursing impossible! */
28033 +               /* raise a segfault for the current process */
28034                 send_sig(SIGSEGV, current, 1);
28035 +       }
28036 +       else
28037 +       {
28038 +               /* identifying the needed handler at exec time succeeded. */
28039 +               /* recursively call these installed handler (one level deep) */
28040 +               current_thread_info()->exec_domain->handler(segment, regp);
28041 +       }
28042  }
28043 +#endif
28044  
28045  static struct exec_domain *
28046  lookup_exec_domain(u_long personality)
28047  {
28048         struct exec_domain *    ep;
28049 -       u_long                  pers = personality(personality);
28050 -               
28051 +       per_id_t per_id = get_personality_id(personality);
28052 +
28053 +       /* browse for id in list of exec domains */             
28054         read_lock(&exec_domains_lock);
28055         for (ep = exec_domains; ep; ep = ep->next) {
28056 -               if (pers >= ep->pers_low && pers <= ep->pers_high)
28057 +               if (per_id >= ep->pers_low && per_id <= ep->pers_high)
28058                         if (try_module_get(ep->module))
28059 +                       {
28060 +                               read_unlock(&exec_domains_lock);
28061                                 goto out;
28062 +                       }
28063         }
28064 +       read_unlock(&exec_domains_lock);
28065  
28066  #ifdef CONFIG_KMOD
28067 -       read_unlock(&exec_domains_lock);
28068 -       request_module("personality-%ld", pers);
28069 -       read_lock(&exec_domains_lock);
28070 +       /* request loading of all data bound to personality id */
28071 +       request_module("personality-%i", per_id);
28072  
28073 +       /* browse for id in list of exec domains - once again */
28074 +       read_lock(&exec_domains_lock);
28075         for (ep = exec_domains; ep; ep = ep->next) {
28076 -               if (pers >= ep->pers_low && pers <= ep->pers_high)
28077 +               if (per_id >= ep->pers_low && per_id <= ep->pers_high)
28078                         if (try_module_get(ep->module))
28079 +                       {
28080 +                               read_unlock(&exec_domains_lock);
28081                                 goto out;
28082 +                       }
28083         }
28084 +       read_unlock(&exec_domains_lock);
28085 +#endif
28086 +
28087 +       /* matching exec domain is still not availabel. */
28088 +#if !defined(CONFIG_ABI_LATE_PROBING)
28089 +       ep = NULL; /* error */
28090 +#else
28091 +#if 0
28092 +       printk(KERN_WARNING \
28093 +               "%s: personality-%i not found, using %i instead.\n",
28094 +               __FILE__, per_id, PER_DEFAULT);
28095  #endif
28096  
28097 +       /* we will start with default exec domain. */
28098 +       /* this will allow simple programs (mov/ret) to fully execute. */
28099 +       /* complex programs will run until the very first syscall. */
28100 +       /* then the syscall handler will attempt switch the identity again. */
28101         ep = &default_exec_domain;
28102 +#endif
28103 +  
28104  out:
28105 -       read_unlock(&exec_domains_lock);
28106         return (ep);
28107  }
28108  
28109 @@ -138,26 +214,37 @@
28110         struct exec_domain      *ep, *oep;
28111  
28112         ep = lookup_exec_domain(personality);
28113 +       if(!ep)
28114 +               return -ENOEXEC;
28115 +
28116 +       /* if the needed exec domain is already set for this process
28117 +         then we save the works for registering with the new fs
28118 +         and releasing the old fs and exec_domain,
28119 +         we just have to update the personality to this process */
28120         if (ep == current_thread_info()->exec_domain) {
28121                 current->personality = personality;
28122                 module_put(ep->module);
28123                 return 0;
28124         }
28125  
28126 +       /* when the new fs is already bound to the current process */
28127         if (atomic_read(&current->fs->count) != 1) {
28128                 struct fs_struct *fsp, *ofsp;
28129  
28130 +               /* register as client for the new fs by copying it */
28131                 fsp = copy_fs_struct(current->fs);
28132                 if (fsp == NULL) {
28133                         module_put(ep->module);
28134                         return -ENOMEM;
28135                 }
28136  
28137 +               /* replace the old with the new fs */
28138                 task_lock(current);
28139                 ofsp = current->fs;
28140                 current->fs = fsp;
28141                 task_unlock(current);
28142  
28143 +               /* quit as a client to the old fs */
28144                 put_fs_struct(ofsp);
28145         }
28146  
28147 @@ -166,17 +253,20 @@
28148          * current->fs.
28149          */
28150  
28151 +       /* replace the old with the new exec_domain */
28152         current->personality = personality;
28153         oep = current_thread_info()->exec_domain;
28154         current_thread_info()->exec_domain = ep;
28155         set_fs_altroot();
28156  
28157 +       /* quit as client for the old exec_domain */
28158         module_put(oep->module);
28159 +
28160         return 0;
28161  }
28162  
28163  int
28164 -get_exec_domain_list(char *page)
28165 +get_exec_domain_list(char *page) /* handler for /proc/execdomains */
28166  {
28167         struct exec_domain      *ep;
28168         int                     len = 0;
28169 @@ -195,11 +285,12 @@
28170  {
28171         u_long old = current->personality;
28172  
28173 -       if (personality != 0xffffffff) {
28174 -               set_personality(personality);
28175 -               if (current->personality != personality)
28176 -                       return -EINVAL;
28177 -       }
28178 +        if (personality == PER_QUERY)
28179 +                return (long)old;
28180 +
28181 +        set_personality(personality);
28182 +        if (get_cur_personality() != personality)
28183 +                return -EINVAL;
28184  
28185         return (long)old;
28186  }
28187 @@ -208,3 +299,100 @@
28188  EXPORT_SYMBOL(register_exec_domain);
28189  EXPORT_SYMBOL(unregister_exec_domain);
28190  EXPORT_SYMBOL(__set_personality);
28191 +
28192 +/*
28193 + * We have to have all sysctl handling for the Linux-ABI
28194 + * in one place as the dynamic registration of sysctls is
28195 + * horribly crufty in Linux <= 2.4.
28196 + *
28197 + * I hope the new sysctl schemes discussed for future versions
28198 + * will obsolete this.
28199 + *
28200 + *                             --hch
28201 + */
28202 +
28203 +u_long abi_defhandler_coff = PER_SCOSVR3;
28204 +u_long abi_defhandler_elf = PER_LINUX;
28205 +u_long abi_defhandler_lcall7 = PER_SVR4;
28206 +u_long abi_defhandler_libcso = PER_SVR4;
28207 +u_int abi_traceflg;
28208 +int abi_fake_utsname;
28209 +
28210 +static struct ctl_table abi_table[] = {
28211 +       {
28212 +               .ctl_name       = ABI_DEFHANDLER_COFF,
28213 +               .procname       = "defhandler_coff",
28214 +               .data           = &abi_defhandler_coff,
28215 +               .maxlen         = sizeof(int),
28216 +               .mode           = 0644,
28217 +               .proc_handler   = &proc_doulongvec_minmax,
28218 +       },
28219 +       {
28220 +               .ctl_name       = ABI_DEFHANDLER_ELF,
28221 +               .procname       = "defhandler_elf",
28222 +               .data           = &abi_defhandler_elf,
28223 +               .maxlen         = sizeof(int),
28224 +               .mode           = 0644,
28225 +               .proc_handler   = &proc_doulongvec_minmax,
28226 +       },
28227 +       {
28228 +               .ctl_name       = ABI_DEFHANDLER_LCALL7,
28229 +               .procname       = "defhandler_lcall7",
28230 +               .data           = &abi_defhandler_lcall7,
28231 +               .maxlen         = sizeof(int),
28232 +               .mode           = 0644,
28233 +               .proc_handler   = &proc_doulongvec_minmax,
28234 +       },
28235 +       {
28236 +               .ctl_name       = ABI_DEFHANDLER_LIBCSO,
28237 +               .procname       = "defhandler_libcso",
28238 +               .data           = &abi_defhandler_libcso,
28239 +               .maxlen         = sizeof(int),
28240 +               .mode           = 0644,
28241 +               .proc_handler   = &proc_doulongvec_minmax,
28242 +       },
28243 +       {
28244 +               .ctl_name       = ABI_TRACE,
28245 +               .procname       = "trace",
28246 +               .data           = &abi_traceflg,
28247 +               .maxlen         = sizeof(u_int),
28248 +               .mode           = 0644,
28249 +               .proc_handler   = &proc_dointvec,
28250 +       },
28251 +       {
28252 +               .ctl_name       = ABI_FAKE_UTSNAME,
28253 +               .procname       = "fake_utsname",
28254 +               .data           = &abi_fake_utsname,
28255 +               .maxlen         = sizeof(int),
28256 +               .mode           = 0644,
28257 +               .proc_handler   = &proc_dointvec,
28258 +       },
28259 +       { .ctl_name = 0 }
28260 +};
28261 +
28262 +static struct ctl_table abi_root_table[] = {
28263 +       {
28264 +               .ctl_name       = CTL_ABI,
28265 +               .procname       = "abi",
28266 +               .mode           = 0555,
28267 +               .child          = abi_table,
28268 +       },
28269 +       { .ctl_name = 0 }
28270 +};
28271 +
28272 +static int __init
28273 +abi_register_sysctl(void)
28274 +{
28275 +       register_sysctl_table(abi_root_table, 1);
28276 +       return 0;
28277 +}
28278 +
28279 +__initcall(abi_register_sysctl);
28280 +
28281 +
28282 +EXPORT_SYMBOL(abi_defhandler_coff);
28283 +EXPORT_SYMBOL(abi_defhandler_elf);
28284 +EXPORT_SYMBOL(abi_defhandler_lcall7);
28285 +EXPORT_SYMBOL(abi_defhandler_libcso);
28286 +EXPORT_SYMBOL(abi_traceflg);
28287 +EXPORT_SYMBOL(abi_fake_utsname);
28288 diff -Nur kernel-source-2.6.16.orig/kernel/fork.c kernel-source-2.6.16/kernel/fork.c
28289 --- kernel-source-2.6.16.orig/kernel/fork.c     2006-04-27 18:30:02.000000000 +1000
28290 +++ kernel-source-2.6.16/kernel/fork.c  2006-04-27 18:50:25.000000000 +1000
28291 @@ -1670,3 +1670,9 @@
28292  bad_unshare_out:
28293         return err;
28294  }
28295 +
28296 +/* symbol exports for LinuxABI Sytem V R4 support */
28297 +/* for ease of use we are exporting those needed symbols permanently */
28298 +/* #if CONFIG_ABI_SVR4 == m */
28299 +EXPORT_SYMBOL(do_fork);
28300 +/* #endif */
28301 diff -Nur kernel-source-2.6.16.orig/kernel/Makefile kernel-source-2.6.16/kernel/Makefile
28302 --- kernel-source-2.6.16.orig/kernel/Makefile   2006-04-27 18:30:02.000000000 +1000
28303 +++ kernel-source-2.6.16/kernel/Makefile        2006-04-27 18:50:25.000000000 +1000
28304 @@ -8,7 +8,7 @@
28305             signal.o sys.o kmod.o workqueue.o pid.o \
28306             rcupdate.o extable.o params.o posix-timers.o \
28307             kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
28308 -           hrtimer.o
28309 +           hrtimer.o syscall_ksyms.o
28310  
28311  obj-y    += vserver/
28312  
28313 diff -Nur kernel-source-2.6.16.orig/kernel/syscall_ksyms.c kernel-source-2.6.16/kernel/syscall_ksyms.c
28314 --- kernel-source-2.6.16.orig/kernel/syscall_ksyms.c    1970-01-01 10:00:00.000000000 +1000
28315 +++ kernel-source-2.6.16/kernel/syscall_ksyms.c 2006-04-27 18:50:25.000000000 +1000
28316 @@ -0,0 +1,183 @@
28317 +/*
28318 + * Exports all Linux syscalls.
28319 + * Christoph Hellwig (hch@caldera.de), 2001
28320 + */
28321 +
28322 +#define __KERNEL_SYSCALLS__
28323 +#include <linux/unistd.h>
28324 +#include <linux/syscalls.h>
28325 +
28326 +#include <linux/config.h>
28327 +#include <linux/module.h>
28328 +#include <linux/personality.h>
28329 +#include <linux/msg.h>
28330 +#include <linux/sem.h>
28331 +#include <linux/shm.h>
28332 +#include <linux/fs.h>
28333 +
28334 +EXPORT_SYMBOL(sys_uselib);
28335 +EXPORT_SYMBOL(sys_sync);
28336 +EXPORT_SYMBOL(sys_fsync);
28337 +EXPORT_SYMBOL(sys_fdatasync);
28338 +EXPORT_SYMBOL(sys_dup);
28339 +EXPORT_SYMBOL(sys_dup2);
28340 +EXPORT_SYMBOL(sys_fcntl);
28341 +#if (BITS_PER_LONG == 32)
28342 +EXPORT_SYMBOL(sys_fcntl64);
28343 +#endif
28344 +EXPORT_SYMBOL(sys_ioctl);
28345 +EXPORT_SYMBOL(sys_link);
28346 +EXPORT_SYMBOL(sys_mkdir);
28347 +EXPORT_SYMBOL(sys_mknod);
28348 +EXPORT_SYMBOL(sys_rename);
28349 +EXPORT_SYMBOL(sys_rmdir);
28350 +EXPORT_SYMBOL(sys_symlink);
28351 +EXPORT_SYMBOL(sys_unlink);
28352 +EXPORT_SYMBOL(sys_umount);
28353 +EXPORT_SYMBOL(sys_oldumount);
28354 +EXPORT_SYMBOL(sys_mount);
28355 +EXPORT_SYMBOL(sys_pivot_root);
28356 +EXPORT_SYMBOL(sys_access);
28357 +EXPORT_SYMBOL(sys_chdir);
28358 +EXPORT_SYMBOL(sys_fchdir);
28359 +EXPORT_SYMBOL(sys_chroot);
28360 +EXPORT_SYMBOL(sys_chmod);
28361 +EXPORT_SYMBOL(sys_fchmod);
28362 +EXPORT_SYMBOL(sys_chown);
28363 +EXPORT_SYMBOL(sys_lchown);
28364 +EXPORT_SYMBOL(sys_fchown);
28365 +EXPORT_SYMBOL(sys_close);
28366 +#if !defined(__alpha__)
28367 +EXPORT_SYMBOL(sys_creat);
28368 +#endif
28369 +EXPORT_SYMBOL(sys_open);
28370 +EXPORT_SYMBOL(sys_statfs);
28371 +EXPORT_SYMBOL(sys_fstatfs);
28372 +EXPORT_SYMBOL(sys_ftruncate);
28373 +EXPORT_SYMBOL(sys_ftruncate64);
28374 +EXPORT_SYMBOL(sys_truncate);
28375 +EXPORT_SYMBOL(sys_truncate64);
28376 +#if !defined(__alpha__) && !defined(__ia64__)
28377 +EXPORT_SYMBOL(sys_utime);
28378 +#endif
28379 +EXPORT_SYMBOL(sys_utimes);
28380 +EXPORT_SYMBOL(sys_vhangup);
28381 +#if !defined(__alpha__)
28382 +EXPORT_SYMBOL(sys_lseek);
28383 +#endif
28384 +EXPORT_SYMBOL(sys_llseek);
28385 +EXPORT_SYMBOL(sys_read);
28386 +EXPORT_SYMBOL(sys_readv);
28387 +EXPORT_SYMBOL(sys_pread64);
28388 +EXPORT_SYMBOL(sys_pwrite64);
28389 +EXPORT_SYMBOL(sys_write);
28390 +EXPORT_SYMBOL(sys_writev);
28391 +EXPORT_SYMBOL(old_readdir);
28392 +EXPORT_SYMBOL(sys_poll);
28393 +EXPORT_SYMBOL(sys_select);
28394 +EXPORT_SYMBOL(sys_readlink);
28395 +EXPORT_SYMBOL(sys_sysfs);
28396 +EXPORT_SYMBOL(sys_acct);
28397 +EXPORT_SYMBOL(sys_exit);
28398 +EXPORT_SYMBOL(sys_getitimer);
28399 +EXPORT_SYMBOL(sys_setitimer);
28400 +EXPORT_SYMBOL(sys_gettimeofday);
28401 +EXPORT_SYMBOL(sys_settimeofday);
28402 +EXPORT_SYMBOL(sys_stime);
28403 +EXPORT_SYMBOL(sys_time);
28404 +#if !defined(__alpha__)
28405 +EXPORT_SYMBOL(sys_nice);
28406 +#endif
28407 +EXPORT_SYMBOL(sys_sched_setscheduler);
28408 +EXPORT_SYMBOL(sys_sched_setparam);
28409 +EXPORT_SYMBOL(sys_sched_getscheduler);
28410 +EXPORT_SYMBOL(sys_sched_getparam);
28411 +EXPORT_SYMBOL(sys_sched_get_priority_max);
28412 +EXPORT_SYMBOL(sys_sched_get_priority_min);
28413 +EXPORT_SYMBOL(sys_sched_rr_get_interval);
28414 +EXPORT_SYMBOL(sys_kill);
28415 +EXPORT_SYMBOL(sys_rt_sigaction);
28416 +EXPORT_SYMBOL(sys_rt_sigpending);
28417 +EXPORT_SYMBOL(sys_rt_sigprocmask);
28418 +EXPORT_SYMBOL(sys_rt_sigtimedwait);
28419 +EXPORT_SYMBOL(sys_sigaltstack);
28420 +EXPORT_SYMBOL(sys_sigpending);
28421 +EXPORT_SYMBOL(sys_sigprocmask);
28422 +EXPORT_SYMBOL(sys_sigsuspend);
28423 +EXPORT_SYMBOL(sys_gethostname);
28424 +EXPORT_SYMBOL(sys_sethostname);
28425 +EXPORT_SYMBOL(sys_setdomainname);
28426 +EXPORT_SYMBOL(sys_getrlimit);
28427 +EXPORT_SYMBOL(sys_setsid);
28428 +EXPORT_SYMBOL(sys_getsid);
28429 +EXPORT_SYMBOL(sys_getpgid);
28430 +EXPORT_SYMBOL(sys_setpgid);
28431 +EXPORT_SYMBOL(sys_getgroups);
28432 +EXPORT_SYMBOL(sys_setgroups);
28433 +EXPORT_SYMBOL(sys_setpriority);
28434 +EXPORT_SYMBOL(sys_getpriority);
28435 +EXPORT_SYMBOL(sys_reboot);
28436 +EXPORT_SYMBOL(sys_setgid);
28437 +EXPORT_SYMBOL(sys_setuid);
28438 +EXPORT_SYMBOL(sys_times);
28439 +EXPORT_SYMBOL(sys_umask);
28440 +EXPORT_SYMBOL(sys_prctl);
28441 +EXPORT_SYMBOL(sys_setreuid);
28442 +EXPORT_SYMBOL(sys_setregid);
28443 +#if !defined(__alpha__) && !defined(__ia64__)
28444 +EXPORT_SYMBOL(sys_alarm);
28445 +#endif
28446 +#if !defined(__alpha__)
28447 +EXPORT_SYMBOL(sys_getpid);
28448 +EXPORT_SYMBOL(sys_getppid);
28449 +EXPORT_SYMBOL(sys_getuid);
28450 +EXPORT_SYMBOL(sys_geteuid);
28451 +EXPORT_SYMBOL(sys_getgid);
28452 +EXPORT_SYMBOL(sys_getegid);
28453 +#endif
28454 +EXPORT_SYMBOL(sys_gettid);
28455 +EXPORT_SYMBOL(sys_nanosleep);
28456 +#if defined(CONFIG_UID16)
28457 +EXPORT_SYMBOL(sys_setreuid16);
28458 +EXPORT_SYMBOL(sys_setregid16);
28459 +EXPORT_SYMBOL(sys_getgroups16);
28460 +EXPORT_SYMBOL(sys_setgroups16);
28461 +#endif
28462 +EXPORT_SYMBOL(sys_wait4);
28463 +EXPORT_SYMBOL(sys_waitpid);
28464 +EXPORT_SYMBOL(sys_sendfile);
28465 +EXPORT_SYMBOL(sys_brk);
28466 +EXPORT_SYMBOL(sys_msync);
28467 +EXPORT_SYMBOL(sys_madvise);
28468 +EXPORT_SYMBOL(sys_mincore);
28469 +EXPORT_SYMBOL(sys_munmap);
28470 +EXPORT_SYMBOL(sys_mprotect);
28471 +EXPORT_SYMBOL(sys_socket);
28472 +EXPORT_SYMBOL(sys_socketpair);
28473 +EXPORT_SYMBOL(sys_bind);
28474 +EXPORT_SYMBOL(sys_listen);
28475 +EXPORT_SYMBOL(sys_accept);
28476 +EXPORT_SYMBOL(sys_connect);
28477 +EXPORT_SYMBOL(sys_getsockname);
28478 +EXPORT_SYMBOL(sys_getpeername);
28479 +EXPORT_SYMBOL(sys_sendto);
28480 +EXPORT_SYMBOL(sys_send);
28481 +EXPORT_SYMBOL(sys_recvfrom);
28482 +EXPORT_SYMBOL(sys_setsockopt);
28483 +EXPORT_SYMBOL(sys_getsockopt);
28484 +EXPORT_SYMBOL(sys_shutdown);
28485 +EXPORT_SYMBOL(sys_sendmsg);
28486 +EXPORT_SYMBOL(sys_recvmsg);
28487 +EXPORT_SYMBOL(sys_socketcall);
28488 +
28489 +EXPORT_SYMBOL(sys_msgget);
28490 +EXPORT_SYMBOL(sys_msgsnd);
28491 +EXPORT_SYMBOL(sys_msgrcv);
28492 +EXPORT_SYMBOL(sys_msgctl);
28493 +EXPORT_SYMBOL(sys_semget);
28494 +EXPORT_SYMBOL(sys_semop);
28495 +EXPORT_SYMBOL(sys_semctl);
28496 +EXPORT_SYMBOL(sys_shmget);
28497 +EXPORT_SYMBOL(do_shmat);
28498 +EXPORT_SYMBOL(sys_shmdt);
28499 +EXPORT_SYMBOL(sys_shmctl);
28500 diff -Nur kernel-source-2.6.16.orig/Makefile kernel-source-2.6.16/Makefile
28501 --- kernel-source-2.6.16.orig/Makefile  2006-04-27 18:16:04.000000000 +1000
28502 +++ kernel-source-2.6.16/Makefile       2006-04-27 18:50:25.000000000 +1000
28503 @@ -464,6 +464,7 @@
28504  net-y          := net/
28505  libs-y         := lib/
28506  core-y         := usr/
28507 +abi-y          := abi/
28508  endif # KBUILD_EXTMOD
28509  
28510  ifeq ($(dot-config),1)
28511 @@ -560,12 +561,14 @@
28512  
28513  vmlinux-dirs   := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
28514                      $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
28515 -                    $(net-y) $(net-m) $(libs-y) $(libs-m)))
28516 +                    $(net-y) $(net-m) $(libs-y) $(libs-m) \
28517 +                    $(abi-y) $(abi-m)))
28518  
28519  vmlinux-alldirs        := $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \
28520                      $(init-n) $(init-) \
28521                      $(core-n) $(core-) $(drivers-n) $(drivers-) \
28522 -                    $(net-n)  $(net-)  $(libs-n)    $(libs-))))
28523 +                    $(net-n)  $(net-)  $(libs-n)    $(libs-) \
28524 +                    $(abi-n)  $(abi-))))
28525  
28526  init-y         := $(patsubst %/, %/built-in.o, $(init-y))
28527  core-y         := $(patsubst %/, %/built-in.o, $(core-y))
28528 @@ -574,6 +577,7 @@
28529  libs-y1                := $(patsubst %/, %/lib.a, $(libs-y))
28530  libs-y2                := $(patsubst %/, %/built-in.o, $(libs-y))
28531  libs-y         := $(libs-y1) $(libs-y2)
28532 +abi-y          := $(patsubst %/, %/built-in.o, $(abi-y))
28533  
28534  # Build vmlinux
28535  # ---------------------------------------------------------------------------
28536 @@ -603,7 +607,7 @@
28537  # System.map is generated to document addresses of all kernel symbols
28538  
28539  vmlinux-init := $(head-y) $(init-y)
28540 -vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y)
28541 +vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y) $(abi-y)
28542  vmlinux-all  := $(vmlinux-init) $(vmlinux-main)
28543  vmlinux-lds  := arch/$(ARCH)/kernel/vmlinux.lds
28544  
28545 diff -Nur kernel-source-2.6.16.orig/net/socket.c kernel-source-2.6.16/net/socket.c
28546 --- kernel-source-2.6.16.orig/net/socket.c      2006-04-27 18:30:02.000000000 +1000
28547 +++ kernel-source-2.6.16/net/socket.c   2006-04-27 18:50:25.000000000 +1000
28548 @@ -124,7 +124,7 @@
28549   *     in the operation structures but are done directly via the socketcall() multiplexor.
28550   */
28551  
28552 -static struct file_operations socket_file_ops = {
28553 +struct file_operations socket_file_ops = {
28554         .owner =        THIS_MODULE,
28555         .llseek =       no_llseek,
28556         .aio_read =     sock_aio_read,
28557 @@ -2121,7 +2121,7 @@
28558  }
28559  #endif /* CONFIG_PROC_FS */
28560  
28561 -/* ABI emulation layers need these two */
28562 +/* LinuxABI emulation layer modules do need these exports */
28563  EXPORT_SYMBOL(move_addr_to_kernel);
28564  EXPORT_SYMBOL(move_addr_to_user);
28565  EXPORT_SYMBOL(sock_create);
28566 @@ -2137,3 +2137,9 @@
28567  EXPORT_SYMBOL(sockfd_lookup);
28568  EXPORT_SYMBOL(kernel_sendmsg);
28569  EXPORT_SYMBOL(kernel_recvmsg);
28570 +
28571 +/* symbol exports for LinuxABI Sytem V R4 support */
28572 +/* for ease of use we are exporting those needed symbols permanently */
28573 +/* #if CONFIG_ABI_SVR4 == m */
28574 +EXPORT_SYMBOL(socket_file_ops);
28575 +/* #endif */
This page took 2.577962 seconds and 3 git commands to generate.