[comp.os.minix] Minix 1.5: fix for O_APPEND option in open

ghelmer@dsuvax.uucp (Guy Helmer) (03/15/91)

As part of my work on porting c-news to Minix, I've uncovered some problems
with the implementation of the O_APPEND flag in the open() system call.
First, open() did not set the current position for the file to the end
of file when a file was opened with O_APPEND (this is not normal behavior
compared with every other system I use).  Second, writes would happen
at the end of the file but the file pointer was only incremented by
the number of bytes written instead of being set to the true position
in the file after the write took place.  Fixes to fs/open.c and fs/read.c
follow at the end of this article.

I've tested these changes in my MINIX-386 kernel rather thoroughly
by way of running dbz's regression test.

This problem becomes evident only with Earl Chew's stdio library.  The
stdio library that comes with Minix implements fopen("file", "a") in a way
that doesn't use the O_APPEND flag in the open() system call.

begin 644 O_APPEND-fix.Z
M'YV-*@*">`.GC!L78UR\D9/F3`(C#$$T"2,'!`@<(&#@T%%#AHX8-4#$R)$C
MAH(6*`<6/#@F`14T=212%$E#9`T=&G':$$G29,"?0(.J4/`3A`P:-%@<S0$"
MZ,F41Y/*J'$#!$J4"BQ:-).&S1<X=.2T\,&5#9PO8][4<4,'1`^1.[)J+?LU
M[-BR9].X>>,6!$,X<;6"H`M6+-FN9\VP"7-F3M\WBAG/B;L"A(+*%E^H`)'$
M#(@G7X)`@5+$"1$0:1S/*=,VC!LR(.B@28W:<1B_9<[465RQ;!D6(%:WA?-F
M3AHZ:=ZXB<W7(&S(@[N6:?KBLM8TGE%HA[RX,0@3GT./+DTDA=NWH$63-FW>
M!'CM?\>F^=+F#9GIX)-\H9*%M/D>;^DG11%'5,%$$%*D8-X>U@DF&&%V'6;6
M5\7U%9\/\QFG1QF4@9"`9B!0$<8:>IT!PFULZ#6=&7*\T49L:$Q'QAM?L+%:
M&6N@8)X9:XV!G'(@Q"C';R"(44=;28`PHQLGT&%=`EJML=<=J'EV7&T@N%%&
M&?>1H0-U3UZ8X99K])7$%$44L42'%O4AET5#TE&''&Z@8`89*00&@IL6$270
MD&&0@9!"##D$41HR57111AO5D,-'.XU4TE,MX!8H0@]%-)&B&,5`PT<WS5"5
MI#X)9>I01<4`PPPLJ,J44Q8E(&N<<]99A!%")'%$GG+))2N(8\0X1IEF+!2>
M>N0-UAV8(7B8`'8@H,"=9-\=.QY[(!!GW(_+O67&%QIRV&NL'VXV!!MES"3;
M='HH-UU:;(6A5XG9#KD:6R`4\80150;Y!KHGBJ&6D^0VQ5R1[P)*!Y<N6/02
M;;1I.489<\Q!41X(CQ%&':N=R`8;(*QU!T-T+.P&I2*MVFH,,UAUE:^SLE8K
M"K?FNJN>,`,K++'&IG?M:9&9J$)US<H*K;1!.P:>S^N5!P*#14/IH$7:'I=<
MMX.!F\:&<46=@!EW(4:A8V]5S6W7SI8+PA1HJ,4&;'=,9S'&(H@)+IEFHJGF
M#B($6<:0/S#K+)^6D0OBN>E6M"X([6H)`KQTR.L&O7#8:U!;^O(+;=L`AR'P
DD3`;3`=?8B2<[L*".CR;8Q&7,7'%%V>\<<=A?!RR&R,?9[("
`
end
-- 
Guy Helmer                       | helmer@sdnet.bitnet
Dakota State University          | dsuvax!ghelmer@wunoc.wustl.edu
(605) 256-5264, (605) 256-2788   | uunet!dsuvax!ghelmer
Ahh, if weddings were as easy to design as software...