本文整理匯總了Golang中camlistore/org/third_party/code/google/com/p/rsc/fuse.OpenResponse.Flags方法的典型用法代碼示例。如果您正苦於以下問題:Golang OpenResponse.Flags方法的具體用法?Golang OpenResponse.Flags怎麽用?Golang OpenResponse.Flags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類camlistore/org/third_party/code/google/com/p/rsc/fuse.OpenResponse
的用法示例。
在下文中一共展示了OpenResponse.Flags方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Open
// Empirically:
// open for read: req.Flags == 0
// open for append: req.Flags == 1
// open for write: req.Flags == 1
// open for read/write (+<) == 2 (bitmask? of?)
//
// open flags are O_WRONLY (1), O_RDONLY (0), or O_RDWR (2). and also
// bitmaks of O_SYMLINK (0x200000) maybe. (from
// fuse_filehandle_xlate_to_oflags in macosx/kext/fuse_file.h)
func (n *mutFile) Open(req *fuse.OpenRequest, res *fuse.OpenResponse, intr fuse.Intr) (fuse.Handle, fuse.Error) {
mutFileOpen.Incr()
log.Printf("mutFile.Open: %v: content: %v dir=%v flags=%v mode=%v", n.permanode, n.content, req.Dir, req.Flags, req.Mode)
r, err := schema.NewFileReader(n.fs.fetcher, n.content)
if err != nil {
mutFileOpenError.Incr()
log.Printf("mutFile.Open: %v", err)
return nil, fuse.EIO
}
// Turn off the OpenDirectIO bit (on by default in rsc fuse server.go),
// else append operations don't work for some reason.
res.Flags &= ^fuse.OpenDirectIO
// Read-only.
if req.Flags == 0 {
mutFileOpenRO.Incr()
log.Printf("mutFile.Open returning read-only file")
n := &node{
fs: n.fs,
blobref: n.content,
}
return &nodeReader{n: n, fr: r}, nil
}
mutFileOpenRW.Incr()
log.Printf("mutFile.Open returning read-write filehandle")
defer r.Close()
return n.newHandle(r)
}
示例2: Open
// Empirically:
// open for read: req.Flags == 0
// open for append: req.Flags == 1
// open for write: req.Flags == 1
// open for read/write (+<) == 2 (bitmask? of?)
//
// open flags are O_WRONLY (1), O_RDONLY (0), or O_RDWR (2). and also
// bitmaks of O_SYMLINK (0x200000) maybe. (from
// fuse_filehandle_xlate_to_oflags in macosx/kext/fuse_file.h)
func (n *roFile) Open(req *fuse.OpenRequest, res *fuse.OpenResponse, intr fuse.Intr) (fuse.Handle, fuse.Error) {
roFileOpen.Incr()
if isWriteFlags(req.Flags) {
return nil, fuse.EPERM
}
log.Printf("roFile.Open: %v: content: %v dir=%v flags=%v mode=%v", n.permanode, n.content, req.Dir, req.Flags, req.Mode)
r, err := schema.NewFileReader(n.fs.fetcher, n.content)
if err != nil {
roFileOpenError.Incr()
log.Printf("roFile.Open: %v", err)
return nil, fuse.EIO
}
// Turn off the OpenDirectIO bit (on by default in rsc fuse server.go),
// else append operations don't work for some reason.
res.Flags &= ^fuse.OpenDirectIO
// Read-only.
nod := &node{
fs: n.fs,
blobref: n.content,
}
return &nodeReader{n: nod, fr: r}, nil
}