9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] a problem with the 9p protocol?
@ 1998-04-04 21:25 Russ
  0 siblings, 0 replies; 2+ messages in thread
From: Russ @ 1998-04-04 21:25 UTC (permalink / raw)


> Where is the problem?

Your problem arises from the way the mount driver handles
mounted file descriptors.  There is a flag CMSG on each fd (well,
each channel) that says whether or not it is mounted.
Once you mount(2) it, the flag gets set.  After the flag is
set, normal reads and writes (via the read and write system
calls) are disallowed, presumably to not interfere with the
9P calls by the mount driver.

> If I run it with:
> 	ramfs -s
> 	filter
> 	mount /srv/filter /tmp/mnt
> it seems to work: 

Right.  In this case, /srv/ramfs has never been mounted directly by the
system, so the associated channel doesn't have the CMSG flag set.
Reads and writes by filter work.

> But if I first mount and
> then unmount the ramfs with:
> 	ramfs -s
> 	mount -c /srv/ramfs /tmp/mnt
> 	unmount /tmp/mnt
> 	filter
> 	mount /srv/filter /tmp/mnt
> I get:
> 	client->server: Tsession tag 65535 		# (from dump)
> 	write server: inappropriate use of fd
> 	mount: mount /srv/filtre /tmp/mnt: fsession: i/o error during authentication

Right.  In this case, /srv/ramfs has been mounted directly,
so CMSG is set. The first time filter calls read or write
(it happens to be a write), it fails.

The phenomenon is more simply demonstrated by
	% ramfs -s
	% echo squeamish ossifrage >>/srv/ramfs
	% mount /srv/ramfs /tmp/mnt
	% unmount /tmp/mnt
	% echo squeamish ossifrage >>/srv/ramfs
	echo: write error: inappropriate use of fd
	%

Russ




^ permalink raw reply	[flat|nested] 2+ messages in thread

* [9fans] a problem with the 9p protocol?
@ 1998-04-04  5:58 Jean
  0 siblings, 0 replies; 2+ messages in thread
From: Jean @ 1998-04-04  5:58 UTC (permalink / raw)




I suppose I missed something in the 9p protocol; has anyone any clue?

I was trying to make a program to filter the 9p messages, a la cfs. The
simplest filter has a simple loop:
	for(;;){
		if ((n = read(client, buffer, sizeof buffer)) < 0)
			error("read client");
		else
			dump("client->server", buffer, n);
		if (write(serveur, buffer, n) < n)
			error("write server");
		if ((n = read(serveur, buffer, sizeof buffer)) < 0)
			error("read server");
		else
			dump("serveur->client", buffer, n);
		if (write(client, buffer, n) < n)
			error("write client");
	}

If I run it with:
	ramfs -s
	filter
	mount /srv/filter /tmp/mnt
it seems to work: I can manipulate files in /tmp/mnt. But if I first mount and
then unmount the ramfs with:
	ramfs -s
	mount -c /srv/ramfs /tmp/mnt
	unmount /tmp/mnt
	filter
	mount /srv/filter /tmp/mnt
I get:
	client->server: Tsession tag 65535 		# (from dump)
	write server: inappropriate use of fd
	mount: mount /srv/filtre /tmp/mnt: fsession: i/o error during authentication

Where is the problem?




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-04-04 21:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-04 21:25 [9fans] a problem with the 9p protocol? Russ
  -- strict thread matches above, loose matches on Subject: below --
1998-04-04  5:58 Jean

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).