// WithRemappedSnapshotView is similar to WithRemappedSnapshot but rootfs is mounted as read-only.
515084
func WithRemappedSnapshotView(id string, i Image, uid, gid uint32) NewContainerOpts {
	return withRemappedSnapshotBase(id, i, uid, gid, true)
}
945598
func GetSnapshot(ctx context.Context, key string) (s Snapshot, err error) {
	err = withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error {
		sbkt := bkt.Bucket([]byte(key))
		if sbkt == nil {
			return errors.Wrap(errdefs.ErrNotFound, "snapshot does not exist")
		}

		s.ID = fmt.Sprintf("%d", readID(sbkt))
		s.Kind = readKind(sbkt)

		if s.Kind != snapshots.KindActive && s.Kind != snapshots.KindView {
			return errors.Wrapf(errdefs.ErrFailedPrecondition, "requested snapshot %v not active or view", key)
		}

		if parentKey := sbkt.Get(bucketKeyParent); len(parentKey) > 0 {
			spbkt := bkt.Bucket(parentKey)
			if spbkt == nil {
				return errors.Wrap(errdefs.ErrNotFound, "parent does not exist")
			}

			s.ParentIDs, err = parents(bkt, spbkt, readID(spbkt))
			if err != nil {
				return errors.Wrap(err, "failed to get parent chain")
			}
		}
		return nil
	})
	if err != nil {
		return Snapshot{}, err
	}

	return
}
81679
func (s *ApplicationConfigurationUpdate) SetApplicationSnapshotConfigurationUpdate(v *ApplicationSnapshotConfigurationUpdate) *ApplicationConfigurationUpdate {
	s.ApplicationSnapshotConfigurationUpdate = v
	return s
}
130007
func (l *Loader) LoadConfigWithSnapshot(rootDir string) (*configs.Config, *Snapshot, hcl.Diagnostics) {
	rootMod, diags := l.parser.LoadConfigDir(rootDir)
	if rootMod == nil {
		return nil, nil, diags
	}

	snap := &Snapshot{
		Modules: map[string]*SnapshotModule{},
	}
	walker := l.makeModuleWalkerSnapshot(snap)
	cfg, cDiags := configs.BuildConfig(rootMod, walker)
	diags = append(diags, cDiags...)

	addDiags := l.addModuleToSnapshot(snap, "", rootDir, "", nil)
	diags = append(diags, addDiags...)

	return cfg, snap, diags
}
1027695
func (v *RsyncVolume) Snapshots() ([]string, error) {
	glog.Infof("Snapshots()")
	v.Lock()
	defer v.Unlock()
	return v.getSnapshotList()
}
783803
func (v *NFSVolume) GetSnapshotWithTag(tagName string) (*volume.SnapshotInfo, error) {
	return nil, ErrNotSupported
}
1077966
func (s *OsdCsiServer) DeleteSnapshot(
	ctx context.Context,
	req *csi.DeleteSnapshotRequest,
) (*csi.DeleteSnapshotResponse, error) {

	if len(req.GetSnapshotId()) == 0 {
		return nil, status.Error(codes.InvalidArgument, "Snapshot id must be provided")
	}

	// Get grpc connection
	conn, err := s.getConn()
	if err != nil {
		return nil, status.Errorf(
			codes.Internal,
			"Unable to connect to SDK server: %v", err)
	}

	// Get secret if any was passed
	ctx = s.setupContextWithToken(ctx, req.GetSecrets())

	// Check ID is valid with the specified volume capabilities
	volumes := api.NewOpenStorageVolumeClient(conn)

	_, err = volumes.Delete(ctx, &api.SdkVolumeDeleteRequest{
		VolumeId: req.GetSnapshotId(),
	})
	if err != nil {
		return nil, status.Errorf(codes.Internal, "Unable to delete snapshot %s: %v",
			req.GetSnapshotId(),
			err)
	}

	return &csi.DeleteSnapshotResponse{}, nil
}
223016
func (f *Facade) DeleteSnapshot(ctx datastore.Context, snapshotID string) error {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.DeleteSnapshot"))
	// Do not DFSLock here, ControlPlaneDao does that
	if err := f.dfs.Delete(snapshotID); err != nil {
		plog.WithField("snapshotid", snapshotID).WithError(err).Debug("Could not delete snapshot")
		return err
	}
	return nil
}
315493
func newSnapshotRecoveryResponse(term uint64, success bool, commitIndex uint64) *SnapshotRecoveryResponse {
	return &SnapshotRecoveryResponse{
		Term:        term,
		Success:     success,
		CommitIndex: commitIndex,
	}
}
1179693
func (r Network_Storage_Backup_Evault) DisableSnapshots(scheduleType *string) (resp bool, err error) {
	params := []interface{}{
		scheduleType,
	}
	err = r.Session.DoRequest("SoftLayer_Network_Storage_Backup_Evault", "disableSnapshots", params, &r.Options, &resp)
	return
}
722139
func (c *RDS) WaitUntilDBSnapshotDeleted(input *DescribeDBSnapshotsInput) error {
	return c.WaitUntilDBSnapshotDeletedWithContext(aws.BackgroundContext(), input)
}
872032
func (ops *vsphereOps) Snapshot(volumeID string, readonly bool) (interface{}, error) {
	return nil, storageops.ErrNotSupported
}
310252
func (v *RsyncVolume) snapshotPath(label string) string {
	root := v.Driver().Root()
	rawLabel := v.rawSnapshotLabel(label)
	return filepath.Join(root, rawLabel)
}
866880
func (v *DNSView) Snapshot() *DNSViewSnapshot {
	v.mutex.Lock()
	defer v.mutex.Unlock()

	gossipSnapshot := v.gossipState.Snapshot()
	// Snapshot must be cheap if nothing has changed
	if v.lastSnapshot != nil && gossipSnapshot.Version == v.lastSnapshot.version {
		return v.lastSnapshot
	}

	snapshot := &DNSViewSnapshot{
		version: gossipSnapshot.Version,
	}

	zoneMap := make(map[string]*dnsViewSnapshotZone)
	for k, v := range gossipSnapshot.Values {
		if strings.HasPrefix(k, "dns/") {
			tokens := strings.Split(k, "/")
			if len(tokens) != 4 {
				glog.Warningf("key had invalid format: %q", k)
				continue
			}

			zoneID := tokens[1]
			recordType := tokens[2]
			name := tokens[3]

			zone := zoneMap[zoneID]
			if zone == nil {
				zone = &dnsViewSnapshotZone{
					Name:    zoneID,
					Records: make(map[string]DNSRecord),
				}
				zoneMap[zoneID] = zone
			}

			key := recordType + "::" + name

			record, found := zone.Records[key]
			if !found {
				record.Name = name
				record.RrsType = recordType
			}

			addresses := strings.Split(v, ",")
			record.Rrdatas = append(record.Rrdatas, addresses...)
			zone.Records[key] = record
		} else {
			glog.Warningf("unknown tag %q=%q", k, v)
		}
	}

	snapshot.zoneMap = zoneMap
	v.lastSnapshot = snapshot

	return snapshot
}
1189667
func (v VirtualMachine) FindSnapshot(ctx context.Context, name string) (*types.ManagedObjectReference, error) {
	var o mo.VirtualMachine

	err := v.Properties(ctx, v.Reference(), []string{"snapshot"}, &o)
	if err != nil {
		return nil, err
	}

	if o.Snapshot == nil || len(o.Snapshot.RootSnapshotList) == 0 {
		return nil, errors.New("no snapshots for this VM")
	}

	m := make(snapshotMap)
	m.add("", o.Snapshot.RootSnapshotList)

	s := m[name]
	switch len(s) {
	case 0:
		return nil, fmt.Errorf("snapshot %q not found", name)
	case 1:
		return &s[0], nil
	default:
		return nil, fmt.Errorf("%q resolves to %d snapshots", name, len(s))
	}
}
1094631
func (s *Filesystem) StateSnapshotMeta() SnapshotMeta {
	if s.file == nil {
		return SnapshotMeta{} // placeholder
	}

	return SnapshotMeta{
		Lineage: s.file.Lineage,
		Serial:  s.file.Serial,

		TerraformVersion: s.file.TerraformVersion,
	}
}
1283694
func NewSnapshotter(root string) (snapshots.Snapshotter, error) {
	// If directory does not exist, create it
	if _, err := os.Stat(root); err != nil {
		if !os.IsNotExist(err) {
			return nil, err
		}
		if err := os.Mkdir(root, 0755); err != nil {
			return nil, err
		}
	}

	mnt, err := mount.Lookup(root)
	if err != nil {
		return nil, err
	}
	if mnt.FSType != "btrfs" {
		return nil, errors.Wrapf(plugin.ErrSkipPlugin, "path %s must be a btrfs filesystem to be used with the btrfs snapshotter", root)
	}
	var (
		active    = filepath.Join(root, "active")
		view      = filepath.Join(root, "view")
		snapshots = filepath.Join(root, "snapshots")
	)

	for _, path := range []string{
		active,
		view,
		snapshots,
	} {
		if err := os.Mkdir(path, 0755); err != nil && !os.IsExist(err) {
			return nil, err
		}
	}
	ms, err := storage.NewMetaStore(filepath.Join(root, "metadata.db"))
	if err != nil {
		return nil, err
	}

	return &snapshotter{
		device: mnt.Source,
		root:   root,
		ms:     ms,
	}, nil
}