// FSInfo unsupported returns 0 values for available and capacity and an error.
508522
func FsInfo(path string) (int64, int64, int64, int64, int64, int64, error) {
	return 0, 0, 0, 0, 0, 0, fmt.Errorf("FsInfo not supported for this build.")
}
480657
func fsStatVolume(ctx context.Context, volume string) (os.FileInfo, error) {
	fi, err := fsStat(ctx, volume)
	if err != nil {
		if os.IsNotExist(err) {
			return nil, errVolumeNotFound
		} else if os.IsPermission(err) {
			return nil, errVolumeAccessDenied
		}
		return nil, err
	}

	if !fi.IsDir() {
		return nil, errVolumeAccessDenied
	}

	return fi, nil
}
744765
func (v *StorageVol) GetInfo() (*StorageVolInfo, error) {
	var cinfo C.virStorageVolInfo
	var err C.virError
	result := C.virStorageVolGetInfoWrapper(v.ptr, &cinfo, &err)
	if result == -1 {
		return nil, makeError(&err)
	}
	return &StorageVolInfo{
		Type:       StorageVolType(cinfo._type),
		Capacity:   uint64(cinfo.capacity),
		Allocation: uint64(cinfo.allocation),
	}, nil
}
164708
func (d Ploop) ImageInfo() (ImageInfoData, error) {
	var info ImageInfoData

	out, err := ploopOut("-v-1", "info", "-s", d.dd)
	if err == nil {
		i := reImageInfo.FindStringSubmatch(out)
		if len(i) != 4 {
			return info, &Err{c: -1,
				s: "Can't parse ploop info -s output:\n" + out}
		}
		info.Blocks, _ = strconv.ParseUint(i[1], 10, 64)
		bs, _ := strconv.ParseUint(i[2], 10, 32)
		info.BlockSize = uint32(bs)
		info.Version, _ = strconv.Atoi(i[3])
	}

	return info, err
}
840094
func fsAvailSpace(dir string) (avail float64, err error) {
	var stderr bytes.Buffer
	cmd := exec.Command("df", dir)
	cmd.Stderr = &stderr
	out, err := cmd.Output()
	if err != nil {
		err := fmt.Errorf("df failed: %v", err)
		if stderr.Len() > 0 {
			err = fmt.Errorf("%s (%q)", err, stderr.String())
		}
		return -1, err
	}
	lines := strings.Split(strings.TrimSpace(string(out)), "\n")
	if len(lines) < 2 {
		logger.Errorf("unexpected output: %q", out)
		return -1, fmt.Errorf("could not determine available space on %q", dir)
	}
	fields := strings.Fields(lines[1])
	if len(fields) < 4 {
		logger.Errorf("unexpected output: %q", out)
		return -1, fmt.Errorf("could not determine available space on %q", dir)
	}
	kilobytes, err := strconv.Atoi(fields[3])
	if err != nil {
		return -1, err
	}
	return float64(kilobytes) / 1024, err
}
10431
func NewSystemsInfo(installationSettingsFile string, sshKey string, nfs string) SystemsInfo {

	configParser := NewConfigurationParser(installationSettingsFile)
	installationSettings := configParser.InstallationSettings

	const (
		defaultRemoteArchivePath = "/tmp/archive.backup"
		mysqlRemoteArchivePath   = "/var/vcap/store/mysql/archive.backup"
		nfsRemoteArchivePath     = "/var/vcap/store/shared/archive.backup"
	)

	var systemDumps = make(map[string]SystemDump)

	for _, job := range configParser.FindCFPostgresJobs() {
		switch job.Identifier {
		case "consoledb":
			systemDumps[ERConsole] = &PgInfo{
				SystemInfo: SystemInfo{
					Product:           "cf",
					Component:         "consoledb",
					Identifier:        "credentials",
					SSHPrivateKey:     sshKey,
					RemoteArchivePath: defaultRemoteArchivePath,
				},
				Database: "console",
			}
		case "ccdb":
			systemDumps[ERCc] = &PgInfo{
				SystemInfo: SystemInfo{
					Product:           "cf",
					Component:         "ccdb",
					Identifier:        "credentials",
					SSHPrivateKey:     sshKey,
					RemoteArchivePath: defaultRemoteArchivePath,
				},
				Database: "ccdb",
			}
		case "uaadb":
			systemDumps[ERUaa] = &PgInfo{
				SystemInfo: SystemInfo{
					Product:           "cf",
					Component:         "uaadb",
					Identifier:        "credentials",
					SSHPrivateKey:     sshKey,
					RemoteArchivePath: defaultRemoteArchivePath,
				},
				Database: "uaa",
			}
		}
	}
	if installationSettings.FindJobInstanceCount("cf", "mysql") > 0 {
		systemDumps[ERMySQL] = &MysqlInfo{
			SystemInfo: SystemInfo{
				Product:           "cf",
				Component:         "mysql",
				Identifier:        "mysql_admin_credentials",
				SSHPrivateKey:     sshKey,
				RemoteArchivePath: mysqlRemoteArchivePath,
			},
			Database: "mysql",
		}
	}

	systemDumps[ERDirector] = &SystemInfo{
		Product:           installationSettings.GetBoshName(),
		Component:         "director",
		Identifier:        "director_credentials",
		SSHPrivateKey:     sshKey,
		RemoteArchivePath: defaultRemoteArchivePath,
	}
	if installationSettings.FindJobInstanceCount("cf", "nfs_server") > 0 {
		systemDumps[ERNfs] = &NfsInfo{
			SystemInfo: SystemInfo{
				Product:           "cf",
				Component:         "nfs_server",
				Identifier:        "vm_credentials",
				SSHPrivateKey:     sshKey,
				RemoteArchivePath: nfsRemoteArchivePath,
			},
			BackupType: nfs,
		}
	} else {
		lo.G.Debugf("no nfs will be set: instancecount: %v skipnfs: %v", installationSettings.FindJobInstanceCount("cf", "nfs_server"), nfs)
	}

	return SystemsInfo{
		SystemDumps: systemDumps,
	}
}
494274
func (ds *dockerService) ImageFsInfo(_ context.Context, _ *runtimeapi.ImageFsInfoRequest) (*runtimeapi.ImageFsInfoResponse, error) {
	info, err := ds.client.Info()
	if err != nil {
		klog.Errorf("Failed to get docker info: %v", err)
		return nil, err
	}

	statsClient := &winstats.StatsClient{}
	fsinfo, err := statsClient.GetDirFsInfo(info.DockerRootDir)
	if err != nil {
		klog.Errorf("Failed to get dir fsInfo for %q: %v", info.DockerRootDir, err)
		return nil, err
	}

	filesystems := []*runtimeapi.FilesystemUsage{
		{
			Timestamp: time.Now().UnixNano(),
			UsedBytes: &runtimeapi.UInt64Value{Value: fsinfo.Usage},
			FsId: &runtimeapi.FilesystemIdentifier{
				Mountpoint: info.DockerRootDir,
			},
		},
	}

	return &runtimeapi.ImageFsInfoResponse{ImageFilesystems: filesystems}, nil
}
153485
func (md *metricsStatFS) getFsInfo(metrics *Metrics) error {
	available, capacity, usage, inodes, inodesFree, inodesUsed, err := fs.FsInfo(md.path)
	if err != nil {
		return NewFsInfoFailedError(err)
	}
	metrics.Available = resource.NewQuantity(available, resource.BinarySI)
	metrics.Capacity = resource.NewQuantity(capacity, resource.BinarySI)
	metrics.Used = resource.NewQuantity(usage, resource.BinarySI)
	metrics.Inodes = resource.NewQuantity(inodes, resource.BinarySI)
	metrics.InodesFree = resource.NewQuantity(inodesFree, resource.BinarySI)
	metrics.InodesUsed = resource.NewQuantity(inodesUsed, resource.BinarySI)
	return nil
}
440570
func (client *storageRESTClient) DiskInfo() (info DiskInfo, err error) {
	respBody, err := client.call(storageRESTMethodDiskInfo, nil, nil, -1)
	if err != nil {
		return
	}
	defer http.DrainBody(respBody)
	err = gob.NewDecoder(respBody).Decode(&info)
	return info, err
}
420128
func (f FailFeeInsufficient) Error() string {
	return fmt.Sprintf("FeeInsufficient(htlc_amt==%v, update=%v", f.HtlcMsat,
		spew.Sdump(f.Update))
}
749686
func FSInfo(file string) (FSInfoData, error) {
	once.Do(loadKmod)
	var info FSInfoData

	out, err := ploopOut("-v-1", "info", file)
	if err == nil {
		info.BlockSize = 1024 // ploop info reports in 1-k blocks
		i := reFSInfo.FindStringSubmatch(out)
		if len(i) != 5 {
			return info, &Err{c: -1,
				s: "Can't parse ploop info output:\n" + out}
		}

		info.Blocks, _ = strconv.ParseUint(i[1], 10, 64)
		blocksUsed, _ := strconv.ParseUint(i[2], 10, 64)
		info.BlocksFree = info.Blocks - blocksUsed

		info.Inodes, _ = strconv.ParseUint(i[3], 10, 64)
		inodesUsed, _ := strconv.ParseUint(i[4], 10, 64)
		info.InodesFree = info.Inodes - inodesUsed
	}

	return info, err
}
900590
func (fs *LanguageFs) LstatIfPossible(name string) (os.FileInfo, bool, error) {
	name, err := fs.realName(name)
	if err != nil {
		return nil, false, err
	}

	var fi os.FileInfo
	var b bool

	if lif, ok := fs.Fs.(afero.Lstater); ok {
		fi, b, err = lif.LstatIfPossible(name)
	} else {
		fi, err = fs.Fs.Stat(name)
	}

	if err != nil {
		return nil, b, err
	}

	lfi, err := fs.newLanguageFileInfo(name, fi)

	return lfi, b, err
}
434810
func (fs *RootMappingFs) LstatIfPossible(name string) (os.FileInfo, bool, error) {

	if fs.isRoot(name) {
		return newRootMappingDirFileInfo(name), false, nil
	}
	name = fs.realName(name)

	if ls, ok := fs.Fs.(afero.Lstater); ok {
		fi, b, err := ls.LstatIfPossible(name)
		return &realFilenameInfo{FileInfo: fi, realFilename: name}, b, err
	}
	fi, err := fs.Stat(name)
	return fi, false, err
}
968951
func (daemon *Daemon) fillPlatformInfo(v *types.Info, sysInfo *sysinfo.SysInfo) {
	v.MemoryLimit = sysInfo.MemoryLimit
	v.SwapLimit = sysInfo.SwapLimit
	v.KernelMemory = sysInfo.KernelMemory
	v.KernelMemoryTCP = sysInfo.KernelMemoryTCP
	v.OomKillDisable = sysInfo.OomKillDisable
	v.CPUCfsPeriod = sysInfo.CPUCfsPeriod
	v.CPUCfsQuota = sysInfo.CPUCfsQuota
	v.CPUShares = sysInfo.CPUShares
	v.CPUSet = sysInfo.Cpuset
	v.PidsLimit = sysInfo.PidsLimit
	v.Runtimes = daemon.configStore.GetAllRuntimes()
	v.DefaultRuntime = daemon.configStore.GetDefaultRuntimeName()
	v.InitBinary = daemon.configStore.GetInitPath()

	defaultRuntimeBinary := daemon.configStore.GetRuntime(v.DefaultRuntime).Path
	if rv, err := exec.Command(defaultRuntimeBinary, "--version").Output(); err == nil {
		if _, commit, err := parseRuncVersion(string(rv)); err != nil {
			logrus.Warnf("failed to parse %s version: %v", defaultRuntimeBinary, err)
			v.RuncCommit.ID = "N/A"
		} else {
			v.RuncCommit.ID = commit
		}
	} else {
		logrus.Warnf("failed to retrieve %s version: %v", defaultRuntimeBinary, err)
		v.RuncCommit.ID = "N/A"
	}

	// runc is now shipped as a separate package. Set "expected" to same value
	// as "ID" to prevent clients from reporting a version-mismatch
	v.RuncCommit.Expected = v.RuncCommit.ID

	if rv, err := daemon.containerd.Version(context.Background()); err == nil {
		v.ContainerdCommit.ID = rv.Revision
	} else {
		logrus.Warnf("failed to retrieve containerd version: %v", err)
		v.ContainerdCommit.ID = "N/A"
	}

	// containerd is now shipped as a separate package. Set "expected" to same
	// value as "ID" to prevent clients from reporting a version-mismatch
	v.ContainerdCommit.Expected = v.ContainerdCommit.ID

	// TODO is there still a need to check the expected version for tini?
	// if not, we can change this, and just set "Expected" to v.InitCommit.ID
	v.InitCommit.Expected = dockerversion.InitCommitID

	defaultInitBinary := daemon.configStore.GetInitPath()
	if rv, err := exec.Command(defaultInitBinary, "--version").Output(); err == nil {
		if _, commit, err := parseInitVersion(string(rv)); err != nil {
			logrus.Warnf("failed to parse %s version: %s", defaultInitBinary, err)
			v.InitCommit.ID = "N/A"
		} else {
			v.InitCommit.ID = commit
			v.InitCommit.Expected = dockerversion.InitCommitID[0:len(commit)]
		}
	} else {
		logrus.Warnf("failed to retrieve %s version: %s", defaultInitBinary, err)
		v.InitCommit.ID = "N/A"
	}

	if !v.MemoryLimit {
		v.Warnings = append(v.Warnings, "WARNING: No memory limit support")
	}
	if !v.SwapLimit {
		v.Warnings = append(v.Warnings, "WARNING: No swap limit support")
	}
	if !v.KernelMemory {
		v.Warnings = append(v.Warnings, "WARNING: No kernel memory limit support")
	}
	if !v.KernelMemoryTCP {
		v.Warnings = append(v.Warnings, "WARNING: No kernel memory TCP limit support")
	}
	if !v.OomKillDisable {
		v.Warnings = append(v.Warnings, "WARNING: No oom kill disable support")
	}
	if !v.CPUCfsQuota {
		v.Warnings = append(v.Warnings, "WARNING: No cpu cfs quota support")
	}
	if !v.CPUCfsPeriod {
		v.Warnings = append(v.Warnings, "WARNING: No cpu cfs period support")
	}
	if !v.CPUShares {
		v.Warnings = append(v.Warnings, "WARNING: No cpu shares support")
	}
	if !v.CPUSet {
		v.Warnings = append(v.Warnings, "WARNING: No cpuset support")
	}
	if !v.IPv4Forwarding {
		v.Warnings = append(v.Warnings, "WARNING: IPv4 forwarding is disabled")
	}
	if !v.BridgeNfIptables {
		v.Warnings = append(v.Warnings, "WARNING: bridge-nf-call-iptables is disabled")
	}
	if !v.BridgeNfIP6tables {
		v.Warnings = append(v.Warnings, "WARNING: bridge-nf-call-ip6tables is disabled")
	}
}
973842
func (f *File) info(offset int) (filename string, line, column int) {
	filename = f.name
	if i := searchInts(f.lines, offset); i >= 0 {
		line, column = i+1, offset-f.lines[i]+1
	}
	if len(f.infos) > 0 {
		// almost no files have extra line infos
		if i := searchLineInfos(f.infos, offset); i >= 0 {
			alt := &f.infos[i]
			filename = alt.Filename
			if i := searchInts(f.lines, alt.Offset); i >= 0 {
				line += alt.Line - i - 1
			}
		}
	}
	return
}
1345852
func (h PfssoHandler) validateInfo(ctx context.Context, info map[string]string) error {
	required := []string{"ip", "mac", "username", "role"}
	for _, k := range required {
		if _, ok := info[k]; !ok {
			return errors.New(fmt.Sprintf("Missing %s in request", k))
		}
	}
	return nil
}
1044826
func (s *Service) RateLimitInfo(ctx context.Context) (*RateLimit, error) {
	var rateLimit RateLimit
	return &rateLimit, s.Get(ctx, &rateLimit, fmt.Sprintf("/account/rate-limits"), nil, nil)
}