Index: PatchLev.h
@@ -3,4 +3,4 @@
  *	directory.
  */
 
-#define PatchLevel "45"
+#define PatchLevel "46"
Index: ChangeLog
@@ -0,0 +1,268 @@
+Index: mincl
+From: knarf@nasim.cube.net (Frank Bartels)
+Date: 22 Jul 1994 06:30:31 +0200
+Message-ID: <m0qQvta-000OGwC@nasim.cube.net>
+
+Here's a small bugfix for the 'mincl' file. bammi's gcc doesn't care
+about it, but Andreas Schwab's MiNT gcc does.
+-------------------------------------------------------------
+Index: ioctl.c tcattr.c include/ioctl.h include/termios.h
+From: nox@jelal.north.de (Juergen Lock)
+Date: 18 Aug 1994 18:27:42 +0200
+Message-ID: <9408171903.AA00235@jelal.north.de>
+
+first termios patches, getting stty (shellutils) running
+-------------------------------------------------------------
+Index: strerror.c
+From: entropy@terminator.rs.itd.umich.edu (Nicholas S Castellano)
+Date: 19 Aug 1994 06:43:21 +0200
+Message-ID: <199408182319.TAA26772@terminator.rs.itd.umich.edu>
+
+baserel bug: go back to pl44 version (remove a few `const')
+-------------------------------------------------------------
+Index: tcattr.c include/termios.h
+From: schwab@issan.informatik.uni-dortmund.de (Andreas Schwab)
+Date: 22 Aug 1994 19:44:09 +0200
+Message-ID: <9408220852.AA19173@issan.informatik.uni-dortmund.de>
+
+Addition to Juergen's patches for the termios emulation in MiNTlib:
+
+I've changed the CS? values to match _TF_?BIT so that they can be
+copied more easily, and fixed a bug in his patch.
+And i added code for backward compatibility since TIOCSETP has changed.
+-------------------------------------------------------------
+Index: getgroup.c getitimer.c getloadavg.c initgroups.c osbind.cpp
+	setegid.c seteuid.c setitimer.c include/limits.h
+	include/mintbind.h include/osbind.h include/param.h
+	include/time.h include/unistd.h
+From: schwab@issan.informatik.uni-dortmund.de (Andreas Schwab)
+Date: 29 Aug 1994 18:03:34 +0200
+Message-ID: <9408290852.AA11271@issan.informatik.uni-dortmund.de>
+
+Here are interfaces for the new functions that MiNT 1.11 provides
+(getloadavg, set/getitimer, initgroups) and some changes to existing
+functions to use the new features, as well as some bug fixes.
+
+In <limits.h> i have changed _POSIX_NGROUPS_MAX to 8 since this is the
+value MiNT provides.
+-------------------------------------------------------------
+Index: strerror.c
+From: benni@schlunz.dfki.uni-sb.de (Benjamin Lorenz)
+Date: 12 Aug 1994 18:02:29 +0200
+Message-ID: <9408121121.AA19308@pfsparc02.phil15.uni-sb.de>
+
+While we are talking about strerror.c, what about changing "access denied"
+into "permission denied"? I'd like that because it's more polite... :-)
+-------------------------------------------------------------
+Index: setvbuf.c
+From: schwab@issan.informatik.uni-dortmund.de (Andreas Schwab)
+Date: 30 Aug 1994 14:34:04 +0200
+Message-ID: <9408300854.AA02166@issan.informatik.uni-dortmund.de>
+
+This patch makes the function setvbuf more robust by checking the
+bmode parameter.
+-------------------------------------------------------------
+Index: tcattr.c include/ioctl.h include/termios.h
+From: nox@jelal.north.de (Juergen Lock)
+Date: 1 Sep 1994 10:59:47 +0200
+Message-ID: <9409010231.AA00068@jelal.north.de>
+
+added ECHOCTL to sg_flags (and termios) so e.g. mgetty can turn it off
+and won't echo the \r after your login name as ^M...
+-------------------------------------------------------------
+Index: setegid.c seteuid.c setregid.c setreuid.c
+From: inf03@Uni-Trier.de (Sascha Blank)
+Date: 5 Sep 1994 19:42:51 +0200
+Message-ID: <9409051059.AA07720@Uni-Trier.De>
+
+replace some files in the MiNTlibs, since the
+library doesn't handle the sete[ug]id() correctly and doesn't know about
+the setre[ug]id() calls.
+
+From: hohmuth@inf.tu-dresden.de (Michael Hohmuth)
+Date: 12 Sep 1994 20:21:29 +0200
+Message-ID: <199409121547.AA17497@irs.inf.tu-dresden.de>
+
+bugfixes
+-------------------------------------------------------------
+Index: tcattr.c
+From: nox@jelal.north.de (Juergen Lock)
+Date: 17 Sep 1994 17:23:40 +0200
+Message-ID: <9409170027.AA00250@jelal.north.de>
+
+compatibility fix (VTIME)
+-------------------------------------------------------------
+Index: link.c mkdir.c opendir.c rename.c rmdir.c symlink.c
+	truncate.c utime.c
+From: nox@jelal.north.de (Juergen Lock)
+Date: 17 Sep 1994 17:23:40 +0200
+Message-ID: <9409170027.AA00250@jelal.north.de>
+
+more EEXIST/EACCESS, ENOTDIR/ENOENT errno fixes...
+-------------------------------------------------------------
+Index: include/time.h
+From: nox@jelal.north.de (Juergen Lock)
+Date: 17 Sep 1994 17:23:40 +0200
+Message-ID: <9409170027.AA00250@jelal.north.de>
+
+fix cpp errors with e.g. `#if CLK_TCK != 0'
+-------------------------------------------------------------
+Index: include/unistd.h
+From: nox@jelal.north.de (Juergen Lock)
+Date: 17 Sep 1994 17:23:40 +0200
+Message-ID: <9409170027.AA00250@jelal.north.de>
+
+fix warnings about _POSIX_VDISABLE redefined
+-------------------------------------------------------------
+Index: include/termios.h
+From: nox@jelal.north.de (Juergen Lock)
+Date: 17 Sep 1994 17:23:40 +0200
+Message-ID: <9409170027.AA00250@jelal.north.de>
+
+fix configure :) (include compiler.h)
+-------------------------------------------------------------
+Index: strerror.c
+From: schwab@issan.informatik.uni-dortmund.de (Andreas Schwab)
+Date: 9 Nov 1994 22:34:04 +0100
+Message-ID: <9411091057.AA06643@issan.informatik.uni-dortmund.de>
+
+The error message for ELOCKED is missing in strerror.c.  I have used
+the text from the comment in errno.h.
+-------------------------------------------------------------
+Index: libgcc2.c mincl
+From: schwab@issan.informatik.uni-dortmund.de (Andreas Schwab)
+Date: 11 Nov 1994 10:38:52 +0100
+Message-ID: <9411110930.AA20927@issan.informatik.uni-dortmund.de>
+
+changes to support gcc 2.6:
+
+- libgcc2.c has new modules (_op_vnew.o _op_vdel.o _eh.o _pure.o), and
+there are a few bug fixes and cleanups.
+-------------------------------------------------------------
+Index: include/linea.h
+From: schwab@issan.informatik.uni-dortmund.de (Andreas Schwab)
+Date: 11 Nov 1994 10:38:52 +0100
+Message-ID: <9411110930.AA20927@issan.informatik.uni-dortmund.de>
+
+changes to support gcc 2.6:
+
+- in <linea.h> the macro linea0() has to be changed so that it
+compiles with -mbaserel, otherwise gcc dies with "fixed or forbidden
+register has been spilled".  This is probably a bug in gcc since
+similar problems occured with the Linux/x86 kernel, where they had to
+change some asm statements to work around this, too.
+-------------------------------------------------------------
+Index: include/mintbind.h
+From: inf03@Uni-Trier.de (Sascha Blank)
+Date: 5 Sep 1994 19:42:51 +0200
+Message-ID: <9409051059.AA07720@Uni-Trier.De>
+
+replace some files in the MiNTlibs, since the
+library doesn't handle the sete[ug]id() correctly and doesn't know about
+the setre[ug]id() calls.
+-------------------------------------------------------------
+Index: lib.h malloc.c realloc.c
+From: schwab@issan.informatik.uni-dortmund.de (Andreas Schwab)
+Date: 13 Dec 1994 11:15:54 +0100
+Message-ID: <9412121106.AA07748@issan.informatik.uni-dortmund.de>
+References: <9412121003.AA12541@faust4.lstm.uni-erlangen.de>
+
+[...] make it possible for free() to return
+memory blocks back to the system, so that the process size can shrink.
+This was part of my patches for emacs, but i'm using this all the
+time, not only for emacs.
+-------------------------------------------------------------
+Index: chmod.c chown.c closedir.c do_stat.c fork.c getgid.c
+	getpid.c getppid.c getuid.c kill.c killpg.c opendir.c
+	readdir.c rewinddi.c sync.c
+Message-Id: <9501311012.AA08775@math.uni-muenster.de>
+From:	Ulrich Kuehn <kuehn@goedel.uni-muenster.de>
+Date:	Tue, 31 Jan 1995 11:12:57 +0100
+
+Hi there!
+
+Here is a patch for the mintlib (based on pl44) for some of the files
+(opendir/readdir/closedir/rewinddir/stat/kill/killpg/chown/chmod/fork/
+getuid/getgid/getpid/getppid/sync)
+to get rid of the MiNT-dependencies. Now only the existence of the
+system call is tested, not the __mint variable.
+This stuff is already tested a bit under Mag!C, so it should work.
+
+adopted to (internal) 45.4, indentation fixes...
+-------------------------------------------------------------
+Index: README
+X-Date: 1995/02/11 20:31:12
+X-From: nox
+
+added note about diff -w (*sigh*)
+-------------------------------------------------------------
+Index: include/limits.h
+X-Date: 1995/02/11 20:35:28
+X-From: nox
+
+upped NAME_MAX to 128 for minixfs pl 11...
+-------------------------------------------------------------
+Index: PatchLev.h fread.c fwrite.c mincl mkfifo.c mknod.c open.c
+	rename.c strerror.c
+X-Date: 1995/02/11 20:57:02
+X-From: nox
+
+made fread/write more robust against NULL *s, added missing fns to mincl,
+(experimental) mkfifo/pty mknod `emulation'
+
+internal release pl 45.4.1
+-------------------------------------------------------------
+Index: linea.c
+From: Thomas Schulze <ts@uni-paderborn.de>
+Date: Tue, 14 Feb 1995 14:10:01 +0100
+Message-Id: <199502141310.OAA25753@austria.uni-paderborn.de>
+
+linea0() update (gcc 2.6.3)
+-------------------------------------------------------------
+Index: PatchLev.h rmdir.c include/PatchLev.h
+X-Date: 1995/02/18 17:31:10
+X-From: nox
+
+rmdir bugfix, internal release pl 45.5
+-------------------------------------------------------------
+Index: AUTHORS README README.46 README.FAQ
+X-Date: 1995/02/21 20:49:28
+X-From: nox
+
+doc updates from knarf... with some changes by me
+-------------------------------------------------------------
+Index: ChangeLog
+X-Date: 1995/03/05 15:28:36
+X-From: nox
+
+new file, changes since pl 45
+-------------------------------------------------------------
+Index: MKChangeLog.pl
+X-Date: 1995/03/05 15:30:24
+X-From: nox
+
+added to distribution, maybe its useful for others...
+-------------------------------------------------------------
+Index: PatchLev.h include/PatchLev.h
+X-Date: 1995/03/05 15:49:10
+X-From: nox
+
+ok you've been waiting long enough...  call this pl46 :)
+-------------------------------------------------------------
+Index: ChangeLog
+X-Date: 1995/03/05 16:15:08
+X-From: nox
+
+updated, pl46
+-------------------------------------------------------------
+Index: include/mintbind.h
+Message-Id: <9501311049.AA09298@math.uni-muenster.de>
+From:	Ulrich Kuehn <kuehn@goedel.uni-muenster.de>
+Subject: New system calls in mintbind.h
+Date:	Tue, 31 Jan 1995 11:49:13 +0100
+
+Hi!
+
+Here is a patch for the mintbind.h file (based of pl 44), but it is
+only for the gnu compiler.
+-------------------------------------------------------------
Index: MKChangeLog.pl
@@ -0,0 +1,73 @@
+#! /usr/bin/perl
+# a quick hack to turn `cvs log' output for a source tree into something
+# more useful for distribution as ChangeLog file... (group changes by
+# log message, sort by date; use author from log message if looks like
+# mail/news article...)
+# From: Juergen Lock "I like perl" <nox@jelal.hb.north.de>
+
+# common root directory, remove from filenames
+$src = "libc/";
+# author to replace for `root', just in case...
+$defauthor = "nox";
+
+while ($_ = $ARGV[0], /^-/) {
+	shift;
+	last if /^--$/;
+	/^-l/ && (++$list);
+}
+while (<>) {
+	if ($lline = (/^-------*$/ .. /^=========*$/)) {
+		if (($lline =~ /E0/ || /^-------*$/) && $text) {
+			if ($lline != 1 || !($text =~ /^=========*$/)) {
+				if (!($text =~ /^(From:?|Date:|Subject:|Message-I[Dd]:|References:)\s+/)) {
+					$author = $defauthor if ($author == "root");
+					$text = "X-From: $author\n\n" . $text;
+				}
+				$dates{$text} = $date if (!$dates{$text} ||
+							$dates{$text} < $date);
+				$file = $dir . $file;
+				undef $dir;
+				if (($files{$text} =~ /(.*\n)*(.*)/) &&
+						(length $2) + (length $file) > 60) {
+					$files{$text} .= "\n\t" . $file ;
+				} else {
+					$files{$text} .= ' ' . $file ;
+				}
+			}
+			undef $text;
+		}
+		if ($hline = (/^-------*$/ .. /^date:.*$/)) {
+			if (/^date:\s+(.*;\s+author:\s+(\S+);.*)$/) {
+				$date = $1;
+				$author = $2;
+			}
+		} else {
+			$text .= $_ if ($text || !/^branches:\s+.*/);
+		}
+		if ($list) {
+			if ($lline == 1) {
+				print "$dir$file:\n\n"
+			} else {
+				print;
+			}
+		}
+	} elsif (/^RCS file:\s+.*\/$src(\S+\/)[^\s\/]*$/) {
+		$dir = $1;
+	} elsif (/^Working file:\s+(\S+)$/) {
+		$file = $1;
+	}
+}
+foreach $text (keys %dates) {
+	$xhead = "Index:$files{$text}\n";
+	if ($text =~ /^X-From:/) {
+		$_ = $dates{$text};
+		s/;.*//;
+		$xhead .= "X-Date: $_\n";
+	}
+	$out{$dates{$text}} = $xhead . $text;
+}
+undef $files, $dates;
+foreach $key (sort(keys %out)) {
+	print $out{$key};
+	print "-------------------------------------------------------------\n";
+}
Index: AUTHORS
@@ -1,8 +1,10 @@
 This is a list, in no particular order, of people who have directly or
 indirectly contributed to the MiNT library.  Please send corrections to
