예제 #1
0
func (c *Collections) Create(fid *srv.FFid, name string, perm uint32) (*srv.File, error) {
	if collection, ok := c.collections[name]; ok {
		return collection, nil
	}
	collection := new(srv.File)
	if err := collection.Add(&c.File, name, c.uid, nil, go9p.DMDIR|0555, collection); err != nil {
		return nil, err
	}
	query := new(Text)
	if err := query.Add(collection, "query", c.uid, nil, 0666, query); err != nil {
		return nil, err
	}
	mmap := new(Text)
	if err := mmap.Add(collection, "map", c.uid, nil, 0666, mmap); err != nil {
		return nil, err
	}
	reduce := new(Text)
	if err := reduce.Add(collection, "reduce", c.uid, nil, 0666, reduce); err != nil {
		return nil, err
	}

	documents := new(Documents)
	if err := documents.Add(collection, "documents", c.uid, nil, 0666, documents); err != nil {
		return nil, err
	}
	documents.collection = c.db.C(name)
	documents.query = query
	documents.mmap = mmap
	documents.reduce = reduce

	c.collections[name] = collection
	return collection, nil
}
예제 #2
0
func main() {
	var err error
	var tm *Time
	var ntm *InfTime
	var s *srv.Fsrv

	flag.Parse()
	user := go9p.OsUsers.Uid2User(os.Geteuid())
	root := new(srv.File)
	err = root.Add(nil, "/", user, nil, go9p.DMDIR|0555, nil)
	if err != nil {
		goto error
	}

	tm = new(Time)
	err = tm.Add(root, "time", go9p.OsUsers.Uid2User(os.Geteuid()), nil, 0444, tm)
	if err != nil {
		goto error
	}
	ntm = new(InfTime)
	err = ntm.Add(root, "inftime", go9p.OsUsers.Uid2User(os.Geteuid()), nil, 0444, ntm)
	if err != nil {
		goto error
	}

	s = srv.NewFileSrv(root)
	s.Dotu = true

	if *debug {
		s.Debuglevel = 1
	}
	if *debugall {
		s.Debuglevel = 2
	}

	s.Start(s)
	err = s.StartNetListener("tcp", *addr)
	if err != nil {
		goto error
	}

	return

error:
	log.Println(fmt.Sprintf("Error: %s", err))
}
예제 #3
0
파일: main.go 프로젝트: korvinfn/mongofs
func start() error {
	session, err := mgo.Dial(*mongo)
	if err != nil {
		return err
	}
	defer session.Close()
	user := go9p.OsUsers.Uid2User(os.Geteuid())
	root := new(srv.File)
	if err := root.Add(nil, "/", user, nil, go9p.DMDIR|0555, nil); err != nil {
		return err
	}
	if err := collections.Add(root, user, session.DB(*dbname)); err != nil {
		return err
	}
	s := srv.NewFileSrv(root)
	s.Dotu = true
	s.Start(s)
	//s.Debuglevel = srv.DbgPrintFcalls
	return s.StartNetListener("tcp", *addr)
}