Пример #1
0
func ncmount(xfs zx.Tree) error {
	if rflag {
		xfs = zx.ROTreeFor(xfs)
	}
	zfs, err := zxfs.New(xfs)
	if err != nil {
		return fmt.Errorf("new zxfs: %s", err)
	}
	dmp = zfs
	c, err := fuse.Mount(mntdir)
	if err != nil {
		return fmt.Errorf("mount zxfs: %s", err)
	}
	defer c.Close()
	err = fs.Serve(c, zfs)
	if err != nil {
		return fmt.Errorf("serve zxfs: %s", err)
	}

	<-c.Ready
	if err := c.MountError; err != nil {
		return fmt.Errorf("mount error: %s", err)
	}
	return nil
}
Пример #2
0
// Create a new cfs given a local tree used as a cache of a remote one.
// Operations are performed on behalf of each file owner.
// The lfs tree must have permission checking disabled
// (cfs will want to update everything in it no matter the user who makes the requests)
func New(tag string, lfs zx.RWTree, rfs zx.Tree, rdonly bool) (*Cfs, error) {
	if lfs == nil || rfs == nil {
		return nil, errors.New("no lfs or rfs")
	}
	rwrfs, ok := rfs.(zx.RWTree)
	if !ok && !rdonly {
		rdonly = true
		rwrfs = zx.ROTreeFor(rfs)
		dbg.Warn("remote %T not rw: rdonly set", rfs)
	}
	if !rdonly {
		if err := chkok(lfs, "Rtime"); err != nil {
			return nil, err
		}
	}
	if tag == "" {
		tag = "cfs!" + rfs.Name()
	}
	fs := &Cfs {
		Tag: tag,
		lfs: lfs,
		cfs: lfs,		// but will keep its ai as nil to wstat uids
		rfs: rwrfs,
		rdonly: rdonly,
		noinvalproto: NoInvalProto,
		Flags: &zx.Flags{Dbg: Debug},
		cUsers: &cUsers {
			who: make(map[string]time.Time),
		},
		cache: cache.New(),
		closedc: make(chan bool),
		polldonec: make(chan bool),
	}
	if DebugLocks {
		fs.lktrz = &lockTrzs{}
	}
	fs.cache.Tag = tag
	fs.cache.Dbg = &fs.Flags.Dbg
	fs.tpath = fmt.Sprintf("cfs%p", fs)
	if fs.noinvalproto {
		fs.invalQ, _ = newInvalQ(tag, &fs.Flags.Dbg, nil)
		close(fs.polldonec)
	} else {
		var mustpoll bool
		fs.invalQ, mustpoll = newInvalQ(tag, &fs.Flags.Dbg, fs.rfs)
		if mustpoll {
			dbg.Warn("%s: polling %s for external changes", tag, fs.rfs)
			// runs with no ai
			go fs.pollproc()
		} else {
			close(fs.polldonec)
		}
	}
	go fs.invalproc()
	fs.Flags.Add("verbsync", &fs.cache.Verb)
	fs.Flags.Add("debug", &fs.Flags.Dbg)
	if d, ok := lfs.(zx.Debugger); ok {
		fs.Flags.Add("ldebug", d.Debug())
	}
	if d, ok := rfs.(zx.Debugger); ok {
		fs.Flags.Add("rdebug", d.Debug())
	}
	fs.Flags.AddRO("rdonly", &fs.rdonly)
	fs.Flags.AddRO("noperm", &fs.NoPermCheck)
	fs.Flags.Add("clear", func(...string)error{
		fs.IOstats.Clear()
		return nil
	})
	return fs, nil
}
Пример #3
0
func ncmount(xfs zx.Tree) error {
	if rflag {
		xfs = zx.ROTreeFor(xfs)
	}
	return zxfs.MountServer(xfs, mntdir)
}