[comp.os.minix] Fixes for problems with O_APPEND in MINIX 1.5

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

(I posted this before, during the Great Dumping of old articles
to comp.os.minix.  I'm reposting now as part of a few articles of
fixes and additions to MINIX in support of c-news.)

Here's a set of patches to fs/open.c and fs/read.c to fix
behavior on files that are opened with the O_APPEND flag set.

When files are opened with this flag set, the file pointer should
be set to the end of the file.  Also, before every write, the
file pointer should be reset to the end of file before the write
occurs, and then the file pointer should be advanced to the new end of
file.  On stock MINIX 1.5 systems running Earl's stdio, the problem
is obvious when doing an fopen(file, "a") on an existing file that has
length > 0, doing some sort of write like an fprintf(fp, "blah"),
and then an ftell(fp) -- the ftell doesn't return the real position
of the file pointer, just the number of bytes that have been written
to the file.

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...