func mount(c *cli.Context) { if len(c.Args()) != 3 { fmt.Printf("Mount: Invalid arguments\n") cli.ShowSubcommandHelp(c) return } horName := c.Args()[0] accessArgs := c.Args()[1] mntDir := c.Args()[2] handleSignals(mntDir) cacheDir, err := createWorkDirs(horName) err = revelo.Revelo(horName, accessArgs, cacheDir, mntDir) if err != nil { log.Errorf("Cannot mount - err: %v\n", err) return } return }
func MountHandler(req *DockerRequest) *DockerResponse { log.WithFields(log.Fields{"Req": req}).Debug("dv: Mount Handler") VolData.lock.RLock() v, ok := VolData.Volumes[req.Name] VolData.lock.RUnlock() if !ok { log.WithFields(log.Fields{"Volume": v}).Error("dv: Mount: Volume not found") return &DockerResponse{Err: " Volume " + req.Name + " not found"} } if v.mntCount > 0 { log.WithFields(log.Fields{"Volume": v}).Info("dv: Mount: Volume already mounted") } if v.mntCount == 0 { go func() { err := revelo.Revelo(v.HorName, v.AccessArgs, v.CacheDir, v.MntDir) if err != nil { log.WithFields(log.Fields{"Volume": v, "Error": err}).Error("dv: Mount: Cannot mount") return } }() } v.mntCount++ VolData.lock.Lock() VolData.Volumes[req.Name] = v VolData.lock.Unlock() log.Infof("Mounted volume %v", v) listAllVols() return &DockerResponse{MntPoint: v.MntDir, Err: ""} }