-
Notifications
You must be signed in to change notification settings - Fork 3
/
jobs.go
49 lines (38 loc) · 1.23 KB
/
jobs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"code.google.com/p/go9p/p"
"code.google.com/p/go9p/p/srv"
"github.com/golang/glog"
)
type jobsdir struct {
srv.File
user p.User
}
// mkJobsDir create the jobs directory at the root of the jobd name space.
func mkJobsDir(dir *srv.File, user p.User) (*jobsdir, error) {
glog.V(4).Infof("Entering mkJobsDir(%v, %v)", dir, user)
defer glog.V(4).Infof("Leaving mkJobsDir(%v, %v)", dir, user)
glog.V(3).Infoln("Create the jobs directory")
jobs := &jobsdir{user: user}
if err := jobs.Add(dir, "jobs", user, nil, p.DMDIR|0555, jobs); err != nil {
glog.Errorln("Can't create jobs directory ", err)
return nil, err
}
return jobs, nil
}
// addJob uses mkJob to create a new job subtree for the given job definition and adds it to
// the jobd name space under the jobs directory.
func (jd *jobsdir) addJob(def jobdef) error {
glog.V(4).Infof("Entering jobsdir.addJob(%s)", def)
defer glog.V(4).Infof("Leaving jobsdir.addJob(%s)", def)
glog.V(3).Info("Add job: ", def)
job, err := mkJob(&jd.File, jd.user, def)
if err != nil {
return err
}
if err := job.Add(&jd.File, def.name, jd.user, nil, p.DMDIR|0555, job); err != nil {
glog.Errorf("Can't add job %s to jobs directory", def.name)
return err
}
return nil
}