[comp.os.minix] Minimal version of C-Library in MINIX-ST??

mboen@nixpbe.UUCP (Martin Boening) (05/02/89)

Last week I tried porting zoo to MINIX-ST and noticed something strange:
I achieved compression ratios of 100 - 101 percent. The debug-output gave
a first clue: lzc wrote 0 bytes to output. So I looked at the zoo sources
closely and noticed that for **NIX-like systems the following opening modes
for files are defined:

> #define Z_READ  "r"
> #define Z_WRITE "r+"
> #define Z_RDWR  "r+"
> #define Z_NEW   "w"

In the Minix sources the fopen-Routine doesn't scan the whole modestring
though. It just looks at the first character. As a result, only three modes
are supported:

 'w' -> create file
 'r' -> read file
 'a' -> write to file (append)

i.e with mode 'w', creat is called, with 'r' an 'open (fn, 0)' and with 'w'
an 'open (fn, 1)'.

All, open does is a 'callm3(FS,OPEN,mode,name)'. Looking at do_open I saw
that 3 modes are supported:

  0    read file
  1    write file
  2    read and write file <--!!!

So, why can't fopen do an 'open (fn, 2)' to open a file for reading and
writing when the modestring contains "r+" or "w+". I tried this and now
zoo seems to work alright (some problems with the time settings remain
[did you know that yesterday was may 1st, 1997?:-)])

My question: is the library supplied with MINIX-ST a minimal version? Has
this been fixed? Does anybody know what GCC does and if it handles this
better? Does anybody know of problems that might occur when opening a file
for reading and writing using fopen (buffer problems, etc.) Does anybody
even care to comment ? :-)

Martin

Email:

in Europe: ...!unido!nixpbe!mboening.pad
elsewhere: ...!uunet!philabs!linus!nixbur!mboening.pad
-- 
Email: in the   USA ->  ...!uunet!philabs!linus!nixbur!mboening.pad
       outside  USA ->  {...!mcvax}!unido!nixpbe!mboening.pad

news@dftsrv.gsfc.nasa.gov (news) (05/05/89)

+
In article <284@nixpbe.UUCP> mboen@nixpbe.UUCP (Martin Boening) writes:
+>[stuff del'd] noticed that for **NIX-like systems the following opening modes
+>for files are defined:
+>
+>> #define Z_READ  "r"
+>> #define Z_WRITE "r+"
+>> #define Z_RDWR  "r+"
+>> #define Z_NEW   "w"
+>
+>In the Minix sources the fopen-Routine doesn't scan the whole modestring
+>though. It just looks at the first character. As a result, only three modes
+>are supported:
+>
+> 'w' -> create file
+> 'r' -> read file
+> 'a' -> write to file (append)
+>
+>i.e with mode 'w', creat is called, with 'r' an 'open (fn, 0)' and with 'w'
+>an 'open (fn, 1)'.
+>
+>All, open does is a 'callm3(FS,OPEN,mode,name)'. Looking at do_open I saw
+>that 3 modes are supported:
+>
+>  0    read file
+>  1    write file
+>  2    read and write file <--!!!
+>
+>So, why can't fopen do an 'open (fn, 2)' to open a file for reading and
+>writing when the modestring contains "r+" or "w+". I tried this and now
+>zoo seems to work alright (some problems with the time settings remain
+>[did you know that yesterday was may 1st, 1997?:-)])
+>
+>My question: is the library supplied with MINIX-ST a minimal version? Has
+>this been fixed? Does anybody know what GCC does and if it handles this
+>better? Does anybody know of problems that might occur when opening a file
+>for reading and writing using fopen (buffer problems, etc.) Does anybody
+>even care to comment ? :-)
From: stailey@iris613.gsfc.nasa.gov (Ken Stailey)
Path: iris613!stailey

  What did the real version 7 have?  Maybe it was somewhat small (primitive)
just like MINIX.

  If I have some time this weekend I will try to re-write fopen().  I made
freopen() for my MINIX in order to bring up some forgotten application;
a modern fopen() can't be that hard, because it's so high level.

  I tried to bring up GCC but decided that it was not in the MINIX style
because it was too big.  (Also I only have 5 meg reserved on my HD for MINIX)

							Ken

*========================================================================*
{  eat more disclaimer                           ken@all.over.the.place  }
*========================================================================*

henry@utzoo.uucp (Henry Spencer) (05/06/89)

In article <284@nixpbe.UUCP> mboen@nixpbe.UUCP (Martin Boening) writes:
>In the Minix sources the fopen-Routine doesn't scan the whole modestring
>though. It just looks at the first character. As a result, only three modes
>are supported:
> 'w' -> create file
> 'r' -> read file
> 'a' -> write to file (append)
>
>My question: is the library supplied with MINIX-ST a minimal version? Has
>this been fixed? ...

Here again, Andy is being V7-compatible at the expense of more recent
developments.  V7 did not support the "+" modes.  (Actually, the code
did them but the documentation did not mention them.)  Any modern C
implementation should do them, however.
-- 
Mars in 1980s:  USSR, 2 tries, |     Henry Spencer at U of Toronto Zoology
2 failures; USA, 0 tries.      | uunet!attcan!utzoo!henry henry@zoo.toronto.edu

dtynan@altos86.UUCP (Dermot Tynan) (05/09/89)

In article <198@dftsrv.gsfc.nasa.gov>, news@dftsrv.gsfc.nasa.gov (news) writes:
	[Discussion of fopen(file, "r+")...]
> 
>   What did the real version 7 have?  Maybe it was somewhat small (primitive)
> just like MINIX.
> 

I checked my copy of the V7 manual on this issue not so long ago.  According
to the "V7 Bible", only 'r', 'w' and 'a' are supported.  However, the NEWS
source has '#ifdef V7' all over the place, and no special code to work around
the "r+" problem.  I posted something to news.software.b, and got the reply
that V7 does indeed support "r+", it is just undocumented.  Have fun...
						- Der
-- 
My address:	dtynan@altos86.Altos.COM	(Hopefully!)
Otherwise:	{altnet,amdahl,pyramid,sun}!altos86!dtynan

  ---  "May the blessings of Jeyes Fluid fall upon you"  ---