Commit Diff


commit - b4b80bdc40a569ab7924e6b99993c91ca0af22f0
commit + a056819507b3f5113ef8b52f04e67dadf29d8927
blob - bbfee97f541e3e8208f8c2f561391daf7ecbf8be
blob + b1409802f09b2d6118b9a09bb03f1e3f947ecbc7
--- channel.go
+++ channel.go
@@ -37,6 +37,8 @@ type Channel interface {
 	SetMSize(msize int)
 }
 
+// NewChannel returns a new channel to read and write Fcalls with the provided
+// connection and message size.
 func NewChannel(conn net.Conn, msize int) Channel {
 	return newChannel(conn, codec9p{}, msize)
 }
@@ -140,7 +142,7 @@ func (ch *channel) ReadFcall(ctx context.Context, fcal
 	if n > len(ch.rdbuf) {
 		// TODO(stevvooe): Make this error detectable and respond with error
 		// message.
-		return fmt.Errorf("message large than buffer:", n)
+		return fmt.Errorf("message too large for buffer: %v > %v ", n, len(ch.rdbuf))
 	}
 
 	// clear out the fcall
blob - 01396c7b3eb94755a94f2b216c9b8d763f557ee3
blob + c339ab88ff81d8dc80a586bbe83eb86604ba7724
--- dispatcher.go
+++ dispatcher.go
@@ -17,6 +17,7 @@ type Handler interface {
 // HandlerFunc is a convenience type for defining inline handlers.
 type HandlerFunc func(ctx context.Context, msg Message) (Message, error)
 
+// Handle implements the requirements for the Handler interface.
 func (fn HandlerFunc) Handle(ctx context.Context, msg Message) (Message, error) {
 	return fn(ctx, msg)
 }
blob - 228904f47bccd17e2149da9f8130a7ac9dc5e42f
blob + 1032f960a0aba5217915c744e0db10bb95e84fd7
--- encoding.go
+++ encoding.go
@@ -24,6 +24,7 @@ type Codec interface {
 	Size(v interface{}) int
 }
 
+// NewCodec returns a new, standard 9P2000 codec, ready for use.
 func NewCodec() Codec {
 	return codec9p{}
 }
blob - 32f3c9fea803b82dc760bfb18310ad2329778fa2
blob + 1a2dcdf34ae0cc8224d4a4dee3b05141bcec4fc6
--- errors.go
+++ errors.go
@@ -10,8 +10,8 @@ type MessageRerror struct {
 	Ename string
 }
 
+// 9p wire errors returned by Session interface methods
 var (
-	// 9p wire errors returned by Session interface methods
 	ErrBadattach    = new9pError("unknown specifier in attach")
 	ErrBadoffset    = new9pError("bad offset")
 	ErrBadcount     = new9pError("bad count")
@@ -33,6 +33,7 @@ var (
 	ErrWalknodir    = new9pError("walk in non-directory")
 
 	// extra errors not part of the normal protocol
+
 	ErrTimeout       = new9pError("fcall timeout") // returned when timing out on the fcall
 	ErrUnknownTag    = new9pError("unknown tag")
 	ErrUnknownMsg    = new9pError("unknown message")    // returned when encountering unknown message type
@@ -46,6 +47,8 @@ func new9pError(s string) error {
 	return MessageRerror{Ename: s}
 }
 
+// Type ensures that 9p errors can be transparently used as a 9p message in an
+// Fcall.
 func (MessageRerror) Type() FcallType {
 	return Rerror
 }
blob - 56d43e0325a8ea98d24f9e076becdd5565f5e5e9
blob + e17a6b70611d29e021f7791f0ef72032b4c16c27
--- fcall.go
+++ fcall.go
@@ -2,8 +2,10 @@ package p9p
 
 import "fmt"
 
+// FcallType encodes the message type for the target Fcall.
 type FcallType uint8
 
+// Definitions for Fcall's used in 9P2000.
 const (
 	Tversion FcallType = iota + 100
 	Rversion
@@ -100,6 +102,8 @@ func (fct FcallType) String() string {
 	}
 }
 
+// Fcall defines the fields for sending a 9p formatted message. The type will
+// be introspected from the Message implementation.
 type Fcall struct {
 	Type    FcallType
 	Tag     Tag
blob - 80b8c565f254f720c9503b1d4403e6e768fb4e64
blob + 28cccaabbf10d0cf1838c5776d073e4237174143
--- readdir.go
+++ readdir.go
@@ -20,6 +20,9 @@ type Readdir struct {
 	offset int64
 }
 
+// NewReaddir returns a new Readdir to assist implementing server-side Readdir.
+// The codec will be used to decode messages with Dir entries. The provided
+// function next will be called until io.EOF is returned.
 func NewReaddir(codec Codec, next func() (Dir, error)) *Readdir {
 	return &Readdir{
 		nextfn: next,
@@ -27,6 +30,8 @@ func NewReaddir(codec Codec, next func() (Dir, error))
 	}
 }
 
+// NewFixedReaddir returns a Readdir that will returned a fixed set of
+// directory entries.
 func NewFixedReaddir(codec Codec, dir []Dir) *Readdir {
 	dirs := make([]Dir, len(dir))
 	copy(dirs, dir) // make our own copy!
blob - 09a3633d1aeadda61c049a24a985c1230e145a93
blob + 80b1e9479bb7f916e95e8c9e0734ed4a889ac404
--- server.go
+++ server.go
@@ -211,7 +211,7 @@ func (c *conn) write(responses chan *Fcall) {
 						// TODO(stevvooe): A full idle timeout on the
 						// connection should be enforced here. We log here,
 						// since this is less common.
-						log.Println("9p server: temporary error writing fcall: %v", err)
+						log.Printf("9p server: temporary error writing fcall: %v", err)
 						continue
 					}
 				}
blob - 5fe03c6db69fbdaf081004818370c0302cf4145b
blob + 3a8f0572fb6280b1a89e1e144dab1e9f165b92fb
--- types.go
+++ types.go
@@ -6,10 +6,14 @@ import (
 )
 
 const (
-	DefaultMSize   = 64 << 10
+	// DefaultMSize messages size used to establish a session.
+	DefaultMSize = 64 << 10
+
+	// DefaultVersion for this package. Currently, the only supported version.
 	DefaultVersion = "9P2000"
 )
 
+// Mode constants for use Dir.Mode.
 const (
 	DMDIR    = 0x80000000 // mode bit for directories
 	DMAPPEND = 0x40000000 // mode bit for append only files
@@ -19,6 +23,7 @@ const (
 	DMTMP    = 0x04000000 // mode bit for non-backed-up files
 
 	// 9p2000.u extensions
+
 	DMSYMLINK   = 0x02000000
 	DMDEVICE    = 0x00800000
 	DMNAMEDPIPE = 0x00200000
@@ -34,6 +39,7 @@ const (
 // Flag defines the flag type for use with open and create
 type Flag uint8
 
+// Constants to use when opening files.
 const (
 	OREAD  Flag = 0x00 // open for read
 	OWRITE      = 0x01 // write
@@ -43,9 +49,9 @@ const (
 	// PROPOSAL(stevvooe): Possible protocal extension to allow the create of
 	// symlinks. Initially, the link is created with no value. Read and write
 	// to read and set the link value.
+
 	OSYMLINK = 0x04
 
-	// or'd in
 	OTRUNC  = 0x10 // or'ed in (except for exec), truncate file first
 	OCEXEC  = 0x20 // or'ed in, close on exec
 	ORCLOSE = 0x40 // or'ed in, remove on close
@@ -54,6 +60,7 @@ const (
 // QType indicates the type of a resource within the Qid.
 type QType uint8
 
+// Constants for use in Qid to indicate resource type.
 const (
 	QTDIR    QType = 0x80 // type bit for directories
 	QTAPPEND       = 0x40 // type bit for append only files
@@ -88,14 +95,23 @@ func (qt QType) String() string {
 // Tag uniquely identifies an outstanding fcall in a 9p session.
 type Tag uint16
 
+// NOTAG is a reserved values for messages sent before establishing a session,
+// such as Tversion.
 const NOTAG Tag = ^Tag(0)
 
+// Fid defines a type to hold Fid values.
 type Fid uint32
 
+// NOFID indicates the lack of an Fid.
 const NOFID Fid = ^Fid(0)
 
+// Qid indicates the type, path and version of the resource returned by a
+// server. It is only valid for a session.
+//
+// Typically, a client maintains a mapping of Fid-Qid as Qids are returned by
+// the server.
 type Qid struct {
-	Type    QType `9p:type,1`
+	Type    QType `9p:"type,1"`
 	Version uint32
 	Path    uint64
 }
@@ -105,6 +121,8 @@ func (qid Qid) String() string {
 		qid.Type, qid.Version, qid.Path)
 }
 
+// Dir defines the structure used for expressing resources in stat/wstat and
+// when reading directories.
 type Dir struct {
 	Type uint16
 	Dev  uint32