add `dir` endpoint to 9p
This commit is contained in:
parent
5c0038d028
commit
f649cad255
|
|
@ -66,6 +66,7 @@ const (
|
||||||
qidNew = 999997
|
qidNew = 999997
|
||||||
qidNDir = 999996
|
qidNDir = 999996
|
||||||
qidCtl = 999995
|
qidCtl = 999995
|
||||||
|
qidDir = 999994
|
||||||
)
|
)
|
||||||
|
|
||||||
var fileNames = []string{"path", "title", "keywords", "signature", "ctl", "backlinks"}
|
var fileNames = []string{"path", "title", "keywords", "signature", "ctl", "backlinks"}
|
||||||
|
|
@ -299,6 +300,14 @@ func (s *server) walk(cs *connState, fc *plan9.Fcall) *plan9.Fcall {
|
||||||
qids = append(qids, qid)
|
qids = append(qids, qid)
|
||||||
path = "/ctl"
|
path = "/ctl"
|
||||||
found = true
|
found = true
|
||||||
|
} else if name == "dir" {
|
||||||
|
qid := plan9.Qid{
|
||||||
|
Type: QTFile,
|
||||||
|
Path: uint64(qidDir),
|
||||||
|
}
|
||||||
|
qids = append(qids, qid)
|
||||||
|
path = "/dir"
|
||||||
|
found = true
|
||||||
} else if name == "n" {
|
} else if name == "n" {
|
||||||
qid := plan9.Qid{
|
qid := plan9.Qid{
|
||||||
Type: QTDir,
|
Type: QTDir,
|
||||||
|
|
@ -695,6 +704,19 @@ func (s *server) readDir(path string, offset int64, count uint32) []byte {
|
||||||
Muid: "denote",
|
Muid: "denote",
|
||||||
Length: 0,
|
Length: 0,
|
||||||
})
|
})
|
||||||
|
// add dir node
|
||||||
|
dirs = append(dirs, plan9.Dir{
|
||||||
|
Qid: plan9.Qid{
|
||||||
|
Type: QTFile,
|
||||||
|
Path: uint64(qidDir),
|
||||||
|
},
|
||||||
|
Mode: 0444,
|
||||||
|
Name: "dir",
|
||||||
|
Uid: "denote",
|
||||||
|
Gid: "denote",
|
||||||
|
Muid: "denote",
|
||||||
|
Length: uint64(len(s.denoteDir)),
|
||||||
|
})
|
||||||
// add n directory
|
// add n directory
|
||||||
dirs = append(dirs, plan9.Dir{
|
dirs = append(dirs, plan9.Dir{
|
||||||
Qid: plan9.Qid{
|
Qid: plan9.Qid{
|
||||||
|
|
@ -847,6 +869,10 @@ func (s *server) getFileContent(path string) string {
|
||||||
return s.getIndexContent()
|
return s.getIndexContent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if path == "/dir" {
|
||||||
|
return s.denoteDir
|
||||||
|
}
|
||||||
|
|
||||||
parts := strings.Split(strings.Trim(path, "/"), "/")
|
parts := strings.Split(strings.Trim(path, "/"), "/")
|
||||||
if len(parts) != 3 || parts[0] != "n" {
|
if len(parts) != 3 || parts[0] != "n" {
|
||||||
return ""
|
return ""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue