]> git.pld-linux.org Git - packages/kernel.git/blame - linux-abi-2.4.3-PLD.patch
- obsolete
[packages/kernel.git] / linux-abi-2.4.3-PLD.patch
CommitLineData
483622cb 1diff -uNr --exclude-from=dontdiff linux-2.4.3/Documentation/abi/00-INDEX linux/Documentation/abi/00-INDEX
2--- linux-2.4.3/Documentation/abi/00-INDEX Thu Jan 1 01:00:00 1970
3+++ linux/Documentation/abi/00-INDEX Fri Mar 30 16:12:20 2001
4@@ -0,0 +1,28 @@
5+00-INDEX
6+ - this file
7+COMPAT
8+ - a list of software that has run succesfull under iBCS
9+CREDITS
10+ - a list of people that have contributed to linux-abi or iBCS
11+ChangeLog
12+ - changelog of linux-abi
13+ChangeLog.ibcs
14+ - changelog of the iBCS project (up to 1998)
15+Error.map
16+ - mapping of error codes from Linux to various personalities
17+HINTS
18+ - FAQ-style Q&A
19+Local-X
20+ - help on local X interfaces
21+Notes.Signal
22+ - some notes on signal handling
23+Personality
24+ - an introduction into Linux personality support
25+README.first
26+ - read this first!
27+Syscall.map
28+ - the syscall mapping for certain personalities
29+TODO.ibcs
30+ - things to be done, leftovers from iBCS
31+
32+$Id$
33diff -uNr --exclude-from=dontdiff linux-2.4.3/Documentation/abi/COMPAT linux/Documentation/abi/COMPAT
34--- linux-2.4.3/Documentation/abi/COMPAT Thu Jan 1 01:00:00 1970
35+++ linux/Documentation/abi/COMPAT Fri Mar 30 16:12:20 2001
36@@ -0,0 +1,181 @@
37+C: This file contains details of programs that have been run under
38+C: Linux using the iBCS emulator. An entry here is no guarantee that
39+C: the program works 100% but does indicate that the major elements
40+C: of the program have been unable to exercise bugs in the emulator
41+C: unless otherwise noted.
42+C:
43+C: An entry in this file does not necessarily indicate that the vendor
44+C: or anyone else actually supports the package under Linux unless
45+C: there is a specific entry to that effect.
46+C:
47+C: Please add to this file - new entries, other releases, amendments
48+C: to existing entries etc.
49+C:
50+C: The layout of this file is intended to be both easy to browse and
51+C: easy to parse, allowing it to be formatted into documents in the
52+C: future. This hasn't happened yet though and might never happen :-).
53+C:
54+C: Key:
55+C: C = Comment
56+C: V = Vendor
57+C: S = Support details
58+C: O = Operating system compiled for
59+C: P = Product
60+C: R = Release(s) known to work
61+C: L = Libraries required
62+C: D = Description
63+C: N = Notes
64+C: T = Tester
65+
66+V: Applied Information Systems, Inc. (info@ais.com)
67+O: SCO
68+P: Xess (MOTIF Spreadsheet)
69+R: current
70+L: statically linked
71+N: A save-disabled demo is available in ftp.uu.net:/vendor/ais/
72+N: Get three files: README, gen.tar, and sco.tar.
73+N: Don't add a .Z or .gz to the end of the filenames; the files
74+N: inside are compressed. ~300K of online documentation is in
75+N: gen.tar.
76+N: If anyone decides to actually *buy* this product, *please*
77+N: mention that you will be running it under Linux. I promise
78+N: you that you will still get technical support (the majority
79+N: of our technical support staff run Linux at home) -- but if
80+N: enough people buy the product asking for a Linux version, my
81+N: employer will be willing to make the investment. Pass the
82+N: word on if you want to see a native-mode, high-quality
83+N: spreadsheet for Linux as much as I do...
84+N: michaelkjohnson
85+T: Michael K.Johnson <johnsonm@merengue.oit.unc.edu>
86+
87+V: Corel
88+O: SCO ODT
89+P: CorelDraw! 3.0 and friends.
90+R: 3.0
91+N: Requires X11, no character versions of these apps.
92+N: Everything seems to be statically linked, no extra libs
93+N: necessary. I had a few problems with my .xmodmap file
94+N: since CorelDraw wants all of the lower function keys to
95+N: be mapped to functions in the CorelDraw program. Uses a
96+N: networked license manager, it worked fine. My programs
97+N: did not install properly due to an install bug. The dir.
98+N: that contains the washes.3fx file and others must be hand
99+N: changed to mode 777 for CorelChart to work (This from
100+N: Corel tech support).
101+T: Doug Ledford <gdl297s@cnas.smsu.edu>
102+
103+V: Informix
104+O: SCO
105+P: Informix SQL Standard Engine
106+R: 4.00 & 5.01
107+L: /shlib/libc_s
108+T: Mike Jagdis <jaggy@purplet.demon.co.uk>
109+
110+V: Informix
111+O: SCO
112+P: Informix SQL Online Dynamic Server
113+R: 7.20.UD5
114+T: Mike Jagdis <jaggy@purplet.demon.co.uk>
115+
116+P: Informix INET
117+R: ???
118+N: INET is reputed to work too but I can't remember who
119+N: said that...
120+T: ???
121+
122+V: IXI
123+O: SCO
124+P: X.desktop
125+R: ???
126+L: /shlib/libnsl_s
127+N: The version of X.desktop tested is that shipped with
128+N: Uniplex Windows. Functionality is at least enough to
129+N: support Uniplex Windows.
130+T: Mike Jagdis <jaggy@purplet.demon.co.uk>
131+
132+V: Oracle
133+O: Interactive
134+P: Oracle
135+R: V6
136+L: /shlib/libnsl_s
137+T: Remete Gabor <rg@tomx.elte.hu>
138+
139+V: Soft-Tek
140+O: SCO
141+P: Tactician Plus (character and X)
142+R: 3.0
143+T: Brandon S. Allbery <bsa@kf8nh.wariat.org>
144+
145+V: SPSS Inc.
146+O: SCO
147+P: SPSS 5.0 for SCO UNIX
148+L: Motif, if you want to use the GUI
149+D: Statistical Package for the Social Sciences
150+N: SCO's cpio is not compatible with GNU's -- I had to dd all
151+N: floppys onto my hd and to concatenate them into one file.
152+N: I couldn't test the GUI since I had no Motif available.
153+T: Joerg Rade <jr@petz.han.de>
154+
155+V: Uniplex Limited
156+O: SCO
157+P: Uniplex / Uniplex Windows
158+R: 7.02
159+L: statically linked (Uniplex Windows requires libnsl_s)
160+N: Uniplex Windows is implemented using a version of IXI
161+N: X.desktop. It is this that requires libnsl_s.
162+T: Mike Jagdis <jaggy@purplet.demon.co.uk>
163+
164+V: V-Systems, Inc.
165+O: SCO
166+P: VSI*FAX (FxServer, FxScript, FxVision) (character and X)
167+R: FxServer 2.0.19, FxScript 1.1.05, FxVision 1.0.16
168+L: Statically linked
169+N: Needs localhost in the X server's access control list
170+N: even when using a local X connection.
171+N: This has not been tested with a modem connected as I
172+N: don't have a Multitech...
173+T: Mike Jagdis <jaggy@purplet.demon.co.uk>
174+
175+V: ViaCrypt
176+O: SCO
177+P: ViaCrypt PGP
178+R: 2.4
179+T: Mark C. Henderson <mch@sqwest.wimsey.bc.ca>
180+
181+V: WordPerfect Corporation
182+O: SCO
183+P: WordPerfect (character and X)
184+R: 5.1
185+L: Statically linked
186+N: Installation under Linux may require changes to some of
187+N: the WP install scripts. See the PROD.Patches/WP file
188+N: for details.
189+N:
190+N: WP uses a network license manager.
191+N:
192+N: For some reason WP use a partition floppy device rather
193+N: than the full block device. Linux does not have this so
194+N: you need to use dd to skip the first cylinder (track?)
195+N: when loading the floppies under Linux. See the HINTS
196+N: file for details.
197+N:
198+N: Fonts appear corrupt. See the HINTS file for a cure.
199+T: Mike Jagdis <jaggy@purplet.demon.co.uk>
200+
201+V: Z-Code Inc
202+O: SCO
203+P: Z-Mail
204+R: 3.2
205+L: Statically linked - Motif based.
206+N: Installation scripts work correctly.
207+N:
208+N: ZMail can use a network license manager or a license file.
209+N: Both are known to work.
210+N:
211+N: ZMail is a GUI-based mail program.
212+N:
213+N: You can download the binaries for ZMail via anonymous ftp
214+N: ftp@ncd.com
215+N: You will have to contact Z-Code to obtain an evaluation
216+N: license if you wish to try it out.
217+T: Eric Youngdale <eric@aib.com>
218diff -uNr --exclude-from=dontdiff linux-2.4.3/Documentation/abi/CREDITS linux/Documentation/abi/CREDITS
219--- linux-2.4.3/Documentation/abi/CREDITS Thu Jan 1 01:00:00 1970
220+++ linux/Documentation/abi/CREDITS Fri Mar 30 16:12:20 2001
221@@ -0,0 +1,79 @@
222+A (non-definitive) list of people who appear to have worked on the
223+emulator and, in some cases, what they appear to have done.
224+
225+This list is in no particular order.
226+
227+This list should probably be better maintained :-).
228+
229+If anyone feels that they are not properly credited here, send diffs to
230+this file.
231+
232+
233+========================================================================
234+
235+Brandon S. Allbery <bsa@kf8nh.wariat.org> or <kf8nh@kf8nh.ampr.org>
236+
237+Graham Adams <gadams@ddrive.demon.co.uk>
238+
239+Tor Arntsen <tor@tss.no> or <tor@spacetec.no>
240+ Emulator as of pl13
241+
242+Philip Balister <balister@vt.edu>
243+ Emulator as of pl13
244+ gdb for coff
245+
246+Alfred Longyear <longyear@netcom.com>
247+ COFF loader
248+ Emulator as of pl12
249+ Original author of libc_s. COFF version.
250+
251+Mike Jagdis <jaggy@purplet.demon.co.uk>
252+ Changes for loadable module version of the emulator.
253+ Multi-personality detection and syscall mapping.
254+ Error code mapping.
255+ Wyse V/386 socket interface.
256+ /dev/socksys socket interface.
257+ /dev/spx to Unix domain socket for local X connections.
258+ Named pipe to Unix domain socket open kludge.
259+ XTI/TLI STREAMS based networking interface.
260+ X.out loader for 386 Xenix binaries.
261+ BSD support.
262+ Trace dummy device.
263+ Segment (LDT) mapping for x.out binaries.
264+ Xenix 286 emulator overlay.
265+ Current source maintainer and primary developer.
266+
267+Joseph L. Portman III <baron@hebron.connected.com>
268+ Major emulator developer.
269+ libc_s
270+
271+Drew Sullivan <drew@lethe.north.net>
272+ Past emulator source maintainer.
273+
274+Eric Youngdale <eric@aib.com> (prev. <eric@cais.com> & <ericy@gnu.ai.mit.edu>)
275+ First cut of the emulator.
276+ ELF loader, plus memory manager and fs/exec.c modifications
277+ to allow multiple binary formats to be loaded.
278+ Keeper of the tsx-11 archive.
279+ libc_s (elf version), plus bugfixes, reorganization, etc.
280+ SVr4 portions of emulator.
281+
282+Karl Kiniger <ki@kretz.co.at>
283+ Interactive 4.0 binary recognition and special support.
284+
285+Remete Gabor <rg@tomx.elte.hu>
286+ Miscellaneous patches.
287+
288+Scott Michel <scottm@intime.com>
289+ SCO multiscreen ioctls.
290+
291+Stephan Riess <Stephan.Riess@Physik.TU-Muenchen.de>
292+ SCO tape ioctls.
293+
294+Peter Polte <peter@cat-productions.de>
295+ Xenix fcntl() file locking facilities.
296+
297+C.A. Lademann <cal@zls.com>
298+
299+Miguel de Icaza <miguel@roxanne.nuclecu.unam.mx>
300+ Sparc support.
301diff -uNr --exclude-from=dontdiff linux-2.4.3/Documentation/abi/ChangeLog linux/Documentation/abi/ChangeLog
302--- linux-2.4.3/Documentation/abi/ChangeLog Thu Jan 1 01:00:00 1970
303+++ linux/Documentation/abi/ChangeLog Fri Mar 30 16:26:49 2001
304@@ -0,0 +1,9 @@
305+2001-03-30 Christoph Hellwig <hch@sb.bsdonline.org>
306+
307+ linux-abi 2.4.3.0
308+
309+ * fix shared library support for COFF
310+ * x.out is now supported (again)
311+ * redo setting of personality based on ELF headers
312+ * get rid of CONFIG_ABI_TRACE (and a lot of nasty ifdefs)
313+ * added documentation, mostly from iBCS
314diff -uNr --exclude-from=dontdiff linux-2.4.3/Documentation/abi/ChangeLog.ibcs linux/Documentation/abi/ChangeLog.ibcs
315--- linux-2.4.3/Documentation/abi/ChangeLog.ibcs Thu Jan 1 01:00:00 1970
316+++ linux/Documentation/abi/ChangeLog.ibcs Fri Mar 30 16:12:20 2001
317@@ -0,0 +1,2769 @@
318+Thu Nov 5 21:45:41 GMT 1998
319+
320+ * Fixed the bug that lets reads and writes on /dev/socksys
321+ take out the kernel.
322+ -- Mike
323+
324+ * Added a kludge around for Sybase isql which appears to
325+ have initialised a struct sockaddr using:
326+ sa.sa_family = htons(AF_INET);
327+ I guess this works on SCO?
328+ -- Mike
329+
330+
331+Sat Oct 31 14:15:44 GMT 1998
332+
333+ * Documentation update.
334+
335+ * If we are doing a T_BIND_REQ with a null address we can
336+ ignore the connection backlog. Listening makes no sense
337+ but some software seems to set it 1 for the hell of it.
338+ -- Mike
339+
340+
341+Tue Oct 20 20:34:20 BST 1998
342+
343+ * Changed the debug messages printed when exec tracing
344+ sees a pointer error on an arg or env entry. It may not
345+ be a "real" error. It could be that we just cannot get
346+ a free page or perhaps the entry is too long for getname().
347+ Whatever, we do not really care at this point anyway.
348+ -- Mike
349+
350+
351+Sat Oct 17 20:24:59 BST 1998
352+
353+ * Documentation update for today's release.
354+ -- Mike
355+
356+
357+Thu Oct 15 21:39:16 BST 1998
358+
359+ * When checking personality only look at the base personality
360+ and ignore the flags. There is at least one case I can
361+ think of, PER_SHORT_INODE, where the personality should
362+ be considered the same even when the flags are different.
363+ -- Mike
364+
365+ * Added the location of the kernel source as an option
366+ in the CONFIG. Hopefully this will make it a little
367+ more obvious that iBCS is *dependant* on the kernel.
368+ -- Mike
369+
370+ * Set SO_BSDCOMPAT on sockets. SYSV has BSD handling of
371+ ICMP errors on UDP sockets rather than RFC conformance.
372+ I think...
373+ -- Mike
374+
375+
376+Wed Oct 14 22:50:48 BST 1998
377+
378+ * When using some user stack as temporary work space we
379+ only leave 1k between the work space and the real user
380+ stack. This is because Informix Dynamic Server uses
381+ threads with limited stack space and the idea of dropping
382+ 16k below what would normally be touched on a SCO system
383+ worries me a bit.
384+ -- Mike
385+
386+
387+Sun Oct 11 11:58:58 BST 1998
388+
389+ * Changed the Tools Makefile to install mkmnttab in
390+ /usr/bin. Informix Dynamic Server _requires_ a
391+ valid /etc/mnttab.
392+ -- Mike
393+
394+
395+Sun Oct 11 11:44:58 BST 1998
396+
397+ * When doing an I_PEEK or I_NREAD STREAMS ioctl we have
398+ to do a probe on sockets in case we need to generate
399+ a control message (e.g. T_CONN_IND) which should then
400+ be offered. This also allows T_CONN_IND messages to be
401+ returned in several MORECTL divided pieces should it
402+ ever be necessary. This is required by Informix Dynamic
403+ Server which does a poll then I_PEEK on a listening
404+ socket before actually picking up the connection. Dynamic
405+ Server is system call hell :-).
406+ -- Mike
407+
408+ * When we do a timod operation via an ioctl there seems
409+ to be no way to cope if the returned message is larger
410+ than the original request. We can't expect the app to
411+ come back for the extra and returning MORECTL to the
412+ app seems to confuse things. Therefore we just discard
413+ the excess. This case is required when an app (e.g.
414+ Informix Dynamic Server) tries to set SO_LINGER using
415+ an int instead of a struct linger via an ioctl.
416+ -- Mike
417+
418+ * Added some debug to the poll handler so we can see what
419+ is being polled.
420+ -- Mike
421+
422+ * More debug message changes.
423+ -- Mike
424+
425+ * Wrap SO_LINGER handling so we can survive if an int is
426+ passed instead of s struct linger. It seems that other
427+ systems do not do such robust error checking as Linux.
428+ Note that if an int is passed we probably do not do what
429+ other systems would but at least we don't give unexpected
430+ errors to broken applications.
431+ -- Mike
432+
433+
434+Sat Oct 10 15:58:29 BST 1998
435+
436+ * Added an entry to Doc/HINTS noting the the Informix
437+ Dynamic Server install requires an /etc/mnttab.
438+ -- Mike
439+
440+ * Wrong option length being passed through to setsockopt()
441+ from the TLI/XTI optmgmt routine.
442+ -- Mike
443+
444+ * When stating files only map "ext2" to "HTFS" for SCO
445+ programs - and then only if the filesystem name really
446+ was "ext2".
447+ -- Mike
448+
449+ * SCO has a different value for the _SC_PAGESIZE argument
450+ to sysconf() than SVR4. Informix wants it to work.
451+ -- Mike
452+
453+ * Hmmm, Informix Dynamic Server may or may not be looking
454+ at the major number on a socket. (I _think_ it does
455+ sometimes). It definitely checks that sockets have
456+ S_IFCHR set in their file modes though...
457+ -- Mike
458+
459+ * Changed some debug messages to make it easier to read
460+ logs when more than one iBCS handled process is running.
461+ -- Mike
462+
463+ * If we get a STREAMS ioctl on a file descriptor only
464+ initialize the socksys handler on it if it is not
465+ already a socket but does belong to the socksys device.
466+ -- Mike
467+
468+
469+Thu Oct 8 21:20:43 BST 1998
470+
471+ * When punting a pseudo device transport provider to a
472+ socket copy the device numbers between the inodes. This
473+ is because Informix Dynamic Server stats the pseudo
474+ device node (/dev/socksys) then stats the socket it
475+ gets and compares the major numbers. Sheesh...
476+ -- Mike
477+
478+ * If socksys_close gets something that is not a socket
479+ it is probably the original pseudo device which was
480+ opened just for an ioctl or two. This is not an error.
481+ -- Mike
482+
483+ * Some programs, notably the Informix Dynamic Server
484+ install program compare the filesystem name from a
485+ stat or sysfs against their own hard coded list of
486+ known "real" filesystems. Hence we call "ext2" "HTFS"
487+ instead for SCO processes.
488+ -- Mike
489+
490+ * Informix DS also checks the release part of the utsname
491+ data to make sure it says "3.2v5.0.0". So now the
492+ utsname struct looks even more like SCO.
493+ -- Mike
494+
495+ * Only dump the ctl part of messages in timod if
496+ tracing is enabled.
497+ -- Mike
498+
499+ * SCO has statvfs in the same place as SVR4 but they have
500+ added a field slap bang in the middle of the struct to
501+ allow some inodes to be reserved for root in much the
502+ same way that some blocks may be reserved.
503+ -- Mike
504+
505+
506+Thu Oct 8 20:48:46 BST 1998
507+
508+ * On timod bind and connect the size of the address is
509+ allowed to be the _used_ bytes whereas the underlying
510+ socket functions require the _total_ bytes. This is
511+ a problem for Sybase.
512+ -- Mike
513+
514+
515+Sun Aug 30 21:49:46 BST 1998
516+
517+ * Changed socksys.c to handle new file_operations struct
518+ in kernel 2.1.119 and later.
519+ -- Mike
520+
521+
522+Sat Aug 22 19:57:01 BST 1998
523+
524+ * Fixes and additions to user pointer checking in ipc.c
525+ -- Mike
526+
527+ * Changed some more KERN_ERRs to KERN_DEBUGs in the
528+ STREAMS ioctl support.
529+ -- Mike
530+
531+
532+Fri Aug 21 20:24:32 BST 1998
533+
534+ * Somehow fchdir had been missed from the main iBCS call
535+ map even though it had been put in the BSD map. Oops.
536+ -- Mike
537+
538+
539+Wed Aug 19 23:12:47 BST 1998
540+
541+ * ALPHA 2.1 release number 2...
542+ -- Mike
543+
544+
545+Wed Aug 19 20:43:09 BST 1998
546+
547+ * Avoid calling rt_sigaction if the mapped signal number
548+ is -1. It is not strictly necessary but why bother?
549+ -- Mike
550+
551+ * Added David Bruce's updated x286emul.
552+ -- Mike
553+
554+
555+Mon Aug 17 21:29:53 BST 1998
556+
557+ * Avoid calling fput with a NULL file pointer.
558+ -- Mike
559+
560+
561+Sun Aug 16 17:32:20 BST 1998
562+
563+ * Fix to copy_{to,from}_user return checking. In many
564+ cases we do not care because they are behind verify_area
565+ checks but in some we do - and copy_{to,from}_user
566+ returns the number of bytes _uncopied_.
567+ -- Mike
568+
569+
570+Sat Aug 15 23:39:42 BST 1998
571+
572+ * Change the flock handling to bounce the flock struct
573+ through kernel space rather than using an in place
574+ modification. The assumptions we were making about
575+ segment registers seem to have become invalid at some
576+ point. We could go to put_user(get_user()) but moving
577+ the whole struct is probably more robust. Which is
578+ faster? I dunno...
579+ -- Mike
580+
581+
582+Sat Aug 15 22:30:41 BST 1998
583+
584+ * Changes to signal functions. Previous code confused old and
585+ new sigsets and could have lead to memory corruption and
586+ was likely the cause of signals getting blocked unexpectedly.
587+ Now we use the rt_sig* and new sigset interface to the
588+ kernel exclusively (in a few years the old stuff may be
589+ removed). This does means that a non-Linux program may
590+ now operate on signals >32 which may not have existed
591+ (and therefore would have errored) in the native environment.
592+ This may be considered a bug or a feature as appropriate...
593+ -- Mike
594+
595+
596+Mon Jul 20 22:23:14 BST 1998
597+
598+ * ALPHA 2.1 release...
599+ -- Mike
600+
601+
602+Mon Jul 20 20:55:47 BST 1998
603+
604+ * Added support for I_FDINSERT in the STREAMS/TLI message
605+ protocol handling. This allows TLI server code to work
606+ using a _real_ libnsl_s (tested briefly) but will break
607+ server code using my replacement libnsl_s until I update
608+ it. (It should probably use an I_FDINSERT simply so it
609+ can still run under SYSV if ever necessary.)
610+ -- Mike
611+
612+ * Use TIOCINQ instead of FIONREAD in the STREAMS ioctl handler.
613+ FIONREAD isn't actually supported on sockets. The socksys
614+ code already had this right.
615+ -- Mike
616+
617+ * Do the MOD_INC, MOD_DEC calls for sockets in the inherit
618+ and release handling only to reduce the opportunity for,
619+ ah, "oversights".
620+ -- Mike
621+
622+
623+Thu Jul 16 22:11:48 BST 1998
624+
625+ * Finally got round to adding a GNU CopyLeft!
626+ -- Mike
627+
628+ * Set up an XTI/TLI private state struct on all sockets at
629+ the same time we plug our own file operations in. This
630+ costs a small amount of extra memory per socket. However
631+ this is strictly correct (although unlikely to be actually
632+ _required_ by anything). It also allows us to set up TEPs
633+ created by XTI/TLI listen/accept easily so they have a
634+ chance of working.
635+ -- Mike
636+
637+ * XTI/TLI fixes:
638+ Do not auto-listen in getmsg() - listen() after connect()
639+ appears to crash some 2.1 kernels(?).
640+ Change the probe for activity in getmsg() to use the
641+ new poll handler directly.
642+ Handle listening TEPs slightly better.
643+ -- Mike
644+
645+ * Changed a stray KERN_ERR to KERN_DEBUG in ioctl.c
646+ -- Mike
647+
648+
649+Fri Jul 3 23:20:37 BST 1998
650+
651+ * Fixed the initial set up of the argument and environment
652+ lists which were broken during the change to 2.1 style
653+ user memory access.
654+ -- Mike
655+
656+
657+Mon Jun 29 22:50:11 BST 1998
658+
659+ * Put kernel_version definition back in emulate.c
660+ -- Mike
661+
662+ * Change loaders to set start_text, end_text, start_data,
663+ end_data, start_brk, brk fully.
664+ -- Mike
665+
666+
667+Thu Jun 25 21:18:11 BST 1998
668+
669+ * Added support for the "fat" IPC structures which use
670+ 32 bit uids, gids etc.
671+ -- Mike
672+
673+
674+Wed Jun 24 21:30:09 BST 1998
675+
676+ * Change suser() checks to use the new capable() calls.
677+ -- Mike
678+
679+ * Changed the CONFIG default to NOT support Xenix 286. It
680+ is an ever increasing build problem. It needs a volunteer
681+ to rewrite it.
682+ -- Mike
683+
684+ * Add locking around system_utsname data using the uts_sem.
685+ -- Mike
686+
687+ * Changed to use dentry stuff. Use fget()/fput() to get
688+ file pointers rather than accessing task fd tables
689+ directly. Use poll interface for SYSV poll and timod
690+ blocking checks. Use lock_kernel()/unlock_kernel()
691+ around stat routines and other namei stuff. Use dput()
692+ to release dentries obtained with namei(). Other
693+ incidental fixes to what went before as I noticed them.
694+ -- Mike
695+
696+
697+Tue Jun 9 20:02:56 BST 1998
698+
699+ * More changes for new module conventions.
700+ -- Mike
701+
702+ * Changed signal stuff to new conventions.
703+ -- Mike
704+
705+ * Changed getname() calling convention.
706+ -- Mike
707+
708+ * Changed fs type to mm_segment_t.
709+ -- Mike
710+
711+ * Changed user VM accesses to use new conventions.
712+ -- Mike
713+
714+
715+Sat Jun 6 20:30:00 BST 1998
716+
717+ * Changed to new module conventions.
718+ -- Mike
719+
720+
721+Thu May 28 22:30:45 BST 1998
722+
723+ * Removed VM_STACK_FLAGS tests.
724+ -- Mike
725+
726+ * Remove VM_GROWSDOWN tests.
727+ -- Mike
728+
729+ * Removed MAP_EXECUTABLE tests.
730+ -- Mike
731+
732+ * Removed MAP_DENYWRITE tests.
733+ -- Mike
734+
735+ * Removed STACK_TOP tests.
736+ -- Mike
737+
738+ * Removed FORKNOEXEC tests.
739+ -- Mike
740+
741+ * Removed INIT_MM tests.
742+ -- Mike
743+
744+
745+Mon May 18 22:49:56 BST 1998
746+
747+ * Fixed xnx_rdchk() return value.
748+ -- Mike
749+
750+ * The serial number returned in the SCO utsname struct
751+ can now be set with sco_serial="..." as a module
752+ option. Some program apparently want to find a real,
753+ believable serial number there. This should be documented
754+ somewhere other than here I guess...
755+ -- Mike
756+
757+
758+Mon May 18 22:03:49 BST 1998
759+
760+ * A class 't' ioctl with no arg type stuff in the top
761+ word is either an SVR4 tape ioctl a Coherent BSD-ish
762+ termios ioctl.
763+ -- Mike
764+
765+
766+Mon Feb 2 22:57:45 GMT 1998
767+
768+ * Other relatively minor changes to allow compilation
769+ under glibc (specifically 2.0.6 but it shouldn't
770+ matter).
771+ -- Mike
772+
773+ * Added an explicit -I flag to search /usr/src/linux/include
774+ since glibc doesn't necessarily require the kernel
775+ includes to be symlinked under /usr/include.
776+ -- Mike
777+
778+ * The personality defaults in binfmt_coff should probably
779+ select short inodes on the assumption that newer stuff
780+ is likely to be built as ELF anyway. I hope.
781+ -- Mike
782+
783+
784+Wed Nov 19 19:28:07 GMT/BST 1997
785+
786+ * Attempt to work around problems with sign extension
787+ when programs believe that the fs magic in a sysfs()
788+ call is short rather than long.
789+ -- Mike
790+
791+ * Added IPPROTO_IP/SOL_IP option name mapping for
792+ {get,set}sockopt. This is correct for SCO OS5 and
793+ hopefully for other SYSV derived Unices. Note that
794+ SCO OS5 ping still doesn't work because it uses an
795+ unsigned char for the IP_TTL value whereas Linux
796+ wants an int - and it objects to getting an error
797+ return. Apparently POSIX 1003g says IP_TTL should
798+ be an unsigned char so OS5, or at least its ping,
799+ is at fault. This probably isn't worth hacking
800+ around unless someone _really_ needs it.
801+ -- Mike
802+
803+
804+Wed Nov 12 22:28:19 GMT/BST 1997
805+
806+ * Added the SCO-ish syscall shortcut to the socksys
807+ networking code.
808+ -- Mike
809+
810+
811+Fri Nov 7 20:13:05 GMT/BST 1997
812+
813+ * Oops, I installed the SCO signal tables in the old
814+ personality mapping but forgot to create a specific
815+ SCO personality using them.
816+ -- Mike
817+
818+
819+Thu Nov 6 08:04:37 GMT/BST 1997
820+
821+ * No, it really should be USR1 for URG under SCO, not
822+ USR2. This is according to the SCO Network Programmer's
823+ documentation. The previous problem was because
824+ confusion between the SVR4 and SCO/SVR3 requirements
825+ prevented a SCO program from registering a handler
826+ for the right signal, I think.
827+ -- Mike
828+
829+
830+Wed Nov 5 14:23:22 GMT/BST 1997
831+
832+ * Created a new signal mapping for SCO and mapped
833+ Linux SIGURG to SCO SIGUSR2. Also changed the
834+ plain ibcs mapping for SIGURG back to IBCS_SIGURG.
835+ Previously I had SIGURG mapped to SIGUSR1 for
836+ what my subconscious says was a good reason but
837+ I can't figure out where I got it from. The USR2
838+ mapping is according to Peter Brueckner - and if
839+ it works for him...
840+ -- Mike
841+
842+
843+Wed Nov 5 09:14:27 GMT/BST 1997
844+
845+ * Repair the STREAMS based socket code. The new socket
846+ hashing in 2.0.30 and beyond means the old code no
847+ longer works. We now delay replacing the fd with
848+ a socket until the first read, write or ioctl. Since
849+ the open has completed at this stage and the fd is
850+ fully initialized we can then use dup() to do the
851+ fd switch, which should always work. As a side effect
852+ this allows us to auto-connect an SPX pipe to X :0
853+ if the first operation is other than a single character
854+ write - which should allow us to handle v. old SVR3
855+ X programs side by side with their more modern, and
856+ common, multi-SPX pipe descendants.
857+ This does mean that some error returns from an
858+ open of a TLI special file might be delayed until
859+ the first operation, however a) these are unlikely
860+ to occur (they are things like no such protocol)
861+ and b) most opens of such files are hidden in
862+ functions like t_open() anyway so if there is a
863+ problem a simple fix to libnsl to check the first
864+ ioctl is all that is needed.
865+ -- Mike
866+
867+ * sysfs() used to enumerate available filesystems seems
868+ to be 0 based on Linux but 1 based on SYSV.
869+ -- Mike
870+
871+
872+Sun Oct 12 00:18:33 GMT/BST 1997
873+ * Ioctls on the NFS pseudo device need to go via the
874+ emulation code rather than the native ioctl handler.
875+ -- Mike
876+
877+
878+Sat Aug 16 14:56:24 GMT/BST 1997
879+
880+ * Changed the use of errno in a prototype in ibcs.h to
881+ avoid possible conflict with an SMP errno definition
882+ which could get inherited from an include file if we
883+ aren't careful.
884+ -- Mike
885+
886+
887+Sat Jul 12 01:00:00 GMT/BST 1997
888+
889+ * Added Xenix locking() modes 5, 6, 7 as per patch from
890+ David Bruce <admin@hulcote.com> (there were others
891+ too). I rewrote it to be a bit cleaner but I haven't
892+ tested it (it's late...). Some one will tell me I guess.
893+ -- Mike
894+
895+Fri Jul 11 22:27:13 GMT/BST 1997
896+
897+ * Added more console ioctl traps to discourage programs
898+ from trying to do funky stuff with the console without
899+ logging unsupported ioctl messages.
900+ -- Mike
901+
902+ * sysfs() can, apparently, map an fs magic number to
903+ an fs name. We do this outside the kernel sysfs()
904+ because there seems no clean way to do it. We simply
905+ have a list of known magic numbers hard coded :-(.
906+ -- Mike
907+
908+ * Implemented sysconfig(). This is appears to be the SVR4
909+ forerunner to the POSIX sysconf().
910+ -- Mike
911+
912+
913+Tue May 13 20:52:05 GMT/BST 1997
914+
915+ * Hand off xmknod calls via ibcs_mknod so that we can
916+ create a directory if that is what the flags imply.
917+ I have not tested to see if xmknod is allowed to create
918+ directories - I just noticed it in passing.
919+ -- Mike
920+
921+ * Added SCO's F_GETHFDO (get highest fd open) fcntl. This is
922+ used by /bin/csh on SCO OS5 to save a few syscalls.
923+ -- Mike
924+
925+
926+Tue May 13 00:10:09 GMT/BST 1997
927+
928+ * More changes to handle long/short inode environments
929+ plus more explanation in the code. Are we having fun yet?
930+ -- Mike
931+
932+
933+Sat May 10 15:19:39 GMT/BST 1997
934+
935+ * Added socketpair() to the socksys emulation. This is
936+ as implemented by SCO OpenServer 5.
937+ -- Mike
938+
939+ * Change binfmt_coff.c to recognise programs compiled for
940+ SCO OpenServer 5, programs compiled for SCO 3.2.4 and
941+ programs compiled under SCO OpenServer 5 but with
942+ compatibility for ODT3.0. Why? Well, sometimes we
943+ should be giving long inodes in returns from getdents,
944+ sometimes short inodes. We don't just want to mask
945+ off the high part because that can lead to some
946+ things becoming invisible. We don't want that.
947+ -- Mike
948+
949+
950+Fri May 9 23:29:37 GMT/BST 1997
951+
952+ * Added some more tape ioctls.
953+ -- Mike
954+
955+
956+Wed Apr 16 23:12:37 GMT/BST 1997
957+
958+ * Fix memory leaks in poll.c and change ENOMEM return
959+ to EAGAIN.
960+ -- Mike
961+
962+
963+Tue Mar 11 21:29:15 GMT/BST 1997
964+
965+ * Add {get,set}rlimit to the SYSV personalities.
966+ -- Mike
967+
968+
969+Fri Mar 7 21:04:24 GMT/BST 1997
970+
971+ * Only build x286emul if EMU_X286 is enabled in CONFIG. There
972+ are many insallations which appear to either not have the
973+ a.out compiler support or have it installed incorrectly.
974+ -- Mike
975+
976+
977+Tue Feb 18 22:04:39 GMT/BST 1997
978+
979+ * Removed unnecessary and incorrect includes.
980+ -- Mike
981+
982+
983+Wed Feb 12 22:03:13 GMT/BST 1997
984+
985+ * Documentation updates for release.
986+ -- Mike
987+
988+
989+Mon Feb 10 22:36:27 GMT/BST 1997
990+
991+ * Dammit! The inode folding in stat() and getdents() was
992+ out of step _again_ :-(.
993+ -- Mike
994+
995+
996+Sun Jan 5 17:20:20 GMT/BST 1997
997+
998+ * sysconf(_SC_CLK_TCK) should return the value of HZ.
999+ -- Mike
1000+
1001+ * Small clarification to README concerning shared libraries.
1002+ -- Mike
1003+
1004+ * Removed the bit about UnixWare X binaries not working from
1005+ Doc/HINTS. Now we have STREAMS/TLI emulation this is no
1006+ longer true (and hasn't been for a while).
1007+ -- Mike
1008+
1009+
1010+Sat Jan 4 19:31:26 GMT/BST 1997
1011+
1012+ * If we open() something that is really a socket we close
1013+ it and reopen it using socket(), connect(). This allows
1014+ a Unix domain socket to look like a named pipe which
1015+ enables more SYSV X clients to connect to a local X
1016+ server using the local method (with suitable symlinks
1017+ to map the pathnames).
1018+ -- Mike
1019+
1020+
1021+Fri Jan 3 22:39:15 GMT/BST 1997
1022+
1023+ * Added a (simplistic) implementation of the I_CANPUT SVR4
1024+ STREAMS ioctl.
1025+ -- Mike
1026+
1027+ * Changed CONFIG.i386 to note that a correct setting of SMP
1028+ is now necessary.
1029+ -- Mike
1030+
1031+
1032+Wed Oct 2 16:28:39 GMT/BST 1996
1033+
1034+ * Intercept mknod() and allow it to create directories. Linux
1035+ doesn't allow this but SYSV does. (What about BSD?)
1036+ -- Mike
1037+
1038+
1039+Wed Oct 2 15:56:57 GMT/BST 1996
1040+
1041+ * Separated out the spx connect code so we can support old,
1042+ single connection spx implementations once we know how to
1043+ recognise them.
1044+ -- Mike
1045+
1046+Wed Oct 2 15:54:45 GMT/BST 1996
1047+
1048+ * At some stage I add some binfmt_elf.c changes that were
1049+ made to the kernel ELF loader in some 2.0.x patch. I forget
1050+ which now but no one should be using the iBCS ELF loader
1051+ currently anyway.
1052+ -- Mike
1053+
1054+
1055+Fri Aug 23 15:42:04 GMT/BST 1996
1056+
1057+ * Moved svr4sig to the right place.
1058+ -- Mike
1059+
1060+ * Moved error message strings to a separate file so they can
1061+ be shared by emulate.c and solaris.c.
1062+ -- Mike
1063+
1064+ * CONFIG files now define ARCH to be the CPU architecture. This
1065+ is used to ensure that architecture specific files are only
1066+ used when necessary.
1067+ -- Mike
1068+
1069+ * Changed the getdents routine in open.c to use the same
1070+ rules for folding 32 bit inodes to 16 as stat and read.
1071+ -- Mike
1072+
1073+
1074+Mon Aug 19 13:33:42 GMT/BST 1996
1075+
1076+ * Correct IPC problem introduced with Sparc changes.
1077+ -- Mike
1078+
1079+
1080+Fri Aug 9 13:27:49 GMT/BST 1996
1081+
1082+ * Fix the inode swapping for /dev/spx and XTI/TLI transports.
1083+ -- Mike
1084+
1085+ * If a COFF binary doesn't have a .comment section we have no
1086+ way to tell what personality we should be using. Switch to
1087+ SCO anyway - odds on it is.
1088+ -- Mike
1089+
1090+
1091+Wed Aug 7 14:22:11 GMT/BST 1996
1092+
1093+ * On SCO at least lseek on a character or block device
1094+ returns 0 not -ESPIPE.
1095+ -- C.A. Lademann <cal@zls.com>
1096+
1097+ * Some problems with /dev/spx and TLI end point handling that
1098+ could leak descriptors, memory and leave the lists of file
1099+ locks in an inconsistent state. Not to mention the fact that
1100+ the socket data in an inode also contains a pointer back to
1101+ the process' file structure. I _think_ I have this sorted
1102+ out now...
1103+ -- Mike
1104+
1105+ * Sparc changes broke select. While I was at it I changed it
1106+ to use the newselect Linux call as well. If we build without
1107+ tracing we'll save a few more bytes of code now too.
1108+ -- Mike
1109+
1110+
1111+Wed Jul 31 14:16:38 GMT/BST 1996
1112+
1113+ * Map EAGAIN to EWOULDBLOCK for recv*() and send*() syscalls.
1114+ Linux seems to return EAGAIN. X/Open allows either EAGAIN
1115+ or EWOULDBLOCK. SVR4 and Wyse V/386 specify EWOULDBLOCK in
1116+ their man pages. SCO doesn't admit to non-blocking possibilities
1117+ in their man pages but some code seems to expect only
1118+ EWOULDBLOCK.
1119+ -- Mike
1120+
1121+
1122+Mon Jul 29 16:58:11 GMT/BST 1996
1123+
1124+ * Added a CONFIG option for SMP. This is enabled by default.
1125+ I don't think this is a problem for non-SMP systems?
1126+ -- Mike
1127+
1128+ * Minor change to the SCO error map.
1129+ -- Mike
1130+
1131+
1132+Fri Jul 26 09:13:43 GMT/BST 1996
1133+
1134+ * Updated README and RELEASE
1135+ -- Mike
1136+
1137+ * Merged Sparc patches from:
1138+ Miguel de Icaza <miguel@roxanne.nuclecu.unam.mx>
1139+ -- Mike
1140+
1141+
1142+Thu Jul 4 12:24:06 GMT/BST 1996
1143+
1144+ * The default is now *not* to build a versioned module. I got
1145+ too many questions about why it wouldn't compile.
1146+ -- Mike
1147+
1148+ * Fix to binfmt_xout.c when Xenix 286 is emulation is not
1149+ configured.
1150+ -- Mike
1151+
1152+
1153+Fri Jun 14 13:36:18 GMT/BST 1996
1154+
1155+ * Added code to explicitly fail the SCO LD?MAP ioctls used
1156+ for channel mapping.
1157+ -- Mike
1158+
1159+
1160+Thu Jun 6 17:21:00 GMT/BST 1996
1161+
1162+ * Cleaned up Stephans SCO tape ioctls and added the
1163+ corresponding SVR4 versions (untested).
1164+ -- Mike
1165+
1166+
1167+Wed Jun 5 10:47:24 GMT/BST 1996
1168+
1169+ * Rewritten the Xenix locking() syscall. The previous one
1170+ was crap.
1171+ -- Mike
1172+
1173+ * Change the read on directory emulation to fold long inodes
1174+ to shorts in the same way as stat and getdents. This may
1175+ help old programs that use stat and read to do a getcwd
1176+ rather than a stat and getdents.
1177+ -- Mike
1178+
1179+ * Use __get_free_page instead of get_free_page in getdents
1180+ since we don't need the buffer cleared initially (I think).
1181+ -- Mike
1182+
1183+
1184+Sat Jun 1 09:50:30 MET DST 1996
1185+ * Added some tape ioctrls for SCO to iBCSemul/ioctl.c.
1186+ -- Stephan
1187+
1188+
1189+Fri May 31 08:44:51 GMT/BST 1996
1190+
1191+ * Move bsdioctl.c to the main group of source files from
1192+ than the BSD specifics. Just about everything else has
1193+ BSD style sgtty stuff and some seemingly modern code
1194+ actually depends on it (e.g. ISC SVR4 telnet)!
1195+ -- Mike
1196+
1197+ * Add CONFIG option to build a versioned module.
1198+ -- Mike
1199+
1200+ * Install the modules in /lib/modules/`uname -r`/misc for
1201+ compatibility with the modules tools.
1202+ -- Mike
1203+
1204+ * If the requested connection indications in a bind request
1205+ is greater than zero do a listen() if the bind is successful.
1206+ We still also do a listen() if the program selects() on
1207+ a bound but unconnected stream. This may help some broken
1208+ programs. It may also break some broken programs. It's
1209+ debatable whether this should now be in or out.
1210+ -- Mike
1211+
1212+ * The bit vector mapping used for converting vectors of
1213+ signal flags had an off by one error. The signal maps
1214+ themselves were also one entry short.
1215+ -- Mike
1216+
1217+ * At some stage I changed the I_SETOWN STREAMS ioctl but
1218+ never committed it?
1219+ -- Mike
1220+
1221+
1222+Thu May 9 12:51:10 GMT/BST 1996
1223+
1224+ * Change to install in /lib/modules/`uname -r`/misc instead
1225+ of /usr/lib/modules for compatibility with the way the
1226+ modules tools have gone.
1227+ -- Mike
1228+
1229+
1230+Thu Apr 25 12:34:06 GMT/BST 1996
1231+
1232+ * Use the CONIND_number in a T_BIND_REQ to decide whether
1233+ or not we should listen() on the socket.
1234+ -- Mike
1235+
1236+
1237+Mon Apr 22 15:42:47 GMT/BST 1996
1238+
1239+ * Added a simple loader that will attempt to pass scripts
1240+ that start with ":" and things that look like simple text
1241+ to /bin/sh. Hopefully this isn't going to conflict with
1242+ magic for other needed formats...
1243+ -- Mike
1244+
1245+
1246+Fri Mar 29 17:11:35 GMT/BST 1996
1247+
1248+ * Committing the all new TLI/XTI options handling. Note that
1249+ TLI and XTI option handling is mutually exclusive at the
1250+ moment. The default is to enable TLI options handling since
1251+ that is what existing SVR3/4 systems use. I haven't found
1252+ one that actually handles X/Open format (they use the
1253+ TNOTSUPPORT cop out) so I don't know how the stack is
1254+ told to use XTI format instead of TLI.
1255+ Note that only SOL_SOCKET/* and SOL_TCP/TCP_NDELAY are
1256+ known to work to any extent at the moment. Others may (or
1257+ may not need mapping) but I can't find the motivation to
1258+ wade through the headers and create yet another table of
1259+ magic numbers. Hopefully everyone just nicked the BSD
1260+ reference code...
1261+ -- Mike
1262+
1263+ * Some more 1.3.7x changes related to process accounting
1264+ (fork but no exec etc.).
1265+ -- Mike
1266+
1267+
1268+Wed Mar 20 13:36:07 GMT/BST 1996
1269+
1270+ * I seem to have forgotten to add a comment about merging
1271+ changes from mid 1.3.7x kernels.
1272+ -- Mike
1273+
1274+
1275+Wed Feb 28 14:53:00 GMT/BST 1996
1276+
1277+ * Fix to shared library loader in binfmt_aout.c from kernel
1278+ patch 1.3.69.
1279+ -- Mike
1280+
1281+
1282+Wed Jan 24 09:58:34 GMT/BST 1996
1283+
1284+ * Implemented I_PEEK.
1285+ -- Mike
1286+
1287+ * Changed I_NREAD to understand that control messages constitute
1288+ queued data.
1289+ -- Mike
1290+
1291+
1292+Fri Jan 19 11:57:20 GMT/BST 1996
1293+
1294+ * Make the socket level connect in timod.c happen synchronously
1295+ always. Allowing the async possibility is a little harder.
1296+ -- Mike
1297+
1298+
1299+Thu Jan 18 16:06:13 GMT/BST 1996
1300+
1301+ * Added (some of) the intial framework for option management.
1302+ This is documented by X/Open but many XTI stacks don't
1303+ seem to implement it. Certainly the man page for t_optmgmt
1304+ in SCO OS5 says it isn't yet implemented. There do seem
1305+ to be programs out there that make options requests though.
1306+ Unfortunately I don't have one right now so this is currently
1307+ disabled and MAY CAUSE KERNEL FAULTS. I don't know...
1308+ -- Mike
1309+
1310+
1311+Tue Jan 16 12:35:21 GMT/BST 1996
1312+
1313+ * Added a slight change to mmap.c. The SVR4 headers describe
1314+ a slight change in functionality which is specified with
1315+ a special flag that is supposedly set by the C library
1316+ interface. I haven't actually seen this flag set by the
1317+ SVR4 dynamic loader (which is the only mmapper I've seen)
1318+ and things seem to work with or without this change. It
1319+ may not be necessary at all?
1320+ -- Mike
1321+
1322+
1323+Fri Jan 12 14:56:38 GMT/BST 1996
1324+
1325+ * Remove trace flag from context() in the callmaps. SVR4's
1326+ /bin/sh seems to use it but doesn't care if it fails.
1327+ -- Mike
1328+
1329+ * Added the SCO OS5 SI86GETFEATURES request to sysi86(). OS5
1330+ uses this to establish what "features" are available when
1331+ a program starts (i.e. in crt*.o). Currently we just return
1332+ the same vector as OS5 itself. I haven't found what the
1333+ flags mean - but one of them indicates xstat extensions
1334+ which I have added to iBCS.
1335+ -- Mike
1336+
1337+ * Change .comment parsers in binfmt_coff.c and binfmt_elf.c
1338+ so we only grab a single page (asking for two contiguous
1339+ pages is antisocial) and then roll through the comment
1340+ section in stages.
1341+ -- Mike
1342+
1343+ * Fixes to binfmt_elf.c and binfmt_aout.c so they compile
1344+ and load with 1.3 kernels.
1345+ -- Mike
1346+
1347+
1348+Tue Jan 9 14:29:49 GMT/BST 1996
1349+
1350+ * Add a kludge to the TLI connect code. For some reason, under
1351+ ISC SVR4, telnet seems to gve the port number in network
1352+ byte order ok but the X programs give it in host byte order.
1353+ One of them is wrong but presumably both work on ISC (I don't
1354+ have the hardware to actually install it). We kludge around
1355+ it here by checking if we are SVR4, AF_INET, port 6000 (host
1356+ order) and, if so, change it to port 6000 (network order).
1357+ This will break anything that wants to make an outgoing
1358+ call to port 28695. There are probably other things that
1359+ expect incorrect port numbers to work but there seems to
1360+ be no easy solution here.
1361+ -- Mike
1362+
1363+
1364+Fri Jan 5 13:34:43 GMT/BST 1996
1365+
1366+ * First draft of code to handle select/poll on transport end
1367+ points correctly. This isn't well tested but should be good
1368+ enough to support normal timod usage.
1369+ -- Mike
1370+
1371+
1372+Thu Jan 4 13:52:25 GMT/BST 1996
1373+
1374+ * TLI changes to get error returns from connects correctly.
1375+ -- Mike
1376+
1377+
1378+Wed Jan 3 17:06:07 GMT/BST 1996
1379+
1380+ * Added a manual page in the Doc directory. This is not
1381+ installed by default.
1382+ -- Mike
1383+
1384+ * Fixed a problem in the .comment parsers in binfmt_elf.c
1385+ and binfmt_coff.c where a number of pages was passed to
1386+ __get_free_pages() instead of a binary power. This has
1387+ been in release versions of binfmt_coff.c for a long
1388+ time but exactly one person has reported anything that
1389+ might be attributable to it. Strange, since the bug should
1390+ have manifested itself as insidious memory leakage and
1391+ corruption...
1392+ -- Mike
1393+
1394+
1395+Wed Jan 3 12:16:47 GMT/BST 1996
1396+
1397+ * Removed all kernel patches in the Patches directory. None
1398+ should be need for kernels 1.3.50 (or earlier?) and onwards.
1399+ None should be essential for 1.2.13 - although some capability
1400+ is lost notably SCO OpenServer 5 ELF binaries (if the kernel
1401+ ELF loader is present) and BSD a.out binaries.
1402+ -- Mike
1403+
1404+ * Another fix to termio[s] ioctls to get the control character
1405+ settings right for SVR4. Previously this was just copied
1406+ from the SCO mapping and just never got changed.
1407+ -- Mike
1408+
1409+
1410+Thu Dec 14 10:41:36 GMT 1995
1411+
1412+ * Added basic getpmsg/putpmsg support. It doesn't do anything
1413+ with bands but we don't have anyway to use them.
1414+ -- Mike
1415+
1416+
1417+Tue Dec 12 09:38:01 GMT 1995
1418+
1419+ * First commit of the major TLI rewrite for Eric Sixt. This
1420+ should be enough for normal TCP & UDP clients. It may be
1421+ sufficient for servers as well but this is untested so far.
1422+ The client stuff has been tested with SCO cu, ISC telnet
1423+ and custom test code down to the getmsg/putmsg level. A shared
1424+ libnsl_s is also included. This has the functions needed for
1425+ clients but lacks some needed for servers currently. It has
1426+ been tested on a real SCO system. It could be done better
1427+ (and should be) but for now we are interested in making existing
1428+ programs work rather than handling all the error conditions
1429+ by the book. The library uses SVR3 shared library tools and
1430+ needs to be built on an SVR3 system (I used SCO).
1431+ Included is a rewrite of the /dev/spx kludging (the old didn't
1432+ work if TLI was enabled). This now allows connections to other
1433+ than /tmp/.X11-unix/X0 (if configured) so you can run multiple
1434+ X servers on the VCs and display SCO X programs on all of them.
1435+ The major/minor numbers used for the emulation devices have
1436+ (necessarily) changed. The top level Makefile will (re)create
1437+ them on a "make install" or "make devices".
1438+ Oh yeah, I built stubs for other libraries as well (specifically
1439+ SCO/SecureWare protlib_s) but don't expect it to have any real
1440+ support. If programs _really_ need stuff from there they are
1441+ like to have reduced or completely broken functionality on
1442+ Linux!
1443+ The script I used to generate the skeleton APIs for the
1444+ shared libraries is libs/mkltab if anyone feels the urge to
1445+ look at other libraries...
1446+ -- Mike
1447+
1448+ * Removed the old quota compile option. It isn't compatible with
1449+ the quota stuff in 1.3.46 and would only cause confusion. This
1450+ means you can't use iBCS if you have the old quota patches
1451+ in a pre-1.3.46 kernel. Tough :-).
1452+ -- Mike
1453+
1454+
1455+Mon Dec 11 15:14:46 GMT 1995
1456+
1457+ * Map I_SETSIG/I_GETSIG to FIOSETOWN/FIOGETOWN and pray...
1458+ -- Mike
1459+
1460+ * Fixed possible memory leak in COFF & ELF personality recognition
1461+ when the offset/size of the .comments section is invalid. This
1462+ could leak when the .comments section exists but is zero bytes
1463+ long I think.
1464+ -- Mike
1465+
1466+
1467+Wed Dec 6 11:31:27 GMT 1995
1468+
1469+ * A stat of a file must give an inode that matches what we get
1470+ from a read of the directory since code that figures out cwd
1471+ needs the inodes to match. Mind you, if there are several inode
1472+ numbers greater than 65534 in the directory we are going to get
1473+ some strange paths. I don't know if this is fixable properly at
1474+ all?
1475+ -- Mike
1476+
1477+ * Yes it is. We just mask off the high word to get the short
1478+ inode number for the stat structure.
1479+ -- Mike
1480+
1481+
1482+Thu Nov 30 16:21:32 GMT 1995
1483+
1484+ * Fix the SVR4 additions to the V7 terminal ioctls. Add handling
1485+ of TIOC[GS]ETD. Have TIOCL[GS]ET trivially succeed (I can't
1486+ find the documentation for the arguments).
1487+ -- Mike
1488+
1489+
1490+Wed Nov 29 12:57:42 GMT 1995
1491+
1492+ * Changed the guesswork svr4_waitsys to implement the correct
1493+ waitid syscall.
1494+ -- Mike
1495+
1496+ * Enable the i486-linuxaout option in x286emul/Makefile by
1497+ default. There seem to be significant numbers of people
1498+ using ELF compilers now. This may be a mistake...
1499+ -- Mike
1500+
1501+ * Fixes to sigsuspend and sigpause in signal.c. The previous
1502+ invocations of the Linux sigsuspend syscall were wrong and
1503+ liable to lead to random freeze ups of programs which used
1504+ sigsuspend() or sigpause().
1505+ -- Mike
1506+
1507+
1508+Fri Nov 24 11:03:01 GMT 1995
1509+
1510+ * Interactive SVR4 seems to be overloading the BSD termio
1511+ ioctls with its own.
1512+ -- Mike
1513+
1514+ * The SVR4 procid subcodes don't match the SCO ones. Or, at
1515+ least, I seem to remember I got the orignal set from SCO
1516+ and UnixWare and Interactive SVR4 are different (but match
1517+ each other).
1518+ -- Mike
1519+
1520+
1521+Thu Nov 23 17:21:56 GMT 1995
1522+
1523+ * Interactive SVR4's /bin/sh calls access(..., 011) but Linux
1524+ returns EINVAL if the access mode has any other bits than
1525+ 007 set. So we have to wrap it and mask it :-(.
1526+ -- Mike
1527+
1528+
1529+Wed Nov 22 10:11:49 GMT 1995
1530+
1531+ * Change to binfmt_elf.c to set total_vm value introduced in
1532+ kernel 1.3.43.
1533+ -- Mike
1534+
1535+
1536+Thu Nov 16 15:02:58 GMT 1995
1537+
1538+ * Added support for SCO OpenServer 5 binaries using .comment
1539+ section parsing as with COFF.
1540+ Built a BSD capable a.out loader as part of iBCS.
1541+ The iBCS ELF loader is only used for recognised (using
1542+ .comments) binaries if the standard ELF loader is configured
1543+ in the kernel iBCS is built against. If the ELF loader is
1544+ not configured in the kernel iBCS is built against the iBCS
1545+ ELF loader is used for all ELF binaries. This prevents the
1546+ iBCS module from becoming un-unloadable on ELF based Linux
1547+ systems.
1548+ Similarly the iBCS a.out loader tries to avoid dealing
1549+ with anything other than BSD binaries for the same reasons.
1550+ This requires a kernel 1.3.42 or greater to allow iBCS
1551+ to insert its loaders into the list before the standard
1552+ kernel ones. Kernels 1.3.39(~) to 1.3.41 have some support
1553+ but there are bugs which will likely prevent you running
1554+ *anything* as soon as iBCS is loaded. Mea culpa. Tough.
1555+ -- Mike
1556+
1557+
1558+Thu Nov 16 11:00:08 GMT 1995
1559+
1560+ * Minor clean up in binfmt_coff.c and fix a minor bug in
1561+ parse_comments that caused it to miss checking a string
1562+ if there was a zero length string in among.
1563+ -- Mike
1564+
1565+
1566+Fri Nov 10 12:22:05 GMT 1995
1567+
1568+ * Changes for latest module bogosities (~1.3.38). We need to
1569+ define __NO_VERSION__ to avoid linux/module.h putting
1570+ a kernel_version in *every* damn file.
1571+ -- Mike
1572+
1573+
1574+Tue Nov 7 10:55:05 GMT 1995
1575+
1576+ * When stealing temp space from the stack we have to actually
1577+ move esp down and then restore it as the 1.3.x kernels add
1578+ a check to trap out of bounds stack accesses. This is not
1579+ tested but I think it only affects the TLI emulation code
1580+ which is disabled by default.
1581+ -- Mike
1582+
1583+
1584+Mon Oct 9 11:22:29 BST 1995
1585+
1586+ * Use kernel readv/writev if available.
1587+ -- Mike
1588+
1589+
1590+Thu Sep 14 12:21:48 BST 1995
1591+
1592+ * Changed references to current->sigaction to allow for the
1593+ changes in kernel patch 1.3.26 which allow sharing of signal
1594+ state between clone processes.
1595+ -- Mike
1596+
1597+
1598+Mon Sep 4 10:04:22 BST 1995
1599+ Originally: Wed Aug 2 09:57:56 GMT 1995
1600+
1601+ * Removed Xenix interrupt bug, created wait() workaround
1602+ for INFORMIX-SQL and built the locking() to fcntl()
1603+ mapping.
1604+ -- Peter <polte@bbtt.com>
1605+
1606+
1607+Wed Aug 30 09:19:54 BST 1995
1608+
1609+ * Merged kernel patch for binfmt_elf.c from 1.3.21 which sets
1610+ EDX to zero on process start up. See the comment in the code
1611+ for reasons.
1612+ -- Mike
1613+
1614+
1615+Tue Aug 29 08:44:50 BST 1995
1616+
1617+ * Workaround. Local X won't work because a putmsg occurs
1618+ after we have already swapped the open descriptor for a
1619+ Unix domain socket. We either need to peek at socket
1620+ internals or actually implement the messages for passing
1621+ file descriptors. This quick fix enables local X connections
1622+ if we build without XTI support.
1623+ -- Mike
1624+
1625+
1626+Tue Aug 8 11:36:41 BST 1995
1627+
1628+ * Fix streams kludging so local X works again (should do
1629+ anyway - it's untested as yet due to hard disk collapse.
1630+ Hopefully someone will tell me if it doesn't work.)
1631+ -- Mike
1632+
1633+
1634+Mon Jul 31 13:25:58 BST 1995
1635+
1636+ * Changes to allow compilation in the presence of a kernel
1637+ built with the quota patches.
1638+ -- Dimitrios Mpougoulias <dbougo@leon.nrcps.ariadne-t.gr>
1639+
1640+
1641+Tue Jul 18 09:01:53 BST 1995
1642+
1643+ * Fixed timod getinfo ioctl. This functionality should move
1644+ into the message handling as bind has.
1645+ -- Mike
1646+
1647+
1648+Mon Jul 17 10:16:43 BST 1995
1649+
1650+ * Added handling of BSD-ish sgtty ioctls. For some reason the
1651+ SVR4 network programs such as telnet have been modified to
1652+ pushd the ttold STREAMS modules and use sgtty calls instead
1653+ of simply using termio[s]. Don't blame me! :-)
1654+ -- Mike
1655+
1656+ * Restructuring of timod.c complete. Timod ioctls now use
1657+ message routines to avoid duplicating code.
1658+ -- Mike
1659+
1660+
1661+Wed Jul 12 14:44:30 BST 1995
1662+
1663+ * Made debug output in binfmt_coff.c less verbose. We only
1664+ really care about matched comment strings. If we dump them
1665+ all here we overrun the kernel message buffer and miss
1666+ interesting stuff when the program actually starts running.
1667+ -- Mike
1668+
1669+ * Changed __get_free_pages in binfmt_coff.c to give the extra
1670+ argument required in 1.3 kernels.
1671+ -- Mike
1672+
1673+
1674+Tue Jul 4 11:48:27 BST 1995
1675+
1676+ * Restructure timod.c ready to rewrite timod_ioctl to use
1677+ putmsg/getmsg rather than reimplementing the same message
1678+ protocol again.
1679+ -- Mike
1680+
1681+
1682+Mon Jul 3 13:41:49 BST 1995
1683+
1684+ * Initial TLI support for outgoing TCP and UDP. Merged BSD/Wyse
1685+ socket ioctl handling with the socksys handler. Fixed (some)
1686+ bugs in poll() emulation. Devices in /dev/inet have changed
1687+ to support TLI access. See README for details.
1688+ -- Mike
1689+
1690+
1691+Tue Jun 27 09:00:02 BST 1995
1692+
1693+ * Don't export symbols from iBCS. I'm not sure when register_symtab
1694+ was introduced so we only drop our symbol table in 1.3
1695+ and later.
1696+ -- Mike
1697+
1698+ * Added missing brackets in binfmt_elf.c as per kernel
1699+ patch 1.3.4.
1700+ -- Mike
1701+
1702+
1703+Thu Jun 22 13:09:49 BST 1995
1704+
1705+ * Big step forward with TLI. I now seem to understand what is
1706+ happening when and have enough to do the initial open and
1707+ get info requests. This may one day actually work...
1708+ -- Mike
1709+
1710+ * Trap EUC ioctls and return EINVAL. We don't do EUC :-).
1711+ -- Mike
1712+
1713+ * Changes for the 1.3 development kernel. This compiles but is
1714+ as yet untested. It still seems ok with 1.2.10.
1715+ -- Mike
1716+
1717+
1718+Wed Jun 14 09:15:39 BST 1995
1719+
1720+ * Added Eric's protection mapping fixes to binfmt_elf.c
1721+ from 1.2.10.
1722+ -- Mike
1723+
1724+
1725+Fri Jun 9 12:31:53 BST 1995
1726+
1727+ * Linux can't stat unmounted filesystems but SCO can (by
1728+ specifying the pathname/fd of a block device and the
1729+ filesystem type. Linux will just stat the filesystem
1730+ that the device node is on (i.e. the root filesystem).
1731+ There isn't much we can do about it. I just lie and
1732+ claim there is 100MB free of 1GB. I hope this won't
1733+ cause too much grief...
1734+ -- Mike
1735+
1736+
1737+Thu May 18 12:06:50 BST 1995
1738+
1739+ * When trying to get an IP domain name don't try the utsname
1740+ domainname if it is "(none)". If we get that far we have to
1741+ give in and return a blank domain name.
1742+ -- Mike
1743+
1744+
1745+Wed May 17 10:15:42 BST 1995
1746+
1747+ * Recheck the socket functions when accept returns a new socket.
1748+ This is pedantic at this stage since we must have had a
1749+ socket initially and the current kernel code isn't likely
1750+ to handle removal and reloading of in use modules. iBCS
1751+ can handle this happening to it though :-).
1752+ -- Mike
1753+
1754+ * Fix timod faking to correctly return an error if given an
1755+ invalid file descriptor rather than trying to dereference
1756+ a null pointer in kernel mode.
1757+ -- Mike
1758+
1759+
1760+Tue Apr 25 11:35:43 BST 1995
1761+
1762+ * If nap() is given a zero timeout return immediately rather
1763+ than blocking indefinitely. Ensure that SIGALRM is not ignored
1764+ during the pause or we never get woken up by the timeout.
1765+ -- Mike
1766+
1767+
1768+Mon Apr 24 09:21:30 BST 1995
1769+
1770+ * Various documentation updates from Eric.
1771+ -- Mike
1772+
1773+
1774+Fri Apr 21 14:34:25 BST 1995
1775+
1776+ * Fixes to IPC. Now it really *should* work...
1777+ -- Mike
1778+
1779+
1780+Thu Apr 13 14:03:45 BST 1995
1781+
1782+ * Tidy up documentation ready for new release.
1783+ -- Mike
1784+
1785+
1786+Wed Apr 12 11:07:52 BST 1995
1787+
1788+ * Moved to an ELF development system with a GCC 2.6.4 snapshot.
1789+ This pointed out a few signed/unsigned mismatches so I
1790+ fixed them. We also have to ensure that x286emul is built
1791+ as a QMAGIC a.out because it won't work any other way. It
1792+ isn't likely to work any other way unless someone pays for
1793+ for it to be done - it isn't what you might call a "sexy"
1794+ project...
1795+ -- Mike
1796+
1797+
1798+Wed Apr 12 08:53:22 BST 1995
1799+
1800+ * Added the kernel patch to handle statically linked SVR4 ELF
1801+ binaries to the Patches directory since it doesn't seem to
1802+ have made any of the 1.2.x patches yet.
1803+ -- Mike
1804+
1805+
1806+Tue Mar 28 09:55:38 BST 1995
1807+
1808+ * Made the ISC specific stuff optional via CONFIG.
1809+ -- Mike
1810+
1811+ * 1. INTERACTIVE UNIX signal numbers are different from IBCS2.
1812+ I added new signalmaps and exec_domains.
1813+ 2. setpgrp does not deattach the controlling terminal.
1814+ Try the setpgrp test program included here after the patch
1815+ on real SCO or xxxx and Linux/IBCS2.
1816+ 3. sigset behavior is incorrect. Test program also included.
1817+ Short description: signal handlers registered whith sigset
1818+ should run with the signal blocked, and after return
1819+ the handler must be restored, so sa_flags = 0
1820+ is the correct setting.
1821+ Calling sigset should remove the signal from the
1822+ blocked set.
1823+ -- Remete Gabor <rg@tomx.elte.hu>
1824+
1825+
1826+Fri Mar 24 10:20:57 GMT 1995
1827+
1828+ * Set the fragment size to zero for [f]statfs() just to be
1829+ pedantic (SCO does this).
1830+ -- Mike
1831+
1832+
1833+Tue Mar 21 10:24:14 GMT 1995
1834+
1835+ * Fixes to 286 overlay and x.out loader by Don Camp
1836+ <don@funsoft.com>.
1837+ -- Mike
1838+
1839+ * New code for SVR4 {get,set}groups since SVR4 uses longs
1840+ for gids whereas Linux uses shorts.
1841+ -- Mike
1842+
1843+
1844+Mon Mar 20 17:06:23 GMT 1995
1845+
1846+ * Added code for waitsys(). This is guesswork at this stage
1847+ but appears sufficient for ISC 4.0 ksh to do something
1848+ reasonable in the simplest case.
1849+ -- Mike
1850+
1851+
1852+Tue Mar 14 09:44:13 GMT 1995
1853+
1854+ * Initial implementation of ptrace. This allows programs
1855+ (SCO and Wyse V/386 programs) to access a process'
1856+ registers but actual tracing semantics will be difficult
1857+ to make functional.
1858+ -- Mike
1859+
1860+ * Alter emulate return to allow return of numbers > 2^^31
1861+ which don't fall in the error code space.
1862+ -- Mike
1863+
1864+ * Added signal mapping to wait() syscalls.
1865+ -- Mike
1866+
1867+ * Updated the main README with the vger mailing list details
1868+ and a few other tidy ups.
1869+ -- Mike
1870+
1871+
1872+Thu Mar 9 10:10:53 GMT 1995
1873+
1874+ * Added a load more system calls to the SVR4 tables (these
1875+ match UnixWare at least I think). Some of these may work,
1876+ some are just marked to shut up run time warnings.
1877+ -- Mike
1878+
1879+ * Increased the size of the buffer used for parsing comment
1880+ sections in binfmt_coff.c to 8k (from 1k). There are
1881+ programs out there that need it.
1882+ -- Mike
1883+
1884+
1885+Tue Mar 7 16:12:36 GMT 1995
1886+
1887+ * More XLI/TLI changes - mostly fixes.
1888+ -- Mike
1889+
1890+ * Added basic handling of the termiox extension used by SVR4
1891+ to give access to hardware flow control. Only RTS & CTS
1892+ or nothing is allowed because that's all Linux does. The
1893+ same comments as below apply to the status of this.
1894+ -- Mike
1895+
1896+ * Rework ioctl handling for termios. SCO uses short in a termios
1897+ structure, SVR4 uses longs. The bit shuffling used for SVR4 is
1898+ the same as for SCO - there are known to be some slight
1899+ differences but these are not believed to be critical for
1900+ most things. A large amount of guesswork went in to this.
1901+ One day I may be able to test it...
1902+ -- Mike
1903+
1904+
1905+Mon Mar 6 12:31:05 GMT 1995
1906+
1907+ * Added a -DMODULE to iBCSemul/Makefile to make new style kernel
1908+ modules work.
1909+ -- Mike
1910+
1911+
1912+Fri Mar 3 15:04:14 GMT 1995
1913+
1914+ * Patches from Eric. (Use Eric's [f]statvfs instead of mine).
1915+ -- Mike
1916+
1917+
1918+Thu Mar 2 11:46:03 GMT 1995
1919+
1920+ * Fixed a silly in the handling of SO_IMASOCKET and SO_PROTOTYPE
1921+ plus added a check on the given buffer length.
1922+ -- Mike
1923+
1924+ * Fixed a silly in the sockopt.inc options mapping.
1925+ -- Mike
1926+
1927+
1928+Wed Mar 1 14:20:06 GMT 1995
1929+
1930+ * Added SVR4 console keyboard mapping and termcap/terminfo
1931+ options to the PROD.Patches directory.
1932+ -- Mike
1933+
1934+
1935+Mon Feb 27 13:30:17 GMT 1995
1936+
1937+ * Added simpleminded implementation of [f]statvfs().
1938+ -- Mike
1939+
1940+ * [f]statfs() now respects the length argument to allow for
1941+ older/smartass code which uses a smaller buffer size.
1942+ -- Mike
1943+
1944+
1945+Fri Feb 17 10:33:23 GMT 1995
1946+
1947+ * More tidy up, a little more work on TLI/XTI (still nowhere
1948+ near usable), fixed the signal debugging messages so it
1949+ makes more sense.
1950+ -- Mike
1951+
1952+
1953+Thu Feb 2 12:45:25 GMT 1995
1954+
1955+ * Changed the BSD termio ioctl handler to recognise the fact
1956+ that some provide V7 compatibility and may be invoked from
1957+ non-BSD binaries - possibly without BSD size encoding.
1958+ -- Mike
1959+
1960+ * Changes for 1.1.88. More definitions moved around in the
1961+ Linux header files :-).
1962+ -- Mike
1963+
1964+
1965+Fri Jan 27 10:12:51 GMT 1995
1966+
1967+ * Also mapped new Linux SIGIO to iBCS SIGIO and changed Linux
1968+ SIGURG to map to SIGUSR1 as documented in SCO's TCP/IP
1969+ programmer's guide. Is SVR4 the same? How badly do we care?
1970+ -- Mike
1971+
1972+ * Had to add a new personality for Xenix binaries since they
1973+ have a different number for SIGPOLL - sigh...
1974+ -- Mike
1975+
1976+
1977+Mon Jan 23 15:34:01 GMT 1995
1978+
1979+ * Changes to includes for 1.1.84.
1980+ -- Mike
1981+
1982+ * Change to binfmt_elf.c from kernel patch 1.1.84.
1983+ -- Mike
1984+
1985+
1986+Tue Jan 17 17:10:25 GMT 1995
1987+
1988+ * Added tracing of argument and environment vectors passed
1989+ to exec().
1990+ -- Mike
1991+
1992+
1993+Mon Jan 16 11:34:58 GMT 1995
1994+
1995+ * Change socksys.c for 1.1.81. There doesn't seem to be a
1996+ convenient define to test but I intended to roll out
1997+ most of the "magic" define testing for 1.2 to clean
1998+ things up.
1999+ -- Mike
2000+
2001+ * Ensure the segment registers are correctly set up when we
2002+ exec a new program - the LDT we may have been using before
2003+ no longer exists.
2004+ -- Mike
2005+
2006+
2007+Fri Jan 6 11:32:52 GMT 1995
2008+
2009+ * Fixed a problem where the Xenix 286 emultor wasn't getting
2010+ the correct return and error codes from lcall7s.
2011+ -- Mike
2012+
2013+ * Added support for exec() in the Xenix 286 emulator.
2014+ -- Mike
2015+
2016+ * Made the spin-before-launch trap in binfmt_xout.c settable
2017+ via a trace option, "xout-block". This is used to attach
2018+ gdb to a 286 process to debug the emulator.
2019+ -- Mike
2020+
2021+ * Fixed a problem with binfmt_xout.c setting the wrong intial
2022+ brk value for impure segmented binaries. The checks for brk
2023+ collisions with mapped space were failing brk changes. Before
2024+ the brk checks were introduced I image we simply trashed
2025+ text or data...
2026+ -- Mike
2027+
2028+
2029+Thu Jan 5 11:21:51 GMT 1995
2030+
2031+ * Added some debug to the STREAMS I_PUSH and I_POP. Also made
2032+ them succeed without actually doing anything. We may be able
2033+ to work round some instances of STREAMS usage one day...
2034+ -- Mike
2035+
2036+
2037+Wed Jan 4 11:17:14 GMT 1995
2038+
2039+ * Change yesterday's mkdir to use getname()/putname() to
2040+ fetch the pathname from user space. I hadn't realised
2041+ these were already in ksyms.c (although how long have they
2042+ been there? This breaks compatibility with older versions
2043+ of the kernel I guess).
2044+ -- Mike
2045+
2046+ * Implement the NIOC ioctls for getting file handles since
2047+ Oracle's TCP server seems to be wanting to do this for some
2048+ reason (why???). This is a simple implementation that simply
2049+ fills in the device number of the filesystem and the inode
2050+ number of the file. This seems to agree with what SCO is
2051+ doing. I don't know what the "exported" fields are or should be.
2052+ -- Mike
2053+
2054+
2055+Tue Jan 3 14:31:13 GMT 1995
2056+
2057+ * POSIX says that a pathname ending with a '/' means the current
2058+ directory whereas SYSV drops the trailing slash. This is only
2059+ a problem with mkdir() I think.
2060+ -- Mike
2061+
2062+
2063+Fri Dec 16 16:25:44 GMT 1994
2064+
2065+ * Added basic support for Wyse V/386 MPX syslocal().
2066+ -- Mike
2067+
2068+
2069+Fri Dec 9 09:14:04 GMT 1994
2070+
2071+ * Changed eaccess() again. We should always set the uid/gid
2072+ rather than fsuid/fsgid since the Linux access() call is
2073+ getting fsuid/fsgid from the current uid/gid.
2074+ -- Mike
2075+
2076+ * Don't bother trying to read x.out segments which have no
2077+ data in the executable.
2078+ -- Mike
2079+
2080+
2081+Thu Dec 8 11:51:06 GMT 1994
2082+
2083+ * Only include <linux/segment.h> if <asm/segment.h> hasn't
2084+ defined KERNEL_DS. The header in the linux subdirectory
2085+ was obsoleted in 1.1.69.
2086+ -- Mike
2087+
2088+
2089+Fri Dec 2 13:50:03 GMT 1994
2090+
2091+ * Force QMAGIC format when building x286emul.
2092+ -- Mike
2093+
2094+ * Patches for 1.1.69.
2095+ -- Mike
2096+
2097+
2098+Thu Dec 1 13:50:37 GMT 1994
2099+
2100+ * Binfmt_xout.c now checks the trace flag to see if debug messages
2101+ should be produced. Trace now has an "xout" option. Trace is
2102+ now a Linux binary which uses a personality() syscall to enable
2103+ emulation so the iBCS trace syscall becomes accessible.
2104+ -- Mike
2105+
2106+ * Changed binfmt_xout.c to use 0x1020 as the entry point for
2107+ the x286emul kludge overlay. This is the expected value
2108+ for a QMAGIC binary which is the default with the newest
2109+ compiler. Really I think uselib() should return something
2110+ useful but I haven't decided what.
2111+ -- Mike
2112+
2113+ * Made the schedule() trap (so gdb can be attached before the
2114+ process starts running) in binfmt_xout.c a CONFIG option
2115+ controlled by the XOUT_TRACE setting.
2116+ -- Mike
2117+
2118+ * Moved the configuration for the optional items out of Makefile
2119+ and into CONFIG.
2120+ -- Mike
2121+
2122+
2123+Wed Nov 30 17:08:05 GMT 1994
2124+
2125+ * Fixed a nasty bug in binfmt_coff.c where an extra page was
2126+ being allocated in the bss causing brk() checks in 1.1.64
2127+ and later to fail _in_certain_circumstances_.
2128+ -- Mike
2129+
2130+
2131+Wed Nov 30 13:58:46 GMT 1994
2132+
2133+ * Added support for unpacking ioctls passed via the STREAMS
2134+ interface and forwarding them to the file descriptor. With
2135+ a slight change to socksys so that devices with minor 2 get
2136+ an anonymous dgram socket immediately they are opened this
2137+ allows many more network programs to work. Thanks to an old
2138+ piece of code from Chip Rosenthal for revealing how it all
2139+ worked - it isn't in the documentation :-).
2140+ -- Mike
2141+
2142+
2143+Wed Nov 30 11:27:56 GMT 1994
2144+
2145+ * Fixed handling of brk and BSD sbrk so error returns are
2146+ handled correctly.
2147+
2148+
2149+Mon Nov 28 10:48:25 GMT 1994
2150+
2151+ * When doing an IPC_STAT on a semaphore force the semaphore
2152+ number to be zero as the kernel code erroneously checks
2153+ it.
2154+ -- Mike
2155+
2156+
2157+Fri Nov 25 14:26:41 GMT 1994
2158+
2159+ * Massive rework of ipc.c. The previous one was buggy as hell.
2160+ This one works with all the demo programs from the Wyse V/386
2161+ IPC documentation. Hopefully someone is going to test it with
2162+ some *real* applications!
2163+ -- Mike
2164+
2165+
2166+Tue Nov 22 09:11:46 GMT 1994
2167+
2168+ * Change the TTYDEVTYPE ioctl to say we on a pseudo terminal
2169+ rather than a console. Anything calling this is likely to
2170+ want to try fancy stuff like mapping the console memory
2171+ and playing with I/O ports if it thinks we are on a console.
2172+ -- Mike
2173+
2174+
2175+Tue Nov 22 09:07:04 GMT 1994
2176+
2177+ * Allow direct usage of 57600 and 115200 serial speeds from
2178+ the BSD domain with kernels 1.1.65 and later.
2179+ The mask-and-merge for iBCS<->Linux termios should be checked
2180+ as we tend to try and preserve unmappable bits where there
2181+ is no other conflict. In 99% of cases we won't see a problem
2182+ though...
2183+ -- Mike
2184+
2185+
2186+Mon Nov 21 10:05:19 GMT 1994
2187+
2188+ * Slight change to previous patch. Confusion over which struct
2189+ size we should be using for the verify_area plus we need to
2190+ do a VERIFY_WRITE as we will rewrite the data before returning.
2191+ -- Mike
2192+
2193+ * Changes to ipc.c for reading structures from user space.
2194+ -- Roberto Bagnara <bagnara@di.unipi.it>
2195+
2196+
2197+Thu Nov 17 15:24:23 GMT 1994
2198+
2199+ * Some of the unused KD ioctls were removed from Linux 1.1.64
2200+ (or was it 63?). Changed vtkd.c accordingly.
2201+ -- Mike
2202+
2203+
2204+Fri Nov 11 14:15:09 GMT 1994
2205+
2206+ * Moved the x286emul overlay to /usr/lib instead of /lib. There
2207+ is no real need for this to be on the root filesystem.
2208+ -- Mike
2209+
2210+
2211+Mon Nov 7 13:51:55 GMT 1994
2212+
2213+ * Added a version of the BSD exec.c patch for Linux 1.1.62.
2214+ -- Mike
2215+
2216+ * Extended SCO keyboard mapping for new kbd.
2217+ -- Mike
2218+
2219+
2220+Tue Nov 1 10:57:18 GMT 1994
2221+
2222+ * Changed the personality test in the BSD kernel patch. Apparently
2223+ FreeBSD uses a machtype of 134 so it's safer to test for Linux
2224+ rather than BSD.
2225+ -- Mike
2226+
2227+
2228+Fri Oct 28 11:25:43 GMT 1994
2229+
2230+ * General clean up of the configuration options in the Makefile
2231+ and elsewhere. It is now possible to choose which loaders are
2232+ included and whether or not BSD or Xenix 286 emulation is
2233+ required.
2234+ -- Mike
2235+
2236+ * Added the x286emul overlay library. This is still very alpha
2237+ but SCO's /bin/masm seems to do the things expected of it :-).
2238+ -- Mike
2239+
2240+
2241+Wed Oct 5 17:00:13 BST 1994
2242+
2243+ * Fleshed out the F_CHSIZE and F_RDCHK fcntls. I still don't
2244+ know if these are ever used from the user layer.
2245+ -- Mike
2246+
2247+
2248+Tue Oct 4 13:17:32 BST 1994
2249+
2250+ * Fixed the BSD termios mappings. This _looks_ ok from the
2251+ point of view of the NetBSD stty.
2252+ -- Mike
2253+
2254+
2255+Fri Sep 23 11:08:31 BST 1994
2256+
2257+ * Add SCO ODT version of CorelDraw to COMPAT file.
2258+ -- Doug Ledford
2259+
2260+
2261+Thu Sep 22 09:25:04 BST 1994
2262+
2263+ * Added the phone numbers of McGraw Hill's order desk to the
2264+ README file.
2265+ -- Mike
2266+
2267+ * chsize() was causing a segment error. The callmap entry punted
2268+ to a Linux system call but the argument count was not negative
2269+ resulting in a call to a bad function pointer.
2270+ -- Mike
2271+
2272+ * Linux doesn't have the l_sysid field in struct flock so we need
2273+ to slide the l_pid field down a word after doing a locking
2274+ fcntl.
2275+ -- Mike
2276+
2277+
2278+Tue Sep 20 10:31:01 BST 1994
2279+
2280+ * Added a simplistic implementation of writev since BSD seems
2281+ so keen to use it as much as possible.
2282+ -- Mike
2283+
2284+ * Fixed the x.out loader (mostly). This requires a minor patch
2285+ to the kernel. Expect this to be put in to the kernel itself
2286+ sometime after 1.1.51. Segment support is still buggy and
2287+ therefore disabled. If programs assume they know what segments
2288+ exist it they are broken anyway!
2289+ -- Mike
2290+
2291+
2292+Wed Sep 14 11:24:18 BST 1994
2293+
2294+ * Added extra fcntl code 14 (used by SVR4 for GETLCK).
2295+ -- Mike
2296+
2297+
2298+Tue Sep 6 10:58:49 BST 1994
2299+
2300+ * Added setting of fsuid/fsgid to the loaders and changed the
2301+ eaccess() function in xnx.c to flip fsuid/fsgid rather than
2302+ uid/gid. If you were having problems with setuid/setgid iBCS
2303+ binaries this is likely to help.
2304+ -- Mike
2305+
2306+
2307+Mon Sep 5 15:07:06 BST 1994
2308+
2309+ * Fixed the bad initialisation of howcnv in signal.c.
2310+ -- Mike
2311+
2312+
2313+Fri Sep 2 11:01:26 BST 1994
2314+
2315+ * Added a little program to the Tools subdirectory which will
2316+ restamp old binaries with the Linux machine type rather than
2317+ zero which is used by BSD. Once this is done you can reliably
2318+ distinguish between BSD and Linux binaries (the current Linux
2319+ linker will set the correct machine type on all new binaries).
2320+ -- Mike
2321+
2322+ * Updated the BSD patch.
2323+ -- Mike
2324+
2325+ * Changed binfmt_coff to avoid passing meaningless MAP_DENYWRITE
2326+ and MAP_EXECUTABLE flags to mmap when we are not actually
2327+ mapping from a file. It would probably never be a problem...
2328+ -- Mike
2329+
2330+
2331+Tue Aug 23 17:21:45 BST 1994
2332+
2333+ * Added my device trace stub in case anyone needs to investigate
2334+ and emulate some special device.
2335+ -- Mike
2336+
2337+
2338+Wed Aug 17 14:06:34 BST 1994
2339+
2340+ * Added an extern definition of the formats list needed by
2341+ the 1.0.x hooks. Presumably this went AWOL at some stage?
2342+ -- Mike
2343+
2344+
2345+Fri Aug 12 09:52:38 BST 1994
2346+
2347+ * Slight change to the socksys major allocation. Removed
2348+ redundant error message.
2349+ -- Mike
2350+
2351+
2352+Wed Aug 10 08:57:32 BST 1994
2353+
2354+ * Added the spelling corrections from the 1.1.42 kernel patch.
2355+ -- Mike
2356+
2357+
2358+Fri Aug 5 10:05:14 BST 1994
2359+
2360+ * Added Scott Michel's SCO multiscreen patches.
2361+ -- Mike
2362+
2363+ * More changes to loaders for latest kernel changes.
2364+ -- Mike
2365+
2366+
2367+Wed Jul 27 10:59:14 BST 1994
2368+
2369+ * Changes for 1.1.36 vm/mprotect.
2370+ -- Mike
2371+
2372+
2373+Tue Jul 26 14:20:27 BST 1994
2374+
2375+ * Tidied up the system call maps a little. ISC is now handled
2376+ by the same maps as SCO.
2377+ -- Mike
2378+
2379+
2380+Wed Jul 20 12:39:55 BST 1994
2381+
2382+ * Removed the lock.patch. This is in the latest kernels.
2383+ -- Mike
2384+
2385+ * Changed the socksys/SCO utsname stuff to do the right thing
2386+ if we have the hostname set to the fqdn and the domainname
2387+ set to the NIS domain. If hostname is not an fqdn we assume
2388+ we are using the domainname == IP domain convention.
2389+ -- Mike
2390+
2391+
2392+Wed Jun 29 13:34:34 BST 1994
2393+
2394+ * Revised the lock.patch to fix the unlock problem and allow
2395+ locks on devices. This should go to Linus (and probably has).
2396+ -- Mike
2397+
2398+ * Removed the kernel 1.1.20 patch. This isn't needed as of
2399+ 1.1.22.
2400+ -- Mike
2401+
2402+
2403+Mon Jun 27 09:26:24 BST 1994
2404+
2405+ * Can't use select() for nap() since the Linux select system
2406+ call expects to pull its arguments from the user stack.
2407+ Rewritten nap() using itimers.
2408+ -- Mike
2409+
2410+ * More fixes from Eric for 1.0 compatibility.
2411+ -- Mike
2412+
2413+
2414+Fri Jun 24 09:37:50 BST 1994
2415+
2416+ * Added a bit about time zones to the HINTS file.
2417+ -- Mike
2418+
2419+ * First draft of BSD termios mapping. Still buggy. Needs
2420+ work to be useful.
2421+ -- Mike
2422+
2423+ * Fixed BSD getdirentries() to align dirents on long word
2424+ boundaries. 'ls' now works and 'tcsh' finds and executes
2425+ commands successfully.
2426+ -- Mike
2427+
2428+ * ibcs_exit should be listed in callmap.inc with arg count 1
2429+ not -1.
2430+ -- Mike
2431+
2432+Thu Jun 23 09:48:43 BST 1994
2433+
2434+ * Lots more BSD-ish stuff. Commit now for release since there is
2435+ confusion over versions at the moment.
2436+ -- Mike
2437+
2438+ * List Xess MOTIF spreadsheet in COMPAT file.
2439+ -- Michael K.Johnson <johnsonm@merengue.oit.unc.edu>
2440+
2441+ * When slurping in mis-aligned COFF binaries we shouldn't be
2442+ aligning the file offset and virtual address to a page
2443+ boundary!
2444+ -- Mike
2445+
2446+ * Merged Eric's latest patches for 1.0 compatibility and Linux
2447+ ELF capability. This was done by hand. I think it's perfect...
2448+ -- Mike
2449+
2450+
2451+Wed Jun 22 14:28:38 BST 1994
2452+
2453+ * Many sigsuspend entries in the callmap had argumetn counts
2454+ of 1 instead of Spl. This caused kernel faults.
2455+ -- Mike
2456+
2457+ * Implemented the ioctls for the pseudo nfs device which under
2458+ SCO is used to get/set the NIS domain. You need to link
2459+ /dev/nfsd to /dev/socksys.
2460+ -- Mike
2461+
2462+ * The socksys getdomainname() was doing the same write null to
2463+ kernel space instead of user space as the wysev386 version.
2464+ -- Mike
2465+
2466+
2467+Tue Jun 21 08:54:34 BST 1994
2468+
2469+ * Use the map_bitvec() function (added as part of the BSD changes)
2470+ in signal.c. Note that there were quite a few mapping bugs in
2471+ the old code. I think I got them all but few would have been
2472+ triggered by my SCO and Wyse stuff.
2473+ -- Mike
2474+
2475+ * Snapshot BSD stuff again ready for release.
2476+ -- Mike
2477+
2478+ * binfmt_coff.c and binfmt_xout.c should be using mmap(NULL,...)
2479+ instead of zeromap_page_range as this will create the vm area
2480+ descriptor as well as mapping the pages. This is needed for
2481+ the verify_area() in 1.1.20 which has tighter checks than
2482+ previous versions.
2483+ -- Mike
2484+
2485+ * Map stack region as a GROWSDOWN vm area in binfmt_elf.c
2486+ -- Mike
2487+
2488+
2489+Fri Jun 17 16:42:59 BST 1994
2490+
2491+ * Major and on going work to add BSD support (optional - see the
2492+ Makefile). I'm committing this now so I have a current tree
2493+ ready for release when Linus goes to 1.1.20.
2494+ -- Mike
2495+
2496+ * Wyse get{host,domain}name were using direct assignment to add
2497+ a trailing null instead of put_fs_byte(). Oops...
2498+ -- Mike
2499+
2500+ * Changes for execution domain support which will be in the main
2501+ kernel as of 1.1.20. This allows easy registration of lcall7
2502+ handlers, binary loaders etc. for different personalities.
2503+ -- Mike
2504+
2505+
2506+Fri Jun 10 10:12:55 BST 1994
2507+
2508+ * Added patch file for kernel locking from Niklas Hallqvist
2509+ <niklas@appli.se>. This (or something very similar) should
2510+ end up in the kernel at some stage.
2511+ -- Mike
2512+
2513+ * Merged Eric's changes for 1.0 compatibilty - or rather didn't.
2514+ After playing with diff for quite a while I finally realised
2515+ we'd both done exactly the same changes :-). However Eric
2516+ has tested them...
2517+ -- Mike
2518+
2519+ * Added Brandon's iBCS trace binary from Eric's 1.0 compatibility
2520+ release.
2521+ -- Mike
2522+
2523+
2524+Thu Jun 9 10:22:56 BST 1994
2525+
2526+ * Mapped msgsys to ibcs_msgsys in callmap.inc. It existed, we
2527+ just didn't admit it before :-).
2528+ -- Mike
2529+
2530+
2531+Tue Jun 7 08:50:34 BST 1994
2532+
2533+ * Sorted out some more ioctl stuff and added a handler for the
2534+ STREAMS ioctl set. This is needed for I_NREAD (number of
2535+ characters readable). Some SYSV X libraries contain implicit
2536+ assumptions that the X connection is via a STREAM and use
2537+ I_NREAD in preference to BSD/socket FIONREAD.
2538+ -- Mike
2539+
2540+ * Oh, Jeez... The changes made for the official kernel patches
2541+ completely shafted the 1.0 compatibility. I've remerged the
2542+ previous code with the new code - there may still be some
2543+ things that need pulling back though. At this point I don't
2544+ have a 1.0 kernel tree around to test against.
2545+ -- Mike
2546+
2547+ * If a COFF program is not correctly aligned disable demand
2548+ paging and resort to slurping the whole lot in at start up.
2549+ -- Mike
2550+
2551+ * Added missing -I../include to the Tools Makefile.
2552+ -- Mike
2553+
2554+
2555+Fri Jun 3 11:53:21 BST 1994
2556+
2557+ * Added my virtual system tools. A virtualised SCO 3.2.4
2558+ system is usable for real work for me...
2559+ -- Mike
2560+
2561+ * Added the synchronous ioctl set. This conflicts with the
2562+ SCO 3.2.x (x < 4) ioctl for getting the video map so it should
2563+ be dependent on the file descriptor it is applied to but since
2564+ we don't currently support either...
2565+ -- Mike
2566+
2567+
2568+Thu Jun 2 17:02:26 BST 1994
2569+
2570+ * Added support for FIORDCHK ioctl. SCO says it's there for
2571+ "backward compatibility" but the system programs still
2572+ seem to use it (notably ksh).
2573+ -- Mike
2574+
2575+
2576+Tue May 31 13:39:34 BST 1994
2577+
2578+ * Patches to sysfs.c for 1.0.x compatibility from Tor with
2579+ some extra clean up.
2580+ -- Mike
2581+
2582+
2583+Fri May 27 09:15:21 BST 1994
2584+
2585+ * Ensure we set up signal() handlers as SA_ONESHOT and sigaction()
2586+ handlers as sticky - similar to patch from Remete Gabor.
2587+ -- Mike
2588+
2589+ * Added the SCO cxenix sigaction extensions. Barely tested...
2590+ -- Mike
2591+
2592+ * Added the cxenix {get,set}itimer calls discovered on SCO by
2593+ Brandon. Currently these are directly mapped to the Linux
2594+ syscalls. They are undocumented by SCO (as far as we know)
2595+ and untested by us (for now).
2596+ -- Mike
2597+
2598+
2599+Thu May 26 11:58:18 BST 1994
2600+
2601+ * Don't include the 0.0.0.0 to localhost address mapping if we
2602+ are building for 1.1.15+. This is mapped in the kernel as of
2603+ 1.1.6 and since we don't support 1.1 kernels before 15...
2604+ -- Mike
2605+
2606+ * Type of signal map vectors should be unsigned long not int.
2607+ -- Mike
2608+
2609+ * Allow tracing to be compiled in to the COFF loader and turned
2610+ on and off with the Tools/trace program.
2611+ -- Mike
2612+
2613+ * Signal maps moved out to maps/signal.inc. The only special
2614+ mapping that happens is for ISC which has a problem with
2615+ Oracle sending SIGSTOP to its backend when SIGSTOP doesn't
2616+ appear to be defined for ISC. We just map SIGSTOP to 0 so
2617+ it appears to work but does nothing.
2618+ -- Mike
2619+
2620+ * Changes for 1.1.15. This will not work with kernels between
2621+ 1.1.10 and 1.1.14 inclusive - guaranteed. It should still
2622+ work with the 1.0.x series but has not been tested recently.
2623+ It probably works against 1.1.0 to 1.1.13 inclusive but that
2624+ is purely coincidence - you shouldn't be using old 1.1.x
2625+ kernels as it's a development series.
2626+ -- Mike
2627+
2628+
2629+Tue May 24 17:27:54 1994 Eric Youngdale (eric@tantalus)
2630+
2631+ * binfmt_xout.c: Use linux_binfmt struct, register_binfmt,
2632+ unregister_binfmt as in pl14.
2633+
2634+ * binfmt_elf.c, binfmt_xout.c: Likewise.
2635+
2636+ * signals.c: Make signals[] and lsignals[] global variables.
2637+
2638+ * ibcs/include/ibcs.h: Add prototypes for signals[] and lsignals[].
2639+
2640+
2641+Tue May 24 10:37:01 BST 1994
2642+
2643+ * Added map entries for the ISC personality to all the maps
2644+ files. Must be more careful adding personalities.
2645+ -- Mike
2646+
2647+ * Added Oracle to the COMPAT file.
2648+ -- Mike
2649+
2650+ * Remember the problem with interrupting an Informix 4GL program
2651+ causing it to go psycho because of I/O errors from the tty?
2652+ Well, this doesn't happen with the new tty drivers in 1.1.13.
2653+ I never found why it happened...
2654+ -- Mike
2655+
2656+ * Noted that the 1.1.11 kernel patches are still ok with 1.1.13.
2657+ -- Mike
2658+
2659+
2660+Mon May 23 08:50:21 BST 1994
2661+
2662+ * Mapped ISC sysconf() to the existing Xenix sysconf(). This
2663+ looks right but isn't checked at all.
2664+ -- Mike
2665+
2666+ * Added ISC TCSETPGRP and TCGETPGRP ioctl traps.
2667+ -- Mike
2668+
2669+
2670+Thu May 19 09:26:34 BST 1994
2671+
2672+ * Added a bug hunting section to the README.
2673+ -- Mike
2674+
2675+ * Always access the socket layer by picking up the file operations
2676+ from an open socket descriptor. This removes the need for
2677+ kernel socket functions to be global and should be friendlier
2678+ towards a loadable socket layer one day.
2679+ -- Mike
2680+
2681+
2682+Mon May 16 10:20:38 BST 1994
2683+
2684+ * Always access system calls via the system call table regardless
2685+ of whether we are using a loadable module or linking directly
2686+ to the kernel. This allows other things to be loadable too.
2687+ -- Mike
2688+
2689+
2690+Wed May 11 13:52:12 BST 1994
2691+
2692+ * Added a tip on how to fix X font problems to the HINTS file.
2693+ Other "soft" changes welcome. Does anyone read the ChangeLog?
2694+ -- Mike
2695+
2696+ * Introduced the PROD.Patches directory and put the WP install
2697+ fixes in there. Documented in COMPAT and README.
2698+ -- Mike
2699+
2700+ * Added some hints on incompatible shell behaviour.
2701+ -- Mike
2702+
2703+
2704+Mon May 9 11:07:52 BST 1994
2705+
2706+ * Updated the 1.1 patch file for 1.1.11.
2707+ -- Mike
2708+
2709+ * Additions for Interactive 4.0
2710+ -- Karl Kiniger (ki@kretz.co.at)
2711+
2712+
2713+Fri May 6 12:03:00 BST 1994
2714+
2715+ * Merged old sysfs.c with the new sysfs.c. The code will now
2716+ work against any kernel - 1.0, 1.1, 1.1.9, 1.1.10...
2717+ -- Mike
2718+
2719+
2720+Thu May 5 10:39:52 BST 1994
2721+
2722+ * Reworked for compatibility with 1.1.10. Kernel patches
2723+ are *not* updated yet. We expect the kernel changes to go
2724+ in to the official distribution any time now...
2725+ -- Mike
2726+
2727+
2728+Tue May 3 12:03:31 BST 1994
2729+
2730+ * Joe/Brad's IPC additions.
2731+
2732+
2733+Fri Apr 29 10:06:10 BST 1994
2734+
2735+ * Updated the README to explain the difference between sysfs.c
2736+ and sysfs.c.old
2737+ -- Mike
2738+
2739+
2740+Wed Apr 27 11:38:52 BST 1994
2741+
2742+ * Added mapping of chsize() to ftruncate(). Implemented nap()
2743+ using select().
2744+ -- Mike
2745+
2746+ * Further fix to termios mapping for iexten and tostop.
2747+ -- Mike
2748+
2749+ * Updated the 1.1.? patch. New ksyms.c with fewer symbols plus
2750+ removed all the socket patches. Sockfunc.h is no longer
2751+ required. The 1.0 patch isn't updated but the extra cruft
2752+ that's in there now shouldn't be any problem.
2753+ -- Mike
2754+
2755+
2756+Tue Apr 26 11:49:07 BST 1994
2757+
2758+ * Removed references to linux/sockfunc.h. We seem to have run
2759+ out of internal socket functions to put in it finally.
2760+ -- Mike
2761+
2762+ * Removed use of socki_lookup(). This just wraps some checks
2763+ around inode->i_socket. We assume the socket layer is stable
2764+ by now...
2765+ -- Mike
2766+
2767+ * Access [gs]etsockopt via the socketcall interface.
2768+ -- Mike
2769+
2770+ * If we have to use our own CFLAGS look in the include directory
2771+ above in case we have been dropped in to the kernel.
2772+ -- Eric
2773+
2774+ * Grab socket file operations when we create a socket rather
2775+ than linking against them directly. Similar to Eric's
2776+ changes but different...
2777+ -- Mike
2778+
2779+
2780+Fri Apr 22 11:10:18 BST 1994
2781+
2782+ * The 'x' class of ioctls are back to being termios rather
2783+ than termio. The problem was that the field size in iBCS
2784+ termios and Linux termios is different.
2785+ -- Mike
2786+
2787+ * Added iBCS <-> Linux termios mapping. This is untested and
2788+ probably imperfect at this stage but nothing crashes with
2789+ this code...
2790+ -- Mike
2791+
2792+ * The iBCS time() syscall doesn't take an argument, the save,
2793+ if any, is handled in the interface library.
2794+ -- Mike
2795+
2796+ * Updated the 1.1 kernel patch to be against 1.1.8. It won't
2797+ work with anything less than 1.1.8 but then if you are
2798+ playing with 1.1 you should be playing with the latest...
2799+ This involves a change in the way sysfs() works. If you
2800+ are using 1.0 and have applications that call sysfs()
2801+ (practically none do) then you need to build with sysfs.c.old.
2802+ -- Mike
2803+
2804+ * The Linux kernel 1.1.8 replaces the static file_systems
2805+ table with a linked list ready for loadable file systems.
2806+ Naturally, I was ready for this... :-(
2807+ -- Mike
2808+
2809+
2810+Thu Apr 21 10:34:34 BST 1994
2811+
2812+ * sysfs.c should be including linux/string.h to get the
2813+ inline string functions rather than needing library
2814+ functions.
2815+ -- Mike
2816+
2817+ * Added code to map between Linux termio structs and SCO/iBCS
2818+ termio structs. There are slight differences. Mapping needs
2819+ to be done for termios structs too. Anything that uses termios
2820+ at this stage is likely to ge a nasty shock!
2821+ -- Mike
2822+
2823+
2824+Tue Apr 19 22:56:55 1994 Eric Youngdale (eric@esp22)
2825+
2826+ * ibcs.h: Put declaration of sys_call_table outside of ifdef.
2827+ (So can be compiled into kernel instead as a module).
2828+
2829+
2830+Tue Apr 19 10:21:17 BST 1994
2831+
2832+ * It looks as though the 'x' class of ioctls should be termio
2833+ ioctls rather than termios. At least this is the case as far
2834+ as SCO 3.2.4 stty appears to be concerned.
2835+ -- Mike
2836+
2837+ * Avoid copying the entire lock structure backwards and forwards
2838+ just to increment one field in open.c. There could be a problem
2839+ here - SCO has a sysid field *before* the pid field but only
2840+ if _XOPEN_SOURCE or _POSIX_SOURCE is defined at compile time.
2841+ There appears to be no obvious way to know what is being used???
2842+ -- Mike
2843+
2844+
2845+Mon Apr 18 08:49:37 BST 1994
2846+
2847+ * There appear to odd little niceties involved with SYSV which
2848+ depend on system configuration and the way users do things.
2849+ Added a HINTS file with known problems/workarounds.
2850+ -- Mike
2851+
2852+ * Changed some annoying KERN_ERRs to KERN_DEBUGs in signal.c
2853+ -- Mike
2854+
2855+ * Watch out for (mis)use of INADDR_ANY instead of localhost
2856+ (primarily by syslog() code?) and replace it with the
2857+ localhost address. We should perhaps do this for sendto()
2858+ as well? (Eric spotted this one on CorelDraw but it's a
2859+ problem with the standard libsocket.c)
2860+ -- Mike
2861+
2862+ * Processes should be allowed to reduce their file size
2863+ limit but only increase it if they have root privileges.
2864+ -- Mike
2865+
2866+ * Fixed the bug in [f]statfs where the first two arguments
2867+ to memcpt_tofs() were exchanged (spotted by Eric).
2868+ -- Mike
2869+
2870+ * SCO seems to like utsys (v7_utsname) to return the same
2871+ thing for sysname and nodename fields just like the SCO
2872+ extended utsname structure has. The SVR4 (abi_utsname)
2873+ return is unknown at this time.
2874+ -- Mike
2875+
2876+ * Removed comments on IPC from README. It *is* fixed?
2877+ -- Mike
2878+
2879+ * Fix IPC which was broken by syscall changes. Also fix
2880+ structure mappings.
2881+ -- Joseph L. Portman III <baron@hebron.connected.com>
2882+
2883+
2884+Thu Apr 14 11:27:24 BST 1994
2885+
2886+ * At some stage SCO managed to build some of their binaries
2887+ with the copyright comment string in quotes so we have a
2888+ new recognition string in the COFF loader. (Seen in uname
2889+ on a 3.2.2 system).
2890+ -- Mike
2891+
2892+ * If we have tracing compiled in then only give unsupported
2893+ syscall messages if we are tracing the API or the syscall
2894+ in question. This allows us to quieten unsupported but
2895+ unimportant syscalls.
2896+ -- Mike
2897+
2898+ * Comment on the IPC limitations in the README file.
2899+ -- Mike
2900+
2901+ * Added implementation of xnx_pathconf(). Actually it doesn't
2902+ look as if we really need it. The Microsoft C compiler seems
2903+ to be misusing it anyway and doesn't even care that it gets
2904+ an error.
2905+ -- Mike
2906+
2907+
2908+Wed Apr 13 09:14:50 BST 1994
2909+
2910+ * Added handling of TIOC[GS]PGRP.
2911+ -- Mike
2912+
2913+ * Added implementation of xnx_eaccess(). This is currently
2914+ simpleminded because Linux access() is. My eaccess() may
2915+ even be wrong.
2916+ -- Mike
2917+
2918+ * When tracing signal delivery we shouldn't be clearing the
2919+ signal flag after reporting it or the signal is never actually
2920+ delivered. I copied the assembler from the kernel and forgot
2921+ to deleted an opcode...
2922+ -- Mike
2923+
2924+ * Signal 0 should have been identity mapped so kill 0 works.
2925+ -- Brandon S. Allbery (kf8nh@kf8nh.ampr.org) (bsa@kf8nh.wariat.org)
2926+
2927+Tue Apr 12 14:30:25 BST 1994
2928+
2929+ * Corrected file size passed to/from setrlimit/getrlimit
2930+ -- Graham Adams (gadams@ddrive.demon.co.uk)
2931+
2932+
2933+Tue Apr 12 11:16:45 BST 1994
2934+
2935+ * Added support for an obscure SCO extension that is used
2936+ to get SCO's extended utsname information.
2937+ -- Mike
2938+
2939+ * Changed ipc.c to always go via the ipc syscall rather than
2940+ direct to internal functions. This should survive if ipc
2941+ isn't in the kernel. It should even do sensible things if
2942+ the ipc module is loaded/unloaded on us.
2943+ -- Mike
2944+
2945+ * Initial changes to access system calls via sys_call_table
2946+ -- Mike
2947+
2948+
2949+05 April 1994
2950+
2951+ * Eric's pre-release fixes.
2952+
2953+
2954+Wed Mar 30 22:35:28 1994 Eric Youngdale (eric@esp22)
2955+
2956+ * ioctl.c: Change 'F' to 'f' for SVr4 FIONREAD ioctl.
2957+
2958+ * Makefile: Add svr4.c.
2959+
2960+ * svr4.c: New file (sort of - it got lost in shuffle before).
2961+
2962+ * include/ibcs/ibcs.h: Include prototypes for abi_uname.
2963+
2964+ * maps/callmap.inc: Insert abi_uname in syscall number 135.
2965+ Add sys_rename in slot 134 (emacs v18 requires this).
2966+
2967+
2968+Tue Mar 29 23:32:35 1994 Eric Youngdale (eric@esp22)
2969+
2970+ * Makefile: Fix so that we do not need uname. Use symbol from
2971+ .config instead.
2972+
2973+ * README: Update a bit.
2974+
2975+
2976+28 March 1994
2977+
2978+ * Preparation for release:
2979+ Tidy up documentation and create CREDITS file from the old
2980+ ToDo list.
2981+ -- Mike
2982+
2983+
2984+27 March 1994
2985+
2986+ * Preparation for release:
2987+ Move headers into a subdirectory.
2988+ Move maps into a subdirectory.
2989+ -- Mike
2990+
2991+
2992+25 March 1994
2993+
2994+ * Changed the COFF loader so that if the filesystem doesn't
2995+ support mmap we read in the whole lot initially and let
2996+ it page to swap if necessary. This is already in the x.out
2997+ loader, it should go in the ELF loader too at some point.
2998+ -- Mike
2999+
3000+
3001+24 March 1994
3002+
3003+ * Added a loader for x.out i386 small model binaries - i.e 386
3004+ Xenix programs. <=286, non-small model binaries are not
3005+ supported and not likely to be in the near future.
3006+ -- Mike
3007+
3008+
3009+Wed Mar 23 23:12:54 1994 Eric Youngdale (eric@esp22)
3010+
3011+ * Add ioctl for 0x4004667f (FIONREAD) (used by SVr4).
3012+
3013+ * map.h (map_segment.map): Make unsigned.
3014+
3015+ * hrtsys.c: New file implementing parts of the hrtsys syscall.
3016+
3017+
3018+02 March 1994
3019+
3020+ * Add socket value mappings. This meant a general move round
3021+ to tidy things up and group map functions/tables.
3022+ There is a new kernel patch in the Patches directory called
3023+ net.patch which gives us access to the sock_*sockopts
3024+ functions directly.
3025+ -- Mike
3026+
3027+
3028+28 February 1994
3029+
3030+ * Implementation of poll().
3031+ -- Eric
3032+
3033+
3034+25 February 1994
3035+
3036+ * Pedantic change to call maps so that IBCS_function contains
3037+ a void * instead of a function pointer - we cast it as
3038+ necessary later in emulate.c. The warnings were annoying me.
3039+
3040+ * Moved struct abi_sigaction from signal.c to abi4.h so it is
3041+ available for prototype declarations. Changed prototype for
3042+ abi_sigsuspend to correspond to implementation in signal.c.
3043+ -- Mike
3044+
3045+ * Reversed out Eric's earlier signal patches and added new ones.
3046+ -- Mike
3047+
3048+ * Updated trace code and trace control program to be useful.
3049+ Control of tracing individual functions is still not there
3050+ yet - perhaps another day.
3051+ Default trace mode is now none (i.e. only functions with
3052+ the trace flag set are traced). Use the trace program to
3053+ change the trace level.
3054+ -- Mike
3055+
3056+ * File modes (open/fcntl flags) are different between Linux and
3057+ iBCS so we need to map between them. Open also requires this
3058+ so fcntl.c is now merged with open.c. Failure to set and reset
3059+ non-blocking mode was what was breaking Unipox.
3060+ -- Mike
3061+
3062+ * Signal handling function changes to map to and from the Linux
3063+ signal set and sigaction flags correctly.
3064+ -- Eric
3065+
3066+
3067+24 February 1994
3068+
3069+ * Added code to the emulate() function to let us know when we
3070+ are about to process a signal on exit from the syscall.
3071+ -- Mike
3072+
3073+ * Implemented proctl() as a no-op. It's not really relevent
3074+ under Linux.
3075+ -- Mike
3076+
3077+ * Added argument count and type for eaccess()
3078+ -- Mike
3079+
3080+ * Have emulate.c return -ENOSYS for unimplemented system calls
3081+ rather than zero.
3082+ -- Mike
3083+
3084+ * Added Eric's patches to waitpid.
3085+
3086+ * Created the ChangeLog!
3087diff -uNr --exclude-from=dontdiff linux-2.4.3/Documentation/abi/Error.map linux/Documentation/abi/Error.map
3088--- linux-2.4.3/Documentation/abi/Error.map Thu Jan 1 01:00:00 1970
3089+++ linux/Documentation/abi/Error.map Fri Mar 30 16:12:20 2001
3090@@ -0,0 +1,143 @@
3091+Mapping of error codes from Linux to various personalities. Codes which Linux
3092+may generate but which can't be mapped directly in a given personality must
3093+be mapped to the nearest equivalent which may invoke the correct behaviour
3094+in the application. This is especially true for things like the ERESTART*
3095+set of error returns!
3096+
3097+NOTES:
3098+
3099+The Xenix set was built with reference to an old SCO Xenix manual rather
3100+than by reference to a real system. It may be incomplete or wrong. If anyone
3101+has access to the Xenix TCP/IP kit we need to add mappings for the TCP/IP
3102+error codes.
3103+
3104+Other personalities may need adding. COFF binaries default
3105+
3106+Linux Name Linux ABI SCO Wyse Xenix 386bsd
3107+
3108+EPERM 1 /* Operation not permitted */
3109+ENOENT 2 /* No such file or directory */
3110+ESRCH 3 /* No such process */
3111+EINTR 4 /* Interrupted system call */
3112+EIO 5 /* I/O error */
3113+ENXIO 6 /* No such device or address */
3114+E2BIG 7 /* Arg list too long */
3115+ENOEXEC 8 /* Exec format error */
3116+EBADF 9 /* Bad file number */
3117+ECHILD 10 /* No child processes */
3118+EAGAIN 11 35 /* Try again */
3119+ENOMEM 12 /* Out of memory */
3120+EACCES 13 /* Permission denied */
3121+EFAULT 14 /* Bad address */
3122+ENOTBLK 15 /* Block device required */
3123+EBUSY 16 /* Device or resource busy */
3124+EEXIST 17 /* File exists */
3125+EXDEV 18 /* Cross-device link */
3126+ENODEV 19 /* No such device */
3127+ENOTDIR 20 /* Not a directory */
3128+EISDIR 21 /* Is a directory */
3129+EINVAL 22 /* Invalid argument */
3130+ENFILE 23 /* File table overflow */
3131+EMFILE 24 /* Too many open files */
3132+ENOTTY 25 /* Not a typewriter */
3133+ETXTBSY 26 /* Text file busy */
3134+EFBIG 27 /* File too large */
3135+ENOSPC 28 /* No space left on device */
3136+ESPIPE 29 /* Illegal seek */
3137+EROFS 30 /* Read-only file system */
3138+EMLINK 31 /* Too many links */
3139+EPIPE 32 /* Broken pipe */
3140+EDOM 33 /* Math argument out of domain of func */
3141+ERANGE 34 /* Math result not representable */
3142+EDEADLK 35 45 45 45 36 11 /* Resource deadlock would occur */
3143+ENAMETOOLONG 36 78 78 228 EINVAL 63 /* File name too long */
3144+ENOLCK 37 46 46 46 45 77 /* No record locks available */
3145+ENOSYS 38 89 89 EINVAL EINVAL 78 /* Function not implemented */
3146+ENOTEMPTY 39 93 145 231 EINVAL 66 /* Directory not empty */
3147+ELOOP 40 90 150 227 EINVAL 62 /* Too many symbolic links encountered */
3148+EWOULDBLOCK EAGAIN 90 90 200 EINVAL 35 /* Operation would block */
3149+ENOMSG 42 35 35 35 43 ? /* No message of desired type */
3150+EIDRM 43 36 36 36 44 ? /* Identifier removed */
3151+ECHRNG 44 37 37 37 EINVAL ? /* Channel number out of range */
3152+EL2NSYNC 45 38 38 38 EINVAL ? /* Level 2 not synchronized */
3153+EL3HLT 46 39 39 39 EINVAL ? /* Level 3 halted */
3154+EL3RST 47 40 40 40 EINVAL ? /* Level 3 reset */
3155+ELNRNG 48 41 41 41 EINVAL ? /* Link number out of range */
3156+EUNATCH 49 42 42 42 EINVAL ? /* Protocol driver not attached */
3157+ENOCSI 50 43 43 43 EINVAL ? /* No CSI structure available */
3158+EL2HLT 51 44 44 44 EINVAL ? /* Level 2 halted */
3159+EBADE 52 ? 50 50 EINVAL ? /* Invalid exchange */
3160+EBADR 53 ? 51 51 EINVAL ? /* Invalid request descriptor */
3161+EXFULL 54 ? 52 52 EINVAL ? /* Exchange full */
3162+ENOANO 55 ? 53 53 EINVAL ? /* No anode */
3163+EBADRQC 56 ? 54 54 EINVAL ? /* Invalid request code */
3164+EBADSLT 57 ? 55 55 EINVAL ? /* Invalid slot */
3165+EDEADLOCK 58 ? 56 56 36 11 /* File locking deadlock error */
3166+EBFONT 59 ? 57 57 EINVAL ? /* Bad font file format */
3167+ENOSTR 60 EINVAL ? /* Device not a stream */
3168+ENODATA 61 EINVAL ? /* No data available */
3169+ETIME 62 EINVAL ? /* Timer expired */
3170+ENOSR 63 EINVAL ? /* Out of streams resources */
3171+ENONET 64 EINVAL ? /* Machine is not on the network */
3172+ENOPKG 65 EINVAL ? /* Package not installed */
3173+EREMOTE 66 EINVAL 71 /* Object is remote */
3174+ENOLINK 67 EINVAL ? /* Link has been severed */
3175+EADV 68 EINVAL ? /* Advertise error */
3176+ESRMNT 69 EINVAL ? /* Srmount error */
3177+ECOMM 70 EINVAL ? /* Communication error on send */
3178+EPROTO 71 ? ? /* Protocol error */
3179+EMULTIHOP 72 74 74 74 ? ? /* Multihop attempted */
3180+EDOTDOT 73 76 76 76 ? ? /* RFS specific error */
3181+EBADMSG 74 77 77 77 ? ? /* Not a data message */
3182+EOVERFLOW 75 79 EINVAL EINVAL ? ? /* Value too large for defined data type */
3183+ENOTUNIQ 76 80 80 80 ? ? /* Name not unique on network */
3184+EBADFD 77 81 81 81 ? ? /* File descriptor in bad state */
3185+EREMCHG 78 82 82 82 ? ? /* Remote address changed */
3186+ELIBACC 79 83 83 83 ? ? /* Can not access a needed shared library */
3187+ELIBBAD 80 84 84 84 ? ? /* Accessing a corrupted shared library */
3188+ELIBSCN 81 85 85 85 ? ? /* .lib section in a.out corrupted */
3189+ELIBMAX 82 86 86 86 ? ? /* Attempting to link in too many shared libraries */
3190+ELIBEXEC 83 87 87 87 ? ? /* Cannot exec a shared library directly */
3191+EILSEQ 84 88 EINVAL EINVAL ? ? /* Illegal byte sequence */
3192+ERESTART 85 91 EINTR EINTR ? ? /* Interrupted system call should be restarted */
3193+ESTRPIPE 86 92 EINVAL EINVAL ? ? /* Streams pipe error */
3194+EUSERS 87 94 EINVAL 233 ? 68 /* Too many users */
3195+ENOTSOCK 88 95 93 203 ? 38 /* Socket operation on non-socket */
3196+EDESTADDRREQ 89 96 94 204 ? 39 /* Destination address required */
3197+EMSGSIZE 90 97 95 205 ? 40 /* Message too long */
3198+EPROTOTYPE 91 98 96 206 ? 41 /* Protocol wrong type for socket */
3199+ENOPROTOOPT 92 99 EINVAL 207 ? 42 /* Protocol not available */
3200+EPROTONOSUPPORT 93 120 97 208 ? 43 /* Protocol not supported */
3201+ESOCKTNOSUPPORT 94 121 98 209 ? 44 /* Socket type not supported */
3202+EOPNOTSUPP 95 122 99 210 ? 45 /* Operation not supported on transport endpoint */
3203+EPFNOSUPPORT 96 123 100 211 ? 46 /* Protocol family not supported */
3204+EAFNOSUPPORT 97 124 101 212 ? 47 /* Address family not supported by protocol */
3205+EADDRINUSE 98 125 102 213 ? 48 /* Address already in use */
3206+EADDRNOTAVAIL 99 126 103 214 ? 49 /* Cannot assign requested address */
3207+ENETDOWN 100 127 104 215 ? 50 /* Network is down */
3208+ENETUNREACH 101 128 105 216 ? 51 /* Network is unreachable */
3209+ENETRESET 102 129 106 217 ? 52 /* Network dropped connection because of reset */
3210+ECONNABORTED 103 130 107 218 ? 53 /* Software caused connection abort */
3211+ECONNRESET 104 131 108 219 ? 54 /* Connection reset by peer */
3212+ENOBUFS 105 132 63 220 ? 55 /* No buffer space available */
3213+EISCONN 106 133 110 221 ? 56 /* Transport endpoint is already connected */
3214+ENOTCONN 107 134 111 222 ? 57 /* Transport endpoint is not connected */
3215+ESHUTDOWN 108 143 112 223 ? 58 /* Cannot send after transport endpoint shutdown */
3216+ETOOMANYREFS 109 144 113 224 ? 59 /* Too many references: cannot splice */
3217+ETIMEDOUT 110 145 114 225 ? 60 /* Connection timed out */
3218+ECONNREFUSED 111 146 115 226 ? 61 /* Connection refused */
3219+EHOSTDOWN 112 147 116 229 ? 64 /* Host is down */
3220+EHOSTUNREACH 113 148 117 230 ? 65 /* No route to host */
3221+EALREADY 114 149 92 202 ? 37 /* Operation already in progress */
3222+EINPROGRESS 115 150 91 201 ? 36 /* Operation now in progress */
3223+ESTALE 116 EINVAL EINVAL 237 ? 70 /* Stale NFS file handle */
3224+EUCLEAN 117 ? 135 135 35 ? /* Structure needs cleaning */
3225+ENOTNAM 118 ? 137 137 37 ? /* Not a XENIX named type file */
3226+ENAVAIL 119 ? 138 138 38 ? /* No XENIX semaphores available */
3227+EISNAM 120 ? 139 139 39 ? /* Is a named type file */
3228+EREMOTEIO 121 ? 140 140 EINVAL ? /* Remote I/O error */
3229+EDQUOT 122 ? ENOSPC 234 ENOSPC 69 /* Quota exceeded */
3230+
3231+ERESTARTSYS 512 EINTR EINTR EINTR EINTR EINTR
3232+ERESTARTNOINTR 513 EINTR EINTR EINTR EINTR EINTR
3233+ERESTARTNOHAND 514 EINTR EINTR EINTR EINTR EINTR /* restart if no handler.. */
3234diff -uNr --exclude-from=dontdiff linux-2.4.3/Documentation/abi/HINTS linux/Documentation/abi/HINTS
3235--- linux-2.4.3/Documentation/abi/HINTS Thu Jan 1 01:00:00 1970
3236+++ linux/Documentation/abi/HINTS Fri Mar 30 16:12:20 2001
3237@@ -0,0 +1,245 @@
3238+PROBLEM:
3239+ Cannot determine user name by reference to /etc/passwd. Failure
3240+ to determine the user name causes some programs (notably programs
3241+ built with Informix 4GL) to exit.
3242+
3243+REASON:
3244+ The functions that parse /etc/passwd are sensitive under SCO
3245+ at least. A corrupt line is taken to be the end of the file
3246+ and further entries are ignored. Any line which has a null
3247+ home directory counts as a corrupt line for SCO.
3248+
3249+SOLUTION:
3250+ Ensure that all lines in /etc/passwd have home directories
3251+ specified. Simply edit /etc/passwd with an editor.
3252+
3253+
3254+# -----------------------------------------------------------------------
3255+
3256+PROBLEM:
3257+ Cannot connect to X server using local connection.
3258+
3259+REASON:
3260+ Some versions of X libraries seem to require 'localhost' to be
3261+ allowed to connect to the X server even if we aren't using a
3262+ TCP/IP connection. The X libraries used for VSI*FAX require
3263+ this, the X libraries used for WordPerfect don't.
3264+
3265+SOLUTION:
3266+ Explicitly allow 'localhost' to connect to the X server using
3267+ 'xhost localhost'.
3268+
3269+
3270+# -----------------------------------------------------------------------
3271+
3272+PROBLEM:
3273+ Installation disks claim to be Unix tar format but they appear
3274+ to be blank MS-DOS format disks!
3275+
3276+REASON:
3277+ Unix provides two floppy devices, the normal floppy devices
3278+ that we all know and love (and which are listed as the Xenix
3279+ compatible devices in the man page) and a second set which
3280+ skips the first track of the disk. For some reason a few vendors
3281+ seem to use this second set when preparing distribution disks.
3282+ WordPerfect seem to do this. Linux currently only supports
3283+ the normal floppy devices.
3284+
3285+SOLUTION:
3286+ You have to skip the first track by hand and read each disk
3287+ individually. Try 'dd if=/dev/fd0 bs=18k skip=1 | tar xfv -'
3288+ for a 3.5" high density disk. Change the 18k to 15k for a
3289+ 5.25" high density disk.
3290+
3291+# -----------------------------------------------------------------------
3292+
3293+PROBLEM:
3294+ A script bombs out with an unexpected EOF looking for "'". This
3295+ only happens on Linux.
3296+
3297+REASON:
3298+ There is a bug in the script which is only a problem on Linux.
3299+ Take the following example:
3300+
3301+ count=`ls | wc | awk '{ printf "%05d", $1 }`
3302+
3303+ Note the missing "'" at the end of the awk statment. The /bin/sh
3304+ supplied with SCO will assume (in this case correctly) that the
3305+ "'" should have occurred immediately before the closing "`" and
3306+ the expression will succeed. The /bin/sh used with Linux (normally
3307+ bash) does not make this assumption and gives an error message.
3308+
3309+SOLUTION:
3310+ Either fix the script or arrange to have it run by a SYSV shell
3311+ rather than bash.
3312+
3313+# -----------------------------------------------------------------------
3314+
3315+PROBLEM:
3316+ Test complains that a numeric argument is required before -eq, -le
3317+ etc.
3318+
3319+REASON:
3320+ The GNU shellutils test and the test built in to bash which are
3321+ the versions of test used under Linux do not accept a null
3322+ argument as equivalent to 0 so 'test "" -le 5' will give an error.
3323+ Under SCO a null argument is taken as equivalent to 0 so the
3324+ statement would be evaluated as 'test 0 -le 5'.
3325+
3326+SOLUTION:
3327+ Fix the script to check arguments for validity before using them
3328+ or provide a fixed version of test and ensure that it is used in
3329+ preference to any shell built in.
3330+
3331+# -----------------------------------------------------------------------
3332+
3333+PROBLEM:
3334+ Some X fonts supplied with packages appear corrupt.
3335+
3336+REASON:
3337+ These are probably snf fonts. The XFree86 X server used with
3338+ Linux appears to fail to load some snf fonts silently and displays
3339+ garbage. Pcf fonts work ok and should be used where possible.
3340+
3341+SOLUTION:
3342+ If you only have the snf fonts all you can do is to try asking the
3343+ vendor for pcf versions or the bdf definitions.
3344+
3345+ If you have the bdf definitions (WordPerfect ship them) then you
3346+ can build a pcf set using:
3347+
3348+ # for bdffn in *.bdf
3349+ > do
3350+ > fn=`basename $bdffn .bdf`
3351+ > [ -r $fn.snf ] && mv $fn.snf $fn.snf.old
3352+ > bdftopcf -o $fn.pcf $bdffn
3353+ > done
3354+ # mkfontdir .
3355+ # xset fp rehash
3356+
3357+# -----------------------------------------------------------------------
3358+
3359+PROBLEM:
3360+ Function keys don't work.
3361+
3362+REASON:
3363+ The default sequences for function keys under Linux are "sort of"
3364+ VT10x like whereas you have probably told your application that
3365+ you are running on an ansi or SCO console.
3366+
3367+SOLUTION:
3368+ It is probably best to run as an ansi screen - especially if
3369+ colour is used - so use the "loadkeys" program to load the
3370+ SCO.map keyboard description from the PROD.Patches directory.
3371+ This directory also contains flexible termcap and terminfo
3372+ descriptions which will allow you run permanently with a SCO
3373+ or SVR4-like console.
3374+
3375+# -----------------------------------------------------------------------
3376+
3377+PROBLEM:
3378+ Line drawing characters come out as weird symbols.
3379+
3380+REASON:
3381+ The application believes you are using a console screen with a
3382+ PC character set and is using 8-bit codes rather than escape
3383+ sequences. Linux defaults to an ISO8859-1 character set though.
3384+
3385+SOLUTION:
3386+ Linux can be switched to PC character set mode with the escape
3387+ sequence ESC-(-U. Arrange to have this sequence sent either
3388+ before the application is started or as part of the initialisation
3389+ that the application does. You can restore the ISO character
3390+ set afterwards with ESC-(-K.
3391+
3392+# -----------------------------------------------------------------------
3393+
3394+PROBLEM:
3395+ SYSV binaries see the wrong time zone.
3396+
3397+REASON:
3398+ SYSV binaries establish the time zone from the TZ environment
3399+ variable whereas Linux uses BSD style zoneinfo files generally.
3400+
3401+SOLUTION:
3402+ Set the TZ environment variable to reflect your time zone. Note
3403+ that the zoneinfo mechanism can also use TZ in preference to
3404+ the /usr/lib/zoneinfo/localtime file if you wish. For this to
3405+ work you must have /usr/lib/zoneinfo/posixrules linked to one
3406+ of the US timezone files. The posixrules file defines how the
3407+ zoneinfo functions interpret TZ and this information is only
3408+ found in the US data files. See the documentation for the
3409+ timezone/zoneinfo package for details.
3410+
3411+# -----------------------------------------------------------------------
3412+
3413+PROBLEM:
3414+ BSD binaries don't see the right time zone.
3415+
3416+REASON:
3417+ Although BSD binaries use the same timezone handling method as
3418+ Linux they expect the zoneinfo information in different places.
3419+
3420+SOLUTION:
3421+ Make the links:
3422+
3423+ # ln -s /usr/lib/zoneinfo /etc/localtime
3424+ # ln -s /usr/lib/zoneinfo /usr/share/zoneinfo
3425+
3426+# -----------------------------------------------------------------------
3427+
3428+PROBLEM:
3429+ BSD binaries complain that they can't find /etc/termcap.
3430+
3431+REASON:
3432+ They may be lying. BSD sometimes uses /usr/share/misc/termcap
3433+ or ~/.termcap (if it exists).
3434+
3435+SOLUTION:
3436+ Either move termcap to /usr/share/misc and make /etc/termcap
3437+ a link to it or make /usr/share/misc/termcap a link to /etc/termcap.
3438+ The use of /usr/share/misc/termcap may be useful in a networked
3439+ environment.
3440+# -----------------------------------------------------------------------
3441+
3442+PROBLEM:
3443+ SVr4 binaries cannot locate shared libraries, or fail to start.
3444+
3445+REASON:
3446+ The shared libraries are not in the correct location, or the dynamic
3447+ loader cannot be located by the kernel.
3448+
3449+SOLUTION:
3450+ Put all SVr4 shared libraries in the directory /usr/i486-sysv4/lib.
3451+ Then create two symbolic links:
3452+
3453+ ln -s /usr/i486-sysv4/lib/libc.so.1 /usr/lib/libc.so.1
3454+ ln -s /usr/i486-sysv4/lib/ld.so.1 /usr/lib/ld.so.1
3455+# -----------------------------------------------------------------------
3456+
3457+PROBLEM:
3458+ SVr4 binaries want to access terminfo instead of termcap
3459+
3460+REASON:
3461+ SVr4 traditionally uses something called terminfo instead of
3462+ termcap to specify terminal characteristics.
3463+
3464+SOLUTION:
3465+ The ncurses distribution (available on many fine ftp sites)
3466+ contains a terminfo database. Just install this, and you
3467+ should be all set.
3468+# -----------------------------------------------------------------------
3469+
3470+PROBLEM:
3471+ The Informix Dynamic Server installation for SCO says
3472+ invalid INFORMIXDIR or insufficient space.
3473+
3474+REASON:
3475+ It wants to scan /etc/mnttab to find all possible
3476+ filesystems. Since Linux uses /etc/mtab instead the
3477+ installation program is under the impression you have
3478+ no filesystems and no space(!).
3479+
3480+SOLUTION:
3481+ Run the perl script Tools/mkmnttab which will build an
3482+ /etc/mnttab from /etc/mtab.
3483diff -uNr --exclude-from=dontdiff linux-2.4.3/Documentation/abi/Local-X linux/Documentation/abi/Local-X
3484--- linux-2.4.3/Documentation/abi/Local-X Thu Jan 1 01:00:00 1970
3485+++ linux/Documentation/abi/Local-X Fri Mar 30 16:12:20 2001
3486@@ -0,0 +1,22 @@
3487+** Local X interface
3488+
3489+The local X interface is simplistic. It assumes only one local X server
3490+exists and assumes that the pathname of the Unix domain socket for
3491+local connections is always /tmp/.X11-unix/X0.
3492+
3493+ The SCO code opens both /dev/X0R and /dev/spx, writes a single byte
3494+to /dev/X0R, reads a message from /dev/X0R with getmsg then writes this
3495+message to /dev/spx with putmsg and closes /dev/X0R. This establishes
3496+the /dev/spx file descriptor as a connection to the X server listening
3497+on /dev/X0R.
3498+
3499+ We ignore all activity on the /dev/X0R device (hence it is a link to
3500+/dev/null), getmsg and putmsg are stubbed so don't do anything and opens
3501+on the /dev/spx simply replace the open inode with a socket connected
3502+to the X server's Unix domain socket.
3503+
3504+ At some point in the future we will implement a simple minded /dev/X*
3505+driver that returns some form of id via the getmsg which can then be
3506+passed to /dev/spx with putmsg and which will allow /dev/spx to connect
3507+to the relevant X server. This will only happen if someone actually
3508+*needs* multiple local X servers...
3509diff -uNr --exclude-from=dontdiff linux-2.4.3/Documentation/abi/Notes.Signal linux/Documentation/abi/Notes.Signal
3510--- linux-2.4.3/Documentation/abi/Notes.Signal Thu Jan 1 01:00:00 1970
3511+++ linux/Documentation/abi/Notes.Signal Fri Mar 30 16:12:20 2001
3512@@ -0,0 +1,42 @@
3513+Drew, Joe, and Brandon.
3514+
3515+This file contains my code for the signal functions. I realized that the
3516+existing signal functions will not suffice. This module should do the
3517+proper processing for iBCS signals.
3518+
3519+There are patches to the emulate module offered by Drew in his pl14n code
3520+release. The Makefile was changed to include the module.
3521+
3522+In addition, I have include a signal.doc file which contains the text from
3523+my UNIX S5 manual describing the functions used by iBCS. I based the
3524+emulator code on this document. Please look it over and see if I have
3525+messed up. I believe it to be correct. However, it never hurts to have
3526+someone check the work before we can trust it.
3527+
3528+It follows what I believe to be the proper calling sequence for signals. I
3529+sent a message to the IBSC2 group with the text from the McGraw Hill book
3530+concerning signals. If you would like a copy of the message, then let me
3531+know.
3532+
3533+Of couse, this could be totally wrong. That is the whole point about
3534+sending this out to a limited distribution.
3535+
3536+In addition to the processing for the various function requests, you may
3537+have noticed that the signal _numbers_ must be changed between the values
3538+used by iBCS and Linux.
3539+
3540+I have had to modify the emulate.c module to export an additional
3541+procedure (and for emulate.c to use the procedure itself.) In addition, I
3542+change the branch table to re-direct the signal processing to the signal.c
3543+module.
3544+
3545+I hope that this will help the project when it has been proven workable.
3546+Please let me know how this turns out -- one way or the other.
3547+
3548+If it does work, then I'll give the final code to Drew to merge into the
3549+master code. That is unless, Drew, you already have it. :-)
3550+
3551+Thanks much.
3552+
3553+--
3554+Al Longyear longyear@netcom.com longyear@sii.com
3555diff -uNr --exclude-from=dontdiff linux-2.4.3/Documentation/abi/Personality linux/Documentation/abi/Personality
3556--- linux-2.4.3/Documentation/abi/Personality Thu Jan 1 01:00:00 1970
3557+++ linux/Documentation/abi/Personality Fri Mar 30 16:12:20 2001
3558@@ -0,0 +1,88 @@
3559+*** Why are multiple personalities necessary?
3560+
3561+Personalities are used to provide the expected set of syscalls and error
3562+code mapping for non-Linux processes. In theory the set of syscalls and
3563+error codes should be standardised across all SYSV systems. In practice
3564+this is the case for SVR4, however SVR3 is a much older code base and
3565+many vendors have extended it leading to incompatibilities between the
3566+expected interfaces. Personalities allow us to vary the interface presented
3567+on a per-process basis thus allowing Linux to run binaries created for
3568+different vendor's extended SVR3s simultaneously.
3569+
3570+
3571+*** How are personalities implemented?
3572+
3573+The per-process task structure contains a field "personality". This defaults
3574+to 0 for Linux binaries, 1 (SVR4) for ELF binaries and 2 (SVR3) for COFF
3575+binaries. However when the COFF loader is called on to load a new binary
3576+it looks at the first 1k of data in each .comment section and compares
3577+the strings it finds with a built in table. If it finds a match it will
3578+set the personality appropriately.
3579+
3580+ When the application makes a system call the iBCS emulation layer uses
3581+the personality code in the per-process task structure to determine which
3582+system call mappings to use to locate the correct function.
3583+
3584+ If the function returns an (Linux) error code the iBCS emulation layer
3585+uses the personality code to determine which error code mappings to use
3586+to translate the error code in to a value the application will understand.
3587+
3588+
3589+*** What personalities are implemented?
3590+
3591+Currently the implemented personalities are SVR4, SVR3 (as a direct
3592+subset of SVR4), SCO 3.[24] and Wyse V/386 3.2.1. Of these the Wyse
3593+emulation is the most complete at this time. Rather than using the
3594+more common streams based TCP/IP stack on their SVR3, Wyse used a BSD
3595+implementation with a system call interface. Currently the Wyse emulation
3596+is the only one capable of running non-Linux TCP/IP binaries.
3597+
3598+
3599+*** When do I need to add a personality rather than use the default?
3600+
3601+When your applications start failing for inexplicable reasons! Seriously,
3602+if you have an SVR3 based Unix which does not currently have its own
3603+personality defined then you should check some things very carefully.
3604+
3605+ Firstly compare your system's /usr/include/sys/errno.h with the data
3606+in the Error.map file. If the values defined in your errno.h do not
3607+match those in the ABI column then you will need to create a new
3608+personality in order to map error codes to the correct values.
3609+
3610+ Next compare your system's /usr/include/sys.s with the data in the
3611+Syscall.map file. If there are system calls in your sys.s that don't
3612+do the same thing as those in the ABI column (other than ones that
3613+simply aren't implemented on your system) then you will need to create
3614+a new personality in order to mapp system calls to the correct functions.
3615+
3616+
3617+*** How do I add a new personality?
3618+
3619+The first step is to find a way for the COFF loader to recognise your
3620+binaries as being different. To do this you need to examine the comments
3621+embedded in a range of binaries, system executables, bought programs of
3622+various ages and locally compiled programs, using "mcs -p" to list the
3623+.comments sections. If you don't have "mcs" use "strings" and look for
3624+version or copyright messages. You are looking for one or more strings
3625+near the top which uniquely identify the system.
3626+
3627+ Once you have your identifying strings you must add a value for the
3628+new personality to linux/include/linux/personality.h (just use the
3629+next highest number) and add the strings to the table in the COFF loader
3630+linux/fs/binfmt_coff.c.
3631+
3632+ The next step is to modify the error map. Edit the file errmap.inc and
3633+look at the end of the file where there is an array of pointers to error
3634+maps call err_map. There is one entry for each personality. Add a new
3635+entry to the end for your personality. If your personality is compatible
3636+with an exising personality you can simply reuse the same error map (see
3637+the duplicate entries for the SVR4 map which is use for both SVR4 and
3638+SVR3 personalities), otherwise you must figure out how to create a new
3639+error mapping. One day it may be documented here :-).
3640+
3641+ Next you must modify the syscall mapping. Edit the file callmap.inc
3642+and look at the end of the file where there is an array containg one
3643+pointer for each personality. Add a new entry to the end. If your syscalls
3644+match one of the existing personalities you may reuse the existing map.
3645+Otherwise you have to build a new one. Again, one day it may be documented
3646+here...
3647diff -uNr --exclude-from=dontdiff linux-2.4.3/Documentation/abi/README.first linux/Documentation/abi/README.first
3648--- linux-2.4.3/Documentation/abi/README.first Thu Jan 1 01:00:00 1970
3649+++ linux/Documentation/abi/README.first Fri Mar 30 16:12:20 2001
3650@@ -0,0 +1,13 @@
3651+First notes on Linux-ABI documentation
3652+2001-March-30
3653+Christoph Hellwig, <hch@caldera.de>
3654+
3655+
3656+Please note that most files in this directory are leftovers from iBCS, which is
3657+dead since 1998. Do not expect this files to uptodate or complete.
3658+
3659+I will update the files and add new onces from time to time.
3660+
3661+ --hch
3662+
3663+$Id$
3664diff -uNr --exclude-from=dontdiff linux-2.4.3/Documentation/abi/Syscall.map linux/Documentation/abi/Syscall.map
3665--- linux-2.4.3/Documentation/abi/Syscall.map Thu Jan 1 01:00:00 1970
3666+++ linux/Documentation/abi/Syscall.map Fri Mar 30 16:12:20 2001
3667@@ -0,0 +1,185 @@
3668+Call ABI SCO 3.2 SCO 3.4 Wyse V/386 3.2.1 386bsd
3669+
3670+ 1 exit
3671+ 2 fork
3672+ 3 read
3673+ 4 write
3674+ 5 open
3675+ 6 close
3676+ 7 wait
3677+ 8 creat
3678+ 9 link
3679+ 10 unlink
3680+ 11 exec
3681+ 12 chdir
3682+ 13 time fchdir
3683+ 14 mknod
3684+ 15 chmod
3685+ 16 chown
3686+ 17 brk/break
3687+ 18 stat getfsstat
3688+ 19 seek/seek
3689+ 20 getpid
3690+ 21 mount
3691+ 22 umount
3692+ 23 setuid
3693+ 24 getuid
3694+ 25 stime geteuid
3695+ 26 ptrace
3696+ 27 alarm recvmsg
3697+ 28 fstat sendmsg
3698+ 29 pause recvfrom
3699+ 30 utime accept
3700+ 31 stty getpeername
3701+ 32 gtty getsockname
3702+ 33 access
3703+ 34 nice chflags
3704+ 35 statfs fchflags
3705+ 36 sync
3706+ 37 kill
3707+ 38 fstatfs stat
3708+ 39 setpgrp getppid
3709+ 40 cxenix lstat
3710+ 41 dup
3711+ 42 pipe
3712+ 43 times getegid
3713+ 44 prof
3714+ 45 lock/plock ktrace
3715+ 46 setgid sigaction
3716+ 47 getgid
3717+ 48 signal sigprocmask
3718+ 49 msgsys getlogin
3719+ 50 sysi86/sys3b setlogin
3720+ 51 sysacct/acct
3721+ 52 shmsys sigpending
3722+ 53 semsys sigaltstack
3723+ 54 ioctl
3724+ 55 uadmin reboot
3725+ 56 ??? revoke
3726+ 57 utssys symlink
3727+ 58 ??? readlink
3728+ 59 execv
3729+ 60 umask
3730+ 61 chroot
3731+ 62 fcntl fstat
3732+ 63 ulimit getkerninfo
3733+ 64 ??? getpagesize
3734+ 65 ??? msync
3735+ 66 ??? vfork
3736+ 67 ??? vread
3737+ 68 ??? vwrite
3738+ 69 ??? sbrk
3739+ 70 advfs sstk
3740+ 71 unadvfs mmap
3741+ 72 rmount vadvise
3742+ 73 rumount munmap
3743+ 74 rfstart mprotect
3744+ 75 ??? madvise
3745+ 76 rdebug vhangup
3746+ 77 rfstop vlimit
3747+ 78 rfsys mincore
3748+ 79 rmdir getgroups
3749+ 80 mkdir setgroups
3750+ 81 getdents getpgrp
3751+ 82 libattach setpgid
3752+ 83 libdetach setitimer
3753+ 84 sysfs wait
3754+ 85 getmsg swapon
3755+ 86 putmsg getitimer
3756+ 87 poll gethostname
3757+ 88 lstat --- --- --- sethostname
3758+ 89 symlink --- --- --- getdtablesize
3759+ 90 readlink --- symlink --- dup2
3760+ 91 setgroups --- lstat --- ---
3761+ 92 getgroups --- readlink --- fcntl
3762+ 93 fchmod --- --- --- select
3763+ 94 fchown --- --- --- ---
3764+ 95 sigprocmask --- --- --- fsync
3765+ 96 sigsuspend --- --- --- setpriority
3766+ 97 sigaltstack --- --- --- socket
3767+ 98 sigaction --- --- --- connect
3768+ 99 sigpending --- --- --- accept
3769+100 context --- --- --- getpriority
3770+101 evsys --- --- --- send
3771+102 evtrapret --- --- --- recv
3772+103 statvfs --- --- --- sigreturn
3773+104 fstatvfs --- --- --- bind
3774+105 ??? setsockopt
3775+106 nfssys --- --- --- listen
3776+107 waitsys --- --- --- vtimes
3777+108 sigsendsys --- --- --- sigvec
3778+109 hrtsys --- --- --- sigblock
3779+110 acancel --- --- --- sigsetmask
3780+111 async --- --- --- sigsuspend
3781+112 priocntlsys --- --- --- sigstack
3782+113 pathconf --- --- --- recvmsg
3783+114 mincore --- --- --- sendmsg
3784+115 mmap --- --- --- vtrace
3785+116 mprotect --- --- --- gettimeofday
3786+117 munmap --- --- --- getrusage
3787+118 fpathconf --- --- --- getsockopt
3788+119 vfork --- --- --- resuba
3789+120 fchdir --- --- --- readv
3790+121 readv --- --- --- writev
3791+122 writev --- --- --- settimeofday
3792+123 xstat --- --- --- fchown
3793+124 lxstat --- --- --- fchmod
3794+125 fxstat --- --- --- recvfrom
3795+126 xmknod --- --- --- setreuid
3796+127 clocal setregid
3797+128 setrlimit --- --- lstat rename
3798+129 getrlimit --- --- readlink truncate
3799+130 lchown --- --- symlink ftruncate
3800+131 memcntl --- --- --- flock
3801+132 getpmsg --- --- --- mkfifo
3802+133 putpmsg --- --- gethostname sendto
3803+134 rename --- --- sethostname shutdown
3804+135 uname --- --- getdomainname socketpair
3805+136 setegid --- --- setdomainname mkdir
3806+137 sysconfig --- --- --- rmdir
3807+138 adjtime --- --- setreuid utimes
3808+139 systeminfo --- --- setregid sigreturn
3809+140 ??? adjtime
3810+141 seteuid --- --- --- getpeername
3811+142 --- --- --- --- gethostid
3812+143 --- --- --- --- sethostid
3813+144 --- --- --- --- getrlimit
3814+145 --- --- --- --- setrlimit
3815+146 --- --- --- --- killpg
3816+147 --- --- --- --- setsid
3817+148 --- --- --- --- quotactl
3818+149 --- --- --- --- quota
3819+150 --- --- --- --- getsockname
3820+151 --- --- --- ---
3821+152 --- --- --- ---
3822+153 --- --- --- ---
3823+154 --- --- --- ---
3824+155 --- --- --- --- nfssvc
3825+156 --- --- --- --- getdirentries
3826+157 --- --- --- --- statfs
3827+158 --- --- --- --- fstatfs
3828+159 --- --- --- ---
3829+160 --- --- --- --- async_daemon
3830+161 --- --- --- --- getfh
3831+162 --- --- --- --- getdomainname
3832+163 --- --- --- --- setdomainname
3833+164 --- --- --- --- uname
3834+165 --- --- --- --- sysarch
3835+166 --- --- --- ---
3836+167 --- --- --- ---
3837+168 --- --- --- ---
3838+169 --- --- --- --- semsys
3839+170 --- --- --- --- msgsys
3840+171 --- --- --- --- shmsys
3841+172 --- --- --- ---
3842+173 --- --- --- ---
3843+174 --- --- --- ---
3844+175 --- --- --- --- ntp_gettime
3845+176 --- --- --- --- ntp_adjtime
3846+177 --- --- --- --- vm_allocate
3847+178 --- --- --- --- vm_deallocate
3848+179 --- --- --- --- vm_inherit
3849+180 --- --- --- --- vm_protect
3850+181 --- --- --- --- setgid
3851+182 --- --- --- --- setegid
3852+183 --- --- --- --- seteuid
3853diff -uNr --exclude-from=dontdiff linux-2.4.3/Documentation/abi/TODO.ibcs linux/Documentation/abi/TODO.ibcs
3854--- linux-2.4.3/Documentation/abi/TODO.ibcs Thu Jan 1 01:00:00 1970
3855+++ linux/Documentation/abi/TODO.ibcs Fri Mar 30 16:12:20 2001
3856@@ -0,0 +1,61 @@
3857+
3858+ These are leftovers from iBCS, I just removed what is already
3859+ done in linux-abi or isn't relevant for us. --hch
3860+
3861+
3862+^Z disconnects but the next read seems to return an error instead
3863+of blocking? (Fixed?)
3864+
3865+SIOGIFFLAGS seems to get passed an empty string as the interface name
3866+(ISC ping). What is supposed to be happening?
3867+
3868+If a timod putmsg fails we should set an error status on the socket and
3869+return it on future calls for strict compatibility. Currently we recover
3870+from things such as protocol errors rather more than we should.
3871+
3872+Getmsg() - when select returns we may not be the first process to wake
3873+up and handle the event. So the recvfrom ought to be non-blocking (not
3874+possible?). If it would block we should go back to the select (unless
3875+the descriptor is in non-blocking mode). (DONE?)
3876+
3877+How should we go about returning TLOOK? Currently we are only working
3878+synchronously so it isn't essential yet. It looks like it's all handled
3879+in libnsl_s.
3880+
3881+The T_MORE flag on t_snd() and t_rcv() marks message boundaries. Strictly
3882+these should be preserved end-to-end. Possible across sockets?
3883+(X/Open specify that message boundaries shouldn't be relied on with TCP)
3884+
3885+Need I_SETSIG ioctl to enable SIGPOLL on available input etc. Note that
3886+a control message counts as input. This should interface with poll() too.
3887+
3888+getmsg() returns EINTR if a signal interrupts it but the t_*() functions
3889+don't seem to propogate this back to the application. Presumably they
3890+loop round?
3891+
3892+The SCO timod doesn't seem to pay much attention to the TI_* command
3893+in an ioctl but uses the T_* primitive in the message block. i.e. if
3894+you have T_BIND_REQ in the message but TI_GETINFO as the ioctl command
3895+timod will do a bind. Currently we use the TI_* by preference. This
3896+needs to change to avoid breaking programs that worked on SCO even
3897+though broken. It shouldn't be _essential_ though as all this is
3898+normally hidden in libnsl_s so should be consistent.
3899+
3900+Connects are currently forced synchronous. It wouldn't be too much
3901+to allow them to happen asynchronously but the async confirmation
3902+is supposed to contain the address we connected to and that is only
3903+available from the connection request message. Unless we save it
3904+somewhere or look it up from the socket. Hang on, we have getpeername()
3905+capabilities...
3906+
3907+There are slight semantic differences between O_NDELAY and O_NONBLOCK
3908+which cause different behaviour on SCO at least. For instance O_NDELAY
3909+does cause t_connect to work asynchronously but O_NONBLOCK doesn't.
3910+Under Linux O_NDELAY and O_NONBLOCK are the same. This could cause
3911+problems at some point I guess...
3912+
3913+Under SCO at least poll and select are different. Poll works on things
3914+that select can be used on but select cannot necessarily work on things
3915+that can be polled. Specifically you can poll a transport end point
3916+but not select on it. Badly written programs could block when they
3917+wouldn't normally.
3918diff -uNr --exclude-from=dontdiff linux-2.4.3/Makefile linux/Makefile
3919--- linux-2.4.3/Makefile Fri Mar 30 14:48:20 2001
3920+++ linux/Makefile Fri Mar 30 17:25:23 2001
3921@@ -118,10 +118,11 @@
3922
3923 CORE_FILES =kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o
3924 NETWORKS =net/network.o
3925+ABI =abi/abi.o
3926 CRYPTO =crypto/crypto.o
3927
3928 LIBS =$(TOPDIR)/lib/lib.a
3929-SUBDIRS =kernel drivers mm fs net ipc lib crypto
3930+SUBDIRS =kernel drivers mm fs net ipc lib crypto abi
3931
3932 DRIVERS-n :=
3933 DRIVERS-y :=
3934@@ -265,6 +265,7 @@
ff7ec961
JR
3935 --start-group \
3936 $(CORE_FILES) \
3937 $(DRIVERS) \
3938+ $(ABI) \
3939 $(NETWORKS) \
3940 $(CRYPTO) \
3941 $(LIBS) \
483622cb 3942diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/Config.in linux/abi/Config.in
3943--- linux-2.4.3/abi/Config.in Thu Jan 1 01:00:00 1970
3944+++ linux/abi/Config.in Fri Mar 30 16:13:20 2001
3945@@ -0,0 +1,37 @@
3946+
3947+mainmenu_option next_comment
3948+comment 'Binary emulation of other systems'
3949+
3950+tristate 'Support for binary emulation of other systems' CONFIG_ABI
3951+
3952+# BSD is completly out of date ...
3953+#dep_tristate ' BSD binary emulation support' CONFIG_ABI_BSD $CONFIG_ABI $CONFIG_ABI
3954+dep_tristate ' SVR3/SVR4 (and derivates) binary emulation support' CONFIG_ABI_SVR4 $CONFIG_ABI
3955+if [ "$CONFIG_ABI_SVR4" = "y" -o "$CONFIG_ABI_SVR4" = "m" ]; then
3956+ dep_mbool ' Include SCO OpenServer specifics' CONFIG_ABI_IBCS_SCO $CONFIG_ABI_SVR4
3957+ dep_mbool ' Include ISC specifics' CONFIG_ABI_IBCS_ISC $CONFIG_ABI_SVR4
3958+ dep_mbool ' Include Wyse V/386 specifics' CONFIG_ABI_IBCS_WYSE $CONFIG_ABI_SVR4
3959+ dep_mbool ' Include Xenix specifics' CONFIG_ABI_XENIX $CONFIG_ABI_SVR4
3960+
3961+ dep_tristate ' UnixWare 7.x binary emulation support' CONFIG_ABI_UW7 $CONFIG_ABI_SVR4
3962+ dep_tristate ' Solaris 2.x binary emulation support' CONFIG_ABI_SOLARIS $CONFIG_ABI_SVR4
3963+fi
3964+
3965+comment 'Support for foreign binary formats'
3966+# coff is used by SVR3, x.out by Xenix, both are SVR4-subsets
3967+dep_tristate ' Kernel support for x.out binaries' CONFIG_BINFMT_XOUT $CONFIG_ABI_SVR4
3968+dep_tristate ' Kernel support for COFF binaries' CONFIG_BINFMT_COFF $CONFIG_ABI_SVR4
3969+
3970+comment 'Linux-ABI debugging settings'
3971+dep_mbool ' Enable verbose errors' CONFIG_ABI_VERBOSE_ERRORS $CONFIG_ABI
3972+
3973+
3974+if [ "$CONFIG_ABI" != "n" ]; then
3975+ define_bool CONFIG_ABI_SPX y
3976+ define_bool CONFIG_ABI_XTI y
3977+
3978+ define_bool CONFIG_ABI_TLI_OPTMGMT y
3979+ define_bool CONFIG_ABI_XTI_OPTMGMT n
3980+fi
3981+
3982+endmenu
3983diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/Makefile linux/abi/Makefile
3984--- linux-2.4.3/abi/Makefile Thu Jan 1 01:00:00 1970
3985+++ linux/abi/Makefile Tue Mar 13 18:49:41 2001
3986@@ -0,0 +1,21 @@
3987+# $Id$
3988+#
3989+# Makefile for the kernel ABI code
3990+#
3991+
3992+O_TARGET := abi.o
3993+
3994+
3995+res-$(CONFIG_ABI) += common/abi-common.o
3996+res-$(CONFIG_ABI_SVR4) += svr4/abi-svr4.o
3997+res-$(CONFIG_ABI_UW7) += uw7/abi-uw7.o
3998+res-$(CONFIG_ABI_SOLARIS) += solaris/abi-solaris.o
3999+
4000+subdir-$(CONFIG_ABI) += common
4001+subdir-$(CONFIG_ABI_SVR4) += svr4
4002+subdir-$(CONFIG_ABI_UW7) += uw7
4003+subdir-$(CONFIG_ABI_SOLARIS) += solaris
4004+
4005+obj-y += $(res-y)
4006+
4007+include $(TOPDIR)/Rules.make
4008diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/common/Makefile linux/abi/common/Makefile
4009--- linux-2.4.3/abi/common/Makefile Thu Jan 1 01:00:00 1970
4010+++ linux/abi/common/Makefile Mon Mar 12 16:34:48 2001
4011@@ -0,0 +1,19 @@
4012+#
4013+# Makefile for the kernel ABI code shared by different emulations
4014+#
4015+
4016+O_TARGET := dummy.o
4017+
4018+list-multi := abi-common.o
4019+abi-common-objs := core.o ioctl.o map.o signal.o socket.o socksys.o stat.o \
4020+ wysev386.o $(ARCH)_dispatch.o $(ARCH)_maps.o
4021+
4022+export-objs := $(abi-common-objs)
4023+
4024+obj-$(CONFIG_ABI) += abi-common.o
4025+
4026+
4027+include $(TOPDIR)/Rules.make
4028+
4029+abi-common.o: $(abi-common-objs)
4030+ $(LD) -r -o $@ $(abi-common-objs)
4031diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/common/core.c linux/abi/common/core.c
4032--- linux-2.4.3/abi/common/core.c Thu Jan 1 01:00:00 1970
4033+++ linux/abi/common/core.c Fri Mar 30 15:23:38 2001
4034@@ -0,0 +1,618 @@
4035+/* $Id$
4036+ * core.c - generic emulation syscalls
4037+ *
4038+ * Copyright (C) 1993 Linus Torvalds
4039+ *
4040+ * Modified by Eric Youngdale to include all ibcs syscalls.
4041+ * Re-written by Drew Sullivan to handle lots more of the syscalls correctly.
4042+ */
4043+
4044+#include <linux/config.h>
4045+#include <linux/module.h>
4046+
4047+#include <linux/types.h>
4048+#include <linux/errno.h>
4049+#include <linux/sched.h>
4050+#include <linux/kernel.h>
4051+#include <linux/mm.h>
4052+#include <linux/stat.h>
4053+#include <linux/stddef.h>
4054+#include <linux/unistd.h>
4055+#include <linux/ptrace.h>
4056+#include <linux/fcntl.h>
4057+#include <linux/time.h>
4058+
4059+#include <linux/fs.h>
4060+#include <linux/sys.h>
4061+#include <linux/slab.h>
4062+#include <linux/file.h>
4063+#include <linux/dirent.h>
4064+
4065+#include <asm/uaccess.h>
4066+#include <asm/system.h>
4067+
4068+#include <abi/abi.h>
4069+#include <abi/signal.h>
4070+#include <abi/trace.h>
4071+
4072+int abi_brk(unsigned long newbrk)
4073+{
4074+ if (!newbrk)
4075+ return current->mm->brk;
4076+ if (newbrk != current->mm->brk && (unsigned long)SYS(brk)(newbrk) != newbrk)
4077+ return -ENOMEM;
4078+ return 0;
4079+}
4080+
4081+EXPORT_SYMBOL(abi_brk);
4082+
4083+#ifdef __sparc__
4084+int abi_fork(struct pt_regs * regs) {
4085+ /* No fork yet */
4086+ printk ("ibcs2/sparc: No fork yet\n");
4087+ send_sig(SIGSEGV, current, 1);
4088+ return -1;
4089+}
4090+
4091+EXPORT_SYMBOL(abi_fork);
4092+
4093+int abi_wait(struct pt_regs * regs) {
4094+ /* No fork yet */
4095+ printk ("ibcs2/sparc: No wait yet\n");
4096+ send_sig(SIGSEGV, current, 1);
4097+ return -1;
4098+}
4099+
4100+EXPORT_SYMBOL(abi_wait);
4101+
4102+int abi_exec(struct pt_regs * regs)
4103+{
4104+
4105+ /* No exec yet */
4106+ printk ("ibcs2/sparc: No fork yet\n");
4107+ send_sig(SIGSEGV, current, 1);
4108+ return -1;
4109+}
4110+
4111+EXPORT_SYMBOL(abi_exec);
4112+
4113+int abi_pipe(struct pt_regs * regs)
4114+{
4115+ long filedes[2];
4116+ mm_segment_t old_fs = get_fs();
4117+ int rvalue;
4118+
4119+ set_fs(get_ds());
4120+ rvalue = SYS(pipe)(&filedes);
4121+ set_fs(old_fs);
4122+ if (rvalue == 0) {
4123+ rvalue = filedes[0];
4124+ regs->u_regs [UREG_I0] = filedes[1];
4125+ }
4126+ return rvalue;
4127+}
4128+
4129+EXPORT_SYMBOL(abi_pipe);
4130+
4131+int abi_getpid(struct pt_regs * regs)
4132+{
4133+ return current->pid;
4134+}
4135+
4136+EXPORT_SYMBOL(abi_getpid);
4137+
4138+int abi_getuid(struct pt_regs * regs)
4139+{
4140+ return current->uid;
4141+}
4142+
4143+EXPORT_SYMBOL(abi_getuid);
4144+
4145+int abi_getgid(struct pt_regs * regs)
4146+{
4147+ return current->gid;
4148+}
4149+
4150+EXPORT_SYMBOL(abi_getgid);
4151+
4152+#else /* __sparc__ */
4153+
4154+int abi_lseek(int fd, unsigned long offset, int whence)
4155+{
4156+ int error;
4157+ struct file *file;
4158+ struct inode *inode;
4159+
4160+ error = SYS(lseek)(fd, offset, whence);
4161+ if (error != -ESPIPE || !personality(PER_SCOSVR3))
4162+ return error;
4163+
4164+ file = fget(fd);
4165+ if (!file)
4166+ goto out;
4167+ inode = file->f_dentry->d_inode;
4168+ if (inode && (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)))
4169+ error = 0;
4170+ fput(file);
4171+out:
4172+ return error;
4173+}
4174+
4175+EXPORT_SYMBOL(abi_lseek);
4176+
4177+int abi_fork(struct pt_regs * regs)
4178+{
4179+ int rvalue;
4180+
4181+ regs->eflags &= ~1; /* Clear carry flag */
4182+ rvalue = SYS(fork)(regs->ebx, regs->ecx, 1,
4183+ regs->esi, regs->edi, regs->ebp, regs->eax, regs->xds,
4184+ regs->xes, regs->orig_eax,
4185+ regs->eip, regs->xcs, regs->eflags, regs->esp, regs->xss);
4186+ regs->edx = 0;
4187+ return rvalue;
4188+}
4189+
4190+EXPORT_SYMBOL(abi_fork);
4191+
4192+int abi_pipe(struct pt_regs * regs)
4193+{
4194+ long filedes[2];
4195+ mm_segment_t old_fs = get_fs();
4196+ int rvalue;
4197+
4198+ set_fs(get_ds());
4199+ rvalue = SYS(pipe)(&filedes);
4200+ set_fs(old_fs);
4201+ if (rvalue == 0) {
4202+ rvalue = filedes[0];
4203+ regs->edx = filedes[1];
4204+ }
4205+ return rvalue;
4206+}
4207+
4208+EXPORT_SYMBOL(abi_pipe);
4209+
4210+/* note the double value return in eax and edx */
4211+int abi_getpid(struct pt_regs * regs)
4212+{
4213+ regs->edx = current->p_pptr->pid;
4214+
4215+ return current->pid;
4216+}
4217+
4218+EXPORT_SYMBOL(abi_getpid);
4219+
4220+/* note the double value return in eax and edx */
4221+int abi_getuid(struct pt_regs * regs)
4222+{
4223+ regs->edx = current->euid;
4224+
4225+ return current->uid;
4226+}
4227+
4228+EXPORT_SYMBOL(abi_getuid);
4229+
4230+/* note the double value return in eax and edx */
4231+int abi_getgid(struct pt_regs * regs)
4232+{
4233+ regs->edx = current->egid;
4234+
4235+ return current->gid;
4236+}
4237+
4238+EXPORT_SYMBOL(abi_getgid);
4239+
4240+#define FLAG_ZF 0x0040
4241+#define FLAG_PF 0x0004
4242+#define FLAG_SF 0x0080
4243+#define FLAG_OF 0x0800
4244+
4245+#define MAGIC_WAITPID_FLAG (FLAG_ZF | FLAG_PF | FLAG_SF | FLAG_OF)
4246+
4247+int abi_wait(struct pt_regs * regs)
4248+{
4249+ long result, kopt;
4250+ int pid, loc, opt;
4251+ mm_segment_t old_fs;
4252+
4253+ /* xenix wait() puts status to edx and returns pid */
4254+ if (personality(PER_XENIX)) {
4255+ old_fs = get_fs();
4256+ set_fs (get_ds());
4257+ result = SYS(wait4)(-1, &loc, 0, NULL);
4258+ set_fs(old_fs);
4259+
4260+ regs->edx = loc;
4261+ return result;
4262+ }
4263+ /* if ZF,PF,SF,and OF are set then it is waitpid */
4264+ if ((regs->eflags & MAGIC_WAITPID_FLAG) == MAGIC_WAITPID_FLAG) {
4265+ get_user(pid, ((unsigned long *) regs->esp) + 1);
4266+ get_user(loc, ((unsigned long *) regs->esp) + 2);
4267+ get_user(opt, ((unsigned long *) regs->esp) + 3);
4268+
4269+ /* Now translate the options from the SVr4 numbers */
4270+ kopt = 0;
4271+ if (opt & 0100) kopt |= WNOHANG;
4272+ if (opt & 4) kopt |= WUNTRACED;
4273+
4274+ result = SYS(wait4)(pid, loc, kopt, NULL);
4275+ } else {
4276+ get_user(loc, ((unsigned long *) regs->esp) + 1);
4277+ result = SYS(wait4)(-1, loc, WUNTRACED, NULL);
4278+ }
4279+ if (result >= 0 && loc) {
4280+ get_user(regs->edx, (unsigned long *) loc);
4281+ if ((regs->edx & 0xff) == 0x7f) {
4282+ int sig = (regs->edx >> 8) & 0xff;
4283+ if (sig < NSIGNALS)
4284+ sig = current->exec_domain->signal_map[sig];
4285+ regs->edx = (regs->edx & (~0xff00)) | (sig << 8);
4286+ put_user(regs->edx, (unsigned long *)loc);
4287+ } else if (regs->edx && regs->edx == (regs->edx & 0xff)) {
4288+ if ((regs->edx & 0x7f) < NSIGNALS)
4289+ regs->edx = current->exec_domain->signal_map[regs->edx & 0x7f];
4290+ put_user(regs->edx, (unsigned long *)loc);
4291+ }
4292+ }
4293+ return result;
4294+}
4295+
4296+EXPORT_SYMBOL(abi_wait);
4297+
4298+/*
4299+ * abi_exec() executes a new program.
4300+ */
4301+int abi_exec(struct pt_regs *regs)
4302+{
4303+ int error;
4304+ char *pgm, **argv, **envp;
4305+ char *filename;
4306+
4307+ get_user((unsigned long) pgm, ((unsigned long *) regs->esp) + 1);
4308+ get_user((unsigned long) argv, ((unsigned long *) regs->esp) + 2);
4309+ get_user((unsigned long) envp, ((unsigned long *) regs->esp) + 3);
4310+
4311+ if (abi_traced(ABI_TRACE_API)) {
4312+ int i;
4313+ char **v, *p, *q;
4314+
4315+ q = getname(pgm);
4316+ if (IS_ERR(q)) {
4317+ __abi_trace(" pgm: 0x%lx pointer error %ld\n",
4318+ (unsigned long)pgm, PTR_ERR(q));
4319+ } else {
4320+ __abi_trace(" pgm: 0x%lx \"%s\"\n",
4321+ (unsigned long)pgm, q);
4322+ putname(q);
4323+ }
4324+
4325+ for (i = 0, v = argv; v && i < 20; v++,i++) {
4326+ if (get_user(p, v) || !p)
4327+ break;
4328+ q = getname(p);
4329+ if (IS_ERR(q)) {
4330+ __abi_trace(" arg: 0x%lx pointer error %ld\n",
4331+ (unsigned long)p, PTR_ERR(q));
4332+ } else {
4333+ __abi_trace(" arg: 0x%lx \"%s\"\n",
4334+ (unsigned long)p, q);
4335+ putname(q);
4336+ }
4337+ }
4338+ if (v && p)
4339+ __abi_trace(" arg: ...\n");
4340+
4341+ for (i=0,v=envp; v && i < 20; v++,i++) {
4342+ if (get_user(p, v) || !p)
4343+ break;
4344+ q = getname(p);
4345+ if (IS_ERR(q)) {
4346+ __abi_trace(" env: 0x%lx pointer error %ld\n",
4347+ (unsigned long)p, PTR_ERR(q));
4348+ } else {
4349+ __abi_trace(" env: 0x%lx \"%s\"\n",
4350+ (unsigned long)p, q);
4351+ putname(q);
4352+ }
4353+ }
4354+ if (v && p)
4355+ __abi_trace(" env: ...\n");
4356+ }
4357+
4358+ filename = getname(pgm);
4359+ error = PTR_ERR(filename);
4360+ if (!IS_ERR(filename)) {
4361+ /* if you get an error on this undefined, then remove the */
4362+ /* 'static' declaration in /linux/fs/exec.c */
4363+ error = do_execve(filename, argv, envp, regs);
4364+ putname (filename);
4365+ }
4366+ return error;
4367+}
4368+
4369+EXPORT_SYMBOL(abi_exec);
4370+
4371+int abi_procids(struct pt_regs * regs)
4372+{
4373+ int op, arg_offset;
4374+
4375+ get_user(op, ((unsigned long *)regs->esp)+1);
4376+
4377+ /* Remap op codes for current personality if necessary. */
4378+ switch (current->personality & PER_MASK) {
4379+ case (PER_SVR3 & PER_MASK):
4380+ case (PER_SCOSVR3 & PER_MASK):
4381+ case (PER_WYSEV386 & PER_MASK):
4382+ case (PER_XENIX & PER_MASK): {
4383+ if (op < 0 || op > 5)
4384+ return -EINVAL;
4385+ op = "\000\001\005\003\377\377"[op];
4386+
4387+ /* SCO at least uses an interesting library to
4388+ * syscall mapping that leaves an extra return
4389+ * address between the op code and the arguments.
4390+ */
4391+ arg_offset = 1;
4392+ break;
4393+ }
4394+
4395+ default:
4396+ arg_offset = 0;
4397+ }
4398+
4399+ switch (op) {
4400+ case 0: /* getpgrp */
4401+ return current->pgrp;
4402+
4403+ case 1: /* setpgrp */
4404+ SYS(setpgid)(0, 0);
4405+ current->tty=NULL;
4406+ return current->pgrp;
4407+
4408+ case 2: { /* getsid */
4409+ unsigned long pid;
4410+ get_user(pid, ((unsigned long *)regs->esp)
4411+ + 2 + arg_offset);
4412+ return SYS(getsid)(pid);
4413+ }
4414+
4415+ case 3: /* setsid */
4416+ return SYS(setsid)();
4417+
4418+ case 4: { /* getpgid */
4419+ unsigned long pid;
4420+ get_user(pid, ((unsigned long *)regs->esp)
4421+ + 2 + arg_offset);
4422+ return SYS(getpgid)(pid);
4423+ }
4424+
4425+ case 5: { /* setpgid */
4426+ int pid, pgid;
4427+
4428+ get_user(pid, ((unsigned long *)regs->esp)
4429+ + 2 + arg_offset);
4430+ get_user(pgid, ((unsigned long *)regs->esp)
4431+ + 3 + arg_offset);
4432+ return SYS(setpgid)(pid, pgid);
4433+ }
4434+ }
4435+
4436+ return -EINVAL;
4437+}
4438+EXPORT_SYMBOL(abi_procids);
4439+
4440+#endif /* __sparc__ */
4441+
4442+int abi_read(int fd, char *buf, int nbytes)
4443+{
4444+ int error, here, posn, reclen;
4445+ struct file *file;
4446+ struct dirent *d;
4447+ mm_segment_t old_fs;
4448+
4449+ error = SYS(read)(fd, buf, nbytes);
4450+ if (error != -EISDIR)
4451+ return error;
4452+
4453+ /*
4454+ * Stupid bloody thing is trying to read a directory. Some old
4455+ * programs expect this to work. It works on SCO. To emulate it
4456+ * we have to map a dirent to a direct. This involves shrinking
4457+ * a long inode to a short. Fortunately nothing this archaic is
4458+ * likely to care about anything but the filenames of entries
4459+ * with non-zero inodes.
4460+ */
4461+
4462+ file = fget(fd);
4463+ if (!file)
4464+ return -EBADF;
4465+
4466+ d = (struct dirent *)get_free_page(GFP_KERNEL);
4467+ if (!d) {
4468+ fput(file);
4469+ return -ENOMEM;
4470+ }
4471+
4472+ error = posn = reclen = 0;
4473+
4474+ while (posn + reclen < nbytes) {
4475+ /* Save the current position and get another dirent */
4476+ here = file->f_pos;
4477+ old_fs = get_fs();
4478+ set_fs (get_ds());
4479+ error = SYS(readdir)(fd, d, 1);
4480+ set_fs(old_fs);
4481+ if (error <= 0)
4482+ break;
4483+
4484+ /* If it'll fit in the buffer save it otherwise back up
4485+ * so it is read next time around.
4486+ * Oh, if we're at the beginning of the buffer there's
4487+ * no chance that this entry will ever fit so don't
4488+ * copy it and don't back off - we'll just pretend it
4489+ * isn't here...
4490+ */
4491+ reclen = 16 * ((d->d_reclen + 13) / 14);
4492+ if (posn + reclen <= nbytes) {
4493+ /* SCO (at least) handles long filenames by breaking
4494+ * them up in to 14 character chunks of which all
4495+ * but the last have the inode set to 0xffff.
4496+ */
4497+ char *p = d->d_name;
4498+
4499+ /* Put all but the last chunk. */
4500+ while (d->d_reclen > 14) {
4501+ put_user(0xffff, (unsigned short *)(buf+posn));
4502+ posn += 2;
4503+ copy_to_user(buf+posn, p, 14);
4504+ posn += 14;
4505+ p += 14;
4506+ d->d_reclen -= 14;
4507+ }
4508+ /* Put the last chunk. Note the we have to fold a
4509+ * long inode number down to a short avoiding
4510+ * giving a zero inode number since that indicates
4511+ * an unused directory slot. Note also that the
4512+ * folding used here must match that used in stat()
4513+ * or path finding programs that do read() on
4514+ * directories will fail.
4515+ */
4516+#if 0
4517+ /* This appears to match what SCO does for
4518+ * reads on a directory with long inodes.
4519+ */
4520+ if ((unsigned long)d->d_ino > 0xfffe)
4521+ put_user(0xfffe, (unsigned short *)(buf+posn));
4522+ else
4523+ put_user((short)d->d_ino, (unsigned short *)(buf+posn));
4524+#else
4525+ /* This attempts to match the way stat and
4526+ * getdents fold long inodes to shorts.
4527+ */
4528+ if ((unsigned long)d->d_ino & 0xffff)
4529+ put_user((unsigned long)d->d_ino & 0xffff,
4530+ (unsigned short *)(buf+posn));
4531+ else
4532+ put_user(0xfffe, (unsigned short *)(buf+posn));
4533+#endif
4534+ posn += 2;
4535+ copy_to_user(buf+posn, p, d->d_reclen);
4536+
4537+ /* Ensure that filenames that don't fill the array
4538+ * completely are null filled.
4539+ */
4540+ for (; d->d_reclen < 14; d->d_reclen++)
4541+ put_user('\0', buf+posn+d->d_reclen);
4542+
4543+ posn += 14;
4544+ } else if (posn) {
4545+ SYS(lseek)(fd, here, 0);
4546+ } /* else posn == 0 */
4547+ }
4548+
4549+ free_page((unsigned long)d);
4550+ fput(file);
4551+
4552+ /* If we've put something in the buffer return the byte count
4553+ * otherwise return the error status.
4554+ */
4555+ return (posn ? posn : error);
4556+}
4557+
4558+EXPORT_SYMBOL(abi_read);
4559+
4560+#ifdef __TRACE_SELECT__
4561+int abi_select(int n, void *rfds, void *wfds, void *efds, struct timeval *t)
4562+{
4563+ struct timeval tv;
4564+ int error;
4565+
4566+ if (!abi_traced(ABI_TRACE_API) || !t)
4567+ goto doit;
4568+
4569+ error = get_user(tv.tv_sec, &(t->tv_sec));
4570+ if (!error)
4571+ error = get_user(tv.tv_usec, &(t->tv_usec));
4572+ if (error)
4573+ return (error);
4574+
4575+ __abi_trace("select timeout in %lus, %luus", tv.tv_sec, tv.tv_usec);
4576+
4577+doit:
4578+ return SYS(_newselect)(n, rfds, wfds, efds, t);
4579+}
4580+EXPORT_SYMBOL(abi_select);
4581+#endif
4582+
4583+
4584+int
4585+abi_time(void)
4586+{
4587+ return SYS(time)(0);
4588+}
4589+
4590+EXPORT_SYMBOL(abi_time);
4591+
4592+
4593+int abi_mknod(const char *fname, int mode, int dev)
4594+{
4595+ /* Linux doesn't allow us to create a directory with mknod(). */
4596+ if ((mode & 0017000) == 0040000)
4597+ return abi_mkdir(fname, mode);
4598+ return SYS(mknod)(fname, mode, dev);
4599+}
4600+
4601+EXPORT_SYMBOL(abi_mknod);
4602+
4603+int abi_mkdir(const char *fname, int mode)
4604+{
4605+ int error;
4606+ mm_segment_t old_fs;
4607+ char *tmp, *p;
4608+
4609+ tmp = getname(fname);
4610+ if (IS_ERR(tmp))
4611+ return PTR_ERR(tmp);
4612+
4613+ /* Drop any trailing slash */
4614+ for (p=tmp; *p; p++);
4615+ p--;
4616+ if (*p == '/')
4617+ *p = '\0';
4618+
4619+ old_fs = get_fs();
4620+ set_fs(get_ds());
4621+ error = SYS(mkdir)(tmp, mode);
4622+ set_fs(old_fs);
4623+
4624+ putname(tmp);
4625+ return error;
4626+}
4627+
4628+EXPORT_SYMBOL(abi_mkdir);
4629+
4630+/*
4631+ * Translate the signal number to the corresponding item for Linux.
4632+ */
4633+static inline int abi_mapsig(int sig)
4634+{
4635+ if ((unsigned int) sig >= NSIGNALS)
4636+ return -1;
4637+ return current->exec_domain->signal_map[sig];
4638+}
4639+
4640+int abi_kill(int pid, int sig)
4641+{
4642+ int outsig = abi_mapsig(sig & 0xFF);
4643+
4644+ abi_trace(ABI_TRACE_SIGNAL, "kill: insig (%d) outsig(%d)",
4645+ sig & 0xFF, outsig);
4646+
4647+ if (outsig < 0)
4648+ return -EINVAL;
4649+ return SYS(kill)(pid, outsig);
4650+}
4651+
4652+EXPORT_SYMBOL(abi_kill);
4653diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/common/i386_dispatch.c linux/abi/common/i386_dispatch.c
4654--- linux-2.4.3/abi/common/i386_dispatch.c Thu Jan 1 01:00:00 1970
4655+++ linux/abi/common/i386_dispatch.c Fri Mar 30 15:23:38 2001
4656@@ -0,0 +1,304 @@
4657+/*
4658+ * arch/i386/abi/dispatch_i386.c
4659+ *
4660+ * Copyright (C) 1993 Linus Torvalds
4661+ * Modified by Eric Youngdale to include all ibcs syscalls.
4662+ * Re-written by Drew Sullivan to handle lots more of the syscalls correctly.
4663+ *
4664+ * Jan 30 1994, Merged Joe Portman's code -- Drew
4665+ * Jan 31 1994, Merged Eric Yongdale's code for elf support -- Drew
4666+ *
4667+ * Feb 4 1994
4668+ * Rebuilt with handling for multiple binary personalities
4669+ * -- Mike Jagdis (jaggy@purplet.demon.co.uk)
4670+ *
4671+ * Feb 14 1994
4672+ * Dual mode. Compiled in if you say yes to the configure iBCS
4673+ * question during 'make config'. Loadable module with kernel
4674+ * hooks otherwise.
4675+ * -- Mike Jagdis (jaggy@purplet.demon.co.uk)
4676+ *
4677+ * Feb 18 1994
4678+ * Added the /dev/socksys emulator. This allows applications which
4679+ * use the socket interface to Lachman streams based TCP/IP to use
4680+ * the Linux TCP/IP stack.
4681+ * -- Mike Jagdis (jaggy@purplet.demon.co.uk)
4682+ *
4683+ * $Id$
4684+ * $Source$
4685+ */
4686+
4687+#include <linux/module.h>
4688+#include <linux/errno.h>
4689+#include <linux/sched.h>
4690+#include <linux/kernel.h>
4691+#include <linux/mm.h>
4692+#include <linux/stddef.h>
4693+#include <linux/unistd.h>
4694+#include <linux/ptrace.h>
4695+#include <linux/fcntl.h>
4696+#include <linux/init.h>
4697+#include <linux/slab.h>
4698+#include <linux/fs.h>
4699+#include <linux/sys.h>
4700+#include <linux/personality.h>
4701+#include <asm/uaccess.h>
4702+
4703+#include <abi/abi.h>
4704+#include <abi/trace.h>
4705+
4706+
4707+#include "verb_errmap.inc"
4708+
4709+#define last(x) ((sizeof(x)/sizeof(*x))-1)
4710+
4711+
4712+MODULE_AUTHOR("Mike Jagdis <jaggy@purplet.demon.co.uk>");
4713+MODULE_DESCRIPTION("Support for non-Linux programs");
4714+
4715+
4716+u_int abi_traceflg = 0xffffffff;
4717+
4718+MODULE_PARM(abi_traceflg, "i");
4719+MODULE_PARM_DESC(abi_traceflg, "iBCS debug trace");
4720+
4721+
4722+static void fail(long eax, ABI_func * p);
4723+static void plist(char * name, char * args, int * list);
4724+
4725+ABI_func * abi_current;
4726+
4727+static const char * const sig_names[] = {
4728+ "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL",
4729+ "SIGTRAP", "SIGABRT/SIGIOT","SIGUNUSED", "SIGFPE",
4730+ "SIGKILL", "SIGUSR1", "SIGSEGV", "SIGUSR2",
4731+ "SIGPIPE", "SIGALRM", "SIGTERM", "SIGSTKFLT",
4732+ "SIGCHLD", "SIGCONT", "SIGSTOP", "SIGTSTP",
4733+ "SIGTTIN", "SIGTTOU", "SIGIO/SIGPOLL/SIGURG",
4734+ "SIGXCPU", "SIGXFSZ", "SIGVTALRM", "SIGPROF",
4735+ "SIGWINCH", "SIGLOST", "SIGPWR", "SIG 31",
4736+ "SIG 32"
4737+};
4738+
4739+
4740+void
4741+abi_dispatch(struct pt_regs * regs, ABI_func * p, int of)
4742+{
4743+ int i;
4744+ int args[8];
4745+ int rvalue;
4746+ void *kfunc;
4747+ short nargs;
4748+
4749+ abi_current = p;
4750+
4751+ kfunc = p->kfunc;
4752+ nargs = p->nargs;
4753+
4754+ /* If the number of arguments is negative this is an unfudged
4755+ * system call function and we need to look up the real function
4756+ * address in the kernel's sys_call_table.
4757+ * Note that we never modify the callmap itself but do the lookup
4758+ * for each call. This allows modules that provide syscalls to
4759+ * be loaded and unloaded without any messy locking.
4760+ */
4761+ if (nargs < 0) {
4762+ kfunc = sys_call_table[(int)kfunc];
4763+
4764+ /* Watch for a magic zero. This exists because we
4765+ * can't use -0 to represent a system call that
4766+ * takes no arguments.
4767+ */
4768+ if (nargs == -ZERO)
4769+ nargs = 0;
4770+ else
4771+ nargs = -nargs;
4772+ }
4773+
4774+ if (nargs <= (short)(sizeof(args)/sizeof(args[0])))
4775+ for(i=0; i < nargs; i++)
4776+ get_user(args[i], ((unsigned long *)regs->esp)+(i+of));
4777+
4778+ if (abi_traced(ABI_TRACE_API)) {
4779+ if (nargs == Spl) {
4780+ for(i = 0; i < (int)strlen(p->args); i++)
4781+ get_user(args[i], ((u_long *)regs->esp) + (i + of));
4782+ }
4783+ plist(p->name, p->args, args);
4784+ }
4785+
4786+ rvalue = -ENOSYS;
4787+ if (kfunc) {
4788+ switch(nargs) {
4789+ case Fast:
4790+ ((sysfun_p)kfunc)(regs);
4791+ if (abi_traced(ABI_TRACE_API|ABI_TRACE_SIGNAL) &&
4792+ signal_pending(current)) {
4793+ u_long signr;
4794+
4795+ signr = current->pending.signal.sig[0] &
4796+ ~current->blocked.sig[0];
4797+
4798+ __asm__("bsf %1,%0\n\t"
4799+ :"=r" (signr)
4800+ :"0" (signr));
4801+
4802+ __abi_trace("SIGNAL %lu <%s>\n",
4803+ signr + 1, sig_names[signr]);
4804+ }
4805+ return;
4806+ case Spl:
4807+ rvalue = ((sysfun_p)kfunc)(regs);
4808+ break;
4809+ case 0:
4810+ rvalue = ((sysfun_p)kfunc)();
4811+ break;
4812+ case 1:
4813+ rvalue = ((sysfun_p)kfunc)(args[0]);
4814+ break;
4815+ case 2:
4816+ rvalue = ((sysfun_p)kfunc)(args[0], args[1]);
4817+ break;
4818+ case 3:
4819+ rvalue = ((sysfun_p)kfunc)(args[0], args[1], args[2]);
4820+ break;
4821+ case 4:
4822+ rvalue = ((sysfun_p)kfunc)(args[0], args[1], args[2], args[3]);
4823+ break;
4824+ case 5:
4825+ rvalue = ((sysfun_p)kfunc)(args[0], args[1], args[2],
4826+ args[3], args[4]);
4827+ break;
4828+ case 6:
4829+ rvalue = ((sysfun_p)kfunc)(args[0], args[1], args[2],
4830+ args[3], args[4], args[5]);
4831+ break;
4832+ case 7:
4833+ rvalue = ((sysfun_p)kfunc)(args[0], args[1], args[2],
4834+ args[3], args[4], args[5],
4835+ args[6]);
4836+ break;
4837+ default:
4838+ fail(regs->eax, p);
4839+ }
4840+ } else
4841+ fail(regs->eax, p);
4842+
4843+ if (rvalue >= 0 || rvalue < -ENOIOCTLCMD) {
4844+ regs->eflags &= ~1; /* Clear carry flag */
4845+ regs->eax = rvalue;
4846+
4847+ abi_trace(ABI_TRACE_API, "%s returns %ld {%ld}\n",
4848+ p->name, regs->eax, regs->edx);
4849+ } else {
4850+ regs->eflags |= 1; /* Set carry flag */
4851+ regs->eax = iABI_errors(-rvalue);
4852+
4853+ if (abi_traced(ABI_TRACE_API)) {
4854+#ifdef CONFIG_ABI_VERBOSE_ERRORS
4855+ __abi_trace("%s error return linux=%d -> ibcs=%ld <%s>\n",
4856+ p->name, rvalue, regs->eax,
4857+ -rvalue < (int)(sizeof(errmsg)/sizeof(errmsg[0]))
4858+ ? errmsg[-rvalue]
4859+ : "unknown");
4860+#else
4861+ __abi_trace("%s error return linux=%d -> ibcs=%ld\n",
4862+ p->name, rvalue, regs->eax);
4863+#endif
4864+ }
4865+ }
4866+
4867+ if (abi_traced(ABI_TRACE_API|ABI_TRACE_SIGNAL) &&
4868+ signal_pending(current)) {
4869+ u_long signr;
4870+
4871+ signr = current->pending.signal.sig[0] &
4872+ ~current->blocked.sig[0];
4873+
4874+ __asm__("bsf %1,%0\n\t"
4875+ :"=r" (signr)
4876+ :"0" (signr));
4877+
4878+ __abi_trace("SIGNAL %lu <%s>, queued 0x%08lx\n",
4879+ signr + 1, sig_names[signr],
4880+ current->pending.signal.sig[0]);
4881+ }
4882+}
4883+EXPORT_SYMBOL(abi_dispatch);
4884+
4885+int
4886+abi_syscall(struct pt_regs *regs)
4887+{
4888+ get_user(regs->eax, ((unsigned long *) regs->esp) + 1);
4889+
4890+ ++regs->esp;
4891+ current->exec_domain->handler(-1,regs);
4892+ --regs->esp;
4893+
4894+ return 0;
4895+}
4896+EXPORT_SYMBOL(abi_syscall);
4897+
4898+/*
4899+ * plist is used by the trace code to show the arg list
4900+ */
4901+static void
4902+plist(char * name, char * args, int * list)
4903+{
4904+ int error;
4905+ char *tmp, *p, arg_buf[512];
4906+
4907+ arg_buf[0] = '\0';
4908+ p = arg_buf;
4909+ while (*args) {
4910+ switch(*args++) {
4911+ case 'd':
4912+ sprintf(p, "%d", *list++);
4913+ break;
4914+ case 'o':
4915+ sprintf(p, "0%o", *list++);
4916+ break;
4917+ case 'p':
4918+ sprintf(p, "0x%p", (void *)(*list++));
4919+ break;
4920+ case '?':
4921+ case 'x':
4922+ sprintf(p, "0x%x", *list++);
4923+ break;
4924+ case 's':
4925+ tmp = getname((char *)(*list++));
4926+ error = PTR_ERR(tmp);
4927+ if (!IS_ERR(tmp)) {
4928+ /* we are debugging, we don't need to see it all */
4929+ tmp[80] = '\0';
4930+ sprintf(p, "\"%s\"", tmp);
4931+ putname(tmp);
4932+ }
4933+ break;
4934+ default:
4935+ sprintf(p, "?%c%c?", '%', args[-1]);
4936+ break;
4937+ }
4938+ while (*p)
4939+ ++p;
4940+ if (*args) {
4941+ *p++ = ',';
4942+ *p++ = ' ';
4943+ *p = '\0';
4944+ }
4945+ }
4946+ __abi_trace("%s(%s)\n", name, arg_buf);
4947+}
4948+
4949+static void
4950+fail(long eax, ABI_func * p)
4951+{
4952+ if (!abi_traced(ABI_TRACE_API))
4953+ return;
4954+
4955+ printk(KERN_ERR "[%s:%d] Unsupported ABI function 0x%lx (%s)\n",
4956+ current->comm, current->pid, eax, p->name);
4957+}
4958+
4959+EXPORT_SYMBOL(abi_traceflg);
4960+EXPORT_SYMBOL(abi_current);
4961diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/common/i386_maps.c linux/abi/common/i386_maps.c
4962--- linux-2.4.3/abi/common/i386_maps.c Thu Jan 1 01:00:00 1970
4963+++ linux/abi/common/i386_maps.c Mon Mar 12 16:34:48 2001
4964@@ -0,0 +1,46 @@
4965+#include <linux/kernel.h>
4966+#include <linux/net.h>
4967+#include <linux/socket.h>
4968+#include <abi/socket.h>
4969+#include <linux/signal.h>
4970+#include <abi/map.h>
4971+#define __NO_VERSION__
4972+ #include <linux/module.h>
4973+
4974+struct map_segment abi_sockopt_map[] = {
4975+ { 0x0001, 0x0001, (char *)SO_DEBUG },
4976+ { 0x0002, 0x0002, (char *)__SO_ACCEPTCON },
4977+ { 0x0004, 0x0004, (char *)SO_REUSEADDR },
4978+ { 0x0008, 0x0008, (char *)SO_KEEPALIVE },
4979+ { 0x0010, 0x0010, (char *)SO_DONTROUTE },
4980+ { 0x0020, 0x0020, (char *)SO_BROADCAST },
4981+ { 0x0040, 0x0040, (char *)SO_USELOOPBACK },
4982+ { 0x0080, 0x0080, (char *)SO_LINGER },
4983+ { 0x0100, 0x0100, (char *)SO_OOBINLINE },
4984+ { 0x0200, 0x0200, (char *)SO_ORDREL },
4985+ { 0x0400, 0x0400, (char *)SO_IMASOCKET },
4986+ { 0x1001, 0x1001, (char *)SO_SNDBUF },
4987+ { 0x1002, 0x1002, (char *)SO_RCVBUF },
4988+ { 0x1003, 0x1003, (char *)SO_SNDLOWAT },
4989+ { 0x1004, 0x1004, (char *)SO_RCVLOWAT },
4990+ { 0x1005, 0x1005, (char *)SO_SNDTIMEO },
4991+ { 0x1006, 0x1006, (char *)SO_RCVTIMEO },
4992+ { 0x1007, 0x1007, (char *)SO_ERROR },
4993+ { 0x1008, 0x1008, (char *)SO_TYPE },
4994+ { 0x1009, 0x1009, (char *)SO_PROTOTYPE },
4995+ { -1 }
4996+};
4997+
4998+
4999+struct map_segment abi_af_map[] = {
5000+ /* The first three entries (AF_UNSPEC, AF_UNIX and AF_INET)
5001+ * are identity mapped. All others aren't available under
5002+ * Linux, nor are Linux's AF_AX25 and AF_IPX available from
5003+ * SCO as far as I know.
5004+ */
5005+ { 0, 2, NULL },
5006+ { -1 }
5007+};
5008+
5009+EXPORT_SYMBOL(abi_af_map);
5010+EXPORT_SYMBOL(abi_sockopt_map);
5011diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/common/ioctl.c linux/abi/common/ioctl.c
5012--- linux-2.4.3/abi/common/ioctl.c Thu Jan 1 01:00:00 1970
5013+++ linux/abi/common/ioctl.c Mon Mar 12 16:34:48 2001
5014@@ -0,0 +1,685 @@
5015+/* $Id$
5016+ *
5017+ * ioctl.c - generic emultions ioctls
5018+ *
5019+ * Copyright (C) 1991, 1992 Linus Torvalds
5020+ *
5021+ * Written by Drew Sullivan.
5022+ * Rewritten by Mike Jagdis.
5023+ *
5024+ */
5025+
5026+#include <linux/module.h>
5027+
5028+#include <linux/errno.h>
5029+#include <linux/stat.h>
5030+#include <linux/fs.h>
5031+#include <linux/sched.h>
5032+#include <linux/kernel.h>
5033+#include <linux/termios.h>
5034+#include <linux/mtio.h>
5035+#include <linux/time.h>
5036+#include <linux/sockios.h>
5037+#include <linux/mm.h>
5038+#include <linux/file.h>
5039+
5040+#include <asm/uaccess.h>
5041+
5042+#include <abi/abi.h>
5043+#include <abi/bsd.h>
5044+#include <abi/stream.h>
5045+#include <abi/tli.h>
5046+#include <abi/abi4.h>
5047+#include <abi/trace.h>
5048+
5049+
5050+int abi_ioctl_socksys(int fd, unsigned int func, void *arg);
5051+
5052+
5053+static inline char *fix(int n)
5054+{
5055+ static char char_class[4];
5056+
5057+ char_class[0] = n & 0xFF0000 ? (char)((n >> 16) & 0xFF) : '.';
5058+ char_class[1] = n & 0x00FF00 ? (char)((n >> 8) & 0xFF) : '.';
5059+ char_class[2] = n & 0x0000FF ? (char)((n ) & 0xFF) : '.';
5060+ char_class[3] = 0;
5061+
5062+ return char_class;
5063+}
5064+
5065+#define BSD_NCCS 20
5066+struct bsd_termios {
5067+ unsigned long c_iflag;
5068+ unsigned long c_oflag;
5069+ unsigned long c_cflag;
5070+ unsigned long c_lflag;
5071+ unsigned char c_cc[BSD_NCCS];
5072+ long c_ispeed;
5073+ long c_ospeed;
5074+};
5075+static unsigned long speed_map[] = {
5076+ 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
5077+ 4800, 9600, 19200, 38400
5078+};
5079+
5080+static unsigned long
5081+bsd_to_linux_speed(unsigned long s)
5082+{
5083+ unsigned int i;
5084+
5085+#ifdef B57600
5086+ if (s == 57600)
5087+ return B57600;
5088+#endif
5089+#ifdef B115200
5090+ if (s == 115200)
5091+ return B115200;
5092+#endif
5093+
5094+ for (i=0; i<sizeof(speed_map)/sizeof(speed_map[0]); i++)
5095+ if (s <= speed_map[i])
5096+ return i;
5097+ return B38400;
5098+}
5099+
5100+static unsigned long
5101+linux_to_bsd_speed(unsigned long s)
5102+{
5103+#ifdef B57600
5104+ if (s == B57600)
5105+ return 57600;
5106+#endif
5107+#ifdef B115200
5108+ if (s == B115200)
5109+ return 115200;
5110+#endif
5111+ return speed_map[s];
5112+}
5113+
5114+
5115+
5116+
5117+static int
5118+bsd_to_linux_termios(int fd, int op, struct bsd_termios *it)
5119+{
5120+ struct termios t;
5121+ mm_segment_t old_fs;
5122+ unsigned long temp;
5123+ char bsd_cc[BSD_NCCS];
5124+ int error;
5125+
5126+ error = verify_area(VERIFY_READ, it, sizeof(struct bsd_termios));
5127+ if (error)
5128+ return error;
5129+
5130+ old_fs = get_fs();
5131+ set_fs(get_ds());
5132+ error = SYS(ioctl)(fd, TCGETS, &t);
5133+ set_fs(old_fs);
5134+ if (error)
5135+ return error;
5136+
5137+ __get_user(t.c_iflag, &it->c_iflag);
5138+ t.c_iflag = (t.c_iflag & ~0xc00)
5139+ | ((t.c_iflag & 0x400) << 1)
5140+ | ((t.c_iflag & 0x800) >> 1);
5141+
5142+ get_user(temp, &it->c_oflag);
5143+ t.c_oflag = (t.c_oflag & ~0x1805)
5144+ | (temp & 9)
5145+ | ((temp & 2) << 1)
5146+ | ((temp & 4) << 10)
5147+ | ((temp & 4) << 9);
5148+
5149+ get_user(temp, &it->c_cflag);
5150+ t.c_cflag = (t.c_cflag & ~0xfff)
5151+ | ((temp & 0xff00) >> 4);
5152+ if (t.c_cflag & 0x30000)
5153+ t.c_cflag |= 020000000000;
5154+ t.c_cflag |= bsd_to_linux_speed(({long s; get_user(s, &it->c_ospeed); s;}))
5155+ | (bsd_to_linux_speed(({long s; get_user(s, &it->c_ispeed); s;})) << 16);
5156+
5157+ get_user(temp, &it->c_lflag);
5158+ t.c_lflag = (t.c_lflag & ~0157663)
5159+ | ((temp & 1) << 12)
5160+ | ((temp & 0x46) << 3)
5161+ | ((temp & 0x420) << 5)
5162+ | ((temp & 0x180) >> 7)
5163+ | ((temp & 0x400000) >> 14)
5164+ | ((temp & 0x2800000) >> 11)
5165+ | ((temp & 0x80000000) >> 24);
5166+
5167+ copy_from_user(bsd_cc, &it->c_cc, BSD_NCCS);
5168+ t.c_cc[VEOF] = bsd_cc[0];
5169+ t.c_cc[VEOL] = bsd_cc[1];
5170+ t.c_cc[VEOL2] = bsd_cc[2];
5171+ t.c_cc[VERASE] = bsd_cc[3];
5172+ t.c_cc[VWERASE] = bsd_cc[4];
5173+ t.c_cc[VKILL] = bsd_cc[5];
5174+ t.c_cc[VREPRINT] = bsd_cc[6];
5175+ t.c_cc[VSWTC] = bsd_cc[7];
5176+ t.c_cc[VINTR] = bsd_cc[8];
5177+ t.c_cc[VQUIT] = bsd_cc[9];
5178+ t.c_cc[VSUSP] = bsd_cc[10];
5179+/* t.c_cc[VDSUSP] = bsd_cc[11];*/
5180+ t.c_cc[VSTART] = bsd_cc[12];
5181+ t.c_cc[VSTOP] = bsd_cc[13];
5182+ t.c_cc[VLNEXT] = bsd_cc[14];
5183+ t.c_cc[VDISCARD] = bsd_cc[15];
5184+ t.c_cc[VMIN] = bsd_cc[16];
5185+ t.c_cc[VTIME] = bsd_cc[17];
5186+/* t.c_cc[VSTATUS] = bsd_cc[18];*/
5187+
5188+ set_fs(get_ds());
5189+ error = SYS(ioctl)(fd, op, &t);
5190+ set_fs(old_fs);
5191+
5192+ return error;
5193+}
5194+
5195+
5196+static int
5197+linux_to_bsd_termios(int fd, int op, struct bsd_termios *it)
5198+{
5199+ struct termios t;
5200+ char bsd_cc[BSD_NCCS];
5201+ mm_segment_t old_fs;
5202+ int error;
5203+
5204+ error = verify_area(VERIFY_WRITE, it, sizeof(struct bsd_termios));
5205+ if (error)
5206+ return error;
5207+
5208+ old_fs = get_fs();
5209+ set_fs(get_ds());
5210+ error = SYS(ioctl)(fd, op, &t);
5211+ set_fs(old_fs);
5212+ if (error)
5213+ return error;
5214+
5215+ put_user((t.c_iflag & 0777)
5216+ | ((t.c_iflag & 02000) >> 1)
5217+ | ((t.c_iflag & 010000) >> 2)
5218+ | ((t.c_iflag & 020000) >> 4),
5219+ &it->c_iflag);
5220+
5221+ put_user((t.c_oflag & 1)
5222+ | ((t.c_oflag & 04) >> 1)
5223+ | ((t.c_oflag & 014000) == 014000 ? 4 : 0),
5224+ &it->c_oflag);
5225+
5226+ put_user((t.c_cflag & ~020000007777)
5227+ | ((t.c_cflag & 0xff0) << 4)
5228+ | ((t.c_cflag & 020000000000) ? 0x30000 : 0),
5229+ &it->c_cflag);
5230+
5231+ put_user(linux_to_bsd_speed(t.c_cflag & CBAUD), &it->c_ospeed);
5232+ if ((t.c_cflag & CIBAUD) != 0)
5233+ put_user(linux_to_bsd_speed((t.c_cflag & CIBAUD) >> 16),
5234+ &it->c_ispeed);
5235+ else
5236+ put_user(linux_to_bsd_speed(t.c_cflag & CBAUD),
5237+ &it->c_ispeed);
5238+
5239+ put_user((t.c_lflag & 07777626010)
5240+ | ((t.c_lflag & 03) << 7)
5241+ | ((t.c_lflag & 01160) >> 3)
5242+ | ((t.c_lflag & 0400) << 14)
5243+ | ((t.c_lflag & 02000) >> 4)
5244+ | ((t.c_lflag & 04000) >> 11)
5245+ | ((t.c_lflag & 010000) << 11)
5246+ | ((t.c_lflag & 040000) << 15)
5247+ | ((t.c_lflag & 0100000) >> 5),
5248+ &it->c_lflag);
5249+
5250+ bsd_cc[0] = t.c_cc[VEOF];
5251+ bsd_cc[1] = t.c_cc[VEOL];
5252+ bsd_cc[2] = t.c_cc[VEOL2];
5253+ bsd_cc[3] = t.c_cc[VERASE];
5254+ bsd_cc[4] = t.c_cc[VWERASE];
5255+ bsd_cc[5] = t.c_cc[VKILL];
5256+ bsd_cc[6] = t.c_cc[VREPRINT];
5257+ bsd_cc[7] = t.c_cc[VSWTC];
5258+ bsd_cc[8] = t.c_cc[VINTR];
5259+ bsd_cc[9] = t.c_cc[VQUIT];
5260+ bsd_cc[10] = t.c_cc[VSUSP];
5261+ bsd_cc[11] = t.c_cc[VSUSP];
5262+ bsd_cc[12] = t.c_cc[VSTART];
5263+ bsd_cc[13] = t.c_cc[VSTOP];
5264+ bsd_cc[14] = t.c_cc[VLNEXT];
5265+ bsd_cc[15] = t.c_cc[VDISCARD];
5266+ bsd_cc[16] = t.c_cc[VMIN];
5267+ bsd_cc[17] = t.c_cc[VTIME];
5268+ bsd_cc[18] = 0; /* t.c_cc[VSTATUS]; */
5269+ bsd_cc[19] = 0;
5270+
5271+ copy_to_user(&it->c_cc, bsd_cc, BSD_NCCS);
5272+
5273+ return error;
5274+}
5275+
5276+
5277+
5278+
5279+struct v7_sgttyb {
5280+ unsigned char sg_ispeed;
5281+ unsigned char sg_ospeed;
5282+ unsigned char sg_erase;
5283+ unsigned char sg_kill;
5284+ int sg_flags;
5285+};
5286+
5287+struct v7_tchars {
5288+ char t_intrc;
5289+ char t_quitc;
5290+ char t_startc;
5291+ char t_stopc;
5292+ char t_eofc;
5293+ char t_brkc;
5294+};
5295+
5296+struct v7_ltchars {
5297+ char t_suspc;
5298+ char t_dsuspc;
5299+ char t_rprntc;
5300+ char t_flushc;
5301+ char t_werasc;
5302+ char t_lnextc;
5303+};
5304+
5305+
5306+int bsd_ioctl_termios(int fd, unsigned int func, void *arg)
5307+{
5308+ switch (func & 0xff) {
5309+ case 0: { /* TIOCGETD */
5310+ unsigned long ldisc;
5311+ mm_segment_t old_fs;
5312+ int error;
5313+
5314+ error = verify_area(VERIFY_WRITE, arg,
5315+ sizeof(unsigned short));
5316+ if (error)
5317+ return error;
5318+
5319+ old_fs = get_fs();
5320+ set_fs(get_ds());
5321+ error = SYS(ioctl)(fd, TIOCGETD, &ldisc);
5322+ set_fs(old_fs);
5323+ if (!error)
5324+ put_user(ldisc, (unsigned short *)arg);
5325+ return error;
5326+ }
5327+ case 1: { /* TIOCSETD */
5328+ unsigned long ldisc;
5329+ mm_segment_t old_fs;
5330+ int error;
5331+
5332+ error = verify_area(VERIFY_READ, arg,
5333+ sizeof(unsigned short));
5334+ if (error)
5335+ return error;
5336+
5337+ get_user(ldisc, (unsigned short *)arg);
5338+ old_fs = get_fs();
5339+ set_fs(get_ds());
5340+ error = SYS(ioctl)(fd, TIOCSETD, &ldisc);
5341+ set_fs(old_fs);
5342+ return error;
5343+ }
5344+
5345+ case 2: { /* TIOCHPCL */
5346+ int error;
5347+ mm_segment_t old_fs;
5348+ struct termios t;
5349+
5350+ old_fs = get_fs();
5351+ set_fs(get_ds());
5352+ error = SYS(ioctl)(fd, TCGETS, &t);
5353+ set_fs(old_fs);
5354+ if (error)
5355+ return error;
5356+
5357+ if (arg)
5358+ t.c_cflag |= HUPCL;
5359+ else
5360+ t.c_cflag &= ~HUPCL;
5361+
5362+ old_fs = get_fs();
5363+ set_fs(get_ds());
5364+ error = SYS(ioctl)(fd, TCSETS, &t);
5365+ set_fs(old_fs);
5366+ return error;
5367+ }
5368+
5369+ case 8: { /* TIOCGETP */
5370+ int error;
5371+ mm_segment_t old_fs;
5372+ struct termios t;
5373+ struct v7_sgttyb sg;
5374+
5375+ error = verify_area(VERIFY_WRITE, arg, sizeof(sg));
5376+ if (error)
5377+ return error;
5378+
5379+ old_fs = get_fs();
5380+ set_fs(get_ds());
5381+ error = SYS(ioctl)(fd, TCGETS, &t);
5382+ set_fs(old_fs);
5383+ if (error)
5384+ return error;
5385+
5386+ sg.sg_ispeed = sg.sg_ospeed = 0;
5387+ sg.sg_erase = t.c_cc[VERASE];
5388+ sg.sg_kill = t.c_cc[VKILL];
5389+ sg.sg_flags =
5390+ /* Old - became TANDEM instead.
5391+ * ((t.c_cflag & HUPCL) >> 10)
5392+ * |
5393+ */
5394+/* O_ODDP */ ((t.c_cflag & PARODD) >> 3)
5395+/* O_EVENP */ | ((t.c_cflag & PARENB) >> 1)
5396+/* LITOUT */ | ((t.c_cflag & OPOST) ? 0 : 0x200000)
5397+/* O_CRMOD */ | ((t.c_oflag & ONLCR) << 2)
5398+/* O_NL1|O_VTDELAY */ | (t.c_oflag & (NL1|VTDLY))
5399+/* O_TBDELAY */ | ((t.c_oflag & TABDLY) ? 02000 : 0)
5400+/* O_CRDELAY */ | ((t.c_oflag & CRDLY) << 3)
5401+/* O_BSDELAY */ | ((t.c_oflag & BSDLY) << 2)
5402+/* O_ECHO|O_LCASE */ | (t.c_lflag & (XCASE|ECHO))
5403+ | ((t.c_lflag & ICANON)
5404+/* O_CBREAK or O_RAW */ ? 0 : ((t.c_lflag & ISIG) ? 0x02 : 0x20))
5405+ /* Incomplete... */
5406+ ;
5407+
5408+ copy_to_user(arg, &sg, sizeof(sg));
5409+ return 0;
5410+ }
5411+
5412+ case 9: /* TIOCSETP */
5413+ case 10: { /* TIOCSETN */
5414+ int error;
5415+ mm_segment_t old_fs;
5416+ struct termios t;
5417+ struct v7_sgttyb sg;
5418+
5419+ error = verify_area(VERIFY_READ, arg, sizeof(sg));
5420+ if (error)
5421+ return error;
5422+ copy_from_user(&sg, arg, sizeof(sg));
5423+
5424+ old_fs = get_fs();
5425+ set_fs(get_ds());
5426+ error = SYS(ioctl)(fd, TCGETS, &t);
5427+ set_fs(old_fs);
5428+ if (error)
5429+ return error;
5430+
5431+ t.c_cc[VERASE] = sg.sg_erase;
5432+ t.c_cc[VKILL] = sg.sg_kill;
5433+ t.c_iflag = ICRNL | IXON;
5434+ t.c_oflag = 0;
5435+ t.c_lflag = ISIG | ICANON;
5436+ if (sg.sg_flags & 0x02) /* O_CBREAK */
5437+ t.c_lflag &= (~ICANON);
5438+ if (sg.sg_flags & 0x08) /* O_ECHO */
5439+ t.c_lflag |= ECHO|ECHOE|ECHOK|ECHOCTL|ECHOKE|IEXTEN;
5440+ if (sg.sg_flags & 0x10) /* O_CRMOD */
5441+ t.c_oflag |= OPOST|ONLCR;
5442+ if (sg.sg_flags & 0x20) { /* O_RAW */
5443+ t.c_iflag = 0;
5444+ t.c_lflag &= ~(ISIG|ICANON);
5445+ }
5446+ if (sg.sg_flags & 0x200000) /* LITOUT */
5447+ t.c_oflag &= (~OPOST);
5448+ if (!(t.c_lflag & ICANON)) {
5449+ t.c_cc[VMIN] = 1;
5450+ t.c_cc[VTIME] = 0;
5451+ }
5452+
5453+ old_fs = get_fs();
5454+ set_fs(get_ds());
5455+ error = SYS(ioctl)(fd, TCSETS, &t);
5456+ set_fs(old_fs);
5457+ return error;
5458+ }
5459+
5460+ case 17: { /* TIOCSETC */
5461+ int error;
5462+ mm_segment_t old_fs;
5463+ struct termios t;
5464+ struct v7_tchars tc;
5465+
5466+ error = verify_area(VERIFY_READ, arg, sizeof(tc));
5467+ if (error)
5468+ return error;
5469+ copy_from_user(&tc, arg, sizeof(tc));
5470+
5471+ old_fs = get_fs();
5472+ set_fs(get_ds());
5473+ error = SYS(ioctl)(fd, TCGETS, &t);
5474+ set_fs(old_fs);
5475+ if (error)
5476+ return error;
5477+
5478+ t.c_cc[VINTR] = tc.t_intrc;
5479+ t.c_cc[VQUIT] = tc.t_quitc;
5480+ t.c_cc[VSTART] = tc.t_startc;
5481+ t.c_cc[VSTOP] = tc.t_stopc;
5482+ t.c_cc[VEOF] = tc.t_eofc;
5483+ t.c_cc[VEOL2] = tc.t_brkc;
5484+
5485+ old_fs = get_fs();
5486+ set_fs(get_ds());
5487+ error = SYS(ioctl)(fd, TCSETS, &t);
5488+ set_fs(old_fs);
5489+ return error;
5490+ }
5491+
5492+ case 18: { /* TIOCGETC */
5493+ int error;
5494+ mm_segment_t old_fs;
5495+ struct termios t;
5496+ struct v7_tchars tc;
5497+
5498+ error = verify_area(VERIFY_WRITE, arg, sizeof(tc));
5499+ if (error)
5500+ return error;
5501+
5502+ old_fs = get_fs();
5503+ set_fs(get_ds());
5504+ error = SYS(ioctl)(fd, TCGETS, &t);
5505+ set_fs(old_fs);
5506+ if (error)
5507+ return error;
5508+
5509+ tc.t_intrc = t.c_cc[VINTR];
5510+ tc.t_quitc = t.c_cc[VQUIT];
5511+ tc.t_startc = t.c_cc[VSTART];
5512+ tc.t_stopc = t.c_cc[VSTOP];
5513+ tc.t_eofc = t.c_cc[VEOF];
5514+ tc.t_brkc = t.c_cc[VEOL2];
5515+
5516+ copy_to_user(arg, &tc, sizeof(tc));
5517+ return 0;
5518+ }
5519+
5520+ case 116: { /* TIOCGLTC */
5521+ int error;
5522+ mm_segment_t old_fs;
5523+ struct termios t;
5524+ struct v7_ltchars tc;
5525+
5526+ error = verify_area(VERIFY_WRITE, arg, sizeof(tc));
5527+ if (error)
5528+ return error;
5529+
5530+ old_fs = get_fs();
5531+ set_fs(get_ds());
5532+ error = SYS(ioctl)(fd, TCGETS, &t);
5533+ set_fs(old_fs);
5534+ if (error)
5535+ return error;
5536+
5537+ tc.t_suspc = t.c_cc[VSUSP];
5538+ tc.t_dsuspc = t.c_cc[VSUSP];
5539+ tc.t_rprntc = t.c_cc[VREPRINT];
5540+ tc.t_flushc = t.c_cc[VEOL2];
5541+ tc.t_werasc = t.c_cc[VWERASE];
5542+ tc.t_lnextc = t.c_cc[VLNEXT];
5543+
5544+ copy_to_user(arg, &tc, sizeof(tc));
5545+ return 0;
5546+ }
5547+
5548+ case 117: { /* TIOCSLTC */
5549+ int error;
5550+ mm_segment_t old_fs;
5551+ struct termios t;
5552+ struct v7_ltchars tc;
5553+
5554+ error = verify_area(VERIFY_READ, arg, sizeof(tc));
5555+ if (error)
5556+ return error;
5557+ copy_from_user(&tc, arg, sizeof(tc));
5558+
5559+ old_fs = get_fs();
5560+ set_fs(get_ds());
5561+ error = SYS(ioctl)(fd, TCGETS, &t);
5562+ set_fs(old_fs);
5563+ if (error)
5564+ return error;
5565+
5566+ t.c_cc[VSUSP] = tc.t_suspc;
5567+ t.c_cc[VEOL2] = tc.t_dsuspc;
5568+ t.c_cc[VREPRINT] = tc.t_rprntc;
5569+ t.c_cc[VEOL2] = tc.t_flushc;
5570+ t.c_cc[VWERASE] = tc.t_werasc;
5571+ t.c_cc[VLNEXT] = tc.t_lnextc;
5572+
5573+ old_fs = get_fs();
5574+ set_fs(get_ds());
5575+ error = SYS(ioctl)(fd, TCSETS, &t);
5576+ set_fs(old_fs);
5577+ return error;
5578+ }
5579+
5580+ case 13: /* TIOEXCL */
5581+ return SYS(ioctl)(fd, TIOCEXCL, arg);
5582+
5583+ case 14: /* TIOCNXCL */
5584+ return SYS(ioctl)(fd, TIOCNXCL, arg);
5585+
5586+ case 16: /* TIOCFLUSH */
5587+ return SYS(ioctl)(fd, TCFLSH, arg);
5588+
5589+ /* ISC (maybe SVR4 in general?) has some extensions over
5590+ * the sgtty stuff. So do later BSDs. Needless to say they
5591+ * both have different extensions.
5592+ */
5593+ case 20: /* TCSETPGRP (TIOC|20) set pgrp of tty */
5594+ return bsd_to_linux_termios(fd, TCSETS, arg);
5595+
5596+ case 21: /* TCGETPGRP (TIOC|21) get pgrp of tty */
5597+ return bsd_to_linux_termios(fd, TCSETSW, arg);
5598+
5599+ case 19: /* TIOCGETA */
5600+ return linux_to_bsd_termios(fd, TCGETS, arg);
5601+
5602+ case 22: /* TIOCSETAF */
5603+ return bsd_to_linux_termios(fd, TCSETSF, arg);
5604+
5605+ case 26: /* TIOCGETD */
5606+ return SYS(ioctl)(fd, TIOCGETD, arg);
5607+
5608+ case 27: /* TIOCSETD */
5609+ return SYS(ioctl)(fd, TIOCSETD, arg);
5610+
5611+ case 97: /* TIOCSCTTY */
5612+ return SYS(ioctl)(fd, TIOCSCTTY, arg);
5613+
5614+ case 103: /* TIOCSWINSZ */
5615+ return SYS(ioctl)(fd, TIOCSWINSZ, arg);
5616+
5617+ case 104: /* TIOCGWINSZ */
5618+ return SYS(ioctl)(fd, TIOCGWINSZ, arg);
5619+
5620+ case 113: /* TIOCNOTTY */
5621+ return SYS(ioctl)(fd, TIOCNOTTY, arg);
5622+
5623+ case 118: /* TIOCSPGRP */
5624+ return SYS(ioctl)(fd, TIOCSPGRP, arg);
5625+
5626+ case 119: /* TIOCGPGRP */
5627+ return SYS(ioctl)(fd, TIOCGPGRP, arg);
5628+
5629+ case 123: /* TIOCSBRK */
5630+ return SYS(ioctl)(fd, TCSBRK, arg);
5631+
5632+ case 124: /* TIOCLGET */
5633+ case 125: /* TIOCLSET */
5634+ return 0;
5635+
5636+
5637+ case 3: /* TIOCMODG */
5638+ case 4: /* TIOCMODS */
5639+ case 94: /* TIOCDRAIN */
5640+ case 95: /* TIOCSIG */
5641+ case 96: /* TIOCEXT */
5642+ case 98: /* TIOCCONS */
5643+ case 102: /* TIOCUCNTL */
5644+ case 105: /* TIOCREMOTE */
5645+ case 106: /* TIOCMGET */
5646+ case 107: /* TIOCMBIC */
5647+ case 108: /* TIOCMBIS */
5648+ case 109: /* TIOCMSET */
5649+ case 110: /* TIOCSTART */
5650+ case 111: /* TIOCSTOP */
5651+ case 112: /* TIOCPKT */
5652+ case 114: /* TIOCSTI */
5653+ case 115: /* TIOCOUTQ */
5654+ case 120: /* TIOCCDTR */
5655+ case 121: /* TIOCSDTR */
5656+ case 122: /* TIOCCBRK */
5657+
5658+ }
5659+
5660+ printk(KERN_ERR "BSD/V7: terminal ioctl 0x%08lx unsupported\n",
5661+ (unsigned long)func);
5662+ return -EINVAL;
5663+}
5664+
5665+
5666+EXPORT_SYMBOL(bsd_ioctl_termios);
5667+
5668+
5669+int abi_ioctl_console(int fd, unsigned int func, void *arg) {
5670+ switch(func) {
5671+ case 0x6301: /* CONS_CURRENT: Get display adapter type */
5672+ case 0x6302: /* CONS_GET: Get display mode setting */
5673+ /* Always error so the application never tries
5674+ * anything overly fancy on the console.
5675+ */
5676+ return -EINVAL;
5677+ case 0x4304: /* _TTYDEVTYPE */
5678+ /* If on console then 1, if pseudo tty then 2 */
5679+ return 2;
5680+ }
5681+ printk(KERN_ERR "iBCS: console ioctl %d unsupported\n", func);
5682+ return -EINVAL;
5683+}
5684+
5685+EXPORT_SYMBOL(abi_ioctl_console);
5686+
5687+int abi_ioctl_video(int fd, unsigned int func, void *arg) {
5688+ switch(func) {
5689+ case 1: /* MAP_CLASS */
5690+ /* Get video memory map & IO privilege */
5691+ /* This doesn't agree with my SCO 3.2.4 ???? */
5692+ case 4: /* C_IOC */
5693+ /* see /etc/conf/pack.d/cn/class.h on any SCO unix box :-) */
5694+ }
5695+ printk(KERN_ERR "iBCS: video ioctl %d unsupported\n", func);
5696+ return -EINVAL;
5697+}
5698+
5699+EXPORT_SYMBOL(abi_ioctl_video);
5700diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/common/map.c linux/abi/common/map.c
5701--- linux-2.4.3/abi/common/map.c Thu Jan 1 01:00:00 1970
5702+++ linux/abi/common/map.c Mon Mar 12 16:34:48 2001
5703@@ -0,0 +1,100 @@
5704+/* $Id$
5705+ *
5706+ * map.c - generic mapping routines for binary emulation
5707+ *
5708+ * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
5709+ *
5710+ */
5711+
5712+#include <linux/module.h>
5713+
5714+#include <linux/sched.h>
5715+#include <linux/net.h>
5716+#include <linux/socket.h>
5717+#include <linux/signal.h>
5718+#include <linux/errno.h>
5719+#include <linux/personality.h>
5720+
5721+#include <abi/socket.h>
5722+#include <abi/map.h>
5723+
5724+long
5725+map_bitvec(unsigned long vec, long map[])
5726+{
5727+ unsigned long newvec, m;
5728+ int i;
5729+
5730+ newvec = 0;
5731+ for (m=1,i=1; i<=32; m<<=1,i++)
5732+ if ((vec & m) && map[i] != -1)
5733+ newvec |= (1 << map[i]);
5734+
5735+ return newvec;
5736+}
5737+
5738+EXPORT_SYMBOL(map_bitvec);
5739+
5740+unsigned long
5741+map_sigvec_from_kernel(sigset_t vec, unsigned long map[])
5742+{
5743+ unsigned long newvec;
5744+ int i;
5745+
5746+ newvec = 0;
5747+ for (i=1; i<=32; i++) {
5748+ if (sigismember(&vec, i) && map[i] != -1)
5749+ newvec |= (1 << map[i]);
5750+ }
5751+ return newvec;
5752+}
5753+
5754+EXPORT_SYMBOL(map_sigvec_from_kernel);
5755+
5756+sigset_t
5757+map_sigvec_to_kernel(unsigned long vec, unsigned long map[])
5758+{
5759+ sigset_t newvec;
5760+ unsigned long m;
5761+ int i;
5762+
5763+ sigemptyset(&newvec);
5764+ for (m=1,i=1; i<=32; m<<=1,i++) {
5765+ if ((vec & m) && map[i] != -1)
5766+ sigaddset(&newvec, map[i]);
5767+ }
5768+ return newvec;
5769+}
5770+
5771+EXPORT_SYMBOL(map_sigvec_to_kernel);
5772+
5773+int
5774+map_value(struct map_segment *m, int val, int def) {
5775+ struct map_segment *seg;
5776+
5777+ /* If no mapping exists in this personality just return the
5778+ * number we were given.
5779+ */
5780+ if (!m)
5781+ return val;
5782+
5783+ /* Search the map looking for a mapping for the given number. */
5784+ for (seg=m; seg->start != -1; seg++) {
5785+ if (seg->start <= val && val <= seg->end) {
5786+ /* If the start and end are the same then this
5787+ * segment has one entry and the map is the value
5788+ * it maps to. Otherwise if we have a vector we
5789+ * pick out the relevant value, if we don't have
5790+ * a vector we give identity mapping.
5791+ */
5792+ if (seg->start == seg->end)
5793+ return (int)seg->map;
5794+ else
5795+ return (seg->map ? seg->map[val-seg->start] : val);
5796+ }
5797+ }
5798+
5799+ /* Number isn't mapped. Returned the requested default. */
5800+ return def;
5801+}
5802+
5803+EXPORT_SYMBOL(map_value);
5804diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/common/signal.c linux/abi/common/signal.c
5805--- linux-2.4.3/abi/common/signal.c Thu Jan 1 01:00:00 1970
5806+++ linux/abi/common/signal.c Mon Mar 12 16:34:48 2001
5807@@ -0,0 +1,573 @@
5808+/* $Id$
5809+ *
5810+ * signal.c - generic signal emulation code
5811+ *
5812+ * This module does not go through the normal processing routines for
5813+ * ibcs. The reason for this is that for most events, the return is a
5814+ * procedure address for the previous setting. This procedure address
5815+ * may be negative which is not an error. Therefore, the return processing
5816+ * for standard functions is skipped by declaring this routine as a "special"
5817+ * module for the decoder and dealing with the register settings directly.
5818+ *
5819+ * Please consider this closely if you plan on changing this mode.
5820+ * -- Al Longyear
5821+ */
5822+
5823+#include <linux/config.h>
5824+#include <linux/module.h>
5825+
5826+#include <linux/errno.h>
5827+#include <linux/sched.h>
5828+#include <linux/kernel.h>
5829+#include <linux/mm.h>
5830+#include <linux/stddef.h>
5831+#include <linux/unistd.h>
5832+#include <linux/ptrace.h>
5833+#include <linux/fcntl.h>
5834+#include <linux/personality.h>
5835+#include <linux/fs.h>
5836+#include <linux/sys.h>
5837+#include <linux/signal.h>
5838+
5839+#include <asm/system.h>
5840+#include <asm/uaccess.h>
5841+
5842+#include <abi/abi.h>
5843+#include <abi/xnx.h>
5844+#include <abi/abi4.h>
5845+#include <abi/map.h>
5846+
5847+#define SIG_HOLD ((__sighandler_t)2) /* hold signal */
5848+
5849+#include <abi/trace.h>
5850+#include <abi/signal.h>
5851+
5852+
5853+typedef void (*pfn) (void); /* Completion function */
5854+
5855+/*
5856+ * Parameters to the signal functions have a common stack frame. This
5857+ * defines the stack frame.
5858+ */
5859+
5860+#define SIGNAL_NUMBER get_syscall_parameter (regs, 0)
5861+#define HIDDEN_PARAM (SIGNAL_NUMBER & ~0xFF)
5862+#define SECOND_PARAM get_syscall_parameter (regs, 1)
5863+#ifdef __sparc__
5864+#define THIRD_PARAM get_syscall_parameter (regs, 2)
5865+#else /* __sparc__ */
5866+#define THIRD_PARAM ((unsigned long) regs->edx)
5867+#endif /* __sparc__ */
5868+
5869+/* Return a mask that includes SIG only. */
5870+#define __sigmask(sig) (1 << ((sig) - 1))
5871+
5872+
5873+#define TO_KERNEL(save) \
5874+ save = get_fs (); \
5875+ set_fs (get_ds ())
5876+
5877+#define FROM_KERNEL(save) \
5878+ set_fs (save)
5879+
5880+#define _S(nr) (1<<((nr)-1))
5881+
5882+#define _BLOCKABLE (~(_S(IBCS_SIGKILL) | _S(IBCS_SIGSTOP)))
5883+
5884+void
5885+deactivate_signal(struct task_struct *task, int signum)
5886+{
5887+ spin_lock_irq(&task->sigmask_lock);
5888+ sigdelset(&task->pending.signal, signum);
5889+ spin_unlock_irq(&task->sigmask_lock);
5890+}
5891+
5892+
5893+EXPORT_SYMBOL(deactivate_signal);
5894+
5895+/*
5896+ * Translate the signal number to the corresponding item for Linux.
5897+ */
5898+static inline int abi_mapsig(int sig)
5899+{
5900+ if ((unsigned int) sig >= NSIGNALS)
5901+ return -1;
5902+ return current->exec_domain->signal_map[sig];
5903+}
5904+
5905+
5906+inline int abi_signo (struct pt_regs *regs, int *sig)
5907+{
5908+ int value = abi_mapsig(SIGNAL_NUMBER & 0xFF);
5909+
5910+ if (value == -1) {
5911+ set_error (regs, iABI_errors (EINVAL));
5912+ return 0;
5913+ }
5914+
5915+ *sig = value;
5916+ return 1;
5917+}
5918+
5919+EXPORT_SYMBOL(abi_signo);
5920+
5921+/*
5922+ * Process the signal() function from iBCS
5923+ *
5924+ * This version appeared in "Advanced Programming in the Unix Environment"
5925+ * by W. Richard Stevens, page 298.
5926+ */
5927+
5928+void abi_sig_handler (struct pt_regs * regs, int sig,
5929+ __sighandler_t handler, int oneshot)
5930+{
5931+ struct sigaction act, oact;
5932+ int answer;
5933+ mm_segment_t old_fs;
5934+
5935+ sigemptyset (&act.sa_mask);
5936+ act.sa_restorer = NULL;
5937+ act.sa_handler = handler;
5938+ act.sa_flags = 0;
5939+
5940+ if (oneshot)
5941+ act.sa_flags = SA_ONESHOT | SA_NOMASK;
5942+ else
5943+ act.sa_flags = 0;
5944+
5945+ TO_KERNEL (old_fs);
5946+ answer = SYS(rt_sigaction) (sig, &act, &oact, sizeof(sigset_t));
5947+ FROM_KERNEL (old_fs);
5948+
5949+ if (answer < 0) {
5950+ set_error (regs, iABI_errors (-answer));
5951+ } else
5952+ set_result (regs, (int) oact.sa_handler);
5953+}
5954+
5955+EXPORT_SYMBOL(abi_sig_handler);
5956+
5957+/*
5958+ * Process the signal() function from iBCS
5959+ */
5960+int abi_signal (struct pt_regs * regs)
5961+{
5962+ __sighandler_t vec;
5963+ int sig;
5964+
5965+ if (abi_signo (regs, &sig)) {
5966+ vec = (__sighandler_t) SECOND_PARAM;
5967+ abi_sig_handler (regs, sig, vec, 1);
5968+ }
5969+ return 0;
5970+}
5971+
5972+EXPORT_SYMBOL(abi_signal);
5973+
5974+/*
5975+ * Process the iBCS sigset function.
5976+ *
5977+ * This is basically the same as the signal() routine with the exception
5978+ * that it will accept a SIG_HOLD parameter.
5979+ *
5980+ * A SIG_HOLD will defer the processing of the signal until a sigrelse()
5981+ * function is called.
5982+ */
5983+int abi_sigset (struct pt_regs * regs)
5984+{
5985+ sigset_t newmask, oldmask;
5986+ __sighandler_t vec;
5987+ int sig, answer;
5988+ mm_segment_t old_fs;
5989+
5990+ if (abi_signo (regs, &sig)) {
5991+ vec = (__sighandler_t) SECOND_PARAM;
5992+ if (vec != SIG_HOLD) {
5993+ deactivate_signal(current, sig);
5994+ abi_sig_handler (regs, sig, vec, 0);
5995+ } else {
5996+/*
5997+ * Process the hold function
5998+ */
5999+ sigemptyset (&newmask);
6000+ sigaddset (&newmask, sig);
6001+
6002+ TO_KERNEL (old_fs);
6003+ answer = SYS(rt_sigprocmask) (SIG_BLOCK,
6004+ &newmask, &oldmask,
6005+ sizeof(sigset_t));
6006+ FROM_KERNEL (old_fs);
6007+
6008+ if (answer < 0) {
6009+ set_error (regs, iABI_errors (-answer));
6010+ }
6011+ }
6012+ }
6013+ return 0;
6014+}
6015+
6016+EXPORT_SYMBOL(abi_sigset);
6017+
6018+/*
6019+ * Process the iBCS sighold function.
6020+ *
6021+ * Suspend the signal from future recognition.
6022+ */
6023+void abi_sighold (struct pt_regs * regs)
6024+{
6025+ sigset_t newmask, oldmask;
6026+ int sig, answer;
6027+ mm_segment_t old_fs;
6028+
6029+ if (!abi_signo (regs, &sig))
6030+ return;
6031+
6032+ sigemptyset (&newmask);
6033+ sigaddset (&newmask, sig);
6034+
6035+ TO_KERNEL (old_fs);
6036+ answer = SYS(rt_sigprocmask) (SIG_BLOCK, &newmask, &oldmask,
6037+ sizeof(sigset_t));
6038+ FROM_KERNEL (old_fs);
6039+
6040+ if (answer < 0) {
6041+ set_error (regs, iABI_errors (-answer));
6042+ }
6043+}
6044+
6045+EXPORT_SYMBOL(abi_sighold);
6046+
6047+/*
6048+ * Process the iBCS sigrelse.
6049+ *
6050+ * Re-enable the signal processing from a previously suspended
6051+ * signal. This may have been done by calling the sighold() function
6052+ * or a longjmp() during the signal processing routine. If you do a
6053+ * longjmp() function then it is expected that you will call sigrelse
6054+ * before going on with the program.
6055+ */
6056+void abi_sigrelse (struct pt_regs * regs)
6057+{
6058+ sigset_t newmask, oldmask;
6059+ int sig, answer;
6060+ mm_segment_t old_fs;
6061+
6062+ if (!abi_signo (regs, &sig))
6063+ return;
6064+
6065+ sigemptyset (&newmask);
6066+ sigaddset (&newmask, sig);
6067+
6068+ TO_KERNEL (old_fs);
6069+ answer = SYS(rt_sigprocmask) (SIG_UNBLOCK, &newmask, &oldmask,
6070+ sizeof(sigset_t));
6071+ FROM_KERNEL (old_fs);
6072+
6073+ if (answer < 0) {
6074+ set_error (regs, iABI_errors (-answer));
6075+ }
6076+}
6077+
6078+EXPORT_SYMBOL(abi_sigrelse);
6079+
6080+/*
6081+ * Process the iBCS sigignore
6082+ *
6083+ * This is basically a signal (...,SIG_IGN) call.
6084+ */
6085+
6086+void abi_sigignore (struct pt_regs * regs)
6087+{
6088+ struct sigaction act, oact;
6089+ int sig, answer;
6090+ mm_segment_t old_fs;
6091+
6092+ if (!abi_signo (regs, &sig))
6093+ return;
6094+
6095+ sigemptyset (&act.sa_mask);
6096+
6097+ act.sa_restorer = NULL;
6098+ act.sa_handler = SIG_IGN;
6099+ act.sa_flags = 0;
6100+
6101+ TO_KERNEL (old_fs);
6102+ answer = SYS(rt_sigaction) (sig, &act, &oact, sizeof(sigset_t));
6103+ FROM_KERNEL (old_fs);
6104+
6105+ if (answer < 0) {
6106+ set_error (regs, iABI_errors (-answer));
6107+ }
6108+}
6109+
6110+EXPORT_SYMBOL(abi_sigignore);
6111+
6112+/*
6113+ * Process the iBCS sigpause
6114+ *
6115+ * Wait for the signal indicated to arrive before resuming the
6116+ * processing. I do not know if the signal is processed first using
6117+ * the normal event processing before the return. If someone can
6118+ * shed some light on this then please correct this code. I block
6119+ * the signal and look for it to show up in the pending list.
6120+ */
6121+
6122+void abi_sigpause (struct pt_regs * regs)
6123+{
6124+ old_sigset_t newset;
6125+ int sig, answer;
6126+
6127+#ifdef __sparc__
6128+ printk(KERN_ERR "Sparc/iBCS: sigpause not yet implemented\n");
6129+#else
6130+ if (!abi_signo(regs, &sig))
6131+ return;
6132+
6133+ newset = ~0UL;
6134+ newset &= (1UL << (sig-1));
6135+ answer = SYS(sigsuspend)(0, current->blocked,
6136+ newset, regs->esi, regs->edi,
6137+ regs->ebp, regs->eax,
6138+ regs->xds, regs->xes,
6139+ regs->orig_eax,
6140+ regs->eip, regs->xcs, regs->eflags,
6141+ regs->esp, regs->xss);
6142+
6143+ if (answer < 0) {
6144+ set_error(regs, iABI_errors(-answer));
6145+ }
6146+#endif
6147+}
6148+
6149+EXPORT_SYMBOL(abi_sigpause);
6150+
6151+/*
6152+ * This is the service routine for the syscall #48 (signal funcs).
6153+ *
6154+ * Examine the request code and branch on the request to the appropriate
6155+ * function.
6156+ */
6157+
6158+int abi_sigfunc (struct pt_regs * regs)
6159+{
6160+ int sig_type = (int) HIDDEN_PARAM;
6161+
6162+ abi_trace(ABI_TRACE_SIGNAL|ABI_TRACE_SIGNAL_F, "sig%s(%ld, 0x%08lx, 0x%08lx)",
6163+ sig_type == 0 ? "nal"
6164+ : (sig_type == 0x100 ? "set"
6165+ : (sig_type == 0x200 ? "hold"
6166+ : (sig_type == 0x400 ? "relse"
6167+ : (sig_type == 0x800 ? "ignore"
6168+ : (sig_type == 0x1000 ? "pause"
6169+ : "???" ))))),
6170+ SIGNAL_NUMBER & 0xff, SECOND_PARAM, THIRD_PARAM);
6171+
6172+#ifdef __sparc__
6173+ set_result (regs, 0);
6174+#else /* __sparc__ */
6175+ regs->eflags &= ~1;
6176+ regs->eax = 0;
6177+#endif /* __sparc__ */
6178+ switch (sig_type) {
6179+ case 0x0000:
6180+ abi_signal (regs);
6181+ break;
6182+
6183+ case 0x0100:
6184+ abi_sigset (regs);
6185+ break;
6186+
6187+ case 0x0200:
6188+ abi_sighold (regs);
6189+ break;
6190+
6191+ case 0x0400:
6192+ abi_sigrelse (regs);
6193+ break;
6194+
6195+ case 0x0800:
6196+ abi_sigignore (regs);
6197+ break;
6198+
6199+ case 0x1000:
6200+ abi_sigpause (regs);
6201+ break;
6202+
6203+ default:
6204+ set_error (regs, EINVAL);
6205+
6206+ abi_trace(ABI_TRACE_SIGNAL|ABI_TRACE_SIGNAL_F,
6207+ "sigfunc(%x, %ld, %lx, %lx) unsupported",
6208+ sig_type,
6209+ SIGNAL_NUMBER, SECOND_PARAM, THIRD_PARAM);
6210+
6211+ return 0;
6212+ }
6213+
6214+ abi_trace(ABI_TRACE_SIGNAL|ABI_TRACE_SIGNAL_F,
6215+ "returns %ld", get_result (regs));
6216+ return 0;
6217+}
6218+
6219+EXPORT_SYMBOL(abi_sigfunc);
6220+
6221+
6222+/* This function is used to handle the sigaction call from SVr4 binaries.
6223+ If anyone else uses this, this function needs to be modified since the
6224+ order and size of the ibcs_sigaction structure is different in ibcs
6225+ and the SVr4 ABI */
6226+
6227+
6228+asmlinkage int abi_sigaction(int abi_signum, const struct abi_sigaction * action,
6229+ struct abi_sigaction * oldaction)
6230+{
6231+ struct abi_sigaction new_sa, old_sa;
6232+ int error, signo;
6233+ mm_segment_t old_fs;
6234+ struct sigaction nsa, osa;
6235+
6236+ signo = abi_mapsig(abi_signum);
6237+ if (signo == -1)
6238+ return -EINVAL;
6239+
6240+ if (oldaction) {
6241+ error = verify_area(VERIFY_WRITE, oldaction,
6242+ sizeof(struct abi_sigaction));
6243+ if (error)
6244+ return error;
6245+ }
6246+
6247+ if (action) {
6248+ error = copy_from_user(&new_sa, action,
6249+ sizeof(struct abi_sigaction));
6250+ if (error)
6251+ return -EFAULT;
6252+ nsa.sa_restorer = NULL;
6253+ nsa.sa_handler = new_sa.sa_handler;
6254+ nsa.sa_mask = map_sigvec_to_kernel(new_sa.sa_mask,
6255+ current->exec_domain->signal_map);
6256+ if(new_sa.sa_flags & ABI_SA_ONSTACK)
6257+ nsa.sa_flags |= SA_ONSTACK;
6258+ if(new_sa.sa_flags & ABI_SA_RESTART)
6259+ nsa.sa_flags |= SA_RESTART;
6260+ if(new_sa.sa_flags & ABI_SA_NODEFER)
6261+ nsa.sa_flags |= SA_NODEFER;
6262+ if(new_sa.sa_flags & ABI_SA_RESETHAND)
6263+ nsa.sa_flags |= SA_RESETHAND;
6264+ if(new_sa.sa_flags & ABI_SA_NOCLDSTOP)
6265+ nsa.sa_flags |= SA_NOCLDSTOP;
6266+ if(new_sa.sa_flags & ABI_SA_NOCLDWAIT)
6267+ nsa.sa_flags |= SA_NOCLDWAIT;
6268+ }
6269+
6270+ old_fs = get_fs();
6271+ set_fs(get_ds());
6272+ error = SYS(rt_sigaction)(signo,
6273+ action ? &nsa : NULL,
6274+ oldaction ? &osa : NULL,
6275+ sizeof(sigset_t));
6276+ set_fs(old_fs);
6277+
6278+ if (!error && oldaction) {
6279+ old_sa.sa_handler = osa.sa_handler;
6280+ old_sa.sa_mask = map_sigvec_from_kernel(osa.sa_mask,
6281+ current->exec_domain->signal_invmap);
6282+ old_sa.sa_flags = 0;
6283+ if(osa.sa_flags & SA_ONSTACK)
6284+ old_sa.sa_flags |= ABI_SA_ONSTACK;
6285+ if(osa.sa_flags & SA_RESTART)
6286+ old_sa.sa_flags |= ABI_SA_RESTART;
6287+ if(osa.sa_flags & SA_NODEFER)
6288+ old_sa.sa_flags |= ABI_SA_NODEFER;
6289+ if(osa.sa_flags & SA_RESETHAND)
6290+ old_sa.sa_flags |= ABI_SA_RESETHAND;
6291+ if(osa.sa_flags & SA_NOCLDSTOP)
6292+ old_sa.sa_flags |= ABI_SA_NOCLDSTOP;
6293+ if(osa.sa_flags & SA_NOCLDWAIT)
6294+ old_sa.sa_flags |= ABI_SA_NOCLDWAIT;
6295+ /* This should never fail... */
6296+ copy_to_user(oldaction, &old_sa, sizeof(struct abi_sigaction));
6297+ }
6298+ return error;
6299+}
6300+
6301+EXPORT_SYMBOL(abi_sigaction);
6302+
6303+
6304+static short int howcnv[] = {SIG_SETMASK, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK};
6305+
6306+asmlinkage int
6307+abi_sigprocmask(int how, unsigned long *abinset, unsigned long *abioset)
6308+{
6309+ sigset_t new_set, *nset, old_set, *oset;
6310+ unsigned long new_set_abi, old_set_abi;
6311+ mm_segment_t old_fs;
6312+ int error;
6313+
6314+ nset = oset = NULL;
6315+
6316+ if (abinset) {
6317+ get_user(new_set_abi, abinset);
6318+ new_set = map_sigvec_to_kernel(new_set_abi,
6319+ current->exec_domain->signal_map);
6320+ nset = &new_set;
6321+ }
6322+ if (abioset)
6323+ oset = &old_set;
6324+
6325+ old_fs = get_fs();
6326+ set_fs(get_ds());
6327+ error = SYS(rt_sigprocmask)(howcnv[how], nset, oset, sizeof(sigset_t));
6328+ set_fs(old_fs);
6329+
6330+ if (!error && abioset) {
6331+ old_set_abi = map_sigvec_from_kernel(old_set,
6332+ current->exec_domain->signal_invmap);
6333+ put_user(old_set_abi, abioset);
6334+ }
6335+
6336+ return error;
6337+}
6338+
6339+
6340+EXPORT_SYMBOL(abi_sigprocmask);
6341+
6342+#ifndef __sparc__
6343+int abi_sigsuspend(struct pt_regs * regs)
6344+{
6345+ unsigned long * set;
6346+ unsigned long oldset;
6347+ old_sigset_t newset;
6348+ int error;
6349+
6350+ if (personality(PER_BSD)) {
6351+ oldset = get_syscall_parameter (regs, 0);
6352+ } else
6353+ {
6354+ set = (unsigned long *)get_syscall_parameter (regs, 0);
6355+ error = get_user(oldset, set);
6356+ if (error)
6357+ return error;
6358+ }
6359+ newset = map_bitvec(oldset,
6360+ current->exec_domain->signal_map);
6361+
6362+ abi_trace(ABI_TRACE_SIGNAL,
6363+ "sigsuspend oldset, newset = %lx %lx", oldset, newset);
6364+ {
6365+#if 0
6366+ extern do_sigpause(unsigned int, struct pt_regs *);
6367+ return do_sigpause(newset, regs);
6368+#endif
6369+ }
6370+ return SYS(sigsuspend)(0, oldset,
6371+ newset, regs->esi, regs->edi,
6372+ regs->ebp, regs->eax,
6373+ regs->xds, regs->xes,
6374+ regs->orig_eax,
6375+ regs->eip, regs->xcs, regs->eflags,
6376+ regs->esp, regs->xss);
6377+}
6378+
6379+EXPORT_SYMBOL(abi_sigsuspend);
6380+#endif /* __sparc__ */
6381diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/common/socket.c linux/abi/common/socket.c
6382--- linux-2.4.3/abi/common/socket.c Thu Jan 1 01:00:00 1970
6383+++ linux/abi/common/socket.c Mon Mar 12 16:34:48 2001
6384@@ -0,0 +1,263 @@
6385+/* $Id$
6386+ *
6387+ * socket.c - generic emulated socket code
6388+ *
6389+ * Copyright (C) 1994, 1996 Mike Jagdis (jaggy@purplet.demon.co.uk)
6390+ *
6391+ */
6392+
6393+#include <linux/config.h>
6394+#include <linux/module.h>
6395+
6396+#include <asm/uaccess.h>
6397+
6398+#include <linux/types.h>
6399+#include <linux/fs.h>
6400+#include <linux/mm.h>
6401+#include <linux/ptrace.h>
6402+#include <linux/net.h>
6403+#include <linux/socket.h>
6404+#include <linux/sys.h>
6405+
6406+#include <abi/abi.h>
6407+#include <abi/socket.h>
6408+#include <abi/map.h>
6409+#include <abi/trace.h>
6410+
6411+
6412+int
6413+abi_do_setsockopt(unsigned long *sp)
6414+{
6415+ int error;
6416+ int level, optname;
6417+
6418+ error = verify_area(VERIFY_READ,
6419+ ((unsigned long *)sp),
6420+ 5*sizeof(long));
6421+ if (error)
6422+ return error;
6423+
6424+ get_user(level, ((unsigned long *)sp)+1);
6425+ get_user(optname, ((unsigned long *)sp)+2);
6426+
6427+ if (abi_traced(ABI_TRACE_STREAMS|ABI_TRACE_SOCKSYS)) {
6428+ u_long optval, optlen;
6429+
6430+ get_user(optval, ((u_long *)sp) + 3);
6431+ get_user(optlen, ((u_long *)sp) + 4);
6432+ __abi_trace("setsockopt level=%d, optname=%d, "
6433+ "optval=0x%08lx, optlen=0x%08lx\n",
6434+ level, optname, optval, optlen);
6435+ }
6436+
6437+ switch (level) {
6438+ case 0: /* IPPROTO_IP aka SOL_IP */
6439+ /* This is correct for the SCO family. Hopefully
6440+ * it is correct for other SYSV...
6441+ */
6442+ optname--;
6443+ if (optname == 0)
6444+ optname = 4;
6445+ if (optname > 4) {
6446+ optname += 24;
6447+ if (optname <= 33)
6448+ optname--;
6449+ if (optname < 32 || optname > 36)
6450+ return -EINVAL;
6451+ }
6452+ put_user(optname, ((unsigned long *)sp)+2);
6453+ break;
6454+
6455+ case 0xffff:
6456+ put_user(SOL_SOCKET, ((unsigned long *)sp)+1);
6457+ optname = map_value(current->exec_domain->sockopt_map, optname, 0);
6458+ put_user(optname, ((unsigned long *)sp)+2);
6459+
6460+ switch (optname) {
6461+ case SO_LINGER: {
6462+ unsigned long optlen;
6463+
6464+ /* SO_LINGER takes a struct linger
6465+ * as the argument but some code
6466+ * uses an int and expects to get
6467+ * away without an error. Sigh...
6468+ */
6469+ get_user(optlen, ((unsigned long *)sp)+4);
6470+ if (optlen == sizeof(int))
6471+ return 0;
6472+ break;
6473+ }
6474+
6475+ /* The following are not currently implemented
6476+ * under Linux so we must fake them in
6477+ * reasonable ways. (Only SO_PROTOTYPE is
6478+ * documented in SCO's man page).
6479+ */
6480+ case SO_PROTOTYPE:
6481+ case SO_ORDREL:
6482+ case SO_SNDTIMEO:
6483+ case SO_RCVTIMEO:
6484+ return -ENOPROTOOPT;
6485+
6486+ case SO_USELOOPBACK:
6487+ case SO_SNDLOWAT:
6488+ case SO_RCVLOWAT:
6489+ return 0;
6490+
6491+ /* The following are not currenty implemented
6492+ * under Linux and probably aren't settable
6493+ * anyway.
6494+ */
6495+ case SO_IMASOCKET:
6496+ return -ENOPROTOOPT;
6497+ }
6498+
6499+ default:
6500+ /* FIXME: We assume everything else uses the
6501+ * same level and option numbers. This is true
6502+ * for IPPROTO_TCP(/SOL_TCP) and TCP_NDELAY
6503+ * but is known to be incorrect for other
6504+ * potential options :-(.
6505+ */
6506+ break;
6507+ }
6508+
6509+ return SYS(socketcall)(SYS_SETSOCKOPT, sp);
6510+}
6511+
6512+EXPORT_SYMBOL(abi_do_setsockopt);
6513+
6514+int
6515+abi_do_getsockopt(unsigned long *sp)
6516+{
6517+ int error;
6518+ int level, optname;
6519+ char *optval;
6520+ long *optlen;
6521+
6522+ error = verify_area(VERIFY_READ,
6523+ ((unsigned long *)sp),
6524+ 5*sizeof(long));
6525+ if (error)
6526+ return error;
6527+
6528+ get_user((unsigned long) level, ((unsigned long *)sp)+1);
6529+ get_user((unsigned long) optname, ((unsigned long *)sp)+2);
6530+ get_user((unsigned long) optval, ((unsigned long *)sp)+3);
6531+ get_user((unsigned long) optlen, ((unsigned long *)sp)+4);
6532+
6533+ if (abi_traced(ABI_TRACE_STREAMS|ABI_TRACE_SOCKSYS)) {
6534+ long l;
6535+
6536+ get_user(l, optlen);
6537+ __abi_trace("getsockopt level=%d, optname=%d, optval=0x%08lx, "
6538+ "optlen=0x%08lx[%ld]\n", level, optname,
6539+ (u_long)optval, (u_long)optlen, l);
6540+ }
6541+
6542+ switch (level) {
6543+ case 0: /* IPPROTO_IP aka SOL_IP */
6544+ /* This is correct for the SCO family. Hopefully
6545+ * it is correct for other SYSV...
6546+ */
6547+ optname--;
6548+ if (optname == 0)
6549+ optname = 4;
6550+ if (optname > 4) {
6551+ optname += 24;
6552+ if (optname <= 33)
6553+ optname--;
6554+ if (optname < 32 || optname > 36)
6555+ return -EINVAL;
6556+ }
6557+ put_user(optname, ((unsigned long *)sp)+2);
6558+ break;
6559+
6560+ case 0xffff:
6561+ put_user(SOL_SOCKET, ((unsigned long *)sp)+1);
6562+ optname = map_value(current->exec_domain->sockopt_map, optname, 0);
6563+ put_user(optname, ((unsigned long *)sp)+2);
6564+
6565+ switch (optname) {
6566+ case SO_LINGER: {
6567+ long l;
6568+
6569+ /* SO_LINGER takes a struct linger
6570+ * as the argument but some code
6571+ * uses an int and expects to get
6572+ * away without an error. Sigh...
6573+ */
6574+ get_user(l, optlen);
6575+ if (l == sizeof(int)) {
6576+ put_user(0, (long *)optval);
6577+ return 0;
6578+ }
6579+ break;
6580+ }
6581+
6582+ /* The following are not currently implemented
6583+ * under Linux so we must fake them in
6584+ * reasonable ways. (Only SO_PROTOTYPE is
6585+ * documented in SCO's man page).
6586+ */
6587+ case SO_PROTOTYPE: {
6588+ unsigned long len;
6589+ error = get_user(len, optlen);
6590+ if (error)
6591+ return error;
6592+ if (len < sizeof(long))
6593+ return -EINVAL;
6594+
6595+ error = verify_area(VERIFY_WRITE,
6596+ (char *)optval,
6597+ sizeof(long));
6598+ if (!error) {
6599+ put_user(0, (long *)optval);
6600+ put_user(sizeof(long),
6601+ optlen);
6602+ }
6603+ return error;
6604+ }
6605+
6606+ case SO_ORDREL:
6607+ case SO_SNDTIMEO:
6608+ case SO_RCVTIMEO:
6609+ return -ENOPROTOOPT;
6610+
6611+ case SO_USELOOPBACK:
6612+ case SO_SNDLOWAT:
6613+ case SO_RCVLOWAT:
6614+ case SO_IMASOCKET: {
6615+ unsigned long len;
6616+ error = get_user(len, optlen);
6617+ if (error)
6618+ return error;
6619+ if (len < sizeof(long))
6620+ return -EINVAL;
6621+
6622+ error = verify_area(VERIFY_WRITE,
6623+ (char *)optval,
6624+ sizeof(long));
6625+ if (!error) {
6626+ put_user(1, (long *)optval);
6627+ put_user(sizeof(long),
6628+ optlen);
6629+ }
6630+ return error;
6631+ }
6632+ }
6633+
6634+ default:
6635+ /* FIXME: We assume everything else uses the
6636+ * same level and option numbers. This is true
6637+ * for IPPROTO_TCP(/SOL_TCP) and TCP_NDELAY
6638+ * but is known to be incorrect for other
6639+ * potential options :-(.
6640+ */
6641+ break;
6642+ }
6643+
6644+ return SYS(socketcall)(SYS_GETSOCKOPT, sp);
6645+}
6646+
6647+EXPORT_SYMBOL(abi_do_getsockopt);
6648diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/common/socksys.c linux/abi/common/socksys.c
6649--- linux-2.4.3/abi/common/socksys.c Thu Jan 1 01:00:00 1970
6650+++ linux/abi/common/socksys.c Sun Mar 18 18:45:12 2001
6651@@ -0,0 +1,1106 @@
6652+/* $Id$
6653+ * socksys.c - svr4 /dev/socksys emulation
6654+ *
6655+ * Copyright 1994-1996 Mike Jagdis (jaggy@purplet.demon.co.uk)
6656+ */
6657+
6658+#include <linux/config.h>
6659+#include <linux/module.h>
6660+
6661+#include <linux/types.h>
6662+#include <linux/errno.h>
6663+#include <linux/fs.h>
6664+#include <linux/fcntl.h>
6665+#include <linux/major.h>
6666+#include <linux/kernel.h>
6667+#include <linux/in.h>
6668+#include <linux/net.h>
6669+#include <linux/sched.h>
6670+#include <linux/signal.h>
6671+#include <linux/socket.h>
6672+#include <net/sock.h>
6673+#include <linux/slab.h>
6674+#include <linux/mm.h>
6675+#include <linux/un.h>
6676+#include <linux/utsname.h>
6677+#include <linux/time.h>
6678+#include <linux/termios.h>
6679+#include <linux/sys.h>
6680+#include <linux/file.h>
6681+#include <linux/poll.h>
6682+#include <linux/capability.h>
6683+#include <linux/init.h>
6684+
6685+
6686+#include <asm/uaccess.h>
6687+
6688+#include <abi/abi.h>
6689+#include <abi/map.h>
6690+#include <abi/trace.h>
6691+#include <abi/socksys.h>
6692+#include <abi/tli.h>
6693+
6694+
6695+static int socksys_read(struct file *filep,
6696+ char *buf, size_t count, loff_t *offset);
6697+static int socksys_write(struct file *filep,
6698+ const char *buf, size_t count, loff_t *offset);
6699+static int socksys_open(struct inode *ino, struct file *filep);
6700+static int socksys_close(struct inode *ino, struct file *filep);
6701+static unsigned int socksys_poll(struct file *filep, struct poll_table_struct *wait);
6702+
6703+
6704+/*
6705+ * socksys_fops defines the file operations that can be applied to the
6706+ * /dev/socksys device.
6707+ */
6708+static struct file_operations socksys_fops = {
6709+ owner: THIS_MODULE,
6710+ read: socksys_read,
6711+ write: socksys_write,
6712+ open: socksys_open,
6713+ release: socksys_close,
6714+};
6715+
6716+/* socksys_socket_fops defines the file operations that can be applied to
6717+ * sockets themselves. This gets initialised when the first socket is
6718+ * created.
6719+ */
6720+static struct file_operations socksys_socket_fops = {
6721+ NULL,
6722+};
6723+
6724+static int (*sock_close)(struct inode *inode, struct file *file);
6725+static unsigned int (*sock_poll)(struct file *filep, struct poll_table_struct *wait);
6726+
6727+
6728+void
6729+inherit_socksys_funcs(unsigned int fd, int state)
6730+{
6731+#ifdef CONFIG_ABI_XTI
6732+ struct T_private *priv;
6733+#endif
6734+ struct inode *ino;
6735+ struct file *filep = fget(fd);
6736+ if (!filep)
6737+ return;
6738+
6739+ ino = filep->f_dentry->d_inode;
6740+
6741+#ifdef SO_BSDCOMPAT
6742+ /* SYSV sockets are BSD like with respect to ICMP errors
6743+ * with UDP rather than RFC conforming. I think.
6744+ */
6745+ ino->u.socket_i.sk->bsdism = 1;
6746+#endif
6747+
6748+#ifdef CONFIG_ABI_XTI
6749+ priv = (struct T_private *)kmalloc(sizeof(struct T_private), GFP_KERNEL);
6750+ if (priv) {
6751+ priv->magic = XTI_MAGIC;
6752+ priv->state = state;
6753+ priv->offset = 0;
6754+ priv->pfirst = priv->plast = NULL;
6755+ }
6756+ filep->private_data = priv;
6757+#endif
6758+
6759+ /* If our file operations don't appear to match
6760+ * what the socket system is advertising it may
6761+ * be because we haven't initialised ours at all
6762+ * yet or it may be because the old socket system
6763+ * module was unloaded and reloaded. This isn't
6764+ * entirely safe because we may still have open
6765+ * sockets which *should* use the old routines
6766+ * until they close - tough, for now.
6767+ */
6768+ if (socksys_socket_fops.read != filep->f_op->read) {
6769+ memcpy(&socksys_socket_fops,
6770+ filep->f_op,
6771+ sizeof(struct file_operations));
6772+ sock_close = socksys_socket_fops.release;
6773+ sock_poll = socksys_socket_fops.poll;
6774+ socksys_socket_fops.release = socksys_close;
6775+ socksys_socket_fops.poll = socksys_poll;
6776+ }
6777+ filep->f_op = &socksys_socket_fops;
6778+#if 1
6779+ ino->i_mode = 0020000; /* S_IFCHR */
6780+ ino->i_rdev = MKDEV(SOCKSYS_MAJOR, 0);
6781+#endif
6782+ fput(filep);
6783+ // MOD_INC_USE_COUNT;
6784+}
6785+
6786+EXPORT_SYMBOL(inherit_socksys_funcs);
6787+
6788+static int
6789+spx_connect(unsigned int fd, int spxnum)
6790+{
6791+ int newfd, err, args[3];
6792+ struct sockaddr_un addr = {
6793+ AF_UNIX, "/tmp/.X11-unix/X0"
6794+ };
6795+ mm_segment_t old_fs = get_fs();
6796+
6797+ abi_trace(ABI_TRACE_SOCKSYS,
6798+ "SPX: %u choose service %d", fd, spxnum);
6799+
6800+ /* Rather than use an explicit path to the X :0 server
6801+ * socket we should use the given number to look up a path
6802+ * name to use (we can't rely on servers registering their
6803+ * sockets either - for one thing we don't emulate that yet
6804+ * and for another thing different OS binaries do things in
6805+ * different ways but all must interoperate).
6806+ * I suggest putting the mapping in, say, /dev/spx.map/%d
6807+ * where each file is a symlink containing the path of the
6808+ * socket to use. Then we can just do a readlink() here to
6809+ * get the pathname.
6810+ * Hey, this is what we do here now!
6811+ */
6812+ addr.sun_family = AF_UNIX;
6813+ sprintf(addr.sun_path, "/dev/spx.map/%u", spxnum);
6814+ set_fs(get_ds());
6815+ err = SYS(readlink)(addr.sun_path, addr.sun_path,
6816+ sizeof(addr.sun_path)-1);
6817+ set_fs(old_fs);
6818+ if (err == -ENOENT) {
6819+
6820+ abi_trace(ABI_TRACE_SOCKSYS,
6821+ "SPX: %u no symlink \"%s\", try X :0",
6822+ fd, addr.sun_path);
6823+ strcpy(addr.sun_path, "/tmp/.X11-unix/X0");
6824+ } else {
6825+ if (err < 0)
6826+ return err;
6827+ addr.sun_path[err] = '\0';
6828+ }
6829+
6830+ abi_trace(ABI_TRACE_SOCKSYS, "SPX: %u get a Unix domain socket", fd);
6831+
6832+ args[0] = AF_UNIX;
6833+ args[1] = SOCK_STREAM;
6834+ args[2] = 0;
6835+ set_fs(get_ds());
6836+ newfd = SYS(socketcall)(SYS_SOCKET, args);
6837+ set_fs(old_fs);
6838+ if (newfd < 0)
6839+ return newfd;
6840+
6841+ abi_trace(ABI_TRACE_SOCKSYS, "SPX: %u connect to \"%s\"",
6842+ fd, addr.sun_path);
6843+
6844+ args[0] = newfd;
6845+ args[1] = (int)&addr;
6846+ args[2] = sizeof(struct sockaddr_un);
6847+ set_fs(get_ds());
6848+ err = SYS(socketcall)(SYS_CONNECT, args);
6849+ set_fs(old_fs);
6850+ if (err) {
6851+ SYS(close)(newfd);
6852+ return err;
6853+ }
6854+ return newfd;
6855+}
6856+
6857+
6858+int
6859+abi_socksys_fd_init(int fd, int rw, const char *buf, int *count)
6860+{
6861+ struct file *filep;
6862+ struct inode *ino;
6863+ int error, sockfd;
6864+
6865+ /* FIXME: we are always holding the filep when we get here
6866+ * anyway so we could just use fcheck here...
6867+ */
6868+ filep = fget(fd);
6869+ if (!filep)
6870+ return -EBADF;
6871+ ino = filep->f_dentry->d_inode;
6872+
6873+ abi_trace(ABI_TRACE_SOCKSYS, "socksys: fd=%d initializing", fd);
6874+
6875+ /* Minor = 0 is the socksys device itself. No special handling
6876+ * will be needed as it is controlled by the application
6877+ * via ioctls.
6878+ */
6879+ if (MINOR(ino->i_rdev) == 0) {
6880+ fput(filep);
6881+ return 0;
6882+ }
6883+
6884+ /* Minor = 1 is the spx device. This is the client side of a
6885+ * streams pipe to the X server. Under SCO and friends
6886+ * the library code messes around setting the connection
6887+ * up itself. We do it ourselves - this means we don't
6888+ * need to worry about the implementation of the server
6889+ * side (/dev/X0R - which must exist but can be a link
6890+ * to /dev/null) nor do we need to actually implement
6891+ * getmsg/putmsg.
6892+ */
6893+ if (MINOR(ino->i_rdev) == 1) {
6894+ int unit = 1;
6895+
6896+ fput(filep);
6897+
6898+ /* It seems early spx implementations were just a
6899+ * quick hack to get X to work. They only supported
6900+ * one destination and connected automatically.
6901+ * Later versions take a single byte write, the
6902+ * value of the byte telling them which destination
6903+ * to connect to. Hence this quick hack to work
6904+ * with both. If the first write is a single byte
6905+ * it's a connect request otherwise we auto-connect
6906+ * to destination 1.
6907+ */
6908+ if (rw == 1 && *count == 1) {
6909+ error = get_user(unit, buf);
6910+ if (error)
6911+ return error;
6912+ (*count)--;
6913+ }
6914+
6915+ sockfd = spx_connect(fd, unit);
6916+ if (sockfd < 0)
6917+ return sockfd;
6918+ }
6919+
6920+ /*
6921+ * Otherwise the high 4 bits specify the address/protocol
6922+ * family (AF_INET, AF_UNIX etc.) and the low 4 bits determine
6923+ * the protocol (IPPROTO_IP, IPPROTO_UDP, IPPROTO_TCP etc.)
6924+ * although not using a one-to-one mapping as the minor number
6925+ * is not big enough to hold everything directly. The socket
6926+ * type is inferrred from the protocol.
6927+ */
6928+ else { /* XTI */
6929+ int args[3];
6930+ mm_segment_t old_fs = get_fs();
6931+
6932+ /* Grab a socket. */
6933+
6934+ abi_trace(ABI_TRACE_SOCKSYS,
6935+ "XTI: %d get socket for transport end"
6936+ " point (dev = 0x%04x)",
6937+ fd, ino->i_rdev);
6938+
6939+ switch ((args[0] = ((MINOR(ino->i_rdev) >> 4) & 0x0f))) {
6940+ case AF_UNIX:
6941+ args[1] = SOCK_STREAM;
6942+ args[2] = 0;
6943+ break;
6944+
6945+ case AF_INET: {
6946+ int prot[16] = {
6947+ IPPROTO_ICMP, IPPROTO_ICMP,
6948+ IPPROTO_IGMP, IPPROTO_IPIP,
6949+ IPPROTO_TCP, IPPROTO_EGP,
6950+ IPPROTO_PUP, IPPROTO_UDP,
6951+ IPPROTO_IDP, IPPROTO_RAW,
6952+ };
6953+ int type[16] = {
6954+ SOCK_RAW, SOCK_RAW,
6955+ SOCK_RAW, SOCK_RAW,
6956+ SOCK_STREAM, SOCK_RAW,
6957+ SOCK_RAW, SOCK_DGRAM,
6958+ SOCK_RAW, SOCK_RAW,
6959+ };
6960+ int i = MINOR(ino->i_rdev) & 0x0f;
6961+ args[2] = prot[i];
6962+ args[1] = type[i];
6963+ break;
6964+ }
6965+
6966+ default:
6967+ args[1] = SOCK_RAW;
6968+ args[2] = 0;
6969+ break;
6970+ }
6971+ fput(filep);
6972+
6973+ abi_trace(ABI_TRACE_SOCKSYS,
6974+ "XTI: %d socket %d %d %d",
6975+ fd, args[0], args[1], args[2]);
6976+
6977+ set_fs(get_ds());
6978+ sockfd = SYS(socketcall)(SYS_SOCKET, args);
6979+ set_fs(old_fs);
6980+ if (sockfd < 0)
6981+ return sockfd;
6982+ }
6983+
6984+ /* Redirect operations on the socket fd via our emulation
6985+ * handlers then swap the socket fd and the original fd,
6986+ * discarding the original fd.
6987+ */
6988+ inherit_socksys_funcs(sockfd, TS_UNBND);
6989+
6990+ abi_trace(ABI_TRACE_SOCKSYS, "XTI: %d -> %d", fd, sockfd);
6991+
6992+ SYS(dup2)(sockfd, fd);
6993+ SYS(close)(sockfd);
6994+ return 1;
6995+}
6996+EXPORT_SYMBOL(abi_socksys_fd_init);
6997+
6998+
6999+static int
7000+socksys_read(struct file *filep, char *buf, size_t count, loff_t *offset)
7001+{
7002+ struct inode *ino = filep->f_dentry->d_inode;
7003+
7004+ /* FIXME: this condition *must* be true - if we have already
7005+ * replaced this with a socket we have changed the file ops
7006+ * too surely?
7007+ */
7008+ if (ino && !ino->i_sock) {
7009+ int fd;
7010+ for (fd = 0; fd < current->files->max_fdset; fd++) {
7011+ if (fcheck(fd) == filep) {
7012+ int error;
7013+ error = abi_socksys_fd_init(fd, 0, NULL, NULL);
7014+ if (error > 0) {
7015+ fput(filep);
7016+ filep = fget(fd);
7017+ return filep->f_op->read(filep, buf,
7018+ count, offset);
7019+ } else
7020+ return error ? error : -EINVAL;
7021+ }
7022+ }
7023+ }
7024+ return -EINVAL;
7025+}
7026+
7027+
7028+static int
7029+socksys_write(struct file *filep, const char *buf, size_t count, loff_t *offset)
7030+{
7031+ struct inode *ino = filep->f_dentry->d_inode;
7032+
7033+ /* FIXME: this condition *must* be true - if we have already
7034+ * replaced this with a socket we have changed the file ops
7035+ * too surely?
7036+ */
7037+ if (ino && !ino->i_sock) {
7038+ int fd;
7039+ for (fd = 0; fd < current->files->max_fdset; fd++) {
7040+ if (fcheck(fd) == filep) {
7041+ int error;
7042+ error = abi_socksys_fd_init(fd, 1, buf, &count);
7043+ if (error > 0) {
7044+ fput(filep);
7045+ filep = fget(fd);
7046+ return count
7047+ ? filep->f_op->write(filep, buf,
7048+ count, offset)
7049+ : 0;
7050+ } else
7051+ return error ? error : -EINVAL;
7052+ }
7053+ }
7054+ }
7055+ return -EINVAL;
7056+}
7057+
7058+
7059+int
7060+socksys_syscall(int *sp)
7061+{
7062+ int error, cmd;
7063+
7064+ error = get_user(cmd, sp);
7065+ if (error)
7066+ return error;
7067+ sp++;
7068+
7069+ if (abi_traced(ABI_TRACE_SOCKSYS)) {
7070+ u_long a0, a1, a2, a3, a4, a5;
7071+ static const char * const cmd_map[] = {
7072+ "", "accept", "bind", "connect", "getpeername",
7073+ "getsockname", "getsockopt", "listen", "recv",
7074+ "recvfrom", "send", "sendto", "setsockopt", "shutdown",
7075+ "socket", "select", "getipdomain", "setipdomain",
7076+ "adjtime", "setreuid", "setregid", "gettimeofday",
7077+ "settimeofday", "getitimer", "setitimer",
7078+ "recvmsg", "sendmsg", "sockpair"
7079+ };
7080+
7081+ get_user(a0, sp+0);
7082+ get_user(a1, sp+1);
7083+ get_user(a2, sp+2);
7084+ get_user(a3, sp+3);
7085+ get_user(a4, sp+4);
7086+ get_user(a5, sp+5);
7087+
7088+ __abi_trace("socksys: %s (%d) "
7089+ "<0x%lx,0x%lx,0x%lx,0x%lx,0x%lx,0x%lx>",
7090+ (cmd >= 0 &&
7091+ cmd < sizeof(cmd_map) / sizeof(cmd_map[0]))
7092+ ? cmd_map[cmd] : "???", cmd,
7093+ a0, a1, a2, a3, a4, a5);
7094+ }
7095+
7096+ switch (cmd) {
7097+ case SSYS_SO_SOCKET: {
7098+ /* Get a socket but replace the socket file
7099+ * operations with our own so we can do the
7100+ * right thing for ioctls.
7101+ */
7102+ int fd;
7103+ unsigned long x;
7104+
7105+ get_user(x, ((unsigned long *)sp)+0);
7106+ put_user(map_value(current->exec_domain->af_map, x, 0),
7107+ ((unsigned long *)sp)+0);
7108+ get_user(x, ((unsigned long *)sp)+1);
7109+ put_user(map_value(current->exec_domain->socktype_map, x, 0),
7110+ ((unsigned long *)sp)+1);
7111+
7112+ if ((fd = SYS(socketcall)(SYS_SOCKET, sp)) < 0)
7113+ return fd;
7114+
7115+ inherit_socksys_funcs(fd, TS_UNBND);
7116+ return fd;
7117+ }
7118+
7119+ case SSYS_SO_ACCEPT: {
7120+ int fd;
7121+
7122+ if ((fd = SYS(socketcall)(SYS_ACCEPT, sp)) < 0)
7123+ return fd;
7124+
7125+ inherit_socksys_funcs(fd, TS_DATA_XFER);
7126+ return fd;
7127+ }
7128+ case SSYS_SO_BIND:
7129+ return SYS(socketcall)(SYS_BIND, sp);
7130+ case SSYS_SO_CONNECT:
7131+ return SYS(socketcall)(SYS_CONNECT, sp);
7132+ case SSYS_SO_GETPEERNAME:
7133+ return SYS(socketcall)(SYS_GETPEERNAME, sp);
7134+ case SSYS_SO_GETSOCKNAME:
7135+ return SYS(socketcall)(SYS_GETSOCKNAME, sp);
7136+ case SSYS_SO_GETSOCKOPT:
7137+ return abi_do_getsockopt((unsigned long *)sp);
7138+ case SSYS_SO_LISTEN:
7139+ return SYS(socketcall)(SYS_LISTEN, sp);
7140+ case SSYS_SO_RECV: {
7141+ int err = SYS(socketcall)(SYS_RECV, sp);
7142+ if (err == -EAGAIN) err = -EWOULDBLOCK;
7143+ return err;
7144+ }
7145+ case SSYS_SO_RECVFROM: {
7146+ int err = SYS(socketcall)(SYS_RECVFROM, sp);
7147+ if (err == -EAGAIN) err = -EWOULDBLOCK;
7148+ return err;
7149+ }
7150+ case SSYS_SO_SEND: {
7151+ int err = SYS(socketcall)(SYS_SEND, sp);
7152+ if (err == -EAGAIN) err = -EWOULDBLOCK;
7153+ return err;
7154+ }
7155+ case SSYS_SO_SENDTO: {
7156+ int err = SYS(socketcall)(SYS_SENDTO, sp);
7157+ if (err == -EAGAIN) err = -EWOULDBLOCK;
7158+ return err;
7159+ }
7160+ case SSYS_SO_SETSOCKOPT:
7161+ return abi_do_setsockopt((unsigned long *)sp);
7162+ case SSYS_SO_SHUTDOWN:
7163+ return SYS(socketcall)(SYS_SHUTDOWN, sp);
7164+
7165+ case SSYS_SO_GETIPDOMAIN: {
7166+ int error, len;
7167+ char *name, *p;
7168+
7169+ error = get_user((unsigned long) name, (char *)(sp+0));
7170+ if (!error)
7171+ get_user(len, sp+1);
7172+ if (!error) {
7173+ down_read(&uts_sem);
7174+ error = verify_area(VERIFY_WRITE, name, len);
7175+ if (!error) {
7176+ --len;
7177+ for (p=system_utsname.nodename; *p && *p != '.'; p++);
7178+ if (*p == '.')
7179+ p++;
7180+ else
7181+ p = system_utsname.domainname;
7182+ if (strcmp(p, "(none)"))
7183+ for (;*p && len > 0; p++,len--) {
7184+ __put_user(*p, name);
7185+ name++;
7186+ }
7187+ __put_user('\0', name);
7188+ }
7189+ up_read(&uts_sem);
7190+ }
7191+ return error;
7192+ }
7193+ case SSYS_SO_SETIPDOMAIN: {
7194+ int error, len, togo;
7195+ char *name, *p;
7196+
7197+ if (!capable(CAP_SYS_ADMIN))
7198+ return -EPERM;
7199+
7200+ error = get_user((unsigned long) name, (char *)(sp+0));
7201+ if (!error)
7202+ error = get_user(len, sp+1);
7203+ if (error)
7204+ return error;
7205+
7206+ down_write(&uts_sem);
7207+ togo = __NEW_UTS_LEN;
7208+ for (p=system_utsname.nodename; *p && *p != '.'; p++,togo--);
7209+ if (*p == '.')
7210+ p++,togo--;
7211+
7212+ error = -EINVAL;
7213+ if (len <= togo) {
7214+ while (len-- > 0) {
7215+ get_user(*p, name);
7216+ p++;
7217+ name++;
7218+ }
7219+ *p = '\0';
7220+ error = 0;
7221+ }
7222+ up_write(&uts_sem);
7223+ return error;
7224+ }
7225+
7226+ case SSYS_SO_SETREUID:
7227+ case SSYS_SO_SETREGID: {
7228+ int error;
7229+ uid_t ruid, euid;
7230+
7231+ error = get_user(ruid, sp+0);
7232+ if (!error)
7233+ error = get_user(euid, sp+1);
7234+ if (error)
7235+ return error;
7236+ return (cmd == SSYS_SO_SETREUID)
7237+ ? SYS(setreuid)(ruid, euid)
7238+ : SYS(setregid)(ruid, euid);
7239+ }
7240+
7241+ case SSYS_SO_GETTIME:
7242+ case SSYS_SO_SETTIME: {
7243+ int error;
7244+ struct timeval *tv;
7245+ struct timezone *tz;
7246+
7247+ error = get_user((unsigned long) tv, sp+0);
7248+ if (!error)
7249+ error = get_user((unsigned long) tz, sp+1);
7250+ if (error)
7251+ return error;
7252+ return (cmd == SSYS_SO_GETTIME)
7253+ ? SYS(gettimeofday)(tv, tz)
7254+ : SYS(settimeofday)(tv, tz);
7255+ }
7256+
7257+ case SSYS_SO_GETITIMER: {
7258+ int error, which;
7259+ struct itimerval *value;
7260+
7261+ error = get_user((unsigned long) which, sp+0);
7262+ if (!error)
7263+ error = get_user((unsigned long) value, sp+1);
7264+ if (error)
7265+ return error;
7266+ return SYS(getitimer)(which, value);
7267+ }
7268+ case SSYS_SO_SETITIMER: {
7269+ int error, which;
7270+ struct itimerval *value, *ovalue;
7271+
7272+ error = get_user((unsigned long) which, sp+0);
7273+ if (!error)
7274+ error = get_user((unsigned long) value, sp+1);
7275+ if (!error)
7276+ error = get_user((unsigned long) ovalue, sp+2);
7277+ if (error)
7278+ return error;
7279+ return SYS(setitimer)(which, value, ovalue);
7280+ }
7281+
7282+ case SSYS_SO_SELECT:
7283+ /* This may be wrong? I don't know how to trigger
7284+ * this case. Select seems to go via the Xenix
7285+ * select entry point.
7286+ */
7287+ return SYS(select)(sp);
7288+
7289+ case SSYS_SO_ADJTIME:
7290+ return -EINVAL;
7291+
7292+ /* These appear in SCO 3.2v5. I assume that the format of
7293+ * a msghdr is identical with Linux. I have not checked.
7294+ */
7295+ case SSYS_SO_RECVMSG: {
7296+ int err = SYS(socketcall)(SYS_RECVMSG, sp);
7297+ if (err == -EAGAIN) err = -EWOULDBLOCK;
7298+ return err;
7299+ }
7300+ case SSYS_SO_SENDMSG: {
7301+ int err = SYS(socketcall)(SYS_SENDMSG, sp);
7302+ if (err == -EAGAIN) err = -EWOULDBLOCK;
7303+ return err;
7304+ }
7305+
7306+ case SSYS_SO_SOCKPAIR: {
7307+ /* Get a socketpair but replace the socket file
7308+ * operations with our own so we can do the
7309+ * right thing for ioctls.
7310+ */
7311+ struct file *filep;
7312+ struct inode *ino;
7313+ int error, args[4], pairin[2], pairout[2];
7314+ mm_segment_t old_fs = get_fs();
7315+
7316+ /* The first two arguments are file descriptors
7317+ * of sockets which have already been opened
7318+ * and should now be connected back to back.
7319+ */
7320+ error = get_user(pairin[0], sp+0);
7321+ if (!error)
7322+ error = get_user(pairin[1], sp+1);
7323+ if (error)
7324+ return error;
7325+
7326+ filep = fget(pairin[0]);
7327+ if (!filep)
7328+ return -EBADF;
7329+ ino = filep->f_dentry->d_inode;
7330+ if (!ino || !ino->i_sock) {
7331+ fput(filep);
7332+ return -EBADF;
7333+ }
7334+
7335+ args[0] = AF_UNIX;
7336+ args[1] = ino->u.socket_i.type;
7337+ args[2] = 0;
7338+ args[3] = (int)pairout;
7339+
7340+ fput(filep);
7341+
7342+ /* FIXME: Do we need to close these here? If we
7343+ * fail to connect them should they be open?
7344+ */
7345+ SYS(close)(pairin[0]);
7346+ SYS(close)(pairin[1]);
7347+
7348+ set_fs(get_ds());
7349+ error = SYS(socketcall)(SYS_SOCKETPAIR, args);
7350+ set_fs(old_fs);
7351+ if (error < 0)
7352+ return error;
7353+
7354+ if (pairout[0] != pairin[0]) {
7355+ SYS(dup2)(pairout[0], pairin[0]);
7356+ SYS(close)(pairout[0]);
7357+ }
7358+ if (pairout[1] != pairin[1]) {
7359+ SYS(dup2)(pairout[1], pairin[1]);
7360+ SYS(close)(pairout[1]);
7361+ }
7362+
7363+ inherit_socksys_funcs(pairin[0], TS_DATA_XFER);
7364+ inherit_socksys_funcs(pairin[1], TS_DATA_XFER);
7365+ return 0;
7366+ }
7367+ }
7368+
7369+ return -EINVAL;
7370+}
7371+
7372+
7373+EXPORT_SYMBOL(socksys_syscall);
7374+
7375+int
7376+abi_ioctl_socksys(int fd, unsigned int cmd, void *arg)
7377+{
7378+ int error;
7379+
7380+ switch (cmd) {
7381+ /* Strictly the ip domain and nis domain are separate and
7382+ * distinct under SCO but Linux only has the one domain.
7383+ */
7384+ case NIOCGETDOMNAM: {
7385+ struct domnam_args dn;
7386+ char *p;
7387+
7388+ error = copy_from_user(&dn, (char *)arg,
7389+ sizeof(struct domnam_args));
7390+ if (error)
7391+ return -EFAULT;
7392+
7393+ down_read(&uts_sem);
7394+ error = verify_area(VERIFY_WRITE, dn.name, dn.namelen);
7395+ if (!error) {
7396+ --dn.namelen;
7397+ for (p=system_utsname.domainname; *p && dn.namelen > 0; p++,dn.namelen--) {
7398+ __put_user(*p, dn.name);
7399+ dn.name++;
7400+ }
7401+ __put_user('\0', dn.name);
7402+ }
7403+ up_read(&uts_sem);
7404+ return error;
7405+ }
7406+ case NIOCSETDOMNAM: {
7407+ struct domnam_args dn;
7408+
7409+ error = copy_from_user(&dn, (char *)arg,
7410+ sizeof(struct domnam_args));
7411+ if (error)
7412+ return -EFAULT;
7413+
7414+ return SYS(setdomainname)(dn.name, dn.namelen);
7415+ }
7416+
7417+ case NIOCLSTAT: {
7418+ /* I think this was used before symlinks were added
7419+ * to the base SCO OS?
7420+ */
7421+ struct lstat_args st;
7422+
7423+ error = copy_from_user(&st, (char *)arg,
7424+ sizeof(struct lstat_args));
7425+ if (error)
7426+ return -EFAULT;
7427+
7428+ return abi_lstat(st.fname, st.statb);
7429+ }
7430+
7431+ case NIOCOLDGETFH:
7432+ case NIOCGETFH: {
7433+ struct getfh_args gf;
7434+ struct nameidata nd;
7435+
7436+ if (!capable(CAP_SYS_ADMIN))
7437+ return -EPERM;
7438+
7439+ error = copy_from_user(&gf, (char *)arg,
7440+ sizeof(struct getfh_args));
7441+ if (error)
7442+ return -EFAULT;
7443+
7444+ /* XXX: is this needed anymore? */
7445+ error = verify_area(VERIFY_WRITE, (char *)gf.fhp, sizeof(fhandle_t));
7446+ if (error)
7447+ return error;
7448+
7449+ error = user_path_walk(gf.fname, &nd);
7450+ if (error)
7451+ return error;
7452+
7453+ error = do_revalidate(nd.dentry);
7454+ if (!error) {
7455+ struct inode *ino = nd.dentry->d_inode;
7456+ __put_user(ino->i_dev, &gf.fhp->fh.fsid);
7457+ __put_user(ino->i_ino, &gf.fhp->fh.fno);
7458+ __put_user(0L, &gf.fhp->fh.fgen);
7459+ __put_user(ino->i_dev, &gf.fhp->fh.ex_fsid);
7460+ __put_user(ino->i_ino, &gf.fhp->fh.ex_fno);
7461+ __put_user(0L, &gf.fhp->fh.ex_fgen);
7462+ error = 0;
7463+ }
7464+ path_release(&nd);
7465+ return error;
7466+ }
7467+
7468+ case NIOCNFSD:
7469+ case NIOCASYNCD:
7470+ case NIOCCLNTHAND:
7471+ case NIOCEXPORTFS:
7472+ return -EINVAL;
7473+
7474+ case SSYS_SIOCSOCKSYS: /* Pseudo socket syscall */
7475+ case SVR4_SIOCSOCKSYS:
7476+ return socksys_syscall((int *)arg);
7477+
7478+ case SSYS_SIOCSHIWAT: /* set high watermark */
7479+ case SVR4_SIOCSHIWAT:
7480+ case SSYS_SIOCSLOWAT: /* set low watermark */
7481+ case SVR4_SIOCSLOWAT:
7482+ /* Linux doesn't support them but lie anyway
7483+ * or some things take it as fatal (why?)
7484+ * FIXME: actually we can do this now...
7485+ */
7486+ return 0;
7487+
7488+ case SSYS_SIOCGHIWAT: /* get high watermark */
7489+ case SVR4_SIOCGHIWAT:
7490+ case SSYS_SIOCGLOWAT: /* get low watermark */
7491+ case SVR4_SIOCGLOWAT:
7492+ /* Linux doesn't support them but lie anyway
7493+ * or some things take it as fatal (why?)
7494+ * FIXME: actually we can do this now...
7495+ */
7496+ if ((error = verify_area(VERIFY_WRITE, (char *)arg,
7497+ sizeof(unsigned long))))
7498+ return error;
7499+ put_user(0, (unsigned long *)arg);
7500+ return 0;
7501+
7502+ case SSYS_SIOCATMARK: /* at oob mark? */
7503+ case SVR4_SIOCATMARK:
7504+ return SYS(ioctl)(fd, SIOCATMARK, arg);
7505+
7506+ case SSYS_SIOCSPGRP: /* set process group */
7507+ case SVR4_SIOCSPGRP:
7508+ return SYS(ioctl)(fd, SIOCSPGRP, arg);
7509+ case SSYS_SIOCGPGRP: /* get process group */
7510+ case SVR4_SIOCGPGRP:
7511+ return SYS(ioctl)(fd, SIOCGPGRP, arg);
7512+
7513+ case FIONREAD:
7514+ case SSYS_FIONREAD: /* BSD compatibilty */
7515+ error = SYS(ioctl)(fd, TIOCINQ, arg);
7516+
7517+ if (!error && abi_traced(ABI_TRACE_SOCKSYS)) {
7518+ u_long n;
7519+
7520+ get_user(n, (u_long *)arg);
7521+ __abi_trace("socksys: %d FIONREAD "
7522+ "found %lu bytes ready",
7523+ fd, n);
7524+ }
7525+
7526+ return error;
7527+
7528+ case SSYS_FIONBIO: /* BSD compatibilty */
7529+ return SYS(ioctl)(fd, FIONBIO, arg);
7530+
7531+ case SSYS_FIOASYNC: /* BSD compatibilty */
7532+ return SYS(ioctl)(fd, FIOASYNC, arg);
7533+
7534+ case SSYS_SIOCADDRT: /* add route */
7535+ case SVR4_SIOCADDRT:
7536+ return SYS(ioctl)(fd, SIOCADDRT, arg);
7537+ case SSYS_SIOCDELRT: /* delete route */
7538+ case SVR4_SIOCDELRT:
7539+ return SYS(ioctl)(fd, SIOCDELRT, arg);
7540+
7541+ case SSYS_SIOCSIFADDR: /* set ifnet address */
7542+ case SVR4_SIOCSIFADDR:
7543+ return SYS(ioctl)(fd, SIOCSIFADDR, arg);
7544+ case SSYS_SIOCGIFADDR: /* get ifnet address */
7545+ case SVR4_SIOCGIFADDR:
7546+ return SYS(ioctl)(fd, SIOCGIFADDR, arg);
7547+
7548+ case SSYS_SIOCSIFDSTADDR: /* set p-p address */
7549+ case SVR4_SIOCSIFDSTADDR:
7550+ return SYS(ioctl)(fd, SIOCSIFDSTADDR, arg);
7551+ case SSYS_SIOCGIFDSTADDR: /* get p-p address */
7552+ case SVR4_SIOCGIFDSTADDR:
7553+ return SYS(ioctl)(fd, SIOCGIFDSTADDR, arg);
7554+
7555+ case SSYS_SIOCSIFFLAGS: /* set ifnet flags */
7556+ case SVR4_SIOCSIFFLAGS:
7557+ return SYS(ioctl)(fd, SIOCSIFFLAGS, arg);
7558+ case SSYS_SIOCGIFFLAGS: /* get ifnet flags */
7559+ case SVR4_SIOCGIFFLAGS:
7560+#if 0
7561+ case SVRX_SIOCGIFFLAGS:
7562+#endif
7563+ return SYS(ioctl)(fd, SIOCGIFFLAGS, arg);
7564+
7565+ case SSYS_SIOCGIFCONF: /* get ifnet list */
7566+ case SVR4_SIOCGIFCONF:
7567+#if 0
7568+ case SVRX_SIOCGIFCONF:
7569+#endif
7570+ return SYS(ioctl)(fd, SIOCGIFCONF, arg);
7571+
7572+ case SSYS_SIOCGIFBRDADDR: /* get broadcast addr */
7573+ case SVR4_SIOCGIFBRDADDR:
7574+ return SYS(ioctl)(fd, SIOCGIFBRDADDR, arg);
7575+ case SSYS_SIOCSIFBRDADDR: /* set broadcast addr */
7576+ case SVR4_SIOCSIFBRDADDR:
7577+ return SYS(ioctl)(fd, SIOCSIFBRDADDR, arg);
7578+
7579+ case SSYS_SIOCGIFNETMASK: /* get net addr mask */
7580+ case SVR4_SIOCGIFNETMASK:
7581+ return SYS(ioctl)(fd, SIOCGIFNETMASK, arg);
7582+ case SSYS_SIOCSIFNETMASK: /* set net addr mask */
7583+ return SYS(ioctl)(fd, SIOCSIFNETMASK, arg);
7584+
7585+ case SSYS_SIOCGIFMETRIC: /* get IF metric */
7586+ case SVR4_SIOCGIFMETRIC:
7587+ return SYS(ioctl)(fd, SIOCGIFMETRIC, arg);
7588+ case SSYS_SIOCSIFMETRIC: /* set IF metric */
7589+ case SVR4_SIOCSIFMETRIC:
7590+ return SYS(ioctl)(fd, SIOCSIFMETRIC, arg);
7591+
7592+ case SSYS_SIOCSARP: /* set arp entry */
7593+ case SVR4_SIOCSARP:
7594+ return SYS(ioctl)(fd, SIOCSARP, arg);
7595+ case SSYS_SIOCGARP: /* get arp entry */
7596+ case SVR4_SIOCGARP:
7597+ return SYS(ioctl)(fd, SIOCGARP, arg);
7598+ case SSYS_SIOCDARP: /* delete arp entry */
7599+ case SVR4_SIOCDARP:
7600+ return SYS(ioctl)(fd, SIOCDARP, arg);
7601+
7602+ case SSYS_SIOCGENADDR: /* Get ethernet addr */
7603+ case SVR4_SIOCGENADDR:
7604+ return SYS(ioctl)(fd, SIOCGIFHWADDR, arg);
7605+
7606+ case SSYS_SIOCSIFMTU: /* get if_mtu */
7607+ case SVR4_SIOCSIFMTU:
7608+ return SYS(ioctl)(fd, SIOCSIFMTU, arg);
7609+ case SSYS_SIOCGIFMTU: /* set if_mtu */
7610+ case SVR4_SIOCGIFMTU:
7611+ return SYS(ioctl)(fd, SIOCGIFMTU, arg);
7612+
7613+ case SSYS_SIOCGETNAME: /* getsockname */
7614+ case SVR4_SIOCGETNAME:
7615+ case SSYS_SIOCGETPEER: /* getpeername */
7616+ case SVR4_SIOCGETPEER:
7617+ {
7618+ struct sockaddr uaddr;
7619+ int uaddr_len = sizeof(struct sockaddr);
7620+ int op, args[3];
7621+ mm_segment_t old_fs;
7622+
7623+ if ((error = verify_area(VERIFY_WRITE, (char *)arg, sizeof(struct sockaddr))))
7624+ return error;
7625+ if (cmd == SSYS_SIOCGETNAME || cmd == SVR4_SIOCGETNAME)
7626+ op = SYS_GETSOCKNAME;
7627+ else
7628+ op = SYS_GETPEERNAME;
7629+ args[0] = fd;
7630+ args[1] = (int)&uaddr;
7631+ args[2] = (int)&uaddr_len;
7632+ old_fs = get_fs();
7633+ set_fs (get_ds());
7634+ error = SYS(socketcall)(op, args);
7635+ set_fs(old_fs);
7636+ if (error >= 0)
7637+ copy_to_user((char *)arg, &uaddr, uaddr_len);
7638+ return error;
7639+ }
7640+
7641+ case SSYS_IF_UNITSEL: /* set unit number */
7642+ case SVR4_IF_UNITSEL:
7643+ case SSYS_SIOCXPROTO: /* empty proto table */
7644+ case SVR4_SIOCXPROTO:
7645+
7646+ case SSYS_SIOCIFDETACH: /* detach interface */
7647+ case SVR4_SIOCIFDETACH:
7648+ case SSYS_SIOCGENPSTATS: /* get ENP stats */
7649+ case SVR4_SIOCGENPSTATS:
7650+
7651+ case SSYS_SIOCSIFNAME: /* set interface name */
7652+ case SVR4_SIOCSIFNAME:
7653+ case SSYS_SIOCGIFONEP: /* get one-packet params */
7654+ case SSYS_SIOCSIFONEP: /* set one-packet params */
7655+
7656+ case SSYS_SIOCPROTO: /* link proto */
7657+ case SVR4_SIOCPROTO:
7658+ case SSYS_SIOCX25XMT:
7659+ case SVR4_SIOCX25XMT:
7660+ case SSYS_SIOCX25RCV:
7661+ case SVR4_SIOCX25RCV:
7662+ case SSYS_SIOCX25TBL:
7663+ case SVR4_SIOCX25TBL:
7664+
7665+ default:
7666+ printk(KERN_DEBUG "%d iBCS: socksys: %d: ioctl 0x%x with argument 0x%lx requested\n",
7667+ current->pid, fd,
7668+ cmd, (unsigned long)arg);
7669+ break;
7670+ }
7671+
7672+ return -EINVAL;
7673+}
7674+
7675+EXPORT_SYMBOL(abi_ioctl_socksys);
7676+
7677+
7678+static int
7679+socksys_open(struct inode *ino, struct file *filep)
7680+{
7681+ abi_trace(ABI_TRACE_SOCKSYS,
7682+ "socksys: filep=0x%08lx, inode=0x%08lx opening",
7683+ (u_long)filep, (u_long)ino);
7684+ return 0;
7685+}
7686+
7687+
7688+static unsigned int
7689+socksys_poll(struct file *filep, struct poll_table_struct *wait)
7690+{
7691+ unsigned int mask = 0;
7692+
7693+#ifdef CONFIG_ABI_XTI
7694+ struct inode *ino = filep->f_dentry->d_inode;
7695+
7696+ /* If this is a timod transport end point and there
7697+ * is a control message queued we have readable data.
7698+ */
7699+ if (ino && ino->i_sock && MINOR(ino->i_rdev) != 1
7700+ && Priv(filep) && Priv(filep)->pfirst)
7701+ mask = Priv(filep)->pfirst->pri == MSG_HIPRI
7702+ ? POLLPRI
7703+ : POLLIN;
7704+#endif
7705+
7706+ if (sock_poll)
7707+ mask |= (*sock_poll)(filep, wait);
7708+ return mask;
7709+}
7710+
7711+
7712+static int
7713+socksys_close(struct inode *ino, struct file *filep)
7714+{
7715+ int error;
7716+
7717+ /* Not being a socket is not an error - it is probably
7718+ * just the pseudo device transport provider.
7719+ */
7720+ error = 0;
7721+ if (ino && ino->i_sock) {
7722+#ifdef CONFIG_ABI_XTI
7723+ if (filep->private_data) {
7724+ struct T_primsg *it;
7725+ it = ((struct T_private *)filep->private_data)->pfirst;
7726+ while (it) {
7727+ struct T_primsg *tmp = it;
7728+ it = it->next;
7729+ kfree(tmp);
7730+ }
7731+ kfree(filep->private_data);
7732+ }
7733+#endif
7734+ error = sock_close(ino, filep);
7735+ }
7736+
7737+ abi_trace(ABI_TRACE_SOCKSYS, "socksys: %lx closed", (u_long)filep);
7738+
7739+ return error;
7740+}
7741+
7742+static int __init init_abi(void)
7743+{
7744+ int ret;
7745+
7746+ if ((ret = register_chrdev(SOCKSYS_MAJOR, "socksys", &socksys_fops)))
7747+ printk(KERN_ERR "abi: unable register socksys char major\n");
7748+ return (ret);
7749+}
7750+
7751+static void __exit cleanup_abi(void)
7752+{
7753+ unregister_chrdev(SOCKSYS_MAJOR, "socksys");
7754+}
7755+
7756+module_init(init_abi);
7757+module_exit(cleanup_abi);
7758diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/common/stat.c linux/abi/common/stat.c
7759--- linux-2.4.3/abi/common/stat.c Thu Jan 1 01:00:00 1970
7760+++ linux/abi/common/stat.c Sun Mar 18 17:35:53 2001
7761@@ -0,0 +1,139 @@
7762+/* $Id$
7763+ * stat.c - iABI stat(2) emulation
7764+ *
7765+ * Copyright (C) 1991, 1992 Linus Torvalds
7766+ *
7767+ * Hacked by Eric Youngdale for iBCS.
7768+ * Added to by Drew Sullivan.
7769+ * Heavily rewritten by Christoph Hellwig for Linux 2.4.
7770+ */
7771+
7772+#include <linux/module.h>
7773+
7774+#include <linux/errno.h>
7775+#include <linux/stat.h>
7776+#include <linux/fs.h>
7777+#include <linux/sched.h>
7778+#include <linux/kernel.h>
7779+#include <linux/mm.h>
7780+#include <linux/file.h>
7781+
7782+#include <asm/uaccess.h>
7783+#include <abi/abi.h>
7784+
7785+
7786+#ifdef __sparc__
7787+static int cp_abi_stat(struct inode * inode, struct ibcs_stat * statbuf)
7788+{
7789+ struct ibcs_stat tmp;
7790+
7791+ memset ((void *) &tmp, 0, sizeof (tmp));
7792+ tmp.st_dev = inode->i_dev;
7793+ tmp.st_ino = inode->i_ino;
7794+ tmp.st_mode = inode->i_mode;
7795+ tmp.st_nlink = inode->i_nlink;
7796+ tmp.st_uid = inode->i_uid;
7797+ tmp.st_gid = inode->i_gid;
7798+ tmp.st_rdev = inode->i_rdev;
7799+ tmp.st_size = inode->i_size;
7800+ tmp.st_atime.tv_sec = inode->i_atime;
7801+ tmp.st_mtime.tv_sec = inode->i_mtime;
7802+ tmp.st_ctime.tv_sec = inode->i_ctime;
7803+ tmp.st_blksize = inode->i_blksize;
7804+ tmp.st_blocks = inode->i_blocks;
7805+ return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
7806+}
7807+
7808+#else /* if not sparc... */
7809+
7810+/*
7811+ * Believe it or not, the original stat structure is compatible with ibcs2.
7812+ * The xstat struct used by SVr4 is different than our new struct, but we will
7813+ * deal with that later
7814+ */
7815+static int cp_abi_stat(struct inode * inode, struct ibcs_stat * statbuf)
7816+{
7817+ struct ibcs_stat tmp;
7818+
7819+ /* Note that we have to fold a long inode number down to a short.
7820+ * This must match what happens in coff:ibcs_read() and
7821+ * open.c:svr4_getdents() since code that figures out cwd needs
7822+ * the inodes to match. Because it must match read() on a
7823+ * directory we have to avoid the situation where we end up
7824+ * with a zero inode value. A zero inode value in a read()
7825+ * on a directory indicates an empty directory slot.
7826+ */
7827+ if ((unsigned long)inode->i_ino & 0xffff)
7828+ tmp.st_ino = (unsigned long)inode->i_ino & 0xffff;
7829+ else
7830+ tmp.st_ino = 0xfffe;
7831+
7832+ tmp.st_dev = inode->i_dev;
7833+ tmp.st_mode = inode->i_mode;
7834+ tmp.st_nlink = inode->i_nlink;
7835+ tmp.st_uid = inode->i_uid;
7836+ tmp.st_gid = inode->i_gid;
7837+ tmp.st_rdev = inode->i_rdev;
7838+ tmp.st_size = inode->i_size;
7839+ tmp.st_atime = inode->i_atime;
7840+ tmp.st_mtime = inode->i_mtime;
7841+ tmp.st_ctime = inode->i_ctime;
7842+ return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
7843+}
7844+#endif /* not sparc */
7845+
7846+
7847+int abi_stat(char *filename, struct ibcs_stat *st)
7848+{
7849+ struct nameidata nd;
7850+ int error;
7851+
7852+ error = user_path_walk(filename, &nd);
7853+ if (!error) {
7854+ error = do_revalidate(nd.dentry);
7855+ if (!error)
7856+ error = cp_abi_stat(nd.dentry->d_inode, st);
7857+ path_release(&nd);
7858+ }
7859+ return error;
7860+}
7861+
7862+EXPORT_SYMBOL(abi_stat);
7863+
7864+
7865+int abi_lstat(char *filename, struct ibcs_stat *st)
7866+{
7867+ struct nameidata nd;
7868+ int error;
7869+
7870+ error = user_path_walk_link(filename, &nd);
7871+ if (!error) {
7872+ error = do_revalidate(nd.dentry);
7873+ if (!error)
7874+ error = cp_abi_stat(nd.dentry->d_inode, st);
7875+ path_release(&nd);
7876+ }
7877+ return error;
7878+}
7879+
7880+EXPORT_SYMBOL(abi_lstat);
7881+
7882+
7883+int abi_fstat(unsigned int fd, struct ibcs_stat *st)
7884+{
7885+ struct file * f;
7886+ int err = -EBADF;
7887+
7888+ f = fget(fd);
7889+ if (f) {
7890+ struct dentry * dentry = f->f_dentry;
7891+ err = do_revalidate(dentry);
7892+ if (!err)
7893+ err = cp_abi_stat(dentry->d_inode, st);
7894+ fput(f);
7895+ }
7896+
7897+ return err;
7898+}
7899+
7900+EXPORT_SYMBOL(abi_fstat);
7901diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/common/verb_errmap.inc linux/abi/common/verb_errmap.inc
7902--- linux-2.4.3/abi/common/verb_errmap.inc Thu Jan 1 01:00:00 1970
7903+++ linux/abi/common/verb_errmap.inc Mon Mar 12 16:34:48 2001
7904@@ -0,0 +1,129 @@
7905+
7906+#ifdef CONFIG_ABI_VERBOSE_ERRORS
7907+static char *errmsg[] = {
7908+ "No error",
7909+ "Operation not permitted",
7910+ "No such file or directory",
7911+ "No such process",
7912+ "Interrupted system call",
7913+ "I/O error",
7914+ "No such device or address",
7915+ "Arg list too long",
7916+ "Exec format error",
7917+ "Bad file number",
7918+ "No child processes",
7919+ "Try again",
7920+ "Out of memory",
7921+ "Permission denied",
7922+ "Bad address",
7923+ "Block device required",
7924+ "Device or resource busy",
7925+ "File exists",
7926+ "Cross-device link",
7927+ "No such device",
7928+ "Not a directory",
7929+ "Is a directory",
7930+ "Invalid argument",
7931+ "File table overflow",
7932+ "Too many open files",
7933+ "Not a typewriter",
7934+ "Text file busy",
7935+ "File too large",
7936+ "No space left on device",
7937+ "Illegal seek",
7938+ "Read-only file system",
7939+ "Too many links",
7940+ "Broken pipe",
7941+ "Math argument out of domain of func",
7942+ "Math result not representable",
7943+ "Resource deadlock would occur",
7944+ "File name too long",
7945+ "No record locks available",
7946+ "Function not implemented",
7947+ "Directory not empty",
7948+ "Too many symbolic links encountered",
7949+ "",
7950+ "No message of desired type",
7951+ "Identifier removed",
7952+ "Channel number out of range",
7953+ "Level 2 not synchronized",
7954+ "Level 3 halted",
7955+ "Level 3 reset",
7956+ "Link number out of range",
7957+ "Protocol driver not attached",
7958+ "No CSI structure available",
7959+ "Level 2 halted",
7960+ "Invalid exchange",
7961+ "Invalid request descriptor",
7962+ "Exchange full",
7963+ "No anode",
7964+ "Invalid request code",
7965+ "Invalid slot",
7966+ "File locking deadlock error",
7967+ "Bad font file format",
7968+ "Device not a stream",
7969+ "No data available",
7970+ "Timer expired",
7971+ "Out of streams resources",
7972+ "Machine is not on the network",
7973+ "Package not installed",
7974+ "Object is remote",
7975+ "Link has been severed",
7976+ "Advertise error",
7977+ "Srmount error",
7978+ "Communication error on send",
7979+ "Protocol error",
7980+ "Multihop attempted",
7981+ "RFS specific error",
7982+ "Not a data message",
7983+ "Value too large for defined data type",
7984+ "Name not unique on network",
7985+ "File descriptor in bad state",
7986+ "Remote address changed",
7987+ "Can not access a needed shared library",
7988+ "Accessing a corrupted shared library",
7989+ ".lib section in a.out corrupted",
7990+ "Attempting to link in too many shared libraries",
7991+ "Cannot exec a shared library directly",
7992+ "Illegal byte sequence",
7993+ "Interrupted system call should be restarted",
7994+ "Streams pipe error",
7995+ "Too many users",
7996+ "Socket operation on non-socket",
7997+ "Destination address required",
7998+ "Message too long",
7999+ "Protocol wrong type for socket",
8000+ "Protocol not available",
8001+ "Protocol not supported",
8002+ "Socket type not supported",
8003+ "Operation not supported on transport endpoint",
8004+ "Protocol family not supported",
8005+ "Address family not supported by protocol",
8006+ "Address already in use",
8007+ "Cannot assign requested address",
8008+ "Network is down",
8009+ "Network is unreachable",
8010+ "Network dropped connection because of reset",
8011+ "Software caused connection abort",
8012+ "Connection reset by peer",
8013+ "No buffer space available",
8014+ "Transport endpoint is already connected",
8015+ "Transport endpoint is not connected",
8016+ "Cannot send after transport endpoint shutdown",
8017+ "Too many references: cannot splice",
8018+ "Connection timed out",
8019+ "Connection refused",
8020+ "Host is down",
8021+ "No route to host",
8022+ "Operation already in progress",
8023+ "Operation now in progress",
8024+ "Stale NFS file handle",
8025+ "Structure needs cleaning",
8026+ "Not a XENIX named type file",
8027+ "No XENIX semaphores available",
8028+ "Is a named type file",
8029+ "Remote I/O error",
8030+ "Quota exceeded",
8031+};
8032+
8033+#endif /* CONFIG_ABI_VERBOSE_ERRORS */
8034diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/common/wysev386.c linux/abi/common/wysev386.c
8035--- linux-2.4.3/abi/common/wysev386.c Thu Jan 1 01:00:00 1970
8036+++ linux/abi/common/wysev386.c Mon Mar 12 16:34:48 2001
8037@@ -0,0 +1,226 @@
8038+/* $Id$
8039+ *
8040+ * wysev386.c - wyse386 specific syscalls
8041+ *
8042+ * Copyright 1994, 1996 Mike Jagdis (jaggy@purplet.demon.co.uk)
8043+ *
8044+ * XXX: the name of this file is wrong -- ch
8045+ */
8046+
8047+#include <linux/module.h>
8048+
8049+#include <asm/uaccess.h>
8050+
8051+#include <linux/mm.h>
8052+#include <linux/sched.h>
8053+#include <linux/utsname.h>
8054+#include <linux/wait.h>
8055+#include <linux/net.h>
8056+#include <linux/sys.h>
8057+
8058+#include <abi/abi.h>
8059+#include <abi/map.h>
8060+#include <abi/socket.h>
8061+
8062+
8063+int abi_gethostname(char *name, int len)
8064+{
8065+ int error;
8066+ char *p;
8067+
8068+ down_read(&uts_sem);
8069+ error = verify_area(VERIFY_WRITE, name, len);
8070+ if (!error) {
8071+ --len;
8072+ for (p = system_utsname.nodename; *p && len; p++,len--) {
8073+ __put_user(*p, name);
8074+ name++;
8075+ }
8076+ __put_user('\0', name);
8077+ }
8078+ up_read(&uts_sem);
8079+
8080+ return error;
8081+}
8082+
8083+EXPORT_SYMBOL(abi_gethostname);
8084+
8085+int abi_getdomainname(char *name, int len)
8086+{
8087+ int error;
8088+ char *p;
8089+
8090+ down_read(&uts_sem);
8091+ error = verify_area(VERIFY_WRITE, name, len);
8092+ if (!error) {
8093+ --len;
8094+ for (p = system_utsname.domainname; *p && len; p++,len--) {
8095+ __put_user(*p, name);
8096+ name++;
8097+ }
8098+ __put_user('\0', name);
8099+ }
8100+ up_read(&uts_sem);
8101+
8102+ return error;
8103+}
8104+
8105+EXPORT_SYMBOL(abi_getdomainname);
8106+
8107+int abi_wait3(int *loc)
8108+{
8109+ int pid;
8110+
8111+ pid = SYS(wait4)(-1, loc, WNOHANG, 0);
8112+
8113+ if(loc) {
8114+ int res;
8115+ __get_user(res, (unsigned long *) loc);
8116+ if ((res & 0xff) == 0x7f) {
8117+ int sig = (res >> 8) & 0xff;
8118+ sig = current->exec_domain->signal_map[sig];
8119+ res = (res & (~0xff00)) | (sig << 8);
8120+ put_user(res, (unsigned long *)loc);
8121+ } else if (res && res == (res & 0xff)) {
8122+ res = current->exec_domain->signal_map[res & 0x7f];
8123+ put_user(res, (unsigned long *)loc);
8124+ }
8125+ }
8126+
8127+ return pid;
8128+}
8129+
8130+EXPORT_SYMBOL(abi_wait3);
8131+
8132+
8133+/* It would probably be better to remove the statics in linux/net/socket.c
8134+ * and go direct to the sock_ calls than via the indirection routine.
8135+ */
8136+int abi_socket(struct pt_regs *regs)
8137+{
8138+ unsigned long v;
8139+
8140+ get_user(v, ((unsigned long*)regs->esp)+1);
8141+ put_user(
8142+ map_value(current->exec_domain->af_map, v, 0),
8143+ ((unsigned long *)regs->esp)+1);
8144+ get_user(v, ((unsigned long*)regs->esp)+2);
8145+ put_user(
8146+ map_value(current->exec_domain->socktype_map, v, 0),
8147+ ((unsigned long *)regs->esp)+2);
8148+
8149+ return SYS(socketcall)(SYS_SOCKET, ((unsigned long *)regs->esp) + 1);
8150+}
8151+
8152+EXPORT_SYMBOL(abi_socket);
8153+
8154+int abi_connect(struct pt_regs *regs)
8155+{
8156+ return SYS(socketcall)(SYS_CONNECT, ((unsigned long *)regs->esp) + 1);
8157+}
8158+
8159+EXPORT_SYMBOL(abi_connect);
8160+
8161+int abi_accept(struct pt_regs *regs)
8162+{
8163+ return SYS(socketcall)(SYS_ACCEPT, ((unsigned long *)regs->esp) + 1);
8164+}
8165+
8166+EXPORT_SYMBOL(abi_accept);
8167+
8168+int abi_send(struct pt_regs *regs)
8169+{
8170+ int err = SYS(socketcall)(SYS_SEND, ((unsigned long *)regs->esp) + 1);
8171+ if (err == -EAGAIN)
8172+ err = -EWOULDBLOCK;
8173+ return err;
8174+}
8175+
8176+EXPORT_SYMBOL(abi_send);
8177+
8178+int abi_recv(struct pt_regs *regs)
8179+{
8180+ int err = SYS(socketcall)(SYS_RECV, ((unsigned long *)regs->esp) + 1);
8181+ if (err == -EAGAIN)
8182+ err = -EWOULDBLOCK;
8183+ return err;
8184+}
8185+
8186+EXPORT_SYMBOL(abi_recv);
8187+
8188+
8189+int abi_bind(struct pt_regs *regs)
8190+{
8191+ return SYS(socketcall)(SYS_BIND, ((unsigned long *)regs->esp) + 1);
8192+}
8193+
8194+EXPORT_SYMBOL(abi_bind);
8195+
8196+int abi_setsockopt(struct pt_regs *regs)
8197+{
8198+ return abi_do_setsockopt(((unsigned long *)regs->esp) + 1);
8199+}
8200+
8201+EXPORT_SYMBOL(abi_setsockopt);
8202+
8203+int abi_listen(struct pt_regs *regs)
8204+{
8205+ return SYS(socketcall)(SYS_LISTEN, ((unsigned long *)regs->esp) + 1);
8206+}
8207+
8208+EXPORT_SYMBOL(abi_listen);
8209+
8210+int abi_getsockopt(struct pt_regs *regs)
8211+{
8212+ return abi_do_getsockopt(((unsigned long *)regs->esp) + 1);
8213+}
8214+
8215+EXPORT_SYMBOL(abi_getsockopt);
8216+
8217+int abi_recvfrom(struct pt_regs *regs)
8218+{
8219+ int err = SYS(socketcall)(SYS_RECVFROM, ((unsigned long *)regs->esp) + 1);
8220+ if (err == -EAGAIN)
8221+ err = -EWOULDBLOCK;
8222+ return err;
8223+}
8224+
8225+EXPORT_SYMBOL(abi_recvfrom);
8226+
8227+int abi_sendto(struct pt_regs *regs)
8228+{
8229+ int err = SYS(socketcall)(SYS_SENDTO, ((unsigned long *)regs->esp) + 1);
8230+ if (err == -EAGAIN)
8231+ err = -EWOULDBLOCK;
8232+ return err;
8233+}
8234+
8235+EXPORT_SYMBOL(abi_sendto);
8236+
8237+int abi_shutdown(struct pt_regs *regs)
8238+{
8239+ return SYS(socketcall)(SYS_SHUTDOWN, ((unsigned long *)regs->esp) + 1);
8240+}
8241+
8242+EXPORT_SYMBOL(abi_shutdown);
8243+
8244+int abi_socketpair(struct pt_regs *regs)
8245+{
8246+ return SYS(socketcall)(SYS_SOCKETPAIR, ((unsigned long *)regs->esp) + 1);
8247+}
8248+
8249+EXPORT_SYMBOL(abi_socketpair);
8250+
8251+int abi_getpeername(struct pt_regs *regs)
8252+{
8253+ return SYS(socketcall)(SYS_GETPEERNAME, ((unsigned long *)regs->esp) + 1);
8254+}
8255+
8256+EXPORT_SYMBOL(abi_getpeername);
8257+
8258+int abi_getsockname(struct pt_regs *regs)
8259+{
8260+ return SYS(socketcall)(SYS_GETSOCKNAME, ((unsigned long *)regs->esp) + 1);
8261+}
8262+
8263+EXPORT_SYMBOL(abi_getsockname);
8264diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/solaris/Makefile linux/abi/solaris/Makefile
8265--- linux-2.4.3/abi/solaris/Makefile Thu Jan 1 01:00:00 1970
8266+++ linux/abi/solaris/Makefile Mon Mar 12 16:34:48 2001
8267@@ -0,0 +1,16 @@
8268+#
8269+# Makefile for the kernel ABI code for Solaris emulation
8270+#
8271+
8272+O_TARGET := dummy.o
8273+
8274+list-multi := abi-solaris.o
8275+abi-solaris-objs:= do_solaris.o lfs.o solarisx86.o
8276+
8277+obj-$(CONFIG_ABI_SOLARIS) += abi-solaris.o
8278+
8279+
8280+include $(TOPDIR)/Rules.make
8281+
8282+abi-solaris.o: $(abi-solaris-objs)
8283+ $(LD) -r -o $@ $(abi-solaris-objs)
8284diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/solaris/do_solaris.c linux/abi/solaris/do_solaris.c
8285--- linux-2.4.3/abi/solaris/do_solaris.c Thu Jan 1 01:00:00 1970
8286+++ linux/abi/solaris/do_solaris.c Mon Mar 12 16:34:48 2001
8287@@ -0,0 +1,181 @@
8288+#include <linux/kernel.h>
8289+#include <linux/module.h>
8290+#include <linux/init.h>
8291+
8292+#include <abi/abi.h>
8293+#include <abi/abi4.h>
8294+#include <abi/svr4.h>
8295+#include <abi/solaris.h>
8296+
8297+EXPORT_NO_SYMBOLS;
8298+
8299+extern ABI_func svr4_generic_funcs[];
8300+
8301+static ABI_func Solaris_funcs[] = {
8302+ { 0, Ukn ITR(1, "vtrace", "") }, /* 142 */
8303+ { 0, Ukn ITR(1, "fork1", "") }, /* 143 */
8304+ { 0, Ukn ITR(1, "sigtimedwait", "") }, /* 144 */
8305+ { 0, Ukn ITR(1, "lwp_info", "") }, /* 145 */
8306+ { 0, Ukn ITR(1, "yield", "") }, /* 146 */
8307+ { 0, Ukn ITR(1, "lwp_sema_wait", "") }, /* 147 */
8308+ { 0, Ukn ITR(1, "lwp_sema_post", "") }, /* 148 */
8309+ { 0, Ukn ITR(1, "lwp_sema_trywait","") }, /* 149 */
8310+ { 0, Ukn ITR(1, "?", "") }, /* 150 */
8311+ { 0, Ukn ITR(1, "?", "") }, /* 151 */
8312+ { 0, Ukn ITR(1, "modctl", "") }, /* 152 */
8313+ { 0, Ukn ITR(1, "fchroot", "") }, /* 153 */
8314+ { 0, Ukn ITR(1, "utimes", "") }, /* 154 */
8315+ { 0, Ukn ITR(1, "vhangup", "") }, /* 155 */
8316+ { SC(gettimeofday), -2 ITR(0, "gettimeofday", "xx") }, /* 156 */
8317+ { SC(getitimer), -2 ITR(0, "getitimer", "dx") }, /* 157 */
8318+ { SC(setitimer), -3 ITR(0, "setitimer", "dxx") }, /* 158 */
8319+ { 0, Ukn ITR(1, "lwp_create", "") }, /* 159 */
8320+ { 0, Ukn ITR(1, "lwp_exit", "") }, /* 160 */
8321+ { 0, Ukn ITR(1, "lwp_suspend", "") }, /* 161 */
8322+ { 0, Ukn ITR(1, "lwp_continue", "") }, /* 162 */
8323+ { 0, Ukn ITR(1, "lwp_kill", "") }, /* 163 */
8324+ { 0, Ukn ITR(1, "lwp_self", "") }, /* 164 */
8325+ { 0, Ukn ITR(1, "lwp_setprivate","") }, /* 165 */
8326+ { 0, Ukn ITR(1, "lwp_getprivate","") }, /* 166 */
8327+ { 0, Ukn ITR(1, "lwp_wait", "") }, /* 167 */
8328+ { 0, Ukn ITR(1, "lwp_mutex_unlock","") }, /* 168 */
8329+ { 0, Ukn ITR(1, "lwp_mutex_lock","") }, /* 169 */
8330+ { 0, Ukn ITR(1, "lwp_cond_wait", "") }, /* 170 */
8331+ { 0, Ukn ITR(1, "lwp_cond_signal","") }, /* 171 */
8332+ { 0, Ukn ITR(1, "lwp_cond_broadcast","") }, /* 172 */
8333+ { SC(pread), -4 ITR(1, "pread", "dpdd") }, /* 173 */
8334+ { SC(pwrite), -4 ITR(1, "pwrite", "dpdd") }, /* 174 */
8335+ { sol_llseek, Spl ITR(1, "llseek", "dxxd") }, /* 175 */
8336+ { 0, Ukn ITR(1, "inst_sync", "") }, /* 176 */
8337+ { 0, Ukn ITR(1, "?", "") }, /* 177 */
8338+ { 0, Ukn ITR(1, "kaio", "") }, /* 178 */
8339+ { 0, Ukn ITR(1, "?", "") }, /* 179 */
8340+ { 0, Ukn ITR(1, "?", "") }, /* 180 */
8341+ { 0, Ukn ITR(1, "?", "") }, /* 181 */
8342+ { 0, Ukn ITR(1, "?", "") }, /* 182 */
8343+ { 0, Ukn ITR(1, "?", "") }, /* 183 */
8344+ { 0, Ukn ITR(1, "tsolsys", "") }, /* 184 */
8345+ { sol_acl, 4 ITR(1, "acl", "sddp") }, /* 185 */
8346+ { 0, Ukn ITR(1, "auditsys", "") }, /* 186 */
8347+ { 0, Ukn ITR(1, "processor_bind","") }, /* 187 */
8348+ { 0, Ukn ITR(1, "processor_info","") }, /* 188 */
8349+ { 0, Ukn ITR(1, "p_online", "") }, /* 189 */
8350+ { 0, Ukn ITR(1, "sigqueue", "") }, /* 190 */
8351+ { 0, Ukn ITR(1, "clock_gettime", "") }, /* 191 */
8352+ { 0, Ukn ITR(1, "clock_settime", "") }, /* 192 */
8353+ { 0, Ukn ITR(1, "clock_getres", "") }, /* 193 */
8354+ { 0, Ukn ITR(1, "timer_create", "") }, /* 194 */
8355+ { 0, Ukn ITR(1, "timer_delete", "") }, /* 195 */
8356+ { 0, Ukn ITR(1, "timer_settime", "") }, /* 196 */
8357+ { 0, Ukn ITR(1, "timer_gettime", "") }, /* 197 */
8358+ { 0, Ukn ITR(1, "timer_getoverrun","") }, /* 198 */
8359+ { SC(nanosleep), -2 ITR(1, "nanosleep", "pp") }, /* 199 */
8360+ { 0, Ukn ITR(1, "modstat", "") }, /* 200 */
8361+ { 0, Ukn ITR(1, "facl", "") }, /* 201 */
8362+ { SC(setreuid), -2 ITR(1, "setreuid", "dd") }, /* 202 */
8363+ { SC(setregid), -2 ITR(1, "setregid", "dd") }, /* 203 */
8364+ { 0, Ukn ITR(1, "install_utrap", "") }, /* 204 */
8365+ { 0, Ukn ITR(1, "signotify", "") }, /* 205 */
8366+ { 0, Ukn ITR(1, "schedctl", "") }, /* 206 */
8367+ { 0, Ukn ITR(1, "pset", "") }, /* 207 */
8368+ { 0, Ukn ITR(1, "?", "") }, /* 208 */
8369+ { 0, Ukn ITR(1, "resolvepath", "") }, /* 209 */
8370+ { 0, Ukn ITR(1, "signotifywait", "") }, /* 210 */
8371+ { 0, Ukn ITR(1, "lwp_sigredirect","") }, /* 211 */
8372+ { 0, Ukn ITR(1, "lwp_alarm", "") }, /* 212 */
8373+ { sol_getdents64, 3 ITR(0, "getdents64", "dxd") }, /* 213 */
8374+ { sol_mmap64, 7 ITR(1, "mmap64", "pxdddxx")}, /*214 */
8375+ { sol_stat64, 2 ITR(0, "stat64", "sp") }, /* 215 */
8376+ { sol_lstat64, 2 ITR(0, "lstat64", "sp") }, /* 216 */
8377+ { sol_fstat64, 2 ITR(0, "fstat64", "dp") }, /* 217 */
8378+ { 0, Ukn ITR(1, "statvfs64", "") }, /* 218 */
8379+ { 0, Ukn ITR(1, "fstatvfs64", "") }, /* 219 */
8380+ { 0, Ukn ITR(1, "setrlimit64", "") }, /* 220 */
8381+ { 0, Ukn ITR(1, "getrlimit64", "") }, /* 221 */
8382+ { 0, Ukn ITR(1, "pread64", "") }, /* 222 */
8383+ { 0, Ukn ITR(1, "pwrite64", "") }, /* 223 */
8384+ { 0, Ukn ITR(1, "creat64", "") }, /* 224 */
8385+ { sol_open64, 3 ITR(0, "open64", "soo") }, /* 225 */
8386+ { 0, Ukn ITR(1, "rpcsys", "") }, /* 226 */
8387+ { 0, Ukn ITR(1, "?", "") }, /* 227 */
8388+ { 0, Ukn ITR(1, "?", "") }, /* 228 */
8389+ { 0, Ukn ITR(1, "?", "") }, /* 229 */
8390+ { abi_socket, Spl ITR(1, "so_socket", "ddd") }, /* 230 */
8391+ { abi_socketpair, Spl ITR(1, "so_socketpair", "dddx") }, /* 231 */
8392+ { abi_bind, Spl ITR(1, "bind", "dxd") }, /* 232 */
8393+ { abi_listen, Spl ITR(1, "listen", "dd") }, /* 233 */
8394+ { abi_accept, Spl ITR(1, "accept", "dxx") }, /* 234 */
8395+ { abi_connect, Spl ITR(1, "connect", "dxd") }, /* 235 */
8396+ { abi_shutdown, Spl ITR(1, "shutdown", "dd") }, /* 236 */
8397+ { abi_recv, Spl ITR(1, "recv", "dxdd") }, /* 237 */
8398+ { abi_recvfrom, Spl ITR(1, "recvfrom", "dxddxd")}, /* 238 */
8399+ { 0, Ukn ITR(1, "recvmsg", "") }, /* 239 */
8400+ { abi_send, Spl ITR(1, "send", "dxdd") }, /* 240 */
8401+ { 0, Ukn ITR(0, "sendmsg", "") }, /* 241 */
8402+ { abi_sendto, Spl ITR(1, "sendto", "dxddxd")}, /* 242 */
8403+ { abi_getpeername, Spl ITR(1, "getpeername", "dxx") }, /* 243 */
8404+ { abi_getsockname, Spl ITR(1, "getsockname", "") }, /* 244 */
8405+ { abi_getsockopt, Spl ITR(1, "getsockopt", "dddxx")}, /* 245 */
8406+ { abi_setsockopt, Spl ITR(1, "setsockopt", "dddxd")}, /* 246 */
8407+ { 0, Ukn ITR(1, "sockconfig", "") }, /* 247 */
8408+ { 0, Ukn ITR(1, "ntp_gettime", "") }, /* 248 */
8409+ { 0, Ukn ITR(0, "ntp_adjtime", "") }, /* 249 */
8410+ { 0, Ukn ITR(1, "?", "") }, /* 250 */
8411+ { 0, Ukn ITR(1, "?", "") }, /* 251 */
8412+ { 0, Ukn ITR(1, "?", "") }, /* 252 */
8413+ { 0, Ukn ITR(1, "?", "") }, /* 253 */
8414+ { 0, Ukn ITR(1, "?", "") }, /* 254 */
8415+ { 0, Ukn ITR(1, "?", "") } /* 255 */
8416+};
8417+
8418+
8419+
8420+static void Solaris_lcall7(int segment, struct pt_regs * regs)
8421+{
8422+ int i = regs->eax & 0xff;
8423+ ABI_func *p;
8424+
8425+ if (i < 142)
8426+ p = &svr4_generic_funcs[i];
8427+ else
8428+ p = &Solaris_funcs[i - 142];
8429+
8430+ abi_dispatch(regs, p, 1);
8431+}
8432+
8433+extern struct map_segment svr4_err_map[];
8434+extern struct map_segment svr4_socktype_map[];
8435+extern struct map_segment abi_sockopt_map[];
8436+extern struct map_segment abi_af_map[];
8437+
8438+extern long linux_to_ibcs_signals[];
8439+extern long ibcs_to_linux_signals[];
8440+
8441+
8442+struct exec_domain solaris_exec_domain = {
8443+ "Solaris/x86",
8444+ Solaris_lcall7,
8445+ 13 /* PER_SOLARIS */, 13 /* PER_SOLARIS */,
8446+ ibcs_to_linux_signals,
8447+ linux_to_ibcs_signals,
8448+ svr4_err_map,
8449+ svr4_socktype_map,
8450+ abi_sockopt_map,
8451+ abi_af_map,
8452+ THIS_MODULE,
8453+ NULL
8454+};
8455+
8456+
8457+static void __exit solaris_cleanup(void)
8458+{
8459+ unregister_exec_domain(&solaris_exec_domain);
8460+}
8461+
8462+static int __init solaris_init(void)
8463+{
8464+ return register_exec_domain(&solaris_exec_domain);
8465+}
8466+
8467+module_init(solaris_init);
8468+module_exit(solaris_cleanup);
8469diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/solaris/lfs.c linux/abi/solaris/lfs.c
8470--- linux-2.4.3/abi/solaris/lfs.c Thu Jan 1 01:00:00 1970
8471+++ linux/abi/solaris/lfs.c Fri Mar 30 16:13:52 2001
8472@@ -0,0 +1,301 @@
8473+/* $Id$
8474+ * lfs.c - Solaris Large File Summit support
8475+ *
8476+ */
8477+
8478+#include <linux/errno.h>
8479+#include <linux/stat.h>
8480+#include <linux/fs.h>
8481+#include <linux/sched.h>
8482+#include <linux/kernel.h>
8483+#include <linux/mm.h>
8484+#include <linux/file.h>
8485+#include <linux/slab.h>
8486+#include <linux/mman.h>
8487+#include <linux/un.h>
8488+#include <linux/dirent.h>
8489+#include <asm/uaccess.h>
8490+
8491+#include <abi/abi.h>
8492+#include <abi/lfs.h>
8493+
8494+extern unsigned short fl_ibcs_to_linux[];
8495+extern unsigned short fl_ibcs_to_linux[];
8496+
8497+
8498+int
8499+sol_open64(const char *fname, int flag, int mode)
8500+{
8501+ int error, fd, args[3];
8502+ struct file *file;
8503+ mm_segment_t old_fs;
8504+ char *p;
8505+ struct sockaddr_un addr;
8506+
8507+ fd = SYS(open)(fname, map_flags(flag, fl_ibcs_to_linux) | O_LARGEFILE, mode);
8508+ if (fd < 0)
8509+ return fd;
8510+
8511+ /* Sometimes a program may open a pathname which it expects
8512+ * to be a named pipe (or STREAMS named pipe) when the
8513+ * Linux domain equivalent is a Unix domain socket. (e.g.
8514+ * UnixWare uses a STREAMS named pipe /dev/X/Nserver.0 for
8515+ * X :0 but Linux uses a Unix domain socket /tmp/.X11-unix/X0)
8516+ * It isn't enough just to make the symlink because you cannot
8517+ * open() a socket and read/write it. If we spot the error we can
8518+ * switch to socket(), connect() and things will likely work
8519+ * as expected however.
8520+ */
8521+ file = fget(fd);
8522+ if (!file)
8523+ return fd; /* Huh?!? */
8524+ if (!S_ISSOCK(file->f_dentry->d_inode->i_mode)) {
8525+ fput(file);
8526+ return fd;
8527+ }
8528+ fput(file);
8529+
8530+ SYS(close)(fd);
8531+ args[0] = AF_UNIX;
8532+ args[1] = SOCK_STREAM;
8533+ args[2] = 0;
8534+ old_fs = get_fs();
8535+ set_fs(get_ds());
8536+ fd = SYS(socketcall)(SYS_SOCKET, args);
8537+ set_fs(old_fs);
8538+ if (fd < 0)
8539+ return fd;
8540+
8541+ p = getname(fname);
8542+ if (IS_ERR(p)) {
8543+ SYS(close)(fd);
8544+ return PTR_ERR(p);
8545+ }
8546+ if (strlen(p) >= UNIX_PATH_MAX) {
8547+ putname(p);
8548+ SYS(close)(fd);
8549+ return -E2BIG;
8550+ }
8551+ addr.sun_family = AF_UNIX;
8552+ strcpy(addr.sun_path, p);
8553+ putname(p);
8554+
8555+ args[0] = fd;
8556+ args[1] = (int)&addr;
8557+ args[2] = sizeof(struct sockaddr_un);
8558+ set_fs(get_ds());
8559+ error = SYS(socketcall)(SYS_CONNECT, args);
8560+ set_fs(old_fs);
8561+ if (error) {
8562+ SYS(close)(fd);
8563+ return error;
8564+ }
8565+
8566+ return fd;
8567+}
8568+
8569+
8570+static int
8571+cp_sol_stat64(struct inode *inode, struct sol_stat64 * statbuf)
8572+{
8573+ struct sol_stat64 tmp;
8574+
8575+ memset(&tmp, 0, sizeof(struct sol_stat64));
8576+
8577+ /* I don't see why this makes sense for solaris --hch */
8578+ if ((unsigned long)inode->i_ino & 0xffff)
8579+ tmp.st_ino = (unsigned long)inode->i_ino & 0xffff;
8580+ else
8581+ tmp.st_ino = 0xfffe;
8582+
8583+ tmp.st_dev = inode->i_dev;
8584+ tmp.st_mode = inode->i_mode;
8585+ tmp.st_nlink = inode->i_nlink;
8586+ tmp.st_uid = inode->i_uid;
8587+ tmp.st_gid = inode->i_gid;
8588+ tmp.st_rdev = inode->i_rdev;
8589+ tmp.st_size = inode->i_size;
8590+ tmp.st_atime = inode->i_atime;
8591+ tmp.st_mtime = inode->i_mtime;
8592+ tmp.st_ctime = inode->i_ctime;
8593+
8594+ return copy_to_user(statbuf, &tmp, sizeof(tmp)) ? -EFAULT : 0;
8595+}
8596+
8597+int
8598+sol_stat64(char *filename, struct sol_stat64 *statbuf)
8599+{
8600+ struct nameidata nd;
8601+ int error;
8602+
8603+ error = user_path_walk(filename, &nd);
8604+ if (!error) {
8605+ error = do_revalidate(nd.dentry);
8606+ if (!error)
8607+ error = cp_sol_stat64(nd.dentry->d_inode, statbuf);
8608+ path_release(&nd);
8609+ }
8610+ return error;
8611+}
8612+
8613+int
8614+sol_lstat64(char *filename, struct sol_stat64 *statbuf)
8615+{
8616+ struct nameidata nd;
8617+ int error;
8618+
8619+ error = user_path_walk_link(filename, &nd);
8620+ if (!error) {
8621+ error = do_revalidate(nd.dentry);
8622+ if (!error)
8623+ error = cp_sol_stat64(nd.dentry->d_inode, statbuf);
8624+ path_release(&nd);
8625+ }
8626+ return error;
8627+}
8628+
8629+int
8630+sol_fstat64(unsigned int fd, struct sol_stat64 * statbuf)
8631+{
8632+ struct file *fp;
8633+ int err = -EBADF;
8634+
8635+ fp = fget(fd);
8636+ if (fp) {
8637+ struct dentry *dentry = fp->f_dentry;
8638+
8639+ err = do_revalidate(dentry);
8640+ if (!err)
8641+ err = cp_sol_stat64(dentry->d_inode, statbuf);
8642+ fput(fp);
8643+ }
8644+
8645+ return err;
8646+}
8647+
8648+
8649+
8650+/* If/when the readdir function is changed to read multiple entries
8651+ * at once this should be updated to take advantage of the fact.
8652+ *
8653+ * N.B. For Linux the reclen in a dirent is the number of characters
8654+ * in the filename, for SCO (at least) reclen is the total size of
8655+ * the particular dirent rounded up to the next multiple of 4. The SCO
8656+ * behaviour is faithfully emulated here.
8657+ *
8658+ * XXXX
8659+ * We don't truncate long filenames at all when copying. If we meet a
8660+ * long filename and the buffer supplied by the application simply isn't
8661+ * big enough to hold it we'll return without filling the buffer (i.e
8662+ * return 0). The application will see this as a (premature) end of
8663+ * directory. Is there a work around for this at all???
8664+ */
8665+int
8666+sol_getdents64(int fd, char *buf, int nbytes)
8667+{
8668+ int error, here, posn, reclen;
8669+ struct file *file;
8670+ struct dirent *d;
8671+ mm_segment_t old_fs;
8672+
8673+ error = verify_area(VERIFY_WRITE, buf, nbytes);
8674+ if (error)
8675+ return error;
8676+
8677+ /* Check the file handle here. This is so we can access the current
8678+ * position in the file structure safely without a tedious call
8679+ * to sys_lseek that does nothing useful.
8680+ */
8681+ file = fget(fd);
8682+ if (!file)
8683+ return -EBADF;
8684+
8685+ d = (struct dirent *)__get_free_page(GFP_KERNEL);
8686+ if (!d) {
8687+ fput(file);
8688+ return -ENOMEM;
8689+ }
8690+
8691+ error = posn = reclen = 0;
8692+ while (posn + reclen < nbytes) {
8693+ struct sol_dirent64 tmpbuf;
8694+ /* Save the current position and get another dirent */
8695+ here = file->f_pos;
8696+ old_fs = get_fs();
8697+ set_fs (get_ds());
8698+ error = SYS(readdir)(fd, d, 1);
8699+ set_fs(old_fs);
8700+ if (error <= 0)
8701+ break;
8702+
8703+ /* If it'll fit in the buffer save it otherwise back up
8704+ * so it is read next time around.
8705+ * Oh, if we're at the beginning of the buffer there's
8706+ * no chance that this entry will ever fit so don't
8707+ * copy it and don't back off - we'll just pretend it
8708+ * isn't here...
8709+ */
8710+ reclen = (sizeof(long long) + sizeof(long long)
8711+ + sizeof(unsigned short) + d->d_reclen + 1
8712+ + 3) & (~3);
8713+ if (posn + reclen <= nbytes) {
8714+ tmpbuf.d_off = file->f_pos;
8715+ tmpbuf.d_ino = d->d_ino;
8716+ tmpbuf.d_off = file->f_pos;
8717+ tmpbuf.d_reclen = reclen;
8718+ copy_to_user(buf+posn, &tmpbuf,
8719+ sizeof(struct sol_dirent64) -1);
8720+ copy_to_user(buf+posn+sizeof(struct sol_dirent64)-2,
8721+ &d->d_name, d->d_reclen+1);
8722+ posn += reclen;
8723+ } else if (posn) {
8724+ SYS(lseek)(fd, here, 0);
8725+ } /* else posn == 0 */
8726+ }
8727+
8728+ /* Loose the intermediate buffer. */
8729+ free_page((unsigned long)d);
8730+
8731+ fput(file);
8732+
8733+ /* If we've put something in the buffer return the byte count
8734+ * otherwise return the error status.
8735+ */
8736+ return ((posn > 0) ? posn : error);
8737+}
8738+
8739+
8740+int
8741+sol_mmap64(u_int addr, u_int len, int prot, int flags,
8742+ int fd, u_int off_hi, u_int off)
8743+{
8744+ loff_t off64 = (off | ((loff_t)off_hi << 32));
8745+ u_long pgoff = (off64 >> PAGE_SHIFT);
8746+ struct file *file = NULL;
8747+ int error;
8748+
8749+ if ((off64 + PAGE_ALIGN(len)) < off64)
8750+ return -EINVAL;
8751+
8752+ if (!(off64 & ~PAGE_MASK))
8753+ return -EINVAL;
8754+
8755+ flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
8756+ if (!(flags & MAP_ANONYMOUS)) {
8757+ if (!(file = fget(fd)))
8758+ return -EBADF;
8759+ }
8760+
8761+ if (!(flags & 0x80000000) && addr)
8762+ flags |= MAP_FIXED;
8763+ else
8764+ flags &= 0x7fffffff;
8765+
8766+ down_write(&current->mm->mmap_sem);
8767+ error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
8768+ up_write(&current->mm->mmap_sem);
8769+
8770+ if (file)
8771+ fput(file);
8772+ return (error);
8773+}
8774diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/solaris/solarisx86.c linux/abi/solaris/solarisx86.c
8775--- linux-2.4.3/abi/solaris/solarisx86.c Thu Jan 1 01:00:00 1970
8776+++ linux/abi/solaris/solarisx86.c Mon Mar 12 16:34:48 2001
8777@@ -0,0 +1,75 @@
8778+#include <abi/abi.h>
8779+#include <linux/config.h>
8780+#include <linux/version.h>
8781+#include <asm/uaccess.h>
8782+#include <linux/types.h>
8783+#include <linux/kernel.h>
8784+#include <linux/file.h>
8785+#include <linux/mm.h>
8786+#include <abi/svr4sig.h>
8787+#include <abi/solaris.h>
8788+
8789+int sol_llseek(struct pt_regs * regs)
8790+{
8791+ unsigned int fd;
8792+ unsigned long offset_high, offset_low;
8793+ unsigned origin;
8794+ long long res;
8795+ unsigned int rvalue;
8796+ mm_segment_t old_fs;
8797+ struct inode *inode;
8798+ struct file *file;
8799+ get_user(fd, ((unsigned int *)regs->esp)+1);
8800+ get_user(offset_low, ((unsigned long *)regs->esp)+2);
8801+ get_user(offset_high, ((unsigned long *)regs->esp)+3);
8802+ get_user(origin, ((unsigned int *)regs->esp)+4);
8803+
8804+ old_fs = get_fs();
8805+ set_fs(get_ds());
8806+ rvalue = SYS(_llseek)(fd,offset_high,offset_low,&res,origin);
8807+ set_fs(old_fs);
8808+
8809+ if ( rvalue < -ENOIOCTLCMD) {
8810+ regs->edx = (res >> 32);
8811+ rvalue = (res & 0xffffffff);
8812+ }
8813+ else if (rvalue == -ESPIPE) {
8814+ /* Solaris allows you to seek on a pipe */
8815+ file = fget(fd);
8816+ if (file) {
8817+ inode = file->f_dentry->d_inode;
8818+ if (inode && (S_ISCHR(inode->i_mode)
8819+ || S_ISBLK(inode->i_mode))) {
8820+ rvalue = 0;
8821+ regs->edx = 0;
8822+ }
8823+ fput(file);
8824+ }
8825+ }
8826+
8827+ return rvalue;
8828+}
8829+
8830+int ibcs_memcntl(unsigned addr, unsigned len, int cmd, unsigned arg,
8831+ int attr, int mask)
8832+{
8833+ // printk("ibcs_memcntl being ignored\n");
8834+ return 0;
8835+}
8836+
8837+int sol_acl(char *pathp, int cmd, int nentries, void *aclbufp)
8838+{
8839+ switch (cmd) {
8840+ case GETACLCNT:
8841+ return 0;
8842+
8843+ case GETACL:
8844+ return -EIO;
8845+
8846+ case SETACL:
8847+ return -EPERM;
8848+
8849+ default:
8850+ return -EINVAL;
8851+ }
8852+}
8853diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/Makefile linux/abi/svr4/Makefile
8854--- linux-2.4.3/abi/svr4/Makefile Thu Jan 1 01:00:00 1970
8855+++ linux/abi/svr4/Makefile Mon Mar 12 16:34:48 2001
8856@@ -0,0 +1,29 @@
8857+#
8858+# Makefile for the kernel ABI code which is shared by iBCS, Solaris and UW7
8859+# Loosely speaking, this is the SVR4 code - so that's the name it's got.
8860+#
8861+
8862+O_TARGET := dummy.o
8863+
8864+objs := isc.o isc_funcs.o vtkbd.o xnx.o
8865+export-objs := funcs.o hrtsys.o ioctl.o ipc.o mmap.o open.o poll.o ptrace.o \
8866+ svr4.o sysconf.o sysfs.o sysinfo.o sysi86.o syslocal.o \
8867+ ulimit.o utsname.o stream.o timod.o xnx_funcs.o xstat.o
8868+list-multi := abi-svr4.o
8869+abi-svr4-objs := $(objs) $(export-objs)
8870+
8871+ifeq ($(CONFIG_ABI_IBCS_SCO),y)
8872+abi-svr4-objs += sco_secureware.o
8873+endif
8874+ifeq ($(CONFIG_ABI_IBCS_WYSE),y)
8875+abi-svr4-objs += wyse_nfs.o wyse_tcp.o
8876+endif
8877+
8878+
8879+obj-$(CONFIG_ABI_SVR4) += abi-svr4.o
8880+
8881+
8882+include $(TOPDIR)/Rules.make
8883+
8884+abi-svr4.o: $(abi-svr4-objs)
8885+ $(LD) -r -o $@ $(abi-svr4-objs)
8886diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/funcs.c linux/abi/svr4/funcs.c
8887--- linux-2.4.3/abi/svr4/funcs.c Thu Jan 1 01:00:00 1970
8888+++ linux/abi/svr4/funcs.c Sun Mar 18 17:28:55 2001
8889@@ -0,0 +1,587 @@
8890+/* $Id$
8891+ * funcs.c - iBCS syscall dispatch table
8892+ *
8893+ */
8894+
8895+#include <linux/kernel.h>
8896+#include <linux/module.h>
8897+#include <linux/init.h>
8898+#include <abi/abi.h>
8899+#include <abi/signal.h>
8900+#include <abi/svr4.h>
8901+#include <abi/abi4.h>
8902+
8903+#ifdef CONFIG_ABI_IBCS_SCO
8904+MODULE_PARM(sco_serial, "1-10s");
8905+MODULE_PARM_DESC(sco_serial, "SCO Serial Number");
8906+#endif
8907+
8908+extern void iBCS_class_XNX(struct pt_regs *regs);
8909+extern void iBCS_class_ISC(struct pt_regs *regs);
8910+
8911+#ifdef CONFIG_ABI_IBCS_WYSE
8912+extern void iBCS_class_WYSETCP(struct pt_regs *regs);
8913+extern void iBCS_class_WYSENFS(struct pt_regs *regs);
8914+#endif
8915+
8916+
8917+static char type_svr4_to_linux_seg1[] = {
8918+ SOCK_DGRAM,
8919+ SOCK_STREAM,
8920+ 0,
8921+ SOCK_RAW,
8922+ SOCK_RDM,
8923+ SOCK_SEQPACKET
8924+};
8925+struct map_segment svr4_socktype_map[] = {
8926+ /* 1 to 6 are remapped as indicated. Nothing else is valid. */
8927+ { 1, 6, type_svr4_to_linux_seg1 },
8928+ { -1 }
8929+};
8930+
8931+EXPORT_SYMBOL(svr4_socktype_map);
8932+
8933+/* Map Linux RESTART* values (512,513,514) to EINTR */
8934+static unsigned char LNX_err_table[] = {
8935+ EINTR, EINTR, EINTR
8936+};
8937+
8938+
8939+/*
8940+ * Default Linux to iBCS mapping.
8941+ * We could remove some of the long identity mapped runs but at the
8942+ * expense of extra comparisons for each mapping at run time...
8943+ */
8944+static unsigned char SVR4_err_table[] = {
8945+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
8946+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
8947+ 32, 33, 34, 45, 78, 46, 89, 93, 90, 90, 35, 36, 37, 38, 39, 40,
8948+ 41, 42, 43, 44, 50, 51, 52, 53, 54, 55, 56, 57, 60, 61, 62, 63,
8949+ 64, 65, 66, 67, 68, 69, 70, 71, 74, 76, 77, 79, 80, 81, 82, 83,
8950+ 84, 85, 86, 87, 88, 91, 92, 94, 95, 96, 97, 98, 99,120,121,122,
8951+ 123,124,125,126,127,128,129,130,131,132,133,134,143,144,145,146,
8952+ 147,148,149,150, 22,135,137,138,139,140, 28
8953+};
8954+
8955+
8956+/* SVR4 (aka the full official iBCS) is the base mapping - no exceptions,
8957+ * other than the RESTART* values.
8958+ */
8959+struct map_segment svr4_err_map[] = {
8960+ { 0, 0+sizeof(SVR4_err_table)-1, SVR4_err_table },
8961+ { 512, 512+sizeof(LNX_err_table)-1, LNX_err_table },
8962+ { -1 }
8963+};
8964+
8965+EXPORT_SYMBOL(svr4_err_map);
8966+
8967+ABI_func svr4_generic_funcs[] = {
8968+ { abi_syscall, Fast ITR(0, "syscall", "") }, /* 0 */
8969+ { SC(exit), -1 ITR(0, "exit", "d") }, /* 1 */
8970+ { abi_fork, Spl ITR(0, "fork", "") }, /* 2 */
8971+ { abi_read, 3 ITR(0, "read", "dpd") }, /* 3 */
8972+ { SC(write), -3 ITR(0, "write", "dpd") }, /* 4 */
8973+ { svr4_open, 3 ITR(0, "open", "soo") }, /* 5 */
8974+ { SC(close), -1 ITR(0, "close", "d") }, /* 6 */
8975+ { abi_wait, Spl ITR(0, "wait", "xxx") }, /* 7 */
8976+ { SC(creat), -2 ITR(0, "creat", "so") }, /* 8 */
8977+ { SC(link), -2 ITR(0, "link", "ss") }, /* 9 */
8978+ { SC(unlink), -1 ITR(0, "unlink", "s") }, /* 10 */
8979+ { abi_exec, Spl ITR(0, "exec", "sxx") }, /* 11 */
8980+ { SC(chdir), -1 ITR(0, "chdir", "s") }, /* 12 */
8981+ { abi_time, 0 ITR(0, "time", "") }, /* 13 */
8982+ { abi_mknod, 3 ITR(0, "mknod", "soo") }, /* 14 */
8983+ { SC(chmod), -2 ITR(0, "chmod", "so") }, /* 15 */
8984+ { SC(chown), -3 ITR(0, "chown", "sdd") }, /* 16 */
8985+ { abi_brk, 1 ITR(0, "brk/break", "x") }, /* 17 */
8986+ { abi_stat, 2 ITR(0, "stat", "sp") }, /* 18 */
8987+ { abi_lseek, 3 ITR(0, "seek/lseek", "ddd") }, /* 19 */
8988+ { abi_getpid, Spl ITR(0, "getpid", "") }, /* 20 */
8989+ { 0, Ukn ITR(1, "mount", "") }, /* 21 */
8990+ { SC(umount), -1 ITR(0, "umount", "s") }, /* 22 */
8991+ { SC(setuid), -1 ITR(0, "setuid", "d") }, /* 23 */
8992+ { abi_getuid, Spl ITR(0, "getuid", "") }, /* 24 */
8993+ { SC(stime), -1 ITR(0, "stime", "d") }, /* 25 */
8994+ { svr4_ptrace, 4 ITR(0, "ptrace", "xdxx") }, /* 26 */
8995+ { SC(alarm), -1 ITR(0, "alarm", "d") }, /* 27 */
8996+ { abi_fstat, 2 ITR(0, "fstat", "dp") }, /* 28 */
8997+ { SC(pause), -ZERO ITR(0, "pause", "") }, /* 29 */
8998+ { SC(utime), -2 ITR(0, "utime", "xx") }, /* 30 */
8999+ { 0, Ukn ITR(0, "stty", "") }, /* 31 */
9000+ { 0, Ukn ITR(1, "gtty", "") }, /* 32 */
9001+ { SC(access), -2 ITR(0, "access", "so") }, /* 33 */
9002+ { SC(nice), -1 ITR(0, "nice", "d") }, /* 34 */
9003+ { svr4_statfs, 4 ITR(0, "statfs", "spdd") }, /* 35 */
9004+ { SC(sync), -ZERO ITR(0, "sync", "") }, /* 36 */
9005+ { abi_kill, 2 ITR(0, "kill", "dd") }, /* 37 */
9006+ { svr4_fstatfs, 4 ITR(0, "fstatfs", "dpdd") }, /* 38 */
9007+ { abi_procids, Spl ITR(0, "ibcs_procids", "d") }, /* 39 */
9008+ { iBCS_class_XNX, Fast ITR(0, "cxenix", "") }, /* 40 */
9009+ { SC(dup), -1 ITR(0, "dup", "d") }, /* 41 */
9010+ { abi_pipe, Spl ITR(0, "pipe", "") }, /* 42 */
9011+ { SC(times), -1 ITR(0, "times", "p") }, /* 43 */
9012+ { SC(profil), -4 ITR(0, "prof", "xxxx")}, /* 44 */
9013+ { 0, Ukn ITR(1, "lock/plock", "") }, /* 45 */
9014+ { SC(setgid), -1 ITR(0, "setgid", "d") }, /* 46 */
9015+ { abi_getgid, Spl ITR(0, "getgid", "") }, /* 47 */
9016+ { abi_sigfunc, Fast ITR(0, "sigfunc", "xxx") }, /* 48 */
9017+ { svr4_msgsys, Spl ITR(0, "msgsys", "dxddd")}, /* 49 */
9018+ { svr4_sysi86, Spl ITR(0, "sysi86/sys3b", "d") }, /* 50 */
9019+ { SC(acct), -1 ITR(0, "acct/sysacct", "x") }, /* 51 */
9020+ { svr4_shmsys, Fast ITR(0, "shmsys", "ddxo")}, /* 52 */
9021+ { svr4_semsys, Spl ITR(0, "semsys", "dddx")}, /* 53 */
9022+ { svr4_ioctl, Spl ITR(0, "ioctl", "dxx") }, /* 54 */
9023+ { 0, 3 ITR(0, "uadmin", "xxx") }, /* 55 */
9024+ { 0, Ukn ITR(1, "?", "") }, /* 56 */
9025+ { v7_utsname, 1 ITR(0, "utsys", "x") }, /* 57 */
9026+ { SC(fsync), -1 ITR(0, "fsync", "d") }, /* 58 */
9027+ { abi_exec, Spl ITR(0, "execv", "spp") }, /* 59 */
9028+ { SC(umask), -1 ITR(0, "umask", "o") }, /* 60 */
9029+ { SC(chroot), -1 ITR(0, "chroot", "s") }, /* 61 */
9030+ { svr4_fcntl, Spl ITR(0, "fcntl", "dxx") }, /* 62 */
9031+ { svr4_ulimit, 2 ITR(0, "ulimit", "xx") }, /* 63 */
9032+ { 0, Ukn ITR(1, "?", "") }, /* 64 */
9033+ { 0, Ukn ITR(1, "?", "") }, /* 65 */
9034+ { 0, Ukn ITR(1, "?", "") }, /* 66 */
9035+ { 0, Ukn ITR(1, "?", "") }, /* 67 */
9036+ { 0, Ukn ITR(1, "?", "") }, /* 68 */
9037+ { 0, Ukn ITR(1, "?", "") }, /* 69 */
9038+ { 0, Ukn ITR(1, "advfs", "") }, /* 70 */
9039+ { 0, Ukn ITR(1, "unadvfs", "") }, /* 71 */
9040+ { 0, Ukn ITR(1, "rmount", "") }, /* 72 */
9041+ { 0, Ukn ITR(1, "rumount", "") }, /* 73 */
9042+ { 0, Ukn ITR(1, "rfstart", "") }, /* 74 */
9043+ { 0, Ukn ITR(1, "?", "") }, /* 75 */
9044+ { 0, Ukn ITR(1, "rdebug", "") }, /* 76 */
9045+ { 0, Ukn ITR(1, "rfstop", "") }, /* 77 */
9046+ { 0, Ukn ITR(1, "rfsys", "") }, /* 78 */
9047+ { SC(rmdir), -1 ITR(0, "rmdir", "s") }, /* 79 */
9048+ { abi_mkdir, 2 ITR(0, "mkdir", "so") }, /* 80 */
9049+ { svr4_getdents, 3 ITR(0, "getdents", "dxd") }, /* 81 */
9050+ { 0, Ukn ITR(1, "libattach", "") }, /* 82 */
9051+ { 0, Ukn ITR(1, "libdetach", "") }, /* 83 */
9052+ { svr4_sysfs, 3 ITR(0, "sysfs", "dxx") }, /* 84 */
9053+ { svr4_getmsg, Spl ITR(0, "getmsg", "dxxx") }, /* 85 */
9054+ { svr4_putmsg, Spl ITR(0, "putmsg", "dxxd") }, /* 86 */
9055+ { svr4_poll, 3 ITR(0, "poll", "xdd") }, /* 87 */
9056+ { abi_lstat, 2 ITR(0, "lstat", "sp") }, /* 88 */
9057+ { SC(symlink), -2 ITR(0, "symlink", "ss") }, /* 89 */
9058+ { SC(readlink), -3 ITR(0, "readlink", "spd") }, /* 90 */
9059+ { 0, Ukn ITR(0, "svr4_setgroups","dp") }, /* 91 */
9060+ { 0, Ukn ITR(0, "svr4_getgroups","dp") }, /* 92 */
9061+ { SC(fchmod), -2 ITR(0, "fchmod", "do") }, /* 93 */
9062+ { SC(fchown), -3 ITR(0, "fchown", "ddd") }, /* 94 */
9063+ { abi_sigprocmask, 3 ITR(0, "sigprocmask", "dxx") }, /* 95 */
9064+ { abi_sigsuspend, Spl ITR(0, "sigsuspend", "x") }, /* 96 */
9065+ { 0, 2 ITR(1, "sigaltstack", "xx") }, /* 97 */
9066+ { abi_sigaction, 3 ITR(0, "sigaction", "dxx") }, /* 98 */
9067+ { svr4_sigpending, 2 ITR(1, "sigpending", "dp") }, /* 99 */
9068+ { svr4_context, Spl ITR(0, "context", "") }, /* 100 */
9069+ { 0, Ukn ITR(1, "evsys", "") }, /* 101 */
9070+ { 0, Ukn ITR(1, "evtrapret", "") }, /* 102 */
9071+ { abi_statvfs, 2 ITR(0, "statvfs", "sp") }, /* 103 */
9072+ { abi_statvfs, 2 ITR(0, "fstatvfs", "dp") }, /* 104 */
9073+ { iBCS_class_ISC, Fast ITR(0, "sysisc", "") }, /* 105 */
9074+ { 0, Ukn ITR(1, "nfssys", "") }, /* 106 */
9075+ { 0, 4 ITR(0, "waitid", "ddxd") }, /* 107 */
9076+ { 0, 3 ITR(1, "sigsendsys", "ddd") }, /* 108 */
9077+ { svr4_hrtsys, Spl ITR(0, "hrtsys", "xxx") }, /* 109 */
9078+ { 0, 3 ITR(1, "acancel", "dxd") }, /* 110 */
9079+ { 0, Ukn ITR(1, "async", "") }, /* 111 */
9080+ { 0, Ukn ITR(1, "priocntlsys", "") }, /* 112 */
9081+ { svr4_pathconf, 2 ITR(1, "pathconf", "sd") }, /* 113 */
9082+ { 0, 3 ITR(1, "mincore", "xdx") }, /* 114 */
9083+ { svr4_mmap, 6 ITR(0, "mmap", "xxxxdx") },/* 115 */
9084+ { SC(mprotect), -3 ITR(0, "mprotect", "xdx") },/* 116 */
9085+ { SC(munmap), -2 ITR(0, "munmap", "xd") },/* 117 */
9086+ { svr4_fpathconf, 2 ITR(1, "fpathconf", "dd") }, /* 118 */
9087+ { abi_fork, Spl ITR(0, "vfork", "") }, /* 119 */
9088+ { SC(fchdir), -1 ITR(0, "fchdir", "d") }, /* 120 */
9089+ { SC(readv), -3 ITR(0, "readv", "dxd") }, /* 121 */
9090+ { SC(writev), -3 ITR(0, "writev", "dxd") }, /* 122 */
9091+ { svr4_xstat, 3 ITR(0, "xstat", "dsx") }, /* 123 */
9092+ { svr4_lxstat, 3 ITR(0, "lxstat", "dsx") }, /* 124 */
9093+ { svr4_fxstat, 3 ITR(0, "fxstat", "ddx") }, /* 125 */
9094+ { svr4_xmknod, 4 ITR(0, "xmknod", "dsox")}, /* 126 */
9095+ { svr4_syslocal, Spl ITR(0, "syslocal", "d") }, /* 127 */
9096+ { svr4_getrlimit, 2 ITR(0, "setrlimit", "dx") }, /* 128 */
9097+ { svr4_setrlimit, 2 ITR(0, "getrlimit", "dx") }, /* 129 */
9098+ { 0, 3 ITR(1, "lchown", "sdd") }, /* 130 */
9099+ { 0, Ukn ITR(1, "memcntl", "") }, /* 131 */
9100+#ifdef CONFIG_ABI_XTI
9101+ { svr4_getpmsg, 5 ITR(0, "getpmsg", "dxxxx")}, /* 132 */
9102+ { svr4_putpmsg, 5 ITR(0, "putpmsg", "dxxdd")}, /* 133 */
9103+#else
9104+ { 0, 5 ITR(0, "getpmsg", "dxxxx")}, /* 132 */
9105+ { 0, 5 ITR(0, "putpmsg", "dxxdd")}, /* 133 */
9106+#endif
9107+ { SC(rename), -2 ITR(0, "rename", "ss") }, /* 134 */
9108+ { abi_utsname, 1 ITR(0, "uname", "x") }, /* 135 */
9109+ { svr4_setegid, 1 ITR(1, "setegid", "d") }, /* 136 */
9110+ { svr4_sysconfig, 1 ITR(0, "sysconfig", "d") }, /* 137 */
9111+ { 0, Ukn ITR(1, "adjtime", "") }, /* 138 */
9112+ { svr4_sysinfo, 3 ITR(0, "systeminfo", "dsd") }, /* 139 */
9113+ { socksys_syscall, 1 ITR(0, "socksys_syscall","x") }, /* 140 */
9114+ { svr4_seteuid, 1 ITR(1, "seteuid", "d") }, /* 141 */
9115+};
9116+
9117+EXPORT_SYMBOL(svr4_generic_funcs);
9118+
9119+
9120+static ABI_func iBCS_funcs[] = {
9121+ { 0, Ukn ITR(1, "?", "") }, /* 142 */
9122+ { 0, Ukn ITR(1, "?", "") }, /* 143 */
9123+ { 0, 2 ITR(1, "secsys", "dx") }, /* 144 */
9124+ { 0, 4 ITR(1, "filepriv", "sdxd") }, /* 145 */
9125+ { 0, 3 ITR(1, "procpriv", "dxd") }, /* 146 */
9126+ { 0, 3 ITR(1, "devstat", "sdx") }, /* 147 */
9127+ { 0, 5 ITR(1, "aclipc", "ddddx")}, /* 148 */
9128+ { 0, 3 ITR(1, "fdevstat", "ddx") }, /* 149 */
9129+ { 0, 3 ITR(1, "flvlfile", "ddx") }, /* 150 */
9130+ { 0, 3 ITR(1, "lvlfile", "sdx") }, /* 151 */
9131+ { 0, Ukn ITR(1, "?", "") }, /* 152 */
9132+ { 0, 2 ITR(1, "lvlequal", "xx") }, /* 153 */
9133+ { 0, 2 ITR(1, "lvlproc", "dx") }, /* 154 */
9134+ { 0, Ukn ITR(1, "?", "") }, /* 155 */
9135+ { 0, 4 ITR(1, "lvlipc", "dddx") }, /* 156 */
9136+ { 0, 4 ITR(1, "acl", "sddx") }, /* 157 */
9137+ { 0, Ukn ITR(1, "auditevt", "") }, /* 158 */
9138+ { 0, Ukn ITR(1, "auditctl", "") }, /* 159 */
9139+ { 0, Ukn ITR(1, "auditdmp", "") }, /* 160 */
9140+ { 0, Ukn ITR(1, "auditlog", "") }, /* 161 */
9141+ { 0, Ukn ITR(1, "auditbuf", "") }, /* 162 */
9142+ { 0, 2 ITR(1, "lvldom", "xx") }, /* 163 */
9143+ { 0, Ukn ITR(1, "lvlvfs", "") }, /* 164 */
9144+ { 0, 2 ITR(1, "mkmld", "so") }, /* 165 */
9145+ { 0, Ukn ITR(1, "mlddone", "") }, /* 166 */
9146+ { 0, 2 ITR(0, "secadvise", "xx") }, /* 167 */
9147+ { 0, Ukn ITR(1, "online", "") }, /* 168 */
9148+ { SC(setitimer), -3 ITR(0, "setitimer", "dxx") }, /* 169 */
9149+ { SC(getitimer), -2 ITR(0, "getitimer", "dx") }, /* 170 */
9150+ { SC(gettimeofday), -2 ITR(0, "gettimeofday", "xx") }, /* 171 */
9151+ { SC(settimeofday), -2 ITR(0, "settimeofday", "xx") }, /* 172 */
9152+ { 0, Ukn ITR(1, "lwpcreate", "") }, /* 173 */
9153+ { 0, Ukn ITR(1, "lwpexit", "") }, /* 174 */
9154+ { 0, Ukn ITR(1, "lwpwait", "") }, /* 175 */
9155+ { 0, Ukn ITR(1, "lwpself", "") }, /* 176 */
9156+ { 0, Ukn ITR(1, "lwpinfo", "") }, /* 177 */
9157+ { 0, Ukn ITR(1, "lwpprivate", "") }, /* 178 */
9158+ { 0, Ukn ITR(1, "processorbind", "") }, /* 179 */
9159+ { 0, Ukn ITR(1, "processorexbind","") }, /* 180 */
9160+ { 0, Ukn ITR(1, "", "") }, /* 181 */
9161+ { 0, Ukn ITR(1, "sync_mailbox", "") }, /* 182 */
9162+ { 0, Ukn ITR(1, "prepblock", "") }, /* 183 */
9163+ { 0, Ukn ITR(1, "block", "") }, /* 184 */
9164+ { 0, Ukn ITR(1, "rdblock", "") }, /* 185 */
9165+ { 0, Ukn ITR(1, "unblock", "") }, /* 186 */
9166+ { 0, Ukn ITR(1, "cancelblock", "") }, /* 187 */
9167+ { 0, Ukn ITR(1, "?", "") }, /* 188 */
9168+ { 0, Ukn ITR(1, "pread", "") }, /* 189 */
9169+ { 0, Ukn ITR(1, "pwrite", "") }, /* 190 */
9170+ { SC(truncate), -2 ITR(0, "truncate", "sd") }, /* 191 */
9171+ { SC(ftruncate), -2 ITR(0, "ftruncate", "dd") }, /* 192 */
9172+ { 0, Ukn ITR(1, "lwpkill", "") }, /* 193 */
9173+ { 0, Ukn ITR(1, "sigwait", "") }, /* 194 */
9174+ { 0, Ukn ITR(1, "fork1", "") }, /* 195 */
9175+ { 0, Ukn ITR(1, "forkall", "") }, /* 196 */
9176+ { 0, Ukn ITR(1, "modload", "") }, /* 197 */
9177+ { 0, Ukn ITR(1, "moduload", "") }, /* 198 */
9178+ { 0, Ukn ITR(1, "modpath", "") }, /* 199 */
9179+ { 0, Ukn ITR(1, "modstat", "") }, /* 200 */
9180+ { 0, Ukn ITR(1, "modadm", "") }, /* 201 */
9181+ { 0, Ukn ITR(1, "getksym", "") }, /* 202 */
9182+ { 0, Ukn ITR(1, "lwpsuspend", "") }, /* 203 */
9183+ { 0, Ukn ITR(1, "lwpcontinue", "") }, /* 204 */
9184+ { 0, Ukn ITR(1, "?", "") }, /* 205 */
9185+ { 0, Ukn ITR(1, "?", "") }, /* 206 */
9186+ { 0, Ukn ITR(1, "?", "") }, /* 207 */
9187+ { 0, Ukn ITR(1, "?", "") },
9188+ { 0, Ukn ITR(1, "?", "") },
9189+ { 0, Ukn ITR(1, "?", "") },
9190+ { 0, Ukn ITR(1, "?", "") },
9191+ { 0, Ukn ITR(1, "?", "") },
9192+ { 0, Ukn ITR(1, "?", "") },
9193+#ifdef CONFIG_ABI_IBCS_WYSE
9194+ { iBCS_class_WYSETCP,Fast ITR(1, "?", "") },
9195+#else
9196+ { 0, Fast ITR(1, "?", "") },
9197+#endif
9198+ { 0, Ukn ITR(1, "?", "") }
9199+};
9200+
9201+#ifdef CONFIG_ABI_IBCS_SCO
9202+static ABI_func SCO_funcs[] = {
9203+ { 0, Ukn ITR(1, "?", "") }, /* 88 */
9204+ { sw_security, 6 ITR(0, "security", "dxxxxx")},/* 89 */
9205+ { SC(symlink), -2 ITR(0, "symlink", "ss") }, /* 90 */
9206+ { abi_lstat, 2 ITR(0, "lstat", "sp") }, /* 91 */
9207+ { SC(readlink), -3 ITR(0, "readlink", "spd") }, /* 92 */
9208+ { 0, Ukn ITR(1, "?", "") }, /* 93 */
9209+ { 0, Ukn ITR(1, "?", "") }, /* 94 */
9210+ { 0, Ukn ITR(1, "?", "") } /* 95 */
9211+};
9212+#endif
9213+
9214+#ifdef CONFIG_ABI_IBCS_WYSE
9215+static ABI_func WYSE_funcs[] = {
9216+ { abi_lstat, 2 ITR(0, "lstat", "sp") }, /* 128 */
9217+ { SC(readlink), -3 ITR(0, "readlink", "spd") }, /* 129 */
9218+ { SC(symlink), -2 ITR(0, "symlink", "ss") }, /* 130 */
9219+ { iBCS_class_WYSETCP,Fast ITR(0, "?", "") }, /* 131 */
9220+ { iBCS_class_WYSENFS,Fast ITR(0, "?", "") }, /* 132 */
9221+ { abi_gethostname, 2 ITR(0, "gethostname", "xd") }, /* 133 */
9222+ { SC(sethostname), -2 ITR(0, "sethostname", "sd") }, /* 134 */
9223+ { abi_getdomainname,2 ITR(0, "getdomainname","xd") }, /* 135 */
9224+ { SC(setdomainname), -2 ITR(0, "setdomainname","sd") }, /* 136 */
9225+ { 0, Ukn ITR(1, "?", "") }, /* 137 */
9226+ { SC(setreuid), -2 ITR(0, "setreuid", "dd") }, /* 138 */
9227+ { SC(setregid), -2 ITR(0, "setregid", "dd") }, /* 139 */
9228+ { 0, Ukn ITR(1, "?", "") }, /* 140 */
9229+ { 0, Ukn ITR(1, "?", "") }, /* 141 */
9230+ { 0, Ukn ITR(1, "?", "") }, /* 142 */
9231+ { 0, Ukn ITR(1, "?", "") } /* 143 */
9232+};
9233+#endif
9234+
9235+static void
9236+iBCS_lcall7(int segment, struct pt_regs * regs)
9237+{
9238+ int i = regs->eax & 0xff;
9239+ ABI_func *p;
9240+
9241+ if (segment == 0x27) {
9242+ printk(KERN_ERR "solaris binary slipped into svr4 handler, exiting\n");
9243+ return;
9244+ }
9245+
9246+#ifdef CONFIG_ABI_IBCS_WYSE
9247+ if (i < 0x88 && i > 0x77 && current->personality == PER_WYSEV386)
9248+ p = &WYSE_funcs[i - 0x78];
9249+ else
9250+#endif
9251+#ifdef CONFIG_ABI_IBCS_SCO
9252+ if (i < 0x60 && i > 0x57 && current->personality == PER_SCOSVR3)
9253+ p = &SCO_funcs[i - 0x58];
9254+ else
9255+#endif
9256+ if (i < 142)
9257+ p = &svr4_generic_funcs[i];
9258+ else
9259+ p = &iBCS_funcs[i - 142];
9260+
9261+ abi_dispatch(regs, p, 1);
9262+}
9263+
9264+extern struct map_segment svr4_err_map[];
9265+extern struct map_segment svr4_socktype_map[];
9266+extern struct map_segment abi_sockopt_map[];
9267+extern struct map_segment abi_af_map[];
9268+
9269+
9270+long linux_to_ibcs_signals[NSIGNALS+1] = {
9271+ 0,
9272+ IBCS_SIGHUP, IBCS_SIGINT, IBCS_SIGQUIT, IBCS_SIGILL,
9273+ IBCS_SIGTRAP, IBCS_SIGABRT, -1, IBCS_SIGFPE,
9274+ IBCS_SIGKILL, IBCS_SIGUSR1, IBCS_SIGSEGV, IBCS_SIGUSR2,
9275+ IBCS_SIGPIPE, IBCS_SIGALRM, IBCS_SIGTERM, IBCS_SIGSEGV,
9276+ IBCS_SIGCHLD, IBCS_SIGCONT, IBCS_SIGSTOP, IBCS_SIGTSTP,
9277+ IBCS_SIGTTIN, IBCS_SIGTTOU, IBCS_SIGURG, IBCS_SIGGXCPU,
9278+ IBCS_SIGGXFSZ, IBCS_SIGVTALRM, IBCS_SIGPROF, IBCS_SIGWINCH,
9279+ IBCS_SIGIO, IBCS_SIGPWR, -1, -1
9280+};
9281+
9282+long ibcs_to_linux_signals[NSIGNALS+1] = {
9283+ 0,
9284+ SIGHUP, SIGINT, SIGQUIT, SIGILL,
9285+ SIGTRAP, SIGIOT, SIGUNUSED, SIGFPE,
9286+ SIGKILL, SIGUNUSED, SIGSEGV, SIGUNUSED,
9287+ SIGPIPE, SIGALRM, SIGTERM, SIGUSR1,
9288+ SIGUSR2, SIGCHLD, SIGPWR, SIGWINCH,
9289+ SIGURG, SIGPOLL, SIGSTOP, SIGTSTP,
9290+ SIGCONT, SIGTTIN, SIGTTOU, SIGVTALRM,
9291+ SIGPROF, SIGXCPU, SIGXFSZ, -1
9292+};
9293+
9294+EXPORT_SYMBOL(linux_to_ibcs_signals);
9295+EXPORT_SYMBOL(ibcs_to_linux_signals);
9296+
9297+#ifdef CONFIG_ABI_IBCS_SCO
9298+static long linux_to_sco_signals[NSIGNALS+1] = {
9299+ 0,
9300+ IBCS_SIGHUP, IBCS_SIGINT, IBCS_SIGQUIT, IBCS_SIGILL,
9301+ IBCS_SIGTRAP, IBCS_SIGABRT, -1, IBCS_SIGFPE,
9302+ IBCS_SIGKILL, IBCS_SIGUSR1, IBCS_SIGSEGV, IBCS_SIGUSR2,
9303+ IBCS_SIGPIPE, IBCS_SIGALRM, IBCS_SIGTERM, IBCS_SIGSEGV,
9304+ IBCS_SIGCHLD, IBCS_SIGCONT, IBCS_SIGSTOP, IBCS_SIGTSTP,
9305+ IBCS_SIGTTIN, IBCS_SIGTTOU, IBCS_SIGUSR1, IBCS_SIGGXCPU,
9306+ IBCS_SIGGXFSZ, IBCS_SIGVTALRM, IBCS_SIGPROF, IBCS_SIGWINCH,
9307+ IBCS_SIGIO, IBCS_SIGPWR, -1, -1
9308+};
9309+
9310+static long sco_to_linux_signals[NSIGNALS+1] = {
9311+ 0,
9312+ SIGHUP, SIGINT, SIGQUIT, SIGILL,
9313+ SIGTRAP, SIGIOT, SIGUNUSED, SIGFPE,
9314+ SIGKILL, SIGUNUSED, SIGSEGV, SIGUNUSED,
9315+ SIGPIPE, SIGALRM, SIGTERM, SIGURG,
9316+ SIGUSR2, SIGCHLD, SIGPWR, SIGWINCH,
9317+ SIGUNUSED, SIGPOLL, SIGSTOP, SIGTSTP,
9318+ SIGCONT, SIGTTIN, SIGTTOU, SIGVTALRM,
9319+ SIGPROF, SIGXCPU, SIGXFSZ, -1
9320+};
9321+#endif
9322+
9323+extern long linux_to_ibcs_signals[];
9324+extern long ibcs_to_linux_signals[];
9325+
9326+
9327+#ifdef CONFIG_ABI_IBCS_ISC
9328+static long linux_to_isc_signals[NSIGNALS+1] = {
9329+ 0,
9330+ IBCS_SIGHUP, IBCS_SIGINT, IBCS_SIGQUIT, IBCS_SIGILL,
9331+ IBCS_SIGTRAP, IBCS_SIGABRT, -1, IBCS_SIGFPE,
9332+ IBCS_SIGKILL, IBCS_SIGUSR1, IBCS_SIGSEGV, IBCS_SIGUSR2,
9333+ IBCS_SIGPIPE, IBCS_SIGALRM, IBCS_SIGTERM, IBCS_SIGSEGV,
9334+ IBCS_SIGCHLD, ISC_SIGCONT, ISC_SIGSTOP, ISC_SIGTSTP,
9335+ IBCS_SIGTTIN, IBCS_SIGTTOU, IBCS_SIGUSR1, IBCS_SIGGXCPU,
9336+ IBCS_SIGGXFSZ, IBCS_SIGVTALRM, IBCS_SIGPROF, IBCS_SIGWINCH,
9337+ IBCS_SIGIO, IBCS_SIGPWR, -1, -1
9338+};
9339+
9340+static long isc_to_linux_signals[NSIGNALS+1] = {
9341+ 0,
9342+ SIGHUP, SIGINT, SIGQUIT, SIGILL,
9343+ SIGTRAP, SIGIOT, SIGUNUSED, SIGFPE,
9344+ SIGKILL, SIGUNUSED, SIGSEGV, SIGUNUSED,
9345+ SIGPIPE, SIGALRM, SIGTERM, SIGUSR1,
9346+ SIGUSR2, SIGCHLD, SIGPWR, SIGWINCH,
9347+ -1, SIGPOLL, SIGCONT, SIGSTOP,
9348+ SIGTSTP, SIGTTIN, SIGTTOU, SIGVTALRM,
9349+ SIGPROF, SIGXCPU, SIGXFSZ, -1
9350+};
9351+#endif /* CONFIG_ABI_IBCS_ISC */
9352+
9353+#ifdef CONFIG_ABI_XENIX
9354+static long linux_to_xnx_signals[NSIGNALS+1] = {
9355+ 0,
9356+ IBCS_SIGHUP, IBCS_SIGINT, IBCS_SIGQUIT, IBCS_SIGILL,
9357+ IBCS_SIGTRAP, IBCS_SIGABRT, -1, IBCS_SIGFPE,
9358+ IBCS_SIGKILL, IBCS_SIGUSR1, IBCS_SIGSEGV, IBCS_SIGUSR2,
9359+ IBCS_SIGPIPE, IBCS_SIGALRM, IBCS_SIGTERM, IBCS_SIGSEGV,
9360+ IBCS_SIGCHLD, IBCS_SIGCONT, IBCS_SIGSTOP, IBCS_SIGTSTP,
9361+ IBCS_SIGTTIN, IBCS_SIGTTOU, IBCS_SIGUSR1, IBCS_SIGGXCPU,
9362+ IBCS_SIGGXFSZ, IBCS_SIGVTALRM, IBCS_SIGPROF, IBCS_SIGWINCH,
9363+ 20 /*XNX_SIGIO*/, IBCS_SIGPWR, -1, -1
9364+};
9365+
9366+static long xnx_to_linux_signals[NSIGNALS+1] = {
9367+ 0,
9368+ SIGHUP, SIGINT, SIGQUIT, SIGILL,
9369+ SIGTRAP, SIGIOT, SIGUNUSED, SIGFPE,
9370+ SIGKILL, SIGUNUSED, SIGSEGV, SIGUNUSED,
9371+ SIGPIPE, SIGALRM, SIGTERM, SIGUSR1,
9372+ SIGUSR2, SIGCHLD, SIGPWR, SIGPOLL,
9373+ -1, -1, -1, -1,
9374+ -1, -1, -1, -1,
9375+ -1, -1, -1, -1
9376+};
9377+#endif
9378+
9379+struct exec_domain ibcs_exec_domain = {
9380+ name: "iBCS2",
9381+ handler: iBCS_lcall7,
9382+ pers_low: 1 /* PER_SVR4 */,
9383+ pers_high: 2 /* PER_SVR3 */,
9384+ signal_map: ibcs_to_linux_signals,
9385+ signal_invmap: linux_to_ibcs_signals,
9386+ err_map: svr4_err_map,
9387+ socktype_map: svr4_socktype_map,
9388+ sockopt_map: abi_sockopt_map,
9389+ af_map: abi_af_map,
9390+ module: THIS_MODULE
9391+};
9392+
9393+#ifdef CONFIG_ABI_IBCS_SCO
9394+struct exec_domain sco_exec_domain = {
9395+ name: "OpenServer",
9396+ handler: iBCS_lcall7,
9397+ pers_low: 3 /* PER_SCOSVR3 */,
9398+ pers_high: 3 /* PER_SCOSVR3 */,
9399+ signal_map: sco_to_linux_signals,
9400+ signal_invmap: linux_to_sco_signals,
9401+ err_map: svr4_err_map,
9402+ socktype_map: svr4_socktype_map,
9403+ sockopt_map: abi_sockopt_map,
9404+ af_map: abi_af_map,
9405+ module: THIS_MODULE
9406+};
9407+#endif
9408+
9409+#ifdef CONFIG_ABI_IBCS_XENIX
9410+struct exec_domain xnx_exec_domain = {
9411+ name: "Xenix",
9412+ handler: iBCS_lcall7,
9413+ pers_low: 7 /* PER_XENIX */,
9414+ pers_high: 7 /* PER_XENIX */,
9415+ signal_map: xnx_to_linux_signals,
9416+ signal_invmap: linux_to_xnx_signals,
9417+ err_map: svr4_err_map,
9418+ socktype_map: svr4_socktype_map,
9419+ sockopt_map: abi_sockopt_map,
9420+ af_map: abi_af_map,
9421+ module: THIS_MODULE
9422+};
9423+#endif
9424+
9425+#ifdef CONFIG_ABI_IBCS_ISC
9426+struct exec_domain isc_exec_domain = {
9427+ name: "ISC",
9428+ handler: iBCS_lcall7,
9429+ pers_low: 5 /* PER_ISCR4 */,
9430+ pers_high: 5 /* PER_ISCR4 */,
9431+ signal_map: isc_to_linux_signals,
9432+ signal_invmap: linux_to_isc_signals,
9433+ err_map: svr4_err_map,
9434+ socktype_map: svr4_socktype_map,
9435+ sockopt_map: abi_sockopt_map,
9436+ af_map: abi_af_map,
9437+ module: THIS_MODULE
9438+};
9439+#endif
9440+
9441+
9442+
9443+static void __exit
9444+ibcs_cleanup(void)
9445+{
9446+#ifdef CONFIG_ABI_IBCS_ISC
9447+ unregister_exec_domain(&isc_exec_domain);
9448+#endif
9449+#ifdef CONFIG_ABI_IBCS_XENIX
9450+ unregister_exec_domain(&xnx_exec_domain);
9451+#endif
9452+#ifdef CONFIG_ABI_IBCS_SCO
9453+ unregister_exec_domain(&sco_exec_domain);
9454+#endif
9455+ unregister_exec_domain(&ibcs_exec_domain);
9456+}
9457+
9458+
9459+static int __init
9460+ibcs_init(void)
9461+{
9462+ register_exec_domain(&ibcs_exec_domain);
9463+#ifdef CONFIG_ABI_IBCS_SCO
9464+ register_exec_domain(&sco_exec_domain);
9465+#endif
9466+#ifdef CONFIG_ABI_IBCS_XENIX
9467+ register_exec_domain(&xnx_exec_domain);
9468+#endif
9469+#ifdef CONFIG_ABI_IBCS_ISC
9470+ register_exec_domain(&isc_exec_domain);
9471+#endif
9472+ return 0;
9473+}
9474+
9475+module_init(ibcs_init);
9476+module_exit(ibcs_cleanup);
9477diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/hrtsys.c linux/abi/svr4/hrtsys.c
9478--- linux-2.4.3/abi/svr4/hrtsys.c Thu Jan 1 01:00:00 1970
9479+++ linux/abi/svr4/hrtsys.c Mon Mar 12 16:34:48 2001
9480@@ -0,0 +1,186 @@
9481+/* $Id$
9482+ *
9483+ * This file contins the emulated SVR4 hrtsys interface
9484+ *
9485+ * Copyright (C) 1994 Eric Youngdale.
9486+ *
9487+ * The hrtsys interface is used by SVR4, and is effectively a way of doing
9488+ * itimer. I do not know why this is used instead of the regular itimer
9489+ * stuff, but it appears to be related to bsd programs/functionality.
9490+ *
9491+ */
9492+
9493+#include <linux/config.h>
9494+#include <linux/module.h>
9495+
9496+#include <asm/uaccess.h>
9497+
9498+#include <linux/ptrace.h>
9499+#include <linux/errno.h>
9500+#include <linux/mm.h>
9501+#include <linux/string.h>
9502+
9503+#include <abi/abi.h>
9504+#include <abi/trace.h>
9505+
9506+
9507+struct hrt_time_t {
9508+ unsigned long secs;
9509+ unsigned long sub_sec; /* Less than one second. */
9510+ unsigned long resolution; /* Resolution of timer */
9511+};
9512+
9513+struct hrtcmd {
9514+ int cmd;
9515+ int clk;
9516+ struct hrt_time_t interval;
9517+ struct hrt_time_t tod;
9518+ int flags;
9519+ int error;
9520+ int reserved[3];
9521+};
9522+
9523+static int
9524+ibcs_hrtcntl (struct pt_regs * regs)
9525+{
9526+ unsigned int param[4];
9527+ struct timeval * tv;
9528+ int i, error;
9529+
9530+ for (i=0; i<4; i++)
9531+ param[i] = get_syscall_parameter (regs, 1+i);
9532+
9533+ if (param[0] != 1 || param[1] != 1 || param[2] != 0)
9534+ return -EINVAL;
9535+
9536+ tv = (struct timeval *) param[3];
9537+
9538+ abi_trace(ABI_TRACE_API, "hrtcntl(0x%lx)\n", (u_long)tv);
9539+
9540+ error = verify_area(VERIFY_WRITE, (char *) tv,sizeof *tv);
9541+ if (error)
9542+ return error;
9543+
9544+ return SYS(gettimeofday)(tv, NULL);
9545+}
9546+
9547+static int
9548+ibcs_hrtalarm (struct pt_regs * regs)
9549+{
9550+ struct itimerval get_buffer;
9551+ struct hrtcmd * hcmd;
9552+ int i, error, cmd, retval, which;
9553+ mm_segment_t old_fs = get_fs();
9554+
9555+ i = get_syscall_parameter (regs, 2);
9556+ if(i != 1)
9557+ return -EINVAL;
9558+
9559+ hcmd = (struct hrtcmd *) get_syscall_parameter (regs, 1);
9560+
9561+ error = verify_area (VERIFY_WRITE, (char *) hcmd,sizeof *hcmd);
9562+ if (error)
9563+ return error;
9564+
9565+ get_user (cmd, ((unsigned long *) hcmd));
9566+
9567+ /* Now figure out which clock we want to fiddle with */
9568+ get_user (which, ((unsigned long *) hcmd)+1);
9569+
9570+ abi_trace(ABI_TRACE_API, "%d hrtalarm(0x%lx %d)",
9571+ (u_long)cmd, which);
9572+
9573+ switch (which) {
9574+ case 4:
9575+ which = 2;
9576+ break;
9577+ case 2:
9578+ which = 1;
9579+ break;
9580+ case 1:
9581+ which = 0;
9582+ break;
9583+ default:
9584+ return -EINVAL;
9585+ };
9586+
9587+ switch (cmd) {
9588+ case 0xc:
9589+ if(({long r; get_user(r, ((unsigned long *) hcmd)+4); r;}) != 1000000)
9590+ return -EINVAL;
9591+ copy_from_user(&get_buffer.it_value, ((unsigned long *) hcmd)+2,
9592+ sizeof(struct timeval));
9593+ memset(&get_buffer.it_interval, 0, sizeof(struct timeval));
9594+ set_fs(get_ds());
9595+ retval = SYS(setitimer)(which, &get_buffer, NULL);
9596+ set_fs(old_fs);
9597+ break;
9598+ case 0xd:
9599+ set_fs(get_ds());
9600+ retval = SYS(getitimer)(which, &get_buffer);
9601+ set_fs(old_fs);
9602+
9603+ abi_trace(ABI_TRACE_API, "hrtalarm(d %lx) %lx %lx %lx %lx",
9604+ (u_long)hcmd,
9605+ get_buffer.it_interval.tv_sec,
9606+ get_buffer.it_interval.tv_usec,
9607+ get_buffer.it_value.tv_sec,
9608+ get_buffer.it_value.tv_usec);
9609+
9610+ put_user(1000000, &hcmd->interval.resolution);
9611+ copy_to_user(((unsigned long *) hcmd)+2, &get_buffer.it_interval,
9612+ sizeof(get_buffer));
9613+ retval = 1;
9614+ break;
9615+ case 0xf:
9616+ if(({long r; get_user(r, ((unsigned long *) hcmd)+4); r;}) != 1000000)
9617+ return -EINVAL;
9618+ if(({long r; get_user(r, ((unsigned long *) hcmd)+7); r;}) != 1000000)
9619+ return -EINVAL;
9620+ copy_from_user(&get_buffer.it_value, &hcmd->tod,
9621+ sizeof(struct timeval));
9622+ copy_from_user(&get_buffer.it_interval, &hcmd->interval,
9623+ sizeof(struct timeval));
9624+ set_fs(get_ds());
9625+ retval = SYS(setitimer)(which, &get_buffer, NULL);
9626+ set_fs(old_fs);
9627+ break;
9628+ case 0x10:
9629+ memset(&get_buffer, 0, sizeof(get_buffer));
9630+ set_fs(get_ds());
9631+ retval = SYS(setitimer)(which, &get_buffer, NULL);
9632+ set_fs(old_fs);
9633+ break;
9634+ default:
9635+ retval = -EINVAL;
9636+ };
9637+
9638+ return retval;
9639+}
9640+
9641+int
9642+svr4_hrtsys (struct pt_regs * regs)
9643+{
9644+ int func, retval;
9645+
9646+ func = get_syscall_parameter (regs, 0);
9647+
9648+ abi_trace(ABI_TRACE_API, "hrtsys(%d)", func);
9649+
9650+ switch (func) {
9651+ case 0:
9652+ retval = ibcs_hrtcntl(regs);
9653+ break;
9654+ case 1:
9655+ retval = ibcs_hrtalarm(regs);
9656+ break;
9657+ case 2:
9658+ case 3:
9659+ default:
9660+ retval = -EINVAL;
9661+ }
9662+
9663+ return retval;
9664+}
9665+
9666+EXPORT_SYMBOL(svr4_hrtsys);
9667diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/ioctl.c linux/abi/svr4/ioctl.c
9668--- linux-2.4.3/abi/svr4/ioctl.c Thu Jan 1 01:00:00 1970
9669+++ linux/abi/svr4/ioctl.c Sun Mar 18 11:54:28 2001
9670@@ -0,0 +1,1212 @@
9671+/* $Id$
9672+ *
9673+ * This file contains a SYSV compatibe ioctl(2) implementation
9674+ *
9675+ * Copyright (C) 1991, 1992 Linus Torvalds
9676+ *
9677+ * Written by Drew Sullivan.
9678+ * Rewritten by Mike Jagdis.
9679+ *
9680+ */
9681+
9682+#include <linux/config.h>
9683+#include <linux/module.h>
9684+#include <linux/version.h>
9685+
9686+#include <asm/uaccess.h>
9687+
9688+#include <linux/errno.h>
9689+#include <linux/stat.h>
9690+#include <linux/fs.h>
9691+#include <linux/sched.h>
9692+#include <linux/kernel.h>
9693+#include <linux/termios.h>
9694+#include <linux/mtio.h>
9695+#include <linux/time.h>
9696+#include <linux/sockios.h>
9697+#include <linux/mm.h>
9698+#include <linux/file.h>
9699+#include <linux/slab.h>
9700+
9701+#include <abi/abi.h>
9702+#include <abi/bsd.h>
9703+#include <abi/stream.h>
9704+#include <abi/tli.h>
9705+#include <abi/svr4.h>
9706+#include <abi/trace.h>
9707+
9708+
9709+#ifdef CONFIG_ABI_IBCS_SCO
9710+static int sco_ioctl_tape(int fd, unsigned int func, unsigned long arg);
9711+#endif
9712+static int bsd_ioctl_file(int fd, unsigned int func, void *arg);
9713+static int ibcs_ioctl_tape(int fd, unsigned int func, unsigned long arg);
9714+static int ibcs_ioctl_termios(int fd, unsigned int func, void *arg);
9715+static int ibcs_ioctl_termio(int fd, unsigned int func, void *arg);
9716+extern int abi_ioctl_console(int fd, unsigned int func, void *arg);
9717+extern int abi_ioctl_video(int fd, unsigned int func, void *arg);
9718+
9719+/* do_ioctl() is a meta mapper, that is
9720+ it looks up the class of the ioctl and then
9721+ dispatchs to lower level routines to handle the
9722+ mapping of the actual ioctls
9723+*/
9724+
9725+static int
9726+do_ioctl(struct pt_regs *regs, int fd, unsigned long ioctl_num, void *arg)
9727+{
9728+ unsigned int class = ioctl_num >> 8;
9729+ char class_str[4];
9730+
9731+ switch (class) {
9732+ case 0: /* SCO ioctls on the pseudo NFS device probably. */
9733+ return abi_ioctl_socksys(fd, ioctl_num, arg);
9734+
9735+ case 'A': /* ??? SCO console keyboard stuff? */
9736+ return -EINVAL;
9737+
9738+#ifdef CONFIG_ABI_IBCS_SCO
9739+ case 'm':
9740+ return sco_ioctl_tape(fd, ioctl_num, (unsigned long)arg);
9741+#endif
9742+ case 't':
9743+ if (personality(PER_SVR4))
9744+ return ibcs_ioctl_tape(fd, ioctl_num, (unsigned long)arg);
9745+ else
9746+ return bsd_ioctl_termios(fd, ioctl_num, arg);
9747+
9748+ case 'f':
9749+ return bsd_ioctl_file(fd, ioctl_num, arg);
9750+
9751+ case 'T': /* xenix ioctl compatibility */
9752+ return ibcs_ioctl_termio(fd, ioctl_num & 0xFF, arg);
9753+
9754+ case ('i' << 16) | ('X' << 8): /* iBCS2 POSIX */
9755+ case 'x': /* Pre-iBCS2 POSIX */
9756+ return ibcs_ioctl_termios(fd, ioctl_num & 0xFF, arg);
9757+
9758+ case 'C':
9759+ case 'c':
9760+ return abi_ioctl_console(fd, ioctl_num, arg);
9761+
9762+ case ('i' << 16) | ('C' << 8): /* iBCS2 POSIX */
9763+ return abi_ioctl_video(fd, ioctl_num & 0xFF, arg);
9764+
9765+ /* SCO 3.2.2 uses ('X'<<8)|1 for access to the video map
9766+ * and the 'X' set is also used for synchronous comm
9767+ * lines (I think?). SVR4 uses it for tty extensions to
9768+ * support hardware flow control and external clocks.
9769+ */
9770+ case 'X':
9771+ if (personality(PER_SVR4) || personality(PER_SOLARIS))
9772+ return svr4_ioctl_termiox(fd, ioctl_num & 0xFF, arg);
9773+ return -EINVAL;
9774+
9775+ /* These aren't implemented and are never likely to be as they
9776+ * are specific to drivers for obscure hardware. (For those
9777+ * that don't know they're the JERQ ioctls. Says it all
9778+ * really!)
9779+ */
9780+ case 'j':
9781+ return -EINVAL;
9782+
9783+ /* The 'S' set could also be display mode switch
9784+ * ioctls in a SCO 3.2.x x<4 environment. It should
9785+ * depend on the descriptor they are applied to.
9786+ * According to ISC the Xenix STREAMS ioctls had the
9787+ * high bit set on the command to differentiate them
9788+ * from mode switch ioctls. Yuk, yuk, yuk...
9789+ */
9790+ case 'S':
9791+ return svr4_ioctl_stream(regs, fd, ioctl_num & 0x7F, arg);
9792+
9793+ /* These are STREAMS socket module ioctls. */
9794+ case 'I':
9795+#if defined(CONFIG_ABI_XTI)
9796+ return svr4_ioctl_sockmod(fd, ioctl_num & 0xFF, arg);
9797+#else
9798+ return -EINVAL;
9799+#endif
9800+
9801+ /* These are SCO <vtkd.h> ioctls - see vtkd.h */
9802+ case 'v':
9803+ case 'K':
9804+ return ibcs_ioctl_vtkd(fd, ioctl_num, arg);
9805+
9806+ /* EUC ioctls. These are something to do with chararcter
9807+ * code set conversions in SVR4. If we don't support
9808+ * them the correct thing to do is to return EINVAL.
9809+ */
9810+ case 'E'|0x80:
9811+ return -EINVAL;
9812+
9813+ /* SCO channel mapping. I can't find any documentation
9814+ * for this. These are the LD?MAP ioctls defined in
9815+ * sys/termio.h and sys/emap.h. They are used by mapchan.
9816+ */
9817+ case 'D':
9818+ return -EINVAL;
9819+ }
9820+
9821+ /* If we haven't handled it yet it must be a BSD style ioctl
9822+ * with a (possible) argument description in the high word of
9823+ * the opcode.
9824+ */
9825+ switch (class & 0xff) {
9826+ /* From SVR4 as specified in sys/iocomm.h */
9827+ case 'f':
9828+ return bsd_ioctl_file(fd, ioctl_num, arg);
9829+
9830+ /* BSD or V7 terminal ioctls. */
9831+ case 't':
9832+ return bsd_ioctl_termios(fd, ioctl_num, arg);
9833+
9834+ /* "Traditional" BSD and Wyse V/386 3.2.1A TCP/IP ioctls. */
9835+ case 's':
9836+ case 'r':
9837+ case 'i':
9838+ return abi_ioctl_socksys(fd, ioctl_num, arg);
9839+
9840+ /* SVR3 streams based socket TCP/IP ioctls.
9841+ * These are handed over to the standard ioctl
9842+ * handler since /dev/socksys is an emulated device
9843+ * and front ends any sockets created through it.
9844+ * Note that 'S' ioctls without the BSDish argument
9845+ * type in the high bytes are STREAMS ioctls and 'I'
9846+ * ioctls without the BSDish type in the high bytes
9847+ * are the STREAMS socket module ioctls. (see above).
9848+ */
9849+ case 'S':
9850+ case 'R':
9851+ case 'I':
9852+ return abi_ioctl_socksys(fd, ioctl_num, arg);
9853+ }
9854+
9855+ /* If nothing has handled it yet someone may have to do some
9856+ * more work...
9857+ */
9858+ class_str[0] = class & 0xFF0000 ? (char)((class >> 16) & 0xFF) : '.';
9859+ class_str[1] = class & 0x00FF00 ? (char)((class >> 8) & 0xFF) : '.';
9860+ class_str[2] = class & 0x0000FF ? (char)((class ) & 0xFF) : '.';
9861+ class_str[3] = 0;
9862+
9863+ printk(KERN_ERR "iBCS: ioctl(%d, %lx[%s], 0x%lx) unsupported\n",
9864+ fd, ioctl_num, class_str, (unsigned long)arg);
9865+
9866+ return -EINVAL;
9867+}
9868+
9869+
9870+/* Some of these are used by SVR3/4 too... */
9871+static int bsd_ioctl_file(int fd, unsigned int func, void *arg)
9872+{
9873+ switch (func) {
9874+ case BSD__IOV('f', 1): case BSD__IO('f', 1): /* FIOCLEX */
9875+ FD_SET(fd, current->files->close_on_exec);
9876+ return 0;
9877+
9878+ case BSD__IOV('f', 2): case BSD__IO('f', 2): /* FIONCLEX */
9879+ FD_CLR(fd, current->files->close_on_exec);
9880+ return 0;
9881+
9882+ case BSD__IOV('f', 3): case BSD__IO('f', 3): { /* FIORDCHK */
9883+ int error, nbytes;
9884+ mm_segment_t old_fs;
9885+
9886+ old_fs = get_fs();
9887+ set_fs (get_ds());
9888+ error = SYS(ioctl)(fd, FIONREAD, &nbytes);
9889+ set_fs(old_fs);
9890+
9891+ return (error <= 0 ? error : nbytes);
9892+ }
9893+
9894+ case BSD__IOW('f', 123, int): /* FGETOWN */
9895+ return SYS(ioctl)(fd, FIOGETOWN, arg);
9896+
9897+ case BSD__IOW('f', 124, int): /* FSETOWN */
9898+ return SYS(ioctl)(fd, FIOSETOWN, arg);
9899+
9900+ case BSD__IOW('f', 125, int): /* FIOASYNC */
9901+ return SYS(ioctl)(fd, FIOASYNC, arg);
9902+
9903+ case BSD__IOW('f', 126, int): /* FIONBIO */
9904+ return SYS(ioctl)(fd, FIONBIO, arg);
9905+
9906+ case BSD__IOR('f', 127, int): /* FIONREAD */
9907+ return SYS(ioctl)(fd, FIONREAD, arg);
9908+ }
9909+
9910+ printk(KERN_ERR "iBCS: file ioctl 0x%08lx unsupported\n",
9911+ (unsigned long)func);
9912+ return -EINVAL;
9913+}
9914+
9915+static int svr_to_linux_termio(int fd, int op, struct svr_termio *it)
9916+{
9917+ struct termio t;
9918+ mm_segment_t old_fs;
9919+ char eof;
9920+ unsigned short lflag;
9921+ int error;
9922+
9923+ error = verify_area(VERIFY_READ, it, sizeof(struct svr_termio));
9924+ if (error)
9925+ return error;
9926+
9927+ old_fs = get_fs();
9928+ set_fs(get_ds());
9929+ error = SYS(ioctl)(fd, TCGETA, &t);
9930+ set_fs(old_fs);
9931+ if (error)
9932+ return error;
9933+
9934+ /* Save things we may need later. */
9935+ eof = t.c_cc[4];
9936+ lflag = t.c_lflag;
9937+
9938+ /* Copy the entire structure then fix up as necessary. */
9939+ copy_from_user(&t, it, sizeof(struct svr_termio));
9940+
9941+ /* If ICANON isn't set then we've been given VMIN in place
9942+ * of VEOF.
9943+ */
9944+ if (!(t.c_lflag & 0000002)) {
9945+ t.c_cc[6] = t.c_cc[4];
9946+ t.c_cc[4] = eof;
9947+ }
9948+
9949+ if (t.c_cflag & 0100000) /* CRTSFL - SCO only? */
9950+ t.c_cflag |= CRTSCTS;
9951+ t.c_cflag &= ~0170000; /* LOBLK|CTSFLOW|RTSFLOW|CRTSFL */
9952+
9953+ set_fs(get_ds());
9954+ error = SYS(ioctl)(fd, op, &t);
9955+ set_fs(old_fs);
9956+
9957+ return error;
9958+}
9959+
9960+static int linux_to_svr_termio(int fd, struct svr_termio *it)
9961+{
9962+ struct termio t;
9963+ mm_segment_t old_fs;
9964+ int error;
9965+
9966+ error = verify_area(VERIFY_WRITE, it, sizeof(struct svr_termio));
9967+ if (error)
9968+ return error;
9969+
9970+ old_fs = get_fs();
9971+ set_fs(get_ds());
9972+ error = SYS(ioctl)(fd, TCGETA, &t);
9973+ set_fs(old_fs);
9974+ if (error)
9975+ return error;
9976+
9977+ /* If ICANON isn't set then we substitute VEOF with VMIN. */
9978+ if (!(t.c_lflag & 0000002)) {
9979+ t.c_cc[4] = t.c_cc[6];
9980+ }
9981+
9982+ /* Copy to the user supplied structure. */
9983+ copy_to_user(it, &t, sizeof(struct svr_termio));
9984+
9985+ return error;
9986+}
9987+
9988+
9989+#ifdef CONFIG_ABI_IBCS_SCO
9990+#define SCO_NCCS (SVR_NCC+5)
9991+struct sco_termios {
9992+ unsigned short c_iflag;
9993+ unsigned short c_oflag;
9994+ unsigned short c_cflag;
9995+ unsigned short c_lflag;
9996+ char c_line;
9997+ unsigned char c_cc[SCO_NCCS];
9998+ char c_ispeed;
9999+ char c_ospeed;
10000+};
10001+static int sco_to_linux_termios(int fd, int op, struct sco_termios *it)
10002+{
10003+ struct termios t;
10004+ mm_segment_t old_fs;
10005+ unsigned short lflag, r;
10006+ char sco_cc[SCO_NCCS];
10007+ int error;
10008+
10009+ error = verify_area(VERIFY_READ, it, sizeof(struct sco_termios));
10010+ if (error)
10011+ return error;
10012+
10013+ old_fs = get_fs();
10014+ set_fs(get_ds());
10015+ error = SYS(ioctl)(fd, TCGETS, &t);
10016+ set_fs(old_fs);
10017+ if (error)
10018+ return error;
10019+
10020+ __get_user(t.c_iflag, &it->c_iflag);
10021+ t.c_iflag &= ~0100000; /* DOSMODE */
10022+
10023+ __get_user(t.c_oflag, &it->c_oflag);
10024+
10025+ __get_user(t.c_cflag, &it->c_cflag);
10026+ if (t.c_cflag & 0100000) /* CRTSFL - SCO only? */
10027+ t.c_cflag |= CRTSCTS;
10028+ t.c_cflag &= ~0170000; /* LOBLK|CTSFLOW|RTSFLOW|CRTSFL */
10029+
10030+ lflag = t.c_lflag;
10031+ t.c_lflag &= ~0100777;
10032+ __get_user(r, &it->c_lflag);
10033+ t.c_lflag |= r;
10034+ if ((t.c_lflag & 0100000))
10035+ SYS(ioctl)(fd, TIOCEXCL, 0);
10036+ else
10037+ SYS(ioctl)(fd, TIOCNXCL, 0);
10038+ t.c_lflag &= ~0100000;
10039+ t.c_lflag |= (t.c_lflag & 0000400) << 7; /* Move IEXTEN */
10040+ t.c_lflag &= ~0000400;
10041+ t.c_lflag |= (t.c_lflag & 0001000) >> 1; /* Move TOSTOP */
10042+ t.c_lflag &= ~0001000;
10043+ t.c_lflag |= (lflag & 0001000); /* Restore ECHOCTL */
10044+
10045+ __get_user(t.c_line, &it->c_line); /* XXX Map this? */
10046+
10047+ copy_from_user(sco_cc, &it->c_cc, SCO_NCCS);
10048+ t.c_cc[0] = sco_cc[0];
10049+ t.c_cc[1] = sco_cc[1];
10050+ t.c_cc[2] = sco_cc[2];
10051+ t.c_cc[3] = sco_cc[3];
10052+ t.c_cc[7] = sco_cc[7];
10053+ t.c_cc[8] = sco_cc[11];
10054+ t.c_cc[9] = sco_cc[12];
10055+ t.c_cc[10] = sco_cc[10];
10056+ t.c_cc[16] = sco_cc[6];
10057+ if (t.c_lflag & ICANON) {
10058+ t.c_cc[4] = sco_cc[4];
10059+ t.c_cc[11] = sco_cc[5];
10060+ } else {
10061+ t.c_cc[4] = sco_cc[8];
10062+ t.c_cc[5] = sco_cc[5];
10063+ t.c_cc[6] = sco_cc[4];
10064+ t.c_cc[11] = sco_cc[9];
10065+ }
10066+
10067+ set_fs(get_ds());
10068+ error = SYS(ioctl)(fd, op, &t);
10069+ set_fs(old_fs);
10070+
10071+ return error;
10072+}
10073+
10074+static int linux_to_sco_termios(int fd, int op, struct sco_termios *it)
10075+{
10076+ struct termios t;
10077+ char sco_cc[SCO_NCCS];
10078+ mm_segment_t old_fs;
10079+ int error;
10080+
10081+ error = verify_area(VERIFY_WRITE, it, sizeof(struct sco_termios));
10082+ if (error)
10083+ return error;
10084+
10085+ old_fs = get_fs();
10086+ set_fs(get_ds());
10087+ error = SYS(ioctl)(fd, op, &t);
10088+ set_fs(old_fs);
10089+ if (error)
10090+ return error;
10091+
10092+ put_user(t.c_iflag & 0017777, &it->c_iflag);
10093+
10094+ put_user(t.c_oflag & 0177777, &it->c_oflag);
10095+
10096+ if (t.c_cflag & CRTSCTS)
10097+ t.c_cflag |= 0100000; /* CRTSFL - SCO only? */
10098+ put_user(t.c_cflag & 0177777, &it->c_cflag);
10099+
10100+ t.c_lflag &= ~0001000;
10101+ t.c_lflag |= (t.c_lflag & 0000400) << 1;
10102+ t.c_lflag &= ~0000400;
10103+ t.c_lflag |= (t.c_lflag & 0100000) >> 7;
10104+ t.c_lflag &= ~0100000;
10105+ put_user(t.c_lflag & 0001777, &it->c_lflag);
10106+
10107+ put_user(t.c_line, &it->c_line); /* XXX Map this? */
10108+
10109+ sco_cc[0] = t.c_cc[0];
10110+ sco_cc[1] = t.c_cc[1];
10111+ sco_cc[2] = t.c_cc[2];
10112+ sco_cc[3] = t.c_cc[3];
10113+ sco_cc[6] = t.c_cc[16];
10114+ sco_cc[7] = t.c_cc[7];
10115+ sco_cc[8] = t.c_cc[4];
10116+ sco_cc[9] = t.c_cc[11];
10117+ sco_cc[10] = t.c_cc[10];
10118+ sco_cc[11] = t.c_cc[8];
10119+ sco_cc[12] = t.c_cc[9];
10120+ if (t.c_lflag & ICANON) {
10121+ sco_cc[4] = t.c_cc[4];
10122+ sco_cc[5] = t.c_cc[11];
10123+ } else {
10124+ sco_cc[4] = t.c_cc[6];
10125+ sco_cc[5] = t.c_cc[5];
10126+ }
10127+
10128+ copy_to_user(&it->c_cc, sco_cc, SCO_NCCS);
10129+
10130+ return error;
10131+}
10132+#endif /* CONFIG_ABI_IBCS_SCO */
10133+
10134+
10135+/* XXX This is just copied from SCO above. There are minor differences
10136+ * but not in any of the critical flags and non of them overlap - I think.
10137+ */
10138+
10139+static int svr4_to_linux_termios(int fd, int op, struct svr4_termios *it)
10140+{
10141+ struct termios t;
10142+ mm_segment_t old_fs;
10143+ unsigned short lflag, r;
10144+ char svr4_cc[SVR4_NCCS];
10145+ int error;
10146+
10147+ error = verify_area(VERIFY_READ, it, sizeof(struct svr4_termios));
10148+ if (error)
10149+ return error;
10150+
10151+ old_fs = get_fs();
10152+ set_fs(get_ds());
10153+ error = SYS(ioctl)(fd, TCGETS, &t);
10154+ set_fs(old_fs);
10155+ if (error)
10156+ return error;
10157+
10158+ __get_user(t.c_iflag, &it->c_iflag);
10159+ t.c_iflag &= ~0100000; /* DOSMODE */
10160+
10161+ __get_user(t.c_oflag, &it->c_oflag);
10162+
10163+ __get_user(t.c_cflag, &it->c_cflag);
10164+ if (t.c_cflag & 0100000) /* CRTSFL - SCO only? */
10165+ t.c_cflag |= CRTSCTS;
10166+ t.c_cflag &= ~0170000; /* LOBLK|CTSFLOW|RTSFLOW|CRTSFL */
10167+
10168+ lflag = t.c_lflag;
10169+ t.c_lflag &= ~0100777;
10170+ __get_user(r, &it->c_lflag);
10171+ t.c_lflag |= r;
10172+ if ((t.c_lflag & 0100000))
10173+ SYS(ioctl)(fd, TIOCEXCL, 0);
10174+ else
10175+ SYS(ioctl)(fd, TIOCNXCL, 0);
10176+ t.c_lflag &= ~0100000;
10177+ t.c_lflag |= (t.c_lflag & 0000400) << 7; /* Move IEXTEN */
10178+ t.c_lflag &= ~0000400;
10179+ t.c_lflag |= (t.c_lflag & 0001000) >> 1; /* Move TOSTOP */
10180+ t.c_lflag &= ~0001000;
10181+ t.c_lflag |= (lflag & 0001000); /* Restore ECHOCTL */
10182+
10183+ copy_from_user(svr4_cc, &it->c_cc, SVR4_NCCS);
10184+ t.c_cc[0] = svr4_cc[0];
10185+ t.c_cc[1] = svr4_cc[1];
10186+ t.c_cc[2] = svr4_cc[2];
10187+ t.c_cc[3] = svr4_cc[3];
10188+ t.c_cc[7] = svr4_cc[7];
10189+ t.c_cc[8] = svr4_cc[8];
10190+ t.c_cc[9] = svr4_cc[9];
10191+ t.c_cc[10] = svr4_cc[10];
10192+ t.c_cc[12] = svr4_cc[12];
10193+ t.c_cc[13] = svr4_cc[13];
10194+ t.c_cc[14] = svr4_cc[14];
10195+ t.c_cc[15] = svr4_cc[15];
10196+ t.c_cc[16] = svr4_cc[16];
10197+ if (t.c_lflag & ICANON) {
10198+ t.c_cc[4] = svr4_cc[4];
10199+ t.c_cc[11] = svr4_cc[5];
10200+ } else {
10201+ t.c_cc[5] = svr4_cc[5];
10202+ t.c_cc[6] = svr4_cc[4];
10203+ t.c_cc[11] = svr4_cc[6];
10204+ }
10205+
10206+ set_fs(get_ds());
10207+ error = SYS(ioctl)(fd, op, &t);
10208+ set_fs(old_fs);
10209+
10210+ return error;
10211+}
10212+
10213+static int linux_to_svr4_termios(int fd, int op, struct svr4_termios *it)
10214+{
10215+ struct termios t;
10216+ char svr4_cc[SVR4_NCCS];
10217+ mm_segment_t old_fs;
10218+ int error;
10219+
10220+ error = verify_area(VERIFY_WRITE, it, sizeof(struct svr4_termios));
10221+ if (error)
10222+ return error;
10223+
10224+ old_fs = get_fs();
10225+ set_fs(get_ds());
10226+ error = SYS(ioctl)(fd, op, &t);
10227+ set_fs(old_fs);
10228+ if (error)
10229+ return error;
10230+
10231+ put_user(t.c_iflag & 0017777, &it->c_iflag);
10232+
10233+ put_user(t.c_oflag & 0177777, &it->c_oflag);
10234+
10235+ if (t.c_cflag & CRTSCTS)
10236+ t.c_cflag |= 0100000; /* CRTSFL - SCO only? */
10237+ put_user(t.c_cflag & 0177777, &it->c_cflag);
10238+
10239+ t.c_lflag &= ~0001000;
10240+ t.c_lflag |= (t.c_lflag & 0000400) << 1;
10241+ t.c_lflag &= ~0000400;
10242+ t.c_lflag |= (t.c_lflag & 0100000) >> 7;
10243+ t.c_lflag &= ~0100000;
10244+ put_user(t.c_lflag & 0001777, &it->c_lflag);
10245+
10246+ svr4_cc[0] = t.c_cc[0];
10247+ svr4_cc[1] = t.c_cc[1];
10248+ svr4_cc[2] = t.c_cc[2];
10249+ svr4_cc[3] = t.c_cc[3];
10250+ svr4_cc[6] = t.c_cc[16];
10251+ svr4_cc[7] = t.c_cc[7];
10252+ svr4_cc[8] = t.c_cc[8];
10253+ svr4_cc[9] = t.c_cc[9];
10254+ svr4_cc[10] = t.c_cc[10];
10255+ svr4_cc[11] = t.c_cc[10];
10256+ svr4_cc[12] = t.c_cc[12];
10257+ svr4_cc[13] = t.c_cc[13];
10258+ svr4_cc[14] = t.c_cc[14];
10259+ svr4_cc[15] = t.c_cc[15];
10260+ if (t.c_lflag & ICANON) {
10261+ svr4_cc[4] = t.c_cc[4];
10262+ svr4_cc[5] = t.c_cc[11];
10263+ } else {
10264+ svr4_cc[4] = t.c_cc[6];
10265+ svr4_cc[5] = t.c_cc[5];
10266+ }
10267+
10268+ copy_to_user(&it->c_cc, svr4_cc, SVR4_NCCS);
10269+
10270+ return error;
10271+}
10272+
10273+
10274+static int ibcs_ioctl_termios(int fd, unsigned int func, void *arg)
10275+{
10276+#ifdef CONFIG_ABI_IBCS_SCO
10277+ switch(func) {
10278+ case 1: /* XCGETA */
10279+ return linux_to_sco_termios(fd, TCGETS, arg);
10280+ case 2: /* XCSETA */
10281+ return sco_to_linux_termios(fd, TCSETS, arg);
10282+ case 3: /* XCSETAW */
10283+ return sco_to_linux_termios(fd, TCSETSW, arg);
10284+ case 4: /* XCSETAF */
10285+ return sco_to_linux_termios(fd, TCSETSF, arg);
10286+ }
10287+#endif
10288+ printk(KERN_ERR "iBCS: SCO termios ioctl %d unsupported\n", func);
10289+ return -EINVAL;
10290+}
10291+
10292+static int ibcs_ioctl_termio(int fd, unsigned int func, void *arg)
10293+{
10294+ switch(func) {
10295+ case 1: /* TCGETA (TIOC|1) */
10296+ return linux_to_svr_termio(fd, arg);
10297+
10298+ case 2: /* TCSETA (TIOC|2) */
10299+ return svr_to_linux_termio(fd, TCSETA, arg);
10300+ case 3: /* TCSETAW (TIOC|3) */
10301+ return svr_to_linux_termio(fd, TCSETAW, arg);
10302+ case 4: /* TCSETAF (TIOC|4) */
10303+ return svr_to_linux_termio(fd, TCSETAF, arg);
10304+
10305+ case 5: /* TCSBRK (TIOC|5) */
10306+ return SYS(ioctl)(fd, TCSBRK, arg);
10307+ case 6: /* TCXONC (TIOC|6) */
10308+ return SYS(ioctl)(fd, TCXONC, arg);
10309+ case 7: /* TCFLSH (TIOC|7) */
10310+ return SYS(ioctl)(fd, TCFLSH, arg);
10311+
10312+ /* This group appear in SVR4 but not SVR3 (SCO). */
10313+ case 8: /* TIOCKBON */
10314+ case 9: /* TIOCKBOF */
10315+ case 10: /* KBENABLED */
10316+ return -EINVAL;
10317+
10318+ /* This set is used by SVR4 for termios ioctls. */
10319+ case 13: /* TCGETS */
10320+ return linux_to_svr4_termios(fd, TCGETS, arg);
10321+ case 14: /* TCSETS */
10322+ return svr4_to_linux_termios(fd, TCSETS, arg);
10323+ case 15: /* TCSETSW */
10324+ return svr4_to_linux_termios(fd, TCSETSW, arg);
10325+ case 16: /* TCSETSF */
10326+ return svr4_to_linux_termios(fd, TCSETSF, arg);
10327+
10328+ /* These two are specific to ISC. */
10329+ case 20: /* TCSETPGRP (TIOC|20) set pgrp of tty */
10330+ return SYS(ioctl)(fd, TIOCSPGRP, arg);
10331+ case 21: /* TCGETPGRP (TIOC|21) get pgrp of tty */
10332+ return SYS(ioctl)(fd, TIOCGPGRP, arg);
10333+
10334+ case 34: /* TCGETSC (TIOC|34) ioctl for scancodes */
10335+ return 0x04; /* Translates scancode to ascii */
10336+ case 35: /* TCSETSC (TIOC|35) ioctl for scancodes */
10337+ return 0;
10338+
10339+ case 103: /* TIOCSWINSZ (TIOC|103) */
10340+ return SYS(ioctl)(fd, TIOCSWINSZ, arg);
10341+ case 104: /* TIOCGWINSZ (TIOC|104) */
10342+ return SYS(ioctl)(fd, TIOCGWINSZ, arg);
10343+
10344+ case 118: /* TIOCSPGRP (TIOC|118) set pgrp of tty */
10345+ return SYS(ioctl)(fd, TIOCSPGRP, arg);
10346+ case 119: /* TIOCGPGRP (TIOC|119) get pgrp of tty */
10347+ return SYS(ioctl)(fd, TIOCGPGRP, arg);
10348+
10349+ case 32: /* TCDSET (TIOC|32) */
10350+ case 33: /* RTS_TOG (TIOC|33) 386 - "RTS" toggle define 8A1 protocol */
10351+
10352+ case 120: /* TIOSETSAK (TIOC|120) set SAK sequence for tty */
10353+ case 121: /* TIOGETSAK (TIOC|121) get SAK sequence for tty */
10354+ printk(KERN_ERR "iBCS: termio ioctl %d unimplemented\n",
10355+ func);
10356+ return -EINVAL;
10357+ }
10358+ printk(KERN_ERR "iBCS: termio ioctl %d unsupported\n", func);
10359+ return -EINVAL;
10360+}
10361+
10362+struct termiox {
10363+ unsigned short x_hflag;
10364+ unsigned short x_cflag;
10365+ unsigned short x_rflag[5];
10366+ unsigned short x_sflag;
10367+};
10368+
10369+#define RTSXOFF 0x0001
10370+#define CTSXON 0x0002
10371+
10372+int svr4_ioctl_termiox(int fd, unsigned int func, void *arg)
10373+{
10374+ struct termios t;
10375+ struct termiox tx;
10376+ mm_segment_t old_fs;
10377+ int error;
10378+
10379+ if (func < 1 || func > 4)
10380+ return -EINVAL;
10381+
10382+ error = verify_area(func == 1 ? VERIFY_WRITE : VERIFY_READ,
10383+ arg, sizeof(struct termiox));
10384+ if (error)
10385+ return error;
10386+
10387+ old_fs = get_fs();
10388+ set_fs(get_ds());
10389+ error = SYS(ioctl)(fd, TCGETS, &t);
10390+ set_fs(old_fs);
10391+ if (error)
10392+ return error;
10393+
10394+ if (func == 1) { /* TCGETX */
10395+ memset(&tx, '\0', sizeof(struct termiox));
10396+ if (t.c_cflag & CRTSCTS)
10397+ tx.x_hflag = RTSXOFF|CTSXON;
10398+ copy_to_user(arg, &tx, sizeof(struct termiox));
10399+ return 0;
10400+ }
10401+
10402+ copy_from_user(&tx, arg, sizeof(struct termiox));
10403+ if ((tx.x_hflag != 0 && tx.x_hflag != (RTSXOFF|CTSXON))
10404+ || tx.x_cflag || tx.x_rflag[0] || tx.x_rflag[1]
10405+ || tx.x_rflag[2] || tx.x_rflag[3] || tx.x_rflag[4]
10406+ || tx.x_sflag)
10407+ return -EINVAL;
10408+
10409+ if (tx.x_hflag)
10410+ t.c_cflag |= CRTSCTS;
10411+ else
10412+ t.c_cflag &= (~CRTSCTS);
10413+
10414+ old_fs = get_fs();
10415+ set_fs(get_ds());
10416+ switch (func) {
10417+ case 2: /* TCSETX */
10418+ error = SYS(ioctl)(fd, TCSETS, &t);
10419+ break;
10420+ case 3: /* TCSETXW */
10421+ error = SYS(ioctl)(fd, TCSETSW, &t);
10422+ break;
10423+ case 4: /* TCSETXF */
10424+ error = SYS(ioctl)(fd, TCSETSF, &t);
10425+ break;
10426+ }
10427+ set_fs(old_fs);
10428+ return error;
10429+}
10430+EXPORT_SYMBOL(svr4_ioctl_termiox);
10431+
10432+
10433+int svr4_ioctl_stream(struct pt_regs *regs, int fd, unsigned int func, void *arg)
10434+{
10435+ struct file *filep;
10436+ struct inode *ino;
10437+ int error;
10438+
10439+ filep = fget(fd);
10440+ if (!filep)
10441+ return -EBADF;
10442+ ino = filep->f_dentry->d_inode;
10443+
10444+ if (ino && !ino->i_sock
10445+ && MAJOR(ino->i_rdev) == SOCKSYS_MAJOR) {
10446+ error = abi_socksys_fd_init(fd, 0, NULL, NULL);
10447+ if (error < 0)
10448+ return error;
10449+ fput(filep);
10450+ filep = fget(fd);
10451+ if (!filep)
10452+ return -EBADF;
10453+ ino = filep->f_dentry->d_inode;
10454+ }
10455+
10456+ switch (func) {
10457+ case 001: /* I_NREAD */
10458+ error = verify_area(VERIFY_WRITE,
10459+ arg, sizeof(unsigned long));
10460+ if (error) {
10461+ fput(filep);
10462+ return error;
10463+ }
10464+#ifdef CONFIG_ABI_XTI
10465+ if (ino->i_sock && MAJOR(ino->i_rdev) == SOCKSYS_MAJOR)
10466+ timod_update_socket(fd, filep, regs);
10467+
10468+ if (ino->i_sock
10469+ && Priv(filep) && Priv(filep)->pfirst) {
10470+ put_user(Priv(filep)->pfirst->length,
10471+ (unsigned long *)arg);
10472+ fput(filep);
10473+ return 1; /* at least 1... (FIXME) */
10474+ }
10475+#endif
10476+ fput(filep);
10477+ error = SYS(ioctl)(fd, TIOCINQ, arg);
10478+ if (error == -EINVAL)
10479+ return 0;
10480+ if (error)
10481+ return error;
10482+ __get_user(error, (unsigned long *)arg);
10483+ return (error == 0 ? 0 : 1);
10484+
10485+ case 017: { /* I_PEEK */
10486+#ifdef CONFIG_ABI_XTI
10487+ struct strpeek buf;
10488+
10489+ error = verify_area(VERIFY_WRITE,
10490+ arg, sizeof(struct strpeek));
10491+ if (error) {
10492+ fput(filep);
10493+ return error;
10494+ }
10495+ copy_from_user(&buf, arg, sizeof(buf));
10496+
10497+ if (ino->i_sock && MAJOR(ino->i_rdev) == SOCKSYS_MAJOR)
10498+ timod_update_socket(fd, filep, regs);
10499+
10500+ if (ino->i_sock
10501+ && Priv(filep) && Priv(filep)->pfirst
10502+ && (!buf.flags || buf.flags == Priv(filep)->pfirst->pri)) {
10503+ int l = buf.ctl.maxlen <= Priv(filep)->pfirst->length
10504+ ? buf.ctl.maxlen
10505+ : Priv(filep)->pfirst->length;
10506+ error = verify_area(VERIFY_WRITE,
10507+ buf.ctl.buf, l);
10508+ if (error) {
10509+ fput(filep);
10510+ return error;
10511+ }
10512+ copy_to_user(buf.ctl.buf,
10513+ ((char *)&Priv(filep)->pfirst->type)
10514+ + Priv(filep)->offset, l);
10515+ put_user(l, &((struct strpeek *)arg)->ctl.len);
10516+ if (buf.dat.maxlen >= 0)
10517+ put_user(0, &((struct strpeek *)arg)->dat.len);
10518+ put_user(Priv(filep)->pfirst->pri,
10519+ &((struct strpeek *)arg)->flags);
10520+ fput(filep);
10521+ return 1;
10522+ }
10523+ /* FIXME: I think we should also be able to peek
10524+ * at data as well?
10525+ */
10526+#endif
10527+ fput(filep);
10528+ return 0; /* Nothing to peek at. */
10529+ }
10530+ }
10531+
10532+ fput(filep);
10533+
10534+ switch (func) {
10535+ case 010: { /* I_STR */
10536+ /* Unpack the ioctl data and forward as a normal
10537+ * ioctl. Timeouts are not handled (yet?).
10538+ */
10539+ struct strioctl {
10540+ int cmd, timeout, len;
10541+ char *data;
10542+ } it;
10543+
10544+ error = verify_area(VERIFY_READ,
10545+ arg, sizeof(struct strioctl));
10546+ if (error)
10547+ return error;
10548+ copy_from_user(&it, arg, sizeof(struct strioctl));
10549+
10550+ abi_trace(ABI_TRACE_STREAMS,
10551+ "STREAMS I_STR ioctl(%d, 0x%08lx, 0x%08lx)",
10552+ fd, (u_long)it.cmd, (u_long)it.data);
10553+
10554+ switch (it.cmd >> 8) {
10555+ case 'T':/* timod */
10556+#ifdef CONFIG_ABI_XTI
10557+ return timod_ioctl(regs,
10558+ fd, it.cmd & 0xff,
10559+ it.data, it.len,
10560+ &((struct strioctl *)arg)->len);
10561+#else
10562+ return -EINVAL;
10563+#endif
10564+ default:
10565+ return do_ioctl(regs, fd, it.cmd, it.data);
10566+ }
10567+ }
10568+
10569+ case 002: { /* I_PUSH */
10570+ char *tmp;
10571+
10572+ /* Get the name anyway to validate it. */
10573+ tmp = getname(arg);
10574+ if (IS_ERR(tmp))
10575+ return PTR_ERR(tmp);
10576+
10577+ abi_trace(ABI_TRACE_STREAMS,
10578+ "%d STREAMS I_PUSH %s", fd, tmp);
10579+
10580+ putname(tmp);
10581+ return 0;
10582+ }
10583+
10584+ case 003: /* I_POP */
10585+ abi_trace(ABI_TRACE_STREAMS, "%d STREAMS I_POP", fd);
10586+ return 0;
10587+
10588+ case 005: /* I_FLUSH */
10589+ return 0;
10590+
10591+ case 013: { /* I_FIND */
10592+ char *tmp;
10593+
10594+ /* Get the name anyway to validate it. */
10595+ tmp = getname(arg);
10596+ if (IS_ERR(tmp))
10597+ return PTR_ERR(tmp);
10598+
10599+ abi_trace(ABI_TRACE_STREAMS,
10600+ "%d STREAMS I_FIND %s", fd, tmp);
10601+#ifdef CONFIG_ABI_XTI
10602+ if (!strcmp(tmp, "timod")) {
10603+ putname(tmp);
10604+ return 1;
10605+ }
10606+#endif
10607+ putname(tmp);
10608+ return 0;
10609+ }
10610+
10611+ /* FIXME: These are bogus. */
10612+ case 011: /* I_SETSIG */
10613+ return SYS(ioctl)(fd, FIOSETOWN, current->pid);
10614+ case 012: /* I_GETSIG */
10615+ return SYS(ioctl)(fd, FIOGETOWN, arg);
10616+
10617+ case 020: /* I_FDINSERT */
10618+#ifdef CONFIG_ABI_XTI
10619+ return stream_fdinsert(regs, fd,
10620+ (struct strfdinsert *)arg);
10621+#else
10622+ return -EINVAL;
10623+#endif
10624+
10625+ case 004: /* I_LOOK */
10626+ case 006: /* I_SRDOPT */
10627+ case 007: /* I_GRDOPT */
10628+ case 014: /* I_LINK */
10629+ case 015: /* I_UNLINK */
10630+ case 021: /* I_SENDFD */
10631+ case 022: /* I_RECVFD */
10632+ case 023: /* I_SWROPT */
10633+ case 040: /* I_SETCLTIME */
10634+ return 0; /* Lie... */
10635+ case 042: /* I_CANPUT */
10636+ /* Arg is the priority band in question. We only
10637+ * support one priority band so arg must be 0.
10638+ * If the band is writable we should return 1, if
10639+ * the band is flow controlled we should return 0.
10640+ */
10641+ if (arg)
10642+ return -EINVAL;
10643+
10644+ /* FIXME: How can we test if a write would block? */
10645+ return 1;
10646+
10647+ case 024: /* I_GWROPT */
10648+ case 025: /* I_LIST */
10649+ case 026: /* I_PLINK */
10650+ case 027: /* I_PUNLINK */
10651+ case 030: /* I_SETEV */
10652+ case 031: /* I_GETEV */
10653+ case 032: /* I_STREV */
10654+ case 033: /* I_UNSTREV */
10655+ case 034: /* I_FLUSHBAND */
10656+ case 035: /* I_CKBAND */
10657+ case 036: /* I_GETBAND */
10658+ case 037: /* I_ATMARK */
10659+ case 041: /* I_GETCLTIME */
10660+ /* Unsupported - drop out. */
10661+ }
10662+ printk(KERN_ERR "iBCS: STREAMS ioctl 0%o unsupported\n", func);
10663+ return -EINVAL;
10664+}
10665+
10666+EXPORT_SYMBOL(svr4_ioctl_stream);
10667+
10668+
10669+#ifdef CONFIG_ABI_IBCS_SCO
10670+static int sco_ioctl_tape(int fd, unsigned int func, unsigned long arg)
10671+{
10672+ mm_segment_t old_fs;
10673+ int error;
10674+ struct mtop mtop;
10675+
10676+ mtop.mt_count = 1;
10677+
10678+ switch (func & 0xff) {
10679+ case 1: /* MT_RESET */
10680+ mtop.mt_op = MTRESET;
10681+ break;
10682+
10683+ case 2: /* MT_RETEN */
10684+ mtop.mt_op = MTRETEN;
10685+ break;
10686+
10687+ case 3: /* MT_REWIND */
10688+ mtop.mt_op = MTREW;
10689+ break;
10690+
10691+ case 4: /* MT_ERASE */
10692+ case 23: /* HP_ERASE */
10693+ mtop.mt_op = MTERASE;
10694+ break;
10695+
10696+ case 6: /* MT_RFM */
10697+ mtop.mt_op = MTFSF;
10698+ break;
10699+
10700+ case 7: /* MT_WFM */
10701+ mtop.mt_op = MTWEOF;
10702+ break;
10703+
10704+ case 8: /* MT_LOAD */
10705+ mtop.mt_op = MTLOAD;
10706+ break;
10707+
10708+ case 9: /* MT_UNLOAD */
10709+ mtop.mt_op = MTOFFL;
10710+ break;
10711+
10712+ case 19: /* MT_RSM */
10713+ mtop.mt_op = MTFSS;
10714+ break;
10715+
10716+ case 20: /* MT_WSM */
10717+ mtop.mt_op = MTWSM;
10718+ break;
10719+
10720+ case 21: /* MT_EOD */
10721+ mtop.mt_op = MTEOM;
10722+ break;
10723+
10724+ case 24: /* MT_SETBLK */
10725+ mtop.mt_op = MTSETBLK;
10726+ mtop.mt_count = arg;
10727+ break;
10728+
10729+ case 25: /* MT_LOCK */
10730+ mtop.mt_op = MTLOCK;
10731+ break;
10732+
10733+ case 26: /* MT_UNLOCK */
10734+ mtop.mt_op = MTUNLOCK;
10735+ break;
10736+
10737+
10738+#if 0
10739+/* The following function codes are just copied from the SCO
10740+ include file.
10741+*/
10742+ case 0: /* MT_STATUS */
10743+ case 5: /* MT_AMOUNT */
10744+ case 10: /* MT_DSTATUS */
10745+ case 11: /* MT_FORMAT */
10746+ case 12: /* MT_GETHDR */
10747+ case 13: /* MT_PUTHDR */
10748+ case 14: /* MT_GETNEWBB */
10749+ case 15: /* MT_PUTNEWBB */
10750+ case 16: /* MT_GETVTBL */
10751+ case 17: /* MT_PUTVTBL */
10752+ case 18: /* MT_SERVO */
10753+ case 22: /* MT_FORMPART */
10754+ case 38: /* MT_SETANSI */
10755+ case 64: /* MT_REPORT */
10756+#endif
10757+ default:
10758+ printk (KERN_ERR "iBCS: SCO tape ioctl func=%d arg=%x unsupported\n",
10759+ func & 0xff, (int) arg);
10760+ return -EINVAL;
10761+ }
10762+
10763+ old_fs = get_fs ();
10764+ set_fs (get_ds ());
10765+ error = SYS (ioctl) (fd, MTIOCTOP, &mtop);
10766+ set_fs (old_fs);
10767+ return error;
10768+}
10769+#endif
10770+
10771+static int ibcs_ioctl_tape(int fd, unsigned int func, unsigned long arg)
10772+{
10773+ mm_segment_t old_fs;
10774+ int error;
10775+ struct mtop mtop;
10776+
10777+ mtop.mt_count = 1;
10778+
10779+ switch (func & 0xff) {
10780+ case 1: /* MT_RETEN */
10781+ mtop.mt_op = MTRETEN;
10782+ break;
10783+
10784+ case 2: /* MT_REWIND */
10785+ mtop.mt_op = MTREW;
10786+ break;
10787+
10788+ case 3: /* MT_ERASE */
10789+ mtop.mt_op = MTERASE;
10790+ break;
10791+
10792+ case 4: /* MT_WFM */
10793+ mtop.mt_op = MTWEOF;
10794+ break;
10795+
10796+ case 5: /* MT_RESET */
10797+ mtop.mt_op = MTRESET;
10798+ break;
10799+
10800+ case 7: /* T_SFF */
10801+ mtop.mt_op = MTFSF;
10802+ break;
10803+
10804+ case 8: /* T_SBF */
10805+ mtop.mt_op = MTBSF;
10806+ break;
10807+
10808+ case 9: /* T_LOAD */
10809+ mtop.mt_op = MTLOAD;
10810+ break;
10811+
10812+ case 10: /* MT_UNLOAD */
10813+ mtop.mt_op = MTOFFL;
10814+ break;
10815+
10816+ case 15: /* T_WRBLKLEN */
10817+ mtop.mt_op = MTLOCK;
10818+ mtop.mt_count = arg;
10819+ break;
10820+
10821+ case 16: /* T_PREVMV */
10822+ mtop.mt_op = MTLOCK;
10823+ break;
10824+
10825+ case 17: /* T_ALLOMV */
10826+ mtop.mt_op = MTUNLOCK;
10827+ break;
10828+
10829+ case 20: /* T_EOD */
10830+ mtop.mt_count = arg;
10831+ mtop.mt_op = MTEOM;
10832+ break;
10833+
10834+ case 21: /* T_SSFB */
10835+ mtop.mt_count = arg;
10836+ mtop.mt_op = MTBSFM;
10837+ break;
10838+
10839+ case 22: /* T_SSFF */
10840+ mtop.mt_count = arg;
10841+ mtop.mt_op = MTFSFM;
10842+ break;
10843+
10844+ case 24: /* T_STD */
10845+ mtop.mt_count = arg;
10846+ mtop.mt_op = MTSETDENSITY;
10847+ break;
10848+
10849+#if 0
10850+ case 6: /* T_STATUS */
10851+ case 14: /* T_RDBLKLEN */
10852+ case 18: /* T_SBB */
10853+ case 19: /* T_SFB */
10854+ case 23: /* T_STS */
10855+#endif
10856+ default:
10857+ printk (KERN_ERR "iBCS: SYSV tape ioctl func=%d arg=%x unsupported\n",
10858+ func & 0xff, (int) arg);
10859+ return -EINVAL;
10860+ }
10861+
10862+ old_fs = get_fs ();
10863+ set_fs (get_ds ());
10864+ error = SYS (ioctl) (fd, MTIOCTOP, &mtop);
10865+ set_fs (old_fs);
10866+ return error;
10867+}
10868+
10869+
10870+int svr4_ioctl(struct pt_regs * regs)
10871+{
10872+ int fd;
10873+ unsigned int ioctl_num;
10874+ void *arg;
10875+
10876+ fd = (int)get_syscall_parameter (regs, 0);
10877+ ioctl_num = (unsigned int)get_syscall_parameter (regs, 1);
10878+ arg = (void *)get_syscall_parameter (regs, 2);
10879+ return do_ioctl(regs, fd, ioctl_num, arg);
10880+}
10881+
10882+EXPORT_SYMBOL(svr4_ioctl);
10883diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/ipc.c linux/abi/svr4/ipc.c
10884--- linux-2.4.3/abi/svr4/ipc.c Thu Jan 1 01:00:00 1970
10885+++ linux/abi/svr4/ipc.c Fri Mar 30 15:23:46 2001
10886@@ -0,0 +1,942 @@
10887+/* $Id$
10888+ *
10889+ * Thiss file contains the emulated SYSV IPC impementation
10890+ *
10891+ * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
10892+ *
10893+ * Massive work over with a fine tooth comb, lots of rewriting. There
10894+ * were a *lot* of bugs in this - mismatched structs that weren't
10895+ * mapped, wrong pointers etc. I've tested this version with the
10896+ * demo programs from the Wyse V/386 IPC documentation which exercise
10897+ * all the functions. I don't have any major IPC using applications
10898+ * to test it with - as far as I know...
10899+ *
10900+ * Original copyright etc. follows:
10901+ *
10902+ * Copyright (C) 1993,1994 Joe Portman (baron@hebron.connected.com)
10903+ * First stab at ibcs shm, sem and msg handlers
10904+ *
10905+ * NOTE:
10906+ * Please contact the author above before blindly making changes
10907+ * to this file. You will break things.
10908+ *
10909+ * 04-15-1994 JLP III
10910+ * Still no msgsys, but IPC_STAT now works for shm calls
10911+ * Corrected argument order for sys_ipc calls, to accomodate Mike's
10912+ * changes, so that we can just call sys_ipc instead of the internal
10913+ * sys_* calls for ipc functions.
10914+ * Cleaned up translation of perm structures
10915+ * tstshm for Oracle now works.
10916+ *
10917+ * 04-23-1994 JLP III
10918+ * Added in msgsys calls, Tested and working
10919+ * Added translation for IPC_SET portions of all xxxctl functions.
10920+ * Added SHM_LOCK and SHM_UNLOCK to shmsys
10921+ *
10922+ * 04-28-1994 JLP III
10923+ * Special thanks to Brad Pepers for adding in the GETALL and SETALL
10924+ * case of semaphores. (pepersb@cuug.ab.ca)
10925+ *
10926+ */
10927+
10928+#include <linux/config.h>
10929+
10930+#include <linux/module.h>
10931+
10932+#include <asm/uaccess.h>
10933+
10934+#include <linux/errno.h>
10935+#include <linux/sched.h>
10936+#include <linux/kernel.h>
10937+#include <linux/mm.h>
10938+#include <linux/stddef.h>
10939+#include <linux/unistd.h>
10940+#include <linux/ptrace.h>
10941+
10942+#include <asm/system.h>
10943+#include <linux/fs.h>
10944+#include <linux/sys.h>
10945+#include <asm/ipc.h>
10946+#include <linux/ipc.h>
10947+#include <linux/sem.h>
10948+#include <linux/shm.h>
10949+#include <linux/msg.h>
10950+#include <linux/string.h>
10951+
10952+#include <abi/abi.h>
10953+#include <abi/trace.h>
10954+
10955+
10956+struct ibcs_ipc_perm {
10957+ unsigned short uid; /* owner's user id */
10958+ unsigned short gid; /* owner's group id */
10959+ unsigned short cuid; /* creator's user id */
10960+ unsigned short cgid; /* creator's group id */
10961+ unsigned short mode; /* access modes */
10962+ unsigned short seq; /* slot usage sequence number */
10963+ long key; /* key */
10964+};
10965+
10966+struct ibcs_ipc_perm_l {
10967+ unsigned long uid; /* owner's user id */
10968+ unsigned long gid; /* owner's group id */
10969+ unsigned long cuid; /* creator's user id */
10970+ unsigned long cgid; /* creator's group id */
10971+ unsigned long mode; /* access modes */
10972+ unsigned long seq; /* slot usage sequence number */
10973+ long key; /* key */
10974+ void *ipc_secp; /* security structure pointer */
10975+ long pad[3]; /* reserved */
10976+};
10977+
10978+struct ibcs_semid_ds {
10979+ struct ibcs_ipc_perm sem_perm;
10980+ struct sem *sem_base;
10981+ unsigned short sem_nsems;
10982+ char __pad[2];
10983+ unsigned long sem_otime;
10984+ unsigned long sem_ctime;
10985+};
10986+
10987+struct ibcs_semid_ds_l {
10988+ struct ibcs_ipc_perm_l sem_perm;
10989+ struct sem *sem_base;
10990+ unsigned short sem_nsems;
10991+ char __pad[2];
10992+ unsigned long sem_otime;
10993+ unsigned long sem_pad1;
10994+ unsigned long sem_ctime;
10995+ unsigned long sem_pad2;
10996+ unsigned long sem_pad3[4];
10997+};
10998+
10999+struct ibcs_shmid_ds {
11000+ struct ibcs_ipc_perm shm_perm; /* operation permission struct */
11001+ int shm_segsz; /* size of segment in bytes */
11002+ struct region *__pad1; /* ptr to region structure */
11003+ char __pad2[4]; /* for swap compatibility */
11004+ ushort shm_lpid; /* pid of last shmop */
11005+ ushort shm_cpid; /* pid of creator */
11006+ unsigned short shm_nattch; /* used only for shminfo */
11007+ unsigned short __pad3;
11008+ time_t shm_atime; /* last shmat time */
11009+ time_t shm_dtime; /* last shmdt time */
11010+ time_t shm_ctime; /* last change time */
11011+};
11012+
11013+struct ibcs_shmid_ds_l {
11014+ struct ibcs_ipc_perm_l shm_perm;/* operation permission struct */
11015+ int shm_segsz; /* size of segment in bytes */
11016+ struct region *__pad1; /* ptr to region structure */
11017+ unsigned short shm_lckcnt; /* number of times it is being locked */
11018+ char __pad2[2]; /* for swap compatibility */
11019+ unsigned long shm_lpid; /* pid of last shmop */
11020+ unsigned long shm_cpid; /* pid of creator */
11021+ unsigned long shm_nattch; /* used only for shminfo */
11022+ unsigned long shm_cnattch;
11023+ unsigned long shm_atime; /* last shmat time */
11024+ unsigned long shm_pad1;
11025+ unsigned long shm_dtime; /* last shmdt time */
11026+ unsigned long shm_pad2;
11027+ unsigned long shm_ctime; /* last change time */
11028+ unsigned long shm_pad3;
11029+ unsigned long shm_pad4[4];
11030+};
11031+
11032+struct ibcs_msqid_ds {
11033+ struct ibcs_ipc_perm msg_perm;
11034+ struct msg *msg_first;
11035+ struct msg *msg_last;
11036+ ushort msg_cbytes;
11037+ ushort msg_qnum;
11038+ ushort msg_qbytes;
11039+ ushort msg_lspid;
11040+ ushort msg_lrpid;
11041+ time_t msg_stime;
11042+ time_t msg_rtime;
11043+ time_t msg_ctime;
11044+};
11045+
11046+struct ibcs_msqid_ds_l {
11047+ struct ibcs_ipc_perm_l msg_perm;
11048+ struct msg *msg_first;
11049+ struct msg *msg_last;
11050+ unsigned long msg_cbytes;
11051+ unsigned long msg_qnum;
11052+ unsigned long msg_qbytes;
11053+ unsigned long msg_lspid;
11054+ unsigned long msg_lrpid;
11055+ unsigned long msg_stime;
11056+ unsigned long msg_pad1;
11057+ unsigned long msg_rtime;
11058+ unsigned long msg_pad2;
11059+ unsigned long msg_ctime;
11060+ unsigned long msg_pad3;
11061+ unsigned long msg_pad4[4];
11062+};
11063+
11064+
11065+static inline void ip_to_lp(struct ibcs_ipc_perm *ip, struct ipc_perm *lp)
11066+{
11067+ lp->uid = ip->uid;
11068+ lp->gid = ip->gid;
11069+ lp->cuid = ip->cuid;
11070+ lp->cgid = ip->cgid;
11071+ lp->mode = ip->mode;
11072+ lp->seq = ip->seq;
11073+ lp->key = ip->key;
11074+}
11075+
11076+static inline void lp_to_ip(struct ipc_perm *lp, struct ibcs_ipc_perm *ip)
11077+{
11078+ ip->uid = lp->uid;
11079+ ip->gid = lp->gid;
11080+ ip->cuid = lp->cuid;
11081+ ip->cgid = lp->cgid;
11082+ ip->mode = lp->mode;
11083+ ip->seq = lp->seq;
11084+ ip->key = lp->key;
11085+}
11086+
11087+static inline void ip_to_lp_l(struct ibcs_ipc_perm_l *ip, struct ipc_perm *lp)
11088+{
11089+ lp->uid = ip->uid;
11090+ lp->gid = ip->gid;
11091+ lp->cuid = ip->cuid;
11092+ lp->cgid = ip->cgid;
11093+ lp->mode = ip->mode;
11094+ lp->seq = ip->seq;
11095+ lp->key = ip->key;
11096+}
11097+
11098+static inline void lp_to_ip_l(struct ipc_perm *lp, struct ibcs_ipc_perm_l *ip)
11099+{
11100+ ip->uid = lp->uid;
11101+ ip->gid = lp->gid;
11102+ ip->cuid = lp->cuid;
11103+ ip->cgid = lp->cgid;
11104+ ip->mode = lp->mode;
11105+ ip->seq = lp->seq;
11106+ ip->key = lp->key;
11107+}
11108+
11109+
11110+#define U_SEMCTL (0)
11111+#define U_SEMGET (1)
11112+#define U_SEMOP (2)
11113+#define U_SHMLOCK (3)
11114+#define U_SHMUNLOCK (4)
11115+
11116+#define U_IPC_RMID 0
11117+#define U_IPC_SET 1
11118+#define U_IPC_STAT 2
11119+#define U_GETNCNT 3
11120+#define U_GETPID 4
11121+#define U_GETVAL 5
11122+#define U_GETALL 6
11123+#define U_GETZCNT 7
11124+#define U_SETVAL 8
11125+#define U_SETALL 9
11126+#define U_IPC_RMID_L 10
11127+#define U_IPC_SET_L 11
11128+#define U_IPC_STAT_L 12
11129+
11130+static inline int ibcs_sem_trans(int arg)
11131+{
11132+ switch (arg) {
11133+ case U_IPC_RMID: return IPC_RMID;
11134+ case U_IPC_SET: return IPC_SET;
11135+ case U_IPC_STAT: return IPC_STAT;
11136+ case U_GETNCNT: return GETNCNT;
11137+ case U_GETPID: return GETPID;
11138+ case U_GETVAL: return GETVAL;
11139+ case U_GETALL: return GETALL;
11140+ case U_GETZCNT: return GETZCNT;
11141+ case U_SETVAL: return SETVAL;
11142+ case U_SETALL: return SETALL;
11143+ case U_IPC_RMID_L: return IPC_RMID;
11144+ case U_IPC_SET_L: return U_IPC_SET_L;
11145+ case U_IPC_STAT_L: return U_IPC_STAT_L;
11146+ }
11147+ return -1;
11148+}
11149+
11150+static void isem_to_lsem(struct ibcs_semid_ds *is, struct semid_ds *ls)
11151+{
11152+ ip_to_lp(&is->sem_perm, &ls->sem_perm);
11153+ ls->sem_base = is->sem_base;
11154+ ls->sem_nsems = is->sem_nsems;
11155+ ls->sem_otime = is->sem_otime;
11156+ ls->sem_ctime = is->sem_ctime;
11157+}
11158+
11159+static void lsem_to_isem(struct semid_ds *ls, struct ibcs_semid_ds *is)
11160+{
11161+ lp_to_ip(&ls->sem_perm, &is->sem_perm);
11162+ is->sem_base = ls->sem_base;
11163+ is->sem_nsems = ls->sem_nsems;
11164+ is->sem_otime = ls->sem_otime;
11165+ is->sem_ctime = ls->sem_ctime;
11166+}
11167+
11168+static void isem_to_lsem_l(struct ibcs_semid_ds_l *is, struct semid_ds *ls)
11169+{
11170+ ip_to_lp_l(&is->sem_perm, &ls->sem_perm);
11171+ ls->sem_base = is->sem_base;
11172+ ls->sem_nsems = is->sem_nsems;
11173+ ls->sem_otime = is->sem_otime;
11174+ ls->sem_ctime = is->sem_ctime;
11175+}
11176+
11177+static void lsem_to_isem_l(struct semid_ds *ls, struct ibcs_semid_ds_l *is)
11178+{
11179+ memset(is, 0, sizeof(*is));
11180+ lp_to_ip_l(&ls->sem_perm, &is->sem_perm);
11181+ is->sem_base = ls->sem_base;
11182+ is->sem_nsems = ls->sem_nsems;
11183+ is->sem_otime = ls->sem_otime;
11184+ is->sem_ctime = ls->sem_ctime;
11185+}
11186+
11187+int svr4_semsys(struct pt_regs *regs)
11188+{
11189+ int command = get_syscall_parameter (regs, 0);
11190+ int arg1, arg2, arg3;
11191+ union semun *arg4;
11192+ struct semid_ds ls;
11193+ union semun lsemun;
11194+ mm_segment_t old_fs;
11195+ int retval;
11196+
11197+ arg1 = get_syscall_parameter (regs, 1);
11198+ arg2 = get_syscall_parameter (regs, 2);
11199+ arg3 = get_syscall_parameter (regs, 3);
11200+ switch (command) {
11201+ case U_SEMCTL:
11202+ /* XXX - The value for arg4 depends on how union
11203+ * passing is implement on this architecture and
11204+ * compiler. The following is *only* known to be
11205+ * right for Intel (the default else case).
11206+ */
11207+#ifdef __sparc__
11208+ arg4 = (union semun *)get_syscall_parameter (regs, 4);
11209+#else
11210+ arg4 = (union semun *)(((unsigned long *) regs->esp) + (5));
11211+#endif
11212+
11213+ abi_trace(ABI_TRACE_API, "semctl: args: %d %d %d %lx",
11214+ arg1, arg2, arg3, (u_long)arg4);
11215+
11216+ switch (arg3) {
11217+ case U_IPC_SET: {
11218+ struct ibcs_semid_ds is, *is_p;
11219+
11220+ retval = get_user(is_p, (struct ibcs_semid_ds **)&arg4->buf);
11221+ if (!retval)
11222+ retval = verify_area(VERIFY_WRITE, is_p, sizeof(is));
11223+ if (retval)
11224+ return retval;
11225+
11226+ copy_from_user(&is, (char *)is_p, sizeof(is));
11227+ isem_to_lsem(&is, &ls);
11228+
11229+ lsemun.buf = &ls;
11230+ old_fs = get_fs();
11231+ set_fs (get_ds());
11232+ retval = SYS (ipc) (SEMCTL, arg1, arg2, IPC_SET, &lsemun);
11233+ set_fs(old_fs);
11234+
11235+ lsem_to_isem(&ls, &is);
11236+ copy_to_user((char *)is_p, &is, sizeof(is));
11237+ return retval;
11238+ }
11239+
11240+ case U_IPC_SET_L: {
11241+ struct ibcs_semid_ds_l is, *is_p;
11242+
11243+ retval = get_user(is_p, (struct ibcs_semid_ds_l **)&arg4->buf);
11244+ if (!retval)
11245+ retval = verify_area(VERIFY_WRITE, is_p, sizeof(is));
11246+ if (retval)
11247+ return retval;
11248+
11249+ copy_from_user(&is, (char *)is_p, sizeof(is));
11250+ isem_to_lsem_l(&is, &ls);
11251+
11252+ lsemun.buf = &ls;
11253+ old_fs = get_fs();
11254+ set_fs (get_ds());
11255+ retval = SYS (ipc) (SEMCTL, arg1, arg2, IPC_SET, &lsemun);
11256+ set_fs(old_fs);
11257+
11258+ lsem_to_isem_l(&ls, &is);
11259+ copy_to_user((char *)is_p, &is, sizeof(is));
11260+ return retval;
11261+ }
11262+
11263+ case U_IPC_RMID:
11264+ case U_IPC_RMID_L:
11265+ case U_SETVAL:
11266+ case U_GETVAL:
11267+ case U_GETPID:
11268+ case U_GETNCNT:
11269+ case U_GETZCNT: {
11270+ int cmd = ibcs_sem_trans(arg3);
11271+ return SYS (ipc) (SEMCTL, arg1, arg2, cmd, arg4);
11272+ }
11273+
11274+ case U_SETALL:
11275+ case U_GETALL: {
11276+ int cmd = ibcs_sem_trans(arg3);
11277+ return SYS (ipc) (SEMCTL, arg1, 0, cmd, arg4);
11278+ }
11279+
11280+ case U_IPC_STAT: {
11281+ struct ibcs_semid_ds is, *is_p;
11282+
11283+ retval = get_user(is_p, (struct ibcs_semid_ds **)&arg4->buf);
11284+ if (!retval)
11285+ retval = verify_area(VERIFY_WRITE, (char *)is_p, sizeof(is));
11286+ if (retval)
11287+ return retval;
11288+
11289+ lsemun.buf = &ls;
11290+ old_fs = get_fs();
11291+ set_fs(get_ds());
11292+ retval = SYS (ipc) (SEMCTL, arg1, 0, IPC_STAT, &lsemun);
11293+ set_fs(old_fs);
11294+ if (retval < 0)
11295+ return retval;
11296+
11297+ lsem_to_isem(&ls, &is);
11298+ copy_to_user((char *)is_p, &is, sizeof(is));
11299+ return retval;
11300+ }
11301+
11302+ case U_IPC_STAT_L: {
11303+ struct ibcs_semid_ds_l is, *is_p;
11304+
11305+ retval = get_user(is_p, (struct ibcs_semid_ds_l **)&arg4->buf);
11306+ if (!retval)
11307+ retval = verify_area(VERIFY_WRITE, (char *)is_p, sizeof(is));
11308+ if (retval)
11309+ return retval;
11310+
11311+ lsemun.buf = &ls;
11312+ old_fs = get_fs();
11313+ set_fs(get_ds());
11314+ retval = SYS (ipc) (SEMCTL, arg1, 0, IPC_STAT, &lsemun);
11315+ set_fs(old_fs);
11316+ if (retval < 0)
11317+ return retval;
11318+
11319+ lsem_to_isem_l(&ls, &is);
11320+ copy_to_user((char *)is_p, &is, sizeof(is));
11321+ return retval;
11322+ }
11323+
11324+ default:
11325+ printk(KERN_ERR "%d ibcs_semctl: unsupported command %d\n",
11326+ current->pid, arg3);
11327+ return -EINVAL;
11328+ }
11329+
11330+ case U_SEMGET:
11331+ abi_trace(ABI_TRACE_API, "semget: args: %d %d %o",
11332+ arg1, arg2, arg3);
11333+ return SYS(ipc)(SEMGET, arg1, arg2, arg3, 0);
11334+
11335+ case U_SEMOP:
11336+ if (abi_traced(ABI_TRACE_API)) {
11337+ struct sembuf * tp = (struct sembuf *) arg2;
11338+ struct sembuf tmp;
11339+ int x;
11340+
11341+ __abi_trace("semop: args: %d 0x%08lx %d",
11342+ arg1, (u_long)arg2, arg3);
11343+
11344+ for (x = 0; x < arg3; x++) {
11345+ copy_from_user (&tmp, tp, sizeof(tmp));
11346+ __abi_trace("semop args: %d %d 0%o",
11347+ tmp.sem_num,
11348+ tmp.sem_op,
11349+ tmp.sem_flg);
11350+ tp++;
11351+ }
11352+ }
11353+ return SYS(ipc)(SEMOP, arg1, arg3, 0, (struct sembuf *)arg2);
11354+ }
11355+ return -EINVAL;
11356+}
11357+
11358+EXPORT_SYMBOL(svr4_semsys);
11359+
11360+
11361+#define U_SHMAT (0)
11362+#define U_SHMCTL (1)
11363+#define U_SHMDT (2)
11364+#define U_SHMGET (3)
11365+
11366+static void
11367+ishm_to_lshm(struct ibcs_shmid_ds *is, struct shmid_ds *ls)
11368+{
11369+ ip_to_lp(&is->shm_perm, &ls->shm_perm);
11370+ ls->shm_segsz = is->shm_segsz;
11371+ ls->shm_lpid = is->shm_lpid;
11372+ ls->shm_cpid = is->shm_cpid;
11373+ ls->shm_nattch = is->shm_nattch;
11374+ ls->shm_atime = is->shm_atime;
11375+ ls->shm_dtime = is->shm_dtime;
11376+ ls->shm_ctime = is->shm_ctime;
11377+}
11378+
11379+static void
11380+lshm_to_ishm(struct shmid_ds *ls, struct ibcs_shmid_ds *is)
11381+{
11382+ lp_to_ip(&ls->shm_perm, &is->shm_perm);
11383+ is->shm_segsz = ls->shm_segsz;
11384+ is->shm_lpid = ls->shm_lpid;
11385+ is->shm_cpid = ls->shm_cpid;
11386+ is->shm_nattch = ls->shm_nattch;
11387+ is->shm_atime = ls->shm_atime;
11388+ is->shm_dtime = ls->shm_dtime;
11389+ is->shm_ctime = ls->shm_ctime;
11390+}
11391+
11392+static void
11393+ishm_to_lshm_l(struct ibcs_shmid_ds_l *is, struct shmid_ds *ls)
11394+{
11395+ ip_to_lp_l(&is->shm_perm, &ls->shm_perm);
11396+ ls->shm_segsz = is->shm_segsz;
11397+ ls->shm_lpid = is->shm_lpid;
11398+ ls->shm_cpid = is->shm_cpid;
11399+ ls->shm_nattch = is->shm_nattch;
11400+ ls->shm_atime = is->shm_atime;
11401+ ls->shm_dtime = is->shm_dtime;
11402+ ls->shm_ctime = is->shm_ctime;
11403+}
11404+
11405+static void lshm_to_ishm_l(struct shmid_ds * ls, struct ibcs_shmid_ds_l * is)
11406+{
11407+ memset(is, 0, sizeof(*is));
11408+ lp_to_ip_l(&ls->shm_perm, &is->shm_perm);
11409+ is->shm_segsz = ls->shm_segsz;
11410+ is->shm_lpid = ls->shm_lpid;
11411+ is->shm_cpid = ls->shm_cpid;
11412+ is->shm_nattch = ls->shm_nattch;
11413+ is->shm_atime = ls->shm_atime;
11414+ is->shm_dtime = ls->shm_dtime;
11415+ is->shm_ctime = ls->shm_ctime;
11416+}
11417+
11418+
11419+int svr4_shmsys(struct pt_regs * regs)
11420+{
11421+ int command = get_syscall_parameter (regs, 0);
11422+ int arg1, arg2, arg3;
11423+ mm_segment_t old_fs;
11424+ long retval = 0;
11425+ char *addr = 0;
11426+
11427+ arg1 = arg2 = arg3 = 0;
11428+ switch (command) {
11429+ case U_SHMAT:
11430+ case U_SHMCTL:
11431+ case U_SHMGET:
11432+ arg1 = get_syscall_parameter (regs, 1);
11433+ arg2 = get_syscall_parameter (regs, 2);
11434+ arg3 = get_syscall_parameter (regs, 3);
11435+ break;
11436+ case U_SHMDT:
11437+ addr = (char *) get_syscall_parameter (regs, 1);
11438+ break;
11439+ default:
11440+ printk(KERN_ERR "%d iBCS: bad SHM command %d\n",
11441+ current->pid, command);
11442+ retval = -EINVAL;
11443+ goto test_exit;
11444+ }
11445+
11446+ switch (command) {
11447+ case U_SHMAT: {
11448+#ifdef IPCCALL
11449+ unsigned long raddr;
11450+#endif
11451+ abi_trace(ABI_TRACE_API, "shmat: args: %d %x %o",
11452+ arg1, arg2, arg3);
11453+ /*
11454+ * raddr = 0 tells sys_shmat to limit to 2G
11455+ * and we are IBCS, no raddr value to return
11456+ */
11457+#ifdef IPCCALL
11458+ old_fs = get_fs();
11459+ set_fs(get_ds());
11460+ retval = SYS (ipc) (IPCCALL(1,SHMAT), arg1, arg3, &raddr, (char *) arg2);
11461+ set_fs(old_fs);
11462+ if (retval >= 0)
11463+ retval = raddr;
11464+#else
11465+ retval = SYS (ipc) (SHMAT, arg1, arg3, 0, (char *) arg2);
11466+#endif
11467+
11468+ abi_trace(ABI_TRACE_API, "shmat: return val is %lx", retval);
11469+ goto test_exit;
11470+ }
11471+
11472+ case U_SHMGET:
11473+ abi_trace(ABI_TRACE_API, "shmget: args: %d %x %o",
11474+ arg1, arg2, arg3);
11475+
11476+ retval = SYS(ipc)(SHMGET, arg1, arg2, arg3, 0);
11477+ goto test_exit;
11478+
11479+ case U_SHMDT:
11480+ abi_trace(ABI_TRACE_API, "shmdt: arg: %lx",
11481+ (u_long)addr);
11482+ retval = SYS(ipc)(SHMDT, 0, 0, 0, addr);
11483+ goto test_exit;
11484+
11485+ case U_SHMCTL:
11486+ abi_trace(ABI_TRACE_API, "shmctl: args: %d %x %o %d %x",
11487+ arg1, arg2, arg3, arg3, arg3);
11488+ switch (arg2) {
11489+ case U_SHMLOCK:
11490+ retval = SYS (ipc) (SHMCTL, arg1, SHM_LOCK, 0, arg3);
11491+ goto test_exit;
11492+
11493+ case U_SHMUNLOCK:
11494+ retval = SYS (ipc) (SHMCTL, arg1, SHM_UNLOCK, 0, arg3);
11495+ goto test_exit;
11496+
11497+ case U_IPC_SET: {
11498+ struct ibcs_shmid_ds is;
11499+ struct shmid_ds ls;
11500+
11501+ retval = verify_area(VERIFY_WRITE, (char *)arg3, sizeof(is));
11502+ if (retval)
11503+ goto test_exit;
11504+
11505+ copy_from_user(&is, (char *)arg3, sizeof(is));
11506+ ishm_to_lshm(&is, &ls);
11507+
11508+ old_fs = get_fs();
11509+ set_fs (get_ds());
11510+ retval = SYS (ipc) (SHMCTL, arg1, IPC_SET, 0, &ls);
11511+ set_fs(old_fs);
11512+ if (retval < 0)
11513+ goto test_exit;
11514+
11515+ lshm_to_ishm(&ls, &is);
11516+ copy_to_user((char *)arg3, &is, sizeof(is));
11517+ goto test_exit;
11518+ }
11519+
11520+ case U_IPC_SET_L: {
11521+ struct ibcs_shmid_ds_l is;
11522+ struct shmid_ds ls;
11523+
11524+ retval = verify_area(VERIFY_WRITE, (char *)arg3, sizeof(is));
11525+ if (retval)
11526+ goto test_exit;
11527+
11528+ copy_from_user(&is, (char *)arg3, sizeof(is));
11529+ ishm_to_lshm_l(&is, &ls);
11530+
11531+ old_fs = get_fs();
11532+ set_fs (get_ds());
11533+ retval = SYS (ipc) (SHMCTL, arg1, IPC_SET, 0, &ls);
11534+ set_fs(old_fs);
11535+ if (retval < 0)
11536+ goto test_exit;
11537+
11538+ lshm_to_ishm_l(&ls, &is);
11539+ copy_to_user((char *)arg3, &is, sizeof(is));
11540+ goto test_exit;
11541+ }
11542+
11543+ case U_IPC_RMID:
11544+ case U_IPC_RMID_L:
11545+ retval = SYS (ipc) (SHMCTL, arg1, IPC_RMID, arg3);
11546+ goto test_exit;
11547+
11548+ case U_IPC_STAT: {
11549+ struct ibcs_shmid_ds is;
11550+ struct shmid_ds ls;
11551+
11552+ old_fs = get_fs();
11553+ set_fs (get_ds());
11554+ retval = SYS (ipc) (SHMCTL, arg1, IPC_STAT, 0, &ls);
11555+ set_fs(old_fs);
11556+ if (retval < 0)
11557+ goto test_exit;
11558+
11559+ lshm_to_ishm(&ls, &is);
11560+ retval = copy_to_user((char *)arg3, &is, sizeof(is)) ? -EFAULT : 0;
11561+ goto test_exit;
11562+ }
11563+
11564+ case U_IPC_STAT_L: {
11565+ struct ibcs_shmid_ds_l is;
11566+ struct shmid_ds ls;
11567+
11568+ old_fs = get_fs();
11569+ set_fs (get_ds());
11570+ retval = SYS (ipc) (SHMCTL, arg1, IPC_STAT, 0, &ls);
11571+ set_fs(old_fs);
11572+ if (retval < 0)
11573+ goto test_exit;
11574+
11575+ lshm_to_ishm_l(&ls, &is);
11576+ retval = copy_to_user((char *)arg3, &is, sizeof(is)) ? -EFAULT : 0;
11577+ goto test_exit;
11578+ }
11579+
11580+ default:
11581+ printk(KERN_ERR "%d iBCS: ibcs_shmctl: unsupported command %d\n",
11582+ current->pid, arg2);
11583+ }
11584+ retval = -EINVAL;
11585+ goto test_exit;
11586+
11587+ default:
11588+ __abi_trace("shmsys: command: %x", command);
11589+ retval = -EINVAL;
11590+ goto test_exit;
11591+ }
11592+
11593+test_exit:;
11594+ if ((retval < 0) && (retval > -255)) {
11595+ set_error (regs, iABI_errors (-retval));
11596+ abi_trace(ABI_TRACE_API, "Error %ld", get_result (regs));
11597+ } else {
11598+ clear_error (regs);
11599+ set_result (regs, retval);
11600+ }
11601+
11602+ return 0;
11603+}
11604+
11605+EXPORT_SYMBOL(svr4_shmsys);
11606+
11607+
11608+#define U_MSGGET (0)
11609+#define U_MSGCTL (1)
11610+#define U_MSGRCV (2)
11611+#define U_MSGSND (3)
11612+
11613+static void imsq_to_lmsq(struct ibcs_msqid_ds * im, struct msqid_ds * lm)
11614+{
11615+ ip_to_lp(&im->msg_perm, &lm->msg_perm);
11616+ lm->msg_first = im->msg_first;
11617+ lm->msg_last = im->msg_last;
11618+ lm->msg_cbytes = im->msg_cbytes;
11619+ lm->msg_qnum = im->msg_qnum;
11620+ lm->msg_qbytes = im->msg_qbytes;
11621+ lm->msg_lspid = im->msg_lspid;
11622+ lm->msg_lrpid = im->msg_lrpid;
11623+ lm->msg_stime = im->msg_stime;
11624+ lm->msg_rtime = im->msg_rtime;
11625+ lm->msg_ctime = im->msg_ctime;
11626+}
11627+
11628+static void
11629+lmsq_to_imsq(struct msqid_ds *lm, struct ibcs_msqid_ds *im)
11630+{
11631+ lp_to_ip(&lm->msg_perm, &im->msg_perm);
11632+ im->msg_first = lm->msg_first;
11633+ im->msg_last = lm->msg_last;
11634+ im->msg_cbytes = lm->msg_cbytes;
11635+ im->msg_qnum = lm->msg_qnum;
11636+ im->msg_qbytes = lm->msg_qbytes;
11637+ im->msg_lspid = lm->msg_lspid;
11638+ im->msg_lrpid = lm->msg_lrpid;
11639+ im->msg_stime = lm->msg_stime;
11640+ im->msg_rtime = lm->msg_rtime;
11641+ im->msg_ctime = lm->msg_ctime;
11642+}
11643+
11644+static void
11645+imsq_to_lmsq_l(struct ibcs_msqid_ds_l *im, struct msqid_ds *lm)
11646+{
11647+ ip_to_lp_l(&im->msg_perm, &lm->msg_perm);
11648+ lm->msg_first = im->msg_first;
11649+ lm->msg_last = im->msg_last;
11650+ lm->msg_cbytes = im->msg_cbytes;
11651+ lm->msg_qnum = im->msg_qnum;
11652+ lm->msg_qbytes = im->msg_qbytes;
11653+ lm->msg_lspid = im->msg_lspid;
11654+ lm->msg_lrpid = im->msg_lrpid;
11655+ lm->msg_stime = im->msg_stime;
11656+ lm->msg_rtime = im->msg_rtime;
11657+ lm->msg_ctime = im->msg_ctime;
11658+}
11659+
11660+static void lmsq_to_imsq_l(struct msqid_ds * lm, struct ibcs_msqid_ds_l * im)
11661+{
11662+ memset(im, 0, sizeof(*im));
11663+ lp_to_ip_l(&lm->msg_perm, &im->msg_perm);
11664+ im->msg_first = lm->msg_first;
11665+ im->msg_last = lm->msg_last;
11666+ im->msg_cbytes = lm->msg_cbytes;
11667+ im->msg_qnum = lm->msg_qnum;
11668+ im->msg_qbytes = lm->msg_qbytes;
11669+ im->msg_lspid = lm->msg_lspid;
11670+ im->msg_lrpid = lm->msg_lrpid;
11671+ im->msg_stime = lm->msg_stime;
11672+ im->msg_rtime = lm->msg_rtime;
11673+ im->msg_ctime = lm->msg_ctime;
11674+}
11675+
11676+int svr4_msgsys(struct pt_regs * regs)
11677+{
11678+ int command = get_syscall_parameter (regs, 0);
11679+ int arg1, arg2, arg4, arg5;
11680+ mm_segment_t old_fs;
11681+ char *arg3;
11682+ int retval;
11683+
11684+ arg1 = get_syscall_parameter (regs, 1);
11685+ arg2 = get_syscall_parameter (regs, 2);
11686+ arg3 = (char *) get_syscall_parameter (regs, 3);
11687+
11688+ switch (command) {
11689+ /* hard one first */
11690+ case U_MSGCTL:
11691+ switch (arg2) {
11692+ case U_IPC_SET: {
11693+ struct ibcs_msqid_ds im;
11694+ struct msqid_ds lm;
11695+
11696+ retval = verify_area(VERIFY_WRITE, arg3, sizeof(im));
11697+ if (retval)
11698+ return retval;
11699+
11700+ copy_from_user(&im, (char *) arg3, sizeof(im));
11701+ imsq_to_lmsq(&im, &lm);
11702+
11703+ old_fs = get_fs();
11704+ set_fs (get_ds());
11705+ retval = SYS (ipc) (MSGCTL, arg1, IPC_SET, 0, &lm);
11706+ set_fs (old_fs);
11707+
11708+ lmsq_to_imsq(&lm, &im);
11709+ copy_to_user((char *)arg3, &im, sizeof(im));
11710+ return retval;
11711+ }
11712+
11713+ case U_IPC_SET_L: {
11714+ struct ibcs_msqid_ds_l im;
11715+ struct msqid_ds lm;
11716+
11717+ retval = verify_area(VERIFY_WRITE, arg3, sizeof(im));
11718+ if (retval)
11719+ return retval;
11720+
11721+ copy_from_user(&im, (char *) arg3, sizeof(im));
11722+ imsq_to_lmsq_l(&im, &lm);
11723+
11724+ old_fs = get_fs();
11725+ set_fs (get_ds());
11726+ retval = SYS (ipc) (MSGCTL, arg1, IPC_SET, 0, &lm);
11727+ set_fs (old_fs);
11728+
11729+ lmsq_to_imsq_l(&lm, &im);
11730+ copy_to_user((char *)arg3, &im, sizeof(im));
11731+ return retval;
11732+ }
11733+
11734+ case U_IPC_RMID:
11735+ case U_IPC_RMID_L:
11736+ return SYS (ipc) (MSGCTL, arg1, IPC_RMID, 0, arg3);
11737+
11738+ case U_IPC_STAT: {
11739+ struct ibcs_msqid_ds im;
11740+ struct msqid_ds lm;
11741+
11742+ retval = verify_area(VERIFY_WRITE, arg3, sizeof(im));
11743+ if (retval)
11744+ return retval;
11745+
11746+ old_fs = get_fs();
11747+ set_fs (get_ds());
11748+ retval = SYS (ipc) (MSGCTL, arg1, IPC_STAT, 0, &lm);
11749+ set_fs (old_fs);
11750+
11751+ if (retval < 0)
11752+ return retval;
11753+
11754+ lmsq_to_imsq(&lm, &im);
11755+ copy_to_user((char *)arg3, &im, sizeof(im));
11756+ return retval;
11757+ }
11758+
11759+ case U_IPC_STAT_L: {
11760+ struct ibcs_msqid_ds_l im;
11761+ struct msqid_ds lm;
11762+
11763+ retval = verify_area(VERIFY_WRITE, arg3, sizeof(im));
11764+ if (retval)
11765+ return retval;
11766+
11767+ old_fs = get_fs();
11768+ set_fs (get_ds());
11769+ retval = SYS (ipc) (MSGCTL, arg1, IPC_STAT, 0, &lm);
11770+ set_fs (old_fs);
11771+
11772+ if (retval < 0)
11773+ return retval;
11774+
11775+ lmsq_to_imsq_l(&lm, &im);
11776+ copy_to_user((char *)arg3, &im, sizeof(im));
11777+ return retval;
11778+ }
11779+
11780+ default:
11781+ printk(KERN_ERR "%d ibcs_msgctl: unsupported command %d\n",
11782+ current->pid, arg2);
11783+ }
11784+
11785+ case U_MSGGET:
11786+ return SYS (ipc) (MSGGET, arg1, arg2, 0, 0);
11787+
11788+ case U_MSGSND:
11789+ arg4 = get_syscall_parameter (regs, 4);
11790+ retval = SYS (ipc) (MSGSND, arg1, arg3, arg4, (char *) arg2);
11791+ return ((retval > 0) ? 0 : retval);
11792+
11793+ case U_MSGRCV: {
11794+#ifdef IPCCALL
11795+ arg4 = get_syscall_parameter (regs, 4);
11796+ arg5 = get_syscall_parameter (regs, 5);
11797+ return SYS(ipc)(IPCCALL(1,MSGRCV), arg1, arg3, arg5, arg2, arg4);
11798+#else
11799+#ifdef __sparc__
11800+ printk(KERN_ERR
11801+ "%d Sparc/IBCS: Kludgy U_MSGRCV not implemented\n",
11802+ current->pid);
11803+ return -EINVAL;
11804+#else /* __sparc__ */
11805+ struct ipc_kludge *scratch;
11806+ long old_esp = regs->esp;
11807+
11808+ scratch = (struct ipc_kludge *)((regs->esp-1024-sizeof(struct ipc_kludge)) & 0xfffffffc);
11809+ regs->esp = (long)scratch;
11810+ get_user(arg4, ((unsigned long *) regs->esp) + 5);
11811+ get_user(arg5, ((unsigned long *) regs->esp) + 6);
11812+ put_user((long)arg2, &scratch->msgp);
11813+ put_user((long)arg4, &scratch->msgtyp);
11814+ retval = SYS (ipc) (MSGRCV, arg1, arg3, arg5, scratch);
11815+ regs->esp = old_esp;
11816+ return retval;
11817+#endif /* sparc */
11818+#endif /* IPCCALL */
11819+ }
11820+
11821+ default:
11822+ printk(KERN_ERR "%d ibcs_msgctl: unsupported command %d\n",
11823+ current->pid, command);
11824+ }
11825+ return -EINVAL;
11826+}
11827+
11828+EXPORT_SYMBOL(svr4_msgsys);
11829diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/isc.c linux/abi/svr4/isc.c
11830--- linux-2.4.3/abi/svr4/isc.c Thu Jan 1 01:00:00 1970
11831+++ linux/abi/svr4/isc.c Mon Mar 12 16:34:48 2001
11832@@ -0,0 +1,29 @@
11833+/* $Id$
11834+ *
11835+ * This file contains code to enable ISC 4.0 executables (posix setostype)
11836+ *
11837+ * Copyright (C) 1994 Karl Kiniger (ki@kretz.co.at)
11838+ *
11839+ * Some changes also done to callmap.inc: readlink, symlink, lstat
11840+ * entry point numbers are differing from SYSVr4
11841+ *
11842+ */
11843+
11844+#include <linux/config.h>
11845+#include <linux/module.h>
11846+
11847+#include <linux/types.h>
11848+#include <linux/errno.h>
11849+#include <linux/kernel.h>
11850+
11851+#include <abi/abi.h>
11852+#include <abi/trace.h>
11853+
11854+
11855+int
11856+isc_setostype(int arg1)
11857+{
11858+ abi_trace(ABI_TRACE_API,
11859+ "sysisc: ISC_SETOSTYPE 0x%x", arg1);
11860+ return 0;
11861+}
11862diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/isc_funcs.c linux/abi/svr4/isc_funcs.c
11863--- linux-2.4.3/abi/svr4/isc_funcs.c Thu Jan 1 01:00:00 1970
11864+++ linux/abi/svr4/isc_funcs.c Fri Mar 30 15:23:46 2001
11865@@ -0,0 +1,57 @@
11866+/* $Id$
11867+ *
11868+ * The isc syscall dispatcher
11869+ *
11870+ */
11871+
11872+#include <linux/module.h>
11873+
11874+#include <asm/uaccess.h>
11875+
11876+#include <linux/kernel.h>
11877+
11878+#include <abi/abi.h>
11879+#include <abi/abi4.h>
11880+
11881+#define SC(name) (void *)__NR_##name
11882+
11883+#define ITR(trace, name, args) ,trace,name,args
11884+
11885+static ABI_func ISC_funcs[] = {
11886+ { 0, Ukn ITR(1, "isc_sysisc0", "") }, /* 00 */
11887+ { isc_setostype, 1 ITR(0, "isc_setostype", "d") }, /* 01 */
11888+ { SC(rename), -2 ITR(0, "isc_rename", "ss") }, /* 02 */
11889+ { abi_sigaction, 3 ITR(0, "isc_sigaction", "dxx") }, /* 03 */
11890+ { abi_sigprocmask, 3 ITR(0, "isc_sicprocmask","dxx") }, /* 04 */
11891+ { 0, 1 ITR(0, "isc_sigpending","x") }, /* 05 */
11892+ { SC(getgroups), -2 ITR(0, "isc_getgroups", "dp") }, /* 06 */
11893+ { SC(setgroups), -2 ITR(0, "isc_setgroups", "dp") }, /* 07 */
11894+ { 0, Ukn ITR(1, "pathconf", "") }, /* 08 */
11895+ { 0, Ukn ITR(1, "fpathconf", "") }, /* 09 */
11896+ { ibcs_sysconf, 1 ITR(0, "sysconf", "d") }, /* 10 */
11897+ { SC(waitpid), -3 ITR(0, "isc_waitpid", "dxx") }, /* 11 */
11898+ { SC(setsid), -ZERO ITR(0, "isc_setsid", "") }, /* 12 */
11899+ { SC(setpgid), -2 ITR(0, "isc_setpgid", "dd") }, /* 13 */
11900+ { 0, Ukn ITR(1, "isc_adduser", "") }, /* 14 */
11901+ { 0, Ukn ITR(1, "isc_setuser", "") }, /* 15 */
11902+ { 0, Ukn ITR(1, "isc_sysisc16", "") }, /* 16 */
11903+ { abi_sigsuspend, Spl ITR(0, "isc_sigsuspend","x") }, /* 17 */
11904+ { SC(symlink), -2 ITR(0, "isc_symlink", "ss") }, /* 18 */
11905+ { SC(readlink), -3 ITR(0, "isc_readlink", "spd") }, /* 19 */
11906+ { 0, Ukn ITR(1, "isc_getmajor", "") } /* 20 */
11907+};
11908+
11909+
11910+void iBCS_class_ISC(struct pt_regs *regs) {
11911+ int i;
11912+
11913+ get_user(i, ((unsigned long *)regs->esp)+1);
11914+ if (i > 20) {
11915+ regs->eax = iABI_errors(-EINVAL);
11916+ regs->eflags |= 1;
11917+ return;
11918+ }
11919+
11920+ abi_dispatch(regs, &ISC_funcs[i], 2);
11921+ return;
11922+}
11923diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/mmap.c linux/abi/svr4/mmap.c
11924--- linux-2.4.3/abi/svr4/mmap.c Thu Jan 1 01:00:00 1970
11925+++ linux/abi/svr4/mmap.c Fri Mar 30 16:14:03 2001
11926@@ -0,0 +1,47 @@
11927+/* $Id$
11928+ * mmap.c - svr4 mmap(2) emulation
11929+ *
11930+ * Copyright (c) 1994 Eric Youngdale
11931+ * Copyright (c) 2001 Christoph Hellwig
11932+ */
11933+
11934+#include <linux/errno.h>
11935+#include <linux/sched.h>
11936+#include <linux/file.h>
11937+#include <linux/module.h>
11938+#include <linux/mm.h>
11939+#include <linux/mman.h>
11940+
11941+int
11942+svr4_mmap(u_int addr, u_int len, int prot, int flags, int fd, u_int off)
11943+{
11944+ struct file * fp = NULL;
11945+ int error = -EBADF;
11946+
11947+ if (!(flags & MAP_ANONYMOUS)) {
11948+ fp = fget(fd);
11949+ if (!fp)
11950+ goto out;
11951+ }
11952+
11953+ if (personality(PER_SVR4) && !(flags & 0x80000000) && addr) {
11954+ u_long ret;
11955+
11956+ down_write(&current->mm->mmap_sem);
11957+ ret = do_mmap(fp, addr, len, prot, flags | MAP_FIXED, off);
11958+ up_write(&current->mm->mmap_sem);
11959+ error = (ret == addr ? 0 : (int)ret);
11960+ goto put;
11961+ }
11962+
11963+ down_write(&current->mm->mmap_sem);
11964+ error = do_mmap(fp, addr, len, prot, flags & 0x7fffffff, off);
11965+ up_write(&current->mm->mmap_sem);
11966+
11967+put:
11968+ if (fp)
11969+ fput(fp);
11970+out:
11971+ return (error);
11972+}
11973+EXPORT_SYMBOL(svr4_mmap);
11974diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/open.c linux/abi/svr4/open.c
11975--- linux-2.4.3/abi/svr4/open.c Thu Jan 1 01:00:00 1970
11976+++ linux/abi/svr4/open.c Sun Mar 18 11:54:28 2001
11977@@ -0,0 +1,475 @@
11978+/* $Id$
11979+ * open.c - svr4 open(2), statfs(2), fcntl(2) and getdents(2) emulation
11980+ *
11981+ * Copyright (c) 1993 Joe Portman (baron@hebron.connected.com)
11982+ * Copyright (c) 1993, 1994 Drew Sullivan (re-worked for iBCS2)
11983+ * Copyright (c) 2000 Christoph Hellwig (rewrote lookup-related code)
11984+ */
11985+
11986+#include <linux/config.h>
11987+#include <linux/module.h>
11988+
11989+#include <linux/vfs.h>
11990+#include <linux/types.h>
11991+#include <linux/utime.h>
11992+#include <linux/errno.h>
11993+#include <linux/fcntl.h>
11994+#include <linux/stat.h>
11995+#include <linux/string.h>
11996+#include <linux/sched.h>
11997+#include <linux/kernel.h>
11998+#include <linux/signal.h>
11999+#include <linux/tty.h>
12000+#include <linux/time.h>
12001+#include <linux/slab.h>
12002+#include <linux/un.h>
12003+#include <linux/file.h>
12004+#include <asm/uaccess.h>
12005+
12006+
12007+#include <asm/bitops.h>
12008+
12009+#include <abi/abi.h>
12010+#include <abi/xnx.h>
12011+#include <abi/trace.h>
12012+
12013+#include <linux/dirent.h>
12014+
12015+
12016+/* ISC (at least) assumes O_CREAT if O_TRUNC is given. This is emulated
12017+ * here but is it correct for iBCS in general? Do we care?
12018+ */
12019+unsigned short fl_ibcs_to_linux[] = {
12020+ 0x0001, 0x0002, 0x0800, 0x0400, 0x1000, 0x0000, 0x0000, 0x0800,
12021+ 0x0040, 0x0240, 0x0080, 0x0100, 0x0000, 0x0000, 0x0000, 0x0000
12022+};
12023+
12024+EXPORT_SYMBOL(fl_ibcs_to_linux);
12025+
12026+unsigned short fl_linux_to_ibcs[] = {
12027+ 0x0001, 0x0002, 0x0000, 0x0000, 0x0000, 0x0000, 0x0100, 0x0400,
12028+ 0x0800, 0x0200, 0x0008, 0x0004, 0x0010, 0x0000, 0x0000, 0x0000
12029+};
12030+
12031+static int
12032+copy_statfs(struct ibcs_statfs *buf, struct statfs *st)
12033+{
12034+ struct ibcs_statfs ibcsstat;
12035+
12036+ ibcsstat.f_type = st->f_type;
12037+ ibcsstat.f_bsize = st->f_bsize;
12038+ ibcsstat.f_frsize = 0;
12039+ ibcsstat.f_blocks = st->f_blocks;
12040+ ibcsstat.f_bfree = st->f_bfree;
12041+ ibcsstat.f_files = st->f_files;
12042+ ibcsstat.f_ffree = st->f_ffree;
12043+ memset(ibcsstat.f_fname, 0, sizeof(ibcsstat.f_fname));
12044+ memset(ibcsstat.f_fpack, 0, sizeof(ibcsstat.f_fpack));
12045+
12046+ /* Finally, copy it to the user's buffer */
12047+ return copy_to_user(buf, &ibcsstat, sizeof(struct ibcs_statfs));
12048+}
12049+
12050+int svr4_statfs(const char * path, struct ibcs_statfs * buf, int len, int fstype)
12051+{
12052+ struct ibcs_statfs ibcsstat;
12053+
12054+ if (len > (int)sizeof(struct ibcs_statfs))
12055+ return -EINVAL;
12056+
12057+ if (!fstype) {
12058+ struct nameidata nd;
12059+ int error;
12060+
12061+ error = user_path_walk(path, &nd);
12062+ if (!error) {
12063+ struct statfs tmp;
12064+ error = vfs_statfs(nd.dentry->d_inode->i_sb, &tmp);
12065+ if (!error && copy_statfs(buf, &tmp))
12066+ error = -EFAULT;
12067+ path_release(&nd);
12068+ }
12069+
12070+ return error;
12071+ }
12072+
12073+ /*
12074+ * Linux can't stat unmounted filesystems so we
12075+ * simply lie and claim 500MB of 8GB is free. Sorry.
12076+ */
12077+ ibcsstat.f_bsize = 1024;
12078+ ibcsstat.f_frsize = 0;
12079+ ibcsstat.f_blocks = 8 * 1024 * 1024; /* 8GB */
12080+ ibcsstat.f_bfree = 500 * 1024; /* 100MB */
12081+ ibcsstat.f_files = 60000;
12082+ ibcsstat.f_ffree = 50000;
12083+ memset(ibcsstat.f_fname, 0, sizeof(ibcsstat.f_fname));
12084+ memset(ibcsstat.f_fpack, 0, sizeof(ibcsstat.f_fpack));
12085+
12086+ /* Finally, copy it to the user's buffer */
12087+ return copy_to_user(buf, &ibcsstat, len) ? -EFAULT : 0;
12088+}
12089+
12090+EXPORT_SYMBOL(svr4_statfs);
12091+
12092+int svr4_fstatfs(unsigned int fd, struct ibcs_statfs * buf, int len, int fstype)
12093+{
12094+ struct ibcs_statfs ibcsstat;
12095+
12096+ if (len > (int)sizeof(struct ibcs_statfs))
12097+ return -EINVAL;
12098+
12099+ if (!fstype) {
12100+ struct file * file;
12101+ struct statfs tmp;
12102+ int error;
12103+
12104+ error = -EBADF;
12105+ file = fget(fd);
12106+ if (!file)
12107+ goto out;
12108+ error = vfs_statfs(file->f_dentry->d_inode->i_sb, &tmp);
12109+ if (!error && copy_statfs(buf, &tmp))
12110+ error = -EFAULT;
12111+ fput(file);
12112+
12113+out:
12114+ return error;
12115+ }
12116+
12117+ /*
12118+ * Linux can't stat unmounted filesystems so we
12119+ * simply lie and claim 500MB of 8GB is free. Sorry.
12120+ */
12121+ ibcsstat.f_bsize = 1024;
12122+ ibcsstat.f_frsize = 0;
12123+ ibcsstat.f_blocks = 8 * 1024 * 1024; /* 8GB */
12124+ ibcsstat.f_bfree = 500 * 1024; /* 100MB */
12125+ ibcsstat.f_files = 60000;
12126+ ibcsstat.f_ffree = 50000;
12127+ memset(ibcsstat.f_fname, 0, sizeof(ibcsstat.f_fname));
12128+ memset(ibcsstat.f_fpack, 0, sizeof(ibcsstat.f_fpack));
12129+
12130+ /* Finally, copy it to the user's buffer */
12131+ return copy_to_user(buf, &ibcsstat, len) ? -EFAULT : 0;
12132+}
12133+
12134+EXPORT_SYMBOL(svr4_fstatfs);
12135+
12136+
12137+int svr4_open(const char *fname, int flag, int mode)
12138+{
12139+#ifdef __sparc__
12140+ return SYS(open)(fname, map_flags(flag, fl_ibcs_to_linux), mode);
12141+#else
12142+ int error, fd, args[3];
12143+ struct file *file;
12144+ mm_segment_t old_fs;
12145+ char *p;
12146+ struct sockaddr_un addr;
12147+
12148+ fd = SYS(open)(fname, map_flags(flag, fl_ibcs_to_linux), mode);
12149+ if (fd < 0)
12150+ return fd;
12151+
12152+ /* Sometimes a program may open a pathname which it expects
12153+ * to be a named pipe (or STREAMS named pipe) when the
12154+ * Linux domain equivalent is a Unix domain socket. (e.g.
12155+ * UnixWare uses a STREAMS named pipe /dev/X/Nserver.0 for
12156+ * X :0 but Linux uses a Unix domain socket /tmp/.X11-unix/X0)
12157+ * It isn't enough just to make the symlink because you cannot
12158+ * open() a socket and read/write it. If we spot the error we can
12159+ * switch to socket(), connect() and things will likely work
12160+ * as expected however.
12161+ */
12162+ file = fget(fd);
12163+ if (!file)
12164+ return fd; /* Huh?!? */
12165+ if (!S_ISSOCK(file->f_dentry->d_inode->i_mode)) {
12166+ fput(file);
12167+ return fd;
12168+ }
12169+ fput(file);
12170+
12171+ SYS(close)(fd);
12172+ args[0] = AF_UNIX;
12173+ args[1] = SOCK_STREAM;
12174+ args[2] = 0;
12175+ old_fs = get_fs();
12176+ set_fs(get_ds());
12177+ fd = SYS(socketcall)(SYS_SOCKET, args);
12178+ set_fs(old_fs);
12179+ if (fd < 0)
12180+ return fd;
12181+
12182+ p = getname(fname);
12183+ if (IS_ERR(p)) {
12184+ SYS(close)(fd);
12185+ return PTR_ERR(p);
12186+ }
12187+ if (strlen(p) >= UNIX_PATH_MAX) {
12188+ putname(p);
12189+ SYS(close)(fd);
12190+ return -E2BIG;
12191+ }
12192+ addr.sun_family = AF_UNIX;
12193+ strcpy(addr.sun_path, p);
12194+ putname(p);
12195+
12196+ args[0] = fd;
12197+ args[1] = (int)&addr;
12198+ args[2] = sizeof(struct sockaddr_un);
12199+ set_fs(get_ds());
12200+ error = SYS(socketcall)(SYS_CONNECT, args);
12201+ set_fs(old_fs);
12202+ if (error) {
12203+ SYS(close)(fd);
12204+ return error;
12205+ }
12206+
12207+ return fd;
12208+#endif
12209+}
12210+
12211+EXPORT_SYMBOL(svr4_open);
12212+
12213+
12214+#define NAME_OFFSET(de) ((int) ((de)->d_name - (char *) (de)))
12215+#define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
12216+
12217+struct svr4_getdents_callback {
12218+ struct dirent * current_dir;
12219+ struct dirent * previous;
12220+ int count;
12221+ int error;
12222+};
12223+
12224+static int svr4_filldir(void * __buf, const char * name, int namlen, off_t offset,
12225+ ino_t ino, unsigned int d_type)
12226+{
12227+ struct dirent * dirent;
12228+ struct svr4_getdents_callback * buf = (struct svr4_getdents_callback *) __buf;
12229+ int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
12230+
12231+ buf->error = -EINVAL; /* only used if we fail.. */
12232+ if (reclen > buf->count)
12233+ return -EINVAL;
12234+
12235+ dirent = buf->previous;
12236+ if (dirent)
12237+ put_user(offset, &dirent->d_off);
12238+ dirent = buf->current_dir;
12239+ buf->previous = dirent;
12240+
12241+ if (current->personality & SHORT_INODE) {
12242+ /* read() on a directory only handles
12243+ * short inodes but cannot use 0 as that
12244+ * indicates an empty directory slot.
12245+ * Therefore stat() must also fold
12246+ * inode numbers avoiding 0. Which in
12247+ * turn means that getdents() must fold
12248+ * inodes avoiding 0 - if the program
12249+ * was built in a short inode environment.
12250+ * If we have short inodes in the dirent
12251+ * we also have a two byte pad so we
12252+ * can let the high word fall in the pad.
12253+ * This makes it a little more robust if
12254+ * we guessed the inode size wrong.
12255+ */
12256+ if (!((unsigned long)dirent->d_ino & 0xffff))
12257+ dirent->d_ino = 0xfffffffe;
12258+ }
12259+
12260+ put_user(ino, &dirent->d_ino);
12261+ put_user(reclen, &dirent->d_reclen);
12262+ copy_to_user(dirent->d_name, name, namlen);
12263+ put_user(0, dirent->d_name + namlen);
12264+ ((char *) dirent) += reclen;
12265+ buf->current_dir = dirent;
12266+ buf->count -= reclen;
12267+ return 0;
12268+}
12269+
12270+
12271+
12272+int svr4_getdents(int fd, char *dirent, int count)
12273+{
12274+ struct file * file;
12275+ struct dirent * lastdirent;
12276+ struct svr4_getdents_callback buf;
12277+ int error;
12278+
12279+ error = -EBADF;
12280+ file = fget(fd);
12281+ if (!file)
12282+ goto out;
12283+
12284+ buf.current_dir = (struct dirent *) dirent;
12285+ buf.previous = NULL;
12286+ buf.count = count;
12287+ buf.error = 0;
12288+ error = vfs_readdir(file, svr4_filldir, &buf);
12289+ if (error < 0)
12290+ goto out_putf;
12291+ error = buf.error;
12292+ lastdirent = buf.previous;
12293+ if (lastdirent) {
12294+ put_user(file->f_pos, &lastdirent->d_off);
12295+ error = count - buf.count;
12296+ }
12297+
12298+out_putf:
12299+ fput(file);
12300+
12301+out:
12302+ return error;
12303+}
12304+
12305+EXPORT_SYMBOL(svr4_getdents);
12306+
12307+struct ibcs_flock {
12308+ short l_type; /* numbers don't match */
12309+ short l_whence;
12310+ off_t l_start;
12311+ off_t l_len; /* 0 means to end of file */
12312+ short l_sysid;
12313+ short l_pid;
12314+};
12315+
12316+
12317+int svr4_fcntl(struct pt_regs *regs)
12318+{
12319+ int arg1, arg2, arg3;
12320+ int error, retval;
12321+
12322+#ifndef __sparc__
12323+ error = verify_area(VERIFY_READ,
12324+ ((unsigned long *)regs->esp)+1,
12325+ 3*sizeof(long));
12326+ if (error)
12327+ return error;
12328+#endif /* __sparc__ */
12329+ arg1 = get_syscall_parameter (regs, 0);
12330+ arg2 = get_syscall_parameter (regs, 1);
12331+ arg3 = get_syscall_parameter (regs, 2);
12332+
12333+ switch (arg2) {
12334+ /* These match the Linux commands. */
12335+ case 0: /* F_DUPFD */
12336+ case 1: /* F_GETFD */
12337+ case 2: /* F_SETFD */
12338+ return SYS(fcntl)(arg1, arg2, arg3);
12339+
12340+ /* The iBCS flags don't match Linux flags. */
12341+ case 3: /* F_GETFL */
12342+ return map_flags(SYS(fcntl)(arg1, arg2, arg3),
12343+ fl_linux_to_ibcs);
12344+ case 4: /* F_SETFL */
12345+ arg3 = map_flags(arg3, fl_ibcs_to_linux);
12346+ return SYS(fcntl)(arg1, arg2, arg3);
12347+
12348+ /* The lock stucture is different. */
12349+ case 14: /* F_GETLK SVR4 */
12350+ arg2 = 5;
12351+ /* fall through */
12352+ case 5: /* F_GETLK */
12353+ case 6: /* F_SETLK */
12354+ case 7: /* F_SETLKW */
12355+ {
12356+ struct ibcs_flock fl;
12357+ struct flock l_fl;
12358+ mm_segment_t old_fs;
12359+
12360+ error = verify_area(VERIFY_WRITE, (void *)arg3,
12361+ sizeof(fl));
12362+ if (error)
12363+ return error;
12364+ error = copy_from_user(&fl, (void *)arg3, sizeof(fl));
12365+ if (error)
12366+ return -EFAULT;
12367+
12368+ l_fl.l_type = fl.l_type - 1;
12369+ l_fl.l_whence = fl.l_whence;
12370+ l_fl.l_start = fl.l_start;
12371+ l_fl.l_len = fl.l_len;
12372+ l_fl.l_pid = fl.l_pid;
12373+
12374+ abi_trace(ABI_TRACE_API,
12375+ "lock l_type: %d l_whence: %d "
12376+ "l_start: %lu l_len: %lu "
12377+ "l_sysid: %d l_pid: %d\n",
12378+ fl.l_type, fl.l_whence,
12379+ fl.l_start, fl.l_len,
12380+ fl.l_sysid, fl.l_pid);
12381+
12382+ old_fs = get_fs();
12383+ set_fs(get_ds());
12384+ retval = SYS(fcntl)(arg1, arg2, &l_fl);
12385+ set_fs(old_fs);
12386+
12387+ if (!retval) {
12388+ fl.l_type = l_fl.l_type + 1;
12389+ fl.l_whence = l_fl.l_whence;
12390+ fl.l_start = l_fl.l_start;
12391+ fl.l_len = l_fl.l_len;
12392+ fl.l_sysid = 0;
12393+ fl.l_pid = l_fl.l_pid;
12394+ /* This should not fail... */
12395+ copy_to_user((void *)arg3, &fl, sizeof(fl));
12396+ }
12397+
12398+ return retval;
12399+ }
12400+
12401+ case 10: /* F_ALLOCSP */
12402+ /* Extend allocation for specified portion of file. */
12403+ case 11: /* F_FREESP */
12404+ /* Free a portion of a file. */
12405+ return 0;
12406+
12407+ /* These are intended to support the Xenix chsize() and
12408+ * rdchk() system calls. I don't know if these may be
12409+ * generated by applications or not.
12410+ */
12411+ case 0x6000: /* F_CHSIZE */
12412+ return SYS(ftruncate)(arg1, arg3);
12413+#ifndef __sparc__
12414+ case 0x6001: /* F_RDCHK */
12415+ return xnx_rdchk(arg1);
12416+#endif /* __sparc__ */
12417+
12418+#ifdef CONFIG_ABI_IBCS_SCO
12419+ /* This could be SCO's get highest fd open if the fd we
12420+ * are called on is -1 otherwise it could be F_CHKFL.
12421+ */
12422+ case 8: /* F_GETHFDO */
12423+ if (arg1 == -1)
12424+ return find_first_zero_bit(current->files->open_fds,
12425+ current->files->max_fdset);
12426+ /* else fall through to fail */
12427+#else
12428+ /* The following are defined but reserved and unknown. */
12429+ case 8: /* F_CHKFL */
12430+#endif
12431+
12432+ /* These are made from the Xenix locking() system call.
12433+ * According to available documentation these would
12434+ * never be generated by an application - only by the
12435+ * kernel Xenix support.
12436+ */
12437+ case 0x6300: /* F_LK_UNLCK */
12438+ case 0x7200: /* F_LK_LOCK */
12439+ case 0x6200: /* F_LK_NBLCK */
12440+ case 0x7100: /* F_LK_RLCK */
12441+ case 0x6100: /* F_LK_NBRLCK */
12442+
12443+ default:
12444+ abi_trace(ABI_TRACE_API,
12445+ "unsupported fcntl 0x%lx, arg 0x%lx",
12446+ (u_long)arg2, (u_long)arg3);
12447+
12448+ return -EINVAL;
12449+ break;
12450+ }
12451+}
12452+EXPORT_SYMBOL(svr4_fcntl);
12453diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/poll.c linux/abi/svr4/poll.c
12454--- linux-2.4.3/abi/svr4/poll.c Thu Jan 1 01:00:00 1970
12455+++ linux/abi/svr4/poll.c Sun Mar 18 11:54:28 2001
12456@@ -0,0 +1,99 @@
12457+/* $Id$
12458+ *
12459+ * This file contains the procedures for the handling of poll.
12460+ *
12461+ * Copyright (C) 1994 Eric Youngdale
12462+ *
12463+ * Created for Linux based loosely upon linux select code, which
12464+ * in turn is loosely based upon Mathius Lattner's minix
12465+ * patches by Peter MacDonald. Heavily edited by Linus.
12466+ *
12467+ * Poll is used by SVr4 instead of select, and it has considerably
12468+ * more functionality. Parts of it are related to STREAMS, and since
12469+ * we do not have streams, we fake it. In fact, select() still exists
12470+ * under SVr4, but libc turns it into a poll() call instead.
12471+ *
12472+ * (note: poll is now native to Linux... -- hch)
12473+ */
12474+
12475+#include <linux/config.h>
12476+#include <linux/module.h>
12477+#include <linux/version.h>
12478+
12479+#include <linux/types.h>
12480+#include <linux/time.h>
12481+#include <linux/fs.h>
12482+#include <linux/kernel.h>
12483+#include <linux/sched.h>
12484+#include <linux/string.h>
12485+#include <linux/stat.h>
12486+#include <linux/signal.h>
12487+#include <linux/errno.h>
12488+#include <linux/slab.h>
12489+
12490+#include <asm/uaccess.h>
12491+#include <asm/system.h>
12492+
12493+#include <abi/abi.h>
12494+#include <abi/tli.h>
12495+#include <abi/svr4.h>
12496+#include <abi/trace.h>
12497+
12498+/* FIXME: This is just copied from linux/fs/select.c simply so we can
12499+ * add the XTI message check - and even then only if XTI is enabled
12500+ * in the module. We could probably do better. But see the following
12501+ * comment which notes the possibility of needing to do some flag
12502+ * mapping in the event vectors one day...
12503+ */
12504+
12505+/* FIXME: Some of the event flags may need mapping. This list does
12506+ * not agree with the list Linux is using. The important ones do, but...
12507+ */
12508+#define POLLIN 1
12509+#define POLLPRI 2
12510+#define POLLOUT 4
12511+#define POLLERR 8
12512+#define POLLHUP 16
12513+#define POLLNVAL 32
12514+#define POLLRDNORM 64
12515+#define POLLWRNORM POLLOUT
12516+#define POLLRDBAND 128
12517+#define POLLWRBAND 256
12518+
12519+#define DEFAULT_POLLMASK (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
12520+
12521+
12522+/*
12523+ * FIXME: just have the callmap go direct to Linux poll()?
12524+ */
12525+int
12526+svr4_poll(struct poll * ufds, size_t nfds, int timeout)
12527+{
12528+ int error;
12529+
12530+ if (abi_traced(ABI_TRACE_API)) {
12531+ int i;
12532+
12533+ for (i = 0; i < nfds; i++) {
12534+ __abi_trace(" %3d 0x%04x 0x%04x",
12535+ ufds[i].fd, ufds[i].events,
12536+ ufds[i].revents);
12537+ }
12538+ }
12539+
12540+ error = SYS(poll)(ufds, nfds, timeout);
12541+
12542+ if (abi_traced(ABI_TRACE_API)) {
12543+ int i;
12544+
12545+ for (i = 0; i < nfds; i++) {
12546+ __abi_trace(" %3d 0x%04x 0x%04x",
12547+ ufds[i].fd, ufds[i].events,
12548+ ufds[i].revents);
12549+ }
12550+ }
12551+
12552+ return error;
12553+}
12554+
12555+EXPORT_SYMBOL(svr4_poll);
12556diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/ptrace.c linux/abi/svr4/ptrace.c
12557--- linux-2.4.3/abi/svr4/ptrace.c Thu Jan 1 01:00:00 1970
12558+++ linux/abi/svr4/ptrace.c Mon Mar 12 16:34:48 2001
12559@@ -0,0 +1,145 @@
12560+/* $Id$
12561+ *
12562+ * sysv ptrace(2) emulation
12563+ *
12564+ * Copyright (C) 1995 Mike Jagdis
12565+ *
12566+ */
12567+
12568+#include <linux/config.h>
12569+#include <linux/module.h>
12570+
12571+#include <asm/uaccess.h>
12572+
12573+#include <linux/errno.h>
12574+#include <linux/sched.h>
12575+#include <linux/kernel.h>
12576+#include <linux/mm.h>
12577+#include <linux/user.h>
12578+
12579+#include <abi/abi.h>
12580+#include <abi/signal.h>
12581+#include <abi/trace.h>
12582+
12583+
12584+#define NREGS 19
12585+
12586+#define U(X) ((unsigned long)&((struct user *)0)->X)
12587+
12588+#ifdef CONFIG_ABI_IBCS_SCO
12589+static unsigned long sco_to_linux_reg[NREGS] = {
12590+ U(regs.gs), U(regs.fs), U(regs.es), U(regs.ds),
12591+ U(regs.edi), U(regs.esi),
12592+ U(regs.ebp),
12593+ U(regs.esp /* ESP */),
12594+ U(regs.ebx), U(regs.edx), U(regs.ecx), U(regs.eax),
12595+ U(signal /* Trap */),
12596+ U(reserved /* ERR */),
12597+ U(regs.eip), U(regs.cs), U(regs.eflags),
12598+ U(regs.esp), U(regs.ss)
12599+};
12600+#endif
12601+
12602+#ifdef CONFIG_ABI_IBCS_WYSE
12603+static unsigned long wysev386_to_linux_reg[NREGS] = {
12604+ U(regs.es), U(regs.ds), U(regs.edi), U(regs.esi),
12605+ U(regs.ebp), U(regs.esp),
12606+ U(regs.ebx), U(regs.edx), U(regs.ecx), U(regs.eax),
12607+ U(signal /* Trap */),
12608+ U(reserved /* ERR */),
12609+ U(regs.eip), U(regs.cs),
12610+ U(regs.eflags),
12611+ U(regs.esp /* UESP */),
12612+ U(regs.ss),
12613+ U(regs.fs), U(regs.gs)
12614+};
12615+#endif
12616+
12617+
12618+unsigned long *reg_map[] = {
12619+ NULL,
12620+ NULL, /* SVR4 */
12621+ NULL, /* SVR3 is a subset of SVR4 */
12622+#ifdef CONFIG_ABI_IBCS_SCO
12623+ sco_to_linux_reg, /* SCO SVR3 */
12624+#else
12625+ NULL,
12626+#endif
12627+#ifdef CONFIG_ABI_IBCS_WYSE
12628+ wysev386_to_linux_reg, /* Wyse V/386 */
12629+#else
12630+ NULL,
12631+#endif
12632+ NULL, /* ISC R4 */
12633+ NULL, /* BSD */
12634+ NULL /* Xenix */
12635+};
12636+
12637+
12638+int svr4_ptrace(int req, int pid, unsigned long addr, unsigned long data)
12639+{
12640+#if !defined(CONFIG_ABI_IBCS_SCO) && !defined(CONFIG_ABI_IBCS_WYSE)
12641+ return -EIO;
12642+#else
12643+ unsigned long res;
12644+
12645+ /* Slight variations between iBCS and Linux codes. */
12646+ if (req == PTRACE_ATTACH)
12647+ req = 10;
12648+ else if (req == PTRACE_DETACH)
12649+ req = 11;
12650+
12651+ /* Remap access to the registers. */
12652+ if (req == 3 || req == 6) {
12653+ if (addr == 0x1200 /* get offset of u_ar0 (SCO) */
12654+ || addr == 0x1292) { /* get offset of u_ar0 (Wyse V/386) */
12655+ return 0x4000;
12656+ }
12657+
12658+ if ((addr & 0xff00) == 0x4000) { /* Registers */
12659+ addr = (addr & 0xff) >> 2;
12660+ if (addr > NREGS
12661+ || (int)(addr = reg_map[current->personality & PER_MASK][addr]) == -1)
12662+ return -EIO;
12663+ }
12664+ }
12665+
12666+ if (req == 7 && data > 0) {
12667+ if (data > NSIGNALS)
12668+ return -EIO;
12669+ data = current->exec_domain->signal_map[data];
12670+ }
12671+
12672+ if (req == 1 || req == 2 || req == 3) {
12673+ mm_segment_t old_fs;
12674+ int error;
12675+
12676+ old_fs = get_fs();
12677+ set_fs(get_ds());
12678+ error = SYS(ptrace)(req, pid, addr, &res);
12679+ set_fs(old_fs);
12680+ if (error)
12681+ return error;
12682+ }
12683+
12684+ if ((abi_traced(ABI_TRACE_API)) && (req == 3 || req == 6)) {
12685+ static const char * const regnam[] = {
12686+ "EBX", "ECX", "EDX", "ESI", "EDI", "EBP", "EAX",
12687+ "DS", "ES", "FS", "GS", "ORIG_EAX", "EIP", "CS",
12688+ "EFL", "UESP", "SS"
12689+ };
12690+ __abi_trace("%ld [%s] = 0x%08lx\n",
12691+ addr>>2,
12692+ (addr>>2) < sizeof(regnam)/sizeof(regnam[0])
12693+ ? regnam[addr>>2] : "???",
12694+ req == 3 ? res : data);
12695+ }
12696+
12697+ if (req == 1 || req == 2 || req == 3)
12698+ return res;
12699+
12700+ return SYS(ptrace)(req, pid, addr, data);
12701+#endif /* !defined(CONFIG_ABI_IBCS_SCO) && !defined(CONFIG_ABI_IBCS_WYSE) */
12702+}
12703+
12704+EXPORT_SYMBOL(svr4_ptrace);
12705diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/sco_secureware.c linux/abi/svr4/sco_secureware.c
12706--- linux-2.4.3/abi/svr4/sco_secureware.c Thu Jan 1 01:00:00 1970
12707+++ linux/abi/svr4/sco_secureware.c Mon Mar 12 16:34:48 2001
12708@@ -0,0 +1,52 @@
12709+/* $Id$
12710+ *
12711+ * sco_secureware.c - secureware syscall emulation
12712+ *
12713+ * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
12714+ *
12715+ *
12716+ * SecureWare, Inc. provided the C2 security subsystem used on SCO Unix.
12717+ * This is not that package. This does not even attempt to emulate
12718+ * that package. This emulates just enough of the "obvious" bits to
12719+ * allow some programs to get a bit further. It is not useful to
12720+ * try to implement C2 security in an emulator. Nor is it particularly
12721+ * useful to run SCO's secure admin programs on Linux anyway...
12722+ */
12723+
12724+#include <linux/errno.h>
12725+#include <linux/kernel.h>
12726+#include <linux/sched.h>
12727+
12728+#include <abi/abi.h>
12729+#include <abi/trace.h>
12730+
12731+
12732+int
12733+sw_security(int cmd, void *p1, void *p2, void *p3, void *p4, void *p5)
12734+{
12735+ switch (cmd) {
12736+ case 1: /* getluid */
12737+ /* We want the login user id. We don't have it
12738+ * specifically so we'll just use the real uid
12739+ * instead - it should be good enough.
12740+ */
12741+ return current->uid;
12742+
12743+ case 2: /* setluid */
12744+ /* Strictly we should only be able to call setluid()
12745+ * once but we can't enforce that. We have the choice
12746+ * between having it always succeed or always fail.
12747+ * Since setluid() should only ever be invoked by
12748+ * things like login processes we always fail it.
12749+ */
12750+ return -EPERM;
12751+
12752+ case 0:
12753+ case 3:
12754+ case 4:
12755+ default:
12756+ printk(KERN_ERR "iBCS: unsupported security call cmd=%d\n",
12757+ cmd);
12758+ return -EINVAL;
12759+ }
12760+}
12761diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/stream.c linux/abi/svr4/stream.c
12762--- linux-2.4.3/abi/svr4/stream.c Thu Jan 1 01:00:00 1970
12763+++ linux/abi/svr4/stream.c Mon Mar 12 16:34:48 2001
12764@@ -0,0 +1,132 @@
12765+/* $Id$
12766+ * stream.c - SVR4 streams handling
12767+ *
12768+ * Copyright 1994,1995 Mike Jagdis (jaggy@purplet.demon.co.uk)
12769+ *
12770+ */
12771+
12772+#include <linux/config.h>
12773+#include <linux/module.h>
12774+
12775+#include <asm/uaccess.h>
12776+
12777+#include <linux/types.h>
12778+#include <linux/errno.h>
12779+#include <linux/kernel.h>
12780+#include <linux/ptrace.h>
12781+#include <linux/net.h>
12782+#include <linux/mm.h>
12783+#include <linux/socket.h>
12784+#include <linux/file.h>
12785+
12786+#include <abi/abi.h>
12787+#include <abi/stream.h>
12788+#include <abi/tli.h>
12789+#include <abi/trace.h>
12790+
12791+
12792+int svr4_getmsg(struct pt_regs *regs)
12793+{
12794+ int fd;
12795+ struct file *filep;
12796+ struct inode *ino;
12797+ int error;
12798+
12799+ fd = (int)get_syscall_parameter (regs, 0);
12800+ filep = fget(fd);
12801+ if (!filep)
12802+ return -EBADF;
12803+
12804+ error = -EBADF;
12805+ ino = filep->f_dentry->d_inode;
12806+ if (ino->i_sock) {
12807+#if defined(CONFIG_ABI_XTI) || defined(CONFIG_ABI_SPX)
12808+ error = timod_getmsg(fd, ino, 0, regs);
12809+#else
12810+ error = 0;
12811+#endif /* CONFIG_ABI_XTI */
12812+ }
12813+ fput(filep);
12814+ return error;
12815+}
12816+
12817+EXPORT_SYMBOL(svr4_getmsg);
12818+
12819+
12820+int svr4_putmsg(struct pt_regs *regs)
12821+{
12822+ int fd;
12823+ struct file *filep;
12824+ struct inode *ino;
12825+ int error;
12826+
12827+ fd = (int)get_syscall_parameter (regs, 0);
12828+ filep = fget(fd);
12829+ if (!filep)
12830+ return -EBADF;
12831+
12832+ error = -EBADF;
12833+ ino = filep->f_dentry->d_inode;
12834+ if (ino->i_sock
12835+ || (MAJOR(ino->i_rdev) == 30 && MINOR(ino->i_rdev) == 1)) {
12836+#if defined(CONFIG_ABI_XTI) || defined(CONFIG_ABI_SPX)
12837+ error = timod_putmsg(fd, ino, 0, regs);
12838+#else
12839+ error = 0;
12840+#endif
12841+ }
12842+ fput(filep);
12843+ return error;
12844+}
12845+
12846+EXPORT_SYMBOL(svr4_putmsg);
12847+
12848+#ifdef CONFIG_ABI_XTI
12849+int svr4_getpmsg(struct pt_regs *regs)
12850+{
12851+ int fd;
12852+ struct file *filep;
12853+ struct inode *ino;
12854+ int error;
12855+
12856+ fd = (int)get_syscall_parameter (regs, 0);
12857+
12858+ filep = fget(fd);
12859+ if (!filep)
12860+ return -EBADF;
12861+
12862+ error = -EBADF;
12863+ ino = filep->f_dentry->d_inode;
12864+ if (ino->i_sock)
12865+ error = timod_getmsg(fd, ino, 1, regs);
12866+ fput(filep);
12867+ return error;
12868+}
12869+
12870+EXPORT_SYMBOL(svr4_getpmsg);
12871+
12872+int svr4_putpmsg(struct pt_regs *regs)
12873+{
12874+ int fd;
12875+ struct file *filep;
12876+ struct inode *ino;
12877+ int error;
12878+
12879+ fd = (int)get_syscall_parameter (regs, 0);
12880+
12881+ filep = fget(fd);
12882+ if (!filep)
12883+ return -EBADF;
12884+
12885+ error = -EBADF;
12886+ ino = filep->f_dentry->d_inode;
12887+ if (ino->i_sock
12888+ || (MAJOR(ino->i_rdev) == 30 && MINOR(ino->i_rdev) == 1))
12889+ error = timod_putmsg(fd, ino, 1, regs);
12890+ fput(filep);
12891+ return error;
12892+}
12893+
12894+EXPORT_SYMBOL(svr4_putpmsg);
12895+
12896+#endif /* CONFIG_ABI_XTI */
12897diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/svr4.c linux/abi/svr4/svr4.c
12898--- linux-2.4.3/abi/svr4/svr4.c Thu Jan 1 01:00:00 1970
12899+++ linux/abi/svr4/svr4.c Sun Mar 18 11:54:28 2001
12900@@ -0,0 +1,346 @@
12901+/* $Id$
12902+ *
12903+ * This file contains the emulation of some simple sysv syscalls
12904+ *
12905+ * Copyright (C) 1995 Mike Jagdis
12906+ *
12907+ */
12908+
12909+#include <linux/config.h>
12910+#include <linux/module.h>
12911+
12912+#include <asm/uaccess.h>
12913+
12914+#include <linux/types.h>
12915+#include <linux/errno.h>
12916+#include <linux/sched.h>
12917+#include <linux/kernel.h>
12918+#include <linux/mm.h>
12919+#include <linux/stddef.h>
12920+#include <linux/unistd.h>
12921+#include <linux/ptrace.h>
12922+#include <linux/fcntl.h>
12923+#include <linux/time.h>
12924+
12925+#include <asm/system.h>
12926+#include <linux/fs.h>
12927+#include <linux/sys.h>
12928+#include <linux/slab.h>
12929+
12930+#include <abi/abi.h>
12931+#include <abi/abi4.h>
12932+#include <abi/svr4.h>
12933+#include <abi/trace.h>
12934+#include <abi/svr4sig.h>
12935+#include <abi/solaris.h>
12936+
12937+/*
12938+ * Interactive SVR4's /bin/sh calls access(... 011) but Linux returns
12939+ * EINVAL if the access mode has any other bits than 007 set.
12940+ */
12941+
12942+int
12943+svr4_access(char *path, int mode)
12944+{
12945+ return SYS(access)(path, mode & 007);
12946+}
12947+
12948+
12949+int
12950+svr4_getgroups(int n, unsigned long *buf)
12951+{
12952+ int i;
12953+
12954+ if (n) {
12955+ i = verify_area(VERIFY_WRITE, buf, sizeof(unsigned long) * n);
12956+ if (i)
12957+ return i;
12958+ }
12959+ for (i = 0; i < current->ngroups && i < n; i++) {
12960+ put_user(current->groups[i], buf);
12961+ buf++;
12962+ }
12963+ return(i);
12964+}
12965+
12966+
12967+int
12968+svr4_setgroups(int n, unsigned long *buf)
12969+{
12970+ int i;
12971+
12972+ if (!capable(CAP_SETGID))
12973+ return -EPERM;
12974+ if (n > NGROUPS)
12975+ return -EINVAL;
12976+ /* FIXME: Yuk! What if we hit a bad address? */
12977+ for (i = 0; i < n; i++, buf++) {
12978+ get_user(current->groups[i], buf);
12979+ }
12980+ current->ngroups = n;
12981+ return 0;
12982+}
12983+
12984+
12985+int
12986+svr4_waitid(int idtype, int id, struct svr4_siginfo *infop, int options)
12987+{
12988+ long result, kopt;
12989+ mm_segment_t old_fs;
12990+ int pid, status;
12991+
12992+ switch (idtype) {
12993+ case 0: /* P_PID */
12994+ pid = id;
12995+ break;
12996+
12997+ case 1: /* P_PGID */
12998+ pid = -id;
12999+ break;
13000+
13001+ case 7: /* P_ALL */
13002+ pid = -1;
13003+ break;
13004+
13005+ default:
13006+ return -EINVAL;
13007+ }
13008+
13009+ if (infop) {
13010+ result = verify_area(VERIFY_WRITE, infop,
13011+ sizeof(struct svr4_siginfo));
13012+ if (result)
13013+ return result;
13014+ }
13015+
13016+ kopt = 0;
13017+ if (options & 0100) kopt |= WNOHANG;
13018+ if (options & 4) kopt |= WUNTRACED;
13019+
13020+ old_fs = get_fs();
13021+ set_fs(get_ds());
13022+ result = SYS(wait4)(pid, &status, kopt, NULL);
13023+ set_fs(old_fs);
13024+ if (result < 0)
13025+ return result;
13026+
13027+ if (infop) {
13028+ unsigned long op, st;
13029+
13030+ put_user(current->exec_domain->signal_map[SIGCHLD],
13031+ &infop->si_signo);
13032+ put_user(result,
13033+ &infop->_data._proc._pid);
13034+
13035+ if ((status & 0xff) == 0) {
13036+ /* Normal exit. */
13037+ op = SVR4_CLD_EXITED;
13038+ st = status >> 8;
13039+ } else if ((status & 0xff) == 0x7f) {
13040+ /* Stopped. */
13041+ st = (status & 0xff00) >> 8;
13042+ op = (st == SIGSTOP || st == SIGTSTP)
13043+ ? SVR4_CLD_STOPPED
13044+ : SVR4_CLD_CONTINUED;
13045+ st = current->exec_domain->signal_invmap[st];
13046+ } else {
13047+ st = (status & 0xff00) >> 8;
13048+ op = (status & 0200)
13049+ ? SVR4_CLD_DUMPED
13050+ : SVR4_CLD_KILLED;
13051+ st = current->exec_domain->signal_invmap[st];
13052+ }
13053+ put_user(op, &infop->si_code);
13054+ put_user(st, &infop->_data._proc._pdata._cld._status);
13055+ }
13056+ return 0;
13057+}
13058+
13059+EXPORT_SYMBOL(svr4_waitid);
13060+
13061+int
13062+svr4_seteuid(int uid)
13063+{
13064+ return SYS(setreuid)(-1, uid);
13065+}
13066+
13067+int
13068+svr4_setegid(int gid)
13069+{
13070+ return SYS(setregid)(-1, gid);
13071+}
13072+
13073+int
13074+svr4_pathconf(char *path, int name)
13075+{
13076+ switch (name) {
13077+ case _PC_LINK_MAX:
13078+ /* Although Linux headers define values on a per
13079+ * filesystem basis there is no way to access
13080+ * these without hard coding fs information here
13081+ * so for now we use a bogus value.
13082+ */
13083+ return LINK_MAX;
13084+
13085+ case _PC_MAX_CANON:
13086+ return MAX_CANON;
13087+
13088+ case _PC_MAX_INPUT:
13089+ return MAX_INPUT;
13090+
13091+ case _PC_PATH_MAX:
13092+ return PATH_MAX;
13093+
13094+ case _PC_PIPE_BUF:
13095+ return PIPE_BUF;
13096+
13097+ case _PC_CHOWN_RESTRICTED:
13098+ /* We should really think about this and tell
13099+ * the truth.
13100+ */
13101+ return 0;
13102+
13103+ case _PC_NO_TRUNC:
13104+ /* Not sure... It could be fs dependent? */
13105+ return 1;
13106+
13107+ case _PC_VDISABLE:
13108+ return 1;
13109+
13110+ case _PC_NAME_MAX: {
13111+ struct statfs buf;
13112+ char *p;
13113+ int error;
13114+ mm_segment_t old_fs;
13115+
13116+ p = getname(path);
13117+ error = PTR_ERR(p);
13118+ if (!IS_ERR(p)) {
13119+ old_fs = get_fs();
13120+ set_fs (get_ds());
13121+ error = SYS(statfs)(p, &buf);
13122+ set_fs(old_fs);
13123+ putname(p);
13124+ if (!error)
13125+ return buf.f_namelen;
13126+ }
13127+ return error;
13128+ }
13129+ }
13130+
13131+ return -EINVAL;
13132+}
13133+
13134+EXPORT_SYMBOL(svr4_pathconf);
13135+
13136+int
13137+svr4_fpathconf(int fildes, int name)
13138+{
13139+ switch (name) {
13140+ case _PC_LINK_MAX:
13141+ /* Although Linux headers define values on a per
13142+ * filesystem basis there is no way to access
13143+ * these without hard coding fs information here
13144+ * so for now we use a bogus value.
13145+ */
13146+ return LINK_MAX;
13147+
13148+ case _PC_MAX_CANON:
13149+ return MAX_CANON;
13150+
13151+ case _PC_MAX_INPUT:
13152+ return MAX_INPUT;
13153+
13154+ case _PC_PATH_MAX:
13155+ return PATH_MAX;
13156+
13157+ case _PC_PIPE_BUF:
13158+ return PIPE_BUF;
13159+
13160+ case _PC_CHOWN_RESTRICTED:
13161+ /* We should really think about this and tell
13162+ * the truth.
13163+ */
13164+ return 0;
13165+
13166+ case _PC_NO_TRUNC:
13167+ /* Not sure... It could be fs dependent? */
13168+ return 1;
13169+
13170+ case _PC_VDISABLE:
13171+ return 1;
13172+
13173+ case _PC_NAME_MAX: {
13174+ struct statfs buf;
13175+ int error;
13176+ mm_segment_t old_fs;
13177+
13178+ old_fs = get_fs();
13179+ set_fs (get_ds());
13180+ error = SYS(statfs)(fildes, &buf);
13181+ set_fs(old_fs);
13182+ if (!error)
13183+ return buf.f_namelen;
13184+ return error;
13185+ }
13186+ }
13187+
13188+ return -EINVAL;
13189+}
13190+
13191+EXPORT_SYMBOL(svr4_fpathconf);
13192+
13193+int
13194+svr4_sigpending(int which_routine, svr4_sigset_t *set)
13195+{
13196+ /* Solaris multiplexes on this one */
13197+ /* Which routine has the actual routine that should be called */
13198+
13199+ switch (which_routine){
13200+ case 1: /* sigpending */
13201+ printk ("iBCS/Intel: sigpending not implemented\n");
13202+ return -EINVAL;
13203+
13204+ case 2: /* sigfillset */
13205+ set->setbits [0] = ~0;
13206+ set->setbits [1] = 0;
13207+ set->setbits [2] = 0;
13208+ set->setbits [3] = 0;
13209+ return 0;
13210+ }
13211+ return -EINVAL;
13212+}
13213+
13214+EXPORT_SYMBOL(svr4_sigpending);
13215+
13216+static int
13217+svr4_setcontext(svr4_ucontext_t *c, struct pt_regs *regs)
13218+{
13219+ printk (KERN_DEBUG "Getting context\n");
13220+ return 0;
13221+}
13222+
13223+static int
13224+svr4_getcontext(svr4_ucontext_t *c, struct pt_regs *regs)
13225+{
13226+ printk (KERN_DEBUG "Setting context\n");
13227+ return 0;
13228+}
13229+
13230+int
13231+svr4_context(struct pt_regs *regs)
13232+{
13233+ int context_fn = get_syscall_parameter (regs, 0);
13234+ struct svr4_ucontext_t *uc = (void *) get_syscall_parameter (regs, 1);
13235+
13236+ switch (context_fn){
13237+ case 0: /* getcontext */
13238+ return svr4_getcontext (uc, regs);
13239+
13240+ case 1: /* setcontext */
13241+ return svr4_setcontext (uc, regs);
13242+ }
13243+ return -EINVAL;
13244+}
13245+
13246+EXPORT_SYMBOL(svr4_context);
13247diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/sysconf.c linux/abi/svr4/sysconf.c
13248--- linux-2.4.3/abi/svr4/sysconf.c Thu Jan 1 01:00:00 1970
13249+++ linux/abi/svr4/sysconf.c Mon Mar 12 16:34:48 2001
13250@@ -0,0 +1,178 @@
13251+/* $Id$
13252+ * sysconf.c - sysv sysconf(2) and sysconfig(2) emulation
13253+ *
13254+ * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
13255+ */
13256+
13257+#include <linux/module.h>
13258+#include <linux/errno.h>
13259+#include <linux/sched.h>
13260+#include <linux/kernel.h>
13261+#include <linux/mm.h>
13262+#include <linux/stddef.h>
13263+#include <linux/limits.h>
13264+#include <linux/unistd.h>
13265+#include <linux/ptrace.h>
13266+#include <linux/fcntl.h>
13267+#include <linux/smp.h>
13268+#include <linux/swap.h>
13269+#include <linux/fs.h>
13270+#include <linux/sys.h>
13271+#include <asm/uaccess.h>
13272+#include <asm/system.h>
13273+
13274+#include <abi/abi.h>
13275+#include <abi/svr4.h>
13276+#include <abi/trace.h>
13277+
13278+
13279+/* The sysconf() call is supposed to give applications access to various
13280+ * kernel parameters. According to SCO's man page this a POSIX mandated
13281+ * function. Perhaps it should be moved across as a native Linux call?
13282+ *
13283+ * N.B. SCO only has sysconf in the Xenix group. Therefore this is based
13284+ * on the Xenix spec. Is SVR4 the same? Wyse Unix V.3.2.1A doesn't have
13285+ * sysconf documented at all.
13286+ *
13287+ * N.B. 0-7 are required (by who?). Other values may be defined for
13288+ * various systems but there appears no guarantee that they match across
13289+ * platforms. Thus, unless we can identify what system the executable
13290+ * was compiled for, we probably prefer to have extensions fail. Hell,
13291+ * nothing important is going to use this obscure stuff anyway...
13292+ */
13293+#define _SC_ARG_MAX 0
13294+#define _SC_CHILD_MAX 1
13295+#define _SC_CLK_TCK 2
13296+#define _SC_NGROUPS_MAX 3
13297+#define _SC_OPEN_MAX 4
13298+#define _SC_JOB_CONTROL 5
13299+#define _SC_SAVED_IDS 6
13300+#define _SC_VERSION 7
13301+
13302+#define _SC_PAGESIZE 11
13303+#define _SCO_SC_PAGESIZE 34
13304+
13305+extern int max_threads;
13306+
13307+
13308+/* This is an SVR4 system call that is undocumented except for some
13309+ * hints in a header file. It appears to be a forerunner to the
13310+ * POSIX sysconf() call.
13311+ */
13312+int svr4_sysconfig(int name)
13313+{
13314+ switch (name) {
13315+ case _CONFIG_NGROUPS:
13316+ /* From limits.h */
13317+ return (NGROUPS_MAX);
13318+
13319+ case _CONFIG_CHILD_MAX:
13320+ /* From limits.h */
13321+ return (CHILD_MAX);
13322+
13323+ case _CONFIG_OPEN_FILES:
13324+ /* From limits.h */
13325+ return (OPEN_MAX);
13326+
13327+ case _CONFIG_POSIX_VER:
13328+ /* The version of the POSIX standard we conform
13329+ * to. SCO defines _POSIX_VERSION as 198808L
13330+ * sys/unistd.h. What are we? We are 199009L.
13331+ */
13332+ return (199009L);
13333+
13334+ case _CONFIG_PAGESIZE:
13335+ return (PAGE_SIZE);
13336+
13337+ case _CONFIG_CLK_TCK:
13338+ return (HZ);
13339+
13340+ case _CONFIG_XOPEN_VER:
13341+ return 4;
13342+
13343+ case _CONFIG_NACLS_MAX:
13344+ return 0;
13345+
13346+ case _CONFIG_NPROC:
13347+ return max_threads;
13348+
13349+ case _CONFIG_NENGINE:
13350+ case _CONFIG_NENGINE_ONLN:
13351+ return (smp_num_cpus);
13352+
13353+ case _CONFIG_TOTAL_MEMORY:
13354+ return (max_mapnr << (PAGE_SHIFT-10));
13355+
13356+ case _CONFIG_USEABLE_MEMORY:
13357+ case _CONFIG_GENERAL_MEMORY:
13358+ return ((unsigned long) (nr_free_pages()) << (PAGE_SHIFT-10));
13359+
13360+ case _CONFIG_DEDICATED_MEMORY:
13361+ return 0;
13362+
13363+ case _CONFIG_NCGS_CONF:
13364+ case _CONFIG_NCGS_ONLN:
13365+ case _CONFIG_MAX_ENG_PER_CG:
13366+ return 1; /* no NUMA-Q support on Linux yet */
13367+
13368+ case _CONFIG_CACHE_LINE:
13369+ return 32; /* XXX is there a more accurate way? */
13370+
13371+ case _CONFIG_KERNEL_VM:
13372+ return -EINVAL;
13373+
13374+ case _CONFIG_ARG_MAX:
13375+ /* From limits.h */
13376+ return (ARG_MAX);
13377+ }
13378+
13379+ abi_trace(ABI_TRACE_API, "unsupported sysconfig call %d", name);
13380+ return -EINVAL;
13381+}
13382+
13383+
13384+int ibcs_sysconf(int name)
13385+{
13386+ switch (name) {
13387+ case _SC_ARG_MAX:
13388+ /* From limits.h */
13389+ return (ARG_MAX);
13390+
13391+ case _SC_CHILD_MAX:
13392+ /* From limits.h */
13393+ return (CHILD_MAX);
13394+
13395+ case _SC_CLK_TCK:
13396+ return (HZ);
13397+
13398+ case _SC_NGROUPS_MAX:
13399+ /* From limits.h */
13400+ return (NGROUPS_MAX);
13401+
13402+ case _SC_OPEN_MAX:
13403+ /* From limits.h */
13404+ return (OPEN_MAX);
13405+
13406+ case _SC_JOB_CONTROL:
13407+ return (1);
13408+
13409+ case _SC_SAVED_IDS:
13410+ return (1);
13411+
13412+ case _SC_PAGESIZE:
13413+ case _SCO_SC_PAGESIZE:
13414+ return PAGE_SIZE;
13415+
13416+ case _SC_VERSION:
13417+ /* The version of the POSIX standard we conform
13418+ * to. SCO defines _POSIX_VERSION as 198808L
13419+ * sys/unistd.h. What are we?
13420+ */
13421+ return (198808L);
13422+ }
13423+
13424+ abi_trace(ABI_TRACE_API, "unsupported sysconf call %d", name);
13425+ return -EINVAL;
13426+}
13427+
13428+EXPORT_SYMBOL(svr4_sysconfig);
13429diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/sysfs.c linux/abi/svr4/sysfs.c
13430--- linux-2.4.3/abi/svr4/sysfs.c Thu Jan 1 01:00:00 1970
13431+++ linux/abi/svr4/sysfs.c Mon Mar 12 16:34:48 2001
13432@@ -0,0 +1,119 @@
13433+/* $Id$
13434+ * sysfs.c - sysfs(2) emulation
13435+ *
13436+ * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
13437+ */
13438+
13439+#include <linux/module.h>
13440+#include <asm/uaccess.h>
13441+#include <abi/abi.h>
13442+#include <abi/trace.h>
13443+
13444+/*
13445+ * The kernel sysfs() code is almost all we need but, apparently,
13446+ * the SCO (at least) sysfs() will also accept a "magic number"
13447+ * as an index argument and will return the name of the relevant
13448+ * file system. Since Linux doesn't have any concept of fs magic
13449+ * numbers outside the file system code themselves there is no
13450+ * clean way to do it in the kernel. There isn't a clean way to
13451+ * to it here either but it needs to be done somehow :-(.
13452+ */
13453+
13454+#define GETFSIND 1
13455+#define GETFSTYP 2
13456+#define GETNFSTYP 3
13457+
13458+
13459+int
13460+svr4_sysfs(int cmd, int arg1, int arg2)
13461+{
13462+ if (cmd == GETFSIND)
13463+ return SYS(sysfs)(cmd, (char *)arg1);
13464+
13465+ if (cmd == GETNFSTYP)
13466+ return SYS(sysfs)(cmd);
13467+
13468+ if (cmd == GETFSTYP) {
13469+ char *buf = (char *)arg2;
13470+ int error;
13471+
13472+ if (arg1 & 0x80000000)
13473+ arg1 &= 0x0000ffff;
13474+ if (arg1 >= 0 && arg1 < SYS(sysfs)(GETNFSTYP))
13475+ return SYS(sysfs)(cmd, arg1-1, arg2);
13476+
13477+ /*
13478+ * Kludge alert! Hardcoded known magic numbers!
13479+ */
13480+ switch (arg1) {
13481+ case 0xef53: case 0xffffef53:
13482+ case 0xef51: case 0xffffef51:
13483+ /*
13484+ * Some SCO programs (i.e. Informix Dynamic
13485+ * Server are using this to detect "real"
13486+ * filesystems by checking type names :-(.
13487+ * So we lie :-).
13488+ */
13489+ if (personality(PER_SCOSVR3))
13490+ error = copy_to_user(buf, "HTFS", 5);
13491+ else
13492+ error = copy_to_user(buf, "ext2", 5);
13493+ break;
13494+ case 0x137d:
13495+ error = copy_to_user(buf, "ext", 4);
13496+ break;
13497+ case 0x9660: case 0xffff9660:
13498+ error = copy_to_user(buf, "iso9660", 8);
13499+ break;
13500+ case 0x4d44:
13501+ error = copy_to_user(buf, "msdos", 6);
13502+ break;
13503+ case 0x6969:
13504+ error = copy_to_user(buf, "nfs", 4);
13505+ break;
13506+ case 0x9fa0: case 0xffff9fa0:
13507+ error = copy_to_user(buf, "proc", 5);
13508+ break;
13509+ case 0xf995e849:
13510+ case 0xe849: case 0xffffe849:
13511+ error = copy_to_user(buf, "hpfs", 5);
13512+ break;
13513+ case 0x137f: /* original */
13514+ case 0x138f: /* original + 30 char names */
13515+ case 0x2468: /* V2 */
13516+ case 0x2478: /* V2 + 30 char names */
13517+ error = copy_to_user(buf, "minix", 6);
13518+ break;
13519+ case 0x564c:
13520+ error = copy_to_user(buf, "ncpfs", 6);
13521+ break;
13522+ case 0x517b:
13523+ error = copy_to_user(buf, "smbfs", 6);
13524+ break;
13525+ case 0x00011954:
13526+ error = copy_to_user(buf, "ufs", 4);
13527+ break;
13528+ case 0x012fd16d: case 0xffffd16d:
13529+ error = copy_to_user(buf, "xiafs", 6);
13530+ break;
13531+ case 0x012ff7b3+1: case 0xfffff7b3+1:
13532+ error = copy_to_user(buf, "xenix", 6);
13533+ break;
13534+ case 0x012ff7b3+2: case 0xfffff7b3+2:
13535+ case 0x012ff7b3+3: case 0xfffff7b3+3:
13536+ error = copy_to_user(buf, "sysv", 5);
13537+ break;
13538+ case 0x012ff7b3+4: case 0xfffff7b3+4:
13539+ error = copy_to_user(buf, "coherent", 9);
13540+ break;
13541+ default:
13542+ error = copy_to_user(buf, "", 1);
13543+ break;
13544+ }
13545+ return error;
13546+ }
13547+
13548+ abi_trace(ABI_TRACE_API, "unsupported sysfs call %d", cmd);
13549+ return -EINVAL;
13550+}
13551+EXPORT_SYMBOL(svr4_sysfs);
13552diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/sysi86.c linux/abi/svr4/sysi86.c
13553--- linux-2.4.3/abi/svr4/sysi86.c Thu Jan 1 01:00:00 1970
13554+++ linux/abi/svr4/sysi86.c Mon Mar 12 16:34:48 2001
13555@@ -0,0 +1,235 @@
13556+/* $Id$
13557+ * sysi86.c - ix86 spcific sysv syscalls
13558+ *
13559+ * Copyright 1994,1995 Mike Jagdis <jaggy@purplet.demon.co.uk>
13560+ */
13561+
13562+#include <linux/module.h>
13563+#include <linux/errno.h>
13564+#include <linux/sched.h>
13565+#include <linux/kernel.h>
13566+#include <linux/mm.h>
13567+#include <linux/stddef.h>
13568+#include <linux/unistd.h>
13569+#include <linux/ptrace.h>
13570+#include <linux/fcntl.h>
13571+#include <linux/fs.h>
13572+#include <linux/sys.h>
13573+
13574+#include <asm/uaccess.h>
13575+#include <asm/system.h>
13576+
13577+#include <abi/abi.h>
13578+#include <abi/trace.h>
13579+
13580+
13581+/* The sysi86() call is used for machine specific functions. Only the
13582+ * most basic are implemented here.
13583+ */
13584+#define SI86SWPI 1 /* General swap functions. */
13585+#define SI86SYM 2 /* Get symbol table */
13586+#define SI86CONF 4 /* Get configuration table */
13587+#define SI86BOOT 5 /* Get timestamp and name of program
13588+ * booted.
13589+ */
13590+#define SI86DMM 7 /* Double-map data segment for
13591+ * read/write/execute support
13592+ */
13593+#define SI86AUTO 9 /* Was an auto-config boot done? */
13594+#define SI86EDT 10 /* Copy contents of EDT to user */
13595+#define SI86SWAP 12 /* Declare swap space */
13596+#define SI86FPHW 40 /* what (if any?) floating-point hardware */
13597+# define FP_NO 0 /* No fp at all */
13598+# define FP_SW 1 /* using emulator */
13599+# define FP_HW 2 /* using hardware */
13600+# define FP_287 2 /* using a 287 */
13601+# define FP_387 3 /* using a 387 */
13602+#define GRNON 52 /* set green light to solid on state */
13603+#define GRNFLASH 53 /* start green light flashing */
13604+#define STIME 54 /* set internal time */
13605+#define SETNAME 56 /* rename the system */
13606+#define RNVR 58 /* read NVRAM */
13607+#define WNVR 59 /* write NVRAM */
13608+#define RTODC 60 /* read time of day clock */
13609+#define CHKSER 61 /* check soft serial number */
13610+#define SI86NVPRT 62 /* print an xtra_nvr structure */
13611+#define SANUPD 63 /* sanity update of kernel buffers */
13612+#define SI86KSTR 64 /* make a copy of a kernel string */
13613+#define SI86MEM 65 /* return the memory size of system */
13614+#define SI86TODEMON 66 /* Transfer control to firmware. */
13615+#define SI86CCDEMON 67 /* Control character access to demon. */
13616+#define SI86CACHE 68 /* Turn cache on and off. */
13617+#define SI86DELMEM 69 /* Delete available memory for testing. */
13618+#define SI86ADDMEM 70 /* Add back deleted memory. */
13619+/* 71 through 74 reserved for VPIX */
13620+#define SI86V86 71 /* V86 system calls (see v86.h) */
13621+#define SI86SLTIME 72 /* Set local time correction */
13622+#define SI86DSCR 75 /* Set a segment or gate descriptor */
13623+#define RDUBLK 76 /* Read U Block */
13624+/* #ifdef MERGE386 */
13625+/* NFA entry point */
13626+#define SI86NFA 77 /* make nfa_sys system call */
13627+#define SI86VM86 81
13628+#define SI86VMENABLE 82
13629+/* #endif MERGE386 */
13630+#define SI86VM86 81
13631+#define SI86VMENABLE 82
13632+#define SI86LIMUSER 91 /* liscense interface */
13633+#define SI86RDID 92 /* ROM BIOS Machid ID */
13634+#define SI86RDBOOT 93 /* Bootable Non-SCSI Hard Disk */
13635+/* Merged Product defines */
13636+#define SI86SHFIL 100 /* map a file into addr space of a proc */
13637+#define SI86PCHRGN 101 /* make globally visible change to a region */
13638+#define SI86BADVISE 102 /* badvise subcommand - see below for */
13639+ /* badvise subfunction definitions */
13640+#define SI86SHRGN 103 /* enable/disable XENIX small model shared */
13641+ /* data context switching */
13642+#define SI86CHIDT 104 /* set user level int 0xf0, ... 0xff handlers */
13643+#define SI86EMULRDA 105 /* remove special emulator read access */
13644+#define SI86GETPIPE 106 /* return the pipe filesystem */
13645+#define SI86SETPIPE 107 /* set the pipe filesystem */
13646+#define SI86SETPIPE_NM 108 /* set the pipe filesystem -non mountable */
13647+#define SI86GETNPIPE 109 /* get # of pipe filesystems */
13648+#define SI86GETPIPE_ALL 110 /* get data on all of pipe filesystems */
13649+#define SI86POPPIPE 111 /* pop pipe file system off stack */
13650+#define SI86APM 112 /* get APM information passed by boot(HW) */
13651+#define SI86TIMECHG 113 /* get time before/after last timechange */
13652+#define SI86GETFEATURES 114 /* get os features vector */
13653+
13654+/* The SI86BADVISE command is used to set Xenix behaviour. */
13655+#define SI86B_SET 0x0100 /* Set badvise bits */
13656+#define SI86B_GET 0x0200 /* Get badvise bits */
13657+#define SI86B_LOCK 0x0001 /* XENIX advisory locking bit */
13658+#define SI86B_PRE_SV 0x0008 /* follow pre-System V x.out behavior */
13659+#define SI86B_XOUT 0x0010 /* follow XENIX x.out behavior */
13660+#define SI86B_XSDSWTCH 0x0080 /* XENIX small model shared data */
13661+ /* context switching enabled */
13662+
13663+
13664+/*
13665+ * The SI86DSCR subcommand of the sysi86() system call
13666+ * sets a segment or gate descriptor in the kernel.
13667+ * The following descriptor types are accepted:
13668+ * - executable and data segments in the LDT at DPL 3
13669+ * - a call gate in the GDT at DPL 3 that points to a segment in the LDT
13670+ * The request structure declared below is used to pass the values
13671+ * to be placed in the descriptor. A pointer to the structure is
13672+ * passed as the second argument of the system call.
13673+ * If acc1 is zero, the descriptor is cleared.
13674+ */
13675+
13676+/* request structure passed by user */
13677+struct ssd {
13678+ unsigned int sel; /* descriptor selector */
13679+ unsigned int bo; /* segment base or gate offset */
13680+ unsigned int ls; /* segment limit or gate selector */
13681+ unsigned int acc1; /* access byte 5 */
13682+ unsigned int acc2; /* access bits in byte 6 or gate count */
13683+};
13684+
13685+
13686+
13687+int svr4_sysi86(struct pt_regs * regs)
13688+{
13689+ int error, cmd;
13690+
13691+ error = get_user(cmd, ((unsigned long *) regs->esp) + 1);
13692+ if (error)
13693+ return error;
13694+
13695+ switch (cmd) {
13696+ case SI86FPHW: {
13697+ unsigned long *np;
13698+
13699+ /* If we remove the 'static' from the definition
13700+ * of fpu_error in linux/init/main.c we can tell
13701+ * whether we are using hardware or software at
13702+ * least. For now let's lie... (actually SCO
13703+ * Unix 3.4 gives me -1...)
13704+ */
13705+ get_user((unsigned long) np, ((unsigned long *) regs->esp) + 2);
13706+ error = verify_area(VERIFY_WRITE, np, sizeof(int));
13707+ if (error)
13708+ return error;
13709+ put_user(FP_387, np);
13710+ return 0;
13711+ }
13712+
13713+ case STIME: {
13714+ /* Set the system time. The argument is a long,
13715+ * sys_stime() expects a pointer to a long...
13716+ */
13717+ return SYS(stime)(((unsigned long *) regs->esp) + 2);
13718+ }
13719+
13720+ case SETNAME: {
13721+ /* The name is required to be string of no more
13722+ * than 7 characters. We don't get passed the
13723+ * length so we are depending upon the current
13724+ * implementation of sys_sethostname() here.
13725+ */
13726+ char *cp;
13727+
13728+ error = get_user((unsigned long) cp, ((unsigned long *) regs->esp) + 2);
13729+ if (error)
13730+ return error;
13731+ return SYS(sethostname)(cp, 7);
13732+ }
13733+
13734+ case SI86MEM: {
13735+ /* Returns the size of physical memory.
13736+ */
13737+ struct sysinfo i;
13738+
13739+ si_meminfo(&i);
13740+ return i.totalram;
13741+ }
13742+
13743+#if defined(CONFIG_ABI_IBCS_SCO)
13744+ case SI86GETFEATURES: {
13745+ char *vec;
13746+ int len, used;
13747+
13748+ if (!personality(PER_SCOSVR3)) {
13749+ current->personality &= ~PER_MASK;
13750+ current->personality |= PER_SCOSVR3;
13751+ }
13752+
13753+#if 1
13754+ error = get_user((unsigned long) vec, ((unsigned long *) regs->esp) + 2);
13755+ if (!error)
13756+ error = get_user(len, ((unsigned long *) regs->esp) + 3);
13757+ if (error)
13758+ return (error);
13759+ /* No, I don't know what these feature flags actually
13760+ * _mean_. This vector just matches SCO OS 5.0.0.
13761+ */
13762+ used = len > 12 ? 12 : len;
13763+ return copy_to_user(vec, "\001\001\001\001\001\001\001\001\002\001\001\001", used) ? -EFAULT : used;
13764+#else
13765+ return 0;
13766+#endif
13767+ }
13768+#endif
13769+
13770+ case SI86DSCR: {
13771+ struct ssd buf;
13772+ unsigned long ssdptr;
13773+
13774+ error = get_user(ssdptr, ((unsigned long *)regs->esp) + 2);
13775+ if (error)
13776+ return (error);
13777+ error = copy_from_user(&buf, (void *)ssdptr, sizeof(struct ssd));
13778+ if (error)
13779+ return (error);
13780+
13781+ printk("SI86DSCR(%x,%x,%x,%x,%x)\n",buf.sel,buf.bo,buf.ls,buf.acc1,buf.acc2);
13782+ return -EINVAL;
13783+ }
13784+ }
13785+
13786+ abi_trace(ABI_TRACE_API, "unsupported sysi86 call %d", cmd);
13787+ return -EINVAL;
13788+}
13789+
13790+EXPORT_SYMBOL(svr4_sysi86);
13791diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/sysinfo.c linux/abi/svr4/sysinfo.c
13792--- linux-2.4.3/abi/svr4/sysinfo.c Thu Jan 1 01:00:00 1970
13793+++ linux/abi/svr4/sysinfo.c Mon Mar 12 16:34:48 2001
13794@@ -0,0 +1,129 @@
13795+/* $Id$
13796+ *
13797+ * sysv sysinfo(2) syscall
13798+ *
13799+ * Copyright (C) 1995 Eric Youngdale
13800+ *
13801+ */
13802+
13803+#include <linux/config.h>
13804+#include <linux/module.h>
13805+#include <linux/version.h>
13806+#include <linux/compile.h>
13807+
13808+#include <asm/uaccess.h>
13809+
13810+#include <linux/mm.h>
13811+#include <linux/errno.h>
13812+#include <linux/sched.h>
13813+#include <abi/abi.h>
13814+#include <linux/utsname.h>
13815+#include <abi/trace.h>
13816+
13817+
13818+#define __O_SI_SYSNAME 1 /* return name of operating system */
13819+#define __O_SI_HOSTNAME 2 /* return name of node */
13820+#define SI_RELEASE 3 /* return release of operating system */
13821+#define SI_VERSION 4 /* return version field of utsname */
13822+#define __O_SI_MACHINE 5 /* return kind of machine */
13823+#define __O_SI_ARCHITECTURE 6 /* return instruction set arch */
13824+#define SI_HW_SERIAL 7 /* return hardware serial number */
13825+#define __O_SI_HW_PROVIDER 8 /* return hardware manufacturer */
13826+#define SI_SRPC_DOMAIN 9 /* return secure RPC domain */
13827+#define SI_INITTAB_NAME 10 /* return name of inittab file used */
13828+#define SI_ARCHITECTURE 100 /* return instruction set arch */
13829+#define SI_BUSTYPES 101 /* return list of bus types */
13830+#define SI_HOSTNAME 102 /* return fully-qualified node name */
13831+#define SI_HW_PROVIDER 103 /* return hardware manufacturer */
13832+#define SI_KERNEL_STAMP 104 /* return kernel generation timestamp */
13833+#define SI_MACHINE 105 /* return kind of machine */
13834+#define SI_OS_BASE 106 /* return base operating system */
13835+#define SI_OS_PROVIDER 107 /* return operating system provider */
13836+#define SI_SYSNAME 108 /* return name of operating system */
13837+#define SI_USER_LIMIT 109 /* return maximum number of users */
13838+
13839+
13840+
13841+int svr4_sysinfo(int cmd, char * buf, long count)
13842+{
13843+ char * return_string;
13844+ static unsigned int serial_number = 0;
13845+ char buffer[16];
13846+ int error;
13847+ int slen;
13848+
13849+ return_string = NULL;
13850+
13851+ switch(cmd) {
13852+ case __O_SI_SYSNAME:
13853+ case SI_SYSNAME:
13854+ return_string = system_utsname.sysname;
13855+ break;
13856+ case __O_SI_HOSTNAME:
13857+ case SI_HOSTNAME:
13858+ return_string = system_utsname.nodename;
13859+ break;
13860+ case SI_VERSION:
13861+ return_string = "2";
13862+ break;
13863+ case SI_RELEASE:
13864+ return_string = system_utsname.release;
13865+ break;
13866+ case SI_MACHINE:
13867+ case __O_SI_MACHINE:
13868+ return_string = system_utsname.machine;
13869+ break;
13870+ case __O_SI_ARCHITECTURE:
13871+ case SI_ARCHITECTURE:
13872+ return_string = "IA32"; /* XXX: this seems wrong, the name ia32 is very new ... -- ch */
13873+ break;
13874+ case SI_BUSTYPES:
13875+ return_string = "PCI ISA";
13876+ break;
13877+ case __O_SI_HW_PROVIDER:
13878+ case SI_HW_PROVIDER:
13879+ return_string = "Generic AT";
13880+ break;
13881+ case SI_KERNEL_STAMP:
13882+ return_string = UTS_VERSION;
13883+ break;
13884+ case SI_INITTAB_NAME:
13885+ return_string = "/etc/inittab";
13886+ break;
13887+ case SI_HW_SERIAL:
13888+ if(serial_number == 0)
13889+ serial_number = 0xdeadbeef;
13890+ sprintf(buffer,"%8.8x", serial_number);
13891+ return_string = buffer;
13892+ break;
13893+ case SI_OS_BASE:
13894+ return_string = "Linux";
13895+ break;
13896+ case SI_OS_PROVIDER:
13897+ return_string = "LBT"; /* someone's initials ? */
13898+ break;
13899+ case SI_SRPC_DOMAIN:
13900+ return_string = system_utsname.domainname;
13901+ break;
13902+ case SI_USER_LIMIT:
13903+ /* have you seen a Linux box with more than 500000 users? */
13904+ return_string = "500000";
13905+ break;
13906+ default:
13907+ abi_trace(ABI_TRACE_API,
13908+ "unsupported sysinfo call %d", cmd);
13909+ return -EINVAL;
13910+ }
13911+
13912+ if (!return_string)
13913+ return 0;
13914+
13915+ down_read(&uts_sem);
13916+ slen = (count < strlen(return_string) + 1 ? count : strlen(return_string) + 1);
13917+ error = copy_to_user(buf, return_string, slen);
13918+ up_read(&uts_sem);
13919+
13920+ return error ? -EFAULT : slen;
13921+}
13922+
13923+EXPORT_SYMBOL(svr4_sysinfo);
13924diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/syslocal.c linux/abi/svr4/syslocal.c
13925--- linux-2.4.3/abi/svr4/syslocal.c Thu Jan 1 01:00:00 1970
13926+++ linux/abi/svr4/syslocal.c Mon Mar 12 16:34:48 2001
13927@@ -0,0 +1,63 @@
13928+/* $Id$
13929+ * syslocal.c - wyse syslocal(2) emulation
13930+ *
13931+ * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
13932+ */
13933+
13934+#include <linux/module.h>
13935+#include <linux/errno.h>
13936+#include <asm/uaccess.h>
13937+
13938+#include <abi/abi.h>
13939+#include <abi/trace.h>
13940+
13941+
13942+/*
13943+ * The syslocal() call is used for machine specific functions. For
13944+ * instance on a Wyse 9000 it give information and control of the
13945+ * available processors.
13946+ */
13947+#ifdef CONFIG_ABI_IBCS_WYSE
13948+# define SL_ONLINE 0 /* Turn processor online */
13949+# define SL_OFFLINE 1 /* Turn processor offline */
13950+# define SL_QUERY 2 /* Query processor status */
13951+# define SL_NENG 3 /* Return No. of processors configured */
13952+# define SL_AFFINITY 4 /* processor binding */
13953+# define SL_CMC_STAT 7 /* gather CMC performance counters info */
13954+# define SL_KACC 8 /* make kernel data readable by user */
13955+# define SL_MACHTYPE 9 /* return machine type (MP/AT) */
13956+# define SL_BOOTNAME 10 /* return name of booted kernel */
13957+# define SL_BOOTDEV 11 /* return type of booted device */
13958+# define SL_UQUERY 12 /* query user status */
13959+
13960+# define SL_MACH_MP 0
13961+# define SL_MACH_AT 1
13962+# define SL_MACH_EISA 2
13963+# define SL_MACH_EMP 3
13964+#endif
13965+
13966+
13967+int
13968+svr4_syslocal(struct pt_regs * regs)
13969+{
13970+ int cmd;
13971+
13972+ cmd = get_syscall_parameter (regs, 0);
13973+
13974+#ifdef CONFIG_ABI_IBCS_WYSE
13975+ switch (cmd) {
13976+ case SL_QUERY:
13977+ return 0;
13978+
13979+ case SL_NENG:
13980+ return 1;
13981+
13982+ case SL_MACHTYPE:
13983+ return (EISA_bus ? SL_MACH_EISA : SL_MACH_AT);
13984+ }
13985+#endif
13986+
13987+ abi_trace(ABI_TRACE_API, "unsupported syslocal call %d", cmd);
13988+ return -EINVAL;
13989+}
13990+EXPORT_SYMBOL(svr4_syslocal);
13991diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/timod.c linux/abi/svr4/timod.c
13992--- linux-2.4.3/abi/svr4/timod.c Thu Jan 1 01:00:00 1970
13993+++ linux/abi/svr4/timod.c Fri Mar 30 15:23:46 2001
13994@@ -0,0 +1,1723 @@
13995+/* $Id$
13996+ *
13997+ * Copyright 1995, 1996 Mike Jagdis (jaggy@purplet.demon.co.uk)
13998+ *
13999+ */
14000+
14001+#include <linux/config.h>
14002+
14003+#ifdef CONFIG_ABI_XTI
14004+#include <linux/module.h>
14005+#include <linux/version.h>
14006+
14007+#include <asm/uaccess.h>
14008+
14009+#include <linux/types.h>
14010+#include <linux/errno.h>
14011+#include <linux/fs.h>
14012+#include <linux/ptrace.h>
14013+#include <linux/sched.h>
14014+#include <linux/kernel.h>
14015+#include <linux/slab.h>
14016+#include <linux/mm.h>
14017+#include <linux/fcntl.h>
14018+#include <linux/socket.h>
14019+#include <linux/in.h>
14020+#include <linux/un.h>
14021+#include <linux/file.h>
14022+#include <linux/poll.h>
14023+
14024+#include <net/sock.h>
14025+
14026+#include <abi/abi.h>
14027+#include <abi/stream.h>
14028+#include <abi/tli.h>
14029+#include <abi/trace.h>
14030+
14031+
14032+static __inline__ struct socket *
14033+socki_lookup(struct inode * inode)
14034+{
14035+ return &(inode->u.socket_i);
14036+}
14037+
14038+
14039+/*
14040+ * This is because TLI and XTI options buffers are incompatible and there
14041+ * is no clear way to detect which format we are dealing with here.
14042+ * Existing systems appear to have TLI options management implemented
14043+ * but return TNOTSUPPORT for XTI requests.
14044+ */
14045+#if defined(CONFIG_ABI_XTI_OPTMGMT) && defined(CONFIG_ABI_TLI_OPTMGMT)
14046+# error "unable to support _both_ TLI and XTI option management"
14047+#endif
14048+
14049+
14050+static char *
14051+xti_prim(int n)
14052+{
14053+ char *tab[] = {
14054+ "T_CONN_REQ", "T_CONN_RES", "T_DISCON_REQ", "T_DATA_REQ",
14055+ "T_EXDATA_REQ", "T_INFO_REQ", "T_BIND_REQ", "T_UNBIND_REQ",
14056+ "T_UNITDATA_REQ", "T_OPTMGMT_REQ", "T_ORDREL_REQ",
14057+ "T_CONN_IND", "T_CONN_CON", "T_DISCON_IND", "T_DATA_IND",
14058+ "T_EXDATA_IND", "T_INFO_ACK", "T_BIND_ACK", "T_ERROR_ACK",
14059+ "T_OK_ACK", "T_UNITDATA_IND", "T_UDERROR_IND",
14060+ "T_OPTMGMT_ACK", "T_ORDREL_IND"
14061+ };
14062+
14063+ if (n < 0 || n >= sizeof(tab)/sizeof(tab[0]))
14064+ return "<unknown>";
14065+ return tab[n];
14066+}
14067+
14068+
14069+#define timod_mkctl(len) kmalloc(sizeof(struct T_primsg)-sizeof(long)+len, \
14070+ GFP_KERNEL)
14071+
14072+
14073+static void
14074+timod_socket_wakeup(struct file * fp)
14075+{
14076+ struct socket * sock;
14077+
14078+ sock = socki_lookup(fp->f_dentry->d_inode);
14079+ wake_up_interruptible(&sock->wait);
14080+
14081+ read_lock(&sock->sk->callback_lock);
14082+ if (sock->fasync_list && !test_bit(SOCK_ASYNC_WAITDATA, &sock->flags))
14083+ __kill_fasync(sock->fasync_list, SIGIO, POLL_IN);
14084+ read_unlock(&sock->sk->callback_lock);
14085+}
14086+
14087+
14088+static void
14089+timod_ok(int fd, int prim)
14090+{
14091+ struct file * fp = fcheck(fd);
14092+ struct T_primsg * it;
14093+ struct T_ok_ack * ok;
14094+
14095+ abi_trace(ABI_TRACE_STREAMS, "%u ok ack prim=%d", fd, prim);
14096+
14097+ if (!(it = timod_mkctl(sizeof(struct T_ok_ack))))
14098+ return;
14099+
14100+ ok = (struct T_ok_ack *)&it->type;
14101+ ok->PRIM_type = T_OK_ACK;
14102+ ok->CORRECT_prim = prim;
14103+
14104+ it->pri = MSG_HIPRI;
14105+ it->length = sizeof(struct T_ok_ack);
14106+ it->next = Priv(fp)->pfirst;
14107+
14108+ Priv(fp)->pfirst = it;
14109+ if (!Priv(fp)->plast)
14110+ Priv(fp)->plast = it;
14111+ timod_socket_wakeup(fp);
14112+}
14113+
14114+static void
14115+timod_error(int fd, int prim, int terr, int uerr)
14116+{
14117+ struct file * fp = fcheck(fd);
14118+ struct T_primsg * it;
14119+ struct T_error_ack * err;
14120+
14121+ abi_trace(ABI_TRACE_STREAMS, "%u error prim=%d, TLI=%d, UNIX=%d",
14122+ fd, prim, terr, uerr);
14123+
14124+ if (!(it = timod_mkctl(sizeof(struct T_error_ack))))
14125+ return;
14126+
14127+ err = (struct T_error_ack *)&it->type;
14128+ err->PRIM_type = T_ERROR_ACK;
14129+ err->ERROR_prim = prim;
14130+ err->TLI_error = terr;
14131+ err->UNIX_error = iABI_errors(uerr);
14132+
14133+ it->pri = MSG_HIPRI;
14134+ it->length = sizeof(struct T_error_ack);
14135+ it->next = Priv(fp)->pfirst;
14136+
14137+ Priv(fp)->pfirst = it;
14138+ if (!Priv(fp)->plast)
14139+ Priv(fp)->plast = it;
14140+ timod_socket_wakeup(fp);
14141+}
14142+
14143+
14144+#if defined(CONFIG_ABI_XTI_OPTMGMT) || defined(CONFIG_ABI_TLI_OPTMGMT)
14145+/*
14146+ * XXX: this function is a _horrible_ mess.
14147+ */
14148+static int
14149+timod_optmgmt(int fd, struct pt_regs * regs, int flag,
14150+ char * opt_buf, int opt_len, int do_ret)
14151+{
14152+ struct file * fp = fcheck(fd);
14153+ char *ret_buf, *ret_base;
14154+ u_long old_esp, *tsp;
14155+ int is_tli, error, failed;
14156+ int ret_len, ret_space;
14157+
14158+ if (opt_buf && opt_len > 0) {
14159+ error = verify_area(VERIFY_READ, opt_buf, opt_len);
14160+ if (error)
14161+ return error;
14162+ }
14163+
14164+ /*
14165+ * FIXME:
14166+ * We should be able to detect the difference between
14167+ * TLI and XTI requests at run time?
14168+ */
14169+ is_tli = CONFIG_ABI_TLI_OPTMGMT;
14170+
14171+ if (!do_ret && (!opt_buf || opt_len <= 0))
14172+ return 0;
14173+
14174+ /*
14175+ * Grab some space on the user stack to work with. We need 6 longs
14176+ * to build an argument frame for [gs]etsockopt calls. We also
14177+ * need space to build the return buffer. This will be at least
14178+ * as big as the given options buffer but the given options
14179+ * buffer may not include space for option values so we allow two
14180+ * longs for each option multiple of the option header size
14181+ * and hope that big options will not exhaust our space and
14182+ * trash the stack.
14183+ */
14184+ ret_space = 1024 + opt_len
14185+ + 2*sizeof(long)*(opt_len / (is_tli ? sizeof(struct opthdr) : sizeof(struct t_opthdr)));
14186+ ret_buf = ret_base = (char *)(regs->esp - ret_space);
14187+ ret_len = 0;
14188+
14189+ old_esp = regs->esp;
14190+ regs->esp -= ret_space + 6*sizeof(long);
14191+ tsp = (unsigned long *)(regs->esp);
14192+ error = verify_area(VERIFY_WRITE, tsp, 6*sizeof(long));
14193+ if (error) {
14194+ regs->esp = old_esp;
14195+ return error;
14196+ }
14197+
14198+ failed = 0;
14199+
14200+#ifndef CONFIG_ABI_TLI_OPTMGMT
14201+ if (is_tli) {
14202+ printk(KERN_WARNING
14203+ "%d iBCS: TLI optmgmt requested but not supported\n",
14204+ current->pid);
14205+ }
14206+#else
14207+ if (is_tli)
14208+ while (opt_len >= sizeof(struct opthdr)) {
14209+ struct opthdr opt;
14210+
14211+ abi_trace(ABI_TRACE_STREAMS, "TLI optmgmt opt_len=%d, "
14212+ "ret_buf=0x%08lx, ret_len=%d, ret_space=%d",
14213+ opt_len, (unsigned long)ret_buf,
14214+ ret_len, ret_space);
14215+
14216+ copy_from_user(&opt, opt_buf, sizeof(struct opthdr));
14217+
14218+ /* Idiot check... */
14219+ if (opt.len > opt_len) {
14220+ failed = TBADOPT;
14221+ break;
14222+ }
14223+
14224+ if (abi_traced(ABI_TRACE_STREAMS)) {
14225+ unsigned long v;
14226+ get_user(v, (unsigned long *)(opt_buf+sizeof(struct opthdr)));
14227+ __abi_trace("TLI optmgmt fd=%d, level=%ld, "
14228+ "name=%ld, value=%ld",
14229+ fd, opt.level, opt.name, v);
14230+ }
14231+
14232+ /* Check writable space in the return buffer. */
14233+ error = verify_area(VERIFY_WRITE, ret_buf, sizeof(struct opthdr));
14234+ if (error) {
14235+ failed = TSYSERR;
14236+ break;
14237+ }
14238+
14239+ /* Flag values:
14240+ * T_NEGOTIATE means try and set it.
14241+ * T_DEFAULT means get the default value.
14242+ * (return the current for now)
14243+ * T_CHECK means get the current value.
14244+ */
14245+ error = 0;
14246+ if (flag == T_NEGOTIATE) {
14247+ put_user(fd, tsp);
14248+ put_user(opt.level, tsp+1);
14249+ put_user(opt.name, tsp+2);
14250+ put_user((int)(opt_buf+sizeof(struct opthdr)), tsp+3);
14251+ put_user(opt.len, tsp+4);
14252+ error = abi_do_setsockopt(tsp);
14253+
14254+ if (error) {
14255+ abi_trace(ABI_TRACE_STREAMS,
14256+ "setsockopt failed: %d", error);
14257+ failed = TBADOPT;
14258+ break;
14259+ }
14260+ }
14261+ if (!error) {
14262+ int len;
14263+
14264+ put_user(fd, tsp);
14265+ put_user(opt.level, tsp+1);
14266+ put_user(opt.name, tsp+2);
14267+ put_user((int)(ret_buf+sizeof(struct opthdr)), tsp+3);
14268+ put_user((int)(tsp+5), tsp+4);
14269+ put_user(ret_space, tsp+5);
14270+ error = abi_do_getsockopt(tsp);
14271+
14272+ if (error) {
14273+ abi_trace(ABI_TRACE_STREAMS,
14274+ "getsockopt failed: %d", error);
14275+ failed = TBADOPT;
14276+ break;
14277+ }
14278+
14279+ get_user(len, tsp+5);
14280+ copy_to_user(ret_buf, &opt, sizeof(opt));
14281+ put_user(len,
14282+ &((struct opthdr *)opt_buf)->len);
14283+ ret_space -= sizeof(struct opthdr) + len;
14284+ ret_len += sizeof(struct opthdr) + len;
14285+ ret_buf += sizeof(struct opthdr) + len;
14286+ }
14287+
14288+ opt_len -= sizeof(struct opthdr) + opt.len;
14289+ opt_buf += sizeof(struct opthdr) + opt.len;
14290+ }
14291+#endif /* CONFIG_ABI_TLI_OPTMGMT */
14292+#ifndef CONFIG_ABI_XTI_OPTMGMT
14293+ else {
14294+ printk(KERN_WARNING
14295+ "%d iBCS: XTI optmgmt requested but not supported\n",
14296+ current->pid);
14297+ }
14298+#else
14299+ else while (opt_len >= sizeof(struct t_opthdr)) {
14300+ struct t_opthdr opt;
14301+
14302+ copy_from_user(&opt, opt_buf, sizeof(struct t_opthdr));
14303+ if (opt.len > opt_len) {
14304+ failed = 1;
14305+ break;
14306+ }
14307+
14308+ if (abi_traced(ABI_TRACE_STREAMS)) {
14309+ unsigned long v;
14310+ get_user(v, (unsigned long *)(opt_buf+sizeof(struct t_opthdr)));
14311+ __abi_trace("XTI optmgmt fd=%d, level=%ld, "
14312+ "name=%ld, value=%ld",
14313+ fd, opt.level, opt.name, v);
14314+ }
14315+
14316+ /* Check writable space in the return buffer. */
14317+ if (verify_area(VERIFY_WRITE, ret_buf, sizeof(struct t_opthdr))) {
14318+ failed = 1;
14319+ break;
14320+ }
14321+
14322+ /* Flag values:
14323+ * T_NEGOTIATE means try and set it.
14324+ * T_CHECK means see if we could set it.
14325+ * (so we just set it for now)
14326+ * T_DEFAULT means get the default value.
14327+ * (return the current for now)
14328+ * T_CURRENT means get the current value (SCO xti.h has
14329+ * no T_CURRENT???).
14330+ */
14331+ error = 0;
14332+ if (flag == T_NEGOTIATE || flag == T_CHECK) {
14333+ put_user(fd, tsp);
14334+ put_user(opt.level, tsp+1);
14335+ put_user(opt.name, tsp+2);
14336+ put_user((int)(opt_buf+sizeof(struct t_opthdr)), tsp+3);
14337+ put_user(opt.len-sizeof(struct t_opthdr), tsp+4);
14338+ error = abi_do_setsockopt(tsp);
14339+ }
14340+ if (!error) {
14341+ put_user(fd, tsp);
14342+ put_user(opt.level, tsp+1);
14343+ put_user(opt.name, tsp+2);
14344+ put_user((int)(ret_buf+sizeof(struct t_opthdr)), tsp+3);
14345+ put_user((int)(tsp+5), tsp+4);
14346+ put_user(ret_space, tsp+5);
14347+ error = abi_do_getsockopt(tsp);
14348+ if (!error) {
14349+ int len;
14350+ get_user(len, tsp+5);
14351+ /* FIXME: opt.status should be set... */
14352+ copy_to_user(ret_buf, &opt, sizeof(opt));
14353+ put_user(len+sizeof(struct t_opthdr),
14354+ &((struct t_opthdr *)opt_buf)->len);
14355+ ret_space -= sizeof(struct t_opthdr) + len;
14356+ ret_len += sizeof(struct t_opthdr) + len;
14357+ ret_buf += sizeof(struct t_opthdr) + len;
14358+ }
14359+ }
14360+
14361+ failed |= error;
14362+ opt_len -= opt.len;
14363+ opt_buf += opt.len;
14364+ }
14365+#endif /* CONFIG_ABI_XTI_OPTMGMT */
14366+
14367+#if 0
14368+ /* If there is left over data the supplied options buffer was
14369+ * formatted incorrectly. But we might have done some work so
14370+ * we must fall through and return an acknowledgement I think.
14371+ */
14372+ if (opt_len) {
14373+ regs->esp = old_esp;
14374+ return -EINVAL;
14375+ }
14376+#endif
14377+
14378+ if (do_ret) {
14379+ struct T_primsg *it;
14380+
14381+ if (failed) {
14382+ timod_error(fd, T_OPTMGMT_REQ, failed, -error);
14383+ regs->esp = old_esp;
14384+ return 0;
14385+ }
14386+
14387+ abi_trace(ABI_TRACE_STREAMS,
14388+ "optmgmt returns %d bytes, failed=%d",
14389+ ret_len, failed);
14390+
14391+ /* Convert the return buffer in the user stack to a
14392+ * T_OPTMGMT_ACK
14393+ * message and queue it.
14394+ */
14395+ it = timod_mkctl(sizeof(struct T_optmgmt_ack) + ret_len);
14396+ if (it) {
14397+ struct T_optmgmt_ack *ack
14398+ = (struct T_optmgmt_ack *)&it->type;
14399+ ack->PRIM_type = T_OPTMGMT_ACK;
14400+ ack->OPT_length = ret_len;
14401+ ack->OPT_offset = sizeof(struct T_optmgmt_ack);
14402+ ack->MGMT_flags = (failed ? T_FAILURE : flag);
14403+ copy_from_user(((char *)ack)+sizeof(struct T_optmgmt_ack),
14404+ ret_base, ret_len);
14405+ it->pri = MSG_HIPRI;
14406+ it->length = sizeof(struct T_optmgmt_ack) + ret_len;
14407+ it->next = Priv(fp)->pfirst;
14408+ Priv(fp)->pfirst = it;
14409+ if (!Priv(fp)->plast)
14410+ Priv(fp)->plast = it;
14411+ timod_socket_wakeup(fp);
14412+ }
14413+ }
14414+
14415+ regs->esp = old_esp;
14416+ return 0;
14417+}
14418+
14419+#else /* no CONFIG_ABI_XTI_OPTMGMT or CONFIG_ABI_TLI_OPTMGMT */
14420+
14421+static int
14422+timod_optmgmt(int fd, struct pt_regs * regs, int flag,
14423+ char * opt_buf, int opt_len, int do_ret)
14424+{
14425+ return -EINVAL;
14426+}
14427+
14428+#endif /* CONFIG_ABI_XTI_OPTMGMT or CONFIG_ABI_TLI_OPTMGMT */
14429+
14430+#define T_PRIV(fp) Priv(fp)
14431+
14432+int
14433+timod_update_socket(int fd, struct file * fp, struct pt_regs * regs)
14434+{
14435+ struct socket * sock;
14436+ struct T_private * priv;
14437+ struct T_primsg * it;
14438+ struct T_conn_ind * ind;
14439+ u_long old_esp, * tsp, alen;
14440+ u_short oldflags;
14441+ int error = 0;
14442+
14443+ sock = socki_lookup(fp->f_dentry->d_inode);
14444+ priv = T_PRIV(fp);
14445+
14446+ /*
14447+ * If this a SOCK_STREAM and is in the TS_WRES_CIND state
14448+ * we are supposed to be looking for an incoming connection.
14449+ */
14450+ if (sock->type != SOCK_STREAM || priv->state != TS_WRES_CIND)
14451+ goto out;
14452+
14453+ old_esp = regs->esp;
14454+ regs->esp -= 1024;
14455+ tsp = (unsigned long *)regs->esp;
14456+ error = verify_area(VERIFY_WRITE, tsp,
14457+ 3*sizeof(long)+sizeof(struct sockaddr));
14458+ if (error) {
14459+ regs->esp = old_esp;
14460+ goto out;
14461+ }
14462+
14463+ put_user(fd, tsp);
14464+ put_user((unsigned long)(tsp+4), tsp+1);
14465+ put_user((unsigned long)(tsp+3), tsp+2);
14466+ put_user(sizeof(struct sockaddr), tsp+3);
14467+
14468+ /*
14469+ * We don't want to block in the accept(). Any
14470+ * blocking necessary must be handled earlier.
14471+ */
14472+ oldflags = fp->f_flags;
14473+ fp->f_flags |= O_NONBLOCK;
14474+ error = SYS(socketcall)(SYS_ACCEPT, tsp);
14475+ fp->f_flags = oldflags;
14476+
14477+ if (error < 0)
14478+ goto out_set;
14479+
14480+ /* The new fd needs to be fixed up
14481+ * with the iBCS file functions and a
14482+ * timod state block.
14483+ */
14484+ inherit_socksys_funcs(error, TS_DATA_XFER);
14485+
14486+ /* Generate a T_CONN_IND and queue it. */
14487+ get_user(alen, tsp+3);
14488+ it = timod_mkctl(sizeof(struct T_conn_ind) + alen);
14489+ if (!it) {
14490+ /* Oops, just drop the connection I guess. */
14491+ SYS(close)(error);
14492+ goto out_set;
14493+ }
14494+
14495+ ind = (struct T_conn_ind *)&it->type;
14496+ ind->PRIM_type = T_CONN_IND;
14497+ ind->SRC_length = alen;
14498+ ind->SRC_offset = sizeof(struct T_conn_ind);
14499+ ind->OPT_length = ind->OPT_offset = 0;
14500+ ind->SEQ_number = error;
14501+
14502+ copy_from_user(((char *)ind)+sizeof(struct T_conn_ind), tsp+4, alen);
14503+#if 0
14504+ it->pri = MSG_HIPRI;
14505+#endif
14506+ it->length = sizeof(struct T_conn_ind) + alen;
14507+ it->next = Priv(fp)->pfirst;
14508+ Priv(fp)->pfirst = it;
14509+ if (!Priv(fp)->plast)
14510+ Priv(fp)->plast = it;
14511+ timod_socket_wakeup(fp);
14512+
14513+out_set:
14514+ regs->esp = old_esp;
14515+out:
14516+ return (error);
14517+}
14518+
14519+
14520+static int
14521+do_getmsg(int fd, struct pt_regs *regs,
14522+ char *ctl_buf, int ctl_maxlen, int *ctl_len,
14523+ char *dat_buf, int dat_maxlen, int *dat_len,
14524+ int *flags_p)
14525+{
14526+ int error;
14527+ long old_esp;
14528+ unsigned long *tsp;
14529+ unsigned short oldflags;
14530+ struct T_unitdata_ind udi;
14531+ struct file *filep;
14532+
14533+ /*
14534+ * It may not be obvious but we are always holding an fget(fd)
14535+ * at this point so we can use fcheck(fd) rather than fget...fput.
14536+ */
14537+ filep = fcheck(fd);
14538+
14539+ if (!Priv(filep) && Priv(filep)->magic != XTI_MAGIC) {
14540+ printk("putmsg on non-STREAMS fd %d by %s\n",fd, current->comm);
14541+ return -EINVAL;
14542+ }
14543+
14544+ abi_trace(ABI_TRACE_STREAMS,
14545+ "getmsg %d, 0x%lx[%d], 0x%lx[%d], %x",
14546+ fd, (u_long)ctl_buf, ctl_maxlen,
14547+ (u_long)dat_buf, dat_maxlen, *flags_p);
14548+
14549+ /*
14550+ * We need some user space to build syscall argument vectors
14551+ * later. Set it up now and page it in if necessary. This will
14552+ * avoid (most?) potential blocking after the select().
14553+ */
14554+ old_esp = regs->esp;
14555+ regs->esp -= 1024;
14556+ tsp = (unsigned long *)regs->esp;
14557+ error = verify_area(VERIFY_WRITE, tsp, 6*sizeof(long));
14558+ regs->esp = old_esp;
14559+ if (error)
14560+ return error;
14561+
14562+ /*
14563+ * If the TEP is not non-blocking we must test for
14564+ * something to do. We don't necessarily know what order
14565+ * events will be happening on the socket so we have to
14566+ * watch for evrything at once.
14567+ * N.B. If we weren't asked for data we should only be looking
14568+ * for connection requests. There are socket type issues to
14569+ * consider here.
14570+ */
14571+ if (!(filep->f_flags & O_NONBLOCK)) {
14572+ poll_table wait_table, *wait;
14573+ unsigned long mask = (POLLIN | POLLRDNORM | POLLHUP | POLLERR);
14574+
14575+ if (*flags_p == MSG_HIPRI)
14576+ mask |= POLLPRI;
14577+
14578+ poll_initwait(&wait_table);
14579+ wait = &wait_table;
14580+
14581+ /*
14582+ * N.B. We need to be sure to recheck after a schedule()
14583+ * so that when we proceed it is because there is
14584+ * something to do and nothing else can get there
14585+ * before us.
14586+ */
14587+ while (!(filep->f_op->poll(filep, wait) & mask)
14588+ && !signal_pending(current)) {
14589+ current->state = TASK_INTERRUPTIBLE;
14590+ wait = NULL;
14591+ schedule();
14592+ }
14593+
14594+ current->state = TASK_RUNNING;
14595+ poll_freewait(&wait_table);
14596+
14597+ if (signal_pending(current))
14598+ return -EINTR;
14599+ }
14600+
14601+ if (ctl_maxlen >= 0 && !Priv(filep)->pfirst)
14602+ timod_update_socket(fd, filep, regs);
14603+
14604+ /*
14605+ * If we were asked for a control part and there is an outstanding
14606+ * message queued as a result of some other operation we'll
14607+ * return that.
14608+ */
14609+ if (ctl_maxlen >= 0 && Priv(filep)->pfirst) {
14610+ int l = ctl_maxlen <= Priv(filep)->pfirst->length
14611+ ? ctl_maxlen : Priv(filep)->pfirst->length;
14612+ error = verify_area(VERIFY_WRITE, ctl_buf, l);
14613+ if (error)
14614+ return error;
14615+
14616+ abi_trace(ABI_TRACE_STREAMS,
14617+ "priority message %ld %s",
14618+ Priv(filep)->pfirst->type,
14619+ xti_prim(Priv(filep)->pfirst->type));
14620+
14621+ copy_to_user(ctl_buf, ((char *)&Priv(filep)->pfirst->type)
14622+ + Priv(filep)->offset, l);
14623+ put_user(l, ctl_len);
14624+ if (dat_maxlen >= 0)
14625+ put_user(0, dat_len);
14626+ *flags_p = Priv(filep)->pfirst->pri;
14627+ Priv(filep)->pfirst->length -= l;
14628+
14629+ if (abi_traced(ABI_TRACE_STREAMS) && ctl_buf && l > 0) {
14630+ int i = -1;
14631+
14632+ for (i = 0; i < l && i < 64; i += 4) {
14633+ u_long v;
14634+
14635+ get_user(v, (u_long *)(ctl_buf + i));
14636+ __abi_trace("ctl: 0x%08lx", v);
14637+ }
14638+ if (i != l)
14639+ __abi_trace("ctl: ...");
14640+ }
14641+
14642+ if (Priv(filep)->pfirst->length) {
14643+ Priv(filep)->offset += l;
14644+
14645+ abi_trace(ABI_TRACE_STREAMS,
14646+ "MORECTL %d bytes",
14647+ Priv(filep)->pfirst->length);
14648+ return MORECTL;
14649+ } else {
14650+ struct T_primsg *it = Priv(filep)->pfirst;
14651+ Priv(filep)->pfirst = it->next;
14652+ if (!Priv(filep)->pfirst)
14653+ Priv(filep)->plast = NULL;
14654+ kfree(it);
14655+ Priv(filep)->offset = 0;
14656+ return 0;
14657+ }
14658+ }
14659+
14660+ *flags_p = 0;
14661+
14662+ /* If we weren't asked for data there is nothing more to do. */
14663+ if (dat_maxlen <= 0) {
14664+ if (dat_maxlen == 0)
14665+ put_user(0, dat_len);
14666+ if (ctl_maxlen >= 0)
14667+ put_user(0, ctl_len);
14668+ return -EAGAIN;
14669+ }
14670+
14671+ /* If the select() slept we may have had our temp space paged
14672+ * out. The re-verify_area is only really needed for pre-486
14673+ * chips which don't handle write faults from kernel mode.
14674+ */
14675+ regs->esp = (unsigned long)tsp;
14676+ error = verify_area(VERIFY_WRITE, tsp, 6*sizeof(long));
14677+ if (error) {
14678+ regs->esp = old_esp;
14679+ return error;
14680+ }
14681+ put_user(fd, tsp);
14682+ put_user((unsigned long)dat_buf, tsp+1);
14683+ put_user((dat_maxlen < 0 ? 0 : dat_maxlen), tsp+2);
14684+ put_user(0, tsp+3);
14685+ if (ctl_maxlen > (int)sizeof(udi) && Priv(filep)->state == TS_IDLE) {
14686+ put_user((unsigned long)ctl_buf+sizeof(udi), tsp+4);
14687+ put_user(ctl_maxlen-sizeof(udi), ctl_len);
14688+ put_user((int)ctl_len, tsp+5);
14689+ } else {
14690+ put_user(0, tsp+4);
14691+ put_user(0, ctl_len);
14692+ put_user((int)ctl_len, tsp+5);
14693+ }
14694+
14695+ /* We don't want to block in the recvfrom(). Any blocking is
14696+ * handled by the select stuff above.
14697+ */
14698+ oldflags = filep->f_flags;
14699+ filep->f_flags |= O_NONBLOCK;
14700+ error = SYS(socketcall)(SYS_RECVFROM, tsp);
14701+ filep->f_flags = oldflags;
14702+
14703+ regs->esp = old_esp;
14704+ if (error < 0)
14705+ return error;
14706+ if (error
14707+ && ctl_maxlen > (int)sizeof(udi)
14708+ && Priv(filep)->state == TS_IDLE) {
14709+ udi.PRIM_type = T_UNITDATA_IND;
14710+ get_user(udi.SRC_length, ctl_len);
14711+ udi.SRC_offset = sizeof(udi);
14712+ udi.OPT_length = udi.OPT_offset = 0;
14713+ copy_to_user(ctl_buf, &udi, (int)sizeof(udi));
14714+ put_user(sizeof(udi)+udi.SRC_length, ctl_len);
14715+#if 0
14716+ if (abi_traced(ABI_TRACE_STREAMS) &&
14717+ ctl_buf && udi.SRC_length > 0) {
14718+ char * buf = ctl_buf + sizeof(udi);
14719+ int i = -1;
14720+
14721+ for (i = 0; i < udi.SRC_length &&
14722+ i < 64; i += 4) {
14723+ u_long v;
14724+
14725+ get_user(v, (u_long *)(buf+i));
14726+ __abi_trace("dat: 0x%08lx", v);
14727+ }
14728+ if (i != udi.SRC_length)
14729+ __abi_trace("dat: ...");
14730+ }
14731+#endif
14732+ } else {
14733+ put_user(0, ctl_len);
14734+ }
14735+ put_user(error, dat_len);
14736+
14737+ return 0;
14738+}
14739+
14740+
14741+static int
14742+do_putmsg(int fd, struct pt_regs *regs, char *ctl_buf, int ctl_len,
14743+ char *dat_buf, int dat_len, int flags)
14744+{
14745+ struct file *filep;
14746+ int error, terror;
14747+ unsigned long cmd;
14748+
14749+ /* It may not be obvious but we are always holding an fget(fd)
14750+ * at this point so we can use fcheck(fd) rather than fget...fput.
14751+ */
14752+ filep = fcheck(fd);
14753+
14754+ if (!Priv(filep) && Priv(filep)->magic != XTI_MAGIC) {
14755+ printk("putmsg on non-STREAMS fd %d by %s\n",fd, current->comm);
14756+ return -EINVAL;
14757+ }
14758+
14759+ if (abi_traced(ABI_TRACE_STREAMS)) {
14760+ u_long v;
14761+ __abi_trace("putmsg %d, 0x%lx[%d], 0x%lx[%d], %x",
14762+ fd, (u_long)ctl_buf, ctl_len,
14763+ (u_long)dat_buf, dat_len, flags);
14764+
14765+ get_user(v, ctl_buf);
14766+ __abi_trace("putmsg prim: %ld %s", v, xti_prim(v));
14767+
14768+ if (ctl_buf && ctl_len > 0) {
14769+ int i = -1;
14770+
14771+ for (i = 0; i < ctl_len && i < 64; i += 4) {
14772+ u_long v;
14773+
14774+ get_user(v, (u_long *)(ctl_buf + i));
14775+ __abi_trace("ctl: 0x%08lx", v);
14776+ }
14777+ if (i != ctl_len)
14778+ __abi_trace("ctl: ...");
14779+ }
14780+
14781+ if (dat_buf && dat_len > 0) {
14782+ int i = -1;
14783+
14784+ for (i = 0; i < dat_len && i < 64; i += 4) {
14785+ u_long v;
14786+
14787+ get_user(v, (u_long *)(dat_buf + i));
14788+ __abi_trace("dat: 0x%08lx", v);
14789+ }
14790+ if (i != dat_len)
14791+ __abi_trace("dat: ...");
14792+ }
14793+ }
14794+
14795+ error = get_user(cmd, (unsigned long *)ctl_buf);
14796+ if (error)
14797+ return error;
14798+
14799+ switch (cmd) {
14800+ case T_BIND_REQ: {
14801+ struct T_bind_req req;
14802+ long old_esp;
14803+ unsigned long *tsp;
14804+
14805+ abi_trace(ABI_TRACE_STREAMS, "%u bind req", fd);
14806+
14807+ error = verify_area(VERIFY_READ, ctl_buf, sizeof(req));
14808+ if (error)
14809+ return error;
14810+
14811+ if (Priv(filep)->state != TS_UNBND) {
14812+ timod_error(fd, T_BIND_REQ, TOUTSTATE, 0);
14813+ return 0;
14814+ }
14815+
14816+ old_esp = regs->esp;
14817+ regs->esp -= 1024;
14818+ tsp = (unsigned long *)(regs->esp);
14819+ error = verify_area(VERIFY_WRITE, tsp, 3*sizeof(long));
14820+ if (error) {
14821+ timod_error(fd, T_BIND_REQ, TSYSERR, -error);
14822+ regs->esp = old_esp;
14823+ return 0;
14824+ }
14825+
14826+ copy_from_user(&req, ctl_buf, sizeof(req));
14827+ if (req.ADDR_offset && req.ADDR_length) {
14828+ struct sockaddr_in *sin;
14829+ unsigned short family;
14830+
14831+#if 1 /* Wheee... Kludge time... */
14832+ sin = (struct sockaddr_in *)(ctl_buf
14833+ + req.ADDR_offset);
14834+ get_user(family, &sin->sin_family);
14835+
14836+ /* Sybase seems to have set up the address
14837+ * struct with sa->sa_family = htons(AF_?)
14838+ * which is bollocks. I have no idea why it
14839+ * apparently works on SCO?!?
14840+ */
14841+ if (family && !(family & 0x00ff))
14842+ put_user(ntohs(family), &sin->sin_family);
14843+#endif
14844+
14845+ put_user(fd, tsp);
14846+ put_user((unsigned long)ctl_buf
14847+ + req.ADDR_offset, tsp+1);
14848+ /* For TLI/XTI the length may be the 8 *used*
14849+ * bytes, for (IP?) sockets it must be the 16
14850+ * *total* bytes in a sockaddr_in.
14851+ */
14852+ put_user(req.ADDR_length == 8
14853+ ? 16 : req.ADDR_length,
14854+ tsp+2);
14855+ error = SYS(socketcall)(SYS_BIND, tsp);
14856+
14857+ if (!error) {
14858+ if (req.CONIND_number) {
14859+
14860+ abi_trace(ABI_TRACE_STREAMS,
14861+ "%u listen backlog=%lu",
14862+ fd, req.CONIND_number);
14863+
14864+ put_user(fd, tsp);
14865+ put_user(req.CONIND_number, tsp+1);
14866+ SYS(socketcall)(SYS_LISTEN, tsp);
14867+ Priv(filep)->state = TS_WRES_CIND;
14868+ } else {
14869+ Priv(filep)->state = TS_IDLE;
14870+ }
14871+ }
14872+ } else {
14873+ error = 0;
14874+ }
14875+
14876+ regs->esp = old_esp;
14877+
14878+ if (!error) {
14879+ struct T_primsg *it;
14880+ it = timod_mkctl(ctl_len);
14881+ if (it) {
14882+ struct T_bind_ack *ack = (struct T_bind_ack *)&it->type;
14883+ copy_from_user(ack, ctl_buf, ctl_len);
14884+ ack->PRIM_type = T_BIND_ACK;
14885+ it->pri = MSG_HIPRI;
14886+ it->length = ctl_len;
14887+ it->next = NULL;
14888+ timod_ok(fd, T_BIND_REQ);
14889+ Priv(filep)->plast->next = it;
14890+ Priv(filep)->plast = it;
14891+ return 0;
14892+ }
14893+ }
14894+ switch (error) {
14895+ case -EINVAL:
14896+ terror = TOUTSTATE;
14897+ error = 0;
14898+ break;
14899+ case -EACCES:
14900+ terror = TACCES;
14901+ error = 0;
14902+ break;
14903+ case -EADDRNOTAVAIL:
14904+ case -EADDRINUSE:
14905+ terror = TNOADDR;
14906+ error = 0;
14907+ break;
14908+ default:
14909+ terror = TSYSERR;
14910+ break;
14911+ }
14912+ timod_error(fd, T_BIND_REQ, terror, -error);
14913+ return 0;
14914+ }
14915+ case T_CONN_RES: {
14916+ struct T_conn_res *res = (struct T_conn_res *)ctl_buf;
14917+ unsigned int conn_fd;
14918+
14919+ error = get_user(conn_fd, &res->SEQ_number);
14920+ if (error)
14921+ return error;
14922+
14923+ abi_trace(ABI_TRACE_STREAMS,
14924+ "%u accept: conn fd=%u, use fd=%u\n",
14925+ fd, conn_fd, flags);
14926+
14927+ if (conn_fd != flags) {
14928+ error = SYS(dup2)(conn_fd, flags);
14929+ SYS(close)(conn_fd);
14930+ if (error < 0)
14931+ return error;
14932+ }
14933+ timod_ok(fd, T_CONN_RES);
14934+ return 0;
14935+ }
14936+ case T_CONN_REQ: {
14937+ struct T_conn_req req;
14938+ long old_esp;
14939+ unsigned short oldflags;
14940+ unsigned long *tsp;
14941+ struct T_primsg *it;
14942+ struct sockaddr_in *sin;
14943+ unsigned short family;
14944+
14945+ abi_trace(ABI_TRACE_STREAMS, "%u connect req", fd);
14946+
14947+ error = verify_area(VERIFY_READ, ctl_buf, sizeof(req));
14948+ if (error)
14949+ return error;
14950+
14951+ if (Priv(filep)->state != TS_UNBND
14952+ && Priv(filep)->state != TS_IDLE) {
14953+ timod_error(fd, T_CONN_REQ, TOUTSTATE, 0);
14954+ return 0;
14955+ }
14956+
14957+ old_esp = regs->esp;
14958+ regs->esp -= 1024;
14959+ tsp = (unsigned long *)(regs->esp);
14960+ error = verify_area(VERIFY_WRITE, tsp, 3*sizeof(long));
14961+ if (error) {
14962+ timod_error(fd, T_CONN_REQ, TSYSERR, -error);
14963+ regs->esp = old_esp;
14964+ return 0;
14965+ }
14966+ copy_from_user(&req, ctl_buf, sizeof(req));
14967+ put_user(fd, tsp);
14968+ put_user((unsigned long)ctl_buf + req.DEST_offset, tsp+1);
14969+ /* For TLI/XTI the length may be the 8 *used*
14970+ * bytes, for (IP?) sockets it must be the 16
14971+ * *total* bytes in a sockaddr_in.
14972+ */
14973+ put_user(req.DEST_length == 8
14974+ ? 16 : req.DEST_length,
14975+ tsp+2);
14976+
14977+#if 1 /* Wheee... Kludge time... */
14978+ sin = (struct sockaddr_in *)(ctl_buf
14979+ + req.DEST_offset);
14980+ get_user(family, &sin->sin_family);
14981+
14982+ /* Sybase seems to have set up the address
14983+ * struct with sa->sa_family = htons(AF_?)
14984+ * which is bollocks. I have no idea why it
14985+ * apparently works on SCO?!?
14986+ */
14987+ if (family && !(family & 0x00ff)) {
14988+ family = ntohs(family);
14989+ put_user(family, &sin->sin_family);
14990+ }
14991+
14992+ /* Sheesh... ISC telnet seems to give the port
14993+ * number low byte first as I expected but the
14994+ * X programs seem to be giving high byte first.
14995+ * One is broken of course but clearly both
14996+ * should work. No, I don't understand this
14997+ * either but I can at least try...
14998+ * A better solution would be for you to change
14999+ * the definition of xserver0 in ISC's /etc/services
15000+ * but then it wouldn't work out of the box...
15001+ */
15002+ if (personality(PER_SVR4) && family == AF_INET) {
15003+ get_user(family, &sin->sin_port);
15004+ if (family == 0x1770)
15005+ put_user(htons(family),
15006+ &sin->sin_port);
15007+ }
15008+#endif
15009+ /* FIXME: We should honour non-blocking mode
15010+ * here but that means that the select probe
15011+ * needs to know that if select returns ok and
15012+ * we are in T_OUTCON we have a connection
15013+ * completion. This isn't so bad but the real
15014+ * problem is that the connection acknowledgement
15015+ * is supposed to contain the destination
15016+ * address.
15017+ */
15018+ oldflags = filep->f_flags;
15019+ filep->f_flags &= ~O_NONBLOCK;
15020+ error = SYS(socketcall)(SYS_CONNECT, tsp);
15021+ filep->f_flags = oldflags;
15022+ regs->esp = old_esp;
15023+
15024+ if (!error) {
15025+ struct T_conn_con *con;
15026+
15027+ it = timod_mkctl(ctl_len);
15028+ if (!it)
15029+ return -ENOMEM;
15030+ it->length = ctl_len;
15031+ con = (struct T_conn_con *)&it->type;
15032+ copy_from_user(con, ctl_buf, ctl_len);
15033+ con->PRIM_type = T_CONN_CON;
15034+ Priv(filep)->state = TS_DATA_XFER;
15035+ } else {
15036+ struct T_discon_ind *dis;
15037+
15038+ abi_trace(ABI_TRACE_STREAMS,
15039+ "%u connect failed (errno=%d)",
15040+ fd, error);
15041+
15042+ it = timod_mkctl(sizeof(struct T_discon_ind));
15043+ if (!it)
15044+ return -ENOMEM;
15045+ it->length = sizeof(struct T_discon_ind);
15046+ dis = (struct T_discon_ind *)&it->type;
15047+ dis->PRIM_type = T_DISCON_IND;
15048+ dis->DISCON_reason = iABI_errors(-error);
15049+ dis->SEQ_number = 0;
15050+ }
15051+ timod_ok(fd, T_CONN_REQ);
15052+ it->pri = 0;
15053+ it->next = NULL;
15054+ Priv(filep)->plast->next = it;
15055+ Priv(filep)->plast = it;
15056+ return 0;
15057+ }
15058+
15059+ case T_DISCON_REQ: {
15060+ struct T_discon_req *req;
15061+
15062+ req = (struct T_discon_req *)ctl_buf;
15063+ error = get_user(fd, &req->SEQ_number);
15064+ if (error)
15065+ return error;
15066+
15067+ abi_trace(ABI_TRACE_STREAMS, "disconnect %u", fd);
15068+ /* Fall through... */
15069+ }
15070+ case T_ORDREL_REQ: {
15071+ SYS(close)(fd);
15072+ return 0;
15073+ }
15074+
15075+ case T_DATA_REQ: {
15076+ long old_esp;
15077+ unsigned long *tsp;
15078+
15079+ abi_trace(ABI_TRACE_STREAMS, "%u data req", fd);
15080+
15081+ if (Priv(filep)->state != TS_DATA_XFER) {
15082+ return 0;
15083+ }
15084+
15085+ old_esp = regs->esp;
15086+ regs->esp -= 1024;
15087+ tsp = (unsigned long *)(regs->esp);
15088+ error = verify_area(VERIFY_WRITE, tsp, 6*sizeof(long));
15089+ if (error) {
15090+ regs->esp = old_esp;
15091+ return 0;
15092+ }
15093+ put_user(fd, tsp);
15094+ put_user((unsigned long)dat_buf, tsp+1);
15095+ put_user(dat_len, tsp+2);
15096+ put_user(0, tsp+3);
15097+ error = SYS(socketcall)(SYS_SEND, tsp);
15098+ regs->esp = old_esp;
15099+ return error;
15100+ }
15101+
15102+ case T_UNITDATA_REQ: {
15103+ struct T_unitdata_req req;
15104+ long old_esp;
15105+ unsigned long *tsp;
15106+
15107+
15108+ abi_trace(ABI_TRACE_STREAMS, "%u unitdata req", fd);
15109+
15110+ error = verify_area(VERIFY_READ, ctl_buf, sizeof(req));
15111+ if (error)
15112+ return error;
15113+
15114+ if (Priv(filep)->state != TS_IDLE
15115+ && Priv(filep)->state != TS_DATA_XFER) {
15116+ timod_error(fd, T_UNITDATA_REQ, TOUTSTATE, 0);
15117+ return 0;
15118+ }
15119+
15120+ old_esp = regs->esp;
15121+ regs->esp -= 1024;
15122+ tsp = (unsigned long *)(regs->esp);
15123+ error = verify_area(VERIFY_WRITE, tsp, 6*sizeof(long));
15124+ if (error) {
15125+ timod_error(fd, T_UNITDATA_REQ, TSYSERR, -error);
15126+ regs->esp = old_esp;
15127+ return 0;
15128+ }
15129+ put_user(fd, tsp);
15130+ put_user((unsigned long)dat_buf, tsp+1);
15131+ put_user(dat_len, tsp+2);
15132+ put_user(0, tsp+3);
15133+ copy_from_user(&req, ctl_buf, sizeof(req));
15134+ if (req.DEST_length > 0) {
15135+ put_user((unsigned long)(ctl_buf+req.DEST_offset), tsp+4);
15136+ put_user(req.DEST_length, tsp+5);
15137+ error = SYS(socketcall)(SYS_SENDTO, tsp);
15138+ regs->esp = old_esp;
15139+ return error;
15140+ }
15141+ error = SYS(socketcall)(SYS_SEND, tsp);
15142+ regs->esp = old_esp;
15143+ return error;
15144+ }
15145+
15146+ case T_UNBIND_REQ:
15147+ Priv(filep)->state = TS_UNBND;
15148+ timod_ok(fd, T_UNBIND_REQ);
15149+ return 0;
15150+
15151+ case T_OPTMGMT_REQ: {
15152+ struct T_optmgmt_req req;
15153+
15154+ abi_trace(ABI_TRACE_STREAMS, "%u optmgmt req", fd);
15155+
15156+ error = verify_area(VERIFY_READ, ctl_buf, sizeof(req));
15157+ if (error)
15158+ return error;
15159+ copy_from_user(&req, ctl_buf, sizeof(req));
15160+
15161+ return timod_optmgmt(fd, regs, req.MGMT_flags,
15162+ req.OPT_offset > 0
15163+ ? ctl_buf+req.OPT_offset
15164+ : NULL,
15165+ req.OPT_length,
15166+ 1);
15167+ }
15168+ }
15169+ if (!abi_traced(ABI_TRACE_STREAMS))
15170+ goto err;
15171+
15172+ if (ctl_buf && ctl_len > 0) {
15173+ int i;
15174+
15175+ for (i = 0; i < ctl_len && i < 32; i += 4) {
15176+ u_long v;
15177+
15178+ get_user(v, (u_long *)(ctl_buf + i));
15179+ __abi_trace("ctl: 0x%08lx\n", v);
15180+ }
15181+ if (i != ctl_len)
15182+ __abi_trace("ctl: ...\n");
15183+ }
15184+ if (dat_buf && dat_len > 0) {
15185+ int i;
15186+ for (i = 0; i < dat_len && i < 32; i += 4) {
15187+ u_long v;
15188+
15189+ get_user(v, (u_long *)(dat_buf + i));
15190+ __abi_trace("dat: 0x%08lx\n", v);
15191+ }
15192+ if (i != dat_len)
15193+ __abi_trace("dat: ...\n");
15194+ }
15195+err:
15196+ return -EINVAL;
15197+}
15198+
15199+
15200+int
15201+timod_ioctl(struct pt_regs *regs,
15202+ int fd, unsigned int func, void *arg, int len, int *len_p)
15203+{
15204+ struct file *filep;
15205+ struct inode *ino;
15206+ int error;
15207+
15208+ filep = fget(fd);
15209+ if (!filep)
15210+ return TBADF;
15211+
15212+ error = verify_area(VERIFY_WRITE, len_p, sizeof(int));
15213+ if (error) {
15214+ fput(filep);
15215+ return (-error << 8) | TSYSERR;
15216+ }
15217+
15218+ ino = filep->f_dentry->d_inode;
15219+
15220+ /* SCO/SVR3 starts at 100, ISC/SVR4 starts at 140. */
15221+ switch (func >= 140 ? func-140 : func-100) {
15222+ case 0: /* TI_GETINFO */
15223+ {
15224+ struct T_info_ack it;
15225+ unsigned long v;
15226+
15227+ abi_trace(ABI_TRACE_STREAMS, "%u getinfo", fd);
15228+
15229+ /* The pre-SVR4 T_info_ack structure didn't have
15230+ * the PROVIDER_flag on the end.
15231+ */
15232+ error = verify_area(VERIFY_WRITE, arg,
15233+ func == 140
15234+ ? sizeof(struct T_info_ack)
15235+ : sizeof(struct T_info_ack)-sizeof(long));
15236+ if (error) {
15237+ fput(filep);
15238+ return (-error << 8) | TSYSERR;
15239+ }
15240+
15241+ __get_user(v, &((struct T_info_req *)arg)->PRIM_type);
15242+ if (v != T_INFO_REQ) {
15243+ fput(filep);
15244+ return (EINVAL << 8) | TSYSERR;
15245+ }
15246+
15247+ it.PRIM_type = T_INFO_ACK;
15248+ it.CURRENT_state = Priv(filep)->state;
15249+ it.CDATA_size = -2;
15250+ it.DDATA_size = -2;
15251+ it.OPT_size = -1;
15252+ it.TIDU_size = 16384;
15253+ switch ((MINOR(ino->i_rdev)>>4) & 0x0f) {
15254+ case AF_UNIX:
15255+ it.ADDR_size = sizeof(struct sockaddr_un);
15256+ break;
15257+ case AF_INET:
15258+ it.ADDR_size = sizeof(struct sockaddr_in);
15259+ break;
15260+ default:
15261+ /* Uh... dunno... play safe(?) */
15262+ it.ADDR_size = 1024;
15263+ break;
15264+ }
15265+ switch (ino->u.socket_i.type) {
15266+ case SOCK_STREAM:
15267+ it.ETSDU_size = 1;
15268+ it.TSDU_size = 0;
15269+ it.SERV_type = 2;
15270+ break;
15271+ default:
15272+ it.ETSDU_size = -2;
15273+ it.TSDU_size = 16384;
15274+ it.SERV_type = 3;
15275+ break;
15276+ }
15277+
15278+ fput(filep);
15279+
15280+ /* The pre-SVR4 T_info_ack structure didn't have
15281+ * the PROVIDER_flag on the end.
15282+ */
15283+ if (func == 140) {
15284+ it.PROVIDER_flag = 0;
15285+ copy_to_user(arg, &it, sizeof(it));
15286+ put_user(sizeof(it), len_p);
15287+ return 0;
15288+ }
15289+ copy_to_user(arg, &it, sizeof(it)-sizeof(long));
15290+ put_user(sizeof(it)-sizeof(long), len_p);
15291+ return 0;
15292+ }
15293+
15294+ case 2: /* TI_BIND */
15295+ {
15296+ int i;
15297+ long prim;
15298+
15299+ abi_trace(ABI_TRACE_STREAMS, "%u bind", fd);
15300+
15301+ error = do_putmsg(fd, regs, arg, len,
15302+ NULL, -1, 0);
15303+ if (error) {
15304+ fput(filep);
15305+ return (-error << 8) | TSYSERR;
15306+ }
15307+
15308+ /* Get the response. This should be either
15309+ * T_OK_ACK or T_ERROR_ACK.
15310+ */
15311+ i = MSG_HIPRI;
15312+ error = do_getmsg(fd, regs,
15313+ arg, len, len_p,
15314+ NULL, -1, NULL,
15315+ &i);
15316+ if (error) {
15317+ fput(filep);
15318+ return (-error << 8) | TSYSERR;
15319+ }
15320+
15321+ get_user(prim, (unsigned long *)arg);
15322+ if (prim == T_ERROR_ACK) {
15323+ unsigned long a, b;
15324+ fput(filep);
15325+ get_user(a, ((unsigned long *)arg)+3);
15326+ get_user(b, ((unsigned long *)arg)+2);
15327+ return (a << 8) | b;
15328+ }
15329+ if (prim != T_OK_ACK) {
15330+ fput(filep);
15331+ return TBADSEQ;
15332+ }
15333+
15334+ /* Get the response to the bind request. */
15335+ i = MSG_HIPRI;
15336+ error = do_getmsg(fd, regs,
15337+ arg, len, len_p,
15338+ NULL, -1, NULL,
15339+ &i);
15340+ fput(filep);
15341+ if (error)
15342+ return (-error << 8) | TSYSERR;
15343+
15344+ return 0;
15345+ }
15346+
15347+ case 3: /* TI_UNBIND */
15348+ if (Priv(filep)->state != TS_IDLE) {
15349+ fput(filep);
15350+ return TOUTSTATE;
15351+ }
15352+ Priv(filep)->state = TS_UNBND;
15353+ fput(filep);
15354+ return 0;
15355+
15356+ case 1: { /* TI_OPTMGMT */
15357+#if defined(CONFIG_ABI_XTI_OPTMGMT) || defined(CONFIG_ABI_TLI_OPTMGMT)
15358+ int i;
15359+ long prim;
15360+
15361+ abi_trace(ABI_TRACE_STREAMS, "%u optmgmt", fd);
15362+
15363+ error = do_putmsg(fd, regs, arg, len,
15364+ NULL, -1, 0);
15365+ if (error) {
15366+ fput(filep);
15367+ return (-error << 8) | TSYSERR;
15368+ }
15369+
15370+ /* Get the response to the optmgmt request. */
15371+ i = MSG_HIPRI;
15372+ error = do_getmsg(fd, regs,
15373+ arg, len, len_p,
15374+ NULL, -1, NULL,
15375+ &i);
15376+ if (error > 0) {
15377+ /* If there is excess data in the response
15378+ * our buffer is too small which implies
15379+ * the application is broken. SO_LINGER
15380+ * is a common fault. Because it works
15381+ * on other systems we attempt to recover
15382+ * by discarding the excess.
15383+ */
15384+ struct T_primsg *it = Priv(filep)->pfirst;
15385+ Priv(filep)->pfirst = it->next;
15386+ if (!Priv(filep)->pfirst)
15387+ Priv(filep)->plast = NULL;
15388+ kfree(it);
15389+ Priv(filep)->offset = 0;
15390+
15391+ abi_trace(ABI_TRACE_STREAMS,
15392+ "excess discarded");
15393+ }
15394+
15395+ fput(filep);
15396+
15397+ if (error < 0)
15398+ return (-error << 8) | TSYSERR;
15399+
15400+ __get_user(prim, (unsigned long *)arg);
15401+ if (prim == T_ERROR_ACK) {
15402+ unsigned long a, b;
15403+ __get_user(a, ((unsigned long *)arg)+3);
15404+ __get_user(b, ((unsigned long *)arg)+2);
15405+ return (a << 8) | b;
15406+ }
15407+
15408+ return 0;
15409+#else /* no CONFIG_ABI_XTI_OPTMGMT or CONFIG_ABI_TLI_OPTMGMT */
15410+ fput(filep);
15411+ return TNOTSUPPORT;
15412+#endif /* CONFIG_ABI_XTI_OPTMGMT or CONFIG_ABI_TLI_OPTMGMT */
15413+ }
15414+
15415+ case 4: /* TI_GETMYNAME */
15416+ case 5: /* TI_SETPEERNAME */
15417+ case 6: /* TI_GETMYNAME */
15418+ case 7: /* TI_SETPEERNAME */
15419+ }
15420+
15421+ abi_trace(ABI_TRACE_STREAMS,
15422+ "STREAMS timod op %d not supported", func);
15423+
15424+ fput(filep);
15425+ return TNOTSUPPORT;
15426+}
15427+
15428+
15429+int svr4_ioctl_sockmod(int fd, unsigned int func, void *arg)
15430+{
15431+ struct file *filep;
15432+ struct inode *ino;
15433+ int error;
15434+
15435+ filep = fget(fd);
15436+ if (!filep)
15437+ return TBADF;
15438+ ino = filep->f_dentry->d_inode;
15439+
15440+ if (MAJOR(ino->i_rdev) == SOCKSYS_MAJOR) {
15441+ error = abi_socksys_fd_init(fd, 0, NULL, NULL);
15442+ if (error < 0)
15443+ return error;
15444+ fput(filep);
15445+ filep = fget(fd);
15446+ if (!filep)
15447+ return TBADF;
15448+ ino = filep->f_dentry->d_inode;
15449+ }
15450+
15451+ switch (func) {
15452+#ifdef __sparc__
15453+ case 110: { /* SI_GETUDATA -- Solaris */
15454+ struct {
15455+ int tidusize, addrsize, optsize, etsdusize;
15456+ int servtype, so_state, so_options;
15457+ int tsdusize;
15458+
15459+ /* Socket parameters */
15460+ int family, type, protocol;
15461+ } *it = arg;
15462+
15463+ abi_trace(ABI_TRACE_STREAMS, "%u new_getudata", fd);
15464+
15465+ error = verify_area(VERIFY_WRITE, it, sizeof(*it));
15466+ if (error) {
15467+ fput(filep);
15468+ return (-error << 8) | TSYSERR;
15469+ }
15470+
15471+ __put_user(16384, &it->tidusize);
15472+ __put_user(sizeof(struct sockaddr), &it->addrsize);
15473+ __put_user(-1, &it->optsize);
15474+ __put_user(0, &it->so_state);
15475+ __put_user(0, &it->so_options);
15476+ __put_user(16384, &it->tsdusize);
15477+
15478+ switch (ino->u.socket_i.type) {
15479+ case SOCK_STREAM:
15480+ __put_user(1, &it->etsdusize);
15481+ __put_user(2, &it->servtype);
15482+ break;
15483+ default:
15484+ __put_user(-2, &it->etsdusize);
15485+ __put_user(3, &it->servtype);
15486+ break;
15487+ }
15488+ __put_user (ino->u.socket_i.ops->family, &it->family);
15489+ __put_user (ino->u.socket_i.type, &it->type);
15490+ __put_user (ino->u.socket_i.ops->family, &it->protocol);
15491+ fput(filep);
15492+ return 0;
15493+ }
15494+
15495+#endif
15496+ case 101: { /* SI_GETUDATA */
15497+ struct {
15498+ int tidusize, addrsize, optsize, etsdusize;
15499+ int servtype, so_state, so_options;
15500+#ifdef __sparc__
15501+ int tsdusize;
15502+#endif
15503+ } *it = arg;
15504+
15505+ abi_trace(ABI_TRACE_STREAMS, "%u getudata", fd);
15506+
15507+ error = verify_area(VERIFY_WRITE, it, sizeof(*it));
15508+ if (error) {
15509+ fput(filep);
15510+ return (-error << 8) | TSYSERR;
15511+ }
15512+
15513+ __put_user(16384, &it->tidusize);
15514+ __put_user(sizeof(struct sockaddr), &it->addrsize);
15515+ __put_user(-1, &it->optsize);
15516+ __put_user(0, &it->so_state);
15517+ __put_user(0, &it->so_options);
15518+
15519+#ifdef __sparc__
15520+ __put_user(16384, &it->tsdusize);
15521+#endif
15522+ switch (ino->u.socket_i.type) {
15523+ case SOCK_STREAM:
15524+ __put_user(1, &it->etsdusize);
15525+ __put_user(2, &it->servtype);
15526+ break;
15527+ default:
15528+ __put_user(-2, &it->etsdusize);
15529+ __put_user(3, &it->servtype);
15530+ break;
15531+ }
15532+ fput(filep);
15533+ return 0;
15534+ }
15535+
15536+ case 102: /* SI_SHUTDOWN */
15537+ case 103: /* SI_LISTEN */
15538+ case 104: /* SI_SETMYNAME */
15539+ case 105: /* SI_SETPEERNAME */
15540+ case 106: /* SI_GETINTRANSIT */
15541+ case 107: /* SI_TCL_LINK */
15542+ case 108: /* SI_TCL_UNLINK */
15543+ }
15544+
15545+ abi_trace(ABI_TRACE_STREAMS,
15546+ "STREAMS sockmod op %d not supported", func);
15547+
15548+ fput(filep);
15549+ return TNOTSUPPORT;
15550+}
15551+EXPORT_SYMBOL(svr4_ioctl_sockmod);
15552+#endif /* CONFIG_ABI_XTI */
15553+
15554+
15555+#if defined(CONFIG_ABI_XTI) || defined(CONFIG_ABI_IBCS_SPX)
15556+
15557+int timod_getmsg(int fd, struct inode *ino, int is_pmsg, struct pt_regs *regs)
15558+{
15559+ struct strbuf *ctlptr, *datptr;
15560+ int *flags_p, flags, *band_p;
15561+ int error;
15562+ struct strbuf ctl, dat;
15563+ struct file *filep;
15564+
15565+ ctlptr = (struct strbuf *) get_syscall_parameter (regs, 1);
15566+ datptr = (struct strbuf *) get_syscall_parameter (regs, 2);
15567+ if (!is_pmsg) {
15568+ flags_p = (int *) get_syscall_parameter (regs, 3);
15569+ } else {
15570+ band_p = (int *) get_syscall_parameter (regs, 3);
15571+ flags_p = (int *) get_syscall_parameter (regs, 4);
15572+ error = verify_area(VERIFY_WRITE, band_p, sizeof(int));
15573+ if (error)
15574+ return error;
15575+ }
15576+
15577+ error = verify_area(VERIFY_WRITE, flags_p, sizeof(int));
15578+ if (error)
15579+ return error;
15580+
15581+ if (ctlptr) {
15582+ error = verify_area(VERIFY_WRITE, ctlptr, sizeof(ctl));
15583+ if (error)
15584+ return error;
15585+ __copy_from_user(&ctl, ctlptr, sizeof(ctl));
15586+ __put_user(-1, &ctlptr->len);
15587+ } else {
15588+ ctl.maxlen = -1;
15589+ }
15590+
15591+ if (datptr) {
15592+ error = verify_area(VERIFY_WRITE, datptr, sizeof(dat));
15593+ if (error)
15594+ return error;
15595+ __copy_from_user(&dat, datptr, sizeof(dat));
15596+ __put_user(-1, &datptr->len);
15597+ } else {
15598+ dat.maxlen = -1;
15599+ }
15600+
15601+ error = verify_area(VERIFY_WRITE, flags_p, sizeof(int));
15602+ if (error)
15603+ return error;
15604+ __get_user(flags, flags_p);
15605+
15606+#ifdef CONFIG_ABI_IBCS_SPX
15607+ if (MAJOR(ino->i_rdev) == SOCKSYS_MAJOR && MINOR(ino->i_rdev) == 1) {
15608+ abi_trace(ABI_TRACE_STREAMS,
15609+ "%d getmsg offers descriptor %d", fd, fd);
15610+ __put_user((u_long)fd, (u_long *)ctl.buf);
15611+ __put_user(4, &ctlptr->len);
15612+ return 0;
15613+ }
15614+#endif /* CONFIG_ABI_IBCS_SPX */
15615+
15616+#ifdef CONFIG_ABI_XTI
15617+ if (flags != 0 && flags != MSG_HIPRI && flags != MSG_ANY
15618+ && flags != MSG_BAND) {
15619+ abi_trace(ABI_TRACE_STREAMS,
15620+ "%d getmsg flags value bad (%d)", fd, flags);
15621+ return -EINVAL;
15622+ }
15623+
15624+ filep = fget(fd);
15625+ error = do_getmsg(fd, regs,
15626+ ctl.buf, ctl.maxlen, &ctlptr->len,
15627+ dat.buf, dat.maxlen, &datptr->len,
15628+ &flags);
15629+ fput(filep);
15630+ if (error >= 0)
15631+ put_user(flags, flags_p);
15632+ return error;
15633+#else /* CONFIG_ABI_XTI */
15634+ return -EINVAL;
15635+#endif /* CONFIG_ABI_XTI */
15636+}
15637+
15638+
15639+int timod_putmsg(int fd, struct inode *ino, int is_pmsg, struct pt_regs *regs)
15640+{
15641+ struct strbuf *ctlptr, *datptr;
15642+ int flags, error, band;
15643+ struct strbuf ctl, dat;
15644+
15645+ ctlptr = (struct strbuf *)get_syscall_parameter (regs, 1);
15646+ datptr = (struct strbuf *)get_syscall_parameter (regs, 2);
15647+ if (!is_pmsg) {
15648+ flags = (int)get_syscall_parameter (regs, 3);
15649+ } else {
15650+ band = (int)get_syscall_parameter (regs, 3);
15651+ flags = (int)get_syscall_parameter (regs, 4);
15652+ }
15653+
15654+ if (ctlptr) {
15655+ error = copy_from_user(&ctl, ctlptr, sizeof(ctl));
15656+ if (error)
15657+ return -EFAULT;
15658+ if (ctl.len < 0 && flags)
15659+ return -EINVAL;
15660+ } else {
15661+ ctl.len = 0;
15662+ ctl.buf = NULL;
15663+ }
15664+
15665+ if (datptr) {
15666+ error = copy_from_user(&dat, datptr, sizeof(dat));
15667+ if (error)
15668+ return -EFAULT;
15669+ } else {
15670+ dat.len = 0;
15671+ dat.buf = NULL;
15672+ }
15673+
15674+#ifdef CONFIG_ABI_IBCS_SPX
15675+ if (MAJOR(ino->i_rdev) == SOCKSYS_MAJOR && MINOR(ino->i_rdev) == 1) {
15676+ unsigned int newfd;
15677+
15678+ if (ctl.len != 4)
15679+ return -EIO;
15680+
15681+ get_user(newfd, (unsigned int *)ctl.buf);
15682+ abi_trace(ABI_TRACE_STREAMS,
15683+ "%d putmsg dups descriptor %d", fd, newfd);
15684+ error = SYS(dup2)(newfd, fd);
15685+ if (error < 0)
15686+ return error;
15687+
15688+ return 0;
15689+ }
15690+#endif /* CONFIG_ABI_IBCS_SPX */
15691+
15692+#ifdef CONFIG_ABI_XTI
15693+ return do_putmsg(fd, regs, ctl.buf, ctl.len,
15694+ dat.buf, dat.len, flags);
15695+#else /* CONFIG_ABI_XTI */
15696+ return -EINVAL;
15697+#endif /* CONFIG_ABI_XTI */
15698+}
15699+
15700+int stream_fdinsert(struct pt_regs *regs, int fd, struct strfdinsert *arg)
15701+{
15702+ struct strfdinsert sfd;
15703+ int error;
15704+
15705+ error = copy_from_user(&sfd, arg, sizeof(sfd));
15706+ if (error)
15707+ return -EFAULT;
15708+
15709+ abi_trace(ABI_TRACE_STREAMS,
15710+ "%u fdinsert: flags=%ld, fildes=%u, offset=%d",
15711+ fd, sfd.flags, sfd.fildes, sfd.offset);
15712+
15713+ return do_putmsg(fd, regs, sfd.ctlbuf.buf, sfd.ctlbuf.len,
15714+ sfd.datbuf.buf, sfd.datbuf.len, sfd.fildes);
15715+}
15716+
15717+#endif /* defined(CONFIG_ABI_XTI) || defined(CONFIG_ABI_IBCS_SPX) */
15718diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/ulimit.c linux/abi/svr4/ulimit.c
15719--- linux-2.4.3/abi/svr4/ulimit.c Thu Jan 1 01:00:00 1970
15720+++ linux/abi/svr4/ulimit.c Sun Mar 18 11:54:28 2001
15721@@ -0,0 +1,148 @@
15722+/* $Id$
15723+ *
15724+ * Copyright (C) 1993 Joe Portman (baron@hebron.connected.com)
15725+ * First stab at ulimit
15726+ *
15727+ * April 9 1994, corrected file size passed to/from setrlimit/getrlimit
15728+ * -- Graham Adams (gadams@ddrive.demon.co.uk)
15729+ *
15730+ */
15731+
15732+#include <linux/module.h>
15733+#include <linux/errno.h>
15734+#include <linux/sched.h>
15735+#include <linux/kernel.h>
15736+#include <linux/unistd.h>
15737+#include <linux/fs.h>
15738+#include <linux/resource.h>
15739+#include <asm/uaccess.h>
15740+
15741+#include <abi/abi.h>
15742+#include <abi/trace.h>
15743+
15744+/*
15745+ * Arguments to ulimit - it's one of the stupid multipled calls...
15746+ */
15747+#define U_GETFSIZE (1) /* get max file size in blocks */
15748+#define U_SETFSIZE (2) /* set max file size in blocks */
15749+#define U_GETMEMLIM (3) /* get process size limit */
15750+#define U_GETMAXOPEN (4) /* get max open files for this process */
15751+#define U_GTXTOFF (64) /* get text offset */
15752+
15753+/*
15754+ * Define nominal block size parameters.
15755+ */
15756+#define ULIM_BLOCKSIZE_BITS 9 /* block size = 512 */
15757+#define ULIM_MAX_BLOCKSIZE (INT_MAX >> ULIM_BLOCKSIZE_BITS)
15758+
15759+
15760+int
15761+svr4_ulimit (int cmd, int val)
15762+{
15763+ switch (cmd) {
15764+ case U_GETFSIZE:
15765+ return (current->rlim[RLIMIT_FSIZE].rlim_cur) >> ULIM_BLOCKSIZE_BITS;
15766+
15767+ case U_SETFSIZE:
15768+ if ((val > ULIM_MAX_BLOCKSIZE) || (val < 0))
15769+ return -ERANGE;
15770+ val <<= ULIM_BLOCKSIZE_BITS;
15771+ if (val > current->rlim[RLIMIT_FSIZE].rlim_max) {
15772+ if (!capable(CAP_SYS_RESOURCE))
15773+ return -EPERM;
15774+ current->rlim[RLIMIT_FSIZE].rlim_max = val;
15775+ }
15776+ current->rlim[RLIMIT_FSIZE].rlim_cur = val;
15777+ return 0;
15778+
15779+ case U_GETMEMLIM:
15780+ return current->rlim[RLIMIT_DATA].rlim_cur;
15781+
15782+ case U_GETMAXOPEN:
15783+ return current->rlim[RLIMIT_NOFILE].rlim_cur;
15784+
15785+ default:
15786+ abi_trace(ABI_TRACE_API, "unsupported ulimit call %d", cmd);
15787+ return -EINVAL;
15788+ }
15789+}
15790+EXPORT_SYMBOL(svr4_ulimit);
15791+
15792+
15793+/*
15794+ * getrlimit/setrlimit args.
15795+ */
15796+#define U_RLIMIT_CPU 0
15797+#define U_RLIMIT_FSIZE 1
15798+#define U_RLIMIT_DATA 2
15799+#define U_RLIMIT_STACK 3
15800+#define U_RLIMIT_CORE 4
15801+#define U_RLIMIT_NOFILE 5
15802+#define U_RLIMIT_AS 6
15803+
15804+
15805+int
15806+svr4_getrlimit(int cmd, void *val)
15807+{
15808+ switch (cmd) {
15809+ case U_RLIMIT_CPU:
15810+ cmd = RLIMIT_CPU;
15811+ break;
15812+ case U_RLIMIT_FSIZE:
15813+ cmd = RLIMIT_FSIZE;
15814+ break;
15815+ case U_RLIMIT_DATA:
15816+ cmd = RLIMIT_DATA;
15817+ break;
15818+ case U_RLIMIT_STACK:
15819+ cmd = RLIMIT_STACK;
15820+ break;
15821+ case U_RLIMIT_CORE:
15822+ cmd = RLIMIT_CORE;
15823+ break;
15824+ case U_RLIMIT_NOFILE:
15825+ cmd = RLIMIT_NOFILE;
15826+ break;
15827+ case U_RLIMIT_AS:
15828+ cmd = RLIMIT_AS;
15829+ break;
15830+ default:
15831+ return -EINVAL;
15832+ }
15833+
15834+ return SYS(getrlimit)(cmd, val);
15835+}
15836+EXPORT_SYMBOL(svr4_getrlimit);
15837+
15838+int
15839+svr4_setrlimit(int cmd, void *val)
15840+{
15841+ switch (cmd) {
15842+ case U_RLIMIT_CPU:
15843+ cmd = RLIMIT_CPU;
15844+ break;
15845+ case U_RLIMIT_FSIZE:
15846+ cmd = RLIMIT_FSIZE;
15847+ break;
15848+ case U_RLIMIT_DATA:
15849+ cmd = RLIMIT_DATA;
15850+ break;
15851+ case U_RLIMIT_STACK:
15852+ cmd = RLIMIT_STACK;
15853+ break;
15854+ case U_RLIMIT_CORE:
15855+ cmd = RLIMIT_CORE;
15856+ break;
15857+ case U_RLIMIT_NOFILE:
15858+ cmd = RLIMIT_NOFILE;
15859+ break;
15860+ case U_RLIMIT_AS:
15861+ cmd = RLIMIT_AS;
15862+ break;
15863+ default:
15864+ return -EINVAL;
15865+ }
15866+
15867+ return SYS(getrlimit)(cmd, val);
15868+}
15869+EXPORT_SYMBOL(svr4_setrlimit);
15870diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/utsname.c linux/abi/svr4/utsname.c
15871--- linux-2.4.3/abi/svr4/utsname.c Thu Jan 1 01:00:00 1970
15872+++ linux/abi/svr4/utsname.c Mon Mar 12 16:34:48 2001
15873@@ -0,0 +1,159 @@
15874+/* $Id$
15875+ *
15876+ * svr4 utsname emuation
15877+ *
15878+ * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
15879+ *
15880+ * The SVR4 utsname support is based on the code originally in svr4.c
15881+ * which was:
15882+ *
15883+ * Copyright (C) 1994 Eric Youngdale.
15884+ */
15885+
15886+#include <linux/module.h>
15887+#include <linux/version.h>
15888+
15889+#include <asm/uaccess.h>
15890+
15891+#include <linux/mm.h>
15892+#include <linux/sched.h>
15893+#include <linux/personality.h>
15894+#include <linux/utsname.h>
15895+
15896+#include <abi/abi.h>
15897+
15898+char sco_serial[10] = "public";
15899+
15900+struct sco_utsname {
15901+ char sysname[9];
15902+ char nodename[9];
15903+ char release[16];
15904+ char kernelid[20];
15905+ char machine[9];
15906+ char bustype[9];
15907+ char sysserial[10];
15908+ unsigned short sysorigin;
15909+ unsigned short sysoem;
15910+ char numusers[9];
15911+ unsigned short numcpu;
15912+};
15913+
15914+struct v7_utsname {
15915+ char sysname[9];
15916+ char nodename[9];
15917+ char release[9];
15918+ char version[9];
15919+ char machine[9];
15920+};
15921+
15922+#define SVR4_NMLN 257
15923+struct svr4_utsname {
15924+ char sysname[SVR4_NMLN];
15925+ char nodename[SVR4_NMLN];
15926+ char release[SVR4_NMLN];
15927+ char version[SVR4_NMLN];
15928+ char machine[SVR4_NMLN];
15929+};
15930+
15931+
15932+#define set_utsfield(to, from, dotchop) \
15933+ { \
15934+ char *p; \
15935+ int i, len = (sizeof(to) > sizeof(from) ? sizeof(from) : sizeof(to)); \
15936+ __copy_to_user(to, from, len); \
15937+ if (dotchop) \
15938+ for (p=from,i=0; *p && *p != '.' && --len; p++,i++); \
15939+ else \
15940+ i = len - 1; \
15941+ __put_user('\0', to+i); \
15942+ }
15943+
15944+
15945+int
15946+sco_utsname(unsigned long addr)
15947+{
15948+ int error;
15949+ struct sco_utsname *it = (struct sco_utsname *)addr;
15950+
15951+ /* This shouldn't be invoked by anything that isn't running
15952+ * in the SCO personality. I can envisage a program that uses
15953+ * this to test if it is running on SCO or not. It probably
15954+ * won't happen but let's make sure it doesn't anyway...
15955+ */
15956+ if (!personality(PER_SCOSVR3))
15957+ return -ENOSYS;
15958+
15959+ down_read(&uts_sem);
15960+ error = verify_area(VERIFY_WRITE, it, sizeof (struct sco_utsname));
15961+ if (!error) {
15962+#if 0
15963+ set_utsfield(it->sysname, system_utsname.nodename, 1);
15964+#else
15965+ set_utsfield(it->sysname, "SCO_SV", 0);
15966+#endif
15967+ set_utsfield(it->nodename, system_utsname.nodename, 1);
15968+#if 0
15969+ set_utsfield(it->release, system_utsname.release, 0);
15970+#else
15971+ set_utsfield(it->release, "3.2v5.0.0\0", 0);
15972+#endif
15973+ set_utsfield(it->kernelid, system_utsname.version, 0);
15974+ set_utsfield(it->machine, system_utsname.machine, 0);
15975+ if (EISA_bus) {
15976+ set_utsfield(it->bustype, "EISA", 0);
15977+ } else {
15978+ set_utsfield(it->bustype, "ISA", 0);
15979+ }
15980+ set_utsfield(it->sysserial, sco_serial, 0);
15981+ __put_user(0xffff, &it->sysorigin);
15982+ __put_user(0xffff, &it->sysoem);
15983+ set_utsfield(it->numusers, "unlim", 0);
15984+ __put_user(1, &it->numcpu);
15985+ }
15986+ up_read(&uts_sem);
15987+
15988+ return error;
15989+}
15990+
15991+
15992+int v7_utsname(unsigned long addr)
15993+{
15994+ int error;
15995+ struct v7_utsname *it = (struct v7_utsname *)addr;
15996+
15997+ down_read(&uts_sem);
15998+ error = verify_area(VERIFY_WRITE, it, sizeof (struct v7_utsname));
15999+ if (!error) {
16000+ set_utsfield(it->sysname, system_utsname.nodename, 1);
16001+ set_utsfield(it->nodename, system_utsname.nodename, 1);
16002+ set_utsfield(it->release, system_utsname.release, 0);
16003+ set_utsfield(it->version, system_utsname.version, 0);
16004+ set_utsfield(it->machine, system_utsname.machine, 0);
16005+ }
16006+ up_read(&uts_sem);
16007+
16008+ return error;
16009+}
16010+
16011+EXPORT_SYMBOL(v7_utsname);
16012+
16013+int abi_utsname(unsigned long addr)
16014+{
16015+ int error;
16016+ struct svr4_utsname *it = (struct svr4_utsname *)addr;
16017+
16018+ down_read(&uts_sem);
16019+ error = verify_area(VERIFY_WRITE, it, sizeof (struct svr4_utsname));
16020+ if (!error) {
16021+ set_utsfield(it->sysname, system_utsname.sysname, 0);
16022+ set_utsfield(it->nodename, system_utsname.nodename, 0);
16023+ set_utsfield(it->release, system_utsname.release, 0);
16024+ set_utsfield(it->version, system_utsname.version, 0);
16025+ set_utsfield(it->machine, system_utsname.machine, 0);
16026+ }
16027+ up_read(&uts_sem);
16028+
16029+ return error;
16030+}
16031+
16032+EXPORT_SYMBOL(abi_utsname);
16033diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/vtkbd.c linux/abi/svr4/vtkbd.c
16034--- linux-2.4.3/abi/svr4/vtkbd.c Thu Jan 1 01:00:00 1970
16035+++ linux/abi/svr4/vtkbd.c Mon Mar 12 16:34:48 2001
16036@@ -0,0 +1,94 @@
16037+/* $Id$
16038+ *
16039+ * This provides internal emulation support for the SCO <sys/vtkd.h> on
16040+ * the multiscreen console. More or less, this involves translating the
16041+ * input ioctl()'s into a similar Linux ioctl()'s.
16042+ *
16043+ * Not emulated SCO multiscreen functions:
16044+ * None.
16045+ *
16046+ * Not emulated SCO keyboard functions:
16047+ * KIOCDOSMODE set DOSMODE
16048+ * KIOCNONDOSMODE unset DOSMODE
16049+ * KDDISPINFO get display start and size
16050+ * KDGKBSTATE get state of keyboard shift keys
16051+ *
16052+ * Written by Scott Michel, scottm@intime.com
16053+ * (c) 1994 Scott Michel as part of the Linux iBCS-2 emulator project.
16054+ *
16055+ */
16056+
16057+#include <linux/module.h>
16058+
16059+#include <asm/uaccess.h>
16060+
16061+#include <linux/errno.h>
16062+#include <linux/fs.h>
16063+#include <linux/sched.h>
16064+#include <linux/kernel.h>
16065+#include <linux/vt.h>
16066+#include <linux/kd.h>
16067+
16068+#include <abi/abi.h>
16069+#include <abi/trace.h>
16070+
16071+static struct {
16072+ int in_ioctl; /* only lower 8 bits */
16073+ int out_ioctl; /* Linux version */
16074+} trantab[] = {
16075+#ifdef KDDISPTYPE
16076+ { 1, KDDISPTYPE },
16077+#endif
16078+ { 2, KDMAPDISP },
16079+ { 3, KDUNMAPDISP },
16080+ { 6, KDGKBMODE },
16081+ { 7, KDSKBMODE },
16082+ { 8, KDMKTONE },
16083+ { 9, KDGETMODE },
16084+ { 10, KDSETMODE },
16085+ { 11, KDADDIO },
16086+ { 12, KDDELIO },
16087+ { 60, KDENABIO },
16088+ { 61, KDDISABIO },
16089+#ifdef KIOCINFO
16090+ { 62, KIOCINFO },
16091+#endif
16092+ { 63, KIOCSOUND },
16093+ { 64, KDGKBTYPE },
16094+ { 65, KDGETLED },
16095+ { 66, KDSETLED },
16096+};
16097+
16098+/*--------------------------------------------------------------------------
16099+ * ibcs_ioctl_vtkd()
16100+ *------------------------------------------------------------------------*/
16101+
16102+int
16103+ibcs_ioctl_vtkd(int fd, int todo, void *arg)
16104+{
16105+ int gen = (todo >> 8) & 0xff, spec = todo & 0xff;
16106+ int newf;
16107+
16108+ if (gen == 'v') {
16109+ /* Could make this translation process table based, but, why
16110+ waste the valuable kernel space? */
16111+
16112+ newf = (spec == 1 ? VT_OPENQRY :
16113+ (spec == 2 ? VT_SETMODE :
16114+ (spec == 3 ? VT_GETMODE :
16115+ (spec == 4 ? VT_RELDISP :
16116+ (spec == 5 ? VT_ACTIVATE : -1)))));
16117+ if (newf != -1)
16118+ return SYS(ioctl)(fd, newf, arg);
16119+ } else if (gen == 'K') {
16120+ register unsigned int i;
16121+
16122+ for (i = 0; i < sizeof(trantab) / sizeof(trantab[0]); ++i) {
16123+ if (spec == trantab[i].in_ioctl)
16124+ return SYS(ioctl)(fd, trantab[i].out_ioctl, arg);
16125+ }
16126+ }
16127+
16128+ printk(KERN_ERR "iBCS: vtkd ioctl 0x%02x unsupported\n", todo);
16129+ return -EINVAL;
16130+}
16131diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/wyse_nfs.c linux/abi/svr4/wyse_nfs.c
16132--- linux-2.4.3/abi/svr4/wyse_nfs.c Thu Jan 1 01:00:00 1970
16133+++ linux/abi/svr4/wyse_nfs.c Fri Mar 30 15:23:46 2001
16134@@ -0,0 +1,30 @@
16135+/* $Id$ */
16136+
16137+#include <linux/kernel.h>
16138+#include <linux/config.h>
16139+#include <abi/abi.h>
16140+
16141+#define SC(name) (void *)__NR_##name
16142+#define ITR(trace, name, args) ,trace,name,args
16143+
16144+static ABI_func WYSENFS_funcs[] = {
16145+ { 0, Ukn ITR(1, "nfs_svc", "") }, /* 0 */
16146+ { 0, Ukn ITR(1, "async_daemon", "") }, /* 1 */
16147+ { 0, Ukn ITR(1, "nfs_getfh", "") }, /* 2 */
16148+ { 0, Ukn ITR(1, "nfsmount", "") } /* 3 */
16149+};
16150+
16151+
16152+void iBCS_class_WYSENFS(struct pt_regs *regs) {
16153+ int i;
16154+
16155+ i = regs->eax >> 8;
16156+ if (i > 3) {
16157+ regs->eax = iABI_errors(-EINVAL);
16158+ regs->eflags |= 1;
16159+ return;
16160+ }
16161+
16162+ abi_dispatch(regs, &WYSENFS_funcs[i],1);
16163+ return;
16164+}
16165diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/wyse_tcp.c linux/abi/svr4/wyse_tcp.c
16166--- linux-2.4.3/abi/svr4/wyse_tcp.c Thu Jan 1 01:00:00 1970
16167+++ linux/abi/svr4/wyse_tcp.c Fri Mar 30 15:23:46 2001
16168@@ -0,0 +1,51 @@
16169+/* $Id$ */
16170+
16171+#include <linux/kernel.h>
16172+#include <linux/config.h>
16173+#include <abi/abi.h>
16174+
16175+#define SC(name) (void *)__NR_##name
16176+
16177+#define ITR(trace, name, args) ,trace,name,args
16178+
16179+static ABI_func WYSETCP_funcs[] = {
16180+#ifdef __TRACE_SELECT__
16181+ { abi_select, 5 ITR(0, "select", "dxxxx")},/* 0 */
16182+#else
16183+ { SC(_newselect), -5 ITR(0, "select", "dxxxx")},/* 0 */
16184+#endif
16185+ { abi_socket, Spl ITR(0, "socket", "ddd") }, /* 1 */
16186+ { abi_connect, Spl ITR(0, "connect", "dxd") }, /* 2 */
16187+ { abi_accept, Spl ITR(0, "accept", "dxx") }, /* 3 */
16188+ { abi_send, Spl ITR(0, "send", "dxdd")}, /* 4 */
16189+ { abi_recv, Spl ITR(0, "recv", "dxdd")}, /* 5 */
16190+ { abi_bind, Spl ITR(0, "bind", "dxd") }, /* 6 */
16191+ { abi_setsockopt, Spl ITR(0, "setsockopt", "") }, /* 7 */
16192+ { abi_listen, Spl ITR(0, "listen", "dd") }, /* 8 */
16193+ { 0, 3 ITR(1, "recvmsg", "dxd") }, /* 9 */
16194+ { 0, 3 ITR(1, "sendmsg", "dxd") }, /* 10 */
16195+ { abi_getsockopt, Spl ITR(0, "getsockopt", "dddxx")}, /* 11 */
16196+ { abi_recvfrom, Spl ITR(0, "recvfrom", "dxddxd")},/* 12 */
16197+ { abi_sendto, Spl ITR(0, "sendto", "dxddxd")},/* 13 */
16198+ { abi_shutdown, Spl ITR(0, "shutdown", "dd") }, /* 14 */
16199+ { abi_socketpair, Spl ITR(0, "socketpair", "dddx")}, /* 15 */
16200+ { 0, Ukn ITR(1, "trace", "") }, /* 16 */
16201+ { abi_getpeername, Spl ITR(0, "getpeername", "dxx") }, /* 17 */
16202+ { abi_getsockname, Spl ITR(0, "getsockname", "") }, /* 18 */
16203+ { abi_wait3, 1 ITR(0, "wait3", "x") }, /* 19 */
16204+};
16205+
16206+
16207+void iBCS_class_WYSETCP(struct pt_regs *regs) {
16208+ int i;
16209+
16210+ i = regs->eax >> 8;
16211+ if (i > 19) {
16212+ regs->eax = iABI_errors(-EINVAL);
16213+ regs->eflags |= 1;
16214+ return;
16215+ }
16216+
16217+ abi_dispatch(regs, &WYSETCP_funcs[i], 1);
16218+ return;
16219+}
16220diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/xnx.c linux/abi/svr4/xnx.c
16221--- linux-2.4.3/abi/svr4/xnx.c Thu Jan 1 01:00:00 1970
16222+++ linux/abi/svr4/xnx.c Mon Mar 12 16:34:48 2001
16223@@ -0,0 +1,428 @@
16224+/* $Id$
16225+ *
16226+ * This file contains an emulation of Xenix syscalls that are used by SCO binaries
16227+ *
16228+ * Copyright (C) 1993,1994 Drew Sullivan
16229+ * Copyright (C) 1994,1995-1996 Mike Jagdis
16230+ *
16231+ */
16232+
16233+#include <linux/module.h>
16234+
16235+#include <asm/uaccess.h>
16236+
16237+#include <linux/errno.h>
16238+#include <linux/sched.h>
16239+#include <linux/kernel.h>
16240+#include <linux/mm.h>
16241+#include <linux/stddef.h>
16242+#include <linux/unistd.h>
16243+#include <linux/ptrace.h>
16244+#include <linux/fcntl.h>
16245+#include <linux/time.h>
16246+#include <linux/signal.h>
16247+#include <linux/slab.h>
16248+
16249+#include <asm/system.h>
16250+#include <linux/fs.h>
16251+#include <linux/sys.h>
16252+#include <linux/termios.h>
16253+#include <linux/limits.h>
16254+#include <linux/vfs.h>
16255+
16256+#include <abi/abi.h>
16257+#include <abi/trace.h>
16258+#include <abi/xnx.h>
16259+
16260+
16261+#define XF_UNLCK 0
16262+#define XF_WRLCK 1
16263+#define XF_RDLCK 3
16264+
16265+
16266+struct ibcs_flock {
16267+ short l_type;
16268+ short l_whence;
16269+ off_t l_start;
16270+ off_t l_len;
16271+ short l_sysid;
16272+ short l_pid;
16273+};
16274+
16275+
16276+/* locking() requires mandatory locking. Processes that attempt to
16277+ * read or write a region locked with locking() are required to block.
16278+ * You need to build a kernel with mandatory locking support and set
16279+ * the permissions on the required file to setgid, no group execute.
16280+ */
16281+int xnx_locking(int fd, int mode, unsigned long size)
16282+{
16283+ struct flock fl;
16284+ mm_segment_t old_fs;
16285+ int error;
16286+
16287+ if ((mode < 0 || mode > 7) && mode != 20) {
16288+ abi_trace(ABI_TRACE_API,
16289+ "unsupported locking() mode=0x%x", mode);
16290+ return -EINVAL;
16291+ }
16292+
16293+ /* Modes 5, 6 & 7 are very like the fcntl mechanism but
16294+ * we can't just punt to that because the type values are
16295+ * different.
16296+ */
16297+ if (mode > 4 && mode < 8) {
16298+ struct ibcs_flock *ifl = (struct ibcs_flock *)size;
16299+ short t;
16300+
16301+ error = verify_area(VERIFY_READ, ifl, sizeof(*ifl));
16302+ if (error)
16303+ return error;
16304+
16305+ get_user(t, &ifl->l_type);
16306+ switch (t) {
16307+ case XF_UNLCK: t = F_UNLCK; break;
16308+ case XF_WRLCK: t = F_WRLCK; break;
16309+ case XF_RDLCK: t = F_RDLCK; break;
16310+ default: return -EINVAL;
16311+ }
16312+ put_user(t, &ifl->l_type);
16313+
16314+ error = SYS(fcntl)(fd, mode, ifl);
16315+
16316+ get_user(t, &ifl->l_type);
16317+ switch (t) {
16318+ case F_UNLCK: t = XF_UNLCK; break;
16319+ case F_WRLCK: t = XF_WRLCK; break;
16320+ case F_RDLCK: t = XF_RDLCK; break;
16321+ }
16322+ put_user(t, &ifl->l_type);
16323+
16324+ get_user(t, &ifl->l_sysid);
16325+ put_user(t, &ifl->l_pid);
16326+ put_user(0, &ifl->l_sysid);
16327+ return error;
16328+ }
16329+
16330+ fl.l_type = (mode == 0 ? F_UNLCK
16331+ : ((mode <= 2 || mode == 20) ? F_WRLCK
16332+ : F_RDLCK));
16333+ fl.l_whence = 1;
16334+ fl.l_start = 0;
16335+ fl.l_len = size;
16336+
16337+ old_fs = get_fs();
16338+ set_fs (get_ds());
16339+ error = SYS(fcntl)(fd,
16340+ mode == 5 ? F_GETLK
16341+ : (!(mode % 2) ? F_SETLK : F_SETLKW),
16342+ &fl);
16343+ set_fs(old_fs);
16344+ return error;
16345+}
16346+
16347+
16348+int xnx_creatsem(char *sem_name, int mode) {
16349+ return -EPERM;
16350+}
16351+
16352+int xnx_opensem(char *sem_name) {
16353+ return -EPERM;
16354+}
16355+
16356+int xnx_sigsem(int sem_num) {
16357+ return -EPERM;
16358+}
16359+
16360+int xnx_waitsem(int sem_num) {
16361+ return -EPERM;
16362+}
16363+
16364+int xnx_nbwaitsem(int sem_num) {
16365+ return -EPERM;
16366+}
16367+
16368+/* Check if input is available */
16369+int xnx_rdchk(int fd) {
16370+ int error, nbytes;
16371+ mm_segment_t old_fs;
16372+
16373+ old_fs = get_fs();
16374+ set_fs (get_ds());
16375+ error = SYS(ioctl)(fd, FIONREAD, &nbytes);
16376+ set_fs(old_fs);
16377+
16378+ if (error < 0) return error;
16379+ return nbytes ? 1 : 0;
16380+}
16381+
16382+/* Linux has a stub sys_ftime. Perhaps this should be there? On the other
16383+ * hand it's an old call that probably shouldn't be used by most modern
16384+ * applications so perhaps it's better here where it needn't bloat the
16385+ * base kernel.
16386+ */
16387+int xnx_ftime(struct timeb * tp) {
16388+ struct timeval tv;
16389+ struct timezone tz;
16390+ int error;
16391+ mm_segment_t old_fs;
16392+
16393+ error = verify_area(VERIFY_WRITE, tp, sizeof(struct timeb));
16394+ if (error)
16395+ return error;
16396+
16397+ old_fs = get_fs();
16398+ set_fs (get_ds());
16399+ error = SYS(gettimeofday)(&tv, &tz);
16400+ set_fs(old_fs);
16401+ if (error)
16402+ return error;
16403+
16404+ put_user(tv.tv_sec, &tp->time);
16405+ put_user((unsigned short)(tv.tv_usec/1000), &tp->millitm);
16406+ put_user((short)tz.tz_minuteswest, &tp->timezone);
16407+ put_user((short)tz.tz_dsttime, &tp->dstflag);
16408+
16409+ return 0;
16410+}
16411+
16412+/* go to sleep for period milliseconds */
16413+int xnx_nap(long period)
16414+{
16415+ __sighandler_t old_handler;
16416+ struct itimerval it;
16417+ struct timeval tv1, tv2;
16418+ struct timezone tz;
16419+ mm_segment_t old_fs;
16420+
16421+ if (!period)
16422+ return 0;
16423+
16424+ it.it_interval.tv_sec = 0;
16425+ it.it_interval.tv_usec = 0;
16426+ it.it_value.tv_sec = 0;
16427+ it.it_value.tv_usec = period * 1000;
16428+ old_fs = get_fs();
16429+ set_fs (get_ds());
16430+ SYS(gettimeofday)(&tv1, &tz);
16431+ spin_lock_irq(&current->sig[SIGALRM-1].siglock);
16432+ old_handler = current->sig->action[SIGALRM-1].sa.sa_handler;
16433+ current->sig->action[SIGALRM-1].sa.sa_handler = SIG_DFL;
16434+ spin_unlock_irq(&current->sig[SIGALRM-1].siglock);
16435+ SYS(setitimer)(ITIMER_REAL, &it, NULL);
16436+ SYS(pause)();
16437+ spin_lock_irq(&current->sig[SIGALRM-1].siglock);
16438+ current->sig->action[SIGALRM-1].sa.sa_handler = old_handler;
16439+ spin_unlock_irq(&current->sig[SIGALRM-1].siglock);
16440+ SYS(gettimeofday)(&tv2, &tz);
16441+ set_fs(old_fs);
16442+
16443+ deactivate_signal(current, SIGALRM);
16444+
16445+ return (signal_pending(current)
16446+ ? -EINTR
16447+ : ((tv2.tv_sec - tv1.tv_sec) * 1000000
16448+ + (tv2.tv_usec - tv1.tv_usec)) / 1000);
16449+}
16450+
16451+int xnx_sdget(char *path, int flags, long size, int mode) {
16452+ return -EPERM;
16453+}
16454+
16455+int xnx_sdfree(char* addr) {
16456+ return -EPERM;
16457+}
16458+
16459+int xnx_sdenter(char *addr, int flags) {
16460+ return -EPERM;
16461+}
16462+
16463+int xnx_sdleave(char *addr) {
16464+ return -EPERM;
16465+}
16466+
16467+int xnx_sdgetv(char *addr) {
16468+ return -EPERM;
16469+}
16470+
16471+int xnx_sdwaitv(char *addr, int vnum) {
16472+ return -EPERM;
16473+}
16474+
16475+/* This allows processes to be allowed to exceed available swap. The man
16476+ * page isn't too clear - it seems to suggest Xenix supports physical
16477+ * memory > swap but this doesn't make sense to me? It almost certainly
16478+ * isn't useful for Linux to actually do anything with this - just lie.
16479+ */
16480+int xnx_proctl(int pid, int command, char *arg) {
16481+#define PRHUGEX 1
16482+#define PRNORMEX 2
16483+ return 0;
16484+}
16485+
16486+int xnx_execseg(excode_t oldaddr, unsigned size) {
16487+ return -EPERM;
16488+}
16489+
16490+
16491+int xnx_unexecseg(excode_t addr) {
16492+ return -EPERM;
16493+}
16494+
16495+/* eaccess() checks access to the given path using the effective
16496+ * uid/gid rather than the real uid/gid.
16497+ */
16498+int xnx_eaccess(char *path, int mode) {
16499+ unsigned short ouid, ogid;
16500+ int err;
16501+
16502+ ouid = current->uid;
16503+ ogid = current->gid;
16504+ current->uid = current->euid;
16505+ current->gid = current->egid;
16506+
16507+ err = SYS(access)(path, mode);
16508+
16509+ current->uid = ouid;
16510+ current->gid = ogid;
16511+
16512+ return err;
16513+}
16514+
16515+/* This allows running adb without executing any programs, but disassembly
16516+ * will work fine with that lie.
16517+ */
16518+int xnx_paccess(int pid, int cmd, int offset, int count, char *ptr) {
16519+ return 0;
16520+}
16521+
16522+int xnx_sigpending(unsigned long *set) {
16523+ return -EPERM;
16524+}
16525+
16526+
16527+#define _PC_LINK_MAX 0
16528+#define _PC_MAX_CANON 1
16529+#define _PC_MAX_INPUT 2
16530+#define _PC_NAME_MAX 3
16531+#define _PC_PATH_MAX 4
16532+#define _PC_PIPE_BUF 5
16533+#define _PC_CHOWN_RESTRICTED 6
16534+#define _PC_NO_TRUNC 7
16535+#define _PC_VDISABLE 8
16536+
16537+int
16538+xnx_pathconf(char *path, int name)
16539+{
16540+ switch (name) {
16541+ case _PC_LINK_MAX:
16542+ /* Although Linux headers define values on a per
16543+ * filesystem basis there is no way to access
16544+ * these without hard coding fs information here
16545+ * so for now we use a bogus value.
16546+ */
16547+ return LINK_MAX;
16548+
16549+ case _PC_MAX_CANON:
16550+ return MAX_CANON;
16551+
16552+ case _PC_MAX_INPUT:
16553+ return MAX_INPUT;
16554+
16555+ case _PC_PATH_MAX:
16556+ return PATH_MAX;
16557+
16558+ case _PC_PIPE_BUF:
16559+ return PIPE_BUF;
16560+
16561+ case _PC_CHOWN_RESTRICTED:
16562+ /* We should really think about this and tell
16563+ * the truth.
16564+ */
16565+ return 0;
16566+
16567+ case _PC_NO_TRUNC:
16568+ /* Not sure... It could be fs dependent? */
16569+ return 1;
16570+
16571+ case _PC_VDISABLE:
16572+ return 1;
16573+
16574+ case _PC_NAME_MAX: {
16575+ struct statfs buf;
16576+ char *p;
16577+ int error;
16578+ mm_segment_t old_fs;
16579+
16580+ p = getname(path);
16581+ error = PTR_ERR(p);
16582+ if (!IS_ERR(p)) {
16583+ old_fs = get_fs();
16584+ set_fs (get_ds());
16585+ error = SYS(statfs)(p, &buf);
16586+ set_fs(old_fs);
16587+ putname(p);
16588+ if (!error)
16589+ return buf.f_namelen;
16590+ }
16591+ return error;
16592+ }
16593+ }
16594+
16595+ return -EINVAL;
16596+}
16597+
16598+int
16599+xnx_fpathconf(int fildes, int name)
16600+{
16601+ switch (name) {
16602+ case _PC_LINK_MAX:
16603+ /* Although Linux headers define values on a per
16604+ * filesystem basis there is no way to access
16605+ * these without hard coding fs information here
16606+ * so for now we use a bogus value.
16607+ */
16608+ return LINK_MAX;
16609+
16610+ case _PC_MAX_CANON:
16611+ return MAX_CANON;
16612+
16613+ case _PC_MAX_INPUT:
16614+ return MAX_INPUT;
16615+
16616+ case _PC_PATH_MAX:
16617+ return PATH_MAX;
16618+
16619+ case _PC_PIPE_BUF:
16620+ return PIPE_BUF;
16621+
16622+ case _PC_CHOWN_RESTRICTED:
16623+ /* We should really think about this and tell
16624+ * the truth.
16625+ */
16626+ return 0;
16627+
16628+ case _PC_NO_TRUNC:
16629+ /* Not sure... It could be fs dependent? */
16630+ return 1;
16631+
16632+ case _PC_VDISABLE:
16633+ return 1;
16634+
16635+ case _PC_NAME_MAX: {
16636+ struct statfs buf;
16637+ int error;
16638+ mm_segment_t old_fs;
16639+
16640+ old_fs = get_fs();
16641+ set_fs (get_ds());
16642+ error = SYS(statfs)(fildes, &buf);
16643+ set_fs(old_fs);
16644+ if (!error)
16645+ return buf.f_namelen;
16646+ return error;
16647+ }
16648+ }
16649+
16650+ return -EINVAL;
16651+}
16652diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/xnx_funcs.c linux/abi/svr4/xnx_funcs.c
16653--- linux-2.4.3/abi/svr4/xnx_funcs.c Thu Jan 1 01:00:00 1970
16654+++ linux/abi/svr4/xnx_funcs.c Fri Mar 30 15:23:46 2001
16655@@ -0,0 +1,163 @@
16656+/* $Id$ */
16657+
16658+#include <linux/config.h>
16659+#include <linux/module.h>
16660+
16661+#include <asm/uaccess.h>
16662+
16663+#include <linux/kernel.h>
16664+
16665+#include <abi/signal.h>
16666+#include <abi/abi.h>
16667+#include <abi/xnx.h>
16668+#include <abi/abi4.h>
16669+
16670+#define SC(name) (void *)__NR_##name
16671+#define ITR(trace, name, args) ,trace,name,args
16672+
16673+/*
16674+ * Translate the signal number to the corresponding item for Linux.
16675+ */
16676+static inline int abi_mapsig(int sig)
16677+{
16678+ if ((unsigned int) sig >= NSIGNALS)
16679+ return -1;
16680+ return current->exec_domain->signal_map[sig];
16681+}
16682+
16683+
16684+asmlinkage int sco_sigaction(int sco_signum, const struct sco_sigaction * action,
16685+ struct sco_sigaction * oldaction)
16686+{
16687+ struct sco_sigaction new_sa, old_sa;
16688+ int error, signo;
16689+ mm_segment_t old_fs;
16690+ struct sigaction nsa, osa;
16691+
16692+ signo = abi_mapsig(sco_signum);
16693+ if (signo == -1)
16694+ return -EINVAL;
16695+
16696+ if (oldaction) {
16697+ error = verify_area(VERIFY_WRITE, oldaction,
16698+ sizeof(struct sco_sigaction));
16699+ if (error)
16700+ return error;
16701+ }
16702+
16703+ if (action) {
16704+ error = copy_from_user(&new_sa, action,
16705+ sizeof(struct sco_sigaction));
16706+ if (error)
16707+ return -EFAULT;
16708+ nsa.sa_restorer = NULL;
16709+ nsa.sa_handler = new_sa.sa_handler;
16710+ nsa.sa_mask = map_sigvec_to_kernel(new_sa.sa_mask,
16711+ current->exec_domain->signal_map);
16712+ nsa.sa_flags = SA_NOMASK;
16713+ if (new_sa.sa_flags & SCO_SA_NOCLDSTOP)
16714+ nsa.sa_flags |= SA_NOCLDSTOP;
16715+ }
16716+
16717+ old_fs = get_fs();
16718+ set_fs(get_ds());
16719+ error = SYS(rt_sigaction)(signo,
16720+ action ? &nsa : NULL,
16721+ oldaction ? &osa : NULL,
16722+ sizeof(sigset_t));
16723+ set_fs(old_fs);
16724+
16725+ if (!error && oldaction) {
16726+ old_sa.sa_handler = osa.sa_handler;
16727+ old_sa.sa_mask = map_sigvec_from_kernel(osa.sa_mask,
16728+ current->exec_domain->signal_invmap);
16729+ old_sa.sa_flags = 0;
16730+ if(osa.sa_flags & SA_NOCLDSTOP)
16731+ old_sa.sa_flags |= SCO_SA_NOCLDSTOP;
16732+ /* This should never fail... */
16733+ copy_to_user(oldaction, &old_sa, sizeof(struct sco_sigaction));
16734+ }
16735+ return error;
16736+}
16737+
16738+static ABI_func XNX_funcs[] = {
16739+ { 0, Ukn ITR(1, "syscall", "") }, /* 0 */
16740+ { xnx_locking, 3 ITR(0, "locking", "ddd") }, /* 1 */
16741+ { xnx_creatsem, 2 ITR(1, "creatsem", "sd") }, /* 2 */
16742+ { xnx_opensem, 1 ITR(1, "opensem", "s") }, /* 3 */
16743+ { xnx_sigsem, 1 ITR(1, "sigsem", "d") }, /* 4 */
16744+ { xnx_waitsem, 1 ITR(1, "waitsem", "d") }, /* 5 */
16745+ { xnx_nbwaitsem, 1 ITR(1, "nbwaitsem", "d") }, /* 6 */
16746+ { xnx_rdchk, 1 ITR(0, "rdchk", "d") }, /* 7 */
16747+ { 0, Ukn ITR(1, "stkgro", "") }, /* 8 */
16748+ { 0, Ukn ITR(1, "?", "") }, /* 9 */
16749+ { SC(ftruncate), -2 ITR(0, "chsize", "dd") }, /* 10 */
16750+ { xnx_ftime, 1 ITR(0, "ftime", "x") }, /* 11 */
16751+ { xnx_nap, 1 ITR(0, "nap", "d") }, /* 12 */
16752+ { xnx_sdget, 4 ITR(1, "sdget", "sddd") }, /* 13 */
16753+ { xnx_sdfree, 1 ITR(1, "sdfree", "x") }, /* 14 */
16754+ { xnx_sdenter, 2 ITR(1, "sdenter", "xd") }, /* 15 */
16755+ { xnx_sdleave, 1 ITR(1, "sdleave", "x") }, /* 16 */
16756+ { xnx_sdgetv, 1 ITR(1, "sdgetv", "x") }, /* 17 */
16757+ { xnx_sdwaitv, 2 ITR(1, "sdwaitv", "xd") }, /* 18 */
16758+ { 0, Ukn ITR(1, "brkctl", "") }, /* 19 */
16759+ { 0, Ukn ITR(1, "?", "") }, /* 20 */
16760+ { 0, 2 ITR(0, "sco-getcwd?", "dx") }, /* 21 */
16761+ { 0, Ukn ITR(1, "?", "") }, /* 22 */
16762+ { 0, Ukn ITR(1, "?", "") }, /* 23 */
16763+ { 0, Ukn ITR(1, "?", "") }, /* 24 */
16764+ { 0, Ukn ITR(1, "?", "") }, /* 25 */
16765+ { 0, Ukn ITR(1, "?", "") }, /* 26 */
16766+ { 0, Ukn ITR(1, "?", "") }, /* 27 */
16767+ { 0, Ukn ITR(1, "?", "") }, /* 28 */
16768+ { 0, Ukn ITR(1, "?", "") }, /* 29 */
16769+ { 0, Ukn ITR(1, "?", "") }, /* 30 */
16770+ { 0, Ukn ITR(1, "?", "") }, /* 31 */
16771+ { xnx_proctl, 3 ITR(0, "proctl", "ddx") }, /* 32 */
16772+ { xnx_execseg, 2 ITR(1, "execseg", "xd") }, /* 33 */
16773+ { xnx_unexecseg, 1 ITR(1, "unexecseg", "x") }, /* 34 */
16774+ { 0, Ukn ITR(1, "?", "") }, /* 35 */
16775+#ifdef __TRACE_SELECT__
16776+ { abi_select, 5 ITR(0, "select", "dxxxx")}, /* 36 */
16777+#else
16778+ { SC(_newselect), -5 ITR(0, "select", "dxxxx")}, /* 36 */
16779+#endif
16780+ { xnx_eaccess, 2 ITR(0, "eaccess", "so") }, /* 37 */
16781+ { xnx_paccess, 5 ITR(1, "paccess", "dddds")},/* 38 */
16782+ { sco_sigaction, 3 ITR(0, "sigaction", "dxx") }, /* 39 */
16783+ { abi_sigprocmask, 3 ITR(0, "sigprocmask", "dxx") }, /* 40 */
16784+ { xnx_sigpending, 1 ITR(1, "sigpending", "x") }, /* 41 */
16785+ { abi_sigsuspend, Spl ITR(0, "sigsuspend", "x") }, /* 42 */
16786+ { SC(getgroups), -2 ITR(0, "getgroups", "dx") }, /* 43 */
16787+ { SC(setgroups), -2 ITR(0, "setgroups", "dx") }, /* 44 */
16788+ { ibcs_sysconf, 1 ITR(0, "sysconf", "d") }, /* 45 */
16789+ { xnx_pathconf, 2 ITR(0, "pathconf", "sd") }, /* 46 */
16790+ { xnx_fpathconf, 2 ITR(0, "fpathconf", "dd") }, /* 47 */
16791+ { SC(rename), -2 ITR(0, "rename", "ss") }, /* 48 */
16792+ { 0, Ukn ITR(1, "?", "") }, /* 49 */
16793+ { sco_utsname, 1 ITR(0, "sco_utsname", "x") }, /* 50 */
16794+ { 0, Ukn ITR(1, "?", "") }, /* 51 */
16795+ { 0, Ukn ITR(1, "?", "") }, /* 52 */
16796+ { 0, Ukn ITR(1, "?", "") }, /* 53 */
16797+ { 0, Ukn ITR(1, "?", "") }, /* 54 */
16798+ { SC(getitimer), -2 ITR(0, "getitimer", "dx") }, /* 55 */
16799+ { SC(setitimer), -3 ITR(0, "setitimer", "dxx") } /* 56 */
16800+};
16801+
16802+
16803+void iBCS_class_XNX(struct pt_regs *regs)
16804+{
16805+ int i;
16806+
16807+ i = regs->eax >> 8;
16808+ if (i > 56) {
16809+ regs->eax = iABI_errors(-EINVAL);
16810+ regs->eflags |= 1;
16811+ return;
16812+ }
16813+
16814+ abi_dispatch(regs, &XNX_funcs[i], 1);
16815+ return;
16816+}
16817+
16818+EXPORT_SYMBOL(iBCS_class_XNX);
16819diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/svr4/xstat.c linux/abi/svr4/xstat.c
16820--- linux-2.4.3/abi/svr4/xstat.c Thu Jan 1 01:00:00 1970
16821+++ linux/abi/svr4/xstat.c Mon Mar 12 16:34:48 2001
16822@@ -0,0 +1,470 @@
16823+/* $Id$
16824+ * xstat.c - xstat(2) related code for sysv emulation
16825+ *
16826+ * Copyright (C) 1991, 1992 Linus Torvalds
16827+ *
16828+ * Hacked by Eric Youngdale for iBCS (1993, 1994).
16829+ * Added to by Drew Sullivan, modified by EY for xstat (used by SVr4).
16830+ * Modified by Christoph Hellwig for Kernel 2.4
16831+ */
16832+
16833+#include <linux/config.h>
16834+#include <linux/module.h>
16835+
16836+#include <asm/uaccess.h>
16837+
16838+#include <linux/kernel.h>
16839+#include <linux/fs.h>
16840+#include <linux/errno.h>
16841+#include <linux/mm.h>
16842+#include <linux/sched.h>
16843+#include <linux/sys.h>
16844+#include <linux/file.h>
16845+
16846+#include <abi/abi.h>
16847+#include <abi/abi4.h>
16848+#include <abi/trace.h>
16849+#include <abi/lfs.h>
16850+
16851+/*
16852+ * The xstat interface is used by SVr4, and is effectively an extension
16853+ * to stat. The general idea is that stat has some limitations (chiefly
16854+ * 16 bit inode numbers), and the solution in SVr4 was to add an entirely
16855+ * new syscall. The /usr/include/sys/stat.h header file defines stat as xstat
16856+ * so that the new interface is used. The one advantage of xstat is that
16857+ * we pass a version number so that it is possible to tell exactly what
16858+ * the application is expecting, and it is easy to do the right thing.
16859+ * There is usually an inline wrapper function in /usr/include/sys/stat.h
16860+ * to perform this conversion.
16861+ */
16862+
16863+#define R3_MKNOD_VERSION 1 /* SVr3 */
16864+#define R4_MKNOD_VERSION 2 /* SVr4 */
16865+#define R3_STAT_VERSION 1 /* SVr3 */
16866+#define R4_STAT_VERSION 2 /* SVr4 */
16867+#define UW7_XSTAT64_VERSION 4 /* UW7 xstat64 */
16868+#define SCO_STAT_VERSION 51 /* SCO OS5 */
16869+
16870+/* Various functions to provide compatibility between the linux
16871+ syscalls and the ABI ABI compliant calls */
16872+
16873+/* Convert a linux dev number into the SVr4 equivalent. */
16874+#define R4_DEV(DEV) ((DEV & 0xff) | ((DEV & 0xff00) << 10))
16875+
16876+
16877+struct sco_xstat {
16878+ short st_dev;
16879+ long __pad1[3];
16880+ unsigned long st_ino;
16881+ unsigned short st_mode;
16882+ short st_nlink;
16883+ unsigned short st_uid;
16884+ unsigned short st_gid;
16885+ short st_rdev;
16886+ long __pad2[2];
16887+ long st_size;
16888+ long __pad3;
16889+ long st_atime;
16890+ long st_mtime;
16891+ long st_ctime;
16892+ long st_blksize;
16893+ long st_blocks;
16894+ char st_fstype[16];
16895+ long __pad4[7];
16896+ long st_sco_flags;
16897+};
16898+
16899+
16900+
16901+/*
16902+ * st_blocks and st_blksize are approximated with a simple algorithm if
16903+ * they aren't supported directly by the filesystem. The minix and msdos
16904+ * filesystems don't keep track of blocks, so they would either have to
16905+ * be counted explicitly (by delving into the file itself), or by using
16906+ * this simple algorithm to get a reasonable (although not 100% accurate)
16907+ * value.
16908+ *
16909+ * Use minix fs values for the number of direct and indirect blocks. The
16910+ * count is now exact for the minix fs except that it counts zero blocks.
16911+ * Everything is in BLOCK_SIZE'd units until the assignment to
16912+ * tmp.st_blksize.
16913+ */
16914+static void
16915+set_blocks(struct inode *inode, long *st_blksize, long *st_blocks)
16916+{
16917+ long blocks, indirect;
16918+
16919+#define D_B 7
16920+#define I_B (BLOCK_SIZE / sizeof(unsigned short))
16921+
16922+ if (!inode->i_blksize) {
16923+ blocks = (inode->i_size + BLOCK_SIZE - 1) / BLOCK_SIZE;
16924+ if (blocks > D_B) {
16925+ indirect = (blocks - D_B + I_B - 1) / I_B;
16926+ blocks += indirect;
16927+ if (indirect > 1) {
16928+ indirect = (indirect - 1 + I_B - 1) / I_B;
16929+ blocks += indirect;
16930+ if (indirect > 1)
16931+ blocks++;
16932+ }
16933+ }
16934+ *st_blocks = (BLOCK_SIZE / 512) * blocks;
16935+ *st_blksize = BLOCK_SIZE;
16936+ } else {
16937+ *st_blocks = inode->i_blocks;
16938+ *st_blksize = inode->i_blksize;
16939+ }
16940+}
16941+
16942+
16943+static int
16944+cp_sco_xstat(struct inode * inode, struct sco_xstat * statbuf)
16945+{
16946+ struct sco_xstat tmp = {0, };
16947+
16948+ /*
16949+ * If we thought we were in a short inode environment we are
16950+ * probably already too late - getdents() will have likely
16951+ * already assumed short inodes and "fixed" anything with
16952+ * a zero low word (because it must match stat() which must
16953+ * match read() on a directory). We will just have to go
16954+ * along with it.
16955+ */
16956+ if ((current->personality & SHORT_INODE)
16957+ && !((unsigned long)tmp.st_ino & 0xffff))
16958+ tmp.st_ino = 0xfffffffe;
16959+ else
16960+ tmp.st_ino = inode->i_ino;
16961+ tmp.st_dev = inode->i_dev;
16962+ tmp.st_mode = inode->i_mode;
16963+ tmp.st_nlink = inode->i_nlink;
16964+ tmp.st_uid = inode->i_uid;
16965+ tmp.st_gid = inode->i_gid;
16966+ tmp.st_rdev = inode->i_rdev;
16967+ tmp.st_size = inode->i_size;
16968+ tmp.st_atime = inode->i_atime;
16969+ tmp.st_mtime = inode->i_mtime;
16970+ tmp.st_ctime = inode->i_ctime;
16971+ set_blocks(inode, &tmp.st_blksize, &tmp.st_blocks);
16972+ strcpy(tmp.st_fstype, "ext2");
16973+ tmp.st_sco_flags = 0; /* 1 if remote */
16974+ return copy_to_user(statbuf, &tmp, sizeof(tmp)) ? -EFAULT : 0;
16975+}
16976+
16977+
16978+static int
16979+cp_svr4_xstat(struct inode * inode, struct svr4_xstat * statbuf)
16980+{
16981+ struct svr4_xstat tmp = {0, };
16982+
16983+ tmp.st_dev = R4_DEV(inode->i_dev);
16984+ tmp.st_ino = inode->i_ino;
16985+ tmp.st_mode = inode->i_mode;
16986+ tmp.st_nlink = inode->i_nlink;
16987+ tmp.st_uid = inode->i_uid;
16988+ tmp.st_gid = inode->i_gid;
16989+ tmp.st_rdev = R4_DEV(inode->i_rdev);
16990+ tmp.st_size = inode->i_size;
16991+ tmp.st_atim.tv_sec = inode->i_atime;
16992+ tmp.st_mtim.tv_sec = inode->i_mtime;
16993+ tmp.st_ctim.tv_sec = inode->i_ctime;
16994+ set_blocks(inode, &tmp.st_blksize, &tmp.st_blocks);
16995+ strcpy(tmp.st_fstype, "ext2");
16996+ return copy_to_user(statbuf, &tmp, sizeof(tmp)) ? -EFAULT : 0;
16997+}
16998+
16999+static int
17000+cp_uw7_stat64(struct inode * inode, struct uw7_stat64 * statbuf)
17001+{
17002+ struct uw7_stat64 tmp = {0, };
17003+
17004+ tmp.st_dev = inode->i_dev;
17005+ tmp.st_ino = (unsigned long long)inode->i_ino;
17006+ tmp.st_mode = (unsigned long)inode->i_mode;
17007+ tmp.st_nlink = inode->i_nlink;
17008+ tmp.st_uid = inode->i_uid;
17009+ tmp.st_gid = inode->i_gid;
17010+ tmp.st_rdev = inode->i_rdev; /* XXX check this! */
17011+ tmp.st_size = (long long)inode->i_size;
17012+ tmp.st_atime.tv_sec = inode->i_atime;
17013+ tmp.st_atime.tv_usec = 0L;
17014+ tmp.st_mtime.tv_sec = inode->i_mtime;
17015+ tmp.st_mtime.tv_usec = 0L;
17016+ tmp.st_ctime.tv_sec = inode->i_ctime;
17017+ tmp.st_ctime.tv_usec = 0L;
17018+ set_blocks(inode, &tmp.st_blksize, (long *)&tmp.st_blocks);
17019+ strcpy(tmp.st_fstype, "ext2");
17020+ tmp.st_aclcnt = 0;
17021+ tmp.st_level = 0;
17022+ tmp.st_flags = 0;
17023+ tmp.st_cmwlevel = 0;
17024+
17025+ return copy_to_user(statbuf, &tmp, sizeof(tmp)) ? -EFAULT : 0;
17026+}
17027+
17028+int svr4_xstat(int vers, char * filename, void * buf)
17029+{
17030+ struct nameidata nd;
17031+ int error;
17032+
17033+ if (vers == R3_STAT_VERSION)
17034+ return abi_stat(filename, (struct ibcs_stat *)buf);
17035+
17036+ error = user_path_walk(filename, &nd);
17037+ if (error)
17038+ return error;
17039+
17040+ error = do_revalidate(nd.dentry);
17041+ if (!error)
17042+ switch (vers) {
17043+ case R4_STAT_VERSION:
17044+ error = cp_svr4_xstat(nd.dentry->d_inode, buf);
17045+ break;
17046+
17047+ case SCO_STAT_VERSION:
17048+ error = cp_sco_xstat(nd.dentry->d_inode, buf);
17049+ break;
17050+
17051+ case UW7_XSTAT64_VERSION:
17052+ error = cp_uw7_stat64(nd.dentry->d_inode, buf);
17053+ break;
17054+
17055+ default:
17056+ error = -EINVAL;
17057+ abi_trace(ABI_TRACE_API,
17058+ "xstat version %d not supported",
17059+ vers);
17060+ break;
17061+ }
17062+
17063+ path_release(&nd);
17064+ return error;
17065+}
17066+
17067+EXPORT_SYMBOL(svr4_xstat);
17068+
17069+int svr4_lxstat(int vers, char * filename, void * buf)
17070+{
17071+ struct nameidata nd;
17072+ int error;
17073+
17074+ if (vers == R3_STAT_VERSION)
17075+ return abi_lstat(filename, (struct ibcs_stat *)buf);
17076+
17077+ error = user_path_walk_link(filename, &nd);
17078+ if (error)
17079+ return error;
17080+
17081+ error = do_revalidate(nd.dentry);
17082+ if (!error)
17083+ switch (vers) {
17084+ case R4_STAT_VERSION:
17085+ error = cp_svr4_xstat(nd.dentry->d_inode, buf);
17086+ break;
17087+
17088+ case SCO_STAT_VERSION:
17089+ error = cp_sco_xstat(nd.dentry->d_inode, buf);
17090+ break;
17091+
17092+ case UW7_XSTAT64_VERSION:
17093+ error = cp_uw7_stat64(nd.dentry->d_inode, buf);
17094+ break;
17095+
17096+ default:
17097+ error = -EINVAL;
17098+ abi_trace(ABI_TRACE_API,
17099+ "xstat version %d not supported",
17100+ vers);
17101+ break;
17102+ }
17103+
17104+ path_release(&nd);
17105+ return error;
17106+}
17107+
17108+EXPORT_SYMBOL(svr4_lxstat);
17109+
17110+int svr4_fxstat(int vers, int fd, void *buf)
17111+{
17112+ struct file * f;
17113+ int error = -EBADF;
17114+
17115+ if (vers == R3_STAT_VERSION)
17116+ return abi_fstat(fd, (struct ibcs_stat *)buf);
17117+
17118+ f = fget(fd);
17119+ if (f) {
17120+ struct dentry * dentry = f->f_dentry;
17121+
17122+ error = do_revalidate(dentry);
17123+ if (!error)
17124+ switch(vers) {
17125+ case R4_STAT_VERSION:
17126+ error = cp_svr4_xstat(dentry->d_inode, buf);
17127+ break;
17128+
17129+ case SCO_STAT_VERSION:
17130+ error = cp_sco_xstat(dentry->d_inode, buf);
17131+ break;
17132+
17133+ case UW7_XSTAT64_VERSION:
17134+ error = cp_uw7_stat64(dentry->d_inode, buf);
17135+ break;
17136+
17137+ default:
17138+ abi_trace(ABI_TRACE_API,
17139+ "fxstat version %d not supported", vers);
17140+ error = -EINVAL;
17141+ }
17142+
17143+ fput(f);
17144+ }
17145+ return error;
17146+}
17147+
17148+EXPORT_SYMBOL(svr4_fxstat);
17149+
17150+int svr4_xmknod(int vers, const char * path, mode_t mode, dev_t dev)
17151+{
17152+ unsigned int major, minor;
17153+
17154+ switch(vers) {
17155+ case R3_MKNOD_VERSION:
17156+ return abi_mknod(path, mode, dev);
17157+
17158+ case R4_MKNOD_VERSION:
17159+ minor = dev & 0x3ffff;
17160+ major = dev >> 18;
17161+ if (minor > 0xff || major > 0xff)
17162+ return -EINVAL;
17163+ return abi_mknod(path, mode, ((major << 8) | minor));
17164+ }
17165+
17166+ abi_trace(ABI_TRACE_API,
17167+ "xmknod version %d not supported", vers);
17168+ return -EINVAL;
17169+}
17170+
17171+EXPORT_SYMBOL(svr4_xmknod);
17172+
17173+/*
17174+ * The following code implements the statvfs function used by SVr4.
17175+ */
17176+
17177+static int
17178+cp_abi_statvfs(struct dentry *dentry,
17179+ struct statfs *src, struct abi_statvfs *statbuf)
17180+{
17181+ struct inode *inode = dentry->d_inode;
17182+ struct abi_statvfs tmp = {0, };
17183+
17184+ tmp.f_blocks = src->f_blocks;
17185+
17186+ tmp.f_bsize = src->f_bsize;
17187+ tmp.f_frsize = 0;
17188+ tmp.f_blocks = src->f_blocks;;
17189+ tmp.f_bfree = src->f_bfree;
17190+ tmp.f_bavail = src->f_bavail;
17191+ tmp.f_files = src->f_files;
17192+ tmp.f_free = src->f_ffree;
17193+ tmp.f_sid = inode->i_sb->s_dev;
17194+
17195+ /* Get the name of the filesystem */
17196+ strcpy(tmp.f_basetype, inode->i_sb->s_type->name);
17197+
17198+ tmp.f_flag = 0;
17199+ if (IS_RDONLY(inode)) tmp.f_flag |= 1;
17200+ if (IS_NOSUID(inode)) tmp.f_flag |= 2;
17201+
17202+ tmp.f_namemax = src->f_namelen;
17203+
17204+ return copy_to_user(statbuf, &tmp, sizeof(tmp)) ? -EFAULT : 0;
17205+}
17206+
17207+
17208+static int
17209+cp_sco_statvfs(struct dentry *dentry,
17210+ struct statfs *src, struct sco_statvfs *statbuf)
17211+{
17212+ struct inode *inode = dentry->d_inode;
17213+ struct sco_statvfs tmp = {0, };
17214+
17215+ tmp.f_blocks = src->f_blocks;
17216+
17217+ tmp.f_bsize = src->f_bsize;
17218+ tmp.f_frsize = src->f_bsize;
17219+ tmp.f_blocks = src->f_blocks;;
17220+ tmp.f_bfree = src->f_bfree;
17221+ tmp.f_bavail = src->f_bavail;
17222+ tmp.f_files = src->f_files;
17223+ tmp.f_free = src->f_ffree;
17224+ tmp.f_favail = src->f_ffree; /* SCO addition in the middle! */
17225+ tmp.f_sid = inode->i_sb->s_dev;
17226+
17227+ /* Get the name of the filesystem. Sadly, some code
17228+ * "in the wild" actually checks the name against a
17229+ * hard coded list to see if it is a "real" fs or not.
17230+ * I believe Informix Dynamic Server for SCO is one such.
17231+ * More lies...
17232+ */
17233+ if (personality(PER_SCOSVR3)
17234+ && !strncmp(inode->i_sb->s_type->name, "ext2", 4)) {
17235+ strcpy(tmp.f_basetype, "HTFS");
17236+ } else {
17237+ strcpy(tmp.f_basetype, inode->i_sb->s_type->name);
17238+ }
17239+
17240+ tmp.f_flag = 0;
17241+ if (IS_RDONLY(inode)) tmp.f_flag |= 1;
17242+ if (IS_NOSUID(inode)) tmp.f_flag |= 2;
17243+
17244+ tmp.f_namemax = src->f_namelen;
17245+
17246+ return copy_to_user(statbuf, &tmp, sizeof(tmp)) ? -EFAULT : 0;
17247+}
17248+
17249+int abi_statvfs(char * filename, void * stat)
17250+{
17251+ struct nameidata nd;
17252+ int error;
17253+
17254+ error = user_path_walk(filename, &nd);
17255+ if (!error) {
17256+ struct statfs tmp;
17257+ error = vfs_statfs(nd.dentry->d_inode->i_sb, &tmp);
17258+ if (!error) {
17259+ if (personality(PER_SCOSVR3))
17260+ error = cp_sco_statvfs(nd.dentry, &tmp, stat);
17261+ else
17262+ error = cp_abi_statvfs(nd.dentry, &tmp, stat);
17263+ }
17264+ path_release(&nd);
17265+ }
17266+ return error;
17267+}
17268+
17269+EXPORT_SYMBOL(abi_statvfs);
17270+
17271+
17272+int abi_fstatvfs(int fd, void *stat)
17273+{
17274+ struct file * file;
17275+ struct statfs tmp;
17276+ int error;
17277+
17278+ error = -EBADF;
17279+ file = fget(fd);
17280+ if (!file)
17281+ goto out;
17282+ error = vfs_statfs(file->f_dentry->d_inode->i_sb, &tmp);
17283+ if (!error) {
17284+ if (personality(PER_SCOSVR3))
17285+ error = cp_sco_statvfs(file->f_dentry, &tmp, stat);
17286+ else
17287+ error = cp_abi_statvfs(file->f_dentry, &tmp, stat);
17288+ }
17289+ fput(file);
17290+out:
17291+ return error;
17292+}
17293diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/uw7/Makefile linux/abi/uw7/Makefile
17294--- linux-2.4.3/abi/uw7/Makefile Thu Jan 1 01:00:00 1970
17295+++ linux/abi/uw7/Makefile Fri Mar 30 18:25:34 2001
17296@@ -0,0 +1,17 @@
17297+#
17298+# Makefile for the kernel ABI code for UnixWare 7.x emulation
17299+#
17300+
17301+O_TARGET := dummy.o
17302+
17303+list-multi := abi-uw7.o
17304+abi-uw7-objs := funcs.o kernel.o ioctl.o context.o mac.o access.o \
17305+ statvfs.o mmap.o
17306+
17307+obj-$(CONFIG_ABI_UW7) += abi-uw7.o
17308+
17309+
17310+include $(TOPDIR)/Rules.make
17311+
17312+abi-uw7.o: $(abi-uw7-objs)
17313+ $(LD) -r -o $@ $(abi-uw7-objs)
17314diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/uw7/access.c linux/abi/uw7/access.c
17315--- linux-2.4.3/abi/uw7/access.c Thu Jan 1 01:00:00 1970
17316+++ linux/abi/uw7/access.c Sun Mar 18 17:35:58 2001
17317@@ -0,0 +1,72 @@
17318+/*
17319+ * abi/uw7/access.c - support for UnixWare access(2) system call.
17320+ *
17321+ * We handle the non-POSIX EFF_ONLY_OK/EX_OK flags.
17322+ * This software is under GPL.
17323+ */
17324+
17325+#include <linux/errno.h>
17326+#include <linux/sched.h>
17327+#include <asm/uaccess.h>
17328+
17329+#include <abi/abi.h>
17330+#include <abi/uw7.h>
17331+
17332+#undef DEBUG
17333+
17334+#ifdef DEBUG
17335+#define DBG(x...) printk(x)
17336+#else
17337+#define DBG(x...)
17338+#endif
17339+
17340+#define UW7_R_OK 004
17341+#define UW7_W_OK 002
17342+#define UW7_X_OK 001
17343+#define UW7_F_OK 000
17344+#define UW7_EFF_ONLY_OK 010
17345+#define UW7_EX_OK 020
17346+
17347+#define UW7_MODE_MSK (UW7_R_OK|UW7_W_OK|UW7_X_OK|UW7_F_OK|UW7_EFF_ONLY_OK|UW7_EX_OK)
17348+
17349+int uw7_access(char * filename, int mode)
17350+{
17351+ struct nameidata nd;
17352+ int error;
17353+
17354+ DBG(KERN_ERR "UW7[%d]: access(%p,%o)\n", current->pid, filename, mode);
17355+
17356+ if (mode & ~UW7_MODE_MSK)
17357+ return -EINVAL;
17358+
17359+ if (mode & UW7_EX_OK) {
17360+ error = user_path_walk(filename, &nd);
17361+ if (!error) {
17362+ error = do_revalidate(nd.dentry);
17363+ if (error) {
17364+ path_release(&nd);
17365+ return -EIO;
17366+ }
17367+ if (!S_ISREG(nd.dentry->d_inode->i_mode)) {
17368+ path_release(&nd);
17369+ return -EACCES;
17370+ }
17371+ path_release(&nd);
17372+ }
17373+ mode &= ~UW7_EX_OK;
17374+ mode |= UW7_X_OK;
17375+ }
17376+ if (mode & UW7_EFF_ONLY_OK) {
17377+ uid_t old_uid = current->uid, old_gid = current->gid;
17378+
17379+ current->uid = current->euid;
17380+ current->gid = current->egid;
17381+ mode &= ~UW7_EFF_ONLY_OK;
17382+ error = SYS(access)(filename, mode);
17383+ current->uid = old_uid;
17384+ current->gid = old_gid;
17385+ } else
17386+ error = SYS(access)(filename, mode);
17387+
17388+ return error;
17389+}
17390diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/uw7/context.c linux/abi/uw7/context.c
17391--- linux-2.4.3/abi/uw7/context.c Thu Jan 1 01:00:00 1970
17392+++ linux/abi/uw7/context.c Mon Mar 12 16:34:48 2001
17393@@ -0,0 +1,96 @@
17394+/*
17395+ * abi/uw7/context.c
17396+ *
17397+ * This software is under GPL
17398+ */
17399+
17400+
17401+#include <linux/ptrace.h>
17402+#include <linux/errno.h>
17403+
17404+#include <asm/uaccess.h>
17405+
17406+#include <abi/abi.h>
17407+#include <abi/uw7.h>
17408+#include <abi/uw7_context.h>
17409+
17410+int
17411+uw7_sigaltstack(const uw7_stack_t *uw7_ss, uw7_stack_t *uw7_oss)
17412+{
17413+ stack_t ss, oss, *ssp = NULL, *ossp = NULL;
17414+ int error;
17415+ mm_segment_t old_fs;
17416+
17417+ if (uw7_ss) {
17418+ error = verify_area(VERIFY_READ, uw7_ss, sizeof(uw7_stack_t));
17419+ if (error)
17420+ return error;
17421+ __get_user(ss.ss_sp, &uw7_ss->ss_sp);
17422+ __get_user(ss.ss_size, &uw7_ss->ss_size);
17423+ __get_user(ss.ss_flags, &uw7_ss->ss_flags);
17424+ ssp = &ss;
17425+ }
17426+
17427+ if (uw7_oss) {
17428+ error = verify_area(VERIFY_WRITE, uw7_oss, sizeof(uw7_stack_t));
17429+ if (error)
17430+ return error;
17431+ __get_user(oss.ss_sp, &uw7_oss->ss_sp);
17432+ __get_user(oss.ss_size, &uw7_oss->ss_size);
17433+ __get_user(oss.ss_flags, &uw7_oss->ss_flags);
17434+ ossp = &oss;
17435+ }
17436+
17437+ old_fs = get_fs();
17438+ set_fs(get_ds());
17439+ error = SYS(sigaltstack)(ssp, ossp);
17440+ set_fs(old_fs);
17441+
17442+ if (ossp) {
17443+ __put_user(ossp->ss_sp, &uw7_oss->ss_sp);
17444+ __put_user(ossp->ss_size, &uw7_oss->ss_size);
17445+ __put_user(ossp->ss_flags, &uw7_oss->ss_flags);
17446+ }
17447+ return error;
17448+}
17449+
17450+static int
17451+getcontext(uw7_context_t * uc, struct pt_regs * regs)
17452+{
17453+ uw7_context_t tmp = { 0 };
17454+
17455+ return copy_to_user(uc, &tmp, sizeof(uw7_context_t)) ? -EFAULT : 0;
17456+}
17457+
17458+static int
17459+getxcontext(uw7_context_t * uc, struct pt_regs * regs)
17460+{
17461+ return 0;
17462+}
17463+
17464+static int
17465+setcontext(uw7_context_t * uc, struct pt_regs * regs)
17466+{
17467+ if (!uc) /* SVR4 says setcontext(NULL) => exit(0) */
17468+ SYS(exit)(0);
17469+ return 0;
17470+}
17471+
17472+int
17473+uw7_context(struct pt_regs * regs)
17474+{
17475+ int fcn = get_syscall_parameter(regs, 0);
17476+ uw7_context_t * uc = (uw7_context_t *) get_syscall_parameter(regs, 1);
17477+
17478+ switch (fcn) {
17479+ case UW7_GETCONTEXT:
17480+ return getcontext(uc, regs);
17481+
17482+ case UW7_GETXCONTEXT:
17483+ return getxcontext(uc, regs);
17484+
17485+ case UW7_SETCONTEXT:
17486+ return setcontext(uc, regs);
17487+ }
17488+ return -EINVAL;
17489+}
17490diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/uw7/funcs.c linux/abi/uw7/funcs.c
17491--- linux-2.4.3/abi/uw7/funcs.c Thu Jan 1 01:00:00 1970
17492+++ linux/abi/uw7/funcs.c Fri Mar 30 18:28:41 2001
17493@@ -0,0 +1,315 @@
17494+/*
17495+ * abi/uw7/funcs.c - UnixWare 7.x system call dispatch table.
17496+ *
17497+ * This software is under GPL
17498+ */
17499+
17500+#include <linux/module.h>
17501+#include <linux/init.h>
17502+#include <linux/kernel.h>
17503+
17504+#include <abi/abi.h>
17505+#include <abi/abi4.h>
17506+#include <abi/svr4.h>
17507+#include <abi/uw7.h>
17508+#include <abi/uw7_context.h>
17509+
17510+
17511+MODULE_DESCRIPTION("SCO UnixWare 7.x emulator");
17512+
17513+
17514+extern void iBCS_class_XNX(struct pt_regs *regs);
17515+
17516+ABI_func uw7_funcs[] = {
17517+ { abi_syscall, Fast ITR(0, "syscall", "") }, /* 0 */
17518+ { SC(exit), -1 ITR(0, "exit", "d") }, /* 1 */
17519+ { abi_fork, Spl ITR(0, "fork", "") }, /* 2 */
17520+ { abi_read, 3 ITR(0, "read", "dpd") }, /* 3 */
17521+ { SC(write), -3 ITR(0, "write", "dpd") }, /* 4 */
17522+ { svr4_open, 3 ITR(0, "open", "soo") }, /* 5 */
17523+ { SC(close), -1 ITR(0, "close", "d") }, /* 6 */
17524+ { abi_wait, Spl ITR(0, "wait", "xxx") }, /* 7 */
17525+ { SC(creat), -2 ITR(0, "creat", "so") }, /* 8 */
17526+ { SC(link), -2 ITR(0, "link", "ss") }, /* 9 */
17527+ { SC(unlink), -1 ITR(0, "unlink", "s") }, /* 10 */
17528+ { abi_exec, Spl ITR(0, "exec", "sxx") }, /* 11 */
17529+ { SC(chdir), -1 ITR(0, "chdir", "s") }, /* 12 */
17530+ { abi_time, 0 ITR(0, "time", "") }, /* 13 */
17531+ { abi_mknod, 3 ITR(0, "mknod", "soo") }, /* 14 */
17532+ { SC(chmod), -2 ITR(0, "chmod", "so") }, /* 15 */
17533+ { SC(chown), -3 ITR(0, "chown", "sdd") }, /* 16 */
17534+ { abi_brk, 1 ITR(0, "brk/break", "x") }, /* 17 */
17535+ { abi_stat, 2 ITR(0, "stat", "sp") }, /* 18 */
17536+ { abi_lseek, 3 ITR(0, "seek/lseek", "ddd") }, /* 19 */
17537+ { abi_getpid, Spl ITR(0, "getpid", "") }, /* 20 */
17538+ { 0, Ukn ITR(1, "mount", "") }, /* 21 */
17539+ { SC(umount), -1 ITR(0, "umount", "s") }, /* 22 */
17540+ { SC(setuid), -1 ITR(0, "setuid", "d") }, /* 23 */
17541+ { abi_getuid, Spl ITR(0, "getuid", "") }, /* 24 */
17542+ { SC(stime), -1 ITR(0, "stime", "d") }, /* 25 */
17543+ { svr4_ptrace, 4 ITR(0, "ptrace", "xdxx") }, /* 26 */
17544+ { SC(alarm), -1 ITR(0, "alarm", "d") }, /* 27 */
17545+ { abi_fstat, 2 ITR(0, "fstat", "dp") }, /* 28 */
17546+ { SC(pause), -ZERO ITR(0, "pause", "") }, /* 29 */
17547+ { SC(utime), -2 ITR(0, "utime", "xx") }, /* 30 */
17548+ { uw7_stty, 2 ITR(0, "stty", "dd") }, /* 31 */
17549+ { uw7_gtty, 2 ITR(1, "gtty", "dd") }, /* 32 */
17550+ { uw7_access, 2 ITR(0, "access", "so") }, /* 33 */
17551+ { SC(nice), -1 ITR(0, "nice", "d") }, /* 34 */
17552+ { svr4_statfs, 4 ITR(0, "statfs", "spdd") }, /* 35 */
17553+ { SC(sync), -ZERO ITR(0, "sync", "") }, /* 36 */
17554+ { abi_kill, 2 ITR(0, "kill", "dd") }, /* 37 */
17555+ { svr4_fstatfs, 4 ITR(0, "fstatfs", "dpdd") }, /* 38 */
17556+ { abi_procids, Spl ITR(0, "ibcs_procids", "d") }, /* 39 */
17557+ { iBCS_class_XNX, Fast ITR(0, "sysext", "") }, /* 40 */
17558+ { SC(dup), -1 ITR(0, "dup", "d") }, /* 41 */
17559+ { abi_pipe, Spl ITR(0, "pipe", "") }, /* 42 */
17560+ { SC(times), -1 ITR(0, "times", "p") }, /* 43 */
17561+ { SC(profil), -4 ITR(0, "prof", "xxxx")}, /* 44 */
17562+ { 0, Ukn ITR(1, "lock/plock", "") }, /* 45 */
17563+ { SC(setgid), -1 ITR(0, "setgid", "d") }, /* 46 */
17564+ { abi_getgid, Spl ITR(0, "getgid", "") }, /* 47 */
17565+ { abi_sigfunc, Fast ITR(0, "sigfunc", "xxx") }, /* 48 */
17566+ { svr4_msgsys, Spl ITR(0, "msgsys", "dxddd")}, /* 49 */
17567+ { svr4_sysi86, Spl ITR(0, "sysi86/sys3b", "d") }, /* 50 */
17568+ { SC(acct), -1 ITR(0, "acct/sysacct", "x") }, /* 51 */
17569+ { svr4_shmsys, Fast ITR(0, "shmsys", "ddxo")}, /* 52 */
17570+ { svr4_semsys, Spl ITR(0, "semsys", "dddx")}, /* 53 */
17571+ { uw7_ioctl, Spl ITR(0, "ioctl", "dxx") }, /* 54 */
17572+ { 0, 3 ITR(0, "uadmin", "xxx") }, /* 55 */
17573+ { 0, Ukn ITR(1, "exch", "") }, /* 56 */
17574+ { v7_utsname, 1 ITR(0, "utsys", "x") }, /* 57 */
17575+ { SC(fsync), -1 ITR(0, "fsync", "d") }, /* 58 */
17576+ { abi_exec, Spl ITR(0, "execv", "spp") }, /* 59 */
17577+ { SC(umask), -1 ITR(0, "umask", "o") }, /* 60 */
17578+ { SC(chroot), -1 ITR(0, "chroot", "s") }, /* 61 */
17579+ { svr4_fcntl, Spl ITR(0, "fcntl", "dxx") }, /* 62 */
17580+ { svr4_ulimit, 2 ITR(0, "ulimit", "xx") }, /* 63 */
17581+ { 0, Ukn ITR(1, "cg_ids", "") }, /* 64 */
17582+ { 0, Ukn ITR(1, "cg_processors", "") }, /* 65 */
17583+ { 0, Ukn ITR(1, "cg_info", "") }, /* 66 */
17584+ { 0, Ukn ITR(1, "cg_bind", "") }, /* 67 */
17585+ { 0, Ukn ITR(1, "cg_current", "") }, /* 68 */
17586+ { 0, Ukn ITR(1, "cg_memloc", "") }, /* 69 */
17587+ { 0, Ukn ITR(1, "advfs", "") }, /* 70 */
17588+ { 0, Ukn ITR(1, "unadvfs", "") }, /* 71 */
17589+ { 0, Ukn ITR(1, "rmount", "") }, /* 72 */
17590+ { 0, Ukn ITR(1, "rumount", "") }, /* 73 */
17591+ { 0, Ukn ITR(1, "rfstart", "") }, /* 74 */
17592+ { 0, Ukn ITR(1, "unused 75", "") }, /* 75 */
17593+ { 0, Ukn ITR(1, "rdebug", "") }, /* 76 */
17594+ { 0, Ukn ITR(1, "rfstop", "") }, /* 77 */
17595+ { 0, Ukn ITR(1, "rfsys", "") }, /* 78 */
17596+ { SC(rmdir), -1 ITR(0, "rmdir", "s") }, /* 79 */
17597+ { SC(mkdir), 2 ITR(0, "mkdir", "so") }, /* 80 */
17598+ { svr4_getdents, 3 ITR(0, "getdents", "dxd") }, /* 81 */
17599+ { 0, Ukn ITR(1, "libattach", "") }, /* 82 */
17600+ { 0, Ukn ITR(1, "libdetach", "") }, /* 83 */
17601+ { svr4_sysfs, 3 ITR(0, "sysfs", "dxx") }, /* 84 */
17602+ { svr4_getmsg, Spl ITR(0, "getmsg", "dxxx") }, /* 85 */
17603+ { svr4_putmsg, Spl ITR(0, "putmsg", "dxxd") }, /* 86 */
17604+ { svr4_poll, 3 ITR(0, "poll", "xdd") }, /* 87 */
17605+ { abi_lstat, 2 ITR(0, "lstat", "sp") }, /* 88 */
17606+ { SC(symlink), -2 ITR(0, "symlink", "ss") }, /* 89 */
17607+ { SC(readlink), -3 ITR(0, "readlink", "spd") }, /* 90 */
17608+ { 0, Ukn ITR(0, "svr4_setgroups","dp") }, /* 91 */
17609+ { 0, Ukn ITR(0, "svr4_getgroups","dp") }, /* 92 */
17610+ { SC(fchmod), -2 ITR(0, "fchmod", "do") }, /* 93 */
17611+ { SC(fchown), -3 ITR(0, "fchown", "ddd") }, /* 94 */
17612+ { abi_sigprocmask, 3 ITR(0, "sigprocmask", "dxx") }, /* 95 */
17613+ { abi_sigsuspend, Spl ITR(0, "sigsuspend", "x") }, /* 96 */
17614+ { uw7_sigaltstack, 2 ITR(1, "sigaltstack", "xx") }, /* 97 */
17615+ { abi_sigaction, 3 ITR(0, "sigaction", "dxx") }, /* 98 */
17616+ { svr4_sigpending, 2 ITR(1, "sigpending", "dp") }, /* 99 */
17617+ { uw7_context, Spl ITR(0, "ucontext", "") }, /* 100 */
17618+ { 0, Ukn ITR(1, "evsys", "") }, /* 101 */
17619+ { 0, Ukn ITR(1, "evtrapret", "") }, /* 102 */
17620+ { abi_statvfs, 2 ITR(0, "statvfs", "sp") }, /* 103 */
17621+ { abi_statvfs, 2 ITR(0, "fstatvfs", "dp") }, /* 104 */
17622+ { 0, Ukn ITR(1, "reserved 105", "") }, /* 105 */
17623+ { 0, Ukn ITR(1, "nfssys", "") }, /* 106 */
17624+ { svr4_waitid, 4 ITR(0, "waitid", "ddxd") }, /* 107 */
17625+ { 0, 3 ITR(1, "sigsendsys", "ddd") }, /* 108 */
17626+ { svr4_hrtsys, Spl ITR(0, "hrtsys", "xxx") }, /* 109 */
17627+ { 0, 3 ITR(1, "acancel", "dxd") }, /* 110 */
17628+ { 0, Ukn ITR(1, "async", "") }, /* 111 */
17629+ { 0, Ukn ITR(1, "priocntlsys", "") }, /* 112 */
17630+ { svr4_pathconf, 2 ITR(1, "pathconf", "sd") }, /* 113 */
17631+ { 0, 3 ITR(1, "mincore", "xdx") }, /* 114 */
17632+ { uw7_mmap, 6 ITR(0, "mmap", "xxxxdx") },/* 115 */
17633+ { SC(mprotect), -3 ITR(0, "mprotect", "xdx") },/* 116 */
17634+ { SC(munmap), -2 ITR(0, "munmap", "xd") },/* 117 */
17635+ { svr4_fpathconf, 2 ITR(1, "fpathconf", "dd") }, /* 118 */
17636+ { abi_fork, Spl ITR(0, "vfork", "") }, /* 119 */
17637+ { SC(fchdir), -1 ITR(0, "fchdir", "d") }, /* 120 */
17638+ { SC(readv), -3 ITR(0, "readv", "dxd") }, /* 121 */
17639+ { SC(writev), -3 ITR(0, "writev", "dxd") }, /* 122 */
17640+ { svr4_xstat, 3 ITR(0, "xstat", "dsx") }, /* 123 */
17641+ { svr4_lxstat, 3 ITR(0, "lxstat", "dsx") }, /* 124 */
17642+ { svr4_fxstat, 3 ITR(0, "fxstat", "ddx") }, /* 125 */
17643+ { svr4_xmknod, 4 ITR(0, "xmknod", "dsox")}, /* 126 */
17644+ { svr4_syslocal, Spl ITR(0, "syslocal", "d") }, /* 127 */
17645+ { svr4_getrlimit, 2 ITR(0, "setrlimit", "dx") }, /* 128 */
17646+ { svr4_setrlimit, 2 ITR(0, "getrlimit", "dx") }, /* 129 */
17647+ { SC(lchown), 3 ITR(1, "lchown","sdd") }, /* 130 */
17648+ { 0, Ukn ITR(1, "memcntl", "") }, /* 131 */
17649+#ifdef CONFIG_ABI_XTI
17650+ { svr4_getpmsg, 5 ITR(0, "getpmsg", "dxxxx")}, /* 132 */
17651+ { svr4_putpmsg, 5 ITR(0, "putpmsg", "dxxdd")}, /* 133 */
17652+#else
17653+ { 0, 5 ITR(0, "getpmsg", "dxxxx")}, /* 132 */
17654+ { 0, 5 ITR(0, "putpmsg", "dxxdd")}, /* 133 */
17655+#endif
17656+ { SC(rename), -2 ITR(0, "rename", "ss") }, /* 134 */
17657+ { abi_utsname, 1 ITR(0, "uname", "x") }, /* 135 */
17658+ { uw7_setegid, 1 ITR(1, "setegid", "d") }, /* 136 */
17659+ { svr4_sysconfig, 1 ITR(0, "sysconfig", "d") }, /* 137 */
17660+ { 0, Ukn ITR(1, "adjtime", "") }, /* 138 */
17661+ { svr4_sysinfo, 3 ITR(0, "systeminfo", "dsd") }, /* 139 */
17662+ { socksys_syscall, 1 ITR(0, "socksys_syscall","x") }, /* 140 */
17663+ { uw7_seteuid, 1 ITR(1, "seteuid", "d") }, /* 141 */
17664+ { 0, Ukn ITR(1, "?", "") }, /* 142 */
17665+ { 0, Ukn ITR(1, "keyctl", "") }, /* 143 */
17666+ { 0, 2 ITR(1, "secsys", "dx") }, /* 144 */
17667+ { 0, 4 ITR(1, "filepriv", "sdxd") }, /* 145 */
17668+ { 0, 3 ITR(1, "procpriv", "dxd") }, /* 146 */
17669+ { 0, 3 ITR(1, "devstat", "sdx") }, /* 147 */
17670+ { 0, 5 ITR(1, "aclipc", "ddddx")}, /* 148 */
17671+ { 0, 3 ITR(1, "fdevstat", "ddx") }, /* 149 */
17672+ { 0, 3 ITR(1, "flvlfile", "ddx") }, /* 150 */
17673+ { 0, 3 ITR(1, "lvlfile", "sdx") }, /* 151 */
17674+ { 0, Ukn ITR(1, "sendv", "") }, /* 152 */
17675+ { 0, 2 ITR(1, "lvlequal", "xx") }, /* 153 */
17676+ { 0, 2 ITR(1, "lvlproc", "dx") }, /* 154 */
17677+ { 0, Ukn ITR(1, "?", "") }, /* 155 */
17678+ { 0, 4 ITR(1, "lvlipc", "dddx") }, /* 156 */
17679+ { 0, 4 ITR(1, "acl", "sddx") }, /* 157 */
17680+ { 0, Ukn ITR(1, "auditevt", "") }, /* 158 */
17681+ { 0, Ukn ITR(1, "auditctl", "") }, /* 159 */
17682+ { 0, Ukn ITR(1, "auditdmp", "") }, /* 160 */
17683+ { 0, Ukn ITR(1, "auditlog", "") }, /* 161 */
17684+ { 0, Ukn ITR(1, "auditbuf", "") }, /* 162 */
17685+ { 0, 2 ITR(1, "lvldom", "xx") }, /* 163 */
17686+ { 0, Ukn ITR(1, "lvlvfs", "") }, /* 164 */
17687+ { 0, 2 ITR(1, "mkmld", "so") }, /* 165 */
17688+ { uw7_mldmode, 1 ITR(1, "mldmode", "d") }, /* 166 */
17689+ { 0, 2 ITR(0, "secadvise", "xx") }, /* 167 */
17690+ { 0, Ukn ITR(1, "online", "") }, /* 168 */
17691+ { SC(setitimer), -3 ITR(0, "setitimer", "dxx") }, /* 169 */
17692+ { SC(getitimer), -2 ITR(0, "getitimer", "dx") }, /* 170 */
17693+ { SC(gettimeofday), -2 ITR(0, "gettimeofday", "xx") }, /* 171 */
17694+ { SC(settimeofday), -2 ITR(0, "settimeofday", "xx") }, /* 172 */
17695+ { 0, Ukn ITR(1, "lwpcreate", "") }, /* 173 */
17696+ { 0, Ukn ITR(1, "lwpexit", "") }, /* 174 */
17697+ { 0, Ukn ITR(1, "lwpwait", "") }, /* 175 */
17698+ { 0, Ukn ITR(1, "lwpself", "") }, /* 176 */
17699+ { 0, Ukn ITR(1, "lwpinfo", "") }, /* 177 */
17700+ { 0, Ukn ITR(1, "lwpprivate", "") }, /* 178 */
17701+ { 0, Ukn ITR(1, "processorbind", "") }, /* 179 */
17702+ { 0, Ukn ITR(1, "processorexbind","") }, /* 180 */
17703+ { 0, Ukn ITR(1, "", "") }, /* 181 */
17704+ { 0, Ukn ITR(1, "sync_mailbox", "") }, /* 182 */
17705+ { 0, Ukn ITR(1, "prepblock", "") }, /* 183 */
17706+ { 0, Ukn ITR(1, "block", "") }, /* 184 */
17707+ { 0, Ukn ITR(1, "rdblock", "") }, /* 185 */
17708+ { 0, Ukn ITR(1, "unblock", "") }, /* 186 */
17709+ { 0, Ukn ITR(1, "cancelblock", "") }, /* 187 */
17710+ { 0, Ukn ITR(1, "187", "") }, /* 188 */
17711+ { uw7_pread, 4 ITR(1, "pread", "dsdd") }, /* 189 */
17712+ { uw7_pwrite, 4 ITR(1, "pwrite", "dsdd") }, /* 190 */
17713+ { SC(truncate), -2 ITR(0, "truncate", "sd") }, /* 191 */
17714+ { SC(ftruncate), -2 ITR(0, "ftruncate", "dd") }, /* 192 */
17715+ { 0, Ukn ITR(1, "lwpkill", "") }, /* 193 */
17716+ { 0, Ukn ITR(1, "sigwait", "") }, /* 194 */
17717+ { abi_fork, Spl ITR(1, "fork1", "") }, /* 195 */
17718+ { abi_fork, Spl ITR(1, "forkall", "") }, /* 196 */
17719+ { 0, Ukn ITR(1, "modload", "") }, /* 197 */
17720+ { 0, Ukn ITR(1, "moduload", "") }, /* 198 */
17721+ { 0, Ukn ITR(1, "modpath", "") }, /* 199 */
17722+ { 0, Ukn ITR(1, "modstat", "") }, /* 200 */
17723+ { 0, Ukn ITR(1, "modadm", "") }, /* 201 */
17724+ { 0, Ukn ITR(1, "getksym", "") }, /* 202 */
17725+ { 0, Ukn ITR(1, "lwpsuspend", "") }, /* 203 */
17726+ { 0, Ukn ITR(1, "lwpcontinue", "") }, /* 204 */
17727+ { 0, Ukn ITR(1, "priocntllst", "") }, /* 205 */
17728+ { uw7_sleep, 1 ITR(1, "sleep", "d") }, /* 206 */
17729+ { 0, Ukn ITR(1, "lwp_sema_wait", "") }, /* 207 */
17730+ { 0, Ukn ITR(1, "lwp_sema_post", "") }, /* 208 */
17731+ { 0, Ukn ITR(1, "lwp_sema_trywait","") }, /* 209 */
17732+ { 0, Ukn ITR(1, "reserved 210","") }, /* 210 */
17733+ { 0, Ukn ITR(1, "unused 211","") }, /* 211 */
17734+ { 0, Ukn ITR(1, "unused 212","") }, /* 212 */
17735+ { 0, Ukn ITR(1, "unused 213","") }, /* 213 */
17736+ { 0, Ukn ITR(1, "unused 214","") }, /* 214 */
17737+ { 0, Ukn ITR(1, "unused 215","") }, /* 215 */
17738+ { uw7_fstatvfs64, 2 ITR(1, "fstatvfs64", "dp") }, /* 216 */
17739+ { uw7_statvfs64, 2 ITR(1, "statvfs64", "sp") }, /* 217 */
17740+ { 0, Ukn ITR(1, "ftruncate64","") }, /* 218 */
17741+ { 0, Ukn ITR(1, "truncate64","") }, /* 219 */
17742+ { 0, Ukn ITR(1, "getrlimit64","") }, /* 220 */
17743+ { 0, Ukn ITR(1, "setrlimit64","") }, /* 221 */
17744+ { uw7_lseek64, 4 ITR(1, "lseek64", "dddd") }, /* 222 */
17745+ { 0, Ukn ITR(1, "mmap64","") }, /* 223 */
17746+ { uw7_pread64, 5 ITR(1, "pread64", "dsddd")}, /* 224 */
17747+ { uw7_pwrite64, 5 ITR(1, "pwrite64", "dsddd")}, /* 225 */
17748+ { 0, Ukn ITR(1, "creat64","") }, /* 226 */
17749+ { 0, Ukn ITR(1, "dshmsys","") }, /* 227 */
17750+ { 0, Ukn ITR(1, "invlpg","") }, /* 228 */
17751+ { 0, Ukn ITR(1, "rfork1","") }, /* 229 */
17752+ { 0, Ukn ITR(1, "rforkall","") }, /* 230 */
17753+ { 0, Ukn ITR(1, "rexecve","") }, /* 231 */
17754+ { 0, Ukn ITR(1, "migrate","") }, /* 232 */
17755+ { 0, Ukn ITR(1, "kill3","") }, /* 233 */
17756+ { 0, Ukn ITR(1, "ssisys","") }, /* 234 */
17757+ { 0, Ukn ITR(1, "xaccept","") }, /* 235 */
17758+ { 0, Ukn ITR(1, "xbind","") }, /* 236 */
17759+ { 0, Ukn ITR(1, "xbindresvport","") }, /* 237 */
17760+ { 0, Ukn ITR(1, "xconnect","") }, /* 238 */
17761+ { 0, Ukn ITR(1, "xgetsockaddr","") }, /* 239 */
17762+ { 0, Ukn ITR(1, "xgetsockopt","") }, /* 240 */
17763+ { 0, Ukn ITR(1, "xlisten","") }, /* 241 */
17764+ { 0, Ukn ITR(1, "xrecvmsg","") }, /* 242 */
17765+ { 0, Ukn ITR(1, "xsendmsg","") }, /* 243 */
17766+ { 0, Ukn ITR(1, "xsetsockaddr","") }, /* 244 */
17767+ { 0, Ukn ITR(1, "xsetsockopt","") }, /* 245 */
17768+ { 0, Ukn ITR(1, "xshutdown","") }, /* 246 */
17769+ { 0, Ukn ITR(1, "xsocket","") }, /* 247 */
17770+ { 0, Ukn ITR(1, "xsocketpair","") }, /* 248 */
17771+ { 0, Ukn ITR(1, "unused 249","") }, /* 249 */
17772+ { 0, Ukn ITR(1, "unused 250","") }, /* 250 */
17773+};
17774+
17775+static void
17776+UW7_lcall7(int segment, struct pt_regs * regs)
17777+{
17778+ abi_dispatch(regs, &uw7_funcs[regs->eax & 0xff], 1);
17779+}
17780+
17781+static struct exec_domain uw7_exec_domain = {
17782+ name: "UnixWare 7",
17783+ handler: UW7_lcall7,
17784+ pers_low: 14 /* PER_UW7 */,
17785+ pers_high: 14 /* PER_UW7 */,
17786+ signal_map: ibcs_to_linux_signals,
17787+ signal_invmap: linux_to_ibcs_signals,
17788+ err_map: svr4_err_map,
17789+ socktype_map: svr4_socktype_map,
17790+ sockopt_map: abi_sockopt_map,
17791+ af_map: abi_af_map,
17792+ module: THIS_MODULE
17793+};
17794+
17795+static int __init
17796+init_uw7(void)
17797+{
17798+ return (register_exec_domain(&uw7_exec_domain));
17799+}
17800+
17801+static void __exit
17802+cleanup_uw7(void)
17803+{
17804+ unregister_exec_domain(&uw7_exec_domain);
17805+}
17806+
17807+module_init(init_uw7);
17808+module_exit(cleanup_uw7);
17809diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/uw7/ioctl.c linux/abi/uw7/ioctl.c
17810--- linux-2.4.3/abi/uw7/ioctl.c Thu Jan 1 01:00:00 1970
17811+++ linux/abi/uw7/ioctl.c Mon Mar 12 16:34:48 2001
17812@@ -0,0 +1,224 @@
17813+/*
17814+ * abi/uw7/ioctl.c - Support for UnixWare 7.x ioctl(2) system call.
17815+ *
17816+ * This module provides a function uw7_ioctl() which is called indirectly
17817+ * via uw7_funcs[] array, see abi/uw7/funcs.c.
17818+ * This software is under GPL
17819+ */
17820+
17821+#include <linux/errno.h>
17822+#include <linux/sched.h>
17823+
17824+#include <asm/uaccess.h>
17825+
17826+#include <abi/abi.h>
17827+#include <abi/uw7.h>
17828+#include <abi/uw7_termbits.h>
17829+
17830+
17831+#undef DEBUG
17832+
17833+#ifdef DEBUG
17834+#define DBG(x...) printk(x)
17835+#else
17836+#define DBG(x...)
17837+#endif
17838+
17839+
17840+static int tioc_tcgets(int fd, struct uw7_termios * tios);
17841+static int tioc_tcsets(int fd, int lnx_cmd, struct uw7_termios * tios);
17842+static int ioctl_T(int fd, unsigned int cmd, void * arg);
17843+
17844+int uw7_ioctl(struct pt_regs * regs)
17845+{
17846+ int fd;
17847+ unsigned int cmd, class;
17848+ void * arg;
17849+ char class_str[4];
17850+
17851+ fd = (int)get_syscall_parameter(regs, 0);
17852+ cmd = (unsigned int)get_syscall_parameter(regs, 1);
17853+ arg = (void *)get_syscall_parameter(regs, 2);
17854+ class = cmd >> 8;
17855+ switch (class) {
17856+ case 'T':
17857+ return ioctl_T(fd, cmd, arg);
17858+ }
17859+
17860+ class_str[0] = class & 0xFF0000 ? (char)((class >> 16) & 0xFF) : '.';
17861+ class_str[1] = class & 0x00FF00 ? (char)((class >> 8) & 0xFF) : '.';
17862+ class_str[2] = class & 0x0000FF ? (char)((class ) & 0xFF) : '.';
17863+ class_str[3] = 0;
17864+
17865+ DBG(KERN_ERR "UW7: ioctl(%d, %x[%s], 0x%lx) unsupported\n",
17866+ fd, cmd, class_str, (unsigned long)arg);
17867+
17868+ return -EINVAL;
17869+}
17870+
17871+static int tioc_tcsets(int fd, int lnx_cmd, struct uw7_termios * tios)
17872+{
17873+ struct termios t;
17874+ struct uw7_termios tmp = {0, };
17875+ mm_segment_t old_fs;
17876+ int error;
17877+
17878+ DBG(KERN_ERR "UW7[%d]: tioc_tcsets(%d,%x,%p)\n",
17879+ current->pid, fd, lnx_cmd, tios);
17880+
17881+ error = verify_area(VERIFY_READ, tios, sizeof(struct uw7_termios));
17882+ if (error)
17883+ return error;
17884+
17885+ old_fs = get_fs();
17886+ set_fs(get_ds());
17887+ error = SYS(ioctl)(fd, TCGETS, &t);
17888+ set_fs(old_fs);
17889+ if (error)
17890+ return error;
17891+
17892+ if (copy_from_user(&tmp, tios, sizeof(struct uw7_termios)))
17893+ return -EFAULT;
17894+ t.c_iflag = tmp.c_iflag & ~UW7_DOSMODE;
17895+ t.c_oflag = tmp.c_oflag;
17896+ t.c_cflag = tmp.c_cflag;
17897+ t.c_lflag = tmp.c_lflag & ~UW7_DEFECHO;
17898+ if (tmp.c_lflag & UW7_FLUSHO)
17899+ t.c_lflag |= FLUSHO;
17900+ else
17901+ t.c_lflag &= ~FLUSHO;
17902+
17903+ DBG(KERN_ERR
17904+ "UW7[%d]: iflag: %lx->%lx, oflag: %lx->%lx, cflag: %lx->%lx, lflag: %lx->%lx\n",
17905+ current->pid, tmp.c_iflag, t.c_iflag, tmp.c_oflag, t.c_oflag,
17906+ tmp.c_cflag, t.c_cflag, tmp.c_lflag, t.c_lflag);
17907+
17908+ t.c_cc[VINTR] = tmp.c_cc[UW7_VINTR];
17909+ t.c_cc[VQUIT] = tmp.c_cc[UW7_VQUIT];
17910+ t.c_cc[VERASE] = tmp.c_cc[UW7_VERASE];
17911+ t.c_cc[VKILL] = tmp.c_cc[UW7_VKILL];
17912+ t.c_cc[VEOL2] = tmp.c_cc[UW7_VEOL2];
17913+ t.c_cc[VSWTC] = tmp.c_cc[UW7_VSWTCH];
17914+ t.c_cc[VSTART] = tmp.c_cc[UW7_VSTART];
17915+ t.c_cc[VSTOP] = tmp.c_cc[UW7_VSTOP];
17916+ t.c_cc[VSUSP] = tmp.c_cc[UW7_VSUSP];
17917+ t.c_cc[VREPRINT] = tmp.c_cc[UW7_VREPRINT];
17918+ t.c_cc[VDISCARD] = tmp.c_cc[UW7_VDISCARD];
17919+ t.c_cc[VWERASE] = tmp.c_cc[UW7_VWERASE];
17920+ t.c_cc[VLNEXT] = tmp.c_cc[UW7_VLNEXT];
17921+ if (t.c_lflag & ICANON) {
17922+ t.c_cc[VEOF] = tmp.c_cc[UW7_VEOF];
17923+ t.c_cc[VEOL] = tmp.c_cc[UW7_VEOL];
17924+ } else {
17925+ t.c_cc[VMIN] = tmp.c_cc[UW7_VMIN];
17926+ t.c_cc[VTIME] = tmp.c_cc[UW7_VTIME];
17927+ t.c_cc[VEOL] = tmp.c_cc[UW7_VEOL2];
17928+ }
17929+
17930+
17931+ DBG(KERN_ERR
17932+ "UW7[%d]: "
17933+ "VINTR: %x->%x, VQUIT: %x->%x, VERASE: %x->%x, VKILL: %x->%x\n"
17934+ "VEOL2: %x->%x\n",
17935+ current->pid, tmp.c_cc[UW7_VINTR], t.c_cc[VINTR],
17936+ tmp.c_cc[UW7_VQUIT], t.c_cc[VQUIT],
17937+ tmp.c_cc[UW7_VERASE], t.c_cc[VERASE],
17938+ tmp.c_cc[UW7_VKILL], t.c_cc[VKILL],
17939+ tmp.c_cc[UW7_VEOL2], t.c_cc[VEOL2]);
17940+
17941+ old_fs = get_fs();
17942+ set_fs(get_ds());
17943+ error = SYS(ioctl)(fd, lnx_cmd, &t);
17944+ set_fs(old_fs);
17945+ return error;
17946+}
17947+
17948+static int tioc_tcgets(int fd, struct uw7_termios * tios)
17949+{
17950+ struct termios t;
17951+ struct uw7_termios tmp = { 0 };
17952+ mm_segment_t old_fs;
17953+ int error;
17954+
17955+ DBG(KERN_ERR "UW7[%d]: tioc_tcgets(%d,%p)\n", current->pid, fd, tios);
17956+
17957+ old_fs = get_fs();
17958+ set_fs(get_ds());
17959+ error = SYS(ioctl)(fd, TCGETS, &t);
17960+ set_fs(old_fs);
17961+ if (error)
17962+ return error;
17963+
17964+ tmp.c_iflag = UW7_IFLAG_MSK & (t.c_iflag & ~UW7_DOSMODE);
17965+ tmp.c_oflag = UW7_OFLAG_MSK & t.c_oflag;
17966+ tmp.c_cflag = UW7_CFLAG_MSK & t.c_cflag;
17967+ tmp.c_lflag = UW7_LFLAG_MSK & (t.c_lflag & ~UW7_DEFECHO);
17968+ if (t.c_lflag & FLUSHO)
17969+ tmp.c_lflag |= UW7_FLUSHO;
17970+ else
17971+ tmp.c_lflag &= ~UW7_FLUSHO;
17972+
17973+ DBG(KERN_ERR
17974+ "UW7[%d]: iflag: %lx->%lx, oflag: %lx->%lx, cflag: %lx->%lx, lflag: %lx->%lx\n",
17975+ current->pid, tmp.c_iflag, t.c_iflag, tmp.c_oflag, t.c_oflag,
17976+ tmp.c_cflag, t.c_cflag, tmp.c_lflag, t.c_lflag);
17977+
17978+ if (t.c_lflag & ICANON) {
17979+ tmp.c_cc[UW7_VEOF] = t.c_cc[VEOF];
17980+ tmp.c_cc[UW7_VEOL] = t.c_cc[VEOL];
17981+ } else {
17982+ tmp.c_cc[UW7_VMIN] = t.c_cc[VMIN];
17983+ tmp.c_cc[UW7_VTIME] = t.c_cc[VTIME];
17984+ }
17985+
17986+ tmp.c_cc[UW7_VINTR] = t.c_cc[VINTR];
17987+ tmp.c_cc[UW7_VQUIT] = t.c_cc[VQUIT];
17988+ tmp.c_cc[UW7_VERASE] = t.c_cc[VERASE];
17989+ tmp.c_cc[UW7_VKILL] = t.c_cc[VKILL];
17990+ tmp.c_cc[UW7_VEOL2] = t.c_cc[VEOL2];
17991+ tmp.c_cc[UW7_VSWTCH] = t.c_cc[VSWTC];
17992+ tmp.c_cc[UW7_VSTART] = t.c_cc[VSTART];
17993+ tmp.c_cc[UW7_VSTOP] = t.c_cc[VSTOP];
17994+ tmp.c_cc[UW7_VSUSP] = tmp.c_cc[UW7_VDSUSP] = t.c_cc[VSUSP];
17995+ tmp.c_cc[UW7_VREPRINT] = t.c_cc[VREPRINT];
17996+ tmp.c_cc[UW7_VDISCARD] = t.c_cc[VDISCARD];
17997+ tmp.c_cc[UW7_VWERASE] = t.c_cc[VWERASE];
17998+ tmp.c_cc[UW7_VLNEXT] = t.c_cc[VLNEXT];
17999+
18000+ return copy_to_user(tios, &tmp, sizeof(struct uw7_termios)) ? -EFAULT : 0;
18001+}
18002+
18003+static int ioctl_T(int fd, unsigned int cmd, void * arg)
18004+{
18005+ DBG(KERN_ERR "ioctl_T(%d,%x,%p)\n", fd, cmd, arg);
18006+
18007+ switch (cmd) {
18008+ case UW7_TCSBRK:
18009+ return SYS(ioctl)(fd, TCSBRK, arg);
18010+
18011+ case UW7_TCXONC:
18012+ return SYS(ioctl)(fd, TCXONC, arg);
18013+
18014+ case UW7_TCFLSH:
18015+ return SYS(ioctl)(fd, TCFLSH, arg);
18016+
18017+ case UW7_TIOCSWINSZ:
18018+ return SYS(ioctl)(fd, TIOCSWINSZ, arg);
18019+
18020+ case UW7_TIOCGWINSZ:
18021+ return SYS(ioctl)(fd, TIOCGWINSZ, arg);
18022+
18023+ case UW7_TCGETS:
18024+ return tioc_tcgets(fd, arg);
18025+
18026+ case UW7_TCSETS:
18027+ return tioc_tcsets(fd, TCSETS, arg);
18028+
18029+ case UW7_TCSETSW:
18030+ return tioc_tcsets(fd, TCSETSW, arg);
18031+
18032+ case UW7_TCSETSF:
18033+ return tioc_tcsets(fd, TCSETSF, arg);
18034+ }
18035+ return -EINVAL;
18036+}
18037diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/uw7/kernel.c linux/abi/uw7/kernel.c
18038--- linux-2.4.3/abi/uw7/kernel.c Thu Jan 1 01:00:00 1970
18039+++ linux/abi/uw7/kernel.c Mon Mar 12 16:34:48 2001
18040@@ -0,0 +1,97 @@
18041+/*
18042+ * abi/uw7/kernel.c - various UW7 system calls.
18043+ *
18044+ * This software is under GPL
18045+ */
18046+
18047+#include <asm/uaccess.h>
18048+
18049+#include <linux/errno.h>
18050+#include <linux/kernel.h>
18051+#include <linux/file.h>
18052+
18053+
18054+#include <abi/abi.h>
18055+#include <abi/uw7.h>
18056+
18057+
18058+int uw7_sleep(int seconds)
18059+{
18060+ struct timespec t;
18061+ mm_segment_t old_fs;
18062+ int error;
18063+
18064+ t.tv_sec = seconds;
18065+ t.tv_nsec = 0;
18066+ old_fs = get_fs();
18067+ set_fs(get_ds());
18068+ error = SYS(nanosleep)(&t, NULL);
18069+ set_fs(old_fs);
18070+ return error;
18071+}
18072+
18073+#define UW7_MAXUID 60002
18074+
18075+int uw7_seteuid(int uid)
18076+{
18077+ if (uid < 0 || uid > UW7_MAXUID)
18078+ return -EINVAL;
18079+ return SYS(setreuid)(-1, uid);
18080+}
18081+
18082+int uw7_setegid(int gid)
18083+{
18084+ if (gid < 0 || gid > UW7_MAXUID)
18085+ return -EINVAL;
18086+ return SYS(setreuid)(-1, gid);
18087+}
18088+
18089+int uw7_lseek64(unsigned int fd, unsigned int off, unsigned int off_hi, unsigned int orig)
18090+{
18091+ loff_t result; /* XXX: how does uw7 return the result? -- ch */
18092+ int retval;
18093+
18094+ /* if (off_hi != 0) (commented because some buggy progs set off_hi = -1)
18095+ return -EINVAL; */
18096+ retval = SYS(_llseek)(fd, (off_t) off_hi, off, &result, orig);
18097+
18098+ return retval ? retval : (int) result;
18099+}
18100+
18101+/* can't call sys_pread() directly because off is 32bit on UW7 */
18102+int uw7_pread(unsigned int fd, char * buf, int count, long off)
18103+{
18104+ return SYS(pread)(fd, buf, count, (loff_t)off);
18105+}
18106+
18107+int uw7_pread64(unsigned int fd, char * buf, int count, unsigned int off, unsigned int off_hi)
18108+{
18109+ if (off_hi != 0)
18110+ return -EINVAL;
18111+
18112+ return SYS(pread)(fd, buf, count, ((loff_t) off_hi << 32) | off);
18113+}
18114+
18115+int uw7_pwrite64(unsigned int fd, char * buf, int count, unsigned int off, unsigned int off_hi)
18116+{
18117+ if (off_hi != 0)
18118+ return -EINVAL;
18119+
18120+ return SYS(pread)(fd, buf, count, ((loff_t) off_hi << 32) | off);
18121+}
18122+
18123+/* can't call sys_pwrite() directly because off is 32bit on UW7 */
18124+int uw7_pwrite(unsigned int fd, char * buf, int count, long off)
18125+{
18126+ return SYS(pwrite)(fd, buf, count, (loff_t)off);
18127+}
18128+
18129+int uw7_stty(int fd, int cmd)
18130+{
18131+ return -EIO;
18132+}
18133+
18134+int uw7_gtty(int fd, int cmd)
18135+{
18136+ return -EIO;
18137+}
18138diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/uw7/mac.c linux/abi/uw7/mac.c
18139--- linux-2.4.3/abi/uw7/mac.c Thu Jan 1 01:00:00 1970
18140+++ linux/abi/uw7/mac.c Mon Mar 12 16:34:48 2001
18141@@ -0,0 +1,41 @@
18142+/*
18143+ * abi/uw7/mac.c - mldmode(2) and friends.
18144+ *
18145+ * This software is under GPL
18146+ */
18147+
18148+#include <linux/sched.h>
18149+#include <abi/uw7.h>
18150+
18151+#undef DEBUG
18152+
18153+#ifdef DEBUG
18154+#define DBG(x...) printk(x)
18155+#else
18156+#define DBG(x...)
18157+#endif
18158+
18159+#define UW7_MLD_REAL 1
18160+#define UW7_MLD_VIRT 0
18161+#define UW7_MLD_QUERY 2
18162+
18163+int uw7_mldmode(int mldmode)
18164+{
18165+ switch (mldmode) {
18166+ case UW7_MLD_REAL:
18167+ DBG(KERN_ERR "UW7[%d]: mldmode(MLD_REAL)\n", current->pid);
18168+ break;
18169+
18170+ case UW7_MLD_VIRT:
18171+ DBG(KERN_ERR "UW7[%d]: mldmode(MLD_VIRT)\n", current->pid);
18172+ break;
18173+
18174+ case UW7_MLD_QUERY:
18175+ DBG(KERN_ERR "UW7[%d]: mldmode(MLD_QUERY)\n", current->pid);
18176+ return UW7_MLD_REAL;
18177+
18178+ default:
18179+ return -EINVAL;
18180+ }
18181+ return 0;
18182+}
18183diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/uw7/mmap.c linux/abi/uw7/mmap.c
18184--- linux-2.4.3/abi/uw7/mmap.c Thu Jan 1 01:00:00 1970
18185+++ linux/abi/uw7/mmap.c Fri Mar 30 16:14:07 2001
18186@@ -0,0 +1,43 @@
18187+/*
18188+ * abi/uw7/mmap.c - mmap(2) system call.
18189+ *
18190+ * This software is under GPL
18191+ */
18192+
18193+#include <linux/mm.h>
18194+#include <linux/errno.h>
18195+#include <linux/file.h>
18196+#include <linux/mman.h>
18197+#include <asm/uaccess.h>
18198+
18199+#include <abi/abi.h>
18200+#include <abi/uw7.h>
18201+
18202+/* same as arch/i386/kernel/sys_i386.c:sys_mmap2 (besides the UW_* handling) -- ch */
18203+int uw7_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags,
18204+ unsigned long fd, unsigned long offset)
18205+{
18206+ int error = -EBADF;
18207+ struct file * file = NULL;
18208+
18209+ if (flags & UW7_MAP_ANONYMOUS) {
18210+ flags |= MAP_ANONYMOUS;
18211+ flags &= ~UW7_MAP_ANONYMOUS;
18212+ }
18213+
18214+ flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
18215+ if (!(flags & MAP_ANONYMOUS)) {
18216+ file = fget(fd);
18217+ if (!file)
18218+ goto out;
18219+ }
18220+
18221+ down_write(&current->mm->mmap_sem);
18222+ error = do_mmap(file, addr, len, prot, flags, offset);
18223+ up_write(&current->mm->mmap_sem);
18224+
18225+ if (file)
18226+ fput(file);
18227+out:
18228+ return error;
18229+}
18230diff -uNr --exclude-from=dontdiff linux-2.4.3/abi/uw7/statvfs.c linux/abi/uw7/statvfs.c
18231--- linux-2.4.3/abi/uw7/statvfs.c Thu Jan 1 01:00:00 1970
18232+++ linux/abi/uw7/statvfs.c Mon Mar 12 16:34:48 2001
18233@@ -0,0 +1,76 @@
18234+/*
18235+ * abi/uw7/statvfs.c - statvfs64() and friends for UW7
18236+ *
18237+ * This software is under GPL
18238+ */
18239+
18240+#include <linux/sched.h>
18241+#include <linux/file.h>
18242+
18243+#include <asm/uaccess.h>
18244+
18245+#include <abi/uw7.h>
18246+
18247+static int
18248+cp_uw7_statvfs64(struct super_block * sb, struct statfs * src,
18249+ struct uw7_statvfs64 * dst)
18250+{
18251+ struct uw7_statvfs64 tmp = {0, };
18252+
18253+ tmp.f_bsize = src->f_bsize;
18254+ tmp.f_frsize = src->f_bsize;
18255+ tmp.f_blocks = src->f_blocks;;
18256+ tmp.f_bfree = src->f_bfree;
18257+ tmp.f_bavail = src->f_bavail;
18258+ tmp.f_files = src->f_files;
18259+ tmp.f_ffree = src->f_ffree;
18260+ tmp.f_favail = src->f_ffree;
18261+ tmp.f_fsid = sb->s_dev;
18262+
18263+ strcpy(tmp.f_basetype, sb->s_type->name);
18264+
18265+ tmp.f_flag = 0;
18266+ tmp.f_namemax = src->f_namelen;
18267+
18268+ return copy_to_user(dst, &tmp, sizeof(tmp)) ? -EFAULT : 0;
18269+}
18270+
18271+int
18272+uw7_statvfs64(char * filename, struct uw7_statvfs64 * buf)
18273+{
18274+
18275+ struct nameidata nd;
18276+ int error;
18277+
18278+ error = user_path_walk(filename, &nd);
18279+ if (!error) {
18280+ struct statfs tmp;
18281+ error = vfs_statfs(nd.dentry->d_inode->i_sb, &tmp);
18282+ if (!error && cp_uw7_statvfs64(nd.dentry->d_inode->i_sb, &tmp, buf))
18283+ error = -EFAULT;
18284+ path_release(&nd);
18285+ }
18286+
18287+ return error;
18288+}
18289+
18290+
18291+int
18292+uw7_fstatvfs64(int fd, struct uw7_statvfs64 * buf)
18293+{
18294+ struct file * file;
18295+ struct statfs tmp;
18296+ int error;
18297+
18298+ error = -EBADF;
18299+ file = fget(fd);
18300+ if (!file)
18301+ goto out;
18302+ error = vfs_statfs(file->f_dentry->d_inode->i_sb, &tmp);
18303+ if (!error && cp_uw7_statvfs64(file->f_dentry->d_inode->i_sb, &tmp, buf))
18304+ error = -EFAULT;
18305+ fput(file);
18306+
18307+out:
18308+ return error;
18309+}
18310diff -uNr --exclude-from=dontdiff linux-2.4.3/arch/i386/config.in linux/arch/i386/config.in
18311--- linux-2.4.3/arch/i386/config.in Fri Mar 30 14:45:00 2001
18312+++ linux/arch/i386/config.in Fri Mar 30 17:25:23 2001
18313@@ -246,6 +246,8 @@
18314
18315 endmenu
18316
18317+source abi/Config.in
18318+
18319 source drivers/mtd/Config.in
18320
18321 source drivers/parport/Config.in
18322diff -uNr --exclude-from=dontdiff linux-2.4.3/fs/Makefile linux/fs/Makefile
18323--- linux-2.4.3/fs/Makefile Fri Mar 30 14:48:44 2001
18324+++ linux/fs/Makefile Fri Mar 30 17:25:23 2001
18325@@ -64,6 +64,8 @@
18326
18327
18328 obj-$(CONFIG_BINFMT_AOUT) += binfmt_aout.o
18329+obj-$(CONFIG_BINFMT_XOUT) += binfmt_xout.o
18330+obj-$(CONFIG_BINFMT_COFF) += binfmt_coff.o
18331 obj-$(CONFIG_BINFMT_EM86) += binfmt_em86.o
18332 obj-$(CONFIG_BINFMT_MISC) += binfmt_misc.o
18333
18334diff -uNr --exclude-from=dontdiff linux-2.4.3/fs/binfmt_coff.c linux/fs/binfmt_coff.c
18335--- linux-2.4.3/fs/binfmt_coff.c Thu Jan 1 01:00:00 1970
18336+++ linux/fs/binfmt_coff.c Fri Mar 30 16:32:53 2001
18337@@ -0,0 +1,950 @@
18338+/* $Id$ */
18339+/*
18340+ * These are the functions used to load COFF IBCS style executables.
18341+ * Information on COFF format may be obtained in either the Intel Binary
18342+ * Compatibility Specification 2 or O'Rilley's book on COFF. The shared
18343+ * libraries are defined only the in the Intel book.
18344+ *
18345+ * This file is based upon code written by Eric Youngdale for the ELF object
18346+ * file format.
18347+ *
18348+ * Author: Al Longyear (longyear@sii.com)
18349+ *
18350+ * Latest Revision:
18351+ * 3 February 1994
18352+ * Al Longyear (longyear@sii.com)
18353+ * Cleared first page of bss section using put_fs_byte.
18354+ *
18355+ * 4 February 1994
18356+ * Mike Jagdis (jaggy@purplet.demon.co.uk)
18357+ * Added scanning of .comment sections for clues as to the
18358+ * "personality" of the executable. This is then used to emulate
18359+ * the right set of non-standard syscall extensions and bugs. :-)
18360+ *
18361+ * 18 February 1994
18362+ * Mike Jagdis (jaggy@purplet.demon.co.uk)
18363+ * If compile the module version of iBCS rather than the in-kernel
18364+ * version we must take care to signal when module code is in use
18365+ * or it may be freed from under us - Bad News :-).
18366+ */
18367+
18368+
18369+#include <linux/module.h>
18370+
18371+#include <asm/uaccess.h>
18372+
18373+#include <linux/fs.h>
18374+#include <linux/stat.h>
18375+#include <linux/sched.h>
18376+#include <linux/init.h>
18377+#include <linux/kernel.h>
18378+#include <linux/mm.h>
18379+#include <linux/mman.h>
18380+#include <linux/a.out.h>
18381+#include <linux/errno.h>
18382+#include <linux/signal.h>
18383+#include <linux/binfmts.h>
18384+#include <linux/string.h>
18385+#include <linux/fcntl.h>
18386+#include <linux/ptrace.h>
18387+#include <linux/coff.h>
18388+#include <linux/malloc.h>
18389+#include <linux/personality.h>
18390+#include <linux/file.h>
18391+#include <linux/smp_lock.h>
18392+
18393+#include <abi/abi.h>
18394+
18395+
18396+static unsigned long * create_coff_tables(char *p,
18397+ struct linux_binprm *bprm, int ibcs);
18398+
18399+static int load_coff_binary(struct linux_binprm *bprm, struct pt_regs *regs);
18400+static int load_coff_library(struct file * file);
18401+static int preload_library(struct linux_binprm *exe_bprm,
18402+ COFF_SCNHDR * sect, struct file *fp);
18403+static int load_object(struct linux_binprm *bprm, struct pt_regs *regs,
18404+ int lib_ok);
18405+static int parse_comments(struct linux_binprm *exe_bprm, COFF_SCNHDR * sect,
18406+ long *personality);
18407+
18408+/*
18409+ * The following table gives clues to the "personality" of the executable
18410+ * which we hope to find in the .comment sections of the binary.
18411+ * The set here may not be comprehensive even for those systems listed.
18412+ * Use 'mcs -p' to list the .comments sections of a binary to see what
18413+ * clues might be there. Or use 'strings' if you don't have mcs.
18414+ */
18415+struct coff_clue {
18416+ short terminal; /* non-zero to stop parsing with this entry */
18417+ short len; /* negative number uses strstr for lookup */
18418+ char *text;
18419+ unsigned long mask_and, mask_or;
18420+};
18421+
18422+static struct coff_clue coff_clues[] = {
18423+ /* Wyse Unix V/386 3.2.1[A]. */
18424+ {1, 36, "@(#) UNIX System V/386 Release 3.2.1",
18425+ 0, PER_WYSEV386},
18426+
18427+ /* SCO Unix V 3.2, 3.2.2, 3.2.4, 3.2.4.2 etc. */
18428+ {1, 23, "@(#) crt1.s 1.8 89/05/30",
18429+ 0, PER_SCOSVR3},
18430+ {1, 16, "@(#)SCO UNIX 3.2",
18431+ 0, PER_SCOSVR3},
18432+ {1, 18, "\"@(#) SCO UNIX 3.2",
18433+ 0, PER_SCOSVR3},
18434+ {1, 17, "@(#) SCO UNIX 3.2",
18435+ 0, PER_SCOSVR3},
18436+ {1, 11, "@(#)SCO 3.2",
18437+ 0, PER_SCOSVR3},
18438+
18439+ /*
18440+ * SCO Unix 3.2.4.2 OpenServer 5 gives 32 bit inodes except
18441+ * programs compiled with ods30 compatibilty. In fact OS5
18442+ * always gives 32 bits but the library drops the top 16 in
18443+ * odt30 mode. We know what should happen and do it however.
18444+ */
18445+ {0, 32, "@(#) crt1.s.source 20.1 94/12/04",
18446+ 0, PER_SCOSVR3},
18447+ {1, 13, "ods_30_compat",
18448+ ~0, SHORT_INODE},
18449+
18450+ /* Interactive (ISC) 4.0 */
18451+ {1, -1, "INTERACTIVE",
18452+ 0, PER_ISCR4},
18453+
18454+ /* End of table */
18455+ {0, 0, 0, 0, 0}
18456+};
18457+
18458+
18459+static struct linux_binfmt coff_format = {
18460+ NULL, THIS_MODULE, load_coff_binary, load_coff_library, NULL, PAGE_SIZE
18461+};
18462+
18463+
18464+/*
18465+ * Small procedure to test for the proper file alignment.
18466+ */
18467+
18468+static inline int is_properly_aligned(COFF_SCNHDR * sect)
18469+{
18470+ long scnptr = COFF_LONG(sect->s_scnptr);
18471+ long vaddr = COFF_LONG(sect->s_vaddr);
18472+
18473+
18474+/*
18475+ * Return the error code if the section is not properly aligned.
18476+ */
18477+
18478+ return ((((vaddr - scnptr) & ~PAGE_MASK) != 0) ? -ENOEXEC : 0);
18479+}
18480+
18481+/*
18482+ * Clear the bytes in the last page of data.
18483+ */
18484+
18485+static
18486+int clear_memory(unsigned long addr, unsigned long size)
18487+{
18488+ int status;
18489+
18490+ size = (PAGE_SIZE - (addr & ~PAGE_MASK)) & ~PAGE_MASK;
18491+ if (size == 0)
18492+ status = 0;
18493+ else {
18494+
18495+ status = verify_area(VERIFY_WRITE, (void *) addr, size);
18496+ if (status >= 0)
18497+ while (size-- != 0) {
18498+ __put_user(0, (char *) addr);
18499+ addr++;
18500+ }
18501+ }
18502+ return status;
18503+}
18504+
18505+struct coff_section {
18506+ long scnptr;
18507+ long size;
18508+ long vaddr;
18509+};
18510+
18511+static inline unsigned long
18512+map_coff(struct file *file, struct coff_section * sect, unsigned long prot,
18513+ unsigned long flag, unsigned long offset)
18514+{
18515+ unsigned long map_addr;
18516+
18517+ down(&current->mm->mmap_sem);
18518+ map_addr = do_mmap(file,
18519+ sect->vaddr & PAGE_MASK,
18520+ sect->size + (sect->vaddr & ~PAGE_MASK),
18521+ prot, flag, offset);
18522+ up(&current->mm->mmap_sem);
18523+
18524+ return (map_addr);
18525+}
18526+
18527+
18528+/*
18529+ * Helper function to process the load operation.
18530+ */
18531+
18532+static int
18533+load_object(struct linux_binprm * bprm, struct pt_regs * regs, int lib_ok)
18534+{
18535+ COFF_FILHDR * coff_hdr = NULL;
18536+ COFF_SCNHDR * sect_bufr = NULL; /* Pointer to section table */
18537+ COFF_SCNHDR * sect_ptr = NULL;
18538+
18539+ COFF_SCNHDR * text_sect, * data_sect, * bss_sect;
18540+
18541+ struct coff_section text, data, bss;
18542+ mm_segment_t old_fs;
18543+
18544+ int text_count, data_count, bss_count, lib_count;
18545+
18546+ unsigned int start_addr = 0; /* Starting location for program */
18547+ short int sections = 0; /* Number of sections in the file */
18548+ short int aout_size = 0; /* Size of the a.out header area */
18549+ short int flags; /* Flag bits from the COFF header */
18550+ int not_pageable = 0; /* Can we demand page the executable? */
18551+ unsigned long p = bprm->p;
18552+ unsigned long personality;
18553+ int coff_exec_fileno;
18554+
18555+ int status = 0; /* Result status register */
18556+ int nIndex;
18557+
18558+ text_sect = data_sect = bss_sect = NULL;
18559+
18560+ coff_hdr = (COFF_FILHDR *) bprm->buf; /* COFF Header */
18561+
18562+ /*
18563+ * Validate the magic value for the object file.
18564+ */
18565+
18566+ if (COFF_I386BADMAG(*coff_hdr))
18567+ return -ENOEXEC;
18568+
18569+ flags = COFF_SHORT(coff_hdr->f_flags);
18570+
18571+ /*
18572+ * The object file should have 32 BIT little endian format. Do not allow
18573+ * it to have the 16 bit object file flag set as Linux is not able to run
18574+ * on the 80286/80186/8086.
18575+ */
18576+ if ((flags & (COFF_F_AR32WR | COFF_F_AR16WR)) != COFF_F_AR32WR)
18577+ return -ENOEXEC;
18578+
18579+ /*
18580+ * If the file is not executable then reject the execution. This means
18581+ * that there must not be external references.
18582+ */
18583+ if ((flags & COFF_F_EXEC) == 0)
18584+ return -ENOEXEC;
18585+
18586+ /*
18587+ * Extract the header information which we need.
18588+ */
18589+ sections = COFF_SHORT(coff_hdr->f_nscns); /* Number of sections */
18590+ aout_size = COFF_SHORT(coff_hdr->f_opthdr); /* Size of opt. headr */
18591+
18592+ /*
18593+ * There must be atleast one section.
18594+ */
18595+ if (!sections)
18596+ return -ENOEXEC;
18597+
18598+ if (!bprm->file->f_op->mmap)
18599+ not_pageable = 1;
18600+
18601+ if (!(sect_bufr = kmalloc(sections * COFF_SCNHSZ, GFP_KERNEL))) {
18602+ printk(KERN_WARNING "coff: kmalloc failed\n");
18603+ return -ENOMEM;
18604+ }
18605+
18606+ status = kernel_read(bprm->file, aout_size + COFF_FILHSZ,
18607+ (char *)sect_bufr, sections * COFF_SCNHSZ);
18608+ if (status < 0)
18609+ goto out_free_buf;
18610+
18611+ status = get_unused_fd();
18612+ if (status < 0)
18613+ goto out_free_buf;
18614+
18615+ get_file(bprm->file);
18616+ fd_install(coff_exec_fileno = status, bprm->file);
18617+
18618+ text_count = 0;
18619+ data_count = 0;
18620+ bss_count = 0;
18621+ lib_count = 0;
18622+
18623+ /*
18624+ * Loop through the sections and find the various types
18625+ */
18626+ sect_ptr = sect_bufr;
18627+
18628+ for (nIndex = 0; nIndex < sections; ++nIndex) {
18629+ long int sect_flags = COFF_LONG(sect_ptr->s_flags);
18630+
18631+ switch (sect_flags) {
18632+ case COFF_STYP_TEXT:
18633+ status = is_properly_aligned(sect_ptr);
18634+ text_sect = sect_ptr;
18635+ text_count++;
18636+ break;
18637+
18638+ case COFF_STYP_DATA:
18639+ status = is_properly_aligned(sect_ptr);
18640+ data_sect = sect_ptr;
18641+ data_count++;
18642+ break;
18643+
18644+ case COFF_STYP_BSS:
18645+ bss_sect = sect_ptr;
18646+ bss_count++;
18647+ break;
18648+
18649+ case COFF_STYP_LIB:
18650+ lib_count++;
18651+ break;
18652+
18653+ default:
18654+ break;
18655+ }
18656+
18657+ sect_ptr = (COFF_SCNHDR *) & ((char *) sect_ptr)[COFF_SCNHSZ];
18658+ }
18659+
18660+ /*
18661+ * If any of the sections weren't properly aligned we aren't going to
18662+ * be able to demand page this executable. Note that at this stage the
18663+ * *only* excuse for having status <= 0 is if the alignment test failed.
18664+ */
18665+
18666+ if (status < 0) {
18667+ not_pageable = 1;
18668+ status = 0;
18669+ }
18670+
18671+ /*
18672+ * Ensure that there are the required sections. There must be one text
18673+ * sections and one each of the data and bss sections for an executable.
18674+ * A library may or may not have a data / bss section.
18675+ */
18676+
18677+ if (text_count != 1)
18678+ status = -ENOEXEC;
18679+
18680+ if (lib_ok)
18681+ if (data_count != 1 || bss_count != 1)
18682+ status = -ENOEXEC;
18683+
18684+ /*
18685+ * If there is no additional header then assume the file starts at
18686+ * the first byte of the text section. This may not be the proper place,
18687+ * so the best solution is to include the optional header. A shared library
18688+ * __MUST__ have an optional header to indicate that it is a shared library.
18689+ */
18690+
18691+ if (status < 0)
18692+ goto out_free_file;
18693+
18694+ if (aout_size == 0) {
18695+ if (!lib_ok)
18696+ status = -ENOEXEC;
18697+ start_addr = COFF_LONG(text_sect->s_vaddr);
18698+
18699+ /*
18700+ * There is some header. Ensure that it is sufficient.
18701+ */
18702+
18703+ } else {
18704+ if (aout_size < (short) COFF_AOUTSZ)
18705+ status = -ENOEXEC;
18706+ else {
18707+ /* Pointer to a.out header */
18708+ COFF_AOUTHDR *aout_hdr =
18709+ (COFF_AOUTHDR *) & ((char *) coff_hdr)[COFF_FILHSZ];
18710+ short int aout_magic = COFF_SHORT(aout_hdr->magic); /* id */
18711+
18712+ /*
18713+ * Validate the magic number in the a.out header. If it is valid then
18714+ * update the starting symbol location. Do not accept these file formats
18715+ * when loading a shared library.
18716+ */
18717+
18718+ switch (aout_magic) {
18719+ case COFF_OMAGIC:
18720+ case COFF_ZMAGIC:
18721+ case COFF_STMAGIC:
18722+ if (!lib_ok)
18723+ status = -ENOEXEC;
18724+ start_addr =
18725+ (unsigned int) COFF_LONG(aout_hdr->entry);
18726+ break;
18727+
18728+ /*
18729+ * Magic value for a shared library. This is valid only when loading a
18730+ * shared library. (There is no need for a start_addr. It won't be used.)
18731+ */
18732+
18733+ case COFF_SHMAGIC:
18734+ if (lib_ok)
18735+ status = -ENOEXEC;
18736+ break;
18737+
18738+ default:
18739+ status = -ENOEXEC;
18740+ break;
18741+ }
18742+ }
18743+ }
18744+
18745+ if (status < 0)
18746+ goto out_free_file;
18747+
18748+ /*
18749+ * Generate the proper values for the text fields
18750+ *
18751+ * THIS IS THE POINT OF NO RETURN. THE NEW PROCESS WILL TRAP OUT SHOULD
18752+ * SOMETHING FAIL IN THE LOAD SEQUENCE FROM THIS POINT ONWARD.
18753+ */
18754+
18755+ text.scnptr = COFF_LONG(text_sect->s_scnptr);
18756+ text.size = COFF_LONG(text_sect->s_size);
18757+ text.vaddr = COFF_LONG(text_sect->s_vaddr);
18758+
18759+ /*
18760+ * Generate the proper values for the data fields
18761+ */
18762+
18763+ if (data_sect != NULL) {
18764+ data.scnptr = COFF_LONG(data_sect->s_scnptr);
18765+ data.size = COFF_LONG(data_sect->s_size);
18766+ data.vaddr = COFF_LONG(data_sect->s_vaddr);
18767+ } else {
18768+ data.scnptr = 0;
18769+ data.size = 0;
18770+ data.vaddr = 0;
18771+ }
18772+
18773+ /*
18774+ * Generate the proper values for the bss fields
18775+ */
18776+
18777+ if (bss_sect != NULL) {
18778+ bss.size = COFF_LONG(bss_sect->s_size);
18779+ bss.vaddr = COFF_LONG(bss_sect->s_vaddr);
18780+ } else {
18781+ bss.size = 0;
18782+ bss.vaddr = 0;
18783+ }
18784+
18785+ /*
18786+ * Flush the executable from memory. At this point the executable is
18787+ * committed to being defined or a segmentation violation will occur.
18788+ */
18789+
18790+ if (lib_ok) {
18791+ status = flush_old_exec(bprm); /* SIGSEGV */
18792+ if (status != 0)
18793+ goto out_free_file;
18794+
18795+ /*
18796+ * Look for clues as to the system this binary was compiled on in the
18797+ * comments section(s). Only look at the main binary, not the shared
18798+ * libraries (or would it be better to prefer shared libraries over
18799+ * binaries? Or could they be different???)
18800+ */
18801+
18802+ personality = PER_SVR3;
18803+
18804+ if (lib_ok) {
18805+ COFF_SCNHDR *sect_ptr2 = sect_bufr;
18806+ int i;
18807+
18808+ for (i = 0; i < sections; i++) {
18809+ long sect_flags = COFF_LONG(sect_ptr2->s_flags);
18810+
18811+ if (sect_flags == COFF_STYP_INFO &&
18812+ (status = parse_comments(bprm, sect_ptr2, &personality)) > 0)
18813+ goto found;
18814+
18815+ sect_ptr2 = (COFF_SCNHDR *) & ((char *) sect_ptr2) [COFF_SCNHSZ];
18816+ }
18817+
18818+ /*
18819+ * If no .comments section was found there is no way to
18820+ * figure out the personality. Odds on it is SCO though...
18821+ */
18822+ personality = PER_SCOSVR3;
18823+ }
18824+
18825+found:
18826+ set_personality(personality);
18827+
18828+ current->mm->start_data = 0;
18829+ current->mm->end_data = 0;
18830+ current->mm->end_code = 0;
18831+ current->mm->mmap = NULL;
18832+ current->flags &= ~PF_FORKNOEXEC;
18833+
18834+ /*
18835+ * Construct the parameter and environment string table entries.
18836+ */
18837+
18838+ current->mm->rss = 0;
18839+ status = setup_arg_pages(bprm);
18840+ if (status < 0) {
18841+ send_sig(SIGSEGV, current, 1);
18842+ return status;
18843+ }
18844+ p = (unsigned long) create_coff_tables((char *)
18845+ bprm->p, bprm, 1);
18846+
18847+ /*
18848+ * Do the end processing once the stack has been constructed
18849+ */
18850+
18851+ current->mm->end_code = text.size +
18852+ (current->mm->start_code = text.vaddr);
18853+ current->mm->end_data = data.size +
18854+ (current->mm->start_data = data.vaddr);
18855+ current->mm->brk = bss.size +
18856+ (current->mm->start_brk = bss.vaddr);
18857+
18858+ current->mm->start_stack = p;
18859+ compute_creds(bprm);
18860+ start_thread(regs, start_addr, p);
18861+ }
18862+
18863+ old_fs = get_fs();
18864+ set_fs(get_ds());
18865+
18866+ if (not_pageable) {
18867+ /*
18868+ * Read the file from disk...
18869+ *
18870+ * XXX: untested.
18871+ */
18872+ loff_t pos = data.scnptr;
18873+ status = do_brk(text.vaddr, text.size);
18874+ bprm->file->f_op->read(bprm->file,
18875+ (char *)data.vaddr, data.scnptr, &pos);
18876+ status = do_brk(data.vaddr, data.size);
18877+ bprm->file->f_op->read(bprm->file,
18878+ (char *)text.vaddr, text.scnptr, &pos);
18879+ status = 0;
18880+ } else {
18881+ /*
18882+ * Map the text pages
18883+ */
18884+
18885+ status = map_coff(bprm->file, &text, PROT_READ | PROT_EXEC,
18886+ MAP_FIXED | MAP_SHARED | MAP_DENYWRITE | MAP_EXECUTABLE,
18887+ text.scnptr & PAGE_MASK);
18888+
18889+ if (status != (text.vaddr & PAGE_MASK)) {
18890+ status = -ENOEXEC;
18891+ goto out_free_file;
18892+ }
18893+
18894+ /*
18895+ * Map the data pages
18896+ */
18897+
18898+ if (data.size != 0) {
18899+ status = map_coff(bprm->file, &data,
18900+ PROT_READ | PROT_WRITE | PROT_EXEC,
18901+ MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
18902+ data.scnptr & PAGE_MASK);
18903+
18904+ if (status != (data.vaddr & PAGE_MASK)) {
18905+ status = -ENOEXEC;
18906+ goto out_free_file;
18907+ }
18908+ }
18909+ }
18910+
18911+ /*
18912+ * Construct the bss data for the process. The bss ranges from the
18913+ * end of the data (which may not be on a page boundary) to the end
18914+ * of the bss section. Allocate any necessary pages for the data.
18915+ */
18916+
18917+ if (bss.size != 0) {
18918+ down(&current->mm->mmap_sem);
18919+ do_mmap(NULL, PAGE_ALIGN(bss.vaddr),
18920+ bss.size + bss.vaddr -
18921+ PAGE_ALIGN(bss.vaddr),
18922+ PROT_READ | PROT_WRITE | PROT_EXEC,
18923+ MAP_FIXED | MAP_PRIVATE, 0);
18924+ up(&current->mm->mmap_sem);
18925+ status = clear_memory(bss.vaddr, bss.size);
18926+
18927+ if (status < 0)
18928+ goto out_free_file;
18929+ }
18930+
18931+ set_fs(old_fs);
18932+
18933+ /*
18934+ * Load any shared library for the executable.
18935+ */
18936+
18937+ if (lib_ok && lib_count != 0) {
18938+ int nIndex;
18939+ COFF_SCNHDR *sect_ptr = sect_bufr;
18940+
18941+ /*
18942+ * Find the library sections. (There should be at least one. It was counted
18943+ * earlier.) This will eventually recurse to our code and load the shared
18944+ * library with our own procedures.
18945+ */
18946+
18947+ for (nIndex = 0; nIndex < sections; ++nIndex) {
18948+ long int sect_flags =
18949+ COFF_LONG(sect_ptr->s_flags);
18950+ if (sect_flags == COFF_STYP_LIB) {
18951+ status = preload_library(bprm,
18952+ sect_ptr, bprm->file);
18953+
18954+ if (status != 0)
18955+ break;
18956+ }
18957+ sect_ptr =
18958+ (COFF_SCNHDR *) & ((char *) sect_ptr) [COFF_SCNHSZ];
18959+ }
18960+ }
18961+
18962+ if (lib_ok) {
18963+ set_binfmt(&coff_format);
18964+
18965+ /*
18966+ * Generate any needed trap for this process. If an error occured then
18967+ * generate a segmentation violation. If the process is being debugged
18968+ * then generate the load trap. (Note: If this is a library load then
18969+ * do not generate the trap here. Pass the error to the caller who
18970+ * will do it for the process in the outer lay of this procedure call.)
18971+ */
18972+
18973+ if (status < 0)
18974+ send_sig(SIGSEGV, current, 0); /* Generate the error trap */
18975+ else {
18976+ if (current->ptrace & PT_PTRACED)
18977+ send_sig(SIGTRAP, current, 0);
18978+ }
18979+ status = 0; /* We are committed. It can't fail */
18980+ }
18981+
18982+
18983+out_free_file:
18984+ sys_close(coff_exec_fileno);
18985+
18986+out_free_buf:
18987+ kfree(sect_bufr);
18988+ return (status);
18989+}
18990+
18991+/*
18992+ * This procedure will load the library listed in the file name given
18993+ * as the parameter. The result will be non-zero should something fail
18994+ * to load.
18995+ */
18996+
18997+static int
18998+preload_this_library(struct linux_binprm *exe_bprm, char *lib_name)
18999+{
19000+ int status;
19001+ mm_segment_t old_fs = get_fs();
19002+/*
19003+ * Change the FS register to the proper kernel address space and attempt
19004+ * to load the library. The library name is allocated from the kernel
19005+ * pool.
19006+ */
19007+ set_fs(get_ds());
19008+ status = SYS(uselib) (lib_name);
19009+ set_fs(old_fs);
19010+/*
19011+ * Return the success/failure to the caller.
19012+ */
19013+ return (status);
19014+}
19015+
19016+/*
19017+ * This procedure is called to load a library section. The various
19018+ * libraries are loaded from the list given in the section data.
19019+ */
19020+
19021+static int
19022+preload_library(struct linux_binprm *exe_bprm,
19023+ COFF_SCNHDR * sect, struct file *fp)
19024+{
19025+ int status = 0; /* Completion status */
19026+ long nbytes; /* Count of bytes in the header area */
19027+/*
19028+ * Fetch the size of the section. There must be enough room for at least
19029+ * one entry.
19030+ */
19031+ nbytes = (long) COFF_LONG(sect->s_size);
19032+ if (nbytes < (long) COFF_SLIBSZ) {
19033+ status = -ENOEXEC;
19034+ }
19035+/*
19036+ * Allocate a buffer to hold the section data
19037+ */
19038+ else {
19039+ COFF_SLIBHD *phdr;
19040+ char *buffer = (char *) kmalloc(nbytes, GFP_KERNEL);
19041+
19042+ if (0 == buffer) {
19043+ status = -ENOEXEC;
19044+ printk(KERN_WARNING "COFF: kmalloc failed\n");
19045+ } else {
19046+ status = kernel_read(exe_bprm->file,
19047+ COFF_LONG(sect->s_scnptr), buffer, nbytes);
19048+
19049+ if (status >= 0 && status != nbytes)
19050+ status = -ENOEXEC;
19051+ }
19052+/*
19053+ * At this point, go through the list of libraries in the data area.
19054+ */
19055+ phdr = (COFF_SLIBHD *) buffer;
19056+ while (status >= 0 && nbytes > (long) COFF_SLIBSZ) {
19057+ int entry_size =
19058+ COFF_LONG(phdr->sl_entsz) * sizeof(long);
19059+ int header_size =
19060+ COFF_LONG(phdr->sl_pathndx) * sizeof(long);
19061+/*
19062+ * Validate the sizes of the various items. I don't trust the linker!!
19063+ */
19064+ if ((unsigned) header_size >= (unsigned) nbytes ||
19065+ entry_size <= 0 ||
19066+ (unsigned) entry_size <=
19067+ (unsigned) header_size) {
19068+ status = -ENOEXEC;
19069+ }
19070+/*
19071+ * Load the library. Stop the load process on the first error.
19072+ */
19073+ else {
19074+ status = preload_this_library(exe_bprm,
19075+ &((char *)
19076+ phdr)
19077+ [header_size]);
19078+ }
19079+/*
19080+ * Point to the next library in the section data.
19081+ */
19082+ nbytes -= entry_size;
19083+ phdr =
19084+ (COFF_SLIBHD *) & ((char *) phdr)[entry_size];
19085+ }
19086+/*
19087+ * Release the space for the library list.
19088+ */
19089+ if (buffer != NULL)
19090+ kfree(buffer);
19091+ }
19092+/*
19093+ * Return the resulting status to the caller.
19094+ */
19095+ return (status);
19096+}
19097+
19098+/*
19099+ * Parse a comments section looking for clues as to the system this
19100+ * was compiled on so we can get the system call interface right.
19101+ */
19102+
19103+static int
19104+parse_comments(struct linux_binprm *exe_bprm, COFF_SCNHDR * sect, long *personality)
19105+{
19106+ unsigned long offset, nbytes;
19107+ char *buffer;
19108+ int status, hits;
19109+
19110+/*
19111+ * Fetch the size of the section. There must be something in there or the
19112+ * section wouldn't exist at all. We only bother with the first 8192
19113+ * characters though. There isn't any point getting too carried away!
19114+ */
19115+ if ((nbytes = COFF_LONG(sect->s_size)) > 8192)
19116+ nbytes = 8192;
19117+
19118+ if (!(buffer = (char *) __get_free_page(GFP_KERNEL)))
19119+ return 0;
19120+
19121+ hits = 0;
19122+ offset = COFF_LONG(sect->s_scnptr);
19123+ while (nbytes > 0) {
19124+ char *p;
19125+ unsigned long count, str_start;
19126+
19127+ status = kernel_read(exe_bprm->file, offset, buffer,
19128+ nbytes > PAGE_SIZE ? PAGE_SIZE : nbytes);
19129+
19130+ if (status <= 0) {
19131+ free_page((unsigned long) buffer);
19132+ return 0;
19133+ }
19134+
19135+ p = buffer;
19136+ str_start = 0;
19137+ for (count = 0; count < status; count++) {
19138+ struct coff_clue *clue;
19139+ char c = *(buffer + PAGE_SIZE - 1);
19140+ *(buffer + PAGE_SIZE - 1) = '\0';
19141+ for (clue = coff_clues; clue->len; clue++) {
19142+ if ((clue->len < 0 && strstr(p, clue->text))
19143+ || (clue->len > 0
19144+ && !strncmp(p, clue->text, clue->len))) {
19145+ *personality &= clue->mask_and;
19146+ *personality |= clue->mask_or;
19147+ if (clue->terminal) {
19148+ free_page((unsigned long)
19149+ buffer);
19150+ return (1);
19151+ }
19152+ hits++;
19153+ }
19154+ }
19155+ *(buffer + PAGE_SIZE - 1) = c;
19156+
19157+ while (*p && count < status)
19158+ p++, count++;
19159+ if (count < status) {
19160+ p++;
19161+ count++;
19162+ str_start = count;
19163+ }
19164+ }
19165+
19166+ /* If we didn't find an end ofstring at all this page
19167+ * probably isn't useful string data.
19168+ */
19169+ if (str_start == 0)
19170+ str_start = status;
19171+
19172+ nbytes -= str_start;
19173+ offset += str_start;
19174+ }
19175+
19176+ free_page((unsigned long) buffer);
19177+ return hits;
19178+}
19179+
19180+
19181+/*
19182+ * Load the image for an (coff) binary.
19183+ *
19184+ * => this procedure is called by the main load sequence,
19185+ * it will load the executable and prepare it for execution
19186+ */
19187+static int
19188+load_coff_binary(struct linux_binprm *bprm, struct pt_regs *regs)
19189+{
19190+ return load_object(bprm, regs, 1);
19191+}
19192+
19193+/*
19194+ * Load the image for an (coff) shared library.
19195+ *
19196+ * => this is called when we need to load a library based upon a file name.
19197+ * => also called through preload_this_library
19198+ */
19199+static int
19200+load_coff_library(struct file *fp)
19201+{
19202+ struct linux_binprm *bpp;
19203+ struct pt_regs regs;
19204+ int err = -ENOMEM;
19205+
19206+ if (!(bpp = kmalloc(sizeof(struct linux_binprm), GFP_KERNEL))) {
19207+ printk(KERN_WARNING "coff: kmalloc failed\n");
19208+ goto out;
19209+ }
19210+
19211+ memset(bpp, 0, sizeof(struct linux_binprm));
19212+ bpp->file = fp;
19213+
19214+ if ((err = kernel_read(fp, 0L, bpp->buf, sizeof(bpp->buf))) < 0)
19215+ printk(KERN_WARNING "coff: unable to read library header\n");
19216+ else
19217+ err = load_object(bpp, &regs, 0);
19218+
19219+ kfree(bpp);
19220+out:
19221+ return (err);
19222+}
19223+
19224+static unsigned long *
19225+create_coff_tables(char *p, struct linux_binprm *bprm, int ibcs)
19226+{
19227+ unsigned long *argv, *envp;
19228+ unsigned long *sp;
19229+ int argc = bprm->argc;
19230+ int envc = bprm->envc;
19231+
19232+ sp = (unsigned long *) ((-(unsigned long) sizeof(char *))
19233+ & (unsigned long) p);
19234+
19235+ sp -= envc + 1;
19236+ envp = sp;
19237+ sp -= argc + 1;
19238+ argv = sp;
19239+
19240+ if (!ibcs) {
19241+ put_user(envp, --sp);
19242+ put_user(argv, --sp);
19243+ }
19244+
19245+ put_user(argc, --sp);
19246+ current->mm->arg_start = (unsigned long) p;
19247+
19248+ while (argc-- > 0) {
19249+ __put_user(p, argv++);
19250+ p += strlen_user(p);
19251+ }
19252+
19253+ __put_user(NULL, argv);
19254+ current->mm->arg_end = current->mm->env_start = (unsigned long) p;
19255+
19256+ while (envc-- > 0) {
19257+ __put_user(p, envp++);
19258+ p += strlen_user(p);
19259+ }
19260+
19261+ __put_user(NULL, envp);
19262+ current->mm->env_end = (unsigned long) p;
19263+
19264+ return sp;
19265+}
19266+
19267+
19268+
19269+
19270+static void __exit
19271+cleanup_binfmt_coff(void)
19272+{
19273+ unregister_binfmt(&coff_format);
19274+}
19275+
19276+
19277+
19278+static int __init
19279+init_binfmt_coff(void)
19280+{
19281+ register_binfmt(&coff_format);
19282+ return 0;
19283+}
19284+
19285+module_init(init_binfmt_coff);
19286+module_exit(cleanup_binfmt_coff);
19287+
19288diff -uNr --exclude-from=dontdiff linux-2.4.3/fs/binfmt_elf.c linux/fs/binfmt_elf.c
19289--- linux-2.4.3/fs/binfmt_elf.c Fri Mar 30 14:48:44 2001
19290+++ linux/fs/binfmt_elf.c Fri Mar 30 17:25:23 2001
19291@@ -397,7 +397,6 @@
19292 int load_addr_set = 0;
19293 char * elf_interpreter = NULL;
19294 unsigned int interpreter_type = INTERPRETER_NONE;
19295- unsigned char ibcs2_interpreter = 0;
19296 mm_segment_t old_fs;
19297 unsigned long error;
19298 struct elf_phdr * elf_ppnt, *elf_phdata;
19299@@ -477,40 +476,18 @@
19300 elf_ppnt->p_filesz);
19301 if (retval < 0)
19302 goto out_free_interp;
19303- /* If the program interpreter is one of these two,
19304- * then assume an iBCS2 image. Otherwise assume
19305- * a native linux image.
19306+
19307+ /*
19308+ * Change our personality, if needed.
19309 */
19310- if (strcmp(elf_interpreter,"/usr/lib/libc.so.1") == 0 ||
19311- strcmp(elf_interpreter,"/usr/lib/ld.so.1") == 0)
19312- ibcs2_interpreter = 1;
19313+ SET_ELF_PERSONALITY(elf_ex, elf_interpreter);
19314+
19315 #if 0
19316 printk("Using ELF interpreter %s\n", elf_interpreter);
19317 #endif
19318-#ifdef __sparc__
19319- if (ibcs2_interpreter) {
19320- unsigned long old_pers = current->personality;
19321- struct exec_domain *old_domain = current->exec_domain;
19322- struct exec_domain *new_domain;
19323- struct fs_struct *old_fs = current->fs, *new_fs;
19324- get_exec_domain(old_domain);
19325- atomic_inc(&old_fs->count);
19326-
19327- set_personality(PER_SVR4);
19328- interpreter = open_exec(elf_interpreter);
19329-
19330- new_domain = current->exec_domain;
19331- new_fs = current->fs;
19332- current->personality = old_pers;
19333- current->exec_domain = old_domain;
19334- current->fs = old_fs;
19335- put_exec_domain(new_domain);
19336- put_fs_struct(new_fs);
19337- } else
19338-#endif
19339- {
19340- interpreter = open_exec(elf_interpreter);
19341- }
19342+
19343+ interpreter = open_exec(elf_interpreter);
19344+
19345 retval = PTR_ERR(interpreter);
19346 if (IS_ERR(interpreter))
19347 goto out_free_interp;
19348@@ -582,10 +559,6 @@
19349 current->flags &= ~PF_FORKNOEXEC;
19350 elf_entry = (unsigned long) elf_ex.e_entry;
19351
19352- /* Do this immediately, since STACK_TOP as used in setup_arg_pages
19353- may depend on the personality. */
19354- SET_PERSONALITY(elf_ex, ibcs2_interpreter);
19355-
19356 /* Do this so that we can load the interpreter, if need be. We will
19357 change some of these later */
19358 current->mm->rss = 0;
19359@@ -725,8 +698,7 @@
19360 printk("(brk) %lx\n" , (long) current->mm->brk);
19361 #endif
19362
19363- if ( current->personality == PER_SVR4 )
19364- {
19365+ if (current->personality & MMAP_PAGE_ZERO) {
19366 /* Why this, you ask??? Well SVr4 maps page 0 as read-only,
19367 and some applications "depend" upon this behavior.
19368 Since we do not have the power to recompile these, we
19369diff -uNr --exclude-from=dontdiff linux-2.4.3/fs/binfmt_xout.c linux/fs/binfmt_xout.c
19370--- linux-2.4.3/fs/binfmt_xout.c Thu Jan 1 01:00:00 1970
19371+++ linux/fs/binfmt_xout.c Sun Mar 18 18:41:16 2001
19372@@ -0,0 +1,804 @@
19373+/* $Id$
19374+ * binfmt_xout.c - support for the Microsoft Xenix x.out binary format
19375+ *
19376+ * Copyright (c) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
19377+ * Copyright (c) 2001 Christoph Hellwig (chhellwig@gmx.net)
19378+ *
19379+ * This file is based upon code written by Al Longyear for the COFF file
19380+ * format which is in turn based upon code written by Eric Youngdale for
19381+ * the ELF object file format. Any errors are most likely my own however.
19382+ */
19383+
19384+#include <linux/config.h>
19385+#include <linux/module.h>
19386+#include <linux/init.h>
19387+#include <linux/fs.h>
19388+#include <linux/sched.h>
19389+#include <linux/mm.h>
19390+#include <linux/mman.h>
19391+#include <linux/a.out.h>
19392+#include <linux/errno.h>
19393+#include <linux/signal.h>
19394+#include <linux/binfmts.h>
19395+#include <linux/string.h>
19396+#include <linux/fcntl.h>
19397+#include <linux/ptrace.h>
19398+#include <linux/personality.h>
19399+#include <linux/file.h>
19400+#include <linux/slab.h>
19401+
19402+#include <asm/uaccess.h>
19403+#include <asm/ldt.h>
19404+
19405+#include <abi/abi.h>
19406+#include <abi/xout.h>
19407+
19408+
19409+/*
19410+ * If you compile with dprintk defined to printk you will get
19411+ * lots of debugging messages from the x.out module.
19412+ */
19413+#define dprintk
19414+
19415+/*
19416+ * If you compile with XOUT_FORCE_PAGE defined (the default)
19417+ * then if all segments are aligned on 1k bounaries within the
19418+ * file and 4k boundaries within the address space we assume
19419+ * that no overlaps occur within the same VM page and the
19420+ * executable can thus be mmapped if the filesystem allows it.
19421+ * I believe this is the case for all 386 small model binaries,
19422+ * 286 binaries can't be demand paged.
19423+ */
19424+#define XOUT_FORCE_PAGE
19425+
19426+/*
19427+ * If you compile with XOUT_SEGMENTS defined the loader will take care
19428+ * to set up the LDT as would "real" Xenix. This shouldn't be necessary
19429+ * for most programs but it is just possible that something out there
19430+ * makes assumptions about its environment and uses segment overrides.
19431+ *
19432+ * The default is not to bother setting up the LDT unless we need support
19433+ * for Xenix 286 binaries.
19434+ */
19435+#undef XOUT_SEGMENTS
19436+
19437+/*
19438+ * Xenix 286 requires segment handling.
19439+ */
19440+#if defined(CONFIG_ABI_IBCS_X286) || defined(CONFIG_ABI_IBCS_X286)
19441+#define XOUT_SEGMENTS
19442+#endif
19443+
19444+
19445+static int xout_load_binary(struct linux_binprm *, struct pt_regs *);
19446+static int xout_load_library(struct file *);
19447+
19448+static struct linux_binfmt xout_format = {
19449+ NULL, THIS_MODULE, xout_load_binary, xout_load_library, NULL, PAGE_SIZE
19450+};
19451+
19452+
19453+#if defined(XOUT_DEBUG) && defined(XOUT_SEGMENTS)
19454+/*
19455+ * This is borrowed (with minor variations since we are in kernel mode)
19456+ * from the DPMI code for DOSEMU. I don't claim to understand LDTs :-).
19457+ */
19458+void
19459+print_desc(int which)
19460+{
19461+ u_long base_addr, limit;
19462+ u_long *lp;
19463+ int count, type, dpl, i;
19464+
19465+ if (which) {
19466+ lp = (u_long *)((struct desc_struct*)(current->mm->segments));
19467+ count = LDT_ENTRIES;
19468+ printk(KERN_DEBUG "xout: LDT\n");
19469+ } else {
19470+ lp = (u_long *)0x10c860; /* gdt; DANGER! MAGIC! */
19471+ count = 8;
19472+ printk(KERN_DEBUG "xout: GDT\n");
19473+ }
19474+
19475+ if (!lp)
19476+ return;
19477+
19478+ printk(KERN_DEBUG "XOUT: SLOT BASE/SEL LIM/OFF TYPE DPL ACCESSBITS\n");
19479+ for (i=0; i < count; i++, lp++) {
19480+ /* First 32 bits of descriptor */
19481+ base_addr = (*lp >> 16) & 0x0000FFFF;
19482+ limit = *lp & 0x0000FFFF;
19483+ lp++;
19484+
19485+ /* First 32 bits of descriptor */
19486+ base_addr |= (*lp & 0xFF000000) | ((*lp << 16) & 0x00FF0000);
19487+ limit |= (*lp & 0x000F0000);
19488+ type = (*lp >> 10) & 7;
19489+ dpl = (*lp >> 13) & 3;
19490+ if ((base_addr > 0) || (limit > 0 )) {
19491+ printk(KERN_DEBUG "XOUT: %03d 0x%08lx 0x%08lx 0x%02x %03d %s%s%s%s%s%s%s\n",
19492+ i,
19493+ base_addr, limit, type, dpl,
19494+ (*lp & 0x100) ? " ACCS'D" : "",
19495+ (*lp & 0x200) ? " R&W" : " R&X",
19496+ (*lp & 0x8000) ? " PRESENT" : "",
19497+ (*lp & 0x100000) ? " USER" : "",
19498+ (*lp & 0x200000) ? " X" : "",
19499+ (*lp & 0x400000) ? " 32" : "",
19500+ (*lp & 0x800000) ? " PAGES" : "");
19501+ }
19502+ }
19503+}
19504+#endif
19505+
19506+
19507+static u_long *
19508+xout_create_tables(char *p, struct linux_binprm *bprm, int ibcs)
19509+{
19510+ int argc = bprm->argc, envc = bprm->envc;
19511+ u_long *argv,*envp;
19512+ u_long *sp;
19513+
19514+ sp = (u_long *) ((-(u_long)sizeof(char *)) & (u_long) p);
19515+ sp -= envc+1;
19516+ envp = sp;
19517+ sp -= argc+1;
19518+ argv = sp;
19519+ if (!ibcs) {
19520+ sp--;
19521+ put_user(envp, sp);
19522+ sp--;
19523+ put_user(argv, sp);
19524+ }
19525+ sp--;
19526+ put_user(argc, sp);
19527+ current->mm->arg_start = (u_long) p;
19528+ while (argc-->0) {
19529+ put_user(p, argv); argv++;
19530+ p += strlen_user(p);
19531+ }
19532+ put_user(NULL,argv);
19533+ current->mm->arg_end = current->mm->env_start = (u_long) p;
19534+ while (envc-->0) {
19535+ put_user(p, envp); envp++;
19536+ p += strlen_user(p);
19537+ }
19538+ put_user(NULL,envp);
19539+ current->mm->env_end = (u_long) p;
19540+ return (sp);
19541+}
19542+
19543+
19544+
19545+
19546+/*
19547+ * If you compile with XOUT_FORCE_PAGE defined (the default)
19548+ * then if all segments are aligned on 1k bounaries within the
19549+ * file and 4k boundaries within the address space we assume
19550+ * that no overlaps occur within the same VM page and the
19551+ * executable can thus be mmapped if the filesystem allows it.
19552+ * I believe this is the case for all 386 small model binaries
19553+ * - which is all we support anyway.
19554+ */
19555+static __inline__ int
19556+isaligned(struct xseg *seg)
19557+{
19558+ dprintk(KERN_DEBUG
19559+ "xout: %04x %04x %04x %02x %08lx %08lx %08lx %08lx\n",
19560+ seg->xs_type, seg->xs_attr, seg->xs_seg,
19561+ seg->xs_align, seg->xs_filpos, seg->xs_psize,
19562+ seg->xs_vsize, seg->xs_rbase);
19563+
19564+#ifdef XOUT_FORCE_PAGE
19565+ /*
19566+ * XXXX The file alignment should be dependent on the block size
19567+ * of the filesystem shouldn't it?
19568+ */
19569+ if ((seg->xs_filpos & 0x3ff) | (seg->xs_rbase & ~PAGE_MASK))
19570+ printk(KERN_DEBUG "xout: bad alignment - demand paging disabled\n");
19571+ return ((seg->xs_filpos & 0x3ff) | (seg->xs_rbase & ~PAGE_MASK));
19572+#else
19573+ if ((seg->xs_filpos - seg->xs_rbase) & ~PAGE_MASK)
19574+ printk(KERN_DEBUG "xout: bad alignment - demand paging disabled\n");
19575+ return ((seg->xs_filpos - seg->xs_rbase) & ~PAGE_MASK);
19576+#endif
19577+}
19578+
19579+
19580+static __inline__ void
19581+clear_memory(u_long addr, u_long size)
19582+{
19583+ while (size-- != 0)
19584+ put_user(0, (char *)addr++);
19585+}
19586+
19587+static int
19588+xout_amen(struct file *fp, struct xseg *sp, int pageable)
19589+{
19590+#ifdef XOUT_SEGMENTS
19591+ struct desc_struct def_ldt;
19592+ modify_ldt_t ldt_info;
19593+ mm_segment_t old_fs;
19594+ int l;
19595+#endif
19596+ u_long bss_size, bss_base;
19597+ int err = 0;
19598+
19599+#ifdef XOUT_SEGMENTS
19600+ old_fs = get_fs();
19601+
19602+seg_again:
19603+ l = 0;
19604+
19605+ /*
19606+ * Xenix 386 segments simply map the whole address
19607+ * space either read-exec only or read-write.
19608+ */
19609+ ldt_info.entry_number = sp->xs_seg >> 3;
19610+ ldt_info.read_exec_only = 0 /* ((s->xs_attr & XS_APURE) ? 1 : 0) */;
19611+ ldt_info.contents = ((sp->xs_type == XS_TTEXT) ? 2 : 0);
19612+ ldt_info.seg_not_present = 0;
19613+ ldt_info.seg_32bit = ((sp->xs_attr & XS_A32BIT) ? 1 : 0);
19614+ if (!ldt_info.seg_32bit) {
19615+ ldt_info.base_addr = *addrp;
19616+ *addrp = PAGE_ALIGN(*addrp + sp->xs_vsize);
19617+ sp->xs_rbase = ldt_info.base_addr;
19618+ } else
19619+ ldt_info.base_addr = 0;
19620+#endif
19621+
19622+ bss_size = sp->xs_vsize - sp->xs_psize;
19623+ bss_base = sp->xs_rbase + sp->xs_psize;
19624+
19625+ /*
19626+ * If it is a text segment update the code boundary
19627+ * markers. If it is a data segment update the data
19628+ * boundary markers.
19629+ */
19630+ if (sp->xs_type == XS_TTEXT) {
19631+ if ((sp->xs_rbase + sp->xs_psize) > current->mm->end_code)
19632+ current->mm->end_code = (sp->xs_rbase + sp->xs_psize);
19633+ } else if (sp->xs_type == XS_TDATA) {
19634+#ifdef XOUT_SEGMENTS
19635+ /*
19636+ * If it is the first data segment note that
19637+ * this is the segment we start in. If this
19638+ * isn't a 386 binary add the stack to the
19639+ * top of this segment.
19640+ */
19641+ if ((xexec->x_cpu & XC_CPU) != XC_386) {
19642+ if (regs->ebx == regs->ecx) {
19643+ regs->ecx = s->xs_seg;
19644+ regs->edx = s->xs_vsize;
19645+ sp->xs_vsize = 0x10000;
19646+ *addrp = PAGE_ALIGN(ldt_info.base_addr + s->xs_vsize);
19647+ }
19648+ } else {
19649+ if (regs->xds == regs->xcs)
19650+ regs->xds = regs->xes = regs->xss = s->xs_seg;
19651+ }
19652+#endif
19653+ if ((sp->xs_rbase + sp->xs_psize) > current->mm->end_data)
19654+ current->mm->end_data = (sp->xs_rbase + sp->xs_psize);
19655+ }
19656+
19657+ if ((sp->xs_rbase + sp->xs_vsize) > current->mm->brk)
19658+ current->mm->start_brk =
19659+ current->mm->brk = PAGE_ALIGN(sp->xs_rbase + sp->xs_vsize);
19660+#ifdef XOUT_SEGMENTS
19661+ if (ldt_info.seg_32bit) {
19662+ ldt_info.limit = (TASK_SIZE-1) >> 12;
19663+ ldt_info.limit_in_pages = 1;
19664+ } else {
19665+ ldt_info.limit = s->xs_vsize-1;
19666+ ldt_info.limit_in_pages = 0;
19667+ }
19668+
19669+ dprintk(KERN_DEBUG "xout: ldt %02x, type=%d, base=0x%08lx, "
19670+ "limit=0x%08x, pages=%d, 32bit=%d\n",
19671+ ldt_info.entry_number, ldt_info.contents,
19672+ ldt_info.base_addr, ldt_info.limit,
19673+ ldt_info.limit_in_pages, ldt_info.seg_32bit);
19674+
19675+ /*
19676+ * Use the modify_ldt syscall since this allocates
19677+ * the initial space for the LDT table, tweaks the
19678+ * GDT etc. We need to read the current LDT first
19679+ * since we need to copy the lcall7 call gate.
19680+ */
19681+ set_fs(get_ds());
19682+ if (!current->mm->segments) {
19683+ SYS(modify_ldt)(0, &def_ldt, sizeof(def_ldt));
19684+ l = 1;
19685+ }
19686+
19687+ status = SYS(modify_ldt)(1, &ldt_info, sizeof(ldt_info));
19688+#if 0
19689+ if (status >= 0 && !ntext && s->xs_seg == 0x47) {
19690+ /* Uh oh, impure binary... */
19691+ ldt_info.entry_number = 0x3f >> 3;
19692+#if 0
19693+ ldt_info.read_exec_only = 1;
19694+#else
19695+ ldt_info.read_exec_only = 0;
19696+#endif
19697+ ldt_info.contents = 2;
19698+ status = SYS(modify_ldt)(1, &ldt_info, sizeof(ldt_info));
19699+ }
19700+#endif
19701+ set_fs(old_fs);
19702+ if (l == 1) {
19703+ l = 0;
19704+ ((struct desc_struct *)(current->mm->segments))[0].a = def_ldt.a;
19705+ ((struct desc_struct *)(current->mm->segments))[0].b = def_ldt.b;
19706+ }
19707+ if (status < 0)
19708+ printk(KERN_INFO "xout: modify_ldt returned %d\n", status);
19709+#endif
19710+
19711+ if (err < 0)
19712+ goto out;
19713+
19714+ if (!pageable) {
19715+ dprintk(KERN_DEBUG "xout: Null map 0x%08lx, length 0x%08lx\n",
19716+ sp->xs_rbase, sp->xs_vsize);
19717+ err = do_mmap(NULL, sp->xs_rbase, sp->xs_vsize,
19718+ PROT_READ|PROT_WRITE|PROT_EXEC,
19719+ MAP_FIXED|MAP_PRIVATE, 0);
19720+ goto out;
19721+ }
19722+
19723+ dprintk(KERN_DEBUG "xout: mmap to 0x%08lx from 0x%08lx, length 0x%08lx\n",
19724+ sp->xs_rbase, sp->xs_filpos, sp->xs_psize);
19725+ if (sp->xs_attr & XS_APURE) {
19726+ err = do_mmap(fp, sp->xs_rbase, sp->xs_psize,
19727+ PROT_READ|PROT_EXEC, MAP_FIXED|MAP_SHARED,
19728+ sp->xs_filpos);
19729+ } else {
19730+ err = do_mmap(fp, sp->xs_rbase, sp->xs_psize,
19731+ PROT_READ|PROT_WRITE|PROT_EXEC,
19732+ MAP_FIXED|MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
19733+ sp->xs_filpos);
19734+ }
19735+
19736+ if (err < 0)
19737+ goto out;
19738+
19739+ /*
19740+ * Map uninitialised data.
19741+ */
19742+ if (bss_size) {
19743+ if (bss_base & PAGE_MASK) {
19744+ clear_memory(bss_base, PAGE_ALIGN(bss_base)-bss_base);
19745+ bss_size -= (PAGE_ALIGN(bss_base) - bss_base);
19746+ bss_base = PAGE_ALIGN(bss_base);
19747+ }
19748+
19749+ dprintk(KERN_DEBUG "xout: Null map 0x%08lx, length 0x%08lx\n",
19750+ bss_base, bss_size);
19751+
19752+ err = do_mmap(NULL, bss_base, bss_size,
19753+ PROT_READ | PROT_WRITE | PROT_EXEC,
19754+ MAP_FIXED | MAP_PRIVATE, 0);
19755+ }
19756+
19757+out:
19758+#ifdef XOUT_SEGMENTS
19759+ if (err >= 0 && !ntext && ndata == 1 && sp->xs_seg >= 0x47) {
19760+ /*
19761+ * Uh oh, impure binary.
19762+ * Mirror this data segment to the text segment
19763+ */
19764+ addrp = mirror_addr = sp->xs_rbase;
19765+ sp->xs_seg = xext->xe_eseg;
19766+ sp->xs_type = XS_TTEXT;
19767+ goto seg_again;
19768+ }
19769+#endif
19770+ return (err);
19771+}
19772+
19773+/*
19774+ * Helper function to process the load operation.
19775+ */
19776+static int
19777+xout_load_object(struct linux_binprm * bpp, struct pt_regs *rp, int executable)
19778+{
19779+ struct xexec *xexec = (struct xexec *)bpp->buf;
19780+ struct xext *xext = (struct xext *)(xexec + 1);
19781+ struct xseg *seglist;
19782+ struct file *fp = NULL;
19783+ u_long addr, mirror_addr;
19784+ int nsegs, ntext, ndata;
19785+ int pageable = 1, err = 0;
19786+ int i;
19787+
19788+ dprintk(KERN_DEBUG "xout: binfmt_xout entry: %s\n",
19789+ bpp->file->f_dentry->d_name.name);
19790+
19791+ if (xexec->x_magic != X_MAGIC) {
19792+ dprintk(KERN_DEBUG "xout: bad magic %04x\n", xexec->x_magic);
19793+ return -ENOEXEC;
19794+ }
19795+
19796+ switch (xexec->x_cpu & XC_CPU) {
19797+ case XC_386:
19798+ break;
19799+#ifdef EMU_X286
19800+ case XC_8086:
19801+ case XC_286:
19802+ case XC_286V:
19803+ case XC_186:
19804+ break;
19805+#endif
19806+ default:
19807+ dprintk(KERN_DEBUG "xout: unsupported CPU type (%02x)\n",
19808+ xexec->x_cpu);
19809+ return -ENOEXEC;
19810+ }
19811+
19812+ /*
19813+ * We can't handle byte or word swapped headers. Well, we
19814+ * *could* but they should never happen surely?
19815+ */
19816+ if ((xexec->x_cpu & (XC_BSWAP | XC_WSWAP)) != XC_WSWAP) {
19817+ dprintk(KERN_DEBUG "xout: wrong byte or word sex (%02x)\n",
19818+ xexec->x_cpu);
19819+ return -ENOEXEC;
19820+ }
19821+
19822+ /* Check it's an executable. */
19823+ if (!(xexec->x_renv & XE_EXEC)) {
19824+ dprintk(KERN_DEBUG "xout: not executable\n");
19825+ return -ENOEXEC;
19826+ }
19827+
19828+ /*
19829+ * There should be an extended header and there should be
19830+ * some segments. At this stage we don't handle non-segmented
19831+ * binaries. I'm not sure you can get them under Xenix anyway.
19832+ */
19833+ if (xexec->x_ext != sizeof(struct xext)) {
19834+ dprintk(KERN_DEBUG "xout: bad extended header\n");
19835+ return -ENOEXEC;
19836+ }
19837+
19838+ if (!(xexec->x_renv & XE_SEG) || !xext->xe_segsize) {
19839+ dprintk(KERN_DEBUG "xout: not segmented\n");
19840+ return -ENOEXEC;
19841+ }
19842+
19843+ if (!(seglist = kmalloc(xext->xe_segsize, GFP_KERNEL))) {
19844+ printk(KERN_WARNING "xout: allocating segment list failed\n");
19845+ return -ENOMEM;
19846+ }
19847+
19848+ err = kernel_read(bpp->file, xext->xe_segpos,
19849+ (char *)seglist, xext->xe_segsize);
19850+ if (err < 0) {
19851+ dprintk(KERN_DEBUG "xout: problem reading segment table\n");
19852+ goto out;
19853+ }
19854+
19855+ if (!bpp->file->f_op->mmap)
19856+ pageable = 0;
19857+
19858+ nsegs = xext->xe_segsize / sizeof(struct xseg);
19859+
19860+ ntext = ndata = 0;
19861+ for (i=0; i<nsegs; i++) {
19862+ switch (seglist[i].xs_type) {
19863+ case XS_TTEXT:
19864+ if (!isaligned(seglist+i))
19865+ pageable = 0;
19866+ ntext++;
19867+ break;
19868+ case XS_TDATA:
19869+ if (!isaligned(seglist+i))
19870+ pageable = 0;
19871+ ndata++;
19872+ break;
19873+ }
19874+ }
19875+
19876+ if (!ndata)
19877+ goto out;
19878+
19879+ /*
19880+ * Generate the proper values for the text fields
19881+ *
19882+ * THIS IS THE POINT OF NO RETURN. THE NEW PROCESS WILL TRAP OUT SHOULD
19883+ * SOMETHING FAIL IN THE LOAD SEQUENCE FROM THIS POINT ONWARD.
19884+ */
19885+
19886+ /*
19887+ * Flush the executable from memory. At this point the executable is
19888+ * committed to being defined or a segmentation violation will occur.
19889+ */
19890+ if (executable) {
19891+ dprintk(KERN_DEBUG "xout: flushing executable\n");
19892+
19893+ flush_old_exec(bpp);
19894+
19895+ current->mm->mmap = NULL;
19896+ current->mm->rss = 0;
19897+
19898+ if ((err = setup_arg_pages(bpp)) < 0) {
19899+ send_sig(SIGSEGV, current, 1);
19900+ return (err);
19901+ }
19902+
19903+#ifdef EMU_X286
19904+ bpp->p = (u_long)xout_create_tables((char *)bpp->p, bpp,
19905+ (xexec->x_cpu & XC_CPU) == XC_386 ? 1 : 0);
19906+#else
19907+ bpp->p = (u_long)xout_create_tables((char *)bpp->p, bpp, 1);
19908+#endif
19909+
19910+ /*
19911+ * Do the end processing once the stack has been constructed
19912+ */
19913+#ifdef XOUT_SEGMENTS
19914+ /*
19915+ * These will be set up later once we've seen the
19916+ * segments that make the program up.
19917+ */
19918+ current->mm->start_code =
19919+ current->mm->end_code =
19920+ current->mm->end_data =
19921+ current->mm->start_brk =
19922+ current->mm->brk = 0;
19923+#else
19924+ current->mm->start_code = 0;
19925+ current->mm->end_code = xexec->x_text;
19926+ current->mm->end_data = xexec->x_text + xexec->x_data;
19927+ current->mm->start_brk =
19928+ current->mm->brk = xexec->x_text + xexec->x_data + xexec->x_bss;
19929+#endif
19930+ compute_creds(bpp);
19931+ current->flags &= ~PF_FORKNOEXEC;
19932+
19933+#ifdef XOUT_SEGMENTS
19934+ /*
19935+ * The code selector is advertised in the header.
19936+ */
19937+ if ((xexec->x_cpu & XC_CPU) != XC_386) {
19938+ regs->ebx = regs->ecx = xext->xe_eseg;
19939+ regs->eax = xexec->x_entry;
19940+ } else {
19941+ regs->xcs = regs->xds = regs->xes = regs->xss = xext->xe_eseg;
19942+ regs->eip = xexec->x_entry;
19943+ }
19944+#else
19945+ rp->xcs = __USER_CS;
19946+ rp->xds = rp->xes = rp->xss = __USER_DS;
19947+ rp->eip = xexec->x_entry;
19948+#endif
19949+
19950+ dprintk(KERN_DEBUG "xout: entry point = 0x%x:0x%08lx\n",
19951+ xext->xe_eseg, xexec->x_entry);
19952+
19953+ rp->esp = current->mm->start_stack = bpp->p;
19954+
19955+ set_personality(PER_XENIX);
19956+ }
19957+
19958+ /* Base address for mapping 16bit segments. This should lie above
19959+ * the emulator overlay.
19960+ */
19961+ addr = X286_MAP_ADDR;
19962+
19963+#ifdef EMU_X286
19964+ /* If this isn't a 386 executable we need to load the overlay
19965+ * library to emulate a [2]86 environment and save the binary
19966+ * headers for later reference by the emulator.
19967+ */
19968+ if ((xexec->x_cpu & XC_CPU) != XC_386) {
19969+ mm_segment_t old_fs = get_fs();
19970+
19971+ set_fs (get_ds ());
19972+ status = SYS(uselib)("/usr/lib/x286emul");
19973+ set_fs (old_fs);
19974+
19975+ status = do_mmap(NULL,
19976+ addr, sizeof(struct xexec)+sizeof(struct xext),
19977+ PROT_READ|PROT_WRITE|PROT_EXEC,
19978+ MAP_FIXED|MAP_PRIVATE,
19979+ 0);
19980+ if (status >= 0) {
19981+ copy_to_user((char *)addr, xexec, sizeof(struct xexec));
19982+ copy_to_user((char *)addr+sizeof(struct xexec), xext, sizeof(struct xext));
19983+ addr = PAGE_ALIGN(addr+sizeof(struct xexec)+sizeof(struct xext));
19984+ }
19985+ }
19986+#endif
19987+
19988+ /*
19989+ * Scan the segments and map them into the process space. If this
19990+ * executable is pageable (unlikely since Xenix aligns to 1k
19991+ * boundaries and we want it aligned to 4k boundaries) this is
19992+ * all we need to do. If it isn't pageable we go round again
19993+ * afterwards and load the data. We have to do this in two steps
19994+ * because if segments overlap within a 4K page we'll lose the
19995+ * first instance when we remap the page. Hope that's clear...
19996+ *
19997+ * N.B. If you compile with XOUT_FORCE_PAGE defined (the default)
19998+ * then if all segments are aligned on 1k bounaries within the
19999+ * file and 4k boundaries within the address space we assume
20000+ * that no overlaps occur within the same VM page and the
20001+ * executable can thus be mmapped if the filesystem allows it.
20002+ * I believe this is the case for all 386 small model binaries
20003+ * - which is all we support anyway.
20004+ */
20005+ mirror_addr = 0;
20006+
20007+ for (i = 0; err >= 0 && i < nsegs; i++) {
20008+ struct xseg *sp = seglist+i;
20009+
20010+ if (sp->xs_attr & XS_AMEM)
20011+ err = xout_amen(fp, sp, pageable);
20012+
20013+ }
20014+
20015+#if 0
20016+ if (addr > current->mm->brk)
20017+ current->mm->start_brk = current->mm->brk = addr;
20018+#endif
20019+
20020+ dprintk(KERN_DEBUG "xout: start code 0x%08lx, end code 0x%08lx,"
20021+ " end data 0x%08lx, brk 0x%08lx\n",
20022+ current->mm->start_code, current->mm->end_code,
20023+ current->mm->end_data, current->mm->brk);
20024+#ifdef XOUT_SEGMENTS
20025+ print_desc(1);
20026+ print_desc(0);
20027+#endif
20028+
20029+ if (pageable)
20030+ goto trap;
20031+ if (err < 0)
20032+ goto trap;
20033+
20034+ for (i = 0; (err >= 0) && (i < nsegs); i++) {
20035+ struct xseg *sp = seglist + i;
20036+ u_long psize;
20037+
20038+ if (sp->xs_type == XS_TTEXT || sp->xs_type == XS_TDATA) {
20039+ dprintk(KERN_DEBUG "xout: read to 0x%08lx from 0x%08lx,"
20040+ " length 0x%08lx\n", sp->xs_rbase,
20041+ sp->xs_filpos, sp->xs_psize);
20042+
20043+ if (sp->xs_psize < 0)
20044+ continue;
20045+
20046+ psize = kernel_read(bpp->file, sp->xs_filpos,
20047+ (char *)sp->xs_rbase, sp->xs_psize);
20048+
20049+ if (psize != sp->xs_psize) {
20050+ dprintk(KERN_DEBUG "xout: short read\n");
20051+ err = -1;
20052+ break;
20053+ }
20054+ }
20055+ }
20056+
20057+ /*
20058+ * Generate any needed trap for this process. If an error occured then
20059+ * generate a segmentation violation. If the process is being debugged
20060+ * then generate the load trap. (Note: If this is a library load then
20061+ * do not generate the trap here. Pass the error to the caller who
20062+ * will do it for the process in the outer lay of this procedure call.)
20063+ */
20064+trap:
20065+ if (executable) {
20066+ if (err < 0) {
20067+ dprintk(KERN_DEBUG "xout: loader forces seg fault "
20068+ "(err = %d)\n", err);
20069+ send_sig(SIGSEGV, current, 0);
20070+ } else if (current->ptrace & PT_PTRACED)
20071+ send_sig(SIGTRAP, current, 0);
20072+ err = 0;
20073+ }
20074+
20075+out:
20076+ kfree(seglist);
20077+
20078+ dprintk(KERN_DEBUG "xout: binfmt_xout: result = %d\n", err);
20079+
20080+ /*
20081+ * If we are using the [2]86 emulation overlay we enter this
20082+ * rather than the real program and give it the information
20083+ * it needs to start the ball rolling.
20084+ */
20085+ if ((xexec->x_cpu & XC_CPU) != XC_386) {
20086+#if 0
20087+ regs->eax = regs->eip;
20088+ regs->ebx = regs->xcs;
20089+ regs->ecx = regs->xds;
20090+ regs->xcs = __USER_CS;
20091+ regs->xds = regs->xes = regs->xss = __USER_DS;
20092+#endif
20093+ rp->eip = 0x1020;
20094+ dprintk(KERN_DEBUG "xout: x286emul 0x%02lx:0x%04lx,"
20095+ " ds=0x%02lx, stack 0x%02lx:0x%04lx\n",
20096+ rp->ebx, rp->eax, rp->ecx, rp->ecx,
20097+ rp->edx);
20098+#ifdef notdef
20099+ while (!signal_pending(current))
20100+ schedule();
20101+#endif
20102+ return (err < 0 ? err : rp->eax);
20103+ }
20104+
20105+#ifdef notdef
20106+ while (!signal_pending(current))
20107+ schedule();
20108+#endif
20109+ /*
20110+ * Xenix 386 programs expect the initial brk value to be in eax
20111+ * on start up. Hence if we succeeded we need to pass back
20112+ * the brk value rather than the status. Ultimately the
20113+ * ret_from_sys_call assembly will place this in eax before
20114+ * resuming (starting) the process.
20115+ */
20116+ return (err < 0 ? err : current->mm->brk);
20117+}
20118+
20119+
20120+/*
20121+ * This procedure is called by the main load sequence. It will load
20122+ * the executable and prepare it for execution. It provides the additional
20123+ * parameters used by the recursive xout loader and tells the loader that
20124+ * this is the main executable. How simple it is . . . .
20125+ */
20126+static int
20127+xout_load_binary(struct linux_binprm *bpp, struct pt_regs *rp)
20128+{
20129+ return (xout_load_object(bpp, rp, 1));
20130+}
20131+
20132+/*
20133+ * Load the image for any shared library. This is called when
20134+ * we need to load a library based upon a file name.
20135+ *
20136+ * XXX: I have never seen a Xenix shared library... --hch
20137+ */
20138+static int
20139+xout_load_library(struct file *fp)
20140+{
20141+ struct linux_binprm *bpp;
20142+ struct pt_regs regs;
20143+ int err = -ENOMEM;
20144+
20145+ if (!(bpp = kmalloc(sizeof(struct linux_binprm), GFP_KERNEL))) {
20146+ printk(KERN_WARNING "xout: kmalloc failed\n");
20147+ goto out;
20148+ }
20149+
20150+ memset(bpp, 0, sizeof(struct linux_binprm));
20151+ bpp->file = fp;
20152+
20153+ if ((err = kernel_read(fp, 0L, bpp->buf, sizeof(bpp->buf))) < 0)
20154+ printk(KERN_WARNING "xout: unable to read library header\n");
20155+ else
20156+ err = xout_load_object(bpp, &regs, 0);
20157+
20158+ kfree(bpp);
20159+out:
20160+ return (err);
20161+}
20162+
20163+static int __init
20164+binfmt_xout_init(void)
20165+{
20166+ return register_binfmt(&xout_format);
20167+}
20168+
20169+static void __exit
20170+binfmt_xout_exit(void)
20171+{
20172+ unregister_binfmt(&xout_format);
20173+}
20174+
20175+module_init(binfmt_xout_init);
20176+module_exit(binfmt_xout_exit);
20177diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/abi.h linux/include/abi/abi.h
20178--- linux-2.4.3/include/abi/abi.h Thu Jan 1 01:00:00 1970
20179+++ linux/include/abi/abi.h Fri Mar 30 15:23:49 2001
20180@@ -0,0 +1,295 @@
20181+ /*
20182+ * Function prototypes used by the iBCS2 emulator
20183+ *
20184+ * $Id$
20185+ * $Source$
20186+ */
20187+
20188+#ifndef __IBCS_IBCS_H__
20189+#define __IBCS_IBCS_H__
20190+#include <linux/ptrace.h> /* for pt_regs */
20191+#include <linux/sched.h>
20192+#include <linux/signal.h>
20193+#include <linux/unistd.h>
20194+#include <linux/config.h>
20195+
20196+#include <abi/stream.h>
20197+#include <abi/map.h>
20198+#include <asm/abi.h>
20199+
20200+/* This is straight from linux/fs/stat.c. It is required for
20201+ * proper NFS attribute caching (so it says there). Maybe the
20202+ * kernel should export it - but it is basically simple...
20203+ */
20204+static __inline__ int
20205+do_revalidate(struct dentry *dentry)
20206+{
20207+ struct inode *inode = dentry->d_inode;
20208+ if (inode->i_op && inode->i_op->revalidate)
20209+ return inode->i_op->revalidate(dentry);
20210+ return 0;
20211+}
20212+
20213+
20214+static inline unsigned short map_flags(unsigned short f, unsigned short map[])
20215+{
20216+ int i;
20217+ unsigned short m, r;
20218+
20219+ r = 0;
20220+ for (i=0,m=1; i < 16; i++,m<<=1)
20221+ if (f & m)
20222+ r |= map[i];
20223+
20224+ return r;
20225+}
20226+
20227+
20228+/* XXX anyone has an idea how to make gcc shut up about this? */
20229+typedef int (*sysfun_p)();
20230+
20231+extern sysfun_p sys_call_table[];
20232+
20233+#define SYS(name) (sys_call_table[__NR_##name])
20234+
20235+
20236+/*
20237+ * the function prefix sys_... are used by linux in native mode.
20238+ * abi_, svr4_, sol_, uw7_ and ibcs_... are emulation interfaces for routines that
20239+ * differ from iBCS2 and linux. The xnx_... are xenix routines.
20240+ */
20241+typedef struct abi_function {
20242+ void * kfunc; /* function to call (sys_..., ibcs_... or xnx_...)
20243+ * or pointer to a sub class.
20244+ */
20245+ short nargs; /* number of args to kfunc or Ukn, Spl or Fast */
20246+ short trace; /* trace function we can turn tracing on or off */
20247+ char * name; /* name of function (for tracing) */
20248+ char * args; /* how to print the arg list (see plist) */
20249+} ABI_func;
20250+
20251+struct ibcs_statfs {
20252+ short f_type;
20253+ long f_bsize;
20254+ long f_frsize;
20255+ long f_blocks;
20256+ long f_bfree;
20257+ long f_files;
20258+ long f_ffree;
20259+ char f_fname[6];
20260+ char f_fpack[6];
20261+};
20262+
20263+
20264+#ifdef __sparc__
20265+
20266+typedef struct {
20267+ long tv_sec;
20268+ long tv_nsec;
20269+} timestruct_t;
20270+
20271+struct ibcs_stat {
20272+ unsigned long st_dev;
20273+ long st_pad1[3]; /* network id */
20274+ unsigned long st_ino;
20275+ unsigned long st_mode;
20276+ unsigned long st_nlink;
20277+ unsigned long st_uid;
20278+ unsigned long st_gid;
20279+ unsigned long st_rdev;
20280+ long st_pad2[2];
20281+ long st_size;
20282+ long st_pad3; /* st_size, off_t expansion */
20283+ timestruct_t st_atime;
20284+ timestruct_t st_mtime;
20285+ timestruct_t st_ctime;
20286+ long st_blksize;
20287+ long st_blocks;
20288+ char st_fstype[16];
20289+ long st_pad4[8]; /* expansion area */
20290+};
20291+#else
20292+struct ibcs_stat {
20293+ unsigned short st_dev;
20294+ unsigned short st_ino;
20295+ unsigned short st_mode;
20296+ unsigned short st_nlink;
20297+ unsigned short st_uid;
20298+ unsigned short st_gid;
20299+ unsigned short st_rdev;
20300+ unsigned long st_size;
20301+ unsigned long st_atime;
20302+ unsigned long st_mtime;
20303+ unsigned long st_ctime;
20304+};
20305+#endif
20306+
20307+
20308+struct ibcs_iovec {
20309+ unsigned long addr;
20310+ int len;
20311+};
20312+
20313+/* coff.c */
20314+extern int abi_brk(unsigned long newbrk);
20315+extern int abi_lseek(int fd, unsigned long offset, int whence);
20316+extern int abi_fork(struct pt_regs * regs);
20317+extern int abi_pipe(struct pt_regs * regs);
20318+extern int abi_getpid(struct pt_regs * regs);
20319+extern int abi_getuid(struct pt_regs * regs);
20320+extern int abi_getgid(struct pt_regs * regs);
20321+extern int abi_wait(struct pt_regs * regs);
20322+extern int ibcs_execv(struct pt_regs * regs);
20323+extern int abi_exec(struct pt_regs * regs);
20324+extern int abi_read(int fd, char *buf, int nbytes);
20325+extern int abi_procids(struct pt_regs * regs);
20326+extern int abi_select(int n, void *rfds, void *wfds, void *efds,
20327+ struct timeval *t);
20328+extern int abi_time(void);
20329+extern int ibcs_writev(int fd, struct ibcs_iovec *it, int n);
20330+
20331+extern int abi_syscall(struct pt_regs *regs);
20332+
20333+/* open.c */
20334+extern int abi_mkdir(const char *fname, int mode);
20335+extern int abi_mknod(const char *fname, int mode, int dev);
20336+
20337+/* secureware.c */
20338+extern int sw_security(int cmd, void *p1, void *p2, void *p3, void *p4, void *p5);
20339+
20340+/* signal.c */
20341+/* For mapping signal numbers */
20342+void deactivate_signal(struct task_struct *task, int signum);
20343+extern int abi_sigfunc(struct pt_regs * regs);
20344+extern int abi_kill(int pid, int sig);
20345+
20346+/* stat.c */
20347+extern int abi_stat(char * filename, struct ibcs_stat * statbuf);
20348+extern int abi_lstat(char * filename, struct ibcs_stat * statbuf);
20349+extern int abi_fstat(unsigned int fd, struct ibcs_stat * statbuf);
20350+
20351+/* svr4.c */
20352+struct svr4_siginfo {
20353+ int si_signo;
20354+ int si_code;
20355+ int si_errno;
20356+ union {
20357+ struct { /* kill(), SIGCLD */
20358+ long _pid;
20359+ union {
20360+ struct {
20361+ long _uid;
20362+ } _kill;
20363+ struct {
20364+ long _utime;
20365+ int _status;
20366+ long _stime;
20367+ } _cld;
20368+ } _pdata;
20369+ } _proc;
20370+ struct { /* SIGSEGV, SIGBUS, SIGILL, SIGFPE */
20371+ char *_addr;
20372+ } _fault;
20373+ struct { /* SIGPOLL, SIGXFSZ */
20374+ int _fd;
20375+ long _band;
20376+ } _file;
20377+ } _data;
20378+};
20379+#define SVR4_CLD_EXITED 1
20380+#define SVR4_CLD_KILLED 2
20381+#define SVR4_CLD_DUMPED 3
20382+#define SVR4_CLD_TRAPPED 4
20383+#define SVR4_CLD_STOPPED 5
20384+#define SVR4_CLD_CONTINUED 6
20385+extern int svr4_getgroups(int n, unsigned long *buf);
20386+extern int svr4_setgroups(int n, unsigned long *buf);
20387+extern int svr4_waitid(int idtype, int id, struct svr4_siginfo *infop, int options);
20388+extern int svr4_access(char *path, int mode);
20389+
20390+/* sysconf.c */
20391+extern int ibcs_sysconf(int name);
20392+
20393+/* utsname.c */
20394+extern int abi_utsname(unsigned long addr);
20395+extern int sco_utsname(unsigned long addr);
20396+extern int v7_utsname(unsigned long addr);
20397+
20398+/* socket.c */
20399+extern int abi_do_setsockopt(unsigned long *sp);
20400+extern int abi_do_getsockopt(unsigned long *sp);
20401+
20402+/* wysev386.c */
20403+extern int abi_gethostname(char *name, int len);
20404+extern int abi_getdomainname(char *name, int len);
20405+extern int abi_wait3(int *loc);
20406+extern int abi_socket(struct pt_regs *regs);
20407+extern int abi_connect(struct pt_regs *regs);
20408+extern int abi_accept(struct pt_regs *regs);
20409+extern int abi_send(struct pt_regs *regs);
20410+extern int abi_recv(struct pt_regs *regs);
20411+extern int abi_bind(struct pt_regs *regs);
20412+extern int abi_setsockopt(struct pt_regs *regs);
20413+extern int abi_listen(struct pt_regs *regs);
20414+extern int abi_getsockopt(struct pt_regs *regs);
20415+extern int abi_recvfrom(struct pt_regs *regs);
20416+extern int abi_sendto(struct pt_regs *regs);
20417+extern int abi_shutdown(struct pt_regs *regs);
20418+extern int abi_socketpair(struct pt_regs *regs);
20419+extern int abi_getpeername(struct pt_regs *regs);
20420+extern int abi_getsockname(struct pt_regs *regs);
20421+
20422+/* ioctl.c */
20423+extern int bsd_ioctl_termios(int fd, unsigned int func, void *arg);
20424+
20425+/* signal.c */
20426+extern int abi_sigsuspend(struct pt_regs *regs);
20427+
20428+/* From wysev386i.c */
20429+extern int wv386_ioctl(int fd, unsigned int ioctl_num, void *arg);
20430+
20431+/* From socksys.c */
20432+extern int socksys_major;
20433+extern void inherit_socksys_funcs(unsigned int fd, int state);
20434+extern int abi_socksys_fd_init(int fd, int rw, const char *buf, int *count);
20435+extern int socksys_syscall(int *sp);
20436+extern int abi_ioctl_socksys(int fd, unsigned int cmd, void *arg);
20437+
20438+
20439+/* From sysisc.c */
20440+extern int isc_setostype(int);
20441+
20442+/* From vtkd.c */
20443+extern int ibcs_ioctl_vtkd(int, int, void *);
20444+
20445+
20446+
20447+#define SC(name) (void *)__NR_##name
20448+#define ITR(trace, name, args) ,trace,name,args
20449+
20450+
20451+/* This table contains the appropriate kernel routines that can be run
20452+ * to perform the syscalls in question. If an entry is 'Ukn' we don't
20453+ * know how to handle it yet. (We also set trace on by default for these)
20454+ * Spl means that we need to do special processing for this syscall
20455+ * (see ibcs_wait or ibcs_getpid)
20456+ * Fast means that even the error return handling is done by the function call.
20457+ */
20458+#define ZERO 0x64 /* Um, magic zero for callmap. Don't ask :-). */
20459+#define Spl 0x65 /* pass the regs structure down */
20460+#define Ukn 0x66 /* no code to handle this case yet */
20461+#define Fast 0x67 /* magic on return, return regs structure already set up */
20462+
20463+void abi_dispatch(struct pt_regs *regs, ABI_func *p, int offset);
20464+
20465+
20466+/* Translate the errno numbers from linux to current personality.
20467+ * This should be removed and all other sources changed to call the
20468+ * map function above directly.
20469+ */
20470+static inline int iABI_errors(int lnx_errno)
20471+{
20472+ return map_value(current->exec_domain->err_map, lnx_errno, 1);
20473+}
20474+
20475+#endif /* __IBCS_IBCS_H__ */
20476diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/abi4.h linux/include/abi/abi4.h
20477--- linux-2.4.3/include/abi/abi4.h Thu Jan 1 01:00:00 1970
20478+++ linux/include/abi/abi4.h Mon Mar 12 16:35:05 2001
20479@@ -0,0 +1,147 @@
20480+/*
20481+ * These are defined to enable their inclsion in the branch table
20482+ * defined below.
20483+ *
20484+ * Hacked by Eric Youngdale for iBCS (1993, 1994).
20485+ *
20486+ * $Id$
20487+ * $Source$
20488+ */
20489+
20490+#ifndef __ABI_ABI_H__
20491+#define __ABI_ABI_H__
20492+#include <abi/svr4sig.h>
20493+
20494+typedef unsigned long ABI_dev_t;
20495+typedef unsigned long ABI_ino_t;
20496+typedef unsigned long ABI_mode_t;
20497+typedef unsigned long ABI_nlink_t;
20498+typedef long ABI_uid_t;
20499+typedef long ABI_off_t;
20500+typedef struct timeval ABI_timestruc_t;
20501+
20502+
20503+struct abi_sigaction {
20504+ int sa_flags;
20505+ __sighandler_t sa_handler;
20506+ unsigned long sa_mask;
20507+ int sa_resv[2]; /* Reserved for something or another */
20508+};
20509+#define ABI_SA_ONSTACK 1
20510+#define ABI_SA_RESETHAND 2
20511+#define ABI_SA_RESTART 4
20512+#define ABI_SA_SIGINFO 8
20513+#define ABI_SA_NODEFER 16
20514+#define ABI_SA_NOCLDWAIT 0x10000
20515+#define ABI_SA_NOCLDSTOP 0x20000
20516+
20517+
20518+struct sco_sigaction {
20519+ void (*sa_handler)(int);
20520+ unsigned long sa_mask;
20521+ int sa_flags;
20522+};
20523+#define SCO_SA_NOCLDSTOP 0x001
20524+#define SCO_SA_COMPAT 0x080 /* 3.2.2 compatibilty. Like SA_SIGNAL? */
20525+#define SCO_SA_SIGNAL 0x100
20526+
20527+
20528+extern int abi_sigaction(int abi_signum, const struct abi_sigaction * action,
20529+ struct abi_sigaction * oldaction);
20530+extern int sco_sigaction(int sco_signum, const struct sco_sigaction * action,
20531+ struct sco_sigaction * oldaction);
20532+extern int abi_sigprocmask(int how, unsigned long *set, unsigned long *oset);
20533+extern int abi_sigsuspend(struct pt_regs * regs);
20534+
20535+
20536+/*
20537+ * This is the general form of the stat structure in an ABI compliant system.
20538+ */
20539+
20540+struct svr4_xstat {
20541+ ABI_dev_t st_dev;
20542+ long st_pad1[3];
20543+ ABI_ino_t st_ino;
20544+ ABI_mode_t st_mode;
20545+ ABI_nlink_t st_nlink;
20546+ ABI_uid_t st_uid;
20547+ ABI_uid_t st_gid;
20548+ ABI_dev_t st_rdev;
20549+ long st_pad2[2];
20550+ ABI_off_t st_size;
20551+ long st_pad3;
20552+ ABI_timestruc_t st_atim;
20553+ ABI_timestruc_t st_mtim;
20554+ ABI_timestruc_t st_ctim;
20555+ long st_blksize;
20556+ long st_blocks;
20557+ char st_fstype[ 16 ] ;
20558+ long st_pad4[8];
20559+};
20560+
20561+/*
20562+ * Structure used by statvfs syscall.
20563+ */
20564+struct abi_statvfs {
20565+ unsigned long f_bsize; /* blocksize */
20566+ unsigned long f_frsize; /* fragment size. */
20567+ unsigned long f_blocks;
20568+ unsigned long f_bfree;
20569+ unsigned long f_bavail;
20570+ unsigned long f_files;
20571+ unsigned long f_free;
20572+ unsigned long f_sid;
20573+ char f_basetype[16];
20574+ unsigned long f_flag;
20575+ unsigned long f_namemax;
20576+ char f_fstr[32];
20577+ unsigned long f_filler[16];
20578+};
20579+
20580+struct sco_statvfs {
20581+ unsigned long f_bsize; /* blocksize */
20582+ unsigned long f_frsize; /* fragment size. */
20583+ unsigned long f_blocks;
20584+ unsigned long f_bfree;
20585+ unsigned long f_bavail;
20586+ unsigned long f_files;
20587+ unsigned long f_free;
20588+ unsigned long f_favail;
20589+ unsigned long f_sid;
20590+ char f_basetype[16];
20591+ unsigned long f_flag;
20592+ unsigned long f_namemax;
20593+ char f_fstr[32];
20594+ unsigned long f_filler[16];
20595+};
20596+
20597+extern int svr4_xstat(int vers, char * path, void * buf);
20598+extern int svr4_lxstat(int vers, char * path, void * buf);
20599+extern int svr4_xmknod(int vers, const char * path, mode_t mode, dev_t dev);
20600+
20601+extern int abi_statvfs(char * path, void * buf);
20602+extern int abi_fstatvfs(int fd, void * buf);
20603+
20604+
20605+
20606+int svr4_fpathconf(int fd, int name);
20607+int svr4_pathconf(char *path, int name);
20608+int svr4_sigpending (int which_routine, svr4_sigset_t *set);
20609+int svr4_context (struct pt_regs *regs);
20610+int svr4_ioctl(struct pt_regs *regs);
20611+
20612+/* POSIX.1 names */
20613+#define _PC_LINK_MAX 1
20614+#define _PC_MAX_CANON 2
20615+#define _PC_MAX_INPUT 3
20616+#define _PC_NAME_MAX 4
20617+#define _PC_PATH_MAX 5
20618+#define _PC_PIPE_BUF 6
20619+#define _PC_NO_TRUNC 7
20620+#define _PC_VDISABLE 8
20621+#define _PC_CHOWN_RESTRICTED 9
20622+/* POSIX.4 names */
20623+#define _PC_ASYNC_IO 10
20624+#define _PC_PRIO_IO 11
20625+#define _PC_SYNC_IO 12
20626+#endif
20627diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/bsd.h linux/include/abi/bsd.h
20628--- linux-2.4.3/include/abi/bsd.h Thu Jan 1 01:00:00 1970
20629+++ linux/include/abi/bsd.h Mon Mar 12 16:35:05 2001
20630@@ -0,0 +1,128 @@
20631+/*
20632+ * Function prototypes used by the BSD emulator
20633+ *
20634+ * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
20635+ *
20636+ * $Id$
20637+ * $Source$
20638+ */
20639+
20640+/* Ioctl's have the command encoded in the lower word, and the size of
20641+ * any in or out parameters in the upper word. The high 3 bits of the
20642+ * upper word are used to encode the in/out status of the parameter.
20643+ * Note that Linux does the same but has the IOC_IN and IOC_OUT values
20644+ * round the other way and uses 0 for IOC_VOID.
20645+ */
20646+#define BSD_IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */
20647+#define BSD_IOC_VOID 0x20000000 /* no parameters */
20648+#define BSD_IOC_OUT 0x40000000 /* copy out parameters */
20649+#define BSD_IOC_IN 0x80000000 /* copy in parameters */
20650+#define BSD_IOC_INOUT (BSD_IOC_IN|BSD_IOC_OUT)
20651+
20652+#define BSD__IOC(inout,group,num,len) \
20653+ (inout | ((len & BSD_IOCPARM_MASK) << 16) | ((group) << 8) | (num))
20654+#define BSD__IO(g,n) BSD__IOC(BSD_IOC_VOID, (g), (n), 0)
20655+#define BSD__IOR(g,n,t) BSD__IOC(BSD_IOC_OUT, (g), (n), sizeof(t))
20656+#define BSD__IOW(g,n,t) BSD__IOC(BSD_IOC_IN, (g), (n), sizeof(t))
20657+#define BSD__IOWR(g,n,t) BSD__IOC(BSD_IOC_INOUT, (g), (n), sizeof(t))
20658+
20659+/* Some SYSV systems exhibit "compatible" BSD ioctls without the bumf. */
20660+#define BSD__IOV(c,d) (((c) << 8) | (d))
20661+
20662+
20663+
20664+#include <linux/limits.h>
20665+
20666+
20667+/* Some BSD values have been extended to 64 bit types... */
20668+typedef long long quad;
20669+
20670+/* From bsd.c */
20671+extern int bsd_getpagesize(void);
20672+extern int bsd_geteuid(void);
20673+extern int bsd_getegid(void);
20674+extern int bsd_sbrk(unsigned long n);
20675+extern int bsd_getdtablesize(void);
20676+extern int bsd_killpg(int pgrp, int sig);
20677+extern int bsd_setegid(int egid);
20678+extern int bsd_seteuid(int euid);
20679+extern int bsd_open(const char * fname, int flag, int mode);
20680+extern int bsd_fcntl(struct pt_regs *regs);
20681+extern int bsd_ioctl(struct pt_regs *regs);
20682+
20683+/* From bsdioctl.c */
20684+extern int bsd_ioctl_termios(int fd, unsigned int func, void *arg);
20685+
20686+/* From bsdsignal.c */
20687+#define BSD_SA_ONSTACK 0x0001
20688+#define BSD_SA_RESTART 0x0002
20689+#define BSD_SA_NOCLDSTOP 0x0004
20690+struct bsd_sigaction {
20691+ void (*sa_handler)(int);
20692+ unsigned int sa_mask;
20693+ int sa_flags;
20694+};
20695+extern int bsd_sigaction(int bsd_signum, const struct bsd_sigaction *action,
20696+ struct bsd_sigaction *oldaction);
20697+extern int bsd_sigprocmask(int how, unsigned long bsdnset, unsigned long *bsdoset);
20698+extern int bsd_sigpending(unsigned long *set);
20699+
20700+/* From bsdsocket.c */
20701+extern int bsd_connect(struct pt_regs *regs);
20702+
20703+/* From bsdstat.c */
20704+struct bsd_stat {
20705+ unsigned short st_dev;
20706+ unsigned long st_ino;
20707+ unsigned short st_mode;
20708+ unsigned short st_nlink;
20709+ unsigned short st_uid;
20710+ unsigned short st_gid;
20711+ unsigned short st_rdev;
20712+ unsigned long st_size;
20713+ unsigned long st_atime;
20714+ unsigned long st_spare1;
20715+ unsigned long st_mtime;
20716+ unsigned long st_spare2;
20717+ unsigned long st_ctime;
20718+ unsigned long st_spare3;
20719+ unsigned long st_blksize;
20720+ unsigned long st_blocks;
20721+ unsigned long st_flags;
20722+ unsigned long st_gen;
20723+};
20724+extern int bsd_stat(char *filename, struct bsd_stat *st);
20725+extern int bsd_lstat(char *filename, struct bsd_stat *st);
20726+extern int bsd_fstat(unsigned int fd, struct bsd_stat *st);
20727+
20728+
20729+#define MNAMELEN 90 /* length of buffer for returned name */
20730+
20731+struct bsd_statfs {
20732+ short f_type; /* type */
20733+ short f_flags; /* copy of mount flags */
20734+ long f_fsize; /* fundamental file system block size */
20735+ long f_bsize; /* optimal transfer block size */
20736+ long f_blocks; /* total data blocks in file system */
20737+ long f_bfree; /* free blocks in fs */
20738+ long f_bavail; /* free blocks avail to non-superuser */
20739+ long f_files; /* total file nodes in file system */
20740+ long f_ffree; /* free file nodes in fs */
20741+ quad f_fsid; /* file system id */
20742+ long f_spare[9]; /* spare for later */
20743+ char f_mntonname[MNAMELEN]; /* directory on which mounted */
20744+ char f_mntfromname[MNAMELEN];/* mounted filesystem */
20745+};
20746+extern int bsd_statfs(const char *path, struct bsd_statfs *buf);
20747+extern int bsd_fstatfs(unsigned int fd, struct bsd_statfs *buf);
20748+
20749+
20750+#define MAXNAMELEN NAME_MAX
20751+
20752+struct bsd_dirent {
20753+ unsigned long d_fileno;
20754+ unsigned short d_reclen;
20755+ unsigned short d_namlen;
20756+ char d_name[MAXNAMELEN+1];
20757+};
20758+extern int bsd_getdirentries(int fd, char *buf, int nbytes, char *end_posn);
20759diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/lfs.h linux/include/abi/lfs.h
20760--- linux-2.4.3/include/abi/lfs.h Thu Jan 1 01:00:00 1970
20761+++ linux/include/abi/lfs.h Mon Mar 12 16:35:05 2001
20762@@ -0,0 +1,69 @@
20763+/* Large File Summit support functions */
20764+
20765+#ifndef __IBCS_LFS_H__
20766+
20767+#include <abi/abi.h>
20768+#include <abi/svr4sig.h>
20769+
20770+struct sol_stat64 {
20771+ unsigned long st_dev;
20772+ long st_pad1[3]; /* reserve for dev expansion */
20773+ /* sysid definition */
20774+ unsigned long long st_ino;
20775+ unsigned long st_mode;
20776+ unsigned long st_nlink;
20777+ unsigned long st_uid;
20778+ unsigned long st_gid;
20779+ unsigned long st_rdev;
20780+ long st_pad2[2];
20781+ unsigned long long st_size; /* large file support */
20782+ unsigned long st_atime;
20783+ unsigned long st_mtime;
20784+ unsigned long st_ctime;
20785+ long st_blksize;
20786+ long long st_blocks; /* large file support */
20787+ char st_fstype[16];
20788+ long st_pad4[8]; /* expansion area */
20789+};
20790+
20791+struct sol_dirent64 {
20792+ unsigned long long d_ino;
20793+ unsigned long long d_off;
20794+ unsigned short d_reclen;
20795+ char d_name[1];
20796+};
20797+
20798+int sol_stat64(char * filename, struct sol_stat64 * statbuf);
20799+int sol_lstat64(char * filename, struct sol_stat64 * statbuf);
20800+int sol_fstat64(unsigned int fd, struct sol_stat64 * statbuf);
20801+int sol_open64(const char *fname, int flag, int mode);
20802+int sol_getdents64(int fd, char *buf, int nbytes);
20803+int sol_mmap64(unsigned vaddr, unsigned vsize, int prot, int flags,
20804+ int fd, unsigned int off_hi, unsigned file_offset);
20805+
20806+/* version 4 (UW7_STAT64_VERSION) stat structure */
20807+struct uw7_stat64 {
20808+ unsigned long st_dev;
20809+ long st_pad1[3];
20810+ unsigned long long st_ino;
20811+ unsigned long st_mode;
20812+ unsigned long st_nlink;
20813+ long st_uid;
20814+ long st_gid;
20815+ unsigned long st_rdev;
20816+ long st_pad2[2];
20817+ long long st_size;
20818+ struct timeval st_atime;
20819+ struct timeval st_mtime;
20820+ struct timeval st_ctime;
20821+ long st_blksize;
20822+ long long st_blocks;
20823+ char st_fstype[16];
20824+ int st_aclcnt;
20825+ unsigned long st_level;
20826+ unsigned long st_flags; /* may contain MLD flag */
20827+ unsigned long st_cmwlevel;
20828+ long st_pad4[4];
20829+};
20830+
20831+#endif /* __IBCS_LFS_H__ */
20832diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/map.h linux/include/abi/map.h
20833--- linux-2.4.3/include/abi/map.h Thu Jan 1 01:00:00 1970
20834+++ linux/include/abi/map.h Mon Mar 12 16:35:05 2001
20835@@ -0,0 +1,24 @@
20836+/*
20837+ * include/abi/map.h
20838+ *
20839+ * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
20840+ *
20841+ * $Id$
20842+ * $Source$
20843+ */
20844+
20845+#ifndef __ABI_MAP_H__
20846+#define __ABI_MAP_H__
20847+
20848+struct map_segment {
20849+ int start, end;
20850+ unsigned char *map;
20851+};
20852+
20853+
20854+extern long map_bitvec(unsigned long vec, long map[]);
20855+extern unsigned long map_sigvec_from_kernel(sigset_t vec, unsigned long map[]);
20856+extern sigset_t map_sigvec_to_kernel(unsigned long vec, unsigned long map[]);
20857+extern int map_value(struct map_segment *m, int val, int def);
20858+
20859+#endif
20860diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/signal.h linux/include/abi/signal.h
20861--- linux-2.4.3/include/abi/signal.h Thu Jan 1 01:00:00 1970
20862+++ linux/include/abi/signal.h Mon Mar 12 16:35:05 2001
20863@@ -0,0 +1,75 @@
20864+#define NSIGNALS 32
20865+
20866+
20867+/* These are the signal numbers for the SVr4 signal handling */
20868+#define IBCS_SIGHUP 1
20869+#define IBCS_SIGINT 2
20870+#define IBCS_SIGQUIT 3
20871+#define IBCS_SIGILL 4
20872+#define IBCS_SIGTRAP 5
20873+#define IBCS_SIGIOT 6
20874+#define IBCS_SIGABRT 6
20875+#define IBCS_SIGEMT 7
20876+#define IBCS_SIGFPE 8
20877+#define IBCS_SIGKILL 9
20878+#define IBCS_SIGBUS 10
20879+#define IBCS_SIGSEGV 11
20880+#define IBCS_SIGSYS 12
20881+#define IBCS_SIGPIPE 13
20882+#define IBCS_SIGALRM 14
20883+#define IBCS_SIGTERM 15
20884+#define IBCS_SIGUSR1 16
20885+#define IBCS_SIGUSR2 17
20886+#define IBCS_SIGCLD 18
20887+#define IBCS_SIGCHLD 18
20888+#define IBCS_SIGPWR 19
20889+#define IBCS_SIGWINCH 20
20890+#define IBCS_SIGURG 21 /* not SCO, SCO uses SIGUSR2 for SIGURG */
20891+#define IBCS_SIGPOLL 22
20892+#define IBCS_SIGIO 22
20893+#define IBCS_SIGSTOP 23
20894+#define IBCS_SIGTSTP 24
20895+#define IBCS_SIGCONT 25
20896+#define IBCS_SIGTTIN 26
20897+#define IBCS_SIGTTOU 27
20898+#define IBCS_SIGVTALRM 28
20899+#define IBCS_SIGPROF 29
20900+#define IBCS_SIGGXCPU 30
20901+#define IBCS_SIGGXFSZ 31
20902+
20903+#define ISC_SIGSTOP 24
20904+#define ISC_SIGTSTP 25
20905+#define ISC_SIGCONT 23
20906+
20907+/* These are the signal numbers used by BSD. */
20908+#define BSD_SIGHUP 1
20909+#define BSD_SIGINT 2
20910+#define BSD_SIGQUIT 3
20911+#define BSD_SIGILL 4
20912+#define BSD_SIGTRAP 5
20913+#define BSD_SIGABRT 6
20914+#define BSD_SIGEMT 7
20915+#define BSD_SIGFPE 8
20916+#define BSD_SIGKILL 9
20917+#define BSD_SIGBUS 10
20918+#define BSD_SIGSEGV 11
20919+#define BSD_SIGSYS 12
20920+#define BSD_SIGPIPE 13
20921+#define BSD_SIGALRM 14
20922+#define BSD_SIGTERM 15
20923+#define BSD_SIGURG 16
20924+#define BSD_SIGSTOP 17
20925+#define BSD_SIGTSTP 18
20926+#define BSD_SIGCONT 19
20927+#define BSD_SIGCHLD 20
20928+#define BSD_SIGTTIN 21
20929+#define BSD_SIGTTOU 22
20930+#define BSD_SIGIO 23
20931+#define BSD_SIGXCPU 24
20932+#define BSD_SIGXFSZ 25
20933+#define BSD_SIGVTALRM 26
20934+#define BSD_SIGPROF 27
20935+#define BSD_SIGWINCH 28
20936+#define BSD_SIGINFO 29
20937+#define BSD_SIGUSR1 30
20938+#define BSD_SIGUSR2 31
20939diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/socket.h linux/include/abi/socket.h
20940--- linux-2.4.3/include/abi/socket.h Thu Jan 1 01:00:00 1970
20941+++ linux/include/abi/socket.h Mon Mar 12 16:35:05 2001
20942@@ -0,0 +1,19 @@
20943+/*
20944+ * include/abi/socket.h
20945+ *
20946+ * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
20947+ *
20948+ * $Id$
20949+ * $Source$
20950+ */
20951+
20952+/* Linux spells this differently. */
20953+#define SO_ACCEPTCONN SO_ACCEPTCON
20954+
20955+/* These aren't (currently) defined by Linux. Watch out for warnings
20956+ * about redefinitions...
20957+ */
20958+#define SO_USELOOPBACK 0xff02
20959+#define SO_ORDREL 0xff03
20960+#define SO_IMASOCKET 0xff04
20961+#define SO_PROTOTYPE 0xff09
20962diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/socksys.h linux/include/abi/socksys.h
20963--- linux-2.4.3/include/abi/socksys.h Thu Jan 1 01:00:00 1970
20964+++ linux/include/abi/socksys.h Mon Mar 12 16:35:05 2001
20965@@ -0,0 +1,277 @@
20966+/*
20967+ * include/abi/socksys.h
20968+ *
20969+ * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
20970+ *
20971+ * $Id$
20972+ * $Source$
20973+ */
20974+
20975+/* Interface to /dev/socksys as used for streams based TCP/IP in SYSV */
20976+
20977+/* Get struct rtentry from linux/route.h - this should be compatible. */
20978+#include <linux/route.h>
20979+
20980+/* Get struct arpreq from linux/if_arp.h - this should be compatible. */
20981+#include <linux/netdevice.h>
20982+#include <linux/if_arp.h>
20983+
20984+/* Get struct ifreq and struct ifconf from linux/if.h - these should
20985+ * be compatible.
20986+ */
20987+#include <linux/if.h>
20988+
20989+
20990+struct socksysreq {
20991+ int args[7];
20992+};
20993+
20994+
20995+struct socknewproto {
20996+ int family; /* address family (AF_INET, etc.) */
20997+ int type; /* protocol type (SOCK_STREAM, etc.) */
20998+ int proto; /* per family proto number */
20999+ dev_t dev; /* major/minor to use (must be a clone) */
21000+ int flags; /* protosw flags */
21001+};
21002+
21003+
21004+/* These are nothing to do with what we know as SO_*. I think they
21005+ * are the command requests which appear in socksysreq structures?
21006+ */
21007+#define SSYS_SO_ACCEPT 1
21008+#define SSYS_SO_BIND 2
21009+#define SSYS_SO_CONNECT 3
21010+#define SSYS_SO_GETPEERNAME 4
21011+#define SSYS_SO_GETSOCKNAME 5
21012+#define SSYS_SO_GETSOCKOPT 6
21013+#define SSYS_SO_LISTEN 7
21014+#define SSYS_SO_RECV 8
21015+#define SSYS_SO_RECVFROM 9
21016+#define SSYS_SO_SEND 10
21017+#define SSYS_SO_SENDTO 11
21018+#define SSYS_SO_SETSOCKOPT 12
21019+#define SSYS_SO_SHUTDOWN 13
21020+#define SSYS_SO_SOCKET 14
21021+#define SSYS_SO_SELECT 15
21022+#define SSYS_SO_GETIPDOMAIN 16
21023+#define SSYS_SO_SETIPDOMAIN 17
21024+#define SSYS_SO_ADJTIME 18
21025+#define SSYS_SO_SETREUID 19
21026+#define SSYS_SO_SETREGID 20
21027+#define SSYS_SO_GETTIME 21
21028+#define SSYS_SO_SETTIME 22
21029+#define SSYS_SO_GETITIMER 23
21030+#define SSYS_SO_SETITIMER 24
21031+#define SSYS_SO_RECVMSG 25 /* Here down is SCO 3.2v5 and up */
21032+#define SSYS_SO_SENDMSG 26
21033+#define SSYS_SO_SOCKPAIR 27
21034+
21035+
21036+/* We encode the ioctl numbers using the argument size as part of
21037+ * the number. This will warn us if we haven't got compatible
21038+ * structures :-).
21039+ * Naturally the SVR3/Lachman ioctl numbers are different from the
21040+ * BSD/SVR4-XTI ioctl numbers. What more would you expect?
21041+ */
21042+
21043+#define SSYS_IOCPARM_MASK 0xff /* parameters must be < 256 bytes */
21044+#define SSYS_IOC_VOID 0x20000000 /* no parameters */
21045+#define SSYS_IOC_OUT 0x40000000 /* copy out parameters */
21046+#define SSYS_IOC_IN 0x80000000 /* copy in parameters */
21047+#define SSYS_IOC_INOUT (SSYS_IOC_IN|SSYS_IOC_OUT)
21048+
21049+#define SSYS_IOS(x,y) (SSYS_IOC_VOID|(x<<8)|y)
21050+#define SSYS_IOSR(x,y,t) (SSYS_IOC_OUT|((sizeof(t)&SSYS_IOCPARM_MASK)<<16)|(x<<8)|y)
21051+#define SSYS_IOSW(x,y,t) (SSYS_IOC_IN|((sizeof(t)&SSYS_IOCPARM_MASK)<<16)|(x<<8)|y)
21052+#define SSYS_IOSWR(x,y,t) (SSYS_IOC_INOUT|((sizeof(t)&SSYS_IOCPARM_MASK)<<16)|(x<<8)|y)
21053+
21054+#define SSYS_SIOCSHIWAT SSYS_IOSW('S', 1, int) /* set high watermark */
21055+#define SSYS_SIOCGHIWAT SSYS_IOSR('S', 2, int) /* get high watermark */
21056+#define SSYS_SIOCSLOWAT SSYS_IOSW('S', 3, int) /* set low watermark */
21057+#define SSYS_SIOCGLOWAT SSYS_IOSR('S', 4, int) /* get low watermark */
21058+#define SSYS_SIOCATMARK SSYS_IOSR('S', 5, int) /* at oob mark? */
21059+#define SSYS_SIOCSPGRP SSYS_IOSW('S', 6, int) /* set process group */
21060+#define SSYS_SIOCGPGRP SSYS_IOSR('S', 7, int) /* get process group */
21061+
21062+
21063+#define SSYS_FIONREAD SSYS_IOSR('S', 8, int) /* BSD compatibilty */
21064+#define SSYS_FIONBIO SSYS_IOSW('S', 9, int) /* BSD compatibilty */
21065+#define SSYS_FIOASYNC SSYS_IOSW('S', 10, int) /* BSD compatibilty */
21066+#define SSYS_SIOCPROTO SSYS_IOSW('S', 11, struct socknewproto) /* link proto */
21067+#define SSYS_SIOCGETNAME SSYS_IOSR('S', 12, struct sockaddr) /* getsockname */
21068+#define SSYS_SIOCGETPEER SSYS_IOSR('S', 13, struct sockaddr) /* getpeername */
21069+#define SSYS_IF_UNITSEL SSYS_IOSW('S', 14, int) /* set unit number */
21070+#define SSYS_SIOCXPROTO SSYS_IOS('S', 15) /* empty proto table */
21071+
21072+#define SSYS_SIOCADDRT SSYS_IOSW('R', 9, struct rtentry) /* add route */
21073+#define SSYS_SIOCDELRT SSYS_IOSW('R', 10, struct rtentry) /* delete route */
21074+
21075+#define SSYS_SIOCSIFADDR SSYS_IOSW('I', 11, struct ifreq) /* set ifnet address */
21076+#define SSYS_SIOCGIFADDR SSYS_IOSWR('I', 12, struct ifreq) /* get ifnet address */
21077+#define SSYS_SIOCSIFDSTADDR SSYS_IOSW('I', 13, struct ifreq) /* set p-p address */
21078+#define SSYS_SIOCGIFDSTADDR SSYS_IOSWR('I', 14, struct ifreq) /* get p-p address */
21079+#define SSYS_SIOCSIFFLAGS SSYS_IOSW('I', 15, struct ifreq) /* set ifnet flags */
21080+#define SSYS_SIOCGIFFLAGS SSYS_IOSWR('I', 16, struct ifreq) /* get ifnet flags */
21081+#define SSYS_SIOCGIFCONF SSYS_IOSWR('I', 17, struct ifconf) /* get ifnet list */
21082+
21083+#define SSYS_SIOCSIFMTU SSYS_IOSW('I', 21, struct ifreq) /* get if_mtu */
21084+#define SSYS_SIOCGIFMTU SSYS_IOSWR('I', 22, struct ifreq) /* set if_mtu */
21085+
21086+#define SSYS_SIOCIFDETACH SSYS_IOSW('I', 26, struct ifreq) /* detach interface */
21087+#define SSYS_SIOCGENPSTATS SSYS_IOSWR('I', 27, struct ifreq) /* get ENP stats */
21088+
21089+#define SSYS_SIOCX25XMT SSYS_IOSWR('I', 29, struct ifreq) /* start a slp proc in
21090+ * x25if */
21091+#define SSYS_SIOCX25RCV SSYS_IOSWR('I', 30, struct ifreq) /* start a slp proc in
21092+ * x25if */
21093+#define SSYS_SIOCX25TBL SSYS_IOSWR('I', 31, struct ifreq) /* xfer lun table to
21094+ * kernel */
21095+
21096+#define SSYS_SIOCGIFBRDADDR SSYS_IOSWR('I', 32, struct ifreq) /* get broadcast addr */
21097+#define SSYS_SIOCSIFBRDADDR SSYS_IOSW('I', 33, struct ifreq) /* set broadcast addr */
21098+#define SSYS_SIOCGIFNETMASK SSYS_IOSWR('I', 34, struct ifreq) /* get net addr mask */
21099+#define SSYS_SIOCSIFNETMASK SSYS_IOSW('I', 35, struct ifreq) /* set net addr mask */
21100+#define SSYS_SIOCGIFMETRIC SSYS_IOSWR('I', 36, struct ifreq) /* get IF metric */
21101+#define SSYS_SIOCSIFMETRIC SSYS_IOSW('I', 37, struct ifreq) /* set IF metric */
21102+
21103+#define SSYS_SIOCSARP SSYS_IOSW('I', 38, struct arpreq) /* set arp entry */
21104+#define SSYS_SIOCGARP SSYS_IOSWR('I', 39, struct arpreq) /* get arp entry */
21105+#define SSYS_SIOCDARP SSYS_IOSW('I', 40, struct arpreq) /* delete arp entry */
21106+
21107+#define SSYS_SIOCSIFNAME SSYS_IOSW('I', 41, struct ifreq) /* set interface name */
21108+#define SSYS_SIOCGIFONEP SSYS_IOSWR('I', 42, struct ifreq) /* get one-packet params */
21109+#define SSYS_SIOCSIFONEP SSYS_IOSW('I', 43, struct ifreq) /* set one-packet params */
21110+
21111+#define SSYS_SIOCGENADDR SSYS_IOSWR('I', 65, struct ifreq) /* Get ethernet addr */
21112+
21113+#define SSYS_SIOCSOCKSYS SSYS_IOSW('I', 66, struct socksysreq) /* Pseudo socket syscall */
21114+
21115+
21116+#define SVR4_SIOCSHIWAT SSYS_IOSW('s', 0, int) /* set high watermark */
21117+#define SVR4_SIOCGHIWAT SSYS_IOSR('s', 1, int) /* get high watermark */
21118+#define SVR4_SIOCSLOWAT SSYS_IOSW('s', 2, int) /* set low watermark */
21119+#define SVR4_SIOCGLOWAT SSYS_IOSR('s', 3, int) /* get low watermark */
21120+#define SVR4_SIOCATMARK SSYS_IOSR('s', 7, int) /* at oob mark? */
21121+#define SVR4_SIOCSPGRP SSYS_IOSW('s', 8, int) /* set process group */
21122+#define SVR4_SIOCGPGRP SSYS_IOSR('s', 9, int) /* get process group */
21123+
21124+#define SVR4_SIOCADDRT SSYS_IOSW('r', 10, struct rtentry) /* add route */
21125+#define SVR4_SIOCDELRT SSYS_IOSW('r', 11, struct rtentry) /* delete route */
21126+
21127+#define SVR4_SIOCSIFADDR SSYS_IOSW('i', 12, struct ifreq) /* set ifnet address */
21128+#define SVR4_SIOCGIFADDR SSYS_IOSWR('i',13, struct ifreq) /* get ifnet address */
21129+#define SVR4_SIOCSIFDSTADDR SSYS_IOSW('i', 14, struct ifreq) /* set p-p address */
21130+#define SVR4_SIOCGIFDSTADDR SSYS_IOSWR('i',15, struct ifreq) /* get p-p address */
21131+#define SVR4_SIOCSIFFLAGS SSYS_IOSW('i', 16, struct ifreq) /* set ifnet flags */
21132+#define SVR4_SIOCGIFFLAGS SSYS_IOSWR('i',17, struct ifreq) /* get ifnet flags */
21133+#define SVR4_SIOCSIFMEM SSYS_IOSW('i', 18, struct ifreq) /* set interface mem */
21134+#define SVR4_SIOCGIFMEM SSYS_IOSWR('i',19, struct ifreq) /* get interface mem */
21135+#define SVR4_SIOCGIFCONF SSYS_IOSWR('i',20, struct ifconf) /* get ifnet list */
21136+#define SVR4_SIOCSIFMTU SSYS_IOSW('i', 21, struct ifreq) /* set if_mtu */
21137+#define SVR4_SIOCGIFMTU SSYS_IOSWR('i',22, struct ifreq) /* get if_mtu */
21138+
21139+ /* from 4.3BSD */
21140+#define SVR4_SIOCGIFBRDADDR SSYS_IOSWR('i',23, struct ifreq) /* get broadcast addr */
21141+#define SVR4_SIOCSIFBRDADDR SSYS_IOSW('i',24, struct ifreq) /* set broadcast addr */
21142+#define SVR4_SIOCGIFNETMASK SSYS_IOSWR('i',25, struct ifreq) /* get net addr mask */
21143+#define SVR4_SIOCSIFNETMASK SSYS_IOSW('i',26, struct ifreq) /* set net addr mask */
21144+#define SVR4_SIOCGIFMETRIC SSYS_IOSWR('i',27, struct ifreq) /* get IF metric */
21145+#define SVR4_SIOCSIFMETRIC SSYS_IOSW('i',28, struct ifreq) /* set IF metric */
21146+
21147+#define SVR4_SIOCSARP SSYS_IOSW('i', 30, struct arpreq) /* set arp entry */
21148+#define SVR4_SIOCGARP SSYS_IOSWR('i',31, struct arpreq) /* get arp entry */
21149+#define SVR4_SIOCDARP SSYS_IOSW('i', 32, struct arpreq) /* delete arp entry */
21150+#define SVR4_SIOCUPPER SSYS_IOSW('i', 40, struct ifreq) /* attach upper layer */
21151+#define SVR4_SIOCLOWER SSYS_IOSW('i', 41, struct ifreq) /* attach lower layer */
21152+#define SVR4_SIOCSETSYNC SSYS_IOSW('i', 44, struct ifreq) /* set syncmode */
21153+#define SVR4_SIOCGETSYNC SSYS_IOSWR('i', 45, struct ifreq) /* get syncmode */
21154+#define SVR4_SIOCSSDSTATS SSYS_IOSWR('i', 46, struct ifreq) /* sync data stats */
21155+#define SVR4_SIOCSSESTATS SSYS_IOSWR('i', 47, struct ifreq) /* sync error stats */
21156+
21157+#define SVR4_SIOCSPROMISC SSYS_IOSW('i', 48, int) /* request promisc mode
21158+ on/off */
21159+#define SVR4_SIOCADDMULTI SSYS_IOSW('i', 49, struct ifreq) /* set m/c address */
21160+#define SVR4_SIOCDELMULTI SSYS_IOSW('i', 50, struct ifreq) /* clr m/c address */
21161+
21162+/* protocol i/o controls */
21163+#define SVR4_SIOCSNIT SSYS_IOSW('p', 0, struct nit_ioc) /* set nit modes */
21164+#define SVR4_SIOCGNIT SSYS_IOSWR('p', 1, struct nit_ioc) /* get nit modes */
21165+
21166+/* STREAMS based socket emulation */
21167+
21168+#define SVR4_SIOCPROTO SSYS_IOSW('s', 51, struct socknewproto) /* link proto */
21169+#define SVR4_SIOCGETNAME SSYS_IOSR('s', 52, struct sockaddr) /* getsockname */
21170+#define SVR4_SIOCGETPEER SSYS_IOSR('s', 53, struct sockaddr) /* getpeername */
21171+#define SVR4_IF_UNITSEL SSYS_IOSW('s', 54, int) /* set unit number */
21172+#define SVR4_SIOCXPROTO SSYS_IOS('s', 55) /* empty proto table */
21173+
21174+#define SVR4_SIOCIFDETACH SSYS_IOSW('i', 56, struct ifreq) /* detach interface */
21175+#define SVR4_SIOCGENPSTATS SSYS_IOSWR('i', 57, struct ifreq) /* get ENP stats */
21176+#define SVR4_SIOCX25XMT SSYS_IOSWR('i', 59, struct ifreq) /* start a slp proc in
21177+ * x25if */
21178+#define SVR4_SIOCX25RCV SSYS_IOSWR('i', 60, struct ifreq) /* start a slp proc in
21179+ * x25if */
21180+#define SVR4_SIOCX25TBL SSYS_IOSWR('i', 61, struct ifreq) /* xfer lun table to
21181+ * kernel */
21182+#define SVR4_SIOCSLGETREQ SSYS_IOSWR('i', 71, struct ifreq) /* wait for switched
21183+ * SLIP request */
21184+#define SVR4_SIOCSLSTAT SSYS_IOSW('i', 72, struct ifreq) /* pass SLIP info to
21185+ * kernel */
21186+#define SVR4_SIOCSIFNAME SSYS_IOSW('i', 73, struct ifreq) /* set interface name */
21187+#define SVR4_SIOCGENADDR SSYS_IOSWR('i', 85, struct ifreq) /* Get ethernet addr */
21188+#define SVR4_SIOCSOCKSYS SSYS_IOSW('i', 86, struct socksysreq) /* Pseudo socket syscall */
21189+
21190+
21191+#if 0
21192+/* Strange, there also seem to be two byte SVR4 ioctls used which are
21193+ * not simply the BSD style ioctl with the high word masked out. i.e the
21194+ * class character doesn't match what I expect.
21195+ */
21196+#define SVRX_SIOCGIFCONF 0x8912
21197+#define SVRX_SIOCGIFFLAGS 0x8913
21198+#endif
21199+
21200+
21201+/* With NFS/NIS there is also a pseudo device /dev/nfsd which understands
21202+ * some ioctls. Since these don't conflict with the socksys ioctls we
21203+ * just link nfsd to socksys and let socksys handle both sets.
21204+ */
21205+#define NIOCNFSD 1
21206+#define NIOCOLDGETFH 2
21207+#define NIOCASYNCD 3
21208+#define NIOCSETDOMNAM 4
21209+#define NIOCGETDOMNAM 5
21210+#define NIOCCLNTHAND 6
21211+#define NIOCEXPORTFS 7
21212+#define NIOCGETFH 8
21213+#define NIOCLSTAT 9
21214+
21215+/* These ioctls take argument structures... */
21216+struct domnam_args {
21217+ char *name;
21218+ int namelen;
21219+};
21220+
21221+struct lstat_args {
21222+ char *fname;
21223+ void *statb;
21224+};
21225+
21226+#define NFS_FHSIZE 32
21227+typedef union {
21228+ struct {
21229+ unsigned short fsid; /* filesystem id (device) */
21230+ unsigned long fno; /* file number (inode) */
21231+ unsigned long fgen; /* file generation */
21232+ unsigned short ex_fsid; /* exported fs id (device) */
21233+ unsigned long ex_fno; /* exported file no (inode) */
21234+ unsigned long ex_fgen; /* exported file gen */
21235+ } fh;
21236+ char pad[NFS_FHSIZE];
21237+} fhandle_t;
21238+
21239+struct getfh_args {
21240+ char *fname;
21241+ fhandle_t *fhp;
21242+};
21243diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/solaris.h linux/include/abi/solaris.h
21244--- linux-2.4.3/include/abi/solaris.h Thu Jan 1 01:00:00 1970
21245+++ linux/include/abi/solaris.h Mon Mar 12 16:35:05 2001
21246@@ -0,0 +1,21 @@
21247+#ifndef __IBCS_SOLX86_H__
21248+#define __IBCS_SOLX86_H__
21249+
21250+#include <abi/lfs.h>
21251+
21252+typedef void svr4_ucontext_t;
21253+
21254+int sol_llseek(struct pt_regs * regs);
21255+int ibcs_memcntl(unsigned addr, unsigned len, int cmd, unsigned arg,
21256+ int attr, int mask);
21257+
21258+
21259+
21260+
21261+#define GETACL 1
21262+#define SETACL 2
21263+#define GETACLCNT 3
21264+
21265+int sol_acl(char *pathp, int cmd, int nentries, void *aclbufp);
21266+
21267+#endif /* __ IBCS_SOLX86_H__ */
21268diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/stream.h linux/include/abi/stream.h
21269--- linux-2.4.3/include/abi/stream.h Thu Jan 1 01:00:00 1970
21270+++ linux/include/abi/stream.h Mon Mar 12 16:35:05 2001
21271@@ -0,0 +1,46 @@
21272+/*
21273+ * include/abi/stream.h
21274+ *
21275+ * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
21276+ *
21277+ * $Id$
21278+ * $Source$
21279+ */
21280+
21281+#ifndef _IBCS_STREAM_H_
21282+#define _IBCS_STREAM_H_
21283+
21284+#define MSG_HIPRI 1
21285+#define RS_HIPRI MSG_HIPRI
21286+#define MSG_ANY 2
21287+#define MSG_BAND 4
21288+
21289+#define MORECTL 1
21290+#define MOREDATA 2
21291+
21292+struct strbuf {
21293+ int maxlen; /* size of buffer */
21294+ int len; /* number of bytes in buffer */
21295+ char *buf; /* pointer to buffer */
21296+};
21297+
21298+/* Used for the I_PEEK STREAMS ioctl. */
21299+struct strpeek {
21300+ struct strbuf ctl;
21301+ struct strbuf dat;
21302+ long flags;
21303+};
21304+
21305+/* Used for the I_FDINSERT STREAMS ioctl. */
21306+struct strfdinsert {
21307+ struct strbuf ctlbuf;
21308+ struct strbuf datbuf;
21309+ long flags;
21310+ unsigned int fildes;
21311+ int offset;
21312+};
21313+
21314+extern int stream_fdinsert(struct pt_regs *regs, int fd,
21315+ struct strfdinsert *arg);
21316+
21317+#endif
21318diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/svr4.h linux/include/abi/svr4.h
21319--- linux-2.4.3/include/abi/svr4.h Thu Jan 1 01:00:00 1970
21320+++ linux/include/abi/svr4.h Mon Mar 12 16:35:05 2001
21321@@ -0,0 +1,134 @@
21322+/*
21323+ * Function prototypes used for SVR4 emulation.
21324+ *
21325+ * $Id$
21326+ * $Source$
21327+ */
21328+#include <linux/ptrace.h> /* for pt_regs */
21329+#include <linux/sched.h>
21330+#include <linux/signal.h>
21331+#include <linux/unistd.h>
21332+
21333+#define SVR_NCC 8
21334+struct svr_termio {
21335+ unsigned short c_iflag;
21336+ unsigned short c_oflag;
21337+ unsigned short c_cflag;
21338+ unsigned short c_lflag;
21339+ char c_line;
21340+ unsigned char c_cc[SVR_NCC];
21341+};
21342+
21343+#define SVR4_NCCS (19)
21344+struct svr4_termios {
21345+ unsigned long c_iflag;
21346+ unsigned long c_oflag;
21347+ unsigned long c_cflag;
21348+ unsigned long c_lflag;
21349+ unsigned char c_cc[SVR4_NCCS];
21350+};
21351+
21352+/* timod.c */
21353+extern int svr4_ioctl_sockmod(int fd, unsigned int func, void *arg);
21354+
21355+/* svr4.c */
21356+extern int svr4_getgroups(int n, unsigned long * buf);
21357+extern int svr4_setgroups(int n, unsigned long * buf);
21358+extern int svr4_waitsys(struct pt_regs * regs);
21359+extern int svr4_seteuid(int uid);
21360+extern int svr4_setegid(int gid);
21361+
21362+/* open.c */
21363+extern int svr4_open(const char * fname, int flag, int mode);
21364+extern int svr4_statfs(const char * path, struct ibcs_statfs * buf, int len, int fstype);
21365+extern int svr4_fstatfs(unsigned int fd, struct ibcs_statfs * buf, int len, int fstype);
21366+extern int svr4_getdents(int fd, char * buf, int nybtes);
21367+
21368+/* ipc.c */
21369+extern int svr4_semsys(struct pt_regs * regs);
21370+extern int svr4_shmsys(struct pt_regs * regs);
21371+extern int svr4_msgsys(struct pt_regs * regs);
21372+
21373+/* stream.c */
21374+extern int svr4_getmsg(struct pt_regs *regs);
21375+extern int svr4_putmsg(struct pt_regs *regs);
21376+extern int svr4_getpmsg(struct pt_regs *regs);
21377+extern int svr4_putpmsg(struct pt_regs *regs);
21378+
21379+/* ioctl.c */
21380+extern int svr4_ioctl_stream(struct pt_regs *regs, int fd, unsigned int func, void *arg);
21381+extern int svr4_ioctl_termiox(int fd, unsigned int func, void *arg);
21382+
21383+/* sysfs.c */
21384+extern int svr4_sysfs(int cmd, int arg1, int arg2);
21385+
21386+/* sysinfo.c */
21387+extern int svr4_sysinfo(int, char *, long);
21388+
21389+/* xstat.c */
21390+extern int svr4_fxstat(int vers, int fd, void * buf);
21391+
21392+/* ulimit.c */
21393+extern int svr4_ulimit(int cmd, int val);
21394+extern int svr4_getrlimit(int cmd, void *val);
21395+extern int svr4_setrlimit(int cmd, void *val);
21396+
21397+/* poll.c */
21398+struct poll{
21399+ int fd;
21400+ short events;
21401+ short revents;
21402+};
21403+extern int svr4_poll(struct poll * ufds, size_t nfds, int timeout);
21404+
21405+/* hrtsys.c */
21406+extern int svr4_hrtsys(struct pt_regs * regs);
21407+
21408+/* syslocal.c */
21409+extern int svr4_syslocal(struct pt_regs * regs);
21410+
21411+/* ptrace.c */
21412+extern int svr4_ptrace(int req, int pid, unsigned long addr, unsigned long data);
21413+
21414+/* fcntl.c */
21415+extern int svr4_fcntl(struct pt_regs *regs);
21416+
21417+/* mmap.c */
21418+extern int svr4_mmap(unsigned int vaddr, unsigned int vsize, int prot,
21419+ int flags, int fd, unsigned int file_offset);
21420+
21421+/* sysconf.c */
21422+#define _CONFIG_NGROUPS 2 /* # configured supplemental groups */
21423+#define _CONFIG_CHILD_MAX 3 /* max # of processes per uid session */
21424+#define _CONFIG_OPEN_FILES 4 /* max # of open files per process */
21425+#define _CONFIG_POSIX_VER 5 /* POSIX version */
21426+#define _CONFIG_PAGESIZE 6 /* system page size */
21427+#define _CONFIG_CLK_TCK 7 /* ticks per second */
21428+#define _CONFIG_XOPEN_VER 8 /* XOPEN version */
21429+#define _CONFIG_NACLS_MAX 9 /* for Enhanced Security */
21430+#define _CONFIG_ARG_MAX 10 /* max length of exec args */
21431+#define _CONFIG_NPROC 11 /* # processes system is config for */
21432+#define _CONFIG_NENGINE 12 /* # configured processors (CPUs) */
21433+#define _CONFIG_NENGINE_ONLN 13 /* # online processors (CPUs) */
21434+#define _CONFIG_TOTAL_MEMORY 14 /* total memory */
21435+#define _CONFIG_USEABLE_MEMORY 15 /* user + system memory */
21436+#define _CONFIG_GENERAL_MEMORY 16 /* user only memory */
21437+#define _CONFIG_DEDICATED_MEMORY 17 /* dedicated memory */
21438+#define _CONFIG_NCGS_CONF 18 /* # CGs in system */
21439+#define _CONFIG_NCGS_ONLN 19 /* # CGs online now */
21440+#define _CONFIG_MAX_ENG_PER_CG 20 /* max engines per CG */
21441+#define _CONFIG_CACHE_LINE 21 /* memory cache line size */
21442+#define _CONFIG_SYSTEM_ID 22 /* system id assigned at ISL */
21443+#define _CONFIG_KERNEL_VM 23 /* size of kernel virtual memory */
21444+extern int svr4_sysconfig(int name);
21445+
21446+/* sysi86.c */
21447+extern int svr4_sysi86(struct pt_regs * regs);
21448+
21449+/* svr4_funcs.c */
21450+extern struct map_segment svr4_err_map[];
21451+extern struct map_segment svr4_socktype_map[];
21452+extern struct map_segment abi_sockopt_map[];
21453+extern struct map_segment abi_af_map[];
21454+extern long linux_to_ibcs_signals[];
21455+extern long ibcs_to_linux_signals[];
21456diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/svr4sig.h linux/include/abi/svr4sig.h
21457--- linux-2.4.3/include/abi/svr4sig.h Thu Jan 1 01:00:00 1970
21458+++ linux/include/abi/svr4sig.h Mon Mar 12 16:35:05 2001
21459@@ -0,0 +1,10 @@
21460+#ifndef __ABI_SVR4SIG_H__
21461+#define __ABI_SVR4SIG_H__
21462+typedef void (*svr4_sig_t)(int, void *, void *);
21463+
21464+typedef struct {
21465+ u32 setbits [4];
21466+} svr4_sigset_t;
21467+
21468+
21469+#endif
21470diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/tli.h linux/include/abi/tli.h
21471--- linux-2.4.3/include/abi/tli.h Thu Jan 1 01:00:00 1970
21472+++ linux/include/abi/tli.h Mon Mar 12 16:35:05 2001
21473@@ -0,0 +1,351 @@
21474+#ifndef __TLI_H
21475+#define __TLI_H
21476+
21477+
21478+struct t_info {
21479+ long addr;
21480+ long options;
21481+ long tsdu;
21482+ long etsdu;
21483+ long connect;
21484+ long discon;
21485+ long servtype;
21486+};
21487+
21488+
21489+/* Error codes used by TLI transport providers. */
21490+#define TBADADDR 1
21491+#define TBADOPT 2
21492+#define TACCES 3
21493+#define TBADF 4
21494+#define TNOADDR 5
21495+#define TOUTSTATE 6
21496+#define TBADSEQ 7
21497+#define TSYSERR 8
21498+#define TLOOK 9
21499+#define TBADDATA 10
21500+#define TBUFOVFLW 11
21501+#define TFLOW 12
21502+#define TNODATA 13
21503+#define TNODIS 14
21504+#define TNOUDERR 15
21505+#define TBADFLAG 16
21506+#define TNOREL 17
21507+#define TNOTSUPPORT 18
21508+#define TSTATECHNG 19
21509+
21510+
21511+/* User level states (maintained internally by libnsl_s). */
21512+#define T_UNINIT 0
21513+#define T_UNBND 1
21514+#define T_IDLE 2
21515+#define T_OUTCON 3
21516+#define T_INCON 4
21517+#define T_DATAXFER 5
21518+#define T_OUTREL 6
21519+#define T_INREL 7
21520+#define T_FAKE 8
21521+#define T_HACK 12
21522+
21523+/* Kernel level states of a transport end point. */
21524+#define TS_UNBND 0 /* unbound */
21525+#define TS_WACK_BREQ 1 /* waiting for T_BIND_REQ ack */
21526+#define TS_WACK_UREQ 2 /* waiting for T_UNBIND_REQ ack */
21527+#define TS_IDLE 3 /* idle */
21528+#define TS_WACK_OPTREQ 4 /* waiting for T_OPTMGMT_REQ ack */
21529+#define TS_WACK_CREQ 5 /* waiting for T_CONN_REQ ack */
21530+#define TS_WCON_CREQ 6 /* waiting for T_CONN_REQ confirmation */
21531+#define TS_WRES_CIND 7 /* waiting for T_CONN_IND */
21532+#define TS_WACK_CRES 8 /* waiting for T_CONN_RES ack */
21533+#define TS_DATA_XFER 9 /* data transfer */
21534+#define TS_WIND_ORDREL 10 /* releasing read but not write */
21535+#define TS_WREQ_ORDREL 11 /* wait to release write but not read */
21536+#define TS_WACK_DREQ6 12 /* waiting for T_DISCON_REQ ack */
21537+#define TS_WACK_DREQ7 13 /* waiting for T_DISCON_REQ ack */
21538+#define TS_WACK_DREQ9 14 /* waiting for T_DISCON_REQ ack */
21539+#define TS_WACK_DREQ10 15 /* waiting for T_DISCON_REQ ack */
21540+#define TS_WACK_DREQ11 16 /* waiting for T_DISCON_REQ ack */
21541+#define TS_NOSTATES 17
21542+
21543+
21544+/* Messages used by "timod". */
21545+#define T_CONN_REQ 0
21546+#define T_CONN_RES 1
21547+#define T_DISCON_REQ 2
21548+#define T_DATA_REQ 3
21549+#define T_EXDATA_REQ 4
21550+#define T_INFO_REQ 5
21551+#define T_BIND_REQ 6
21552+#define T_UNBIND_REQ 7
21553+#define T_UNITDATA_REQ 8
21554+#define T_OPTMGMT_REQ 9
21555+#define T_ORDREL_REQ 10
21556+
21557+#define T_CONN_IND 11
21558+#define T_CONN_CON 12
21559+#define T_DISCON_IND 13
21560+#define T_DATA_IND 14
21561+#define T_EXDATA_IND 15
21562+#define T_INFO_ACK 16
21563+#define T_BIND_ACK 17
21564+#define T_ERROR_ACK 18
21565+#define T_OK_ACK 19
21566+#define T_UNITDATA_IND 20
21567+#define T_UDERROR_IND 21
21568+#define T_OPTMGMT_ACK 22
21569+#define T_ORDREL_IND 23
21570+
21571+/* Flags used from user level library routines. */
21572+#define T_MORE 0x0001
21573+#define T_EXPEDITED 0x0002
21574+#define T_NEGOTIATE 0x0004
21575+#define T_CHECK 0x0008
21576+#define T_DEFAULT 0x0010
21577+#define T_SUCCESS 0x0020
21578+#define T_FAILURE 0x0040
21579+#define T_CURRENT 0x0080
21580+#define T_PARTSUCCESS 0x0100
21581+#define T_READONLY 0x0200
21582+#define T_NOTSUPPORT 0x0400
21583+
21584+
21585+struct T_conn_req {
21586+ long PRIM_type; /* T_CONN_REQ */
21587+ long DEST_length;
21588+ long DEST_offset;
21589+ long OPT_length;
21590+ long OPT_offset;
21591+};
21592+
21593+struct T_conn_res {
21594+ long PRIM_type; /* T_CONN_RES */
21595+ void *QUEUE_ptr;
21596+ long OPT_length;
21597+ long OPT_offset;
21598+ long SEQ_number;
21599+};
21600+
21601+struct T_discon_req {
21602+ long PRIM_type; /* T_DISCON_REQ */
21603+ long SEQ_number;
21604+};
21605+
21606+struct T_data_req {
21607+ long PRIM_type; /* T_DATA_REQ */
21608+ long MORE_flag;
21609+};
21610+
21611+struct T_exdata_req {
21612+ long PRIM_type; /* T_EXDATA_REQ */
21613+ long MORE_flag;
21614+};
21615+
21616+struct T_info_req {
21617+ long PRIM_type; /* T_INFO_REQ */
21618+};
21619+
21620+struct T_bind_req {
21621+ long PRIM_type; /* T_BIND_REQ */
21622+ long ADDR_length;
21623+ long ADDR_offset;
21624+ unsigned long CONIND_number;
21625+};
21626+
21627+struct T_unbind_req {
21628+ long PRIM_type; /* T_UNBIND_REQ */
21629+};
21630+
21631+struct T_unitdata_req {
21632+ long PRIM_type; /* T_UNITDATA_REQ */
21633+ long DEST_length;
21634+ long DEST_offset;
21635+ long OPT_length;
21636+ long OPT_offset;
21637+};
21638+
21639+struct T_optmgmt_req {
21640+ long PRIM_type; /* T_OPTMGMT_REQ */
21641+ long OPT_length;
21642+ long OPT_offset;
21643+ long MGMT_flags;
21644+};
21645+
21646+struct T_ordrel_req {
21647+ long PRIM_type; /* T_ORDREL_REQ */
21648+};
21649+
21650+
21651+struct T_conn_ind {
21652+ long PRIM_type; /* T_CONN_IND */
21653+ long SRC_length;
21654+ long SRC_offset;
21655+ long OPT_length;
21656+ long OPT_offset;
21657+ long SEQ_number;
21658+};
21659+
21660+struct T_conn_con {
21661+ long PRIM_type; /* T_CONN_CON */
21662+ long RES_length;
21663+ long RES_offset;
21664+ long OPT_length;
21665+ long OPT_offset;
21666+};
21667+
21668+struct T_discon_ind {
21669+ long PRIM_type; /* T_DISCON_IND */
21670+ long DISCON_reason;
21671+ long SEQ_number;
21672+};
21673+
21674+struct T_data_ind {
21675+ long PRIM_type; /* T_DATA_IND */
21676+ long MORE_flag;
21677+};
21678+
21679+struct T_exdata_ind {
21680+ long PRIM_type; /* T_EXDATA_IND */
21681+ long MORE_flag;
21682+};
21683+
21684+/* information acknowledgment */
21685+
21686+struct T_info_ack {
21687+ long PRIM_type; /* T_INFO_ACK */
21688+ long TSDU_size;
21689+ long ETSDU_size;
21690+ long CDATA_size;
21691+ long DDATA_size;
21692+ long ADDR_size;
21693+ long OPT_size;
21694+ long TIDU_size;
21695+ long SERV_type;
21696+ long CURRENT_state;
21697+ long PROVIDER_flag;
21698+};
21699+
21700+struct T_bind_ack {
21701+ long PRIM_type; /* T_BIND_ACK */
21702+ long ADDR_length;
21703+ long ADDR_offset;
21704+ unsigned long CONIND_number;
21705+};
21706+
21707+struct T_error_ack {
21708+ long PRIM_type; /* T_ERROR_ACK */
21709+ long ERROR_prim;
21710+ long TLI_error;
21711+ long UNIX_error;
21712+};
21713+
21714+struct T_ok_ack {
21715+ long PRIM_type; /* T_OK_ACK */
21716+ long CORRECT_prim;
21717+};
21718+
21719+struct T_unitdata_ind {
21720+ long PRIM_type; /* T_UNITDATA_IND */
21721+ long SRC_length;
21722+ long SRC_offset;
21723+ long OPT_length;
21724+ long OPT_offset;
21725+};
21726+
21727+struct T_uderror_ind {
21728+ long PRIM_type; /* T_UDERROR_IND */
21729+ long DEST_length;
21730+ long DEST_offset;
21731+ long OPT_length;
21732+ long OPT_offset;
21733+ long ERROR_type;
21734+};
21735+
21736+struct T_optmgmt_ack {
21737+ long PRIM_type; /* T_OPTMGMT_ACK */
21738+ long OPT_length;
21739+ long OPT_offset;
21740+ long MGMT_flags;
21741+};
21742+
21743+struct T_ordrel_ind {
21744+ long PRIM_type; /* T_ORDREL_IND */
21745+};
21746+
21747+
21748+union T_primitives {
21749+ long type;
21750+ struct T_conn_req conn_req;
21751+ struct T_conn_res conn_res;
21752+ struct T_discon_req discon_req;
21753+ struct T_data_req data_req;
21754+ struct T_exdata_req exdata_req;
21755+ struct T_info_req info_req;
21756+ struct T_bind_req bind_req;
21757+ struct T_unbind_req unbind_req;
21758+ struct T_unitdata_req unitdata_req;
21759+ struct T_optmgmt_req optmgmt_req;
21760+ struct T_ordrel_req ordrel_req;
21761+ struct T_conn_ind conn_ind;
21762+ struct T_conn_con conn_con;
21763+ struct T_discon_ind discon_ind;
21764+ struct T_data_ind data_ind;
21765+ struct T_exdata_ind exdata_ind;
21766+ struct T_info_ack info_ack;
21767+ struct T_bind_ack bind_ack;
21768+ struct T_error_ack error_ack;
21769+ struct T_ok_ack ok_ack;
21770+ struct T_unitdata_ind unitdata_ind;
21771+ struct T_uderror_ind uderror_ind;
21772+ struct T_optmgmt_ack optmgmt_ack;
21773+ struct T_ordrel_ind ordrel_ind;
21774+};
21775+
21776+
21777+/* The t_opthdr structure defines the layout of options in a T_OPTMGMT_*
21778+ * data buffer. This is specified in the X/Open specs but does not
21779+ * appear to exist in SCO 3.2.x, SCO OS5, Interactive SVR4 or UnixWare 1.x.
21780+ * There are programs that make options request however.
21781+ * The older TLI uses struct opthdr which is different and incompatible
21782+ * (see below).
21783+ */
21784+struct t_opthdr {
21785+ unsigned long len; /* *Total* length including header */
21786+ unsigned long level;
21787+ unsigned long name;
21788+ unsigned long status;
21789+ char value[0]; /* and onwards... */
21790+};
21791+
21792+struct opthdr {
21793+ long level;
21794+ long name;
21795+ long len; /* Length of option value */
21796+ char value[0]; /* and onwards... */
21797+};
21798+
21799+
21800+struct T_primsg {
21801+ struct T_primsg *next;
21802+ unsigned char pri;
21803+ unsigned char band;
21804+ int length;
21805+ long type;
21806+};
21807+
21808+#define XTI_MAGIC 638654838
21809+
21810+struct T_private {
21811+ int magic;
21812+ long state;
21813+ int offset;
21814+ struct T_primsg *pfirst, *plast;
21815+};
21816+
21817+#define Priv(file) ((struct T_private *)(file->private_data))
21818+
21819+extern int timod_ioctl(struct pt_regs *, int, unsigned int, void *, int, int *);
21820+extern int timod_putmsg(int, struct inode *, int, struct pt_regs *);
21821+extern int timod_getmsg(int, struct inode *, int, struct pt_regs *);
21822+extern int timod_update_socket(int, struct file *, struct pt_regs *);
21823+
21824+#endif /* __TLI_H */
21825diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/trace.h linux/include/abi/trace.h
21826--- linux-2.4.3/include/abi/trace.h Thu Jan 1 01:00:00 1970
21827+++ linux/include/abi/trace.h Fri Mar 30 15:23:49 2001
21828@@ -0,0 +1,66 @@
21829+/*
21830+ * Copyright (c) 2001 Christoph Hellwig.
21831+ * All rights resered.
21832+ *
21833+ * This program is free software; you can redistribute it and/or modify
21834+ * it under the terms of the GNU General Public License as published by
21835+ * the Free Software Foundation; either version 2 of the License, or
21836+ * (at your option) any later version.
21837+ *
21838+ * This program is distributed in the hope that it will be useful,
21839+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21840+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21841+ * GNU General Public License for more details.
21842+ *
21843+ * You should have received a copy of the GNU General Public License
21844+ * along with this program; if not, write to the Free Software
21845+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21846+ *
21847+ * $Id$
21848+ */
21849+#ifndef _ABI_TRACE_H_
21850+#define _ABI_TRACE_H_
21851+
21852+/*
21853+ * Linux-ABI tracing helpers.
21854+ */
21855+#include <linux/config.h>
21856+#include <linux/types.h>
21857+
21858+
21859+/*
21860+ * The currently executed syscall.
21861+ */
21862+extern ABI_func * abi_current;
21863+
21864+/*
21865+ * Check if a syscall needs tracing.
21866+ */
21867+#define abi_traced(res) ((abi_traceflg & (res)) || (abi_current->trace))
21868+
21869+/*
21870+ * Possible flags for abi_traceflg.
21871+ */
21872+#define ABI_TRACE_API 0x00000001 /* all call/return values */
21873+#define ABI_TRACE_IOCTL 0x00000002 /* all ioctl calls */
21874+#define ABI_TRACE_IOCTL_F 0x00000004 /* ioctl calls that fail */
21875+#define ABI_TRACE_SIGNAL 0x00000008 /* all signal calls */
21876+#define ABI_TRACE_SIGNAL_F 0x00000010 /* signal calls that fail */
21877+#define ABI_TRACE_SOCKSYS 0x00000020 /* socksys and spx devices */
21878+#define ABI_TRACE_COFF_LD 0x00000040 /* COFF loader */
21879+#define ABI_TRACE_ELF_LD 0x00000080 /* ELF loader */
21880+#define ABI_TRACE_XOUT_LD 0x00000100 /* XOUT loader */
21881+#define ABI_TRACE_XOUT_DB 0x00000200 /* XOUT loader before launch */
21882+#define ABI_TRACE_STREAMS 0x00000400 /* STREAMS faking */
21883+#define ABI_TRACE_FUNC 0x10000000 /* trace this function */
21884+
21885+extern u_int abi_traceflg;
21886+
21887+#define __abi_trace(fmt...) \
21888+ printk(KERN_DEBUG "[%s:%d]: ", current->comm, current->pid); \
21889+ printk(fmt);
21890+
21891+#define abi_trace(reason, fmt...) \
21892+ { if (abi_traced(reason)) __abi_trace(fmt); }
21893+
21894+#endif /* _ABI_TRACE_H_ */
21895diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/unused-termios.h linux/include/abi/unused-termios.h
21896--- linux-2.4.3/include/abi/unused-termios.h Thu Jan 1 01:00:00 1970
21897+++ linux/include/abi/unused-termios.h Mon Mar 12 16:35:05 2001
21898@@ -0,0 +1,200 @@
21899+/*
21900+ * This file was entered from the book
21901+ * Intel386 Family Binary Compatability Specification 2
21902+ * McGraw-Hill Book company
21903+ * ISBN 0-07-031219-2
21904+ *
21905+ * $Id$
21906+ * $Source$
21907+ */
21908+
21909+#define NCC 8
21910+#define NCCS 13
21911+
21912+typedef unsigned short tcflag_t;
21913+typesef unsigned char cc_t;
21914+typedef unsigned long speed_t;
21915+
21916+struct termio {
21917+ unsigned short c_iflag;
21918+ unsigned short c_oflag;
21919+ unsigned short c_cflag;
21920+ unsigned short c_lflag;
21921+ char c_line;
21922+ unsigned char c_cc[NC];
21923+};
21924+
21925+struct termios {
21926+ tcflag_t c_iflag;
21927+ tcflag_t c_oflag;
21928+ tcflag_t c_cflag;
21929+ tcflag_t c_lflag;
21930+ char c_line;
21931+ cc_t c_cc[NCCS];
21932+ char c_ispeed;
21933+ char c_ospeed;
21934+};
21935+
21936+#define VINTR 0
21937+#define VQUIT 1
21938+#define VERASE 2
21939+#define VKILL 3
21940+#define VEOF 4
21941+#define VEOL 5
21942+#define VEOL2 6
21943+#define VMIN 4
21944+#define VTIME 5
21945+#define VSWTCH 7
21946+#define VSUSP 10
21947+#define VSTART 11
21948+#define VSTOP 12
21949+
21950+#define CNUL 0
21951+#define CDEL 0377
21952+#define CESC '\\'
21953+#define CINTR 0177
21954+#define CQUIT 034
21955+#define CERASE '#'
21956+#define CKILL '@'
21957+#define CSTART 021
21958+#define CSTOP 023
21959+#define CSWTCH 032
21960+#define CNSWTCH 0
21961+#define CSUSP 032
21962+
21963+#define IGNBRK 0000001
21964+#define BRKINT 0000002
21965+#define IGNPAR 0000004
21966+#define PARMRK 0000010
21967+#define INPCK 0000020
21968+#define ISTRIP 0000040
21969+#define INLCR 0000100
21970+#define IGNCR 0000200
21971+#define ICRNL 0000400
21972+#define IUCLC 0001000
21973+#define IXON 0002000
21974+#define IXANY 0004000
21975+#define IXOFF 0010000
21976+#define IMAXBEL 0020000 /* RESERVED */
21977+#define DOSMODE 0100000
21978+
21979+#define OPOST 00000001
21980+#define OLCUC 00000002
21981+#define ONLCR 00000004
21982+#define OCRNL 00000010
21983+#define ONOCR 00000020
21984+#define ONLRET 00000040
21985+#define OFILL 00000100
21986+#define OFDEL 00000200
21987+#define NLDLY 00000400
21988+#define NL0 0
21989+#define NL1 00000400
21990+#define CRDLY 00003000
21991+#define CR0 0
21992+#define CR1 00001000
21993+#define CR2 00002000
21994+#define CR3 00003000
21995+#define TABDLY 00014000
21996+#define TAB0 0
21997+#define TAB1 00004000
21998+#define TAB2 00010000
21999+#define TAB3 00014000
22000+#define BSDLY 00200000
22001+#define BS0 0
22002+#define BS1 00200000
22003+#define VTDLY 00400000
22004+#define VT0 0
22005+#define VT1 00400000
22006+#define FFDLY 01000000
22007+#define FF0 0
22008+#define FF1 01000000
22009+
22010+#define CBAUD 0000017
22011+#define CSIZE 0000060
22012+#define CS5 0
22013+#define CS6 0000020
22014+#define CS7 0000040
22015+#define CS8 0000060
22016+#define CSTOPB 0000100
22017+#define CREAD 0000200
22018+#define PARENB 0000400
22019+#define PARODD 0001000
22020+#define HUPCL 0002000
22021+#define CLOCAL 0004000
22022+#define RCV1EN 0010000
22023+#define XMT1EN 0020000
22024+#define LOBLK 0040000
22025+#define XCLUDE 0100000
22026+
22027+#define ISIG 0000001
22028+#define ICANON 0000002
22029+#define XCASE 0000004
22030+#define ECHO 0000010
22031+#define ECHOE 0000020
22032+#define ECHOK 0000040
22033+#define ECHONL 0000100
22034+#define NOFLSH 0000200
22035+#define IEXTEN 0000400
22036+#defien TOSTOP 0001000
22037+
22038+/* Bits 10-15 (0176000) in the c_lflag field are RESERVED */
22039+
22040+/*
22041+#define XIOC ('x'<<8) Level 2
22042+*/
22043+#define XIOC (('i'<<8)|('X'<<16))
22044+#define XCGETA (XIOC|1)
22045+#define XCSETA (XIOC|2)
22046+#define XCSETAW (XIOC|3)
22047+#define XCSETAF (XIOC|4)
22048+
22049+#define TIOC ('T'<<8)
22050+
22051+#define TCGETA (TIOC|1)
22052+#define TCSETA (TIOC|2)
22053+#define TCSETAW (TIOC|3)
22054+#define TCSETAF (TIOC|4)
22055+#define TCSBRK (TIOC|5)
22056+#define TCXONC (TIOC|6)
22057+#define TCFLSH (TIOC|7)
22058+
22059+#define TIOCGWINSZ (TIOC|104)
22060+#define TIOCSWINSZ (TIOC|103)
22061+
22062+#define TCSANOW XCSETA
22063+#define TCSADRAIN XCSETAW
22064+#define TCSAFLUSH XCSETAF
22065+#define TCSADFLUSH XCSETAF
22066+
22067+#define TCIFLUSH 0
22068+#define TCOFLUSH 1
22069+#define TCIOFLUSH 2
22070+
22071+#define TCOOFF 0
22072+#define TCOON 1
22073+#define TCIOFF 2
22074+#define TCION 3
22075+
22076+#define B0 0
22077+#define B50 1
22078+#define B75 2
22079+#define B110 3
22080+#define B134 4
22081+#define B150 5
22082+#define B200 6
22083+#define B300 7
22084+#define B600 8
22085+#define B1200 9
22086+#define B1800 10
22087+#define B2400 11
22088+#define B4800 12
22089+#define B9600 13
22090+#define B19200 14
22091+#define B38400 15
22092+
22093+struct winsize {
22094+ unsigned short ws_row;
22095+ unsigned short ws_col;
22096+ unsigned short ws_xpixel;
22097+ unsigned short ws_ypixel;
22098+};
22099diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/uw7.h linux/include/abi/uw7.h
22100--- linux-2.4.3/include/abi/uw7.h Thu Jan 1 01:00:00 1970
22101+++ linux/include/abi/uw7.h Mon Mar 12 16:35:05 2001
22102@@ -0,0 +1,82 @@
22103+#ifndef __ABI_UW7_H__
22104+#define __ABI_UW7_H__
22105+
22106+#ifdef __KERNEL__
22107+
22108+#define GETACL 1
22109+#define SETACL 2
22110+#define GETACLCNT 3
22111+
22112+struct acl {
22113+ int a_type;
22114+ uid_t a_id;
22115+ ushort a_perm;
22116+};
22117+
22118+#define UW7_NCCS (19)
22119+struct uw7_termios {
22120+ unsigned long c_iflag;
22121+ unsigned long c_oflag;
22122+ unsigned long c_cflag;
22123+ unsigned long c_lflag;
22124+ unsigned char c_cc[UW7_NCCS];
22125+};
22126+
22127+extern int uw7_acl(char * path, int cmd, int nentries, struct acl * aclp);
22128+
22129+/* access.c */
22130+extern int uw7_access(char * path, int mode);
22131+
22132+/* kernel.c */
22133+extern int uw7_sleep(int seconds);
22134+extern int uw7_seteuid(int uid);
22135+extern int uw7_setegid(int gid);
22136+extern int uw7_pread(unsigned int fd, char * buf, int count, long off);
22137+extern int uw7_pwrite(unsigned int fd, char * buf, int count, long off);
22138+extern int uw7_lseek64(unsigned int fd, unsigned int off,
22139+ unsigned int off_hi, unsigned int orig);
22140+extern int uw7_pread64(unsigned int fd, char * buf, int count,
22141+ unsigned int off_hi, unsigned int off);
22142+extern int uw7_pwrite64(unsigned int fd, char * buf, int count,
22143+ unsigned int off_hi, unsigned int off);
22144+extern int uw7_stty(int fd, int cmd);
22145+extern int uw7_gtty(int fd, int cmd);
22146+
22147+/* proc.c */
22148+extern int uw7_proc_init(void);
22149+extern void uw7_proc_cleanup(void);
22150+
22151+/* ioctl.c */
22152+extern int uw7_ioctl(struct pt_regs * regs);
22153+
22154+/* mac.c */
22155+extern int uw7_mldmode(int mldmode);
22156+
22157+struct uw7_statvfs64 {
22158+ unsigned long f_bsize;
22159+ unsigned long f_frsize;
22160+ unsigned long long f_blocks;
22161+ unsigned long long f_bfree;
22162+ unsigned long long f_bavail;
22163+ unsigned long long f_files;
22164+ unsigned long long f_ffree;
22165+ unsigned long long f_favail;
22166+ unsigned long f_fsid;
22167+ char f_basetype[16];
22168+ unsigned long f_flag;
22169+ unsigned long f_namemax;
22170+ char f_fstr[32];
22171+ unsigned long f_filler[16];
22172+};
22173+
22174+extern int uw7_statvfs64(char * filename, struct uw7_statvfs64 * buf);
22175+extern int uw7_fstatvfs64(int fd, struct uw7_statvfs64 * buf);
22176+
22177+/* the other MAP_XXX values are the same as on Linux/i386 */
22178+#define UW7_MAP_ANONYMOUS 0x100
22179+
22180+extern int uw7_mmap(unsigned long, unsigned long, unsigned long, unsigned long,
22181+ unsigned long, unsigned long);
22182+
22183+#endif /* __KERNEL__ */
22184+#endif /* __ABI_UW7_H__ */
22185diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/uw7_context.h linux/include/abi/uw7_context.h
22186--- linux-2.4.3/include/abi/uw7_context.h Thu Jan 1 01:00:00 1970
22187+++ linux/include/abi/uw7_context.h Mon Mar 12 16:35:05 2001
22188@@ -0,0 +1,45 @@
22189+#ifndef __ABI_UW7_CONTEXT_H__
22190+#define __ABI_UW7_CONTEXT_H__
22191+
22192+#ifdef __KERNEL__
22193+
22194+/* ss_size <-> ss_flags which is why we can't use native Linux stack_t :( */
22195+typedef struct uw7_stack {
22196+ void *ss_sp;
22197+ int ss_size;
22198+ int ss_flags;
22199+} uw7_stack_t;
22200+
22201+/* XXX more registers, please */
22202+typedef struct uw7_mcontext {
22203+ unsigned short gs, __gsh;
22204+ unsigned short fs, __fsh;
22205+ unsigned short es, __esh;
22206+ unsigned short ds, __dsh;
22207+} uw7_mcontext_t;
22208+
22209+typedef struct uw7_sigset {
22210+ unsigned int sigbits[4];
22211+} uw7_sigset_t;
22212+
22213+typedef struct uw7_context {
22214+ unsigned long uc_flags;
22215+ struct uw7_context *uc_link;
22216+ uw7_sigset_t uc_sigmask;
22217+ uw7_stack_t uc_stack;
22218+ uw7_mcontext_t uc_mcontext;
22219+ void *uc_pdata;
22220+ char uc_unused[16];
22221+} uw7_context_t;
22222+
22223+#define UW7_GETCONTEXT 0
22224+#define UW7_SETCONTEXT 1
22225+#define UW7_GETXCONTEXT 2
22226+
22227+
22228+/* context.c */
22229+extern int uw7_context(struct pt_regs * regs);
22230+extern int uw7_sigaltstack(const uw7_stack_t *ss, uw7_stack_t *oss);
22231+
22232+#endif /* __KERNEL__ */
22233+#endif /* __ABI_UW7_CONTEXT_H__ */
22234diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/uw7_termbits.h linux/include/abi/uw7_termbits.h
22235--- linux-2.4.3/include/abi/uw7_termbits.h Thu Jan 1 01:00:00 1970
22236+++ linux/include/abi/uw7_termbits.h Mon Mar 12 16:35:05 2001
22237@@ -0,0 +1,150 @@
22238+#ifndef __ABI_UW7_TERMBITS_H__
22239+#define __ABI_UW7_TERMBITS_H__
22240+
22241+#ifdef __KERNEL__
22242+
22243+#define UW7_TIOC ('T'<<8)
22244+#define UW7_TCGETA (UW7_TIOC|1)
22245+#define UW7_TCSETA (UW7_TIOC|2)
22246+#define UW7_TCSETAW (UW7_TIOC|3)
22247+#define UW7_TCSETAF (UW7_TIOC|4)
22248+#define UW7_TCSBRK (UW7_TIOC|5)
22249+#define UW7_TCXONC (UW7_TIOC|6)
22250+#define UW7_TCFLSH (UW7_TIOC|7)
22251+#define UW7_TCDSET (UW7_TIOC|32)
22252+#define UW7_RTS_TOG (UW7_TIOC|33)
22253+#define UW7_TIOCGWINSZ (UW7_TIOC|104)
22254+#define UW7_TIOCSWINSZ (UW7_TIOC|103)
22255+#define UW7_TCGETS (UW7_TIOC|13)
22256+#define UW7_TCSETS (UW7_TIOC|14)
22257+#define UW7_TCSANOW UW7_TCSETS
22258+#define UW7_TCSETSW (UW7_TIOC|15)
22259+#define UW7_TCSADRAIN UW7_TCSETSW
22260+#define UW7_TCSETSF (UW7_TIOC|16)
22261+#define UW7_TCSAFLUSH UW7_TCSETSF
22262+
22263+/*
22264+ * VEOF/VEOL and VMIN/VTIME are overloaded.
22265+ * VEOF/VEOL are used in canonical mode (ICANON),
22266+ * otherwise VMIN/VTIME are used.
22267+ */
22268+#define UW7_VINTR 0
22269+#define UW7_VQUIT 1
22270+#define UW7_VERASE 2
22271+#define UW7_VKILL 3
22272+#define UW7_VEOF 4
22273+#define UW7_VEOL 5
22274+#define UW7_VEOL2 6
22275+#define UW7_VMIN 4
22276+#define UW7_VTIME 5
22277+#define UW7_VSWTCH 7
22278+#define UW7_VSTART 8
22279+#define UW7_VSTOP 9
22280+#define UW7_VSUSP 10
22281+#define UW7_VDSUSP 11
22282+#define UW7_VREPRINT 12
22283+#define UW7_VDISCARD 13
22284+#define UW7_VWERASE 14
22285+#define UW7_VLNEXT 15
22286+
22287+/*
22288+ * Input modes (c_iflag), same as Linux bits, except DOSMODE (obsolete).
22289+ */
22290+#define UW7_IFLAG_MSK 0017777
22291+#define UW7_IGNBRK 0000001
22292+#define UW7_BRKINT 0000002
22293+#define UW7_IGNPAR 0000004
22294+#define UW7_PARMRK 0000010
22295+#define UW7_INPCK 0000020
22296+#define UW7_ISTRIP 0000040
22297+#define UW7_INLCR 0000100
22298+#define UW7_IGNCR 0000200
22299+#define UW7_ICRNL 0000400
22300+#define UW7_IUCLC 0001000
22301+#define UW7_IXON 0002000
22302+#define UW7_IXANY 0004000
22303+#define UW7_IXOFF 0010000
22304+#define UW7_IMAXBEL 0020000
22305+#define UW7_DOSMODE 0100000
22306+
22307+/*
22308+ * Output modes (c_oflag), exactly the same as Linux bits.
22309+ */
22310+#define UW7_OFLAG_MSK 0177777
22311+#define UW7_OPOST 0000001
22312+#define UW7_OLCUC 0000002
22313+#define UW7_ONLCR 0000004
22314+#define UW7_OCRNL 0000010
22315+#define UW7_ONOCR 0000020
22316+#define UW7_ONLRET 0000040
22317+#define UW7_OFILL 0000100
22318+#define UW7_OFDEL 0000200
22319+#define UW7_NLDLY 0000400
22320+#define UW7_NL0 0000000
22321+#define UW7_NL1 0000400
22322+#define UW7_CRDLY 0003000
22323+#define UW7_CR0 0000000
22324+#define UW7_CR1 0001000
22325+#define UW7_CR2 0002000
22326+#define UW7_CR3 0003000
22327+#define UW7_TABDLY 0014000
22328+#define UW7_TAB0 0000000
22329+#define UW7_TAB1 0004000
22330+#define UW7_TAB2 0010000
22331+#define UW7_TAB3 0014000
22332+#define UW7_XTABS UW7_TAB3
22333+#define UW7_BSDLY 0020000
22334+#define UW7_BS0 0000000
22335+#define UW7_BS1 0020000
22336+#define UW7_VTDLY 0040000
22337+#define UW7_VT0 0000000
22338+#define UW7_VT1 0040000
22339+#define UW7_FFDLY 0100000
22340+#define UW7_FF0 0000000
22341+#define UW7_FF1 0100000
22342+
22343+/*
22344+ * Control modes (c_cflag).
22345+ */
22346+#define UW7_CFLAG_MSK 0177777
22347+#define UW7_CBAUD 0000017
22348+#define UW7_CSIZE 0000060
22349+#define UW7_CS5 0000000
22350+#define UW7_CS6 0000020
22351+#define UW7_CS7 0000040
22352+#define UW7_CS8 0000060
22353+#define UW7_CSTOPB 0000100
22354+#define UW7_CREAD 0000200
22355+#define UW7_PARENB 0000400
22356+#define UW7_PARODD 0001000
22357+#define UW7_HUPCL 0002000
22358+#define UW7_CLOCAL 0004000
22359+#define UW7_XCLUDE 0100000
22360+#define UW7_CIBAUD 000003600000
22361+#define UW7_IBSHIFT 16
22362+#define UW7_PAREXT 000004000000
22363+
22364+/*
22365+ * Local modes (c_lflag), same as Linux except
22366+ * UW7_FLUSHO is different and UW7_DEFECHO is obsolete (set to 0).
22367+ */
22368+#define UW7_LFLAG_MSK 0001777
22369+#define UW7_ISIG 0000001
22370+#define UW7_ICANON 0000002
22371+#define UW7_XCASE 0000004
22372+#define UW7_ECHO 0000010
22373+#define UW7_ECHOE 0000020
22374+#define UW7_ECHOK 0000040
22375+#define UW7_ECHONL 0000100
22376+#define UW7_NOFLSH 0000200
22377+#define UW7_TOSTOP 0000400
22378+#define UW7_ECHOCTL 0001000
22379+#define UW7_ECHOPRT 0002000
22380+#define UW7_ECHOKE 0004000
22381+#define UW7_DEFECHO 0010000
22382+#define UW7_FLUSHO 0020000
22383+#define UW7_PENDIN 0040000
22384+#define UW7_IEXTEN 0100000
22385+
22386+#endif /* __KERNEL__ */
22387+#endif /* __ABI_UW7_TERMBITS_H__ */
22388diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/wysev386i.h linux/include/abi/wysev386i.h
22389--- linux-2.4.3/include/abi/wysev386i.h Thu Jan 1 01:00:00 1970
22390+++ linux/include/abi/wysev386i.h Mon Mar 12 16:35:05 2001
22391@@ -0,0 +1,65 @@
22392+/*
22393+ * include/abi/wysev386i.h
22394+ *
22395+ * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
22396+ *
22397+ * $Id$
22398+ * $Source$
22399+ */
22400+
22401+/* Wyse extensions for 4.3 BSD TCP/IP in V/386 3.2.1A */
22402+
22403+#include <linux/ioctl.h>
22404+
22405+
22406+/* Get struct rtentry from linux/route.h - this should be compatible. */
22407+#include <linux/route.h>
22408+
22409+/* Get struct arpreq from linux/if_arp.h - this should be compatible. */
22410+#include <linux/if_arp.h>
22411+
22412+/* Get struct ifreq and struct ifconf from linux/if.h - these should
22413+ * be compatible.
22414+ */
22415+#include <linux/if.h>
22416+
22417+
22418+/* Wyse use BSD style ioctls. This will warn us if we haven't got compatible
22419+ * structures :-).
22420+ */
22421+
22422+/* socket i/o controls */
22423+#define WVR3_SIOCSHIWAT BSD__IOW('s', 0, int) /* set high watermark */
22424+#define WVR3_SIOCGHIWAT BSD__IOR('s', 1, int) /* get high watermark */
22425+#define WVR3_SIOCSLOWAT BSD__IOW('s', 2, int) /* set low watermark */
22426+#define WVR3_SIOCGLOWAT BSD__IOR('s', 3, int) /* get low watermark */
22427+#define WVR3_SIOCATMARK BSD__IOR('s', 7, int) /* at oob mark? */
22428+#define WVR3_SIOCSPGRP BSD__IOW('s', 8, int) /* set process group */
22429+#define WVR3_SIOCGPGRP BSD__IOR('s', 9, int) /* get process group */
22430+
22431+#define WVR3_SIOCADDRT BSD__IOW('r', 10, struct rtentry) /* add route */
22432+#define WVR3_SIOCDELRT BSD__IOW('r', 11, struct rtentry) /* delete route */
22433+
22434+#define WVR3_SIOCSIFADDR BSD__IOW('i', 12, struct ifreq) /* set ifnet address */
22435+#define WVR3_SIOCGIFADDR BSD__IOWR('i',13, struct ifreq) /* get ifnet address */
22436+#define WVR3_SIOCSIFDSTADDR BSD__IOW('i', 14, struct ifreq) /* set p-p address */
22437+#define WVR3_SIOCGIFDSTADDR BSD__IOWR('i',15, struct ifreq) /* get p-p address */
22438+#define WVR3_SIOCSIFFLAGS BSD__IOW('i', 16, struct ifreq) /* set ifnet flags */
22439+#define WVR3_SIOCGIFFLAGS BSD__IOWR('i',17, struct ifreq) /* get ifnet flags */
22440+#define WVR3_SIOCGIFBRDADDR BSD__IOWR('i',18, struct ifreq) /* get broadcast addr */
22441+#define WVR3_SIOCSIFBRDADDR BSD__IOW('i',19, struct ifreq) /* set broadcast addr */
22442+#define WVR3_SIOCGIFCONF BSD__IOWR('i',20, struct ifconf) /* get ifnet list */
22443+#define WVR3_SIOCGIFNETMASK BSD__IOWR('i',21, struct ifreq) /* get net addr mask */
22444+#define WVR3_SIOCSIFNETMASK BSD__IOW('i',22, struct ifreq) /* set net addr mask */
22445+#define WVR3_SIOCGIFMETRIC BSD__IOWR('i',23, struct ifreq) /* get IF metric */
22446+#define WVR3_SIOCSIFMETRIC BSD__IOW('i',24, struct ifreq) /* set IF metric */
22447+#define WVR3_SIOCSIFHADDR BSD__IOW('i', 25, struct ifreq) /* set hardware addr */
22448+#define WVR3_SIOCGIFHADDR BSD__IOWR('i',26, struct ifreq) /* get hardware addr */
22449+#define WVR3_SIOCRIFHADDR BSD__IOW('i', 27, struct ifreq) /* reset hardware addr */
22450+
22451+#define WVR3_SIOCSARP BSD__IOW('i', 30, struct arpreq) /* set arp entry */
22452+#define WVR3_SIOCGARP BSD__IOWR('i',31, struct arpreq) /* get arp entry */
22453+#define WVR3_SIOCDARP BSD__IOW('i', 32, struct arpreq) /* delete arp entry */
22454+
22455+#define WVR3_SIOCADDMULTI BSD__IOW('i', 33, struct ifreq) /* set multicast addr */
22456+#define WVR3_SIOCDELMULTI BSD__IOW('i', 34, struct ifreq) /* set multicast addr */
22457diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/xnx.h linux/include/abi/xnx.h
22458--- linux-2.4.3/include/abi/xnx.h Thu Jan 1 01:00:00 1970
22459+++ linux/include/abi/xnx.h Mon Mar 12 16:35:05 2001
22460@@ -0,0 +1,41 @@
22461+/*
22462+ * include/abi/xnx.h -- xenix ibcs interface
22463+ *
22464+ * Copyright (C) 1993 Drew Sullivan
22465+ * Released for general use as long as this copyright remains.
22466+ *
22467+ * $Id$
22468+ * $Source$
22469+ */
22470+typedef unsigned short excode_t;
22471+
22472+struct timeb {
22473+ time_t time;
22474+ unsigned short millitm;
22475+ short timezone;
22476+ short dstflag;
22477+};
22478+
22479+extern int xnx_locking(int fd, int mode, unsigned long size);
22480+extern int xnx_creatsem(char *sem_name, int mode);
22481+extern int xnx_opensem(char *sem_name);
22482+extern int xnx_sigsem(int sem_num);
22483+extern int xnx_waitsem(int sem_num);
22484+extern int xnx_nbwaitsem(int sem_num);
22485+extern int xnx_rdchk(int fd);
22486+extern int xnx_ftime(struct timeb * tp);
22487+extern int xnx_nap(long period);
22488+extern int xnx_sdget(char *path, int flags, long size, int mode);
22489+extern int xnx_sdfree(char* addr);
22490+extern int xnx_sdenter(char *addr, int flags);
22491+extern int xnx_sdleave(char *addr);
22492+extern int xnx_sdgetv(char *addr);
22493+extern int xnx_sdwaitv(char *addr, int vnum);
22494+extern int xnx_proctl(int pid, int command, char *arg);
22495+extern int xnx_execseg(excode_t oldaddr, unsigned size);
22496+extern int xnx_unexecseg(excode_t addr);
22497+extern int xnx_eaccess(char *path, int mode);
22498+extern int xnx_paccess(int pid, int cmd, int offset, int count, char *ptr);
22499+extern int xnx_sigpending(unsigned long *set);
22500+extern int xnx_pathconf(char *path, int name);
22501+extern int xnx_fpathconf(int fildes, int name);
22502diff -uNr --exclude-from=dontdiff linux-2.4.3/include/abi/xout.h linux/include/abi/xout.h
22503--- linux-2.4.3/include/abi/xout.h Thu Jan 1 01:00:00 1970
22504+++ linux/include/abi/xout.h Sun Mar 18 17:28:03 2001
22505@@ -0,0 +1,192 @@
22506+/* $Id$
22507+ * xout.h - Microsoft Xenix x.out binary format data structures
22508+ *
22509+ * Copyright (c) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
22510+ */
22511+#ifndef _ABI_XOUT_H_
22512+#define _ABI_XOUT_H_
22513+
22514+/*
22515+ * This file is based on available documentation for the Xenix x.out
22516+ * format. Much is missing here. There is just enough to allow us to
22517+ * support 386 small model and not a lot more.
22518+ */
22519+
22520+/*
22521+ * X.out header
22522+ */
22523+struct xexec {
22524+ u_short x_magic; /* magic number */
22525+ u_short x_ext; /* size of header extension */
22526+
22527+ /*
22528+ * For segmented binaries the following sizes are the sums
22529+ * of the segment sizes.
22530+ */
22531+ long x_text; /* size of text segments */
22532+ long x_data; /* size of initialized data */
22533+ long x_bss; /* size of uninitialized data */
22534+ long x_syms; /* size of symbol table */
22535+ long x_reloc; /* relocation table length */
22536+
22537+ long x_entry; /* entry point */
22538+ char x_cpu; /* cpu type and byte/word order */
22539+ char x_relsym; /* undefined */
22540+ u_short x_renv; /* run-time environment */
22541+};
22542+
22543+/*
22544+ * X.out header extension
22545+ */
22546+struct xext {
22547+ /*
22548+ * These are unused.
22549+ * */
22550+ long xe_trsize; /* ??? */
22551+ long xe_drsize; /* ??? */
22552+ long xe_tbase; /* ??? */
22553+ long xe_dbase; /* ??? */
22554+
22555+ long xe_stksize; /* stack size (if XE_FS set) */
22556+
22557+ /*
22558+ * The following are present if XE_SEG is set.
22559+ */
22560+ long xe_segpos; /* offset to segment table */
22561+ long xe_segsize; /* segment table size */
22562+ long xe_mdtpos; /* offset to machdep table */
22563+ long xe_mdtsize; /* machine dependent table size */
22564+ char xe_mdttype; /* machine dependent table type */
22565+ char xe_pagesize; /* file pagesize, in 512 units */
22566+ char xe_ostype; /* operating system type */
22567+ char xe_osvers; /* operating system version */
22568+ u_short xe_eseg; /* entry segment, machdep */
22569+ u_short xe_sres; /* reserved */
22570+};
22571+
22572+/*
22573+ * X.out segment description.
22574+ */
22575+struct xseg {
22576+ u_short xs_type; /* segment type */
22577+ u_short xs_attr; /* segment attributes */
22578+ u_short xs_seg; /* segment number */
22579+ char xs_align; /* log base 2 of alignment */
22580+ char xs_cres; /* unused */
22581+ u_long xs_filpos; /* file position */
22582+ u_long xs_psize; /* physical size (in file) */
22583+ u_long xs_vsize; /* virtual size (in core) */
22584+ u_long xs_rbase; /* relocation base addr/offset */
22585+ u_short xs_noff; /* segment name table offset */
22586+ u_short xs_sres; /* unused */
22587+ long xs_lres; /* unused */
22588+};
22589+
22590+
22591+/*
22592+ * Magic number for an x.out header.
22593+ */
22594+#define X_MAGIC 0x0206 /* indicates x.out header */
22595+
22596+/*
22597+ * Codes for x_cpu.
22598+ */
22599+#define XC_BSWAP 0x80 /* bytes swapped */
22600+#define XC_WSWAP 0x40 /* words swapped */
22601+#define XC_8086 0x04 /* I8086 */
22602+#define XC_286 0x09 /* iAPX 80286 */
22603+#define XC_286V 0x29 /* iAPX 80286, use xe_osver for version */
22604+#define XC_386 0x0a /* iAPX 80386 */
22605+#define XC_186 0x0b /* iAPX 80186 */
22606+#define XC_CPU 0x3f /* cpu mask */
22607+
22608+/*
22609+ * Flags for the run-time environment.
22610+ */
22611+#define XE_V2 0x4000 /* version 2.x */
22612+#define XE_V3 0x8000 /* version 3.x */
22613+#define XE_OSV 0xc000 /* if XE_SEG use xe_osvers ... */
22614+#define XE_V5 XE_OSV /* else assume v5.x */
22615+#define XE_VERS 0xc000 /* version mask */
22616+
22617+#define XE_5_3 0x2000 /* binary needs 5.3 functionality */
22618+#define XE_LOCK 0x1000 /* Use Advisory locking */
22619+#define XE_SEG 0x0800 /* segment table present */
22620+#define XE_ABS 0x0400 /* absolute memory image (standalone) */
22621+#define XE_ITER 0x0200 /* iterated text/data present */
22622+#define XE_HDATA 0x0100 /* huge model data (never used) */
22623+#define XE_VMOD XE_HDATA /* virtual module */
22624+#define XE_FPH 0x0080 /* floating point hardware required */
22625+#define XE_LTEXT 0x0040 /* large model text */
22626+#define XE_LDATA 0x0020 /* large model data */
22627+#define XE_OVER 0x0010 /* text overlay */
22628+#define XE_FS 0x0008 /* fixed stack */
22629+#define XE_PURE 0x0004 /* pure text */
22630+#define XE_SEP 0x0002 /* separate I & D */
22631+#define XE_EXEC 0x0001 /* executable */
22632+
22633+
22634+/*
22635+ * Segment types.
22636+ */
22637+#define XS_TNULL 0 /* unused segment */
22638+#define XS_TTEXT 1 /* text segment */
22639+#define XS_TDATA 2 /* data segment */
22640+#define XS_TSYMS 3 /* symbol table segment */
22641+#define XS_TREL 4 /* relocation segment */
22642+#define XS_TSESTR 5 /* segment table's string table segment */
22643+#define XS_TGRPS 6 /* group definitions segment */
22644+
22645+#define XS_TIDATA 64 /* iterated data */
22646+#define XS_TTSS 65 /* tss */
22647+#define XS_TLFIX 66 /* lodfix */
22648+#define XS_TDNAME 67 /* descriptor names */
22649+#define XS_TDTEXT 68 /* debug text segment */
22650+#define XS_TIDBG XS_TDTEXT
22651+#define XS_TDFIX 69 /* debug relocation */
22652+#define XS_TOVTAB 70 /* overlay table */
22653+#define XS_T71 71
22654+#define XS_TSYSTR 72 /* symbol string table */
22655+
22656+/*
22657+ * Segment attributes.
22658+ */
22659+#define XS_AMEM 0x8000 /* is a memory image */
22660+
22661+/*
22662+ * For text and data segment types
22663+ */
22664+#define XS_AITER 0x0001 /* contains iteration records */
22665+#define XS_AHUGE 0x0002 /* contains huge element */
22666+#define XS_ABSS 0x0004 /* contains implicit BSS */
22667+#define XS_APURE 0x0008 /* read only, shareable */
22668+#define XS_AEDOWN 0x0010 /* expands downward (stack) */
22669+#define XS_APRIV 0x0020 /* may not be combined */
22670+#define XS_A32BIT 0x0040 /* is 32 bit */
22671+
22672+/*
22673+ * File position macros, valid only if !XE_SEG.
22674+ */
22675+#define XEXTPOS(xp) ((long) sizeof(struct xexec))
22676+#define XTEXTPOS(xp) (XEXTPOS(xp) + (long) (xp)->x_ext)
22677+#define XDATAPOS(xp) (XTEXTPOS(xp) + (xp)->x_text)
22678+#define XBSSPOS(xp) (XDATAPOS(xp) + (xp)->x_data)
22679+#define XSYMPOS(xp) (XDATAPOS(xp) + (xp)->x_data)
22680+#define XRELPOS(xp) (XSYMPOS(xp) + (xp)->x_syms)
22681+#define XENDPOS(xp) (XRELPOS(xp) + (xp)->x_reloc)
22682+
22683+#define XRTEXTPOS(xp, ep) (XRELPOS(xp))
22684+#define XRDATAPOS(xp, ep) (XRELPOS(xp) + (ep)->xe_trsize)
22685+
22686+
22687+/*
22688+ * Specials for the Linux Xenix 286 emulator.
22689+ *
22690+ * The base address that 286 segments are loaded above. This should be
22691+ * above memory used by the emulator overlay. Actual segment data
22692+ * starts slightly higher than this since we map the xexec and xext
22693+ * structures of the executable to this address.
22694+ */
22695+#define X286_MAP_ADDR 0x4000000
22696+
22697+#endif /* _ABI_XOUT_H_ */
22698diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-alpha/elf.h linux/include/asm-alpha/elf.h
22699--- linux-2.4.3/include/asm-alpha/elf.h Fri Sep 22 23:07:43 2000
22700+++ linux/include/asm-alpha/elf.h Fri Mar 30 17:25:23 2001
22701@@ -126,9 +126,22 @@
22702 })
22703
22704 #ifdef __KERNEL__
22705-#define SET_PERSONALITY(EX, IBCS2) \
22706- set_personality(((EX).e_flags & EF_ALPHA_32BIT) \
22707- ? PER_LINUX_32BIT : (IBCS2) ? PER_SVR4 : PER_LINUX)
22708-#endif
22709
22710-#endif
22711+#define SET_ELF_PERSONALITY(ex, interp) \
22712+do { \
22713+ unsigned long personality = PER_LINUX; \
22714+ \
22715+ /* If the header identifies the binary, use that information */ \
22716+ if ((ex).e_flags & EF_ALPHA_32BIT) \
22717+ personality = PER_LINUX_32BIT; \
22718+ \
22719+ /* Else check the interpreter for SVR4isms */ \
22720+ else if (strcmp((interp), "/usr/lib/libc.so.1") == 0 || \
22721+ strcmp((interp), "/usr/lib/ld.so.1") == 0) \
22722+ personality = PER_SVR4; \
22723+ \
22724+ set_personality(personality); \
22725+} while (0)
22726+
22727+#endif /* __KERNEL__ */
22728+#endif /* __ASM_ALPHA_ELF_H */
22729diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-cris/elf.h linux/include/asm-cris/elf.h
22730--- linux-2.4.3/include/asm-cris/elf.h Fri Feb 23 20:12:50 2001
22731+++ linux/include/asm-cris/elf.h Fri Mar 30 17:25:23 2001
22732@@ -62,7 +62,17 @@
22733 #define ELF_PLATFORM (NULL)
22734
22735 #ifdef __KERNEL__
22736-#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
22737-#endif
22738+#define SET_ELF_PERSONALITY(ex, interp) \
22739+do { \
22740+ unsigned long personality = PER_LINUX; \
22741+ \
22742+ /* Check the interpreter for SVR4isms */ \
22743+ else if (strcmp((interp), "/usr/lib/libc.so.1") == 0 || \
22744+ strcmp((interp), "/usr/lib/ld.so.1") == 0) \
22745+ personality = PER_SVR4; \
22746+ \
22747+ set_personality(personality); \
22748+} while (0)
22749
22750-#endif
22751+#endif /* __KERNEL__ */
22752+#endif /* __ASMCRIS_ELF_H */
22753diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-i386/abi.h linux/include/asm-i386/abi.h
22754--- linux-2.4.3/include/asm-i386/abi.h Thu Jan 1 01:00:00 1970
22755+++ linux/include/asm-i386/abi.h Fri Mar 30 17:25:23 2001
22756@@ -0,0 +1,7 @@
22757+#define get_syscall_parameter(regs,n) ({ unsigned long r; \
22758+ get_user(r, ((unsigned long *)regs->esp)+((n)+1)); \
22759+ r; })
22760+#define set_error(regs,e) { regs->eax = (e); regs->eflags |= 1; }
22761+#define clear_error(regs) { regs->eflags &= ~1; }
22762+#define set_result(regs,r) regs->eax = r
22763+#define get_result(regs) regs->eax
22764diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-i386/elf.h linux/include/asm-i386/elf.h
22765--- linux-2.4.3/include/asm-i386/elf.h Thu Jan 4 23:51:47 2001
22766+++ linux/include/asm-i386/elf.h Fri Mar 30 17:31:36 2001
22767@@ -97,8 +97,26 @@
22768
22769 #define ELF_PLATFORM (system_utsname.machine)
22770
22771+/* EF_386_UW7 is needed by elfmark(1) so it's outside __KERNEL__ */
22772+#define EF_386_UW7 0x314B4455
22773+
22774 #ifdef __KERNEL__
22775-#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
22776-#endif
22777
22778-#endif
22779+#define SET_ELF_PERSONALITY(ex, interp) \
22780+do { \
22781+ unsigned long personality = PER_LINUX; \
22782+ \
22783+ /* If the header identifies the binary, use that information */ \
22784+ if ((ex).e_flags == EF_386_UW7) \
22785+ personality = PER_UW7; \
22786+ \
22787+ /* Else check the interpreter for SVR4isms */ \
22788+ else if (strcmp((interp), "/usr/lib/libc.so.1") == 0 || \
22789+ strcmp((interp), "/usr/lib/ld.so.1") == 0) \
22790+ personality = PER_SVR4; \
22791+ \
22792+ set_personality(personality); \
22793+} while (0)
22794+
22795+#endif /* __KERNEL__ */
22796+#endif /* __ASMi386_ELF_H */
22797diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-i386/ldt.h linux/include/asm-i386/ldt.h
22798--- linux-2.4.3/include/asm-i386/ldt.h Sun Jul 11 18:11:46 1999
22799+++ linux/include/asm-i386/ldt.h Fri Mar 30 17:25:23 2001
22800@@ -12,7 +12,7 @@
22801 #define LDT_ENTRY_SIZE 8
22802
22803 #ifndef __ASSEMBLY__
22804-struct modify_ldt_ldt_s {
22805+typedef struct modify_ldt_ldt_s {
22806 unsigned int entry_number;
22807 unsigned long base_addr;
22808 unsigned int limit;
22809@@ -22,7 +22,7 @@
22810 unsigned int limit_in_pages:1;
22811 unsigned int seg_not_present:1;
22812 unsigned int useable:1;
22813-};
22814+} modify_ldt_t;
22815
22816 #define MODIFY_LDT_CONTENTS_DATA 0
22817 #define MODIFY_LDT_CONTENTS_STACK 1
22818diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-i386/namei.h linux/include/asm-i386/namei.h
22819--- linux-2.4.3/include/asm-i386/namei.h Mon Apr 3 00:49:07 2000
22820+++ linux/include/asm-i386/namei.h Fri Mar 30 17:25:23 2001
22821@@ -1,4 +1,4 @@
22822-/* $Id$
22823+/* $Id$
22824 * linux/include/asm-i386/namei.h
22825 *
22826 * Included from linux/fs/namei.c
22827@@ -7,11 +7,59 @@
22828 #ifndef __I386_NAMEI_H
22829 #define __I386_NAMEI_H
22830
22831-/* This dummy routine maybe changed to something useful
22832- * for /usr/gnemul/ emulation stuff.
22833- * Look at asm-sparc/namei.h for details.
22834+//#if defined(CONFIG_ABI) || defined (CONFIG_ABI_MODULE)
22835+#if 1
22836+
22837+/*
22838+ * The base directory for our emulations.
22839+ * - sparc uses usr/gmemul here.
22840+ */
22841+#define I386_EMUL_BASE "emul/"
22842+
22843+/*
22844+ * We emulate quite a lot operting systems...
22845 */
22846+#define I386_SVR4_EMUL I386_EMUL_BASE "/svr4/"
22847+#define I386_SVR3_EMUL I386_EMUL_BASE "/svr3/"
22848+#define I386_SCOSVR3_EMUL I386_EMUL_BASE "/sco/"
22849+#define I386_WYSEV386_EMUL I386_EMUL_BASE "/wyse/"
22850+#define I386_ISCR4_EMUL I386_EMUL_BASE "/isc/"
22851+#define I386_BSD_EMUL I386_EMUL_BASE "/bsd/"
22852+#define I386_XENIX_EMUL I386_EMUL_BASE "/xenix/"
22853+#define I386_SOLARIS_EMUL I386_EMUL_BASE "/solaris/"
22854+#define I386_UW7_EMUL I386_EMUL_BASE "/uw7/"
22855
22856-#define __emul_prefix() NULL
22857+static inline char *__emul_prefix(void)
22858+{
22859+ switch (current->personality) {
22860+ case PER_SVR4:
22861+ return I386_SVR4_EMUL;
22862+ case PER_SVR3:
22863+ return I386_SVR3_EMUL;
22864+ case PER_SCOSVR3:
22865+ return I386_SCOSVR3_EMUL;
22866+ case PER_WYSEV386:
22867+ return I386_WYSEV386_EMUL;
22868+ case PER_ISCR4:
22869+ return I386_ISCR4_EMUL;
22870+ case PER_BSD:
22871+ return I386_BSD_EMUL;
22872+ case PER_XENIX:
22873+ return I386_XENIX_EMUL;
22874+ case PER_SOLARIS:
22875+ return I386_SOLARIS_EMUL;
22876+ case PER_UW7:
22877+ return I386_UW7_EMUL;
22878+ default:
22879+ return NULL;
22880+ }
22881+}
22882+#else
22883+
22884+/*
22885+ * No emulation, no fun :)
22886+ */
22887+#define __emul_prefix() NULL
22888
22889+#endif /* CONFIG_ABI || CONFIG_ABI_MODULE */
22890 #endif /* __I386_NAMEI_H */
22891diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-ia64/elf.h linux/include/asm-ia64/elf.h
22892--- linux-2.4.3/include/asm-ia64/elf.h Wed Jul 12 00:43:45 2000
22893+++ linux/include/asm-ia64/elf.h Fri Mar 30 17:25:23 2001
22894@@ -82,7 +82,18 @@
22895 #define ELF_PLATFORM 0
22896
22897 #ifdef __KERNEL__
22898-#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
22899-#endif
22900
22901+#define SET_ELF_PERSONALITY(ex, interp) \
22902+do { \
22903+ unsigned long personality = PER_LINUX; \
22904+ \
22905+ /* Check the interpreter for SVR4isms */ \
22906+ else if (strcmp((interp), "/usr/lib/libc.so.1") == 0 || \
22907+ strcmp((interp), "/usr/lib/ld.so.1") == 0) \
22908+ personality = PER_SVR4; \
22909+ \
22910+ set_personality(personality); \
22911+} while (0)
22912+
22913+#endif /* __KERNEL__ */
22914 #endif /* _ASM_IA64_ELF_H */
22915diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-m68k/elf.h linux/include/asm-m68k/elf.h
22916--- linux-2.4.3/include/asm-m68k/elf.h Wed Jul 12 00:43:45 2000
22917+++ linux/include/asm-m68k/elf.h Fri Mar 30 17:25:23 2001
22918@@ -89,7 +89,17 @@
22919 #define ELF_PLATFORM (NULL)
22920
22921 #ifdef __KERNEL__
22922-#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
22923-#endif
22924+#define SET_ELF_PERSONALITY(ex, interp) \
22925+do { \
22926+ unsigned long personality = PER_LINUX; \
22927+ \
22928+ /* Check the interpreter for SVR4isms */ \
22929+ else if (strcmp((interp), "/usr/lib/libc.so.1") == 0 || \
22930+ strcmp((interp), "/usr/lib/ld.so.1") == 0) \
22931+ personality = PER_SVR4; \
22932+ \
22933+ set_personality(personality); \
22934+} while (0)
22935
22936-#endif
22937+#endif /* __KERNEL__ */
22938+#endif /* __ASMm68k_ELF_H */
22939diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-mips/elf.h linux/include/asm-mips/elf.h
22940--- linux-2.4.3/include/asm-mips/elf.h Fri Jul 28 03:36:54 2000
22941+++ linux/include/asm-mips/elf.h Fri Mar 30 17:25:23 2001
22942@@ -103,7 +103,17 @@
22943 #define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
22944
22945 #ifdef __KERNEL__
22946-#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
22947-#endif
22948+#define SET_ELF_PERSONALITY(ex, interp) \
22949+do { \
22950+ unsigned long personality = PER_LINUX; \
22951+ \
22952+ /* Check the interpreter for SVR4isms */ \
22953+ else if (strcmp((interp), "/usr/lib/libc.so.1") == 0 || \
22954+ strcmp((interp), "/usr/lib/ld.so.1") == 0) \
22955+ personality = PER_SVR4; \
22956+ \
22957+ set_personality(personality); \
22958+} while (0)
22959
22960+#endif /* __KERNEL__ */
22961 #endif /* __ASM_ELF_H */
22962diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-mips64/elf.h linux/include/asm-mips64/elf.h
22963--- linux-2.4.3/include/asm-mips64/elf.h Fri Jul 28 03:36:54 2000
22964+++ linux/include/asm-mips64/elf.h Fri Mar 30 17:25:23 2001
22965@@ -97,17 +97,21 @@
22966 #define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
22967 #endif
22968
22969-#ifdef __KERNEL__
22970-#define SET_PERSONALITY(ex, ibcs2) \
22971-do { if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
22972- current->thread.mflags |= MF_32BIT; \
22973- else \
22974- current->thread.mflags &= ~MF_32BIT; \
22975- if (ibcs2) \
22976- set_personality(PER_SVR4); \
22977- else if (current->personality != PER_LINUX32) \
22978- set_personality(PER_LINUX); \
22979+#define SET_ELF_PERSONALITY(ex, interp) \
22980+do { \
22981+ /* First do some adjustments for 32bit binary compatiblity */ \
22982+ if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
22983+ current->thread.mflags |= MF_32BIT; \
22984+ else \
22985+ current->thread.mflags &= ~MF_32BIT; \
22986+ \
22987+ /* Check the interpreter for SVR4isms */ \
22988+ if (strcmp((interp), "/usr/lib/libc.so.1") == 0 || \
22989+ strcmp((interp), "/usr/lib/ld.so.1") == 0) \
22990+ set_personality(PER_SVR4); \
22991+ else if (current->personality != PER_LINUX32) \
22992+ set_personality(PER_LINUX); \
22993 } while (0)
22994-#endif
22995
22996+#endif /* __KERNEL__ */
22997 #endif /* _ASM_ELF_H */
22998diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-parisc/elf.h linux/include/asm-parisc/elf.h
22999--- linux-2.4.3/include/asm-parisc/elf.h Fri Mar 30 14:45:52 2001
23000+++ linux/include/asm-parisc/elf.h Fri Mar 30 17:25:23 2001
23001@@ -90,8 +90,11 @@
23002 #define ELF_PLATFORM ("PARISC\0" /*+((boot_cpu_data.x86-3)*5) */)
23003
23004 #ifdef __KERNEL__
23005-#define SET_PERSONALITY(ex, ibcs2) \
23006- current->personality = PER_LINUX
23007-#endif
23008
23009-#endif
23010+#define SET_ELF_PERSONALITY(ex, interp) \
23011+do { \
23012+ __set_personality(PER_LINUX); \
23013+} while (0)
23014+
23015+#endif /* __KERNEL__ */
23016+#endif /* __ASMPARISC_ELF_H */
23017diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-ppc/elf.h linux/include/asm-ppc/elf.h
23018--- linux-2.4.3/include/asm-ppc/elf.h Sat Feb 3 14:51:14 2001
23019+++ linux/include/asm-ppc/elf.h Fri Mar 30 17:25:23 2001
23020@@ -68,8 +68,6 @@
23021
23022 #define ELF_PLATFORM (NULL)
23023
23024-#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
23025-
23026 /*
23027 * We need to put in some extra aux table entries to tell glibc what
23028 * the cache block size is, so it can use the dcbz instruction safely.
23029@@ -89,5 +87,17 @@
23030 NEW_AUX_ENT(2, AT_UCACHEBSIZE, ucache_bsize); \
23031 } while (0)
23032
23033+#define SET_ELF_PERSONALITY(ex, interp) \
23034+do { \
23035+ unsigned long personality = PER_LINUX; \
23036+ \
23037+ /* Check the interpreter for SVR4isms */ \
23038+ else if (strcmp((interp), "/usr/lib/libc.so.1") == 0 || \
23039+ strcmp((interp), "/usr/lib/ld.so.1") == 0) \
23040+ personality = PER_SVR4; \
23041+ \
23042+ set_personality(personality); \
23043+} while (0)
23044+
23045 #endif /* __KERNEL__ */
23046-#endif
23047+#endif /* __PPC_ELF_H */
23048diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-s390/elf.h linux/include/asm-s390/elf.h
23049--- linux-2.4.3/include/asm-s390/elf.h Fri Feb 23 20:12:50 2001
23050+++ linux/include/asm-s390/elf.h Fri Mar 30 17:25:23 2001
23051@@ -75,7 +75,18 @@
23052 #define ELF_PLATFORM (NULL)
23053
23054 #ifdef __KERNEL__
23055-#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
23056-#endif
23057
23058-#endif
23059+#define SET_ELF_PERSONALITY(ex, interp) \
23060+do { \
23061+ unsigned long personality = PER_LINUX; \
23062+ \
23063+ /* Check the interpreter for SVR4isms */ \
23064+ else if (strcmp((interp), "/usr/lib/libc.so.1") == 0 || \
23065+ strcmp((interp), "/usr/lib/ld.so.1") == 0) \
23066+ personality = PER_SVR4; \
23067+ \
23068+ set_personality(personality); \
23069+} while (0)
23070+
23071+#endif /* __KERNEL__ */
23072+#endif /* __ASMS390_ELF_H */
23073diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-s390x/elf.h linux/include/asm-s390x/elf.h
23074--- linux-2.4.3/include/asm-s390x/elf.h Fri Feb 23 20:12:51 2001
23075+++ linux/include/asm-s390x/elf.h Fri Mar 30 17:25:23 2001
23076@@ -76,7 +76,18 @@
23077 #define ELF_PLATFORM (NULL)
23078
23079 #ifdef __KERNEL__
23080-#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
23081-#endif
23082
23083-#endif
23084+#define SET_ELF_PERSONALITY(ex, interp) \
23085+do { \
23086+ unsigned long personality = PER_LINUX; \
23087+ \
23088+ /* Check the interpreter for SVR4isms */ \
23089+ else if (strcmp((interp), "/usr/lib/libc.so.1") == 0 || \
23090+ strcmp((interp), "/usr/lib/ld.so.1") == 0) \
23091+ personality = PER_SVR4; \
23092+ \
23093+ set_personality(personality); \
23094+} while (0)
23095+
23096+#endif /* __KERNEL__ */
23097+#endif /* __ASMS390_ELF_H */
23098diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-sh/elf.h linux/include/asm-sh/elf.h
23099--- linux-2.4.3/include/asm-sh/elf.h Wed Jul 12 00:43:45 2000
23100+++ linux/include/asm-sh/elf.h Fri Mar 30 17:25:23 2001
23101@@ -70,7 +70,11 @@
23102 _r->sr = SR_FD; } while (0)
23103
23104 #ifdef __KERNEL__
23105-#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX_32BIT)
23106-#endif
23107
23108+#define SET_ELF_PERSONALITY(ex, interp) \
23109+do { \
23110+ __set_personality(PER_LINUX_32BIT); \
23111+} while (0)
23112+
23113+#endif /* __KERNEL__ */
23114 #endif /* __ASM_SH_ELF_H */
23115diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-sparc/abi.h linux/include/asm-sparc/abi.h
23116--- linux-2.4.3/include/asm-sparc/abi.h Thu Jan 1 01:00:00 1970
23117+++ linux/include/asm-sparc/abi.h Fri Mar 30 17:25:23 2001
23118@@ -0,0 +1,5 @@
23119+#define get_syscall_parameter(regs,n) (regs)->u_regs [(n)+8]
23120+#define set_error(regs,e) (regs)->u_regs [8] = -(e)
23121+#define set_result(regs,r) regs->u_regs [8] = r
23122+#define clear_error(regs)
23123+#define get_result(regs) regs->u_regs [8]
23124diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-sparc/elf.h linux/include/asm-sparc/elf.h
23125--- linux-2.4.3/include/asm-sparc/elf.h Wed Jul 12 04:02:37 2000
23126+++ linux/include/asm-sparc/elf.h Fri Mar 30 17:25:23 2001
23127@@ -105,7 +105,18 @@
23128 #define ELF_PLATFORM (NULL)
23129
23130 #ifdef __KERNEL__
23131-#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
23132-#endif
23133
23134+#define SET_ELF_PERSONALITY(ex, interp) \
23135+do { \
23136+ unsigned long personality = PER_LINUX; \
23137+ \
23138+ /* Check the interpreter for SVR4isms */ \
23139+ else if (strcmp((interp), "/usr/lib/libc.so.1") == 0 || \
23140+ strcmp((interp), "/usr/lib/ld.so.1") == 0) \
23141+ personality = PER_SVR4; \
23142+ \
23143+ set_personality(personality); \
23144+} while (0)
23145+
23146+#endif /* __KERNEL__ */
23147 #endif /* !(__ASMSPARC_ELF_H) */
23148diff -uNr --exclude-from=dontdiff linux-2.4.3/include/asm-sparc64/elf.h linux/include/asm-sparc64/elf.h
23149--- linux-2.4.3/include/asm-sparc64/elf.h Fri Mar 30 14:48:47 2001
23150+++ linux/include/asm-sparc64/elf.h Fri Mar 30 17:25:23 2001
23151@@ -56,10 +56,10 @@
23152 instruction set this cpu supports. */
23153
23154 /* On Ultra, we support all of the v8 capabilities. */
23155-#define ELF_HWCAP ((HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | \
23156- HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV | \
23157- HWCAP_SPARC_V9) | \
23158- ((tlb_type == cheetah) ? HWCAP_SPARC_ULTRA3 : 0))
23159+#define ELF_HWCAP ((HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | \
23160+ HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV | \
23161+ HWCAP_SPARC_V9) | \
23162+ ((tlb_type == cheetah) ? HWCAP_SPARC_ULTRA3 : 0))
23163
23164 /* This yields a string that ld.so will use to load implementation
23165 specific libraries for optimization. This is more specific in
23166@@ -68,39 +68,51 @@
23167 #define ELF_PLATFORM (NULL)
23168
23169 #ifdef __KERNEL__
23170-#define SET_PERSONALITY(ex, ibcs2) \
23171-do { unsigned char flags = current->thread.flags; \
23172- if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
23173- flags |= SPARC_FLAG_32BIT; \
23174- else \
23175- flags &= ~SPARC_FLAG_32BIT; \
23176- if (flags != current->thread.flags) { \
23177- unsigned long pgd_cache = 0UL; \
23178- if (flags & SPARC_FLAG_32BIT) { \
23179- pgd_t *pgd0 = &current->mm->pgd[0]; \
23180- if (pgd_none (*pgd0)) { \
23181- pmd_t *page = pmd_alloc_one_fast(NULL, 0); \
23182- if (!page) \
23183- page = pmd_alloc_one(NULL, 0); \
23184- pgd_set(pgd0, page); \
23185- } \
23186- pgd_cache = pgd_val(*pgd0) << 11UL; \
23187- } \
23188- __asm__ __volatile__( \
23189- "stxa\t%0, [%1] %2\n\t" \
23190- "membar #Sync" \
23191- : /* no outputs */ \
23192- : "r" (pgd_cache), \
23193- "r" (TSB_REG), \
23194- "i" (ASI_DMMU)); \
23195- current->thread.flags = flags; \
23196- } \
23197- \
23198- if (ibcs2) \
23199- set_personality(PER_SVR4); \
23200- else if (current->personality != PER_LINUX32) \
23201- set_personality(PER_LINUX); \
23202+
23203+#define SET_ELF_PERSONALITY(ex, interp) \
23204+do { \
23205+ unsigned long personality = PER_LINUX; \
23206+ unsigned char flags = current->thread.flags; \
23207+ \
23208+ if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
23209+ flags |= SPARC_FLAG_32BIT; \
23210+ else \
23211+ flags &= ~SPARC_FLAG_32BIT; \
23212+ \
23213+ if (flags != current->thread.flags) { \
23214+ unsigned long pgd_cache = 0UL; \
23215+ \
23216+ if (flags & SPARC_FLAG_32BIT) { \
23217+ pgd_t *pgd0 = &current->mm->pgd[0]; \
23218+ \
23219+ if (pgd_none (*pgd0)) { \
23220+ pmd_t *page = pmd_alloc_one_fast(NULL, 0); \
23221+ \
23222+ if (!page) \
23223+ page = pmd_alloc_one(NULL, 0); \
23224+ pgd_set(pgd0, page); \
23225+ } \
23226+ \
23227+ pgd_cache = pgd_val(*pgd0) << 11UL; \
23228+ } \
23229+ __asm__ __volatile__( \
23230+ "stxa\t%0, [%1] %2\n\t" \
23231+ "membar #Sync" \
23232+ : /* no outputs */ \
23233+ : "r" (pgd_cache), \
23234+ "r" (TSB_REG), \
23235+ "i" (ASI_DMMU)); \
23236+ \
23237+ current->thread.flags = flags; \
23238+ } \
23239+ \
23240+ /* Check the interpreter for SVR4isms */ \
23241+ if (strcmp((interp), "/usr/lib/libc.so.1") == 0 || \
23242+ strcmp((interp), "/usr/lib/ld.so.1") == 0) \
23243+ set_personality(PER_SVR4); \
23244+ else if (current->personality != PER_LINUX32) \
23245+ set_personality(PER_LINUX); \
23246 } while (0)
23247-#endif
23248
23249+#endif /* __KERNEL__ */
23250 #endif /* !(__ASM_SPARC64_ELF_H) */
23251diff -uNr --exclude-from=dontdiff linux-2.4.3/include/linux/major.h linux/include/linux/major.h
23252--- linux-2.4.3/include/linux/major.h Fri Mar 30 14:45:55 2001
23253+++ linux/include/linux/major.h Fri Mar 30 17:25:23 2001
23254@@ -63,6 +63,7 @@
23255 #define ACSI_MAJOR 28
23256 #define AZTECH_CDROM_MAJOR 29
23257 #define GRAPHDEV_MAJOR 29 /* SparcLinux & Linux/68k /dev/fb */
23258+#define SOCKSYS_MAJOR 30 /* iBCS needs this for STREAMS-based TCP/IP */
23259 #define SHMIQ_MAJOR 85 /* Linux/mips, SGI /dev/shmiq */
23260 #define CM206_CDROM_MAJOR 32
23261 #define IDE2_MAJOR 33
23262diff -uNr --exclude-from=dontdiff linux-2.4.3/include/linux/personality.h linux/include/linux/personality.h
23263--- linux-2.4.3/include/linux/personality.h Mon Dec 11 21:49:54 2000
23264+++ linux/include/linux/personality.h Fri Mar 30 17:27:44 2001
23265@@ -6,9 +6,11 @@
23266 #include <asm/current.h>
23267
23268 /* Flags for bug emulation. These occupy the top three bytes. */
23269-#define STICKY_TIMEOUTS 0x4000000
23270-#define WHOLE_SECONDS 0x2000000
23271+#define MMAP_PAGE_ZERO 0x0100000
23272 #define ADDR_LIMIT_32BIT 0x0800000
23273+#define SHORT_INODE 0x1000000
23274+#define WHOLE_SECONDS 0x2000000
23275+#define STICKY_TIMEOUTS 0x4000000
23276
23277 /* Personality types. These go in the low byte. Avoid using the top bit,
23278 * it will conflict with error returns.
23279@@ -16,20 +18,28 @@
23280 #define PER_MASK (0x00ff)
23281 #define PER_LINUX (0x0000)
23282 #define PER_LINUX_32BIT (0x0000 | ADDR_LIMIT_32BIT)
23283-#define PER_SVR4 (0x0001 | STICKY_TIMEOUTS)
23284-#define PER_SVR3 (0x0002 | STICKY_TIMEOUTS)
23285-#define PER_SCOSVR3 (0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS)
23286-#define PER_WYSEV386 (0x0004 | STICKY_TIMEOUTS)
23287+#define PER_SVR4 (0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO)
23288+#define PER_SVR3 (0x0002 | STICKY_TIMEOUTS | SHORT_INODE)
23289+#define PER_SCOSVR3 (0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS | SHORT_INODE)
23290+#define PER_WYSEV386 (0x0004 | STICKY_TIMEOUTS | SHORT_INODE)
23291 #define PER_ISCR4 (0x0005 | STICKY_TIMEOUTS)
23292 #define PER_BSD (0x0006)
23293 #define PER_SUNOS (PER_BSD | STICKY_TIMEOUTS)
23294-#define PER_XENIX (0x0007 | STICKY_TIMEOUTS)
23295+#define PER_XENIX (0x0007 | STICKY_TIMEOUTS | SHORT_INODE)
23296 #define PER_LINUX32 (0x0008)
23297 #define PER_IRIX32 (0x0009 | STICKY_TIMEOUTS) /* IRIX5 32-bit */
23298 #define PER_IRIXN32 (0x000a | STICKY_TIMEOUTS) /* IRIX6 new 32-bit */
23299 #define PER_IRIX64 (0x000b | STICKY_TIMEOUTS) /* IRIX6 64-bit */
23300 #define PER_RISCOS (0x000c)
23301 #define PER_SOLARIS (0x000d | STICKY_TIMEOUTS)
23302+#define PER_UW7 (0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO)
23303+
23304+static __inline__ int
23305+personality(int pers)
23306+{
23307+ return (pers & PER_MASK);
23308+}
23309+
23310
23311 /* Prototype for an lcall7 syscall handler. */
23312 typedef void (*lcall7_func)(int, struct pt_regs *);
23313@@ -46,6 +56,10 @@
23314 unsigned char pers_low, pers_high;
23315 unsigned long * signal_map;
23316 unsigned long * signal_invmap;
23317+ struct map_segment * err_map;
23318+ struct map_segment * socktype_map;
23319+ struct map_segment * sockopt_map;
23320+ struct map_segment * af_map;
23321 struct module * module;
23322 struct exec_domain *next;
23323 };
23324@@ -59,9 +73,12 @@
23325 #define get_exec_domain(it) \
23326 if (it && it->module) __MOD_INC_USE_COUNT(it->module);
23327 extern void __set_personality(unsigned long personality);
23328-#define set_personality(pers) do { \
23329- if (current->personality != pers) \
23330- __set_personality(pers); \
23331+#define set_personality(pers) do { \
23332+ if (current->personality != pers) { \
23333+ __set_personality(pers); \
23334+ printk(KERN_DEBUG "[%s:%d]: set personality to %lx\n", \
23335+ current->comm, current->pid, pers); \
23336+ } \
23337 } while (0)
23338 asmlinkage long sys_personality(unsigned long personality);
23339
23340diff -uNr --exclude-from=dontdiff linux-2.4.3/kernel/ksyms.c linux/kernel/ksyms.c
23341--- linux-2.4.3/kernel/ksyms.c Fri Mar 30 14:48:47 2001
23342+++ linux/kernel/ksyms.c Fri Mar 30 17:25:23 2001
23343@@ -58,6 +58,7 @@
23344
23345 extern void *sys_call_table;
23346
23347+extern int max_threads;
23348 extern int sys_tz;
23349 extern int request_dma(unsigned int dmanr, char * deviceID);
23350 extern void free_dma(unsigned int dmanr);
23351@@ -576,3 +576,6 @@
23352
23353 EXPORT_SYMBOL(tasklist_lock);
23354 EXPORT_SYMBOL(pidhash);
23355+
23356+EXPORT_SYMBOL(max_threads);
23357+
This page took 2.712878 seconds and 4 git commands to generate.