From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <13426df10912050832l3b1674a3sbd5e15f5ba040315@mail.gmail.com> References: <45bb8a0916edcb2ee86883ebeea8945e@brasstown.quanstro.net> <20091205081032.GJ8759@nipl.net> <8ccc8ba40912050344od31827by29522b75a51892c6@mail.gmail.com> <13426df10912050832l3b1674a3sbd5e15f5ba040315@mail.gmail.com> Date: Sat, 5 Dec 2009 18:01:56 +0100 Message-ID: <8ccc8ba40912050901n223b5634pc86a7cb32dd432e9@mail.gmail.com> From: Francisco J Ballesteros To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Subject: Re: [9fans] ideas for helpful system io functions Topicbox-Message-UUID: a888b95a-ead5-11e9-9d60-3106f5b1d025 I mostly agree, but, if you read one char at a time it's likely you'll become quite slow, in general. An external process providing `buffering' so you can seek back if you want, seems to me like a more general solution that does not require a kernel change. In any case, if I gave the impression that it's not worth to experiment, I apologize. that's not what I tried to say. On Sat, Dec 5, 2009 at 5:32 PM, ron minnich wrote: > On Sat, Dec 5, 2009 at 3:44 AM, Francisco J Ballesteros wrote: > >> If you insist on 'unreading', you could just put a front-end process that >> keeps per-request data so that your external process can ask the >> front-end for all the data again. > > The easiest way to implement unread is not to read in the first place. > > If you're only reading small amounts of data, say less then 1024 > bytes, and then forking a process to handle the rest, then by all > means don't use IO that reads in lots of data you may not want. > Instead: > > read(fd, &c, 1); > > and then there's no "overread" to deal with. > > That said, you can prototype unread() so why not? > unread(fd, data, size); > > Attach the "unread" data to the open file struct, modify read so that > if it sees this data it reads it first, try it out. Why not? Plan 9 is > there to be hacked on, so hack it. > > Sam, the rule is, just do it. This hackability is one thing that makes > Plan 9 so attractive. > > ron > >