Skip to content

Commit

Permalink
client: enable support to fifo and socket file types
Browse files Browse the repository at this point in the history
Signed-off-by: Shuoran Liu <[email protected]>
  • Loading branch information
shuoranliu authored and awzhgw committed Jun 11, 2019
1 parent 731f8ec commit fdc357d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions client/fs/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var (
_ fs.NodeCreater = (*Dir)(nil)
_ fs.NodeForgetter = (*Dir)(nil)
_ fs.NodeMkdirer = (*Dir)(nil)
_ fs.NodeMknoder = (*Dir)(nil)
_ fs.NodeRemover = (*Dir)(nil)
_ fs.NodeFsyncer = (*Dir)(nil)
_ fs.NodeRequestLookuper = (*Dir)(nil)
Expand Down Expand Up @@ -281,6 +282,31 @@ func (d *Dir) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.
return nil
}

func (d *Dir) Mknod(ctx context.Context, req *fuse.MknodRequest) (fs.Node, error) {
if (req.Mode&os.ModeNamedPipe == 0 && req.Mode&os.ModeSocket == 0) || req.Rdev != 0 {
return nil, fuse.ENOSYS
}

start := time.Now()
info, err := d.super.mw.Create_ll(d.inode.ino, req.Name, proto.Mode(req.Mode), nil)
if err != nil {
log.LogErrorf("Mknod: parent(%v) req(%v) err(%v)", d.inode.ino, req, err)
return nil, ParseError(err)
}

inode := NewInode(info)
d.super.ic.Put(inode)
child := NewFile(d.super, inode)

d.super.fslock.Lock()
d.super.nodeCache[inode.ino] = child
d.super.fslock.Unlock()

elapsed := time.Since(start)
log.LogDebugf("TRACE Mknod: parent(%v) req(%v) ino(%v) (%v)ns", d.inode.ino, req, inode.ino, elapsed.Nanoseconds())
return child, nil
}

// Symlink handles the symlink request.
func (d *Dir) Symlink(ctx context.Context, req *fuse.SymlinkRequest) (fs.Node, error) {
parentIno := d.inode.ino
Expand Down

0 comments on commit fdc357d

Please sign in to comment.