Example #1
0
	"bazil.org/bazil/fs/snap"
	wiresnap "bazil.org/bazil/fs/snap/wire"
	"bazil.org/bazil/fs/wire"
	"bazil.org/bazil/tokens"
	"bazil.org/bazil/util/env"
	"bazil.org/fuse"
	"bazil.org/fuse/fs"
)

type listSnaps struct {
	fs      *Volume
	rootDir *dir
}

var _ = fs.Node(&listSnaps{})
var _ = fs.NodeMkdirer(&listSnaps{})
var _ = fs.NodeStringLookuper(&listSnaps{})
var _ = fs.Handle(&listSnaps{})
var _ = fs.HandleReadDirer(&listSnaps{})

func (d *listSnaps) Attr() fuse.Attr {
	return fuse.Attr{
		Inode: tokens.InodeSnap,
		Mode:  os.ModeDir | 0755,
		Nlink: 1,
		Uid:   env.MyUID,
		Gid:   env.MyGID,
	}
}

var _ = fs.NodeStringLookuper(&listSnaps{})
Example #2
0
}

func (r *Fsyncs) RecordedFsync() fuse.FsyncRequest {
	val := r.rec.Recorded()
	if val == nil {
		return fuse.FsyncRequest{}
	}
	return *(val.(*fuse.FsyncRequest))
}

// Mkdirs records a Mkdir request and its fields.
type Mkdirs struct {
	rec RequestRecorder
}

var _ = fs.NodeMkdirer(&Mkdirs{})

// Mkdir records the request and returns an error. Most callers should
// wrap this call in a function that returns a more useful result.
func (r *Mkdirs) Mkdir(req *fuse.MkdirRequest, intr fs.Intr) (fs.Node, fuse.Error) {
	tmp := *req
	r.rec.RecordRequest(&tmp)
	return nil, fuse.EIO
}

// RecordedMkdir returns information about the Mkdir request.
// If no request was seen, returns a zero value.
func (r *Mkdirs) RecordedMkdir() fuse.MkdirRequest {
	val := r.rec.Recorded()
	if val == nil {
		return fuse.MkdirRequest{}
Example #3
0
			// file
			n = &File{
				dir:  d,
				name: name,
			}
			return nil
		}
		return fuse.ENOENT
	})
	if err != nil {
		return nil, err
	}
	return n, nil
}

var _ = fs.NodeMkdirer(&Dir{})

func (d *Dir) Mkdir(c context.Context, req *fuse.MkdirRequest) (fs.Node, error) {
	name := req.Name
	err := d.fs.backend.Update(c, func(ctx Context) error {
		b, err := ctx.Dir(d.path)
		if err != nil {
			return err
		}
		if b == nil {
			return errors.New("dir no longer exists")
		}
		if child, err := b.GetDir(name); err != nil {
			return err
		} else if child != nil {
			return fuse.EEXIST