agent: add id (immutable) and name (mutable) files to 9P agent directory
This commit is contained in:
parent
20f05eae6a
commit
afda1f7dd6
|
|
@ -55,7 +55,9 @@ var AgentFileList = []struct {
|
|||
{"toolsrv.loaded", false, false},
|
||||
{"toolsrv.rev", false, false},
|
||||
{"tools", false, false},
|
||||
}
|
||||
{"name", false, false},
|
||||
{"id", false, false},
|
||||
}
|
||||
|
||||
// FileList is the combined list (for backward compat in tests).
|
||||
var FileList = append(SessionFileList, AgentFileList...)
|
||||
|
|
@ -187,6 +189,18 @@ func (h *agentHelper) fileSpec(name string, mode os.FileMode) FileSpec {
|
|||
|
||||
// Read
|
||||
switch name {
|
||||
case "id":
|
||||
fs.Read = func() ([]byte, error) { return []byte(h.sess.Core.Agent().ID()), nil }
|
||||
case "name":
|
||||
fs.Read = func() ([]byte, error) { return []byte(h.sess.Core.Agent().Name()), nil }
|
||||
fs.Write = func(data []byte) error {
|
||||
newName := strings.TrimSpace(string(data))
|
||||
if newName == "" {
|
||||
return nil
|
||||
}
|
||||
h.sess.Core.Agent().Submit(h.sess.SessionCtx, "/agent "+newName)
|
||||
return nil
|
||||
}
|
||||
case "cwd":
|
||||
fs.Read = func() ([]byte, error) {
|
||||
return []byte(h.sess.Core.CWD() + "\n"), nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue