Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_fixcpp/sys/src/libc/9sys/read9pmsg.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <fcall.h>
4
 
5
int
6
read9pmsg(int fd, void *abuf, uint n)
7
{
8
	int m, len;
9
	uchar *buf;
10
 
11
	buf = abuf;
12
 
13
	/* read count */
14
	m = readn(fd, buf, BIT32SZ);
15
	if(m != BIT32SZ){
16
		if(m < 0)
17
			return -1;
18
		return 0;
19
	}
20
 
21
	len = GBIT32(buf);
22
	if(len <= BIT32SZ || len > n){
23
		werrstr("bad length in 9P2000 message header");
24
		return -1;
25
	}
26
	len -= BIT32SZ;
27
	m = readn(fd, buf+BIT32SZ, len);
28
	if(m < len)
29
		return 0;
30
	return BIT32SZ+m;
31
}