I have a situation where I want to take an already-open file descriptor, and make it become /dev/cons before I start a shell. I can't mount it on /dev/cons because it's not a 9p server - just a simple pipe end. If it was a named pipe, I could bind that. fd2path on a pipe just produces: '#|/data' - not a unique name I could bind to. So no help there... I thought I would put it in /srv with a unique name and then bind it over /dev/cons. Starting with a shell that already has the file as fd #2, I tried this: term% echo 2 >/srv/foo term% bind /srv/foo /dev/cons This *almost* works: term% echo hello >>/dev/cons hello term% The problem is that the file in /srv doesn't quite behave like a named pipe end: term% echo hello >/dev/cons /dev/cons: rc: can't open: '/dev/cons' srv file already exists term% I think this is from a check for OTRUNC on open in devsrv in the kernel, which I would guess is being done so people don't accidentally try to use a /srv name that's already in use (I had initially thought it might be a failure from create, or some permissions problem). I tried setting the DMAPPEND bit on the /srv file, in the hopes that that would suppress the OTRUNC, but the kernel srv driver masks off that bit of the file mode, unfortunately. I still haven't been brave enough to go messing with the plan9 kernel.
I'm thinking at this point that I could make a very small 9p file server, serving a file that essentially forwards to and from a file descriptor that the server is given when it starts. I'd mount that on /dev/cons, and I think I can probably make that work. But it seems clumsy, given that a more direct solution seems so close. So I wondering: is there a better way to do this? ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T4a173cfd35edc215-Mdbe4e51c3e84c907521adf60 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
