MCPcopy Create free account
hub / github.com/linuxkit/linuxkit / findDrives

Function findDrives

pkg/extend/extend.go:304–322  ·  view source on GitHub ↗

return a list of all available drives

()

Source from the content-addressed store, hash-verified

302
303// return a list of all available drives
304func findDrives() {
305 driveKeys = []string{}
306 ignoreExp := regexp.MustCompile(`^loop.*$|^nbd.*$|^[a-z]+[0-9]+$`)
307 devs, _ := ioutil.ReadDir("/dev")
308 for _, d := range devs {
309 // this probably shouldn't be so hard
310 // but d.Mode()&os.ModeDevice == 0 doesn't work as expected
311 mode := d.Sys().(*syscall.Stat_t).Mode
312 if (mode & syscall.S_IFMT) != syscall.S_IFBLK {
313 continue
314 }
315 // ignore if it matches regexp
316 if ignoreExp.MatchString(d.Name()) {
317 continue
318 }
319 driveKeys = append(driveKeys, filepath.Join("/dev", d.Name()))
320 }
321 sort.Strings(driveKeys)
322}
323
324func init() {
325 flag.StringVar(&fsTypeVar, "type", "ext4", "Type of filesystem to create")

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected