Updated newConnection.
parent
baa7c29fad
commit
2860526871
|
@ -58,15 +58,27 @@ type Connection struct {
|
|||
cancelFuncs map[uint64]func()
|
||||
}
|
||||
|
||||
// Responsibility for closing the wrapped connection is transferred to the
|
||||
// result. You must call c.close() eventually.
|
||||
// Create a connection wrapping the supplied file descriptor connected to the
|
||||
// kernel. You must eventually call c.close().
|
||||
//
|
||||
// The loggers may be nil.
|
||||
func newConnection(
|
||||
parentCtx context.Context,
|
||||
debugLogger *log.Logger,
|
||||
errorLogger *log.Logger,
|
||||
wrapped *fuseshim.Conn) (c *Connection, err error) {
|
||||
dev *os.File) (c *Connection, err error) {
|
||||
// Create an initialized a wrapped fuseshim connection.
|
||||
wrapped := &fuseshim.Conn{
|
||||
Dev: dev,
|
||||
}
|
||||
|
||||
err = fuseshim.InitMount(wrapped, TODO, TODO)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("fuseshim.InitMount: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Create an object wrapping it.
|
||||
c = &Connection{
|
||||
debugLogger: debugLogger,
|
||||
errorLogger: errorLogger,
|
||||
|
|
|
@ -164,7 +164,7 @@ func Mount(dir string, options ...MountOption) (*Conn, error) {
|
|||
}
|
||||
c.Dev = f
|
||||
|
||||
if err := initMount(c, &conf); err != nil {
|
||||
if err := InitMount(c, conf.maxReadahead, conf.initFlags); err != nil {
|
||||
c.Close()
|
||||
return nil, err
|
||||
}
|
||||
|
@ -181,7 +181,10 @@ func (e *OldVersionError) Error() string {
|
|||
return fmt.Sprintf("kernel FUSE version is too old: %v < %v", e.Kernel, e.LibraryMin)
|
||||
}
|
||||
|
||||
func initMount(c *Conn, conf *mountConfig) error {
|
||||
func InitMount(
|
||||
c *Conn,
|
||||
maxReadahead uint32,
|
||||
initFlags fusekernel.InitFlags) error {
|
||||
req, err := c.ReadRequest()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
|
@ -213,9 +216,9 @@ func initMount(c *Conn, conf *mountConfig) error {
|
|||
|
||||
s := &InitResponse{
|
||||
Library: proto,
|
||||
MaxReadahead: conf.maxReadahead,
|
||||
MaxReadahead: maxReadahead,
|
||||
MaxWrite: maxWrite,
|
||||
Flags: fusekernel.InitBigWrites | conf.initFlags,
|
||||
Flags: fusekernel.InitBigWrites | initFlags,
|
||||
}
|
||||
r.Respond(s)
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue