MCPcopy Create free account
hub / github.com/danderson/netboot / ReadBootFile

Method ReadBootFile

pixiecore/booters.go:98–120  ·  view source on GitHub ↗
(id ID)

Source from the content-addressed store, hash-verified

96}
97
98func (s *staticBooter) ReadBootFile(id ID) (io.ReadCloser, int64, error) {
99 path := string(id)
100 switch {
101 case path == "kernel":
102 return s.serveFile(s.kernel)
103
104 case strings.HasPrefix(path, "initrd-"):
105 i, err := strconv.Atoi(path[7:])
106 if err != nil || i < 0 || i >= len(s.initrd) {
107 return nil, -1, fmt.Errorf("no file with ID %q", id)
108 }
109 return s.serveFile(s.initrd[i])
110
111 case strings.HasPrefix(path, "other-"):
112 i, err := strconv.Atoi(path[6:])
113 if err != nil || i < 0 || i >= len(s.otherIDs) {
114 return nil, -1, fmt.Errorf("no file with ID %q", id)
115 }
116 return s.serveFile(s.otherIDs[i])
117 }
118
119 return nil, -1, fmt.Errorf("no file with ID %q", id)
120}
121
122func (s *staticBooter) WriteBootFile(ID, io.Reader) error {
123 return nil

Callers

nothing calls this directly

Calls 1

serveFileMethod · 0.95

Tested by

no test coverage detected