-entropy.
+entropy.  (i guess thats also mintlib@nasim.cube.net now...  -nox :)
 
-entropy@terminator.rs.itd.umich.edu (entropy) (MiNT library maintainer)
+nox@jelal.nasim.cube.net (Juergen Lock) (Code maintainer)
+knarf@nasim.cube.net (Frank Bartels) (Distribution maintainer)
+entropy@terminator.rs.itd.umich.edu (Nick Castellano)
 bammi@cadence.com (Jwahar Bammi) (tos-gcc library maintainer)
 ersmith@netcom.com (Eric R. Smith)
 hohmuth@freia.inf.tu-dresden.de (Michael Hohmuth)
@@ -10,7 +12,6 @@
 dsb@cs.duke.edu (Scott Bigham)
 schwab@ls5.informatik.uni-dortmund.de (Andreas Schwab)
 hyc@hanauma.Jpl.Nasa.Gov (Howard Chu)
-nox@jelal.north.de (Juergen Lock)
 boender@dutiws.twi.tudelft.nl (Hildo Biersma)
 roemer@informatik.uni-frankfurt.de (Kay Roemer)
 Dirk_Haun@wi2.maus.de (Dirk Haun)
@@ -22,8 +23,7 @@
 Markus_Kilbinger@ac.maus.de (Markus Kilbinger)
 NTOMCZAK@vm.ucs.UAlberta.CA (Michal Jaegermann)
 Ole_Arndt@f.maus.de (Ole Arndt)
-Robert.Wilhelm@Physik.TU-Muenchen.DE (Robert Wilhelm)
-rwilhelm@physik.tu-muenchen.de (Robert Wilhelm)
+robert@gaston.nasim.cube.net (Robert Wilhelm)
 Ulf_Moeller@hh2.maus.de (Ulf Moeller)
 ulf@wolfhh.hanse.de
 Uwe_Ohse@pb2.maus.de (Uwe Ohse)
Index: README
@@ -1,51 +1,59 @@
-This is the readme for the MiNT library.
+This is the README for the MiNT library.
 
-To use the library you will nead the header files in mntincNN.zoo (where NN
-is the same patchlevel as the version of the library you're using).
+To use the library you will nead the header files in mntincNN.tgz
+(where NN is the same patchlevel as the version of the library you're
+using).
+
+As of patchlevel 26, Eric R. Smith has turned over maintenance of the
+library to entropy. After patchlevel 45 nox and knarf continued the
+job.  Like Eric and entropy, we only have gcc, so we've recruited a few
+people to act as sub-maintainers for the portions of the library we
+can't test.
 
-As of patchlevel 26, Eric R. Smith has turned over maintenance of the library
-to me (entropy).  Like Eric, I only have GCC, so I've recruited a few people
-to act as sub-maintainers for the portions of the library I can't test.
-
 Here are the maintainers' addresses:
-GNU C and common files:  entropy@terminator.rs.itd.umich.edu (Nick Castellano)
+
+GNU C and common files:  mintlib@nasim.cube.net [nox & knarf]
+      Code:          nox@jelal.nasim.cube.net (Juergen Lock)
+      Distribution:  knarf@nasim.cube.net (Frank Bartels)
+
 Sozobon C/HSC:  dsb@cs.duke.edu (D. Scott Bigham)
 Pure C:  hohmuth@freia.inf.tu-dresden.de (Michael Hohmuth)
 Lattice C:  pvt1-117@nada.kth.se 
 
-Be sure to read the "Changelog" file so that you know what's new in this
-release of the library.
+Be sure to read the "Changelog" file so that you know what's new in
+this release of the library.
 
-Also, please read the "Copyright" file for important copyright information
-concerning some modules in this library.  Some modules, as noted in
-"Copyright", are covered by the GNU General Public License, which you will
-find in the file "GNUGPL2".
+Also, please read the "Copyright" file for important copyright
+information concerning some modules in this library.  Some modules, as
+noted in "Copyright", are covered by the GNU General Public License,
+which you will find in the file "GNUGPL2".
 
-My priorities for the library (in approximately this order) are:
+Our priorities for the library (in approximately this order) are:
 
 1.  Bug fixes, of course!
-2.  UNIX compatibility
-3.  Synchronization with J. Bammi's GCC library
+2.  UNIX compatibility (BSD, POSIX, SysV)
+3.  Synchronization with J. Bammi's GCC library [???]
 4.  Support for compilers other than GCC
 5.  Frills (beautifying code, fixing ugly hacks, etc.)
 6.  Documentation
 
 If you notice a problem with the library but don't know how to fix it,
-please try to provide as much information as possible so that I can locate
+please try to provide as much information as possible so that we can locate
 the problem (a short piece of code demonstrating the bug, for instance).
 
-All top-level sources and all mntinc include files are now in UNIX carriage
-control format (LF line termination).  If your compiler/editor really wants
-carriage returns, you can convert files back to MS-DOS format (CR-LF line
-termination) using the program crlf.ttp supplied in the crlf/ subdirectory
-(source included).  I made this change because many of the programs I use
-get really confused with MS-DOS (TOS) style files.  Also, J. Bammi's GCC
-libs are maintained in the UNIX style, so converting everything will make
-synchronizing the two libraries easier.
-
-If you're sending in patches for the library, please take into consideration
-the following words from Larry Wall, in the manual page for 'patch'.  It
-will make my life so much easier.
+All top-level sources and all mntinc include files are now in UNIX
+carriage control format (LF line termination).  If your compiler/editor
+really wants carriage returns, you can convert files back to MS-DOS
+format (CR-LF line termination) using the program `crlf' supplied in
+the crlf/ subdirectory (source included).  entropy made this change
+because many of the programs he (and others) use get really confused
+with MS-DOS (TOS) style files.  Also, J. Bammi's GCC libs are maintained
+in the UNIX style, so converting everything will make synchronizing the
+two libraries easier.
+
+If you're sending in patches for the library, please take into
+consideration the following words from Larry Wall, in the manual page
+for 'patch'.  It will make our lives so much easier.
 
     NOTES FOR PATCH SENDERS
         There are several things you should bear  in  mind  if  you  are
@@ -67,30 +75,41 @@
         into one file, it is probably wiser  to  group  related  patches
         into separate files in case something goes haywire.
 
-Of course the notes about keeping a patchlevel.h file don't apply in this
-case, because I maintain the patchlev.h file for the library.  But please
-take note of the rest of it, especially the last sentence!
+Of course the notes about keeping a patchlevel.h file don't apply in
+this case, because we maintain the patchlev.h file for the library.  But
+please take note of the rest of it, especially the last sentence!  And,
+please try to avoid diffs -w flag, it makes diff not only ignore ^Ms
+but also ignore (i.e. mess up) changes in indentation!  For the same
+reason we normally won't use `patch -l', so if your mailer etc. does
+funny things to tabs use uuencode, btoa, or `ship'.  (We also have gzip
+and tar of course.  Note those peecee-things like lharc, st-zip and
+friends still regularly cause problems from mangled filenames up to
+`mysterious' crashes and data loss... not only with MiNT btw.)
 
-As of Patchlevel 31, the MiNT library no longer supports any version of 
+As of Patchlevel 31, the MiNT library no longer supports any version of
 GCC before 2.0.
 
-The GCC version of the MiNT library cannot be built on a TOS filesystem, due
-to name conflicts between several modules (for example, _udivmod.o and
-_udivmoddi4.o).  It should work on a cross-compiler or an ST with a
-filesystem such as minixfs.
-
-My configuration, used to build the library on an extended filename
-V2 minixfs with gcc 2.4.5:
-  /mint/bin/mfsconf F: -s n -d n -x t -l n
-  UNIXMODE=bcu/rUxs
+The GCC version of the MiNT library cannot be built on a FAT filesystem,
+due to name conflicts between several modules (for example, _udivmod.o
+and _udivmoddi4.o).  It works on a cross-compiler or an Atari with a
+`real' filesystem such as minixfs. (and faster as well.  it still
+takes something like half a night for a full rebuild and nearly all
+memory on a 4MB ST running in single user mode...)
+
+Our configuration, used to build the library on an extended filename
+V2 minixfs with gcc 2.5.8 or 2.3.3:
+  mfsconf F: -s n -d n -x t -l n [knarf: What for??]
+  UNIXMODE=/brUs
 
 Special thanks go out to Jeff Weiner and the rest of the umich archive posse
-for letting me use terminator for the maintenance of the library.
+for letting me use terminator for the maintenance of the library. (i think
+knarf doesn't do that anymore?  and my cvs tree is here at home  -nox :)
+Anyway thanks to everyone involved...
 
-May the source be with you.  Wish me luck...I'll need it!
+And may the source be with you.
 
-Cheers,
-entropy
+Bye,
+nox & knarf
 
 Eric's original readme file follows:
 ----------------------------------------------------------------------------
Index: README.FAQ
@@ -1,18 +1,19 @@
 This is a draft of the MiNT library FAQ (Frequently Asked Questions).
 
-Please send corrections and additions to the MiNT library maintainer
-(entropy@terminator.rs.itd.umich.edu).
+Please send corrections and additions to the MiNT library maintaining team
+(mintlib@nasim.cube.net).
 
 You should also read the README file and any other documents accompanying
 this release of the MiNT library.
 
 1. What is the MiNT library?
 
-The MiNT library is a C language API (Application Program Interface) for
-MiNT (MiNT is Not TOS).  The MiNT library is maintained by
-entropy@terminator.rs.itd.umich.edu.  MiNT is a multitasking environment for
-the Atari ST/TT/Falcon computers and is available from Atari along with
-MultiTOS.
+The MiNT library is a C language API (Application Program Interface)
+for MiNT (MiNT is Not TOS).  The MiNT library is now maintained by nox
+and knarf (mintlib@nasim.cube.net). MiNT is a multitasking environment
+for the Atari ST/TT/Falcon computers and is available from Atari along
+with MultiTOS. (older versions, later ones now are only available
+on the 'net)
 
 2. What can I do with the MiNT library?
 
@@ -35,6 +36,9 @@
 mlibXXd.tgz:  Diffs to produce version XX of the source from version
 		(XX - 1).  Apply with the program 'patch'.
 
+Some european sites are ftp.uni-muenster.de, ftp.leo.org (what does that
+name mean anyway?  -nox :)
+
 4. What is the '.tgz' extension used on the library distributions?
 
 The '.tgz' extension means the files have been archived with the UNIX
@@ -63,7 +67,7 @@
 
 The library supports GCC.  Any distribution of the library that you get
 should compile and work with GCC.  There is also support for Pure C, Sozobon
-C (Heat 'N Serve C), and Lattice C.  But I don't have any of these except
+C (Heat 'N Serve C), and Lattice C.  But we don't have any of these except
 GCC, so a given version of the library may require some modification to
 compile correctly (yet another reason to get the source code.)
 
@@ -95,9 +99,9 @@
 GEMDOS or MiNT calls.)  As for the lowercase letters, MiNT allows you to use
 either uppercase or lowercase to refer to your files and directories.
 Adding the Minix Filesystem to your MiNT setup will even allow you to use
-mixed-case filenames, and even long filenames.  Using the Minix Filesystem
-will greatly enhance your system if you plan to use lots of UNIX software
-with the MiNT library.
+mixed-case filenames, and even long filenames and (nearly) everything else
+you may be used to from unix filesystems, after all its just a clone of
+early unix' V2 (and V1) filesystems.  Its also much faster than GEMDOS...
 
 10. I installed your binary distribution, but GCC doesn't seem to be able to
 find the library files.  What am I doing wrong?
@@ -221,35 +225,39 @@
 at the source code for the function in question, as some bugs may be
 discussed in comments in the source.
 
-If it seems you've discovered a new bug, try to fix the problem yourself and
-send me a patch.  You should use the program "diff" to produce a patch file
-of differences between the buggy version and your fixed version.  Be sure to
-use either the "-c" or "-u" flag to diff.  For example, if you've changed
-the file "startup.c", and have the original version saved under the name
-"startup.old", you would type:
+If it seems you've discovered a new bug, try to fix the problem yourself
+and send us a patch.  To debug lib functions source-level use a lib
+(or just the offending function) built with TARGET `debug' and use gdb as
+normal, this is another advantage of having the source... (assuming gcc
+of course, don't know about others.)  Then you should use the program
+"diff" to produce a patch file of differences between the buggy version
+and your fixed version.  Be sure to use either the "-c" or "-u" flag to
+diff.  For example, if you've changed the file "startup.c", and have the
+original version saved under the name "startup.old", you would type:
 
 diff -c startup.old startup.c > startup.pat
 
-...and then mail me the file startup.pat.  When mailing patches, please specify
+...and then mail the file startup.pat.  When mailing patches, please specify
 the version of the library you were working with, and give as much detail as
 possible about the problem you have fixed.  Please see the README file
 distributed with the library source for more information on sending patches.
 
-If you cannot fix the problem yourself, please send me a piece of code (as
-small as possible, don't mail me your magnum opus and say "it doesn't work")
+If you cannot fix the problem yourself, please send a piece of code (as
+small as possible, don't mail your magnum opus and say "it doesn't work")
 that demonstrates the bug, and a detailed description of the problem you're
-having.  Be sure to give me enough information about your system (TOS
-version, MiNT version, MiNT library version, and system type), because if I
-can't recreate your problem I probably can't fix it either.
+having.  Be sure to give enough information about your system (TOS
+version, MiNT version, MiNT library version, and system type), because
+if we can't recreate your problem we probably can't fix it either.
 
 14. I'm having a problem with the library that isn't discussed in the FAQ.
 How do I get more help?
 
-Try asking in the newsgroup comp.sys.atari.st.  If you don't have access to
-that newsgroup or if no one there can help you, send mail to me.  I'll try
-to help you out, but I can't really provide full support for new users and
-that sort of thing, as I don't get paid for work on the library and I *do*
-pay long-distance phone charges to access the Internet.
+Try asking in the newsgroup comp.sys.atari.st, or on the MiNT mailing
+list.  If you don't have access to either or if no one there can help you,
+send mail to us.  We'll try to help you out, but can't really provide
+full support for new users and that sort of thing, as we don't get paid
+for work on the library, and net' access still isn't as cheap in this
+country as it is where most(?) of you live...
 
 15. How do I compile a program written for UNIX?
 
Index: chmod.c
@@ -10,33 +10,31 @@
 #include <unistd.h>
 #include "lib.h"
 
-extern int __mint;
 
 int
 chmod(_path, mode)
-       const char *_path;
-       int   mode;
+	const char *_path;
+	int   mode;
 {
-       int  dosattrib = 0, r;
-       char path[PATH_MAX];
+	int  dosattrib = 0, r;
+	char path[PATH_MAX];
 
-       (void)_unx2dos(_path, path);
-
-	if (__mint >= 9) {	/* use MiNT Fchmod function */
-		r = (int)Fchmod(path, mode);
+	(void)_unx2dos(_path, path);
+	r = (int)Fchmod(path, mode);
 #if 1
-		/* Kludge:  on dos filesystems return success for dirs
-		   even though we failed */
-		if ((r == -ENOENT) && (Dpathconf(path, 5) == 2) &&
-		    (Fattrib(path, 0, 0) == FA_DIR))
-			return 0;
-#endif
-		if (r) {
-			errno = -r;
-			return -1;
-		}
+	/* Kludge:  on dos filesystems return success for dirs
+	   even though we failed */
+	if ((r == -ENOENT) && (Dpathconf(path, 5) == 2) &&
+	    (Fattrib(path, 0, 0) == FA_DIR))
 		return 0;
+#endif
+	if (r && (r != -EINVAL)) {
+		errno = -r;
+		return -1;
 	}
+	else if (r != -EINVAL)   /* call was successfull */
+		return 0;
+
 
 /* The following lines ensure that the archive bit isn't cleared */
 	r = Fattrib(path, 0, 0);
@@ -51,19 +49,19 @@
 	if (r & FA_DIR)
 	  dosattrib |= FA_DIR;
 #if 0
-       if (!(mode & S_IREAD))
-               dosattrib |= FA_HIDDEN;
+	if (!(mode & S_IREAD))
+		dosattrib |= FA_HIDDEN;
 #endif
-       if (!(mode & S_IWRITE))
-               dosattrib |= FA_RDONLY;
-       r = Fattrib(path, 1, dosattrib);
-       if (r < 0) {
+	if (!(mode & S_IWRITE))
+		dosattrib |= FA_RDONLY;
+	r = Fattrib(path, 1, dosattrib);
+	if (r < 0) {
 /* GEMDOS doesn't allow chmod on a directory, so pretend it worked */
 		if (dosattrib & FA_DIR)
 		  return 0;
-               errno = -r;
-               return -1;
-       }
-       return 0;
+		errno = -r;
+		return -1;
+	}
+	return 0;
 }
 
Index: chown.c
@@ -11,7 +11,6 @@
 #include <unistd.h>
 #include "lib.h"
 
-extern int __mint;
 
 int
 chown(_name, uid, gid)
@@ -21,14 +20,11 @@
 	int r;
 	char name[PATH_MAX];
 
-	if (__mint >= 9) {
-		(void)_unx2dos(_name, name);
-		r = (int)Fchown(name, uid, gid);
-		if (r && (r != -EINVAL)) {
-			errno = -r;
-			return -1;
-		}
-		return 0;
+	(void)_unx2dos(_name, name);
+	r = (int)Fchown(name, uid, gid);
+	if (r && (r != -EINVAL)) {
+		errno = -r;
+		return -1;
 	}
 	return 0;
 }
Index: closedir.c
@@ -16,18 +16,26 @@
 #include <mintbind.h>
 #include "lib.h"
 
-extern int __mint;
+
+/* Important note: the same comment for the status variable of
+ * opendir/readdir under Metados applies also here.
+ */
+
 extern ino_t __inode;	/* in stat.c */
 
+
 int
 closedir(dirp)
 	DIR *dirp;
 {
-	int r;
+	long r;
 
-	if (__mint > 8) {
-		r = (int)Dclosedir(dirp->handle);
-	} else {
+	if (dirp->handle != 0xff000000L)
+		r = Dclosedir(dirp->handle);
+	else
+		r = 0;
+	if (r == -EINVAL) {
+		/* hmm, something went wrong, just ignore it. */
 		r = 0;
 	}
 	free(dirp);
Index: do_stat.c
@@ -53,7 +53,9 @@
 	short	magic;
 	_DTA	d;
 	int	isdot = 0;
+	static short have_fxattr = 1;  /* for the first call, assume we have it */
 
+
 	if (!_path) {
 		errno = EFAULT;
 		return -1;
@@ -64,36 +66,43 @@
  */
 	nval = _unx2dos(_path, path);
 
-/* for MiNT 0.9 and up, we use the built in stat() call */
-	if (__mint >= 9) {
+	/* try to use the build in stat() call, but if the system does not
+	 * have it, record that and never try again
+	 */
+	if (have_fxattr) {
 		r = Fxattr(lflag, path, st);
-		if (r) {
+		if (r == -EINVAL) {
+			have_fxattr = 0;
+		}
+		else if (r) {
 			if ((r == -EPATH) && _enoent(path)) {
 				r = -ENOENT;
 			}
 			errno = (int) -r;
 			return -1;
 		}
-		__UNIXTIME(st->st_mtime);
-		__UNIXTIME(st->st_atime);
-		__UNIXTIME(st->st_ctime);
-	/* Most versions of Unix count in 512 byte blocks */
-		st->st_blocks = (st->st_blocks * st->st_blksize) / 512;
-	/* if we hit a symbolic link, try to get its size right */
-		if (lflag && ((st->st_mode & S_IFMT) == S_IFLNK)) {
-			char buf[PATH_MAX + 1];
-			char buf1[PATH_MAX + 1];
-			r = Freadlink(PATH_MAX, buf, path);
-			if (r < 0)
-			  {
-				errno = (int) -r;
-				return -1;
-			  }
-			buf[PATH_MAX] = 0;
-			_dos2unx (buf, buf1);
-			st->st_size = strlen (buf1);
+		else {
+			__UNIXTIME(st->st_mtime);
+			__UNIXTIME(st->st_atime);
+			__UNIXTIME(st->st_ctime);
+		/* Most versions of Unix count in 512 byte blocks */
+			st->st_blocks = (st->st_blocks * st->st_blksize) / 512;
+		/* if we hit a symbolic link, try to get its size right */
+			if (lflag && ((st->st_mode & S_IFMT) == S_IFLNK)) {
+				char buf[PATH_MAX + 1];
+				char buf1[PATH_MAX + 1];
+				r = Freadlink(PATH_MAX, buf, path);
+				if (r < 0)
+				  {
+					errno = (int) -r;
+					return -1;
+				  }
+				buf[PATH_MAX] = 0;
+				_dos2unx (buf, buf1);
+				st->st_size = strlen (buf1);
+			}
+			return 0;
 		}
-		return 0;
 	}
 
 /* otherwise, check to see if we have a name like CON: or AUX: */
Index: fork.c
@@ -8,13 +8,8 @@
 fork()
 {
 	int r;
-	extern int __mint;
 
-	if (__mint == 0)
-		r = -EINVAL;
-	else
-		r = (int)Pfork();
-
+	r = (int)Pfork();
 	if (r < 0) {
 		errno = -r;
 		return -1;
Index: fread.c
@@ -31,15 +31,15 @@
 	register unsigned int f;
 	char *data=_data;
 	char *ptr;
-
-	assert((data != NULL));
-	assert((size != 0));
 	
 	f = fp->_flag;
 	if(f & _IORW) f = (fp->_flag |= _IOREAD);
-	if(!(f & _IOREAD) || (f & (_IOERR | _IOEOF)))
+	if(!(f & _IOREAD) || (f & (_IOERR | _IOEOF)) || !size || !count)
 	    return(0);
 
+	assert((data != NULL));
+	assert((size != 0));
+
 	l = 0;
 #ifdef __SOZOBON__
 	n = (unsigned long)count * size;
Index: fwrite.c
@@ -41,7 +41,8 @@
 	}
 
 	if(!(f & _IOWRT)			/* not opened for write? */
-	|| (f & (_IOERR | _IOEOF)))		/* error/eof conditions? */
+	|| (f & (_IOERR | _IOEOF))		/* error/eof conditions? */
+	|| !size || !count)			/* nothing to do? */
 		return(0);
 
 	assert ((data != NULL));
Index: getgid.c
@@ -1,12 +1,22 @@
 #include <types.h>
 #include <unistd.h>
 #include <mintbind.h>
+#include <errno.h>
 
-extern int __mint;
 extern gid_t __gid;
 
 gid_t
 getgid()
 {
-  return __mint ? Pgetgid() : __gid;
+	long r;
+	static short have_getgid = 1;
+
+	if (have_getgid) {
+		r = Pgetgid();
+		if (r == -EINVAL)
+			have_getgid = 0;
+		else
+			return (gid_t)r;
+	}
+	return __gid;
 }
Index: getgroup.c
@@ -22,6 +22,7 @@
 #include <unistd.h>
 #include <grp.h>
 #include <pwd.h>
+#include <mintbind.h>
 #ifdef TEST
 #include <stdlib.h> /* for calloc() */
 #endif
@@ -42,6 +43,19 @@
   if (!__mint)
     return 0;
 
+  if (__mint >= 0x10b)
+    {
+      long r;
+
+      r = Pgetgroups (gsetlen, grpset);
+      if (r < 0)
+	{
+	  errno = -r;
+	  return -1;
+	}
+      return r;
+    }
+
   currgid = getgid();
   if (gsetlen) {
     if (gsetlen < 0 || !grpset) {
Index: getitimer.c
@@ -0,0 +1,26 @@
+#include <unistd.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <mintbind.h>
+
+/* in getrusage.c */
+__EXTERN void _ms2tval __PROTO ((unsigned long, struct timeval *));
+
+int
+getitimer (which, old)
+     int which;
+     struct itimerval *old;
+{
+  long r;
+  long interval, value;
+
+  r = Tsetitimer (which, 0, 0, &interval, &value);
+  if (r < 0)
+    {
+      errno = -r;
+      return -1;
+    }
+  _ms2tval (interval, &old->it_interval);
+  _ms2tval (value, &old->it_value);
+  return 0;
+}
Index: getloadavg.c
@@ -0,0 +1,34 @@
+#include <compiler.h>
+#include <sys/param.h>
+#include <unistd.h>
+#include <errno.h>
+#include <mintbind.h>
+
+extern int __mint;
+
+int
+getloadavg (loadavg, nelem)
+     double *loadavg;
+     int nelem;
+{
+  long uptime, avenrun[3], r;
+  int i;
+
+  if (!__mint)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
+  r = Suptime (&uptime, avenrun);
+  if (r < 0)
+    {
+      errno = (int) -r;
+      return -1;
+    }
+
+  for (i = 0; i < nelem && i < 3; i++)
+    loadavg[i] = (double) avenrun[i] / FSCALE;
+
+  return i;
+}
Index: getpid.c
@@ -2,6 +2,7 @@
 #include <unistd.h>
 #include <basepage.h>
 #include <mintbind.h>
+#include <errno.h>
 
 extern int __mint;
 
Index: getppid.c
@@ -2,11 +2,21 @@
 #include <unistd.h>
 #include <basepage.h>
 #include <mintbind.h>
+#include <errno.h>
 
-extern int __mint;
 
 int
 getppid()
 {
-  return __mint ? Pgetppid() : (int) (((long)(_base->p_parent)) >> 8);
+	long r;
+	static short have_getppid = 1;
+
+	if (have_getppid) {
+		r = Pgetppid();
+		if (r == -EINVAL)
+			have_getppid = 0;
+		else
+			return (int)r;
+	}
+	return (int)(((long)(_base->p_parent)) >> 8);
 }
Index: getuid.c
@@ -2,12 +2,22 @@
 #include <unistd.h>
 #include <osbind.h>
 #include <mintbind.h>
+#include <errno.h>
 
-extern int __mint;
 extern uid_t __uid;
 
 uid_t
 getuid()
 {
-  return __mint ? Pgetuid() : __uid;
+	long r;
+	static short have_getuid = 1;
+
+	if (have_getuid) {
+		r = Pgetuid();
+		if (r == -EINVAL)
+			have_getuid = 0;
+		else
+			return (uid_t)r;
+	}
+	return __uid;
 }
Index: initgroups.c
@@ -0,0 +1,38 @@
+#include <sys/types.h>
+#include <grp.h>
+#include <limits.h>
+#include <string.h>
+#include <errno.h>
+#include <mintbind.h>
+
+int
+initgroups (user, group)
+	char *user;
+	gid_t group;
+{
+  struct group *g;
+  gid_t groups[NGROUPS_MAX];
+  int n;
+  long r;
+
+  n = 0;
+  groups[n++] = group;
+  setgrent ();
+  while (n < NGROUPS_MAX && (g = getgrent ()) != NULL)
+    if (g->gr_gid != group)
+      {
+	char **m;
+
+	for (m = g->gr_mem; *m != NULL; ++m)
+	  if (!strcmp (*m, user))
+	    groups[n++] = g->gr_gid;
+      }
+  endgrent ();
+  r = Psetgroups (n, groups);
+  if (r < 0)
+    {
+      errno = -r;
+      return -1;
+    }
+  return 0;
+}
Index: ioctl.c
@@ -167,6 +167,14 @@
                 return -1;
                 break;
 	      }
+	    case TIOCSETP:
+	      if (__mint <= 0x10a) {
+		r = Fcntl(fd, arg, cmd);
+		if (r != -EINVAL)
+		  break;
+		cmd = TIOCSETN;
+	      }
+	      /*FALLTHRU*/
 	    default:
 	      r = Fcntl(fd, arg, cmd);
 	      break;
Index: kill.c
@@ -7,7 +7,6 @@
 #include <unistd.h>
 #include <mintbind.h>
 
-extern int __mint;
 
 /* vector of signal handlers (for TOS) */
 extern __Sigfunc _sig_handler[];	/* in signal.c */
@@ -18,6 +17,8 @@
 /* which signals are pending? */
 extern long _sigpending;
 
+short _have_pkill = 1;
+
 int
 kill(pid, sig)
 	int pid, sig;
@@ -25,13 +26,19 @@
 	long r;
 	__Sigfunc hndle;
 
-	if (__mint) {
+	if (_have_pkill) {
 		r = Pkill(pid, sig);
-		if (r < 0) {
+		if (r == -EINVAL)
+			_have_pkill = 0;
+		else if (r < 0) {
 			errno = (int) -r;
 			return -1;
 		}
-	} else {
+		else
+			return 0;
+	}
+	/* fall through to TOS emulation */
+
 		if (sig < 0 || sig >= NSIG || (pid && pid != getpid())) {
 			errno = ERANGE;
 			return -1;
@@ -56,6 +63,6 @@
 				(*hndle)(sig);
 			}
 		}
-	}
+
 	return 0;
 }
Index: killpg.c
@@ -18,18 +18,22 @@
 /* which signals are pending? */
 extern long _sigpending;
 
+extern short _have_pkill;
+
 int
 killpg(pgrp, sig)
 	int pgrp, sig;
 {
 	long r;
 
+#if 0
 	if (__mint == 0) {
 		if (pgrp == 0 || pgrp == getpgrp())
 			return kill(getpid(), sig);
 		errno = EINVAL;
 		return -1;
 	}
+#endif
 	if (pgrp < 0) {
 		errno = ERANGE;
 		return -1;
@@ -38,6 +42,12 @@
 	if (__mint < 7) {	/* compensate for a bug in MiNT 0.6 */
 		(void)Syield();
 	}
+	if (r == -EINVAL)
+	{
+		_have_pkill = 0;
+		if (pgrp == 0 || pgrp == getpgrp())
+			return kill(getpid(), sig);
+	}		
 	if (r < 0) {
 		errno = (int) -r;
 		return -1;
Index: lib.h
@@ -75,10 +75,13 @@
 	long valid;
 #define VAL_FREE  0xf4ee0abcL
 #define VAL_ALLOC 0xa11c0abcL
+#define VAL_BORDER 0xb04d0abcL
 
 	struct mem_chunk *next;
 	unsigned long size;
 	};
+#define ALLOC_SIZE(ch) (*(long *) ((char *) (ch) + sizeof (*(ch))))
+#define BORDER_EXTRA ((sizeof (struct mem_chunk) + sizeof (long) + 7) & ~7)
 
 /* linked list of free blocks */
 
Index: libgcc2.c
@@ -1,6 +1,6 @@
 /* More subroutines needed by GCC output code on some machines.  */
 /* Compile this one with gcc.  */
-/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1992, 1993, 1994 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -18,9 +18,10 @@
 along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
-/* As a special exception, if you link this library with files
-   compiled with GCC to produce an executable, this does not cause
-   the resulting executable to be covered by the GNU General Public License.
+/* As a special exception, if you link this library with other files,
+   some of which are compiled with GCC, to produce an executable,
+   this library does not by itself cause the resulting executable
+   to be covered by the GNU General Public License.
    This exception does not however invalidate any other reasons why
    the executable file might be covered by the GNU General Public License.  */
 
@@ -33,7 +34,7 @@
 #include "tconfig.h"
 #include "machmode.h"
 #ifndef L_trampoline
-#include "gstddef.h"
+#include <stddef.h>
 #endif
 
 /* Don't use `fancy_abort' here even if config.h says to use it.  */
@@ -779,7 +780,7 @@
 __umoddi3 (u, v)
      UDItype u, v;
 {
-  DItype w;
+  UDItype w;
 
   (void) __udivmoddi4 (u, v, &w);
 
@@ -1093,6 +1094,9 @@
 #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT)
 #define HIGH_HALFWORD_COEFF (((UDItype) 1) << (WORD_SIZE / 2))
 #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE)
+#define DI_SIZE (sizeof (DItype) * BITS_PER_UNIT)
+#define DF_SIZE 53
+#define SF_SIZE 24
 
 SFtype
 __floatdisf (u)
@@ -1107,6 +1111,22 @@
   if (u < 0)
     u = -u, negate = 1;
 
+  /* Protect against double-rounding error.
+     Represent any low-order bits, that might be truncated in DFmode,
+     by a bit that won't be lost.  The bit can go in anywhere below the
+     rounding position of the SFmode.  A fixed mask and bit position
+     handles all usual configurations.  It doesn't handle the case
+     of 128-bit DImode, however.  */
+  if (DF_SIZE < DI_SIZE
+      && DF_SIZE > (DI_SIZE - DF_SIZE + SF_SIZE))
+    {
+#define REP_BIT ((USItype) 1 << (DI_SIZE - DF_SIZE))
+      if (u >= ((UDItype) 1 << DF_SIZE))
+	{
+	  if ((USItype) u & (REP_BIT - 1))
+	    u |= REP_BIT;
+	}
+    }
   f = (USItype) (u >> WORD_SIZE);
   f *= HIGH_HALFWORD_COEFF;
   f *= HIGH_HALFWORD_COEFF;
@@ -1171,16 +1191,18 @@
 #undef float
 #undef double
 
-/* frills for C++ */
+/* Default free-store management functions for C++, per sections 12.5 and
+   17.3.3 of the Working Paper. */
 
 #ifdef L_op_new
+/* operator new (size_t), described in 17.3.3.5.  This function is used by
+   C++ programs to allocate a block of memory to hold a single object. */
+
 #include <memory.h>
 
 typedef void (*vfp)(void);
-
 extern vfp __new_handler;
 
-/* void * operator new (size_t sz) */
 void *
 __builtin_new (size_t sz)
 {
@@ -1190,53 +1212,63 @@
   if (sz == 0)
     sz = 1;
   p = (void *) malloc (sz);
-  if (p == 0)
-    (*__new_handler) ();
+  while (p == 0)
+    {
+      (*__new_handler) ();
+      p = (void *) malloc (sz);
+    }
+  
   return p;
 }
 #endif /* L_op_new */
 
+#ifdef L_op_vnew
+/* void * operator new [] (size_t), described in 17.3.3.6.  This function
+   is used by C++ programs to allocate a block of memory for an array.  */
+
+extern void * __builtin_new (size_t);
+
+void *
+__builtin_vec_new (size_t sz)
+{
+  return __builtin_new (sz);
+}
+#endif /* L_op_vnew */
+
 #ifdef L_new_handler
+/* set_new_handler (fvoid_t *) and the default new handler, described in
+   17.3.3.2 and 17.3.3.5.  These functions define the result of a failure
+   to allocate the amount of memory requested from operator new or new []. */
 
   /* Avoid forcing the library's meaning of `write' on the user program
      by using the "internal" name (for use within the library)  */
 #define write(fd, buf, n)	_write((fd), (buf), (n))
 
 typedef void (*vfp)(void);
+void __default_new_handler (void);
 
-extern void *__builtin_new (size_t);
-static void default_new_handler (void);
+vfp __new_handler = __default_new_handler;
 
-vfp __new_handler = default_new_handler;
-
 vfp
-__set_new_handler (handler)
-     vfp handler;
+set_new_handler (vfp handler)
 {
   vfp prev_handler;
 
   prev_handler = __new_handler;
-  if (handler == 0) handler = default_new_handler;
+  if (handler == 0) handler = __default_new_handler;
   __new_handler = handler;
   return prev_handler;
 }
 
-vfp
-set_new_handler (handler)
-     vfp handler;
-{
-  return __set_new_handler (handler);
-}
-
 #define MESSAGE "Virtual memory exceeded in `new'\n"
 
-static void
-default_new_handler ()
+void
+__default_new_handler ()
 {
   /* don't use fprintf (stderr, ...) because it may need to call malloc.  */
   /* This should really print the name of the program, but that is hard to
      do.  We need a standard, clean way to get at the name.  */
-  write (2, MESSAGE, sizeof (MESSAGE));
+  write (2, MESSAGE, sizeof (MESSAGE) - 1);
   /* don't call exit () because that may call global destructors which
      may cause a loop.  */
   _exit (-1);
@@ -1244,7 +1276,10 @@
 #endif
 
 #ifdef L_op_delete
-/* void operator delete (void *ptr) */
+/* operator delete (void *), described in 17.3.3.3.  This function is used
+   by C++ programs to return to the free store a block of memory allocated
+   as a single object. */
+
 void
 __builtin_delete (void *ptr)
 {
@@ -1252,6 +1287,22 @@
     free (ptr);
 }
 #endif
+
+#ifdef L_op_vdel
+/* operator delete [] (void *), described in 17.3.3.4.  This function is
+   used by C++ programs to return to the free store a block of memory
+   allocated as an array. */
+
+extern void __builtin_delete (void *);
+
+void
+__builtin_vec_delete (void *ptr)
+{
+  __builtin_delete (ptr);
+}
+#endif
+
+/* End of C++ free-store management functions */
 
 #ifdef L_trampoline
 
@@ -1271,21 +1322,13 @@
 void
 __do_global_dtors ()
 {
-  unsigned nptrs = (unsigned long) __DTOR_LIST__[0];
-  unsigned i;
-
-  /* Some systems place the number of pointers
-     in the first word of the table.
-     On other systems, that word is -1.
-     In all cases, the table is null-terminated.  */
-
-  /* If the length is not recorded, count up to the null.  */
-  if (nptrs == -1)
-    for (nptrs = 0; __DTOR_LIST__[nptrs + 1] != 0; nptrs++);
-
-  /* GNU LD format.  */
-  for (i = nptrs; i >= 1; i--)
-    __DTOR_LIST__[i] ();
+#ifdef DO_GLOBAL_DTORS_BODY
+  DO_GLOBAL_DTORS_BODY;
+#else
+  func_ptr *p;
+  for (p = __DTOR_LIST__ + 1; *p; )
+    (*p++) ();
+#endif
 }
 
 /* Run all the global constructors on entry to the program.  */
@@ -1327,3 +1370,167 @@
 #include "gbl-ctors.h"
 const func_ptr __DTOR_LIST__[2] = {0, 0};
 #endif /* L_ctor_list */
+
+#ifdef L_eh
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct {
+  void *start;
+  void *end;
+  void *exception_handler;
+} exception_table;
+
+struct exception_table_node {
+  exception_table *table;
+  void *start;
+  void *end;
+  struct exception_table_node *next;
+};
+
+static int except_table_pos = 0;
+static void *except_pc = (void *)0;
+static struct exception_table_node *exception_table_list = 0;
+
+static exception_table *
+find_exception_table (pc)
+     void* pc;
+{
+  register struct exception_table_node *table = exception_table_list;
+  for ( ; table != 0; table = table->next)
+    {
+      if (table->start <= pc && table->end > pc)
+	return table->table;
+    }
+  return 0;
+}
+
+/* this routine takes a pc, and the address of the exception handler associated
+   with the closest exception table handler entry associated with that PC,
+   or 0 if there are no table entries the PC fits in.  The algorithm works
+   something like this:
+
+    while(current_entry exists) {
+        if(current_entry.start < pc )
+            current_entry = next_entry;
+        else {
+            if(prev_entry.start <= pc && prev_entry.end > pc) {
+                save pointer to prev_entry;
+                return prev_entry.exception_handler;
+             }
+            else return 0;
+         }
+     }
+    return 0;
+
+   Assuming a correctly sorted table (ascending order) this routine should
+   return the tighest match...
+
+   In the advent of a tie, we have to give the last entry, as it represents
+   an inner block.
+ */
+
+
+void *
+__find_first_exception_table_match(pc)
+void *pc;
+{
+  exception_table *table = find_exception_table (pc);
+  int pos = 0;
+  int best = 0;
+  if (table == 0)
+    return (void*)0;
+#if 0
+  printf("find_first_exception_table_match(): pc = %x!\n",pc);
+#endif
+
+  except_pc = pc;
+
+#if 0
+  /* We can't do this yet, as we don't know that the table is sorted.  */
+  do {
+    ++pos;
+    if (table[pos].start > except_pc)
+      /* found the first table[pos].start > except_pc, so the previous
+	 entry better be the one we want! */
+      break;
+  } while(table[pos].exception_handler != (void*)-1);
+
+  --pos;
+  if (table[pos].start <= except_pc && table[pos].end > except_pc)
+    {
+      except_table_pos = pos;
+#if 0
+      printf("find_first_eh_table_match(): found match: %x\n",table[pos].exception_handler);
+#endif
+      return table[pos].exception_handler;
+    }
+#else
+  while (table[++pos].exception_handler != (void*)-1) {
+    if (table[pos].start <= except_pc && table[pos].end > except_pc)
+      {
+	/* This can apply.  Make sure it is better or as good as the previous
+	   best.  */
+	/* The best one ends first. */
+	if (best == 0 || (table[pos].end <= table[best].end
+			  /* The best one starts last.  */
+			  && table[pos].start >= table[best].start))
+	  best = pos;
+      }
+  }
+  if (best != 0)
+    return table[best].exception_handler;
+#endif
+
+#if 0
+  printf("find_first_eh_table_match(): else: returning NULL!\n");
+#endif
+  return (void*)0;
+}
+
+int
+__throw_type_match (const char *catch_type, const char *throw_type)
+{
+#if 0
+ printf("__throw_type_match (): catch_type = %s, throw_type = %s\n",
+	catch_type, throw_type);
+#endif
+ return strcmp (catch_type, throw_type);
+}
+
+void
+__register_exceptions (exception_table *table)
+{
+  struct exception_table_node *node = (struct exception_table_node*)
+      malloc (sizeof (struct exception_table_node));
+  exception_table *range = table + 1;
+  node->table = table;
+
+  /* This look can be optimized away either if the table
+     is sorted, or if we pass in extra parameters. */
+  node->start = range->start;
+  node->end = range->end;
+  for (range++ ; range->start != (void*)(-1); range++)
+    {
+      if (range->start < node->start)
+	node->start = range->start;
+      if (range->end < node->end)
+	node->end = range->end;
+    }
+
+  node->next = exception_table_list;
+  exception_table_list = node;
+}
+#endif /* L_eh */
+
+#ifdef L_pure
+#include <unistd.h>
+#define MESSAGE "pure virtual method called\n"
+#define write(fd, buf, n)	_write((fd), (buf), (n))
+void
+__pure_virtual ()
+{
+  write (2, MESSAGE, sizeof (MESSAGE) - 1);
+  _exit (-1);
+}
+#endif
Index: linea.c
@@ -6,19 +6,23 @@
 #define __NO_INLINE__
 #include <linea.h>
 
-void linea0() 							
-{									
-	    								
-	__asm__ volatile						
-	("
-		.word   0xA000; 
-		movl    a0,%0;	
-		movl    a1,%1;	
-		movl    a2,%2"						
-	: "=g"(__aline), "=g"(__fonts), "=g"(__funcs)     /* outputs */	
-	: 						  /* inputs  */	
-	: "d0", "d1", "d2", "a0", "a1", "a2"       /* clobbered regs */	
-	);								
+void linea0()                                                   
+{
+        register __LINEA *__xaline __asm__ ("a0");                      \
+        register __FONT **__xfonts __asm__ ("a1");                      \
+        register short (**__xfuncs) (void) __asm__ ("a2");              \
+                                                                        
+        __asm__ volatile                                                
+        ("
+        .word   0xA000"                                         \
+        : "=g"(__xaline), "=g"(__xfonts), "=g"(__xfuncs)  /* outputs */ \
+        :                                                 /* inputs  */ 
+        : "d0", "d1", "d2", "a0", "a1", "a2"       /* clobbered regs */ 
+        );                                                              
+        __aline = __xaline;                                             \
+        __fonts = __xfonts;                                             \
+        __funcs = __xfuncs;                                             \
+
 }
 
 void linea1() 							
Index: link.c
@@ -4,6 +4,7 @@
 #include <mintbind.h>
 #include <param.h>
 #include <unistd.h>
+#include <stat.h>
 #include "lib.h"
 
 extern int __mint;
@@ -28,6 +29,13 @@
 
 	r = Flink(old, new);
 	if (r < 0) {
+		struct stat sb;
+
+		if ((r == -EPATH)) {
+			if (_enoent(Fxattr(1, old, &sb) ? old : new))
+				r = -ENOENT;
+		} else if ((r == -EACCESS) && (!Fxattr(1, new, &sb)))
+			r = -EEXIST;
 		errno = (int) -r;
 		return -1;
 	}
Index: malloc.c
@@ -12,6 +12,7 @@
 #include <string.h>
 #include <assert.h>
 #include <unistd.h>
+#include <osbind.h>
 #include "lib.h"
 
 extern long _stksize;
@@ -54,7 +55,7 @@
   p = &_mchunk_free_list;
   q = _mchunk_free_list.next;
 
-  while ((q != NULL) && (q->size < n))
+  while ((q != NULL) && (q->size < n || q->valid == VAL_BORDER))
 	{
 	p = q;
 	q = q->next;
@@ -63,8 +64,13 @@
 /* if not enough memory, get more from the system */
   if (q == NULL) 
 	{
-	if (((!_split_mem) && (_heapbase != NULL)) || (n > MINHUNK))
+	if (((!_split_mem) && (_heapbase != NULL))
+	    || n + BORDER_EXTRA > MINHUNK)
+	  {
 		sz = n;
+		if (_heapbase == NULL)
+		  sz += BORDER_EXTRA;
+	  }
 	else {
 		sz = MINHUNK;
 		if (MINHUNK < MAXHUNK)
@@ -86,10 +92,24 @@
 	p = &_mchunk_free_list;
 	while (p->next != NULL && q > p->next)
 	  p = p->next;
+	if (_heapbase == NULL)
+	  {
+	    q->size = BORDER_EXTRA;
+	    sz -= BORDER_EXTRA;
+	    q->valid = VAL_BORDER;
+	    ALLOC_SIZE (q) = sz;
+	    q->next = (struct mem_chunk *) ((long) q + BORDER_EXTRA);
+	    q->next->next = p->next;
+	    p = p->next = q;
+	    q = q->next;
+	  }
+	else
+	  {
+	    q->next = p->next;
+	    p->next = q;
+	  }
 	q->size = sz;
-	q->next = p->next;
 	q->valid = VAL_FREE;
-	p->next = q;
 	}
 		
   if (q->size > n + sizeof(struct mem_chunk))
@@ -146,7 +166,7 @@
 
 /* merge after if possible */
   s = (struct mem_chunk * )(((long) r) + r->size);
-  if (q != NULL && s >= q) 
+  if (q != NULL && s >= q && q->valid != VAL_BORDER)
 	{
 	assert(s == q);
 	r->size += q->size;
@@ -162,6 +182,17 @@
     /* remember: r may be below &_mchunk_free_list in memory */
 	{
 	assert(s == r);
+	if (p->valid == VAL_BORDER)
+	  {
+	    if (ALLOC_SIZE (p) == r->size)
+	      {
+		o->next = r->next;
+		Mfree (p);
+	      }
+	    else
+	      p->next = r;
+	    return;
+	  }
 	p->size += r->size;
 	p->next = r->next;
 	r->size = 0;
@@ -175,6 +206,22 @@
 	  _stksize += p->size;
 	  o->next = p->next;	/* o is always != NULL here */
 	}
+	else if (o->valid == VAL_BORDER && ALLOC_SIZE (o) == p->size)
+	  {
+	    q = &_mchunk_free_list;
+	    s = q->next;
+	    while (s != NULL && s < o)
+	      {
+		q = s;
+		s = q->next;
+	      }
+	    if (s)
+	      {
+		assert (s == o);
+		q->next = p->next;
+		Mfree (o);
+	      }
+	  }
 	}
     else
         {
Index: mincl
@@ -13,7 +13,7 @@
 	_ucmpdi2.o _floatdidf.o _floatdisf.o _fixunsdfsi.o _fixunssfsi.o \
 	_fixunsdfdi.o _fixdfdi.o _fixunssfdi.o _fixsfdi.o _op_new.o \
 	_new_handler.o _op_delete.o _trampoline.o __main.o _ctor_list.o \
-	_dtor_list.o _ffsdi2.o
+	_dtor_list.o _ffsdi2.o _op_vnew.o _op_vdel.o _eh.o _pure.o
 
 GCC= 	crtinit.o stksiz.o inistack.o heapbase.o binmode.o \
 	$(GLIB1) $(GLIB2) $(FCOMPD) $(FCOMPS) \
@@ -76,7 +76,7 @@
 	execl.o execle.o execp.o execv.o execve.o \
 	fcntl.o flock.o fork.o fstat.o \
 	getcwd.o getdtabl.o getegid.o geteuid.o getgid.o getgroup.o \
-	getpid.o getppid.o \
+	getitimer.o getpid.o getppid.o \
 	getuid.o getrusag.o getwd.o \
 	inode.o ioctl.o isatty.o isctty.o \
 	kill.o killpg.o link.o lockf.o lseek.o lstat.o \
@@ -85,7 +85,8 @@
 	pause.o pipe.o perror.o pgrp.o popen.o psignal.o putenv.o \
 	read.o readdir.o rewinddi.o rename.o rmdir.o \
 	sbrk.o seekdir.o select.o \
-	setegid.o seteuid.o setgid.o setregid.o setreuid.o setuid.o \
+	setegid.o seteuid.o setgid.o \
+	setitimer.o setregid.o setreuid.o setuid.o \
 	sgtty.o sigactio.o \
 	sigblock.o siglist.o signal.o sleep.o spawn.o spawnve.o spawnvp.o \
 	setrlimi.o stat.o statfs.o symlink.o sysconf.o \
@@ -129,10 +130,10 @@
 .SUFFIXES: .cpp
 
 $(FCOMPD): %.o: _cmpdf2.cpp
-	$(CC) $(PPFLAGS) -DL$* -c $< -o $@
+	$(CC) $(PPFLAGS) -DL$* -x assembler-with-cpp -c $< -o $@
 
 $(FCOMPS): %.o: _cmpsf2.cpp
-	$(CC) $(PPFLAGS) -DL$* -c $< -o $@
+	$(CC) $(PPFLAGS) -DL$* -x assembler-with-cpp -c $< -o $@
 
 .cpp.o:
 	$(CC) $(PPFLAGS) -x assembler-with-cpp -c $< -o $@
@@ -163,10 +164,10 @@
 bcopy.o: bcopy.cpp
 
 bzero.o: %.o: bzero.cpp
-	$(CC) $(PPFLAGS) -DL$* -c $< -o $@
+	$(CC) $(PPFLAGS) -DL$* -x assembler-with-cpp -c $< -o $@
 
 memset.o: %.o: bzero.cpp
-	$(CC) $(PPFLAGS) -DL$* -c $< -o $@
+	$(CC) $(PPFLAGS) -DL$* -x assembler-with-cpp -c $< -o $@
 
 #
 # integer only io stuff
Index: mkdir.c
@@ -32,7 +32,10 @@
 	}
 
 	if (errno != ENOENT) {		/* Return stat error, if other than */
-		return -1;		/* File not found. */
+					/* File not found. */
+		if ((errno == EPATH) && (_enoent(path)))
+			errno = ENOENT;
+		return -1;
 	}
 
 	rv = Dcreate(path);
Index: mkfifo.c
@@ -1,15 +1,88 @@
-/* fake mkfifo -- this always fails */
+/* fake mkfifo -- should even work sometimes now :)  */
 
+#include <mintbind.h>
 #include <errno.h>
 #include <support.h>
 #include <types.h>
+#include <limits.h>
 #include <stat.h>
 
 int
-mkfifo(path, mode)
-	const char *path;
+mkfifo(_path, mode)
+	const char *_path;
 	mode_t mode;
 {
-	errno = EINVAL;
-	return -1;
+	static unsigned long timelast;
+	char path[PATH_MAX], linkf[30] = "u:\\pipe\\n$", *s, c;
+	unsigned long l;
+	unsigned short x;
+	long r;
+	int i;
+	extern int __mint;
+
+	if (__mint < 9) {
+		errno = EINVAL;
+		return -1;
+	}
+	/* create symlink to /pipe/n$ mode id (see open.c)
+	   for id code pid&0x7fff and time>>1 in base-36, this just fits
+	   in pipefs' limit of 14 chars...  */
+
+	_unx2dos(_path, path);
+	s = linkf + sizeof "u:\\pipe\\n$" - 1;
+	*s++ = ((mode >> 6) & 7) + '0';
+	*s++ = ((mode >> 3) & 7) + '0';
+	*s++ = (mode & 7) + '0';
+#if 0
+#define FMODE (FA_HIDDEN)
+	*s++ = ((FMODE & 0xf0) >> 4) + '@';
+	*s++ = (FMODE & 0xf) + '@';
+#endif
+	x = 36 * 36 * 36 - 1 - (Pgetpid () & 0x7fff);
+	c = x % 36;
+	if (c > 9)
+		c += 'a' - '9' - 1;
+	s[2] = c + '0';
+	x /= 36;
+	c = x % 36;
+	if (c > 9)
+		c += 'a' - '9' - 1;
+	s[1] = c + '0';
+	*s = (x / 36) - 10 + 'a';
+
+	/* BUG:  14 char names in /pipe should work but they do not
+	   everywhere... (MiNT 1.10, readdir gets no \0 char)  ok so
+	   then try to squeeze the pid in 2 chars, this is possible
+	   because they are always <= 999 at least in 1.10.  */
+	if (*s == 'z' && s[1] > '7') {
+		*s = s[1];
+		s[1] = s[2];
+		--s;
+	}
+	s += 3;
+	/* make sure time is uniqe, if necessary sleep. */
+	for (; (l = time((long *)0) >> 1) == timelast;
+	    Fselect (1000, 0L, 0L, 0L))
+		;
+	timelast = l;
+	for (i = 0; i < 6; ++i, l /= 36) {
+		c = l % 36;
+		if (c > 9)
+			c += 'a' - '9' - 1;
+		*s++ = c + '0';
+	}
+	*s = 0;
+	r = Fsymlink(linkf, path);
+	if (r) {
+		struct stat sb;
+
+		if ((r == -EPATH)) {
+			if (_enoent(path))
+				r = -ENOENT;
+		} else if ((r == -EACCESS) && (!Fxattr(1, path, &sb)))
+			r = -EEXIST;
+		errno = (int) -r;
+		return -1;
+	}
+	return (int) r;
 }
Index: mknod.c
@@ -1,4 +1,7 @@
-/* fake mknod -- this always fails, except with MinixFS 0.60pl10 or later */
+/* fake mknod -- this always fails, except with MinixFS 0.60pl10 or later
+ * -- or for ptys in /dev and named pipes, they are `emulated' (partly)
+ * using symlinks to /pipe and some kludges in open()...
+ */
 
 #include <errno.h>
 #include <support.h>
@@ -6,11 +9,15 @@
 #include <limits.h>
 #include <types.h>
 #include <mintbind.h>
-#include <errno.h>
+#include <device.h>
 #include "lib.h"
 
 #define MFS_MKNOD 0x10f
 
+#ifndef PIPE_RDEV
+#define PIPE_RDEV 0x7e00
+#endif
+
 int
 mknod(path, mode, dev)
 	const char *path;
@@ -18,17 +25,54 @@
 {
 	long err;
 	char _path[PATH_MAX];
+	extern int __mint;
 
 	if (S_ISDIR(mode)) {
 		return (mkdir(path, (mode_t) mode));
 	}
+	if (S_ISFIFO(mode) || ((mode & S_IFMT) == 010000)) {
+		return (mkfifo(path, (mode_t) mode));
+	}	
 	_unx2dos (path, _path);
 	err = Dcntl (MFS_MKNOD, _path,
 		     ((long) mode & 0xffff) | ((long) dev << 16));
-	if (err < 0)
-	  {
-	    errno = -err;
-	    return -1;
-	  }
-	return 0;
+	if (err >= 0)
+		return 0;
+	if (__mint >= 9 && S_ISCHR(mode) && major(dev) == major(PIPE_RDEV)) {
+	/* create symlink to /pipe/c$ mode Fcreate-mode flag id (see open.c)
+	   use minor | 0x80 for /dev/ptyp* (flag == '-') and minor & 0x7f
+	   for ttyp* (flag = '$'), id is dev & ~0x80
+	 */
+		char linkf[30] = "u:\\pipe\\c$", *s, c;
+
+		s = linkf + sizeof "u:\\pipe\\c$" - 1;
+		*s++ = ((mode >> 6) & 7) + '0';
+		*s++ = ((mode >> 3) & 7) + '0';
+		*s++ = (mode & 7) + '0';
+#define FMODE (FA_HIDDEN|FA_SYSTEM)
+		*s++ = ((FMODE & 0xf0) >> 4) + '@';
+		*s++ = (FMODE & 0xf) + '@';
+		*s++ = '$';
+		if (dev & 0x80) {
+			dev &= ~0x80;
+			s[-1] = '-';
+		}
+		_ultoa (dev, s, 16);
+
+		err = Fsymlink(linkf, _path);
+		if (err) {
+			struct stat sb;
+
+			if ((err == -EPATH)) {
+				if (_enoent(_path))
+					err = -ENOENT;
+			} else if ((err == -EACCESS) && (!Fxattr(1, _path, &sb)))
+				err = -EEXIST;
+			errno = (int) -err;
+			return -1;
+		}
+		return (int) err;
+	}	
+	errno = -err;
+	return -1;
 }
Index: open.c
@@ -11,7 +11,11 @@
 #include <unistd.h>
 #include <stdarg.h>
 #include <stat.h>
+#include <device.h>
 #include "lib.h"
+#ifndef PIPE_RDEV
+#define PIPE_RDEV 0x7e00
+#endif
 
 /*
  * the MiNT kernel uses 0x08 for O_APPEND. For
@@ -58,6 +62,7 @@
 	int modemask;			/* which bits get passed to the OS? */
 	char filename[PATH_MAX];
 	long fcbuf;			/* a temporary buffer for Fcntl */
+	struct stat sb;
 
 #ifdef __STDC__
 	unsigned pmode;
@@ -86,23 +91,37 @@
 			if (iomode & O_APPEND)
 				iomode |= _REALO_APPEND;
 		}
+		rv = Fxattr (0, filename, &sb);
 	} else {
 		modemask = O_ACCMODE;
+		rv = Fattrib (filename, 0, 0);
 	}
 
-	if(Fattrib(filename, 0, 0) >= 0)		/* file exists */
+	if (rv >= 0)		/* file exists */
 	{
 		if((iomode & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) {
 			errno = EEXIST;
-			return -1;
+			return __SMALLEST_VALID_HANDLE - 1;
+		}
+		rv = (int)Fopen(filename,iomode & modemask & ~O_CREAT);
+		if (rv == -ENOENT)
+		/* race: file can disappear between stat and open... */
+			goto noent;
+		if (rv >= 0 && __mint >= 9 && (__mint <= 0x109 ?
+			S_ISFIFO(sb.st_mode) :
+			(major(sb.st_rdev) == major(PIPE_RDEV)))
+		    && ((iomode & O_WRONLY) ? Foutstat(rv) : Finstat(rv)) < 0) {
+		/* /pipe/file still open but noone at other end */
+			(void)Fclose(rv);
+			errno = ENXIO;
+			return __SMALLEST_VALID_HANDLE - 1;
 		}
-		rv = (int)Fopen(filename,iomode & modemask);
 		if ((iomode & ~modemask & O_TRUNC) && (rv >= 0)) {
 			/* Give up if the mode flags conflict */
 			if (iomode & O_RDONLY) {
 				(void)Fclose(rv);
 				errno = EACCES;
-				return -1;
+				return __SMALLEST_VALID_HANDLE - 1;
 			}
 			/* Try the FTRUNCATE first.  If it fails, have GEMDOS
 			   truncate it, then reopen with the correct modes.
@@ -114,7 +133,7 @@
 				rv = (int)Fcreate(filename, 0x00);
 				if (rv < 0) {
 					errno = -rv;
-					return -1;
+					return __SMALLEST_VALID_HANDLE - 1;
 				}
 				(void)Fclose(rv);
 				rv = (int)Fopen(filename,iomode & modemask);
@@ -123,6 +142,9 @@
 	}
 	else					/* file doesn't exist */
 	{
+		char linkf[40];
+		long l;
+noent:
 		if(iomode & O_CREAT) {
 			if (__mint >= 9)
 			  rv = (int) Fopen (filename, iomode & modemask);
@@ -136,8 +158,67 @@
 			if (rv >= 0 && __mint >= 9)
 				(void)Fchmod(filename, pmode);
 		}
-		else
-			rv = -ENOENT;
+	/* difference between MiNT and unix:  unix can create named pipes
+	   (fifos) and ptys anywhere in the filesystem with mknod/mkfifo
+	   and open both ends with standard open(), without O_CREAT.
+	   MiNT keeps all this in /pipe, creating and first open
+	   have to be done thru Fcreate with mode flags encoded as dos
+	   `attributes' and the kernel doesn't know ENXIO. also ptys
+	   use the same filename for both sides and everything in /pipe
+	   unlinks itself at the last close.
+
+	   the idea is when open would return ENOENT or EACCESS on
+	   creating see if its a symlink to /pipe/[cn]$* and then try
+	   the right Fcreate/chmod here...  so mknod/mkfifo can create
+	   a symlink and pass the mknod info in the link:
+		/pipe/c$ pmode Fcreate-mode [flag] id
+		/pipe/n$ pmode [flag] long-id	(Fcreate-mode == pipe)
+
+	   pmode is octal, Fcreate-mode is 2 nibbles + '@', flag is '-'
+	   for pty server side (/dev/ptyp*) or '$' for pty client (ttyp*,
+	   open server side Fcreates this).  the ids only have to be uniqe
+	   and long-id not start with an octal digit...
+	*/
+		if (__mint >= 9 &&
+		    rv == ((iomode & O_CREAT) ? -EACCESS : -ENOENT) &&
+		    Freadlink (sizeof linkf - 1, linkf, filename) >= 0 &&
+		    !strncmp (linkf, "u:\\pipe\\", 8) &&
+		    linkf[9] == '$' && (linkf[8] == 'c' || linkf[8] == 'n') &&
+		    linkf[10] >= '0' && linkf[10] <= '7') {
+			char *p, *q;
+			pmode = strtoul (linkf+10, &q, 8);
+			p = q;
+			if (linkf[8] == 'n')
+				l = (FA_HIDDEN|0x80);
+			else {
+				l = (*p++ & 0xf) << 4;
+				l |= *p++ & 0xf;
+			}
+			if (((l & 0x80) && ((iomode & (O_ACCMODE|O_NDELAY)) ==
+					(O_WRONLY|O_NDELAY))) ||
+			    ((l & FA_SYSTEM) && *p == '$')) {
+				errno = ENXIO;
+				return __SMALLEST_VALID_HANDLE - 1;
+			}
+			if ((iomode & O_ACCMODE) == O_WRONLY) {
+				l |= FA_RDONLY;
+			}
+			if (*p == '-')
+				*p = '$';
+			if (!(l & ~0x80)) {
+				rv = (int) Fopen (filename, (iomode & modemask)|
+					O_CREAT|O_EXCL);
+			} else {
+				rv = (int) Fcreate (linkf, l & ~0x80);
+				if (rv >= 0 && (iomode & O_NDELAY))
+					Fcntl (rv, iomode & modemask, F_SETFL);
+			}
+			if (rv >= 0) {
+				if (!Fchmod (linkf, pmode) &&
+				    !Fxattr (1, filename, &sb))
+					(void)Fchown (linkf, sb.st_uid, sb.st_gid);
+			}
+		}
 	}
 
 	if (rv < (__SMALLEST_VALID_HANDLE)) {
@@ -161,7 +242,8 @@
 	    }
             /* clear the close-on-exec flag */
 	    fcbuf = (long)Fcntl(rv, (long)0, F_GETFD);
-	    (void)Fcntl(rv, fcbuf & ~FD_CLOEXEC, F_SETFD);
+	    if (fcbuf & FD_CLOEXEC)
+		(void)Fcntl(rv, fcbuf & ~FD_CLOEXEC, F_SETFD);
 	}
 	if ((iomode & O_APPEND) && !(modemask & _REALO_APPEND))
 		(void)Fseek(0L, rv, SEEK_END);
Index: opendir.c
@@ -16,9 +16,20 @@
 #include <mintbind.h>
 #include "lib.h"
 
-extern int __mint;
+
+/* Important note: Metados can have opendir for some device and do not
+ * have it for others, so there is no point in having a status variable
+ * saying there is an opendir call. Check this every time.
+ */
+
 extern ino_t __inode;	/* in stat.c */
 
+/* a new value for DIR->status, to indicate that the file system is not
+ * case sensitive.
+ */
+#define _NO_CASE  8
+
+
 DIR *
 opendir(uname)
 	const char *uname;
@@ -38,17 +49,29 @@
 
 	_unx2dos(uname, name);
 
-	if (__mint > 8) {
-		r = Dopendir(name, 0);
+	r = Dopendir(name, 0);
+	if (r != -EINVAL) {
 		if ( (r & 0xff000000L) == 0xff000000L ) {
+			if ((r == -EPATH) && (_enoent(name)))
+				r = -ENOENT;
 			errno = (int) -r;
 			free(d);
 			return 0;
 		}
-		d->handle = r;
-		d->buf.d_off = 0;
-		return d;
+		else {
+			d->handle = r;
+			d->buf.d_off = 0;
+
+			/* test if the file system is case sensitive */
+			r = Dpathconf(name, 6);
+			if (r > 0)
+				d->status = _NO_CASE;
+			else
+				d->status = 0;
+			return d;
+		}
 	}
+	d->handle = 0xff000000L;  /* indicate that the handle is invalid */
 
 /* TOS emulation routines */
 
Index: osbind.cpp
@@ -210,10 +210,24 @@
 	movew	sp@(18+10), sp@-
 	movew	sp@(14+12), sp@-
 	trap	#1
-	addw	#16, sp
+	lea	sp@(14), sp
 	moveml	sp@+, d2/a2
 	rts
 
+	.globl	_trap_1_wwllll
+_trap_1_wwllll:
+	moveml	d2/a2,sp@-
+	movel	sp@(32),sp@-
+	movel	sp@(28+4),sp@-
+	movel	sp@(24+8),sp@-
+	movel	sp@(20+12),sp@-
+	movew	sp@(18+16),sp@-
+	movew	sp@(14+18),sp@-
+	trap	#1
+	lea	sp@(20),sp
+	moveml	sp@+,d2/a2
+	rts
+
 	.globl	_trap_13_w
 _trap_13_w:
 	moveml	d2/a2, sp@-
@@ -413,9 +427,22 @@
 	movel	sp@(16+8), sp@-
 	movew	sp@(14+12), sp@-
 	trap	#14
-	addw	#14, sp
+	lea	sp@(14), sp
 	moveml	sp@+, d2/a2
 	rts
+	
+	.globl	_trap_14_wllll
+_trap_14_wllll:
+	moveml	d2/a2,sp@-
+	movel	sp@(28),sp@-
+	movel	sp@(24+4),sp@-
+	movel	sp@(20+8),sp@-
+	movel	sp@(16+12),sp@-
+	movew	sp@(14+16),sp@-
+	trap	#14
+	lea	sp@(18),sp
+	moveml	sp@+,d2/a2
+	rts
 
 	.globl	_trap_14_wwwwww
 _trap_14_wwwwww:
@@ -427,9 +454,24 @@
 	movew	sp@(18+8), sp@-
 	movew	sp@(14+10), sp@-
 	trap	#14
-	lea	sp@(14), sp
+	lea	sp@(12), sp
 	moveml	sp@+, d2/a2
 	rts
+
+	.globl	_trap_14_wllllll
+_trap_14_wllllll:
+	moveml	d2/a2,sp@-
+	movel	sp@(36),sp@-
+	movel	sp@(32+4),sp@-
+	movel	sp@(28+8),sp@-
+	movel	sp@(24+12),sp@-
+	movel	sp@(20+16),sp@-
+	movel	sp@(16+20),sp@-
+	movew	sp@(14+24),sp@-
+	trap	#14
+	lea	sp@(26),sp
+	moveml	sp@+,d2/a2
+	rts
 
 	.globl	_trap_14_wwwwwww
 _trap_14_wwwwwww:
Index: readdir.c
@@ -16,9 +16,20 @@
 #include <mintbind.h>
 #include "lib.h"
 
-extern int __mint;
+
+/* Important note: under Metados, some file systems can have opendir/readdir/
+ * closdir, so we must not have a status variable for these ones.
+ * Instead, check the directory struct if there was an opendir call.
+ */
+
 extern ino_t __inode;	/* in stat.c */
 
+/* a new value for DIR->status, to indicate that the file system is not
+ * case sensitive.
+ */
+#define _NO_CASE  8
+
+
 struct dirent *
 readdir(d)
 	DIR *d;
@@ -31,7 +42,10 @@
 	_DTA *olddta;
 	struct dirent *dd = &d->buf;
 
-	if (__mint > 8) {
+	if (d->handle != 0xff000000L)  {
+		/* The directory descriptor was optained by calling Dopendir(), as
+		 * there is a valid handle.
+		 */
 		r = (int)Dreaddir((int)(NAME_MAX+1+sizeof(long)), d->handle, (char *) &dbuf);
 		if (r == -ENMFIL)
 			return 0;
@@ -39,11 +53,18 @@
 			errno = (int) -r;
 			return 0;
 		}
-		dd->d_ino = dbuf.ino;
-		dd->d_off++;
-		dd->d_reclen = (short)strlen(dbuf.name);
-		strcpy(dd->d_name, dbuf.name);
-		return dd;
+		else {
+			dd->d_ino = dbuf.ino;
+			dd->d_off++;
+			dd->d_reclen = (short)strlen(dbuf.name);
+			strcpy(dd->d_name, dbuf.name);
+
+			/* if file system is case insensitive, transform name to lowercase */
+			if (d->status == _NO_CASE)
+				strlwr(dd->d_name);
+
+			return dd;
+		}
 	}
 /* ordinary TOS search, using Fsnext. Note that the first time through,
  * Fsfirst has already provided valid data for us; for subsequent
Index: realloc.c
@@ -60,7 +60,8 @@
 
     /* merge after if possible */
     s = (struct mem_chunk * )(((long) p) + p->size);
-    if (t != NULL && s >= t && p->size + t->size >= sz)
+    if (t != NULL && s >= t && p->size + t->size >= sz
+	&& t->valid != VAL_BORDER)
       {
       assert(s == t);
       p->size += t->size;
Index: rename.c
@@ -15,7 +15,7 @@
 	const char *_oldname, *_newname;
 {
 	char oldname[PATH_MAX], newname[PATH_MAX];
-	int rval;
+	int rval, r;
 	struct stat oldstat;
 	struct stat newstat;
 
@@ -36,13 +36,37 @@
 	rval = Frename(0, oldname, newname);
 	if (rval == 0)
 	  return 0;
-	if (rval != -EXDEV && rval != -ENOENT)
+	if (rval != -EXDEV && rval != -ENOENT && rval != -EPATH)
 	  {
-	    (void) Fdelete (newname);
-	    rval = Frename(0, oldname, newname);
+	    if (!strcmp(newname, oldname)) {
+/* on inode-less filesystems do at least catch rename("foo", "foo"); */
+		    errno = EEXIST;
+		    return -1;
+	    }
+	    if (!(r = Fdelete (newname)))
+		    rval = Frename(0, oldname, newname);
+/* kludge for kernel versions that suffer from `too much DOS' :)  i.e.
+ * still look at the files write permission instead of the directories
+ * even on real filesystems and when running in the MiNT domain:
+ * if it says EACCESS and the dest.dir exists try the old link/unlink way...
+ */
+	    if (rval == -EACCESS && r != -EPATH) {
+		if (!(rval = Flink (oldname, newname))) {
+		    if ((r = Fdelete (oldname)) && r != -ENOENT && r != -EPATH) {
+			    (void) Fdelete (newname);
+		    } else {
+			    rval = 0;	/* alright that did it! */
+		    }
+		} else if (rval == -ENOSYS) {
+		    rval = -EACCESS;	/* filesystem doesn't know link()... */
+		}
+	    }
 	  }
 
 	if (rval < 0) {
+		if ((rval == -EPATH) && __mint >= 9 &&
+		    (_enoent(Fxattr(1, oldname, &oldstat) ? oldname : newname)))
+			rval = -ENOENT;
 		errno = -rval;
 		rval = -1;
 	}
Index: rewinddi.c
@@ -16,7 +16,9 @@
 #include <mintbind.h>
 #include "lib.h"
 
-extern int __mint;
+/* See the comment in opendir.c/readdir.c for the use (or better non-use)
+ * of a status variable for the system call being implemented.
+ */
 extern ino_t __inode;	/* in stat.c */
 
 void
@@ -26,7 +28,7 @@
 	long r;
 	_DTA *olddta;
 
-	if (__mint >= 9) {
+	if (dirp->handle != 0xff000000L)  {
 		(void)Drewinddir(dirp->handle);
 		dirp->buf.d_off = 0;
 		return;
Index: rmdir.c
@@ -2,11 +2,13 @@
 /* written by Eric R. Smith and placed in the public domain */
 
 #include <limits.h>
-#include <osbind.h>
+#include <mintbind.h>
 #include <errno.h>
 #include <unistd.h>
 #include "lib.h"
 
+extern int __mint;
+
 int rmdir(_path)
 	const char *_path;
 {
@@ -16,6 +18,24 @@
 	_unx2dos(_path, path);
 	r = Ddelete(path);
 	if (r < 0) {
+		long d;
+
+		if ((r == -EPATH)) {
+			if (_enoent(path))
+				r = -ENOENT;
+		} else if ((r == -EACCESS) && __mint >= 9 &&
+		    (((d = Dopendir(path, 0)) & 0xff000000L) != 0xff000000L)) {
+			char *name;
+			int  rd;
+
+			do
+				rd = (int)Dreaddir((int)(PATH_MAX), d, path);
+			while (rd >= 0 && *(name=path+sizeof(long)) == '.' &&
+				(!*++name || (*name == '.' && !*++name)));
+			if (rd != -ENMFIL)
+				r = -ENOTEMPTY;
+			(void)Dclosedir (d);
+		}
 		errno = -r;
 		r = -1;
 	}
Index: setegid.c
@@ -1,8 +1,27 @@
+#include <types.h>
 #include <unistd.h>
+#include <osbind.h>
+#include <mintbind.h>
+#include <errno.h>
 
+extern int __mint;
+
 int
 setegid(x)
   int x;
 {
-  return setgid(x);
+  long r;
+
+  if (__mint) {
+    if (__mint >= 0x10B) {
+      r = Psetegid(x);
+      if (r < 0) {
+	errno = (int) -r;
+	return -1;
+      }
+    } else {
+      return (setgid (x));
+    }
+  }
+  return 0;
 }
Index: seteuid.c
@@ -1,8 +1,27 @@
+#include <types.h>
 #include <unistd.h>
+#include <osbind.h>
+#include <mintbind.h>
+#include <errno.h>
 
+extern int __mint;
+
 int
 seteuid(x)
   int x;
 {
-  return setuid(x);
+  long r;
+
+  if (__mint) {
+    if (__mint >= 0x10B) {
+      r = Pseteuid(x);
+      if (r < 0) {
+	errno = (int) -r;
+	return -1;
+      }
+    } else {
+      return (setuid (x));
+    }
+  }
+  return 0;
 }
Index: setitimer.c
@@ -0,0 +1,39 @@
+#include <unistd.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <mintbind.h>
+
+/* in getrusage.c */
+__EXTERN void _ms2tval __PROTO ((unsigned long, struct timeval *));
+
+int
+setitimer (which, new, old)
+     int which;
+     const struct itimerval *new;
+     struct itimerval *old;
+{
+  long r;
+  long newint, newval, oldint = 0, oldval = 0;
+
+  if (new)
+    {
+      newint = (new->it_interval.tv_sec * 1000L
+		+ new->it_interval.tv_usec / 1000L);
+      newval = (new->it_value.tv_sec * 1000L
+		+ new->it_value.tv_usec / 1000L);
+    }
+  r = Tsetitimer (which, new ? &newint : 0, new ? &newval : 0,
+		  old ? &oldint : 0, old ? &oldval : 0);
+  if (r < 0)
+    {
+      errno = -r;
+      return -1;
+    }
+
+  if (old)
+    {
+      _ms2tval (oldint, &old->it_interval);
+      _ms2tval (oldval, &old->it_value);
+    }
+  return 0;
+}
Index: setregid.c
@@ -1,9 +1,28 @@
+#include <types.h>
 #include <unistd.h>
+#include <osbind.h>
+#include <mintbind.h>
+#include <errno.h>
 
+extern int __mint;
+
 int
 setregid(rgid,egid)
   int rgid, egid;
 {
-  return setgid(egid);
+  long r;
+
+  if (__mint) {
+    if (__mint >= 0x10B) {
+      r = Psetregid(rgid, egid);
+      if (r < 0) {
+	errno = (int) -r;
+	return -1;
+      }
+    } else {
+      return (setgid (egid));
+    }
+  }
+  return 0;
 }
 
Index: setreuid.c
@@ -1,9 +1,28 @@
+#include <types.h>
 #include <unistd.h>
+#include <osbind.h>
+#include <mintbind.h>
+#include <errno.h>
 
+extern int __mint;
+
 int
 setreuid(ruid,euid)
   int ruid, euid;
 {
-  return setuid(euid);
+  long r;
+
+  if (__mint) {
+    if (__mint >= 0x10B) {
+      r = Psetreuid(ruid, euid);
+      if (r < 0) {
+	errno = (int) -r;
+	return -1;
+      }
+    } else {
+      return (setuid (euid));
+    }
+  }
+  return 0;
 }
 
Index: setvbuf.c
@@ -10,6 +10,8 @@
 int bmode;
 size_t size;
 {
+    if (bmode != _IOFBF && bmode != _IOLBF && bmode != _IONBF)
+      return -1;
     if(fp->_flag & _IOMYBUF)
 	free(fp->_base);
     fp->_flag &= ~(_IOFBF | _IOLBF | _IONBF | _IOMYBUF);
Index: strerror.c
@@ -3,7 +3,7 @@
 
 static char nullstr[] = "unknown error";
 
-char const *const sys_errlist[] =
+char *sys_errlist[] =
 	{
 	"OK",					/* 0 */
 	"error",				/* 1 */
@@ -41,7 +41,7 @@
 	"file not found",			/* 33 */
 	"path not found",			/* 34 */
 	"no more handles",			/* 35 */
-	"access denied",			/* 36 */
+	"permission denied",			/* 36 */
 	"invalid handle",			/* 37 */
 	nullstr,				/* 38 */
 	"out of memory",			/* 39 */
@@ -53,7 +53,7 @@
 	nullstr,				/* 45 */
 	"invalid drive id",			/* 46 */
 	nullstr,				/* 47 */
-	"rename across drives",			/* 48 */
+	"link across devices",			/* 48 */
 	"no more files",			/* 49 */
 	nullstr,				/* 50 */
 	nullstr,				/* 51 */
@@ -63,7 +63,7 @@
 	nullstr,				/* 55 */
 	nullstr,				/* 56 */
 	nullstr,				/* 57 */
-	nullstr,				/* 58 */
+	"locking conflict",			/* 58 */
 	nullstr,				/* 59 */
 	nullstr,				/* 60 */
 	nullstr,				/* 61 */
@@ -90,13 +90,13 @@
 	nullstr,				/* 82 */
 	nullstr,				/* 83 */
 	nullstr,				/* 84 */
-	"file already exists",			/* 85 */
+	"file exists",				/* 85 */
 	"name too long",			/* 86 */
 	"not a tty",				/* 87 */
 	"range error",				/* 88 */
 	"domain error",				/* 89 */
 	"I/O error",				/* 90 */
-	"disk full",				/* 91 */
+	"no space on device",			/* 91 */
 	nullstr,				/* 92 */
 	nullstr,				/* 93 */
 	nullstr,				/* 94 */
@@ -118,7 +118,7 @@
 
 /* Support for Kay Roemer's socket library */
 
-char const *const _sock_errlist[] = {
+char *const _sock_errlist[] = {
 	"Socket operation on non-socket",		/* 300 */
 	"Destination address required",
 	"Message too long",
@@ -165,6 +165,7 @@
 int errnum;
 {
 	extern int sys_nerr;
+	extern char *sys_errlist[];
 
 	if (errnum >= 0 && errnum < sys_nerr)
 		return(sys_errlist[errnum]);
Index: symlink.c
@@ -29,9 +29,13 @@
 		_unx2dos(new, linkname);
 		r = Fsymlink(path, linkname);
 		if (r) {
-			if ((r == -EPATH) && _enoent(linkname)) {
-				r = -ENOENT;
-			}
+			struct stat sb;
+
+			if ((r == -EPATH)) {
+				if (_enoent(path))
+					r = -ENOENT;
+			} else if ((r == -EACCESS) && (!Fxattr(1, path, &sb)))
+				r = -EEXIST;
 			errno = (int) -r;
 			return -1;
 		}
Index: sync.c
@@ -2,73 +2,38 @@
  * FILE
  *	sync.c
  *	
- *	
  * DESCRIPTION
- *	syncing filesystems, makes only sense with mint and
- *	minixfs for now
+ *	syncing filesystems, makes only sense with mint
  *	
  * BUGS
- *	minixfs V 060 PL 5 always syncs all drives, so there will
- *	be too much syncing, since we call Dcntl for all known drives.
- *	
+ *	fsync does the same as sync()
  */
 
 #include <mintbind.h>
-#include <stat.h>
-#include <errno.h>
 #include <support.h>
-#include <string.h>
-
-extern int __mint;
 
-/* from minixfs.h by S N Henson*/
-#define MFS_BASE	0x100
-#define MFS_VERIFY	(MFS_BASE)		/* Return minixfs magic number */
-#define MFS_SYNC	(MFS_BASE|0x01)	/* Sync the filesystem */
-#define MFS_MAGIC	0x18970431		/* Magic number from MFS_VERIFY */
+extern int errno;
 
 /*
  * FUNCTION
  *	int sync(void)
  *	
  * DESCRIPTION
- *	query all known drives for a valid MinixFs
- *	if we find one, sync it.
+ *	call MiNT's sync system call
  */
 int
 sync()
 {
-	long			magic;
-	unsigned long	drives;
-	int				i, rv;
-	char path[4];
-
-	if (!__mint)
-		return 0;
-
-	strcpy(path, "A:\\");
-	
-	drives = Dsetdrv(Dgetdrv());
-
-	drives &= ~0x3;	/* don't sync the floppys */
+	long res;
 	
-	for (i = 2; drives ; i++) {
-		if (drives & (1L << i)) {
-			drives &= ~(1L << i);
-			path[0] = 'A' + i;
-			magic = 0L;
-			if (!Dcntl(MFS_VERIFY, path, &magic) && magic == MFS_MAGIC) {
-				if ((rv = (int)Dcntl(MFS_SYNC, path, 0L)) < 0) {
-					errno = -rv;
-					return -1;
-				}
-			}
-		}
+	res = Sync();
+	if (res < 0)
+	{
+		errno = -res;
+		return -1;
 	}
-		
 	return 0;
-}  /* sync() */
- 
+}
 
 
 /*
@@ -77,40 +42,14 @@
  *	
  * DESCRIPTION
  *	sync all buffers related to file descriptor fd
- *	since MFS 605 always syncs all the buffers, we don't bother
- *	to get the full path.
+ *  for now, just call the sync() function.
  */
 int
 fsync(fd)
 	int	fd;
 {
-	int			rv;
-	long		magic 	= 0L;
-	char		path[4];
-	struct stat	statbuf;
-
-	if (!__mint)
-		return 0;
-	
-	strcpy(path, "A:\\");
-	if (fstat(fd, &statbuf))
-		return -1;			/* errno set from fstat */
-
-	if (statbuf.st_dev >= 32)
-	  /* If mounted via FS_MOUNT, st_dev will be > 0x100.
-	     Pretend that it worked. */
-	  return 0;
-
-	path[0] = 'A'+ statbuf.st_dev;
-	if (!Dcntl(MFS_VERIFY, path, &magic) && magic == MFS_MAGIC) {
-		if ((rv = (int)Dcntl(MFS_SYNC, path, 0L)) < 0) {
-			errno = -rv;
-			return -1;
-		}
-	}
-
-	return 0;
-}  /* fsync() */
+	return sync();
+}
 
 
 #ifdef TEST
Index: tcattr.c
@@ -5,6 +5,7 @@
 
 #include <mintbind.h>
 #include <types.h>
+#include <param.h>
 #include <errno.h>
 #include <file.h>
 #include <ioctl.h>
@@ -12,6 +13,10 @@
 #include <types.h>
 #include <termios.h>
 
+#define VTIME_MS	100  /* count in .1 seconds */
+
+extern int __mint;
+
 int
 tcgetattr(fd, stp)
   int fd;
@@ -21,7 +26,8 @@
   struct tchars t;
   struct ltchars lt;
   short flags;
-  long r;
+  unsigned short vmin[2];
+  long state, r;
 
   r = Fcntl((short) fd, (long) &sg, TIOCGETP);
   if (r < 0) {
@@ -42,32 +48,26 @@
   if (r < 0) {
     flags = 0;
   }
-  stp->c_iflag = (tcflag_t) (IGNBRK
+  r = Fcntl((short) fd, (long) &state, TIOCGSTATE);
+  if (r < 0) {
+    state = 0;
+  }
+  stp->c_iflag = (tcflag_t) (((flags & _TF_BRKINT) ? BRKINT : 0)
 			| ((sg.sg_flags & CRMOD) ? ICRNL : 0)
-			| ((sg.sg_flags & (EVENP | ODDP)) ? INPCK : IGNPAR)
-			| ((sg.sg_flags & TANDEM) ? (IXON | IXOFF) : 0));
-  stp->c_oflag = (tcflag_t) OPOST;
-  stp->c_cflag = (tcflag_t) (CLOCAL | CREAD
+			| ((sg.sg_flags & (EVENP | ODDP)) ? INPCK :
+			 ((sg.sg_flags & RAW) ? 0 : IGNPAR)) /*keep stty happy*/
+			| ((sg.sg_flags & TANDEM) ? (IXON | IXOFF) : 0)
+			| ((sg.sg_flags & RAW) ? 0 : IXON));
+  stp->c_oflag = (tcflag_t) (sg.sg_flags & RAW) ? 0 : OPOST;
+  stp->c_cflag = (tcflag_t) (CREAD
+			| ((flags & _TF_CAR) ? 0 : CLOCAL)
+			| ((state & _TS_HPCL) ? HUPCL : 0)
 			| (((flags & _TF_STOPBITS) == _TF_2STOP) ? CSTOPB : 0)
+			| (flags & _TF_CHARBITS)
+			| ((sg.sg_flags & RTSCTS) ? CRTSCTS : 0)
 			| ((sg.sg_flags & EVENP) ? PARENB : 0)
 			| ((sg.sg_flags & ODDP) ? (PARENB | PARODD) : 0));
-  switch (flags & _TF_CHARBITS)
-  {
-    case _TF_5BIT:
-      stp->c_cflag |= CS5;
-      break;
-    case _TF_6BIT:
-      stp->c_cflag |= CS6;
-      break;
-    case _TF_7BIT:
-      stp->c_cflag |= CS7;
-      break;
-    case _TF_8BIT:
-    default:
-      stp->c_cflag |= CS8;
-      break;
-  }
-  stp->c_lflag = (tcflag_t) ((sg.sg_flags & (TOSTOP | NOFLSH))
+  stp->c_lflag = (tcflag_t) ((sg.sg_flags & (TOSTOP | NOFLSH | ECHOCTL))
 			| ((sg.sg_flags & ECHO) ? (ECHO | ECHOE | ECHOK) : 0)
 			| ((sg.sg_flags & XKEY) ? IEXTEN : 0)
 			| ((sg.sg_flags & RAW)
@@ -84,10 +84,24 @@
   stp->c_cc[VSUSP]	= (cc_t) lt.t_suspc;
   stp->c_cc[VSTART]	= (cc_t) t.t_startc;
   stp->c_cc[VSTOP]	= (cc_t) t.t_stopc;
-  stp->c_cc[VMIN]	= (cc_t) 1;
-  stp->c_cc[VTIME]	= (cc_t) 0;
+  r = Fcntl((short) fd, (long) &vmin, TIOCGVMIN);
+  if (r < 0) {
+    stp->c_cc[VMIN]	= (cc_t) 1;
+    stp->c_cc[VTIME]	= (cc_t) 0;
+  } else {
+    if (vmin[1]) {
+      stp->c_cc[VMIN]	= (cc_t) 0;
+      stp->c_cc[VTIME]	= (cc_t) (vmin[1] >= 0xff*VTIME_MS) ? 0xff : vmin[1]/VTIME_MS;
+    } else {
+      stp->c_cc[VMIN]	= (cc_t) (vmin[0] >= 0xff) ? 0xff : vmin[0];
+      stp->c_cc[VTIME]	= (cc_t) 0;
+    }
+  }
   stp->c_cc[VLNEXT]	= (cc_t) lt.t_lnextc;
   stp->c_cc[VWERASE]	= (cc_t) lt.t_werasc;
+  stp->c_cc[VDSUSP]	= (cc_t) lt.t_dsuspc;
+  stp->c_cc[VREPRINT]	= (cc_t) lt.t_rprntc;
+  stp->c_cc[VFLUSHO]	= (cc_t) lt.t_flushc;
   return 0;
 }
 
@@ -100,8 +114,9 @@
   struct sgttyb sg;
   struct tchars t;
   struct ltchars lt;
-  short flags;
-  long r;
+  short flags, state;
+  unsigned short vmin[2];
+  long bits[2], r;
 
   r = Fcntl((short) fd, (long) &sg, TIOCGETP);
   if (r < 0) {
@@ -113,36 +128,20 @@
     errno = (int) -r;
     return -1;
   }
-  r = Fcntl((short) fd, (long) &flags, TIOCGFLAGS);
-  if (r < 0) {
-    flags = 0;
-  }
-  sg.sg_flags &= ~(CRMOD | TANDEM | EVENP | ODDP | TOSTOP 
-			| NOFLSH | RAW | CBREAK | ECHO | XKEY);
-  flags &= ~(_TF_STOPBITS | _TF_CHARBITS);
+  sg.sg_flags &= ~(CRMOD | TANDEM | RTSCTS | EVENP | ODDP | TOSTOP 
+			| NOFLSH | ECHOCTL | RAW | CBREAK | ECHO | XKEY);
   sg.sg_flags |= (((stp->c_iflag & ICRNL) ? CRMOD : 0)
-			| ((stp->c_iflag & (IXON | IXOFF)) ? TANDEM : 0));
-  flags |= ((stp->c_cflag & CSTOPB) ? _TF_2STOP : _TF_1STOP);
+			| (((stp->c_iflag & (IXON | IXOFF)) == (IXON | IXOFF)) ? TANDEM : 0)
+			| ((stp->c_cflag & CRTSCTS) ? RTSCTS : 0));
+  flags = ((stp->c_cflag & CSTOPB) ? _TF_2STOP : _TF_1STOP) |
+		((stp->c_cflag & CLOCAL) ? 0 : _TF_CAR) |
+		((stp->c_iflag & BRKINT) ? _TF_BRKINT : 0) |
+		(stp->c_cflag & CSIZE);
+  state = (stp->c_cflag & HUPCL) ? _TS_HPCL : 0;
   sg.sg_flags |= ((stp->c_cflag & PARENB)
 			? ((stp->c_cflag & PARODD) ? ODDP : EVENP)
 			: 0);
-  switch (stp->c_cflag & (CS5 | CS6 | CS7 | CS8))
-  {
-    case CS5:
-      flags |= _TF_5BIT;
-      break;
-    case CS6:
-      flags |= _TF_6BIT;
-      break;
-    case CS7:
-      flags |= _TF_7BIT;
-      break;
-    case CS8:
-    default:
-      flags |= _TF_8BIT;
-      break;
-  }
-  sg.sg_flags |= ((stp->c_lflag & (TOSTOP | NOFLSH | ECHO))
+  sg.sg_flags |= ((stp->c_lflag & (TOSTOP | NOFLSH | ECHOCTL | ECHO))
 			| ((stp->c_lflag & IEXTEN) ? XKEY : 0)
 			| ((stp->c_lflag & ISIG)
 			   ? (stp->c_lflag & ICANON ? 0 : CBREAK) : RAW));
@@ -157,15 +156,26 @@
   lt.t_suspc		= (char) stp->c_cc[VSUSP];
   t.t_startc		= (char) stp->c_cc[VSTART];
   t.t_stopc		= (char) stp->c_cc[VSTOP];
+  if (stp->c_cc[VMIN]) {
+  /* have to ignore VTIME when VMIN is set, some programs rely on it... */
+    vmin[0]		= (unsigned char) stp->c_cc[VMIN];
+    vmin[1]		= 0;
+  } else {
+    vmin[0]		= (unsigned char) 1;
+    vmin[1]		= (unsigned short) stp->c_cc[VTIME] * VTIME_MS;
+  }
   lt.t_lnextc		= (char) stp->c_cc[VLNEXT];
   lt.t_werasc		= (char) stp->c_cc[VWERASE];
+  lt.t_dsuspc		= (char) stp->c_cc[VDSUSP];
+  lt.t_rprntc		= (char) stp->c_cc[VREPRINT];
+  lt.t_flushc		= (char) stp->c_cc[VFLUSHO];
   switch (action)
   {
     case TCSAFLUSH:
       tcflush(fd, TCIFLUSH);
       /* fall through */
     case TCSADRAIN:
-      r = Fcntl((short) fd, (long) &sg, TIOCSETP);
+      r = Fcntl((short) fd, (long) &sg, __mint < 0x10b ? TIOCSETN : TIOCSETP);
       if (r < 0) {
         errno = (int) -r;
         return -1;
@@ -192,6 +202,19 @@
     errno = (int) -r;
     return -1;
   }
-  (void) Fcntl((short) fd, (long) &flags, TIOCSFLAGS);
+  bits[0] = (unsigned)flags;
+  bits[1] = _TF_STOPBITS | _TF_CHARBITS | _TF_CAR | _TF_BRKINT;
+  r = Fcntl((short) fd, (long) &bits, TIOCSFLAGSB);
+  if (r < 0) {
+    short sflags = 0;
+    (void) Fcntl((short) fd, (long) &sflags, TIOCGFLAGS);
+    sflags &= ~(_TF_STOPBITS | _TF_CHARBITS);
+    sflags |= flags & (_TF_STOPBITS | _TF_CHARBITS);
+    (void) Fcntl((short) fd, (long) &sflags, TIOCSFLAGS);
+  }
+  (void) Fcntl((short) fd, (long) &vmin, TIOCSVMIN);
+  bits[0] = (unsigned)state;
+  bits[1] = _TS_HPCL;
+  (void) Fcntl((short) fd, (long) &bits, TIOCSSTATEB);
   return 0;
 }
Index: truncate.c
@@ -41,6 +41,8 @@
       res = Dcntl(FTRUNCATE, (long) filename, (long) &length);
       if (res != -EINVAL)
         {
+	  if ((res == -EPATH) && (_enoent(filename)))
+		res = -ENOENT;
           errno = (int) -res;
           return -1;
 	}
@@ -48,6 +50,8 @@
   fh = (int)Fopen (filename, 2);
   if (fh < 0)
     {
+      if ((fh == -EPATH) && (_enoent(filename)))
+	fh = -ENOENT;
       errno = -fh;
       return -1;
     }
Index: utime.c
@@ -88,6 +88,8 @@
 	}
 	if (res != -EINVAL) {
 		if (res < 0) {
+			if ((res == -EPATH) && (_enoent(filename)))
+				res = -ENOENT;
 			errno = (int) -res;
 			return -1;
 		}
@@ -103,6 +105,8 @@
 		    (Fattrib(filename, 0, 0) == FA_DIR))
 			return 0;
 #endif
+		if ((fh == -EPATH) && (_enoent(filename)))
+			fh = -ENOENT;
 		errno = -fh;
 		return -1;
 	}
