From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sun, 30 Jul 2000 17:38:07 -0500 From: Steve Harris To: 9fans@cse.psu.edu Subject: Re: [9fans] pipefile Message-ID: <20000730173807.A1371@tiger.home.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Topicbox-Message-UUID: ee47ec3e-eac8-11e9-9e20-41e7f4b1d025 On Sun, 30 Jul 2000 14:54:30 rob pike wrote: > The command is called pipefile; it interposes a command > between you and the named file. ... I'm trying to understand this, but I can't figure out how the original file is actually read/written by this code. I think I'm misunderstanding, but it looks to me like the code produces a "closed loop" of two pipes with the filter command in between, with one side "data" bound over and replacing the original file (I'm with it so far I think). But I don't see how the other side of the pipe, "data1", is connected at all with the contents of the original file ( before it had the bind(TEMP "/data", file, MREPL) done over it ). In fact I don't see how you can access the original file contents at all after the bind() call above has been done in the namespace. Or do we not care about the original file at all? Does rio make keyboard input available for reading through /dev/cons even if we've bound something over the original file with MREPL? What am I missing? Here's the section I don't understand: > file = argv[0]; > if(bind("#|", TEMP, MREPL) < 0) > sysfatal("bind pipe %s: %r", TEMP); > if(bind(TEMP "/data", file, MREPL) < 0) > sysfatal("bind %s %s: %r", TEMP "/data", file); > > if(bcmd != nil){ > fd0 = open(TEMP "/data1", ORDWR); > if(fd0 < 0) > sysfatal("open %s: %r", TEMP "/data1"); > connect(bcmd, fd0, fd0); > close(fd0); > }else{ > fd0 = open(TEMP "/data1", OREAD); > if(fd0 < 0) > sysfatal("open %s: %r", TEMP "/data1"); > connect(wcmd, fd0, 1); > fd1 = open(TEMP "/data1", OWRITE); > if(fd1 < 0) > sysfatal("open %s: %r", TEMP "/data1"); > connect(rcmd, 0, fd1); > close(fd0); > close(fd1); > } > unmount(nil, TEMP); > exits(nil); > } >