9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Giacomo Tesio <giacomo@tesio.it>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: [9fans] read9pmsg usage
Date: Mon, 10 Aug 2015 16:11:19 +0200	[thread overview]
Message-ID: <CAHL7psFD9_xWyfPTbh0tCY80=KfRUzfkh5rm_Fij8WJzw2NmJg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1335 bytes --]

Hi, I've a probably naive question that I can't figure out.
I've just noticed that fcall(2) states

> Read9pmsg calls read(2) multiple times, if necessary, to
> read an entire 9P message into buf.  The return value is 0
> for end of file, or -1 for error; it does not return partial
> messages.
>
>
but I've noticed that a few client does not interpret a 0 return value as a
EOF, eg

https://github.com/brho/plan9/blob/master/sys/src/cmd/usb/lib/fs.c#L604-L606
https://github.com/brho/plan9/blob/master/sys/src/cmd/usb/audio/audiofs.c#L889-L891
https://github.com/brho/plan9/blob/master/sys/src/cmd/aux/searchfs.c#L613-L615
https://github.com/brho/plan9/blob/master/sys/src/cmd/lnfs.c#L547-L551
https://github.com/brho/plan9/blob/master/sys/src/cmd/telco/telco.c#L935-L937

The comment there states that

/*
 * reading from a pipe or a network device
 * will give an error after a few eof reads.
 * however, we cannot tell the difference
 * between a zero-length read and an interrupt
 * on the processes writing to us,
 * so we wait for the error.
 */

However many other fs just handle errors and eof together, for example here:
https://github.com/brho/plan9/blob/master/sys/src/cmd/ip/ftpfs/ftpfs.c#L273-L279

I'm a bit confused about this. What's the proper use of the 0 return value?


Giacomo

[-- Attachment #2: Type: text/html, Size: 2165 bytes --]

             reply	other threads:[~2015-08-10 14:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-10 14:11 Giacomo Tesio [this message]
2015-08-10 14:22 ` erik quanstrom
2015-08-10 14:35   ` Giacomo Tesio
2015-08-10 14:54     ` Charles Forsyth
2015-08-10 15:40       ` Charles Forsyth
2015-08-10 20:17       ` Giacomo Tesio
2015-08-10 20:33         ` Charles Forsyth
2015-08-11 15:48 ` Charles Forsyth
2015-08-12  0:21   ` Giacomo Tesio
2015-08-12  7:25     ` David du Colombier
2015-08-12  9:18       ` Giacomo Tesio
2015-08-12 17:17         ` Charles Forsyth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHL7psFD9_xWyfPTbh0tCY80=KfRUzfkh5rm_Fij8WJzw2NmJg@mail.gmail.com' \
    --to=giacomo@tesio.it \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).