func runFsInspector(args []string) int { if err := fsFlagset.Parse(args); err != nil { log.Critical(err) return 1 } if _fsFlags.OriginalDir == "" { log.Critical("original-dir is not set") return 1 } if _fsFlags.Mountpoint == "" { log.Critical("mount-point is not set") return 1 } if _fsFlags.AutopilotConfig != "" && _fsFlags.OrchestratorURL != ocutil.LocalOrchestratorURL { log.Critical("non-default orchestrator url set for autopilot orchestration mode") return 1 } if logutil.Debug { // log level: 0..2 hookfs.SetLogLevel(1) } else { hookfs.SetLogLevel(0) } if _fsFlags.AutopilotConfig != "" { cfg, err := config.NewFromFile(_fsFlags.AutopilotConfig) if err != nil { panic(log.Critical(err)) } autopilotOrchestrator, err := ocutil.NewAutopilotOrchestrator(cfg) if err != nil { panic(log.Critical(err)) } log.Info("Starting autopilot-mode orchestrator") go autopilotOrchestrator.Start() } hook := &inspector.FilesystemInspector{ OrchestratorURL: _fsFlags.OrchestratorURL, EntityID: _fsFlags.EntityID, } fs, err := hookfs.NewHookFs(_fsFlags.OriginalDir, _fsFlags.Mountpoint, hook) if err != nil { panic(log.Critical(err)) } log.Infof("Serving %s", fs) log.Infof("Please run `fusermount -u %s` after using this, manually", _fsFlags.Mountpoint) if err = fs.Serve(); err != nil { panic(log.Critical(err)) } // NOTREACHED return 0 }
func serve(original string, mountpoint string) { fs, err := hookfs.NewHookFs(original, mountpoint, &MyHook{}) if err != nil { log.Fatal(err) } log.Infof("Serving %s", fs) log.Infof("Please run `fusermount -u %s` after using this, manually", mountpoint) if err = fs.Serve(); err != nil { log.Fatal(err) } }