// StatVol - get volume info over the network.
483077
func (client *storageRESTClient) StatVol(volume string) (volInfo VolInfo, err error) {
	values := make(url.Values)
	values.Set(storageRESTVolume, volume)
	respBody, err := client.call(storageRESTMethodStatVol, values, nil, -1)
	if err != nil {
		return
	}
	defer http.DrainBody(respBody)
	err = gob.NewDecoder(respBody).Decode(&volInfo)
	return volInfo, err
}
419327
func (s *VolumeService) GetVolumeByID(id string, opts ...OptionFunc) (*Volume, int, error) {
	p := &ListVolumesParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListVolumes(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.Volumes[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for Volume UUID: %s!", id)
}
257177
func (c *s3Client) Stat(isIncomplete, isFetchMeta bool, sse encrypt.ServerSide) (*clientContent, *probe.Error) {
	c.mutex.Lock()
	defer c.mutex.Unlock()
	bucket, object := c.url2BucketAndObject()
	// Bucket name cannot be empty, stat on URL has no meaning.
	if bucket == "" {
		return nil, probe.NewError(BucketNameEmpty{})
	}

	if object == "" {
		content, err := c.bucketStat(bucket)
		if err != nil {
			return nil, err.Trace(bucket)
		}
		return content, nil
	}

	// The following code tries to calculate if a given prefix/object does really exist
	// using minio-go listing API. The following inputs are supported:
	//     - /path/to/existing/object
	//     - /path/to/existing_directory
	//     - /path/to/existing_directory/
	//     - /path/to/empty_directory
	//     - /path/to/empty_directory/

	nonRecursive := false
	objectMetadata := &clientContent{}

	// Prefix to pass to minio-go listing in order to fetch a given object/directory
	prefix := strings.TrimRight(object, string(c.targetURL.Separator))

	// If the request is for incomplete upload stat, handle it here.
	if isIncomplete {
		for objectMultipartInfo := range c.api.ListIncompleteUploads(bucket, prefix, nonRecursive, nil) {
			if objectMultipartInfo.Err != nil {
				return nil, probe.NewError(objectMultipartInfo.Err)
			}

			if objectMultipartInfo.Key == object {
				objectMetadata.URL = *c.targetURL
				objectMetadata.Time = objectMultipartInfo.Initiated
				objectMetadata.Size = objectMultipartInfo.Size
				objectMetadata.Type = os.FileMode(0664)
				objectMetadata.Metadata = map[string]string{}
				objectMetadata.EncryptionHeaders = map[string]string{}
				return objectMetadata, nil
			}

			if strings.HasSuffix(objectMultipartInfo.Key, string(c.targetURL.Separator)) {
				objectMetadata.URL = *c.targetURL
				objectMetadata.Type = os.ModeDir
				objectMetadata.Metadata = map[string]string{}
				objectMetadata.EncryptionHeaders = map[string]string{}

				return objectMetadata, nil
			}
		}
		return nil, probe.NewError(ObjectMissing{})
	}

	opts := minio.StatObjectOptions{}
	opts.ServerSideEncryption = sse

	for objectStat := range c.listObjectWrapper(bucket, prefix, nonRecursive, nil) {
		if objectStat.Err != nil {
			return nil, probe.NewError(objectStat.Err)
		}
		if strings.HasSuffix(objectStat.Key, string(c.targetURL.Separator)) {
			objectMetadata.URL = *c.targetURL
			objectMetadata.Type = os.ModeDir

			if isFetchMeta {
				stat, err := c.getObjectStat(bucket, object, opts)
				if err != nil {
					return nil, err
				}
				objectMetadata.ETag = stat.ETag
				objectMetadata.Metadata = stat.Metadata
				objectMetadata.EncryptionHeaders = stat.EncryptionHeaders
				objectMetadata.Expires = stat.Expires
			}
			return objectMetadata, nil
		} else if objectStat.Key == object {
			objectMetadata.URL = *c.targetURL
			objectMetadata.Time = objectStat.LastModified
			objectMetadata.Size = objectStat.Size
			objectMetadata.ETag = objectStat.ETag
			objectMetadata.Type = os.FileMode(0664)
			objectMetadata.Metadata = map[string]string{}
			objectMetadata.Expires = objectStat.Expires
			objectMetadata.EncryptionHeaders = map[string]string{}
			if isFetchMeta {
				stat, err := c.getObjectStat(bucket, object, opts)
				if err != nil {
					return nil, err
				}
				objectMetadata.Metadata = stat.Metadata
				objectMetadata.EncryptionHeaders = stat.EncryptionHeaders
				objectMetadata.Expires = stat.Expires
			}
			return objectMetadata, nil
		}
	}
	return c.getObjectStat(bucket, object, opts)
}
320362
func (c *ContivClient) VolumeList() (*[]*Volume, error) {
	// build key and URL
	url := c.baseURL + "/api/v1/volumes/"

	// http get the object
	var objList []*Volume
	err := c.httpGet(url, &objList)
	if err != nil {
		log.Debugf("Error getting volumes. Err: %v", err)
		return nil, err
	}

	return &objList, nil
}
1041027
func (ga *openstackStorageAdapter) GetVolume(volumeId string) (*cinder.Volume, error) {
	resp, err := ga.cinderClient.GetVolume(volumeId)
	if err != nil {
		if gooseerrors.IsNotFound(err) {
			return nil, errors.NotFoundf("volume %q", volumeId)
		}
		return nil, err
	}
	return &resp.Volume, nil
}
1041344
func GetVolumeFSType(v api.Volume) (securityapi.FSType, error) {
	switch {
	case v.HostPath != nil:
		return securityapi.FSTypeHostPath, nil
	case v.EmptyDir != nil:
		return securityapi.FSTypeEmptyDir, nil
	case v.GCEPersistentDisk != nil:
		return securityapi.FSTypeGCEPersistentDisk, nil
	case v.AWSElasticBlockStore != nil:
		return securityapi.FSTypeAWSElasticBlockStore, nil
	case v.GitRepo != nil:
		return securityapi.FSTypeGitRepo, nil
	case v.Secret != nil:
		return securityapi.FSTypeSecret, nil
	case v.NFS != nil:
		return securityapi.FSTypeNFS, nil
	case v.ISCSI != nil:
		return securityapi.FSTypeISCSI, nil
	case v.Glusterfs != nil:
		return securityapi.FSTypeGlusterfs, nil
	case v.PersistentVolumeClaim != nil:
		return securityapi.FSTypePersistentVolumeClaim, nil
	case v.RBD != nil:
		return securityapi.FSTypeRBD, nil
	case v.FlexVolume != nil:
		return securityapi.FSTypeFlexVolume, nil
	case v.Cinder != nil:
		return securityapi.FSTypeCinder, nil
	case v.CephFS != nil:
		return securityapi.FSTypeCephFS, nil
	case v.Flocker != nil:
		return securityapi.FSTypeFlocker, nil
	case v.DownwardAPI != nil:
		return securityapi.FSTypeDownwardAPI, nil
	case v.FC != nil:
		return securityapi.FSTypeFC, nil
	case v.AzureFile != nil:
		return securityapi.FSTypeAzureFile, nil
	case v.ConfigMap != nil:
		return securityapi.FSTypeConfigMap, nil
	case v.VsphereVolume != nil:
		return securityapi.FSTypeVsphereVolume, nil
	case v.Quobyte != nil:
		return securityapi.FSTypeQuobyte, nil
	case v.AzureDisk != nil:
		return securityapi.FSTypeAzureDisk, nil
	case v.PhotonPersistentDisk != nil:
		return securityapi.FSTypePhotonPersistentDisk, nil
	case v.Projected != nil:
		return securityapi.FSProjected, nil
	case v.PortworxVolume != nil:
		return securityapi.FSPortworxVolume, nil
	case v.ScaleIO != nil:
		return securityapi.FSScaleIO, nil
	case v.StorageOS != nil:
		return securityapi.FSStorageOS, nil
	}

	return "", fmt.Errorf("unknown volume type for volume: %#v", v)
}
80296
func (e *defaultStoreEnumerator) CreateVol(vol *api.Volume) error {
	_, err := e.kvdb.Create(e.volKey(vol.Id), vol, 0)
	return err
}
493217
func (s *VolumeService) GetVolumeID(name string, opts ...OptionFunc) (string, int, error) {
	p := &ListVolumesParams{}
	p.p = make(map[string]interface{})

	p.p["name"] = name

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return "", -1, err
		}
	}

	l, err := s.ListVolumes(p)
	if err != nil {
		return "", -1, err
	}

	if l.Count == 0 {
		return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
	}

	if l.Count == 1 {
		return l.Volumes[0].Id, l.Count, nil
	}

	if l.Count > 1 {
		for _, v := range l.Volumes {
			if v.Name == name {
				return v.Id, l.Count, nil
			}
		}
	}
	return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
}
333199
func (s *StatsService) All(pair string, period, volume string) ([]Stats, error) {
	pair = strings.ToUpper(pair)

	params := url.Values{}
	if period != "" {
		params.Add("period", period)
	}
	if volume != "" {
		params.Add("volume", volume)
	}
	req, err := s.client.newRequest("GET", "stats/"+strings.ToUpper(pair), params)

	if err != nil {
		return nil, err
	}

	var stats []Stats
	_, err = s.client.do(req, &stats)

	if err != nil {
		return nil, err
	}

	return stats, nil
}
490930
func (DefaultFs) Stat(name string) (os.FileInfo, error) {
	return os.Stat(name)
}
31986
func (e *defaultStoreEnumerator) UpdateVol(vol *api.Volume) error {
	_, err := e.kvdb.Put(e.volKey(vol.Id), vol, 0)
	return err
}
684959
func (f *DatastoreFile) Stat() (os.FileInfo, error) {
	// TODO: consider using Datastore.Stat() instead
	u, p, err := f.d.downloadTicket(f.ctx, f.name, &soap.Download{Method: "HEAD"})
	if err != nil {
		return nil, err
	}

	res, err := f.d.Client().DownloadRequest(f.ctx, u, p)
	if err != nil {
		return nil, err
	}

	if res.StatusCode != http.StatusOK {
		return nil, statusError(res)
	}

	f.length = res.ContentLength

	return &fileStat{f, res.Header}, nil
}
570261
func (f *FS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error {
	*resp = fuse.StatfsResponse{
		Bsize:   fuseBlockSize,
		Namelen: ^uint32(0),
		Frsize:  fuseBlockSize,
	}

	if f.remoteStatus.ExtraFileName() != "" {
		f.vlog.CLogf(
			ctx, libkb.VLog1,
			"Skipping quota usage check while errors are present")
		return nil
	}

	if session, err := idutil.GetCurrentSessionIfPossible(
		ctx, f.config.KBPKI(), true); err != nil {
		return err
	} else if session == (idutil.SessionInfo{}) {
		// If user is not logged in, don't bother getting quota info. Otherwise
		// reading a public TLF while logged out can fail on macOS.
		return nil
	}
	_, usageBytes, _, limitBytes, err := f.quotaUsage.Get(
		ctx, quotaUsageStaleTolerance/2, quotaUsageStaleTolerance)
	if err != nil {
		f.vlog.CLogf(ctx, libkb.VLog1, "Getting quota usage error: %v", err)
		return err
	}

	total := getNumBlocksFromSize(uint64(limitBytes))
	used := getNumBlocksFromSize(uint64(usageBytes))
	resp.Blocks = total
	resp.Bavail = total - used
	resp.Bfree = total - used

	return nil
}
69689
func statFile(path string) (os.FileInfo, error) {
	gopherjsRoot := filepath.Join(build.Default.GOROOT, "src", "github.com", "gopherjs", "gopherjs")
	if strings.HasPrefix(path, gopherjsRoot+string(filepath.Separator)) {
		path = filepath.ToSlash(path[len(gopherjsRoot):])
		if fi, err := vfsutil.Stat(gopherjspkg.FS, path); err == nil {
			return fi, nil
		}
	}
	return os.Stat(path)
}
1013570
func (fod fileOrDir) Stat() (fi os.FileInfo, err error) {
	defer func() {
		if err != nil {
			err = translateErr(err)
		}
	}()
	if fod.file != nil {
		return &FileInfo{
			fs:   fod.file.fs,
			ei:   fod.ei,
			node: fod.file.node,
			name: fod.file.node.GetBasename(),
		}, nil
	} else if fod.dir != nil {
		return &FileInfo{
			fs:   fod.dir.fs,
			ei:   fod.ei,
			node: fod.dir.node,
			name: fod.dir.node.GetBasename(),
		}, nil
	}
	return nil, errors.New("invalid fod")
}
516498
func (v *volumeClient) Stats(
	volumeID string,
	cumulative bool,
) (*api.Stats, error) {
	stats := &api.Stats{}
	req := v.c.Get().Resource(volumePath + "/stats").Instance(volumeID)
	req.QueryOption(api.OptCumulative, strconv.FormatBool(cumulative))

	err := req.Do().Unmarshal(stats)
	return stats, err

}
210301
func (_m *API) GetVolumeStatus() (*volume.Statuses, error) {
	ret := _m.Called()

	var r0 *volume.Statuses
	if rf, ok := ret.Get(0).(func() *volume.Statuses); ok {
		r0 = rf()
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*volume.Statuses)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func() error); ok {
		r1 = rf()
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}