當前位置: 首頁>>代碼示例>>Golang>>正文


Golang fuse.ToStatus函數代碼示例

本文整理匯總了Golang中github.com/y-okubo/go-fuse/fuse.ToStatus函數的典型用法代碼示例。如果您正苦於以下問題:Golang ToStatus函數的具體用法?Golang ToStatus怎麽用?Golang ToStatus使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ToStatus函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Flush

func (f *loopbackFile) Flush() fuse.Status {
	f.lock.Lock()

	// Since Flush() may be called for each dup'd fd, we don't
	// want to really close the file, we just want to flush. This
	// is achieved by closing a dup'd fd.
	newFd, err := syscall.Dup(int(f.File.Fd()))
	f.lock.Unlock()

	if err != nil {
		return fuse.ToStatus(err)
	}
	err = syscall.Close(newFd)
	return fuse.ToStatus(err)
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:15,代碼來源:files.go

示例2: Truncate

func (f *loopbackFile) Truncate(size uint64) fuse.Status {
	f.lock.Lock()
	r := fuse.ToStatus(syscall.Ftruncate(int(f.File.Fd()), int64(size)))
	f.lock.Unlock()

	return r
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:7,代碼來源:files.go

示例3: Fsync

func (f *loopbackFile) Fsync(flags int) (code fuse.Status) {
	f.lock.Lock()
	r := fuse.ToStatus(syscall.Fsync(int(f.File.Fd())))
	f.lock.Unlock()

	return r
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:7,代碼來源:files.go

示例4: Chown

func (f *loopbackFile) Chown(uid uint32, gid uint32) fuse.Status {
	f.lock.Lock()
	r := fuse.ToStatus(f.File.Chown(int(uid), int(gid)))
	f.lock.Unlock()

	return r
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:7,代碼來源:files.go

示例5: Chmod

func (f *loopbackFile) Chmod(mode uint32) fuse.Status {
	f.lock.Lock()
	r := fuse.ToStatus(f.File.Chmod(os.FileMode(mode)))
	f.lock.Unlock()

	return r
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:7,代碼來源:files.go

示例6: TestUnionFSBarf

func TestUnionFSBarf(t *testing.T) {
	wd, clean := setupUfs(t)
	defer clean()

	if err := os.Mkdir(wd+"/mnt/dir", 0755); err != nil {
		t.Fatalf("os.Mkdir: %v", err)
	}
	if err := os.Mkdir(wd+"/mnt/dir2", 0755); err != nil {
		t.Fatalf("os.Mkdir: %v", err)
	}
	if err := ioutil.WriteFile(wd+"/rw/dir/file", []byte("bla"), 0644); err != nil {
		t.Fatalf("WriteFile failed: %v", err)
	}
	if _, err := os.Lstat(wd + "/mnt/dir/file"); err != nil {
		t.Fatalf("Lstat: %v", err)
	}
	if err := os.Rename(wd+"/rw/dir/file", wd+"/rw/file"); err != nil {
		t.Fatalf("os.Rename: %v", err)
	}

	err := os.Rename(wd+"/mnt/file", wd+"/mnt/dir2/file")
	if fuse.ToStatus(err) != fuse.ENOENT {
		// TODO - this should just succeed?
		t.Fatalf("os.Rename: %v", err)
	}
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:26,代碼來源:unionfs_test.go

示例7: Open

func (fs *loopbackFileSystem) Open(name string, flags uint32, context *fuse.Context) (fuseFile nodefs.File, status fuse.Status) {
	f, err := os.OpenFile(fs.GetPath(name), int(flags), 0)
	if err != nil {
		return nil, fuse.ToStatus(err)
	}
	return nodefs.NewLoopbackFile(f), fuse.OK
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:7,代碼來源:loopback.go

示例8: Open

func (n *memNode) Open(flags uint32, context *fuse.Context) (file File, code fuse.Status) {
	f, err := os.OpenFile(n.filename(), int(flags), 0666)
	if err != nil {
		return nil, fuse.ToStatus(err)
	}

	return n.newFile(f), fuse.OK
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:8,代碼來源:memnode.go

示例9: Allocate

func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status {
	f.lock.Lock()
	err := syscall.Fallocate(int(f.File.Fd()), mode, int64(off), int64(sz))
	f.lock.Unlock()
	if err != nil {
		return fuse.ToStatus(err)
	}
	return fuse.OK
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:9,代碼來源:files_linux.go

示例10: Create

func (n *memNode) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file File, node *Inode, code fuse.Status) {
	ch := n.newNode(name, false)
	ch.info.Mode = mode | fuse.S_IFREG

	f, err := os.Create(ch.filename())
	if err != nil {
		return nil, nil, fuse.ToStatus(err)
	}
	return ch.newFile(f), ch.Inode(), fuse.OK
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:10,代碼來源:memnode.go

示例11: Utimens

func (fs *loopbackFileSystem) Utimens(path string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status) {
	var a time.Time
	if Atime != nil {
		a = *Atime
	}
	var m time.Time
	if Mtime != nil {
		m = *Mtime
	}
	return fuse.ToStatus(os.Chtimes(fs.GetPath(path), a, m))
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:11,代碼來源:loopback.go

示例12: GetAttr

func (f *loopbackFile) GetAttr(a *fuse.Attr) fuse.Status {
	st := syscall.Stat_t{}
	f.lock.Lock()
	err := syscall.Fstat(int(f.File.Fd()), &st)
	f.lock.Unlock()
	if err != nil {
		return fuse.ToStatus(err)
	}
	a.FromStat(&st)

	return fuse.OK
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:12,代碼來源:files.go

示例13: Allocate

func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status {
	// TODO: Handle `mode` parameter.

	// From `man fcntl` on OSX:
	//     The F_PREALLOCATE command operates on the following structure:
	//
	//             typedef struct fstore {
	//                 u_int32_t fst_flags;      /* IN: flags word */
	//                 int       fst_posmode;    /* IN: indicates offset field */
	//                 off_t     fst_offset;     /* IN: start of the region */
	//                 off_t     fst_length;     /* IN: size of the region */
	//                 off_t     fst_bytesalloc; /* OUT: number of bytes allocated */
	//             } fstore_t;
	//
	//     The flags (fst_flags) for the F_PREALLOCATE command are as follows:
	//
	//           F_ALLOCATECONTIG   Allocate contiguous space.
	//
	//           F_ALLOCATEALL      Allocate all requested space or no space at all.
	//
	//     The position modes (fst_posmode) for the F_PREALLOCATE command indicate how to use the offset field.  The modes are as fol-
	//     lows:
	//
	//           F_PEOFPOSMODE   Allocate from the physical end of file.
	//
	//           F_VOLPOSMODE    Allocate from the volume offset.

	k := struct {
		Flags      uint32 // u_int32_t
		Posmode    int64  // int
		Offset     int64  // off_t
		Length     int64  // off_t
		Bytesalloc int64  // off_t
	}{
		0,
		0,
		int64(off),
		int64(sz),
		0,
	}

	// Linux version for reference:
	// err := syscall.Fallocate(int(f.File.Fd()), mode, int64(off), int64(sz))

	f.lock.Lock()
	_, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.File.Fd(), uintptr(syscall.F_PREALLOCATE), uintptr(unsafe.Pointer(&k)))
	f.lock.Unlock()
	if errno != 0 {
		return fuse.ToStatus(errno)
	}
	return fuse.OK
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:52,代碼來源:files_darwin.go

示例14: Flush

func (n *memNodeFile) Flush() fuse.Status {
	code := n.File.Flush()

	if !code.Ok() {
		return code
	}

	st := syscall.Stat_t{}
	err := syscall.Stat(n.node.filename(), &st)
	n.node.info.Size = uint64(st.Size)
	n.node.info.Blocks = uint64(st.Blocks)
	return fuse.ToStatus(err)
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:13,代碼來源:memnode.go

示例15: TestCreationChecks

func TestCreationChecks(t *testing.T) {
	wd, clean := setup(t)
	defer clean()

	err := os.Mkdir(wd+"/store/foo", 0755)
	if err != nil {
		t.Fatalf("Mkdir failed: %v", err)
	}
	os.Symlink(wd+"/ro", wd+"/store/foo/READONLY")
	if err != nil {
		t.Fatalf("Symlink failed: %v", err)
	}

	err = os.Mkdir(wd+"/store/ws2", 0755)
	if err != nil {
		t.Fatalf("Mkdir failed: %v", err)
	}
	os.Symlink(wd+"/ro", wd+"/store/ws2/READONLY")
	if err != nil {
		t.Fatalf("Symlink failed: %v", err)
	}

	err = os.Symlink(wd+"/store/foo", wd+"/mnt/config/bar")
	if err != nil {
		t.Fatalf("Symlink failed: %v", err)
	}

	err = os.Symlink(wd+"/store/foo", wd+"/mnt/config/foo")
	code := fuse.ToStatus(err)
	if code != fuse.EBUSY {
		t.Error("Should return EBUSY", err)
	}

	err = os.Symlink(wd+"/store/ws2", wd+"/mnt/config/config")
	code = fuse.ToStatus(err)
	if code != fuse.EINVAL {
		t.Error("Should return EINVAL", err)
	}
}
開發者ID:y-okubo,項目名稱:go-fuse,代碼行數:39,代碼來源:autounion_test.go


注:本文中的github.com/y-okubo/go-fuse/fuse.ToStatus函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。