コード例 #1
0
ファイル: FileSystem.go プロジェクト: Microsoft/hdfs-mount
// Statfs is called to obtain file system metadata.
// It should write that data to resp.
func (this *FileSystem) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error {
	// TODO: Implement statfs properly. Faking it for now reporting that free space is MaxFileSizeForWrite
	resp.Bsize = 1024
	resp.Bfree = MaxFileSizeForWrite / uint64(resp.Bsize)
	resp.Bavail = resp.Bfree
	resp.Blocks = resp.Bfree * 2
	return nil
}
コード例 #2
0
ファイル: fs.go プロジェクト: funkygao/gafka
func (this *KafkaFS) Statfs(ctx context.Context, req *fuse.StatfsRequest,
	res *fuse.StatfsResponse) error {
	s := syscall.Statfs_t{}
	res.Blocks = s.Blocks
	res.Bfree = s.Bfree
	res.Bavail = s.Bavail
	res.Ffree = s.Ffree
	res.Bsize = uint32(s.Bsize)
	return nil
}
コード例 #3
0
ファイル: fs.go プロジェクト: dankomiocevic/mulifs
func (f *FS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error {
	var stat syscall.Statfs_t
	wd, err := os.Getwd()
	if err != nil {
		return err
	}
	syscall.Statfs(wd, &stat)

	resp.Blocks = stat.Blocks
	resp.Bfree = stat.Bfree
	resp.Bavail = stat.Bavail
	resp.Bsize = uint32(stat.Bsize)
	return nil
}
コード例 #4
0
ファイル: mirrorfs.go プロジェクト: elgutierrez/mirrorfs
func (f *MirrorFS) Statfs(ctx context.Context, req *fuse.StatfsRequest, res *fuse.StatfsResponse) error {
	s := syscall.Statfs_t{}
	err := syscall.Statfs(f.path, &s)
	if err != nil {
		log.Println("DRIVE | Statfs syscall failed; ", err)
		return err
	}

	res.Blocks = s.Blocks
	res.Bfree = s.Bfree
	res.Bavail = s.Bavail
	res.Ffree = s.Ffree
	res.Bsize = s.Bsize
	// log.Println(res)
	return nil
}
コード例 #5
0
ファイル: fs.go プロジェクト: ligadous/logfs
func (f *LogFS) Statfs(ctx context.Context, req *fuse.StatfsRequest, res *fuse.StatfsResponse) error {
	log.Println("** Statfs")

	s := syscall.Statfs_t{}
	err := syscall.Statfs(f.path, &s)
	if err != nil {
		log.Println("DRIVE) Statfs falha no syscall; ", err)
		return err
	}

	res.Blocks = s.Blocks
	res.Bfree = s.Bfree
	res.Bavail = s.Bavail
	res.Ffree = s.Ffree
	res.Bsize = s.Bsize
	return nil
}
コード例 #6
0
ファイル: gocfs.go プロジェクト: thingswise/gocfs
func (fs FS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error {
	resp.Blocks = 18446744073709551615
	resp.Bfree = 18446744073709551615  // Free blocks in file system.
	resp.Bavail = 18446744073709551615 // Free blocks in file system if you're not root.
	resp.Files = 0                     // Total files in file system.
	resp.Ffree = 18446744073709551615  // Free files in file system.
	resp.Bsize = uint32(fs.blockSize)  // Block size
	resp.Namelen = 4294967295          // Maximum file name length?
	resp.Frsize = 1                    // Fragment size, smallest addressable data size in the file system.
	return nil
}
コード例 #7
0
ファイル: fs.go プロジェクト: ncw/rclone
// Statfs is called to obtain file system metadata.
// It should write that data to resp.
func (f *FS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error {
	const blockSize = 4096
	const fsBlocks = (1 << 50) / blockSize
	resp.Blocks = fsBlocks  // Total data blocks in file system.
	resp.Bfree = fsBlocks   // Free blocks in file system.
	resp.Bavail = fsBlocks  // Free blocks in file system if you're not root.
	resp.Files = 1E9        // Total files in file system.
	resp.Ffree = 1E9        // Free files in file system.
	resp.Bsize = blockSize  // Block size
	resp.Namelen = 255      // Maximum file name length?
	resp.Frsize = blockSize // Fragment size, smallest addressable data size in the file system.
	return nil
}
コード例 #8
0
ファイル: fs.go プロジェクト: pombredanne/camlistore
func (fs *CamliFileSystem) Statfs(ctx context.Context, req *fuse.StatfsRequest, res *fuse.StatfsResponse) error {
	// Make some stuff up, just to see if it makes "lsof" happy.
	res.Blocks = 1 << 35
	res.Bfree = 1 << 34
	res.Bavail = 1 << 34
	res.Files = 1 << 29
	res.Ffree = 1 << 28
	res.Namelen = 2048
	res.Bsize = 1024
	return nil
}
コード例 #9
0
ファイル: stat_linux.go プロジェクト: ttacon/cluefs
func statfsToFuse(path string, resp *fuse.StatfsResponse) error {
	var buf syscall.Statfs_t
	if err := syscall.Statfs(path, &buf); err != nil {
		return fuse.ENOTSUP
	}
	resp.Blocks = uint64(buf.Blocks) // Total data blocks in file system.
	resp.Bfree = uint64(buf.Bfree)   // Free blocks in file system.
	resp.Bavail = uint64(buf.Bavail) // Free blocks in file system if you're not root.
	resp.Files = uint64(buf.Files)   // Total files in file system.
	resp.Ffree = uint64(buf.Ffree)   // Free files in file system.
	resp.Bsize = uint32(buf.Bsize)   // Block size
	resp.Namelen = uint32(buf.Namelen)
	resp.Frsize = uint32(buf.Frsize)
	return nil
}
コード例 #10
0
ファイル: drive.go プロジェクト: ryanstout/mirrorfs
func (fs FS) Statfs(req *fuse.StatfsRequest, res *fuse.StatfsResponse, intr fs.Intr) fuse.Error {
	// Make some stuff up, just to see if it makes "lsof" happy.
	res.Blocks = 1 << 35
	res.Bfree = 1 << 34
	res.Bavail = 1 << 34
	res.Files = 1 << 29
	res.Ffree = 1 << 28
	res.Namelen = 2048
	// res.Bsize = 1024
	// res.Bsize = 32768
	// res.Bsize = 49152
	res.Bsize = 4096 * 1024
	return nil
}
コード例 #11
0
ファイル: fs.go プロジェクト: ovh/svfs
// Statfs gets the filesystem meta information. It's notably used to report filesystem metrics
// to the host. If the target account is using quota it will be reported as the device size.
// If no quota was found the device size will be equal to the underlying type maximum value.
func (s *SVFS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error {
	account, _, err := SwiftConnection.Account()
	if err != nil {
		return err
	}

	resp.Bsize = uint32(BlockSize)

	// Not mounting a specific container, then get account
	// information.
	if TargetContainer == "" {
		resp.Files = uint64(account.Objects)
		resp.Blocks = uint64(account.BytesUsed) / uint64(resp.Bsize)
	}
	// Mounting a specific container, then get container usage.
	if TargetContainer != "" {
		c, _, err := SwiftConnection.Container(TargetContainer)
		if err != nil {
			return err
		}
		cs, _, err := SwiftConnection.Container(TargetContainer + segmentContainerSuffix)
		if err != nil {
			return err
		}
		resp.Files = uint64(c.Count)
		resp.Blocks = uint64(c.Bytes+cs.Bytes) / uint64(resp.Bsize)
	}
	// An account quota has been set, compute relative free space.
	if account.Quota > 0 {
		resp.Bavail = uint64(account.Quota-account.BytesUsed) / uint64(resp.Bsize)
		resp.Bfree = resp.Bavail
		if TargetContainer == "" {
			resp.Blocks = uint64(account.Quota) / uint64(resp.Bsize)
		} else {
			resp.Blocks = uint64(account.Quota-account.BytesUsed)/uint64(resp.Bsize) + resp.Blocks
		}
	} else {
		// Else there's theorically no limit to available storage space.
		used := resp.Blocks
		resp.Blocks = uint64(1<<63-1) / uint64(resp.Bsize)
		resp.Bavail = resp.Blocks - used
		resp.Bfree = resp.Bavail
	}

	return nil
}
コード例 #12
0
ファイル: serve_test.go プロジェクト: seacoastboy/fuse
func (f testStatFS) Statfs(req *fuse.StatfsRequest, resp *fuse.StatfsResponse, int fs.Intr) fuse.Error {
	resp.Blocks = 42
	resp.Files = 13
	return nil
}