func ModeFromOS(mode os.FileMode) FileMode {
	m := FileMode(mode.Perm())
	switch {
	case mode.IsDir():
		m |= ModeDirectory
	case mode&os.ModeSymlink != 0:
		m |= ModeSymlink
	case mode&os.ModeSocket != 0:
		m |= ModeSocket
	case mode&os.ModeNamedPipe != 0:
		m |= ModeNamedPipe
	case mode&os.ModeCharDevice != 0:
		m |= ModeCharacterDevice
	case mode&os.ModeDevice != 0:
		m |= ModeBlockDevice
	default:
		m |= ModeRegular
	}
	return m
}
ModeFromOS returns a FileMode from an os.FileMode.
package p9
import (
	"fmt"
	"math"
	"os"
	"strings"
	"sync/atomic"
	"github.com/hugelgupf/p9/internal"
)
var Debug = func(fmt string, v ...interface{}) {}
const (
	DefaultMessageSize uint32 = 64 << 10
)
type OpenFlags uint32
const (
	ReadOnly OpenFlags = 0
	WriteOnly OpenFlags = 1
	ReadWrite OpenFlags = 2
	OpenFlagsModeMask OpenFlags = 3
)
func (o OpenFlags) Mode() OpenFlags {
	return o & OpenFlagsModeMask
}
func (o OpenFlags) OSFlags() int {
	return int(o & OpenFlagsModeMask)
}
func (o OpenFlags) String() string {
	switch o {
	case ReadOnly:
		return "ReadOnly"
	case WriteOnly:
		return "WriteOnly"
	case ReadWrite:
		return "ReadWrite"
	case OpenFlagsModeMask:
		return "OpenFlagsModeMask"
	default:
		return fmt.Sprintf("unknown (%#x)", uint32(o))
	}
}
type tag uint16
type fid uint64
type FileMode uint32
const (
	FileModeMask FileMode = 0170000
	ModeSocket FileMode = 0140000
	ModeSymlink FileMode = 0120000
	ModeRegular FileMode = 0100000
	ModeBlockDevice FileMode = 060000
	ModeDirectory FileMode = 040000
	ModeCharacterDevice FileMode = 020000
	ModeNamedPipe FileMode = 010000
	Read FileMode = 04
	Write FileMode = 02
	Exec FileMode = 01
	AllPermissions FileMode = 0777
	Sticky FileMode = 01000
	permissionsMask FileMode = 01777
)
func (m FileMode) QIDType() QIDType {
	switch {
	case m.IsDir():
		return TypeDir
	case m.IsSocket(), m.IsNamedPipe(), m.IsCharacterDevice():
		return TypeAppendOnly
	case m.IsSymlink():
		return TypeSymlink
	default:
		return TypeRegular
	}
}
func (m FileMode) FileType() FileMode {
	return m & FileModeMask
}
func (m FileMode) Permissions() FileMode {
	return m & permissionsMask
}
func (m FileMode) Writable() FileMode {
	return m | 0222
}
func (m FileMode) IsReadable() bool {
	return m&0444 != 0
}
func (m FileMode) IsWritable() bool {
	return m&0222 != 0
}
func (m FileMode) IsExecutable() bool {
	return m&0111 != 0
}
func (m FileMode) IsRegular() bool {
	return m&FileModeMask == ModeRegular
}
func (m FileMode) IsDir() bool {
	return m&FileModeMask == ModeDirectory
}
func (m FileMode) IsNamedPipe() bool {
	return m&FileModeMask == ModeNamedPipe
}
func (m FileMode) IsCharacterDevice() bool {
	return m&FileModeMask == ModeCharacterDevice
}
func (m FileMode) IsBlockDevice() bool {
	return m&FileModeMask == ModeBlockDevice
}
func (m FileMode) IsSocket() bool {
	return m&FileModeMask == ModeSocket
}
func (m FileMode) IsSymlink() bool {
	return m&FileModeMask == ModeSymlink
}