Last active
August 29, 2015 13:57
-
-
Save wkharold/9861636 to your computer and use it in GitHub Desktop.
mkjobfs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** jobd.go ***/ | |
// mkjobfs creates the static portion of the jobd file hierarchy: the 'clone' | |
// file, and the 'jobs' directory at the root of the hierarchy. | |
func mkjobfs() (*srv.File, error) { | |
var err error | |
user := p.OsUsers.Uid2User(os.Geteuid()) | |
root := new(srv.File) | |
err = root.Add(nil, "/", user, nil, p.DMDIR|0555, nil) | |
if err != nil { | |
return nil, err | |
} | |
err = mkCloneFile(root, user) | |
if err != nil { | |
return nil, err | |
} | |
jobsroot, err = mkJobsDir(root, user) | |
if err != nil { | |
return nil, err | |
} | |
return root, nil | |
} | |
/*** clone.go ***/ | |
type clonefile struct { | |
srv.File | |
} | |
// mkCloneFile creates the clone file at the root of the jobd name space. | |
func mkCloneFile(dir *srv.File, user p.User) error { | |
glog.V(4).Infoln("Entering mkCloneFile(%v, %v)", dir, user) | |
defer glog.V(4).Infoln("Exiting mkCloneFile(%v, %v)", dir, user) | |
glog.V(3).Infoln("Create the clone file") | |
k := new(clonefile) | |
if err := k.Add(dir, "clone", user, nil, 0666, k); err != nil { | |
glog.Errorln("Can't create clone file: ", err) | |
return err | |
} | |
return nil | |
} | |
/*** jobs.go ***/ | |
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment