// generic Sysctl buffer unmarshalling
504755
func sysctlbyname(name string, data interface{}) (err error) {
	val, err := syscall.Sysctl(name)
	if err != nil {
		return err
	}

	buf := []byte(val)

	switch v := data.(type) {
	case *uint64:
		*v = *(*uint64)(unsafe.Pointer(&buf[0]))
		return
	}

	bbuf := bytes.NewBuffer([]byte(val))
	return binary.Read(bbuf, binary.LittleEndian, data)
}
1156899
func (tsv *TabletServer) InitACL(tableACLConfigFile string, enforceTableACLConfig bool) {
	tsv.initACL(tableACLConfigFile, enforceTableACLConfig)

	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan, syscall.SIGHUP)
	go func() {
		for range sigChan {
			tsv.initACL(tableACLConfigFile, enforceTableACLConfig)
		}
	}()
}
451654
func ValidateSysctl(val string) (string, error) {
	validSysctlMap := map[string]bool{
		"kernel.msgmax":          true,
		"kernel.msgmnb":          true,
		"kernel.msgmni":          true,
		"kernel.sem":             true,
		"kernel.shmall":          true,
		"kernel.shmmax":          true,
		"kernel.shmmni":          true,
		"kernel.shm_rmid_forced": true,
	}
	validSysctlPrefixes := []string{
		"net.",
		"fs.mqueue.",
	}
	arr := strings.Split(val, "=")
	if len(arr) < 2 {
		return "", fmt.Errorf("sysctl '%s' is not whitelisted", val)
	}
	if validSysctlMap[arr[0]] {
		return val, nil
	}

	for _, vp := range validSysctlPrefixes {
		if strings.HasPrefix(arr[0], vp) {
			return val, nil
		}
	}
	return "", fmt.Errorf("sysctl '%s' is not whitelisted", val)
}
1076445
func ioctl(fd, name, data uintptr) error {
	_, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(name), uintptr(data))
	if e != 0 {
		return e
	}

	return nil
}
1117885
func (in *Sysctl) DeepCopy() *Sysctl {
	if in == nil {
		return nil
	}
	out := new(Sysctl)
	in.DeepCopyInto(out)
	return out
}
653086
func GetSyscall(name string) (uint32, bool) {
	res, ok := Syscalls[strings.ToLower(name)]
	return uint32(res), ok
}
434546
func SetSysctl(sysctl string, newVal int) error {
	return ioutil.WriteFile(path.Join(sysctlBase, sysctl), []byte(strconv.Itoa(newVal)), 0640)
}
649909
func sysGet(syscallNum uintptr, path string, name string, data []byte) (int, error) {
	ptr, nbytes := bytePtrFromSlice(data)
	/*
		ssize_t extattr_get_file(
			const char *path,
			int attrnamespace,
			const char *attrname,
			void *data,
			size_t nbytes);

		ssize_t extattr_get_link(
			const char *path,
			int attrnamespace,
			const char *attrname,
			void *data,
			size_t nbytes);
	*/
	r0, _, err := syscall.Syscall6(syscallNum, uintptr(unsafe.Pointer(syscall.StringBytePtr(path))),
		EXTATTR_NAMESPACE_USER, uintptr(unsafe.Pointer(syscall.StringBytePtr(name))),
		uintptr(unsafe.Pointer(ptr)), uintptr(nbytes), 0)
	if err != syscall.Errno(0) {
		return int(r0), err
	}
	return int(r0), nil
}
455749
func sysctlByComponents(components []string, value string) (string, error) {
	components = append([]string{sysctlPath}, components...)
	f, err := os.OpenFile(path.Join(components...), os.O_RDWR, 0)
	if err != nil {
		return "", err
	}
	defer f.Close()
	b, err := ioutil.ReadAll(f)
	if err != nil {
		return "", err
	}
	if _, err := f.Seek(0, 0); err != nil {
		return "", err
	}
	if _, err := fmt.Fprintf(f, "%s\n", value); err != nil {
		return "", err
	}
	return strings.TrimRight(string(b), "\n"), nil
}
821651
func (lx *Lexer) stripBuffer() {
	if len(lx.buffer) > 0 {
		if match := lexerWhitespaceRxx.FindSubmatchIndex(lx.buffer); match != nil {
			lx.buffer = lx.buffer[match[3]:]
		}
	}
}
224215
func validateSCCSysctls(fldPath *field.Path, sysctls []string) field.ErrorList {
	allErrs := field.ErrorList{}

	if len(sysctls) == 0 {
		return allErrs
	}

	coversAll := false
	for i, s := range sysctls {
		if len(s) == 0 {
			allErrs = append(allErrs, field.Invalid(fldPath.Index(i), sysctls[i], fmt.Sprintf("empty sysctl not allowed")))
		} else if !IsValidSysctlPattern(string(s)) {
			allErrs = append(
				allErrs,
				field.Invalid(fldPath.Index(i), sysctls[i], fmt.Sprintf("must have at most %d characters and match regex %s",
					kapivalidation.SysctlMaxLength,
					sysctlPatternFmt,
				)),
			)
		} else if s[0] == '*' {
			coversAll = true
		}
	}

	if coversAll && len(sysctls) > 1 {
		allErrs = append(allErrs, field.Forbidden(fldPath.Child("items"), fmt.Sprintf("if '*' is present, must not specify other sysctls")))
	}

	return allErrs
}
669623
func (w *Wrapper01) UnmarshalCQL(info gocql.TypeInfo, data []byte) error {

	if len(data) > 0 {
		_, ipPrefix, err := net.ParseCIDR(string(data))

		if err != nil {
			return err
		}
		w.ip = ipPrefix
	}

	return nil
}
863535
func WithSysctls(c *container.Container) coci.SpecOpts {
	return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) error {
		// We merge the sysctls injected above with the HostConfig (latter takes
		// precedence for backwards-compatibility reasons).
		for k, v := range c.HostConfig.Sysctls {
			s.Linux.Sysctl[k] = v
		}
		return nil
	}
}
343986
func MsglvlSet(intf string, valset uint32) (uint32, uint32, error) {
	e, err := NewEthtool()
	if err != nil {
		return 0, 0, err
	}
	defer e.Close()
	return e.MsglvlSet(intf, valset)
}
298148
func gsfTell(user_data unsafe.Pointer) int64 {
	l := (*virtualIo)(user_data)
	return l.v.Tell(l.v.UserData)
}
1217848
func Syslog(p Priority, msg string) {
	message := C.CString(msg)

	mu.RLock()
	defer mu.RUnlock()

	C.go_syslog(C.int(p), message)
	C.free(unsafe.Pointer(message))
}
49014
func GetSysctl(sysctl string) (int, error) {
	data, err := ioutil.ReadFile(path.Join(sysctlBase, sysctl))
	if err != nil {
		return -1, err
	}
	val, err := strconv.Atoi(strings.Trim(string(data), " \n"))
	if err != nil {
		return -1, err
	}
	return val, nil
}