MCPcopy
hub / github.com/containerd/containerd / parseMountOptions

Function parseMountOptions

core/mount/mount_linux.go:337–395  ·  view source on GitHub ↗

parseMountOptions takes fstab style mount options and parses them for use with a standard mount() syscall

(options []string)

Source from the content-addressed store, hash-verified

335// parseMountOptions takes fstab style mount options and parses them for
336// use with a standard mount() syscall
337func parseMountOptions(options []string) (opt mountOpt, err error) {
338 loopOpt := "loop"
339 flagsMap := map[string]struct {
340 clear bool
341 flag int
342 }{
343 "async": {true, unix.MS_SYNCHRONOUS},
344 "atime": {true, unix.MS_NOATIME},
345 "bind": {false, unix.MS_BIND},
346 "defaults": {false, 0},
347 "dev": {true, unix.MS_NODEV},
348 "diratime": {true, unix.MS_NODIRATIME},
349 "dirsync": {false, unix.MS_DIRSYNC},
350 "exec": {true, unix.MS_NOEXEC},
351 "mand": {false, unix.MS_MANDLOCK},
352 "noatime": {false, unix.MS_NOATIME},
353 "nodev": {false, unix.MS_NODEV},
354 "nodiratime": {false, unix.MS_NODIRATIME},
355 "noexec": {false, unix.MS_NOEXEC},
356 "nomand": {true, unix.MS_MANDLOCK},
357 "norelatime": {true, unix.MS_RELATIME},
358 "nostrictatime": {true, unix.MS_STRICTATIME},
359 "nosuid": {false, unix.MS_NOSUID},
360 "rbind": {false, unix.MS_BIND | unix.MS_REC},
361 "relatime": {false, unix.MS_RELATIME},
362 "remount": {false, unix.MS_REMOUNT},
363 "ro": {false, unix.MS_RDONLY},
364 "rw": {true, unix.MS_RDONLY},
365 "strictatime": {false, unix.MS_STRICTATIME},
366 "suid": {true, unix.MS_NOSUID},
367 "sync": {false, unix.MS_SYNCHRONOUS},
368 }
369 for _, o := range options {
370 // X-containerd.* options are internal mount options that should be processed
371 // by the mount manager before reaching this layer.
372 if strings.HasPrefix(o, "X-containerd.") {
373 return opt, fmt.Errorf("internal mount option %q was not consumed by the mount manager", o)
374 }
375 // If the option does not exist in the flags table or the flag
376 // is not supported on the platform,
377 // then it is a data value for a specific fs type
378 if f, exists := flagsMap[o]; exists && f.flag != 0 {
379 if f.clear {
380 opt.flags &^= f.flag
381 } else {
382 opt.flags |= f.flag
383 }
384 } else if o == loopOpt {
385 opt.losetup = true
386 } else if after, ok := strings.CutPrefix(o, "uidmap="); ok {
387 opt.uidmap = after
388 } else if after, ok := strings.CutPrefix(o, "gidmap="); ok {
389 opt.gidmap = after
390 } else {
391 opt.data = append(opt.data, o)
392 }
393 }
394 return

Callers 1

mountMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…