~mterry/snappy/selftest-reboot-notice

« back to all changes in this revision

Viewing changes to cmd/snappy/cmd_hwassign.go

  • Committer: Snappy Tarmac
  • Author(s): Michael Vogt
  • Date: 2015-06-16 10:32:05 UTC
  • mfrom: (510.1.3 snappy-with-decorator)
  • Revision ID: snappy_tarmac-20150616103205-czpa1fhc2cyr2c9p
Add priv.WithMutex() decorator to avoid duplicating code in cmd/snappy/cmd_*.go by mvo approved by chipaca

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        }
49
49
}
50
50
 
51
 
func (x *cmdHWAssign) Execute(args []string) (err error) {
52
 
        privMutex := priv.New()
53
 
        if err := privMutex.TryLock(); err != nil {
54
 
                return err
55
 
        }
56
 
        defer privMutex.Unlock()
 
51
func (x *cmdHWAssign) Execute(args []string) error {
 
52
        return priv.WithMutex(x.doHWAssign)
 
53
}
57
54
 
 
55
func (x *cmdHWAssign) doHWAssign() error {
58
56
        if err := snappy.AddHWAccess(x.Positional.PackageName, x.Positional.DevicePath); err != nil {
59
57
                if err == snappy.ErrHWAccessAlreadyAdded {
60
58
                        fmt.Printf("'%s' previously allowed access to '%s'. Skipping\n", x.Positional.PackageName, x.Positional.DevicePath)