Commit 7b502e0b authored by Ivan Krasin's avatar Ivan Krasin

Made fields public. Reformatted with gofmt. binary.Read now works.

parent 0c5b36c5
...@@ -17,12 +17,11 @@ const ( ...@@ -17,12 +17,11 @@ const (
bufSize = 65536 + 100 // See the link above for the details bufSize = 65536 + 100 // See the link above for the details
) )
type FileSystem interface { type FileSystem interface{}
}
type MountPoint struct { type MountPoint struct {
mountPoint string mountPoint string
f *os.File f *os.File
} }
// Mount create a fuse fs on the specified mount point. // Mount create a fuse fs on the specified mount point.
...@@ -44,10 +43,10 @@ func Mount(mountPoint string, fs FileSystem) (m *MountPoint, err os.Error) { ...@@ -44,10 +43,10 @@ func Mount(mountPoint string, fs FileSystem) (m *MountPoint, err os.Error) {
mountPoint = path.Clean(path.Join(cwd, mountPoint)) mountPoint = path.Clean(path.Join(cwd, mountPoint))
} }
pid, err := os.ForkExec("/bin/fusermount", pid, err := os.ForkExec("/bin/fusermount",
[]string { "/bin/fusermount", mountPoint }, []string{"/bin/fusermount", mountPoint},
[]string { "_FUSE_COMMFD=3" }, []string{"_FUSE_COMMFD=3"},
"", "",
[]*os.File { nil, nil, nil, remote.File() }) []*os.File{nil, nil, nil, remote.File()})
if err != nil { if err != nil {
return return
} }
...@@ -63,7 +62,7 @@ func Mount(mountPoint string, fs FileSystem) (m *MountPoint, err os.Error) { ...@@ -63,7 +62,7 @@ func Mount(mountPoint string, fs FileSystem) (m *MountPoint, err os.Error) {
if err != nil { if err != nil {
return return
} }
m = &MountPoint { mountPoint, f } m = &MountPoint{mountPoint, f}
go m.loop() go m.loop()
return return
} }
...@@ -78,7 +77,7 @@ func (m *MountPoint) loop() { ...@@ -78,7 +77,7 @@ func (m *MountPoint) loop() {
fmt.Printf("MountPoint.loop: Read failed, err: %v\n", err) fmt.Printf("MountPoint.loop: Read failed, err: %v\n", err)
os.Exit(1) os.Exit(1)
} }
var h fuse_in_header var h In_header
err = binary.Read(r, binary.LittleEndian, &h) err = binary.Read(r, binary.LittleEndian, &h)
if err != nil { if err != nil {
fmt.Printf("MountPoint.loop: binary.Read of fuse_in_header failed with err: %v\n", err) fmt.Printf("MountPoint.loop: binary.Read of fuse_in_header failed with err: %v\n", err)
...@@ -94,10 +93,10 @@ func (m *MountPoint) Unmount() (err os.Error) { ...@@ -94,10 +93,10 @@ func (m *MountPoint) Unmount() (err os.Error) {
return nil return nil
} }
pid, err := os.ForkExec("/bin/fusermount", pid, err := os.ForkExec("/bin/fusermount",
[]string { "/bin/fusermount", "-u", m.mountPoint }, []string{"/bin/fusermount", "-u", m.mountPoint},
nil, nil,
"", "",
[]*os.File { nil, nil, os.Stderr }) []*os.File{nil, nil, os.Stderr})
if err != nil { if err != nil {
return return
} }
...@@ -127,7 +126,7 @@ func Recvmsg(fd int, msg *syscall.Msghdr, flags int) (n int, err os.Error) { ...@@ -127,7 +126,7 @@ func Recvmsg(fd int, msg *syscall.Msghdr, flags int) (n int, err os.Error) {
return return
} }
func getFuseConn(local net.Conn) (f * os.File, err os.Error) { func getFuseConn(local net.Conn) (f *os.File, err os.Error) {
var msg syscall.Msghdr var msg syscall.Msghdr
var iov syscall.Iovec var iov syscall.Iovec
base := make([]int32, 256) base := make([]int32, 256)
...@@ -157,12 +156,10 @@ func getFuseConn(local net.Conn) (f * os.File, err os.Error) { ...@@ -157,12 +156,10 @@ func getFuseConn(local net.Conn) (f * os.File, err os.Error) {
return return
} }
if (fd < 0) { if fd < 0 {
err = os.NewError(fmt.Sprintf("getFuseConn: fd < 0: %d", fd)) err = os.NewError(fmt.Sprintf("getFuseConn: fd < 0: %d", fd))
return return
} }
f = os.NewFile(int(fd), "fuse-conn") f = os.NewFile(int(fd), "fuse-conn")
return return
} }
...@@ -12,7 +12,7 @@ const ( ...@@ -12,7 +12,7 @@ const (
FUSE_ROOT_ID = 1 FUSE_ROOT_ID = 1
/** /**
* Bitmasks for fuse_setattr_in.valid * Bitmasks for Setattr_in.valid
*/ */
FATTR_MODE = (1 << 0) FATTR_MODE = (1 << 0)
FATTR_UID = (1 << 1) FATTR_UID = (1 << 1)
...@@ -183,330 +183,330 @@ const ( ...@@ -183,330 +183,330 @@ const (
userspace works under 64bit kernels */ userspace works under 64bit kernels */
type Attr struct { type Attr struct {
ino uint64 Ino uint64
size uint64 Size uint64
blocks uint64 Blocks uint64
atime uint64 Atime uint64
mtime uint64 Mtime uint64
ctime uint64 Ctime uint64
atimensec uint32 Atimensec uint32
mtimensec uint32 Mtimensec uint32
ctimensec uint32 Ctimensec uint32
mode uint32 Mode uint32
nlink uint32 Nlink uint32
uid uint32 Uid uint32
gid uint32 Gid uint32
rdev uint32 Rdev uint32
blksize uint32 Blksize uint32
padding uint32 Padding uint32
} }
type Kstatfs struct { type Kstatfs struct {
blocks uint64 Blocks uint64
bfree uint64 Bfree uint64
bavail uint64 Bavail uint64
files uint64 Files uint64
ffree uint64 Ffree uint64
bsize uint32 Bsize uint32
namelen uint32 Namelen uint32
frsize uint32 Frsize uint32
padding uint32 Padding uint32
spare [6]uint32 Spare [6]uint32
} }
type File_lock struct { type File_lock struct {
start uint64 Start uint64
end uint64 End uint64
typ uint32 Typ uint32
pid uint32 /* tgid */ Pid uint32 /* tgid */
} }
type Entry_out struct { type Entry_out struct {
nodeid uint64 /* Inode ID */ Nodeid uint64 /* Inode ID */
generation uint64 /* Inode generation: nodeid:gen must Generation uint64 /* Inode generation: nodeid:gen must
be unique for the fs's lifetime */ be unique for the fs's lifetime */
entry_valid uint64 /* Cache timeout for the name */ Entry_valid uint64 /* Cache timeout for the name */
attr_valid uint64 /* Cache timeout for the attributes */ Attr_valid uint64 /* Cache timeout for the attributes */
entry_valid_nsec uint32 Entry_valid_nsec uint32
attr_valid_nsec uint32 Attr_valid_nsec uint32
attr fuse_attr Attr Attr
} }
type Forget_in struct { type Forget_in struct {
nlookup uint64 Nlookup uint64
} }
type Getattr_in struct { type Getattr_in struct {
getattr_flags uint32 Getattr_flags uint32
dummy uint32 Dummy uint32
fh uint64 Fh uint64
} }
type Attr_out struct { type Attr_out struct {
attr_valid uint64 /* Cache timeout for the attributes */ Attr_valid uint64 /* Cache timeout for the attributes */
attr_valid_nsec uint32 Attr_valid_nsec uint32
dummy uint32 Dummy uint32
attr fuse_attr Attr Attr
} }
type Mknod_in struct { type Mknod_in struct {
mode uint32 Mode uint32
rdev uint32 Rdev uint32
umask uint32 Umask uint32
padding uint32 Padding uint32
} }
type Mkdir_in struct { type Mkdir_in struct {
mode uint32 Mode uint32
umask uint32 Umask uint32
} }
type Rename_in struct { type Rename_in struct {
newdir uint64 Newdir uint64
} }
type Link_in struct { type Link_in struct {
oldnodeid uint64 Oldnodeid uint64
} }
type Setattr_in struct { type Setattr_in struct {
valid uint32 Valid uint32
padding uint32 Padding uint32
fh uint64 Fh uint64
size uint64 Size uint64
lock_owner uint64 Lock_owner uint64
atime uint64 Atime uint64
mtime uint64 Mtime uint64
unused2 uint64 Unused2 uint64
atimensec uint32 Atimensec uint32
mtimensec uint32 Mtimensec uint32
unused3 uint32 Unused3 uint32
mode uint32 Mode uint32
unused4 uint32 Unused4 uint32
uid uint32 Uid uint32
gid uint32 Gid uint32
unused5 uint32 Unused5 uint32
} }
type Open_in struct { type Open_in struct {
flags uint32 Flags uint32
unused uint32 Unused uint32
} }
type Create_in struct { type Create_in struct {
flags uint32 Flags uint32
mode uint32 Mode uint32
umask uint32 Umask uint32
padding uint32 Padding uint32
} }
type Open_out struct { type Open_out struct {
fh uint64 Fh uint64
open_flags uint32 Open_flags uint32
padding uint32 Padding uint32
} }
type Release_in struct { type Release_in struct {
fh uint64 Fh uint64
flags uint32 Flags uint32
release_flags uint32 Release_flags uint32
lock_owner uint64 Lock_owner uint64
} }
type Flush_in struct { type Flush_in struct {
fh uint64 Fh uint64
unused uint32 Unused uint32
padding uint32 Padding uint32
lock_owner uint64 Lock_owner uint64
} }
type Read_in struct { type Read_in struct {
fh uint64 Fh uint64
offset uint64 Offset uint64
size uint32 Size uint32
read_flags uint32 Read_flags uint32
lock_owner uint64 Lock_owner uint64
flags uint32 Flags uint32
padding uint32 Padding uint32
} }
type Write_in struct { type Write_in struct {
fh uint64 Fh uint64
offset uint64 Offset uint64
size uint32 Size uint32
write_flags uint32 Write_flags uint32
lock_owner uint64 Lock_owner uint64
flags uint32 Flags uint32
padding uint32 Padding uint32
} }
type Write_out struct { type Write_out struct {
size uint32 Size uint32
padding uint32 Padding uint32
} }
type Statfs_out struct { type Statfs_out struct {
st fuse_kstatfs St Kstatfs
} }
type Fsync_in struct { type Fsync_in struct {
fh uint64 Fh uint64
fsync_flags uint32 Fsync_flags uint32
padding uint32 Padding uint32
} }
type Setxattr_in struct { type Setxattr_in struct {
size uint32 Size uint32
flags uint32 Flags uint32
} }
type Getxattr_in struct { type Getxattr_in struct {
size uint32 Size uint32
padding uint32 Padding uint32
} }
type Getxattr_out struct { type Getxattr_out struct {
size uint32 Size uint32
padding uint32 Padding uint32
} }
type Lk_in struct { type Lk_in struct {
fh uint64 Fh uint64
owner uint64 Owner uint64
lk fuse_file_lock Lk File_lock
lk_flags uint32 Lk_flags uint32
padding uint32 Padding uint32
} }
type Lk_out struct { type Lk_out struct {
lk fuse_file_lock Lk File_lock
} }
type Access_in struct { type Access_in struct {
mask uint32 Mask uint32
padding uint32 Padding uint32
} }
type Init_in struct { type Init_in struct {
major uint32 Major uint32
minor uint32 Minor uint32
max_readahead uint32 Max_readahead uint32
flags uint32 Flags uint32
} }
type Init_out struct { type Init_out struct {
major uint32 Major uint32
minor uint32 Minor uint32
max_readahead uint32 Max_readahead uint32
flags uint32 Flags uint32
max_background uint16 Max_background uint16
congestion_threshold uint16 Congestion_threshold uint16
max_write uint32 Max_write uint32
} }
type Cuse_init_in struct { type Cuse_init_in struct {
major uint32 Major uint32
minor uint32 Minor uint32
unused uint32 Unused uint32
flags uint32 Flags uint32
} }
type Cuse_init_out struct { type Cuse_init_out struct {
major uint32 Major uint32
minor uint32 Minor uint32
unused uint32 Unused uint32
flags uint32 Flags uint32
max_read uint32 Max_read uint32
max_write uint32 Max_write uint32
dev_major uint32 /* chardev major */ Dev_major uint32 /* chardev major */
dev_minor uint32 /* chardev minor */ Dev_minor uint32 /* chardev minor */
spare [10]uint32 Spare [10]uint32
} }
type Interrupt_in struct { type Interrupt_in struct {
unique uint64 Unique uint64
} }
type Bmap_in struct { type Bmap_in struct {
block uint64 Block uint64
blocksize uint32 Blocksize uint32
padding uint32 Padding uint32
} }
type Bmap_out struct { type Bmap_out struct {
block uint64 Block uint64
} }
type Ioctl_in struct { type Ioctl_in struct {
fh uint64 Fh uint64
flags uint32 Flags uint32
cmd uint32 Cmd uint32
arg uint64 Arg uint64
in_size uint32 In_size uint32
out_size uint32 Out_size uint32
} }
type Ioctl_out struct { type Ioctl_out struct {
result int32 Result int32
flags uint32 Flags uint32
in_iovs uint32 In_iovs uint32
out_iovs uint32 Out_iovs uint32
} }
type Poll_in struct { type Poll_in struct {
fh uint64 Fh uint64
kh uint64 Kh uint64
flags uint32 Flags uint32
padding uint32 Padding uint32
} }
type Poll_out struct { type Poll_out struct {
revents uint32 Revents uint32
padding uint32 Padding uint32
} }
type Notify_poll_wakeup_out struct { type Notify_poll_wakeup_out struct {
kh uint64 Kh uint64
} }
type In_header struct { type In_header struct {
length uint32 Length uint32
opcode uint32 Opcode uint32
unique uint64 Unique uint64
nodeid uint64 Nodeid uint64
uid uint32 Uid uint32
gid uint32 Gid uint32
pid uint32 Pid uint32
padding uint32 Padding uint32
} }
type Out_header struct { type Out_header struct {
length uint32 Length uint32
error int32 Error int32
unique uint64 Unique uint64
} }
type Dirent struct { type Dirent struct {
ino uint64 Ino uint64
off uint64 Off uint64
namelen uint32 Namelen uint32
typ uint32 Typ uint32
// name []byte // char name[0] -- looks like the name is right after this struct. // name []byte // char name[0] -- looks like the name is right after this struct.
} }
type Notify_inval_inode_out struct { type Notify_inval_inode_out struct {
ino uint64 Ino uint64
off int64 Off int64
length int64 Length int64
} }
type Notify_inval_entry_out struct { type Notify_inval_entry_out struct {
parent uint64 Parent uint64
namelen uint32 Namelen uint32
padding uint32 Padding uint32
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment