Compare commits
2 Commits
caac53a719
...
2d9f6f635e
Author | SHA1 | Date |
---|---|---|
|
2d9f6f635e | |
|
8156bfadb4 |
|
@ -89,7 +89,7 @@ func convertInMessage(
|
||||||
}
|
}
|
||||||
|
|
||||||
if valid&fusekernel.SetattrMode != 0 {
|
if valid&fusekernel.SetattrMode != 0 {
|
||||||
mode := ConvertFileMode(in.Mode)
|
mode := fuseops.ConvertFileMode(in.Mode)
|
||||||
to.Mode = &mode
|
to.Mode = &mode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ func convertInMessage(
|
||||||
// the fact that this is a directory is implicit in the fact that the
|
// the fact that this is a directory is implicit in the fact that the
|
||||||
// opcode is mkdir. But we want the correct mode to go through, so ensure
|
// opcode is mkdir. But we want the correct mode to go through, so ensure
|
||||||
// that os.ModeDir is set.
|
// that os.ModeDir is set.
|
||||||
Mode: ConvertFileMode(in.Mode) | os.ModeDir,
|
Mode: fuseops.ConvertFileMode(in.Mode) | os.ModeDir,
|
||||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ func convertInMessage(
|
||||||
o = &fuseops.MkNodeOp{
|
o = &fuseops.MkNodeOp{
|
||||||
Parent: fuseops.InodeID(inMsg.Header().Nodeid),
|
Parent: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||||
Name: string(name),
|
Name: string(name),
|
||||||
Mode: ConvertFileMode(in.Mode),
|
Mode: fuseops.ConvertFileMode(in.Mode),
|
||||||
Rdev: in.Rdev,
|
Rdev: in.Rdev,
|
||||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ func convertInMessage(
|
||||||
o = &fuseops.CreateFileOp{
|
o = &fuseops.CreateFileOp{
|
||||||
Parent: fuseops.InodeID(inMsg.Header().Nodeid),
|
Parent: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||||
Name: string(name),
|
Name: string(name),
|
||||||
Mode: ConvertFileMode(in.Mode),
|
Mode: fuseops.ConvertFileMode(in.Mode),
|
||||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1007,7 +1007,7 @@ func convertAttributes(
|
||||||
out.Blocks = (in.Size + 512 - 1) / 512
|
out.Blocks = (in.Size + 512 - 1) / 512
|
||||||
|
|
||||||
// Set the mode.
|
// Set the mode.
|
||||||
out.Mode = ConvertGolangMode(in.Mode)
|
out.Mode = fuseops.ConvertGolangMode(in.Mode)
|
||||||
|
|
||||||
if out.Mode & (syscall.S_IFCHR | syscall.S_IFBLK) != 0 {
|
if out.Mode & (syscall.S_IFCHR | syscall.S_IFBLK) != 0 {
|
||||||
out.Rdev = in.Rdev
|
out.Rdev = in.Rdev
|
||||||
|
@ -1041,71 +1041,6 @@ func convertChildInodeEntry(
|
||||||
convertAttributes(in.Child, &in.Attributes, &out.Attr)
|
convertAttributes(in.Child, &in.Attributes, &out.Attr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConvertFileMode(unixMode uint32) os.FileMode {
|
|
||||||
mode := os.FileMode(unixMode & 0777)
|
|
||||||
switch unixMode & syscall.S_IFMT {
|
|
||||||
case syscall.S_IFREG:
|
|
||||||
// nothing
|
|
||||||
case syscall.S_IFDIR:
|
|
||||||
mode |= os.ModeDir
|
|
||||||
case syscall.S_IFCHR:
|
|
||||||
mode |= os.ModeCharDevice | os.ModeDevice
|
|
||||||
case syscall.S_IFBLK:
|
|
||||||
mode |= os.ModeDevice
|
|
||||||
case syscall.S_IFIFO:
|
|
||||||
mode |= os.ModeNamedPipe
|
|
||||||
case syscall.S_IFLNK:
|
|
||||||
mode |= os.ModeSymlink
|
|
||||||
case syscall.S_IFSOCK:
|
|
||||||
mode |= os.ModeSocket
|
|
||||||
default:
|
|
||||||
// no idea
|
|
||||||
mode |= os.ModeDevice
|
|
||||||
}
|
|
||||||
if unixMode&syscall.S_ISUID != 0 {
|
|
||||||
mode |= os.ModeSetuid
|
|
||||||
}
|
|
||||||
if unixMode&syscall.S_ISGID != 0 {
|
|
||||||
mode |= os.ModeSetgid
|
|
||||||
}
|
|
||||||
if unixMode&syscall.S_ISVTX != 0 {
|
|
||||||
mode |= os.ModeSticky
|
|
||||||
}
|
|
||||||
return mode
|
|
||||||
}
|
|
||||||
|
|
||||||
func ConvertGolangMode(inMode os.FileMode) uint32 {
|
|
||||||
outMode := uint32(inMode) & 0777
|
|
||||||
switch {
|
|
||||||
default:
|
|
||||||
outMode |= syscall.S_IFREG
|
|
||||||
case inMode&os.ModeDir != 0:
|
|
||||||
outMode |= syscall.S_IFDIR
|
|
||||||
case inMode&os.ModeDevice != 0:
|
|
||||||
if inMode&os.ModeCharDevice != 0 {
|
|
||||||
outMode |= syscall.S_IFCHR
|
|
||||||
} else {
|
|
||||||
outMode |= syscall.S_IFBLK
|
|
||||||
}
|
|
||||||
case inMode&os.ModeNamedPipe != 0:
|
|
||||||
outMode |= syscall.S_IFIFO
|
|
||||||
case inMode&os.ModeSymlink != 0:
|
|
||||||
outMode |= syscall.S_IFLNK
|
|
||||||
case inMode&os.ModeSocket != 0:
|
|
||||||
outMode |= syscall.S_IFSOCK
|
|
||||||
}
|
|
||||||
if inMode&os.ModeSetuid != 0 {
|
|
||||||
outMode |= syscall.S_ISUID
|
|
||||||
}
|
|
||||||
if inMode&os.ModeSetgid != 0 {
|
|
||||||
outMode |= syscall.S_ISGID
|
|
||||||
}
|
|
||||||
if inMode&os.ModeSticky != 0 {
|
|
||||||
outMode |= syscall.S_ISVTX
|
|
||||||
}
|
|
||||||
return outMode
|
|
||||||
}
|
|
||||||
|
|
||||||
func writeXattrSize(m *buffer.OutMessage, size uint32) {
|
func writeXattrSize(m *buffer.OutMessage, size uint32) {
|
||||||
out := (*fusekernel.GetxattrOut)(m.Grow(int(unsafe.Sizeof(fusekernel.GetxattrOut{}))))
|
out := (*fusekernel.GetxattrOut)(m.Grow(int(unsafe.Sizeof(fusekernel.GetxattrOut{}))))
|
||||||
out.Size = size
|
out.Size = size
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
package fuseops
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ConvertFileMode(unixMode uint32) os.FileMode {
|
||||||
|
mode := os.FileMode(unixMode & 0777)
|
||||||
|
switch unixMode & syscall.S_IFMT {
|
||||||
|
case syscall.S_IFREG:
|
||||||
|
// nothing
|
||||||
|
case syscall.S_IFDIR:
|
||||||
|
mode |= os.ModeDir
|
||||||
|
case syscall.S_IFCHR:
|
||||||
|
mode |= os.ModeCharDevice | os.ModeDevice
|
||||||
|
case syscall.S_IFBLK:
|
||||||
|
mode |= os.ModeDevice
|
||||||
|
case syscall.S_IFIFO:
|
||||||
|
mode |= os.ModeNamedPipe
|
||||||
|
case syscall.S_IFLNK:
|
||||||
|
mode |= os.ModeSymlink
|
||||||
|
case syscall.S_IFSOCK:
|
||||||
|
mode |= os.ModeSocket
|
||||||
|
default:
|
||||||
|
// no idea
|
||||||
|
mode |= os.ModeDevice
|
||||||
|
}
|
||||||
|
if unixMode&syscall.S_ISUID != 0 {
|
||||||
|
mode |= os.ModeSetuid
|
||||||
|
}
|
||||||
|
if unixMode&syscall.S_ISGID != 0 {
|
||||||
|
mode |= os.ModeSetgid
|
||||||
|
}
|
||||||
|
if unixMode&syscall.S_ISVTX != 0 {
|
||||||
|
mode |= os.ModeSticky
|
||||||
|
}
|
||||||
|
return mode
|
||||||
|
}
|
||||||
|
|
||||||
|
func ConvertGolangMode(inMode os.FileMode) uint32 {
|
||||||
|
outMode := uint32(inMode) & 0777
|
||||||
|
switch {
|
||||||
|
default:
|
||||||
|
outMode |= syscall.S_IFREG
|
||||||
|
case inMode&os.ModeDir != 0:
|
||||||
|
outMode |= syscall.S_IFDIR
|
||||||
|
case inMode&os.ModeDevice != 0:
|
||||||
|
if inMode&os.ModeCharDevice != 0 {
|
||||||
|
outMode |= syscall.S_IFCHR
|
||||||
|
} else {
|
||||||
|
outMode |= syscall.S_IFBLK
|
||||||
|
}
|
||||||
|
case inMode&os.ModeNamedPipe != 0:
|
||||||
|
outMode |= syscall.S_IFIFO
|
||||||
|
case inMode&os.ModeSymlink != 0:
|
||||||
|
outMode |= syscall.S_IFLNK
|
||||||
|
case inMode&os.ModeSocket != 0:
|
||||||
|
outMode |= syscall.S_IFSOCK
|
||||||
|
}
|
||||||
|
if inMode&os.ModeSetuid != 0 {
|
||||||
|
outMode |= syscall.S_ISUID
|
||||||
|
}
|
||||||
|
if inMode&os.ModeSetgid != 0 {
|
||||||
|
outMode |= syscall.S_ISGID
|
||||||
|
}
|
||||||
|
if inMode&os.ModeSticky != 0 {
|
||||||
|
outMode |= syscall.S_ISVTX
|
||||||
|
}
|
||||||
|
return outMode
|
||||||
|
}
|
|
@ -168,7 +168,7 @@ const (
|
||||||
|
|
||||||
// OpenAccessModeMask is a bitmask that separates the access mode
|
// OpenAccessModeMask is a bitmask that separates the access mode
|
||||||
// from the other flags in OpenFlags.
|
// from the other flags in OpenFlags.
|
||||||
const OpenAccessModeMask OpenFlags = syscall.O_ACCMODE
|
const OpenAccessModeMask OpenFlags = OpenReadOnly | OpenWriteOnly | OpenReadWrite
|
||||||
|
|
||||||
// OpenFlags are the O_FOO flags passed to open/create/etc calls. For
|
// OpenFlags are the O_FOO flags passed to open/create/etc calls. For
|
||||||
// example, os.O_WRONLY | os.O_APPEND.
|
// example, os.O_WRONLY | os.O_APPEND.
|
||||||
|
|
Loading…
Reference in New Issue