// Load mount table
16529
func (c *CustomMounterHandler) Load(devPrefixes []string) error {
	return c.cl(devPrefixes, c.mounts, c.paths)
}
1002616
func (d config) Load(filename string) error {
	d.lock.Lock()
	defer d.lock.Unlock()
	if d.clnt != nil {
		return loadFileConfigEtcd(filename, d.clnt, d.data)
	}
	return loadFileConfig(filename, d.data)
}
1060312
func parseMountTable() ([]*types.MountInfo, error) {
	f, err := os.Open("/proc/self/mountinfo")
	if err != nil {
		return nil, err
	}
	defer f.Close()

	return parseInfoFile(f)
}
293097
func (v *DeviceMapperVolume) loadSnapshotImport(reader io.Reader, label, deviceHash, mountpoint, metaPath string) error {

	// Mount the staging device
	if err := v.driver.DeviceSet.MountDevice(deviceHash, mountpoint, label+"_import"); err != nil {
		glog.Errorf("Could not stage the device %s at mountpoint %s for snapshot %s: %s", deviceHash, mountpoint, label, err)
		return err
	}
	glog.V(2).Infof("Mounted staging device %s at mountpoint %s for snapshot %s", deviceHash, mountpoint, label)
	defer func(d *DeviceMapperDriver, deviceHash, mountpoint string) {
		// We use the provided UnmountDevice func here, rather than our own
		// unmount(), because we DO care about Docker's internal bookkeeping
		// here. Without this, DeviceSet.DeleteDevice will fail.
		if err := d.DeviceSet.UnmountDevice(deviceHash, mountpoint); err != nil {
			glog.V(2).Infof("Error unmounting %s (device: %s): %s", mountpoint, deviceHash, err)
		}
		d.DeviceSet.Lock()
		if err := d.DeactivateDevice(deviceHash); err != nil {
			glog.V(2).Infof("Error deactivating device %s: %s", deviceHash, err)
		}
		d.DeviceSet.Unlock()
	}(v.driver, deviceHash, mountpoint)

	// Read the volume and metadata from the stream and write to disk
	var (
		driverFile = label + "-driver"   // Filesystem type of export volume
		deviceFile = label + "-device"   // Information about the device (if available)
		volumeDir  = label + "-volume"   // Volume data
		metaDir    = label + "-metadata" // Metadata
	)
	driverType := ""
	tarfile := tar.NewReader(reader)
	for {
		header, err := tarfile.Next()
		if err == io.EOF {
			if driverType == "" {
				return ErrIncompatibleSnapshot
			}
			break
		} else if err != nil {
			glog.Errorf("Could not import archive for label %s: %s", label, err)
			return err
		}
		if header.Name == driverFile {

			// Get the driver type of the volume and figure out if it is a
			// valid driver.
			bfr := &bytes.Buffer{}
			if _, err := bfr.ReadFrom(tarfile); err != nil {
				glog.Errorf("Could not read from %s: %s", driverFile, err)
				return err
			}
			driverType = bfr.String()
			glog.V(2).Infof("Volume driver type is %s", driverType)
		} else if header.Name == deviceFile {

			// Update the staging device to match the provided settings
			volInfo := volumeInfo{}
			if err := json.NewDecoder(tarfile).Decode(&volInfo); err != nil {
				glog.Errorf("Could not read from %s: %s", deviceFile, err)
				return err
			}

			// Ensure the size of the device is greater than or equal to the
			// value specified in the settings.
			size, err := v.driver.deviceSize(deviceHash)
			if err != nil {
				glog.Errorf("Could not determine the size of the staging device %s: %s", deviceHash, err)
				return err
			}
			if volInfo.Size > size {
				glog.Warning("Device size from import %s is greater than size of staging device; expanding.", label, deviceHash)
				if err := v.driver.resize(deviceHash, volInfo.Size); err != nil {
					glog.Errorf("Could not resize device %s; not importing snapshot %s: %s", deviceHash, label, err)
					return err
				}
				glog.V(2).Infof("Device %s is now %s", deviceHash, units.HumanSize(float64(volInfo.Size)))
			}
		} else if strings.HasPrefix(header.Name, volumeDir) {

			// Untar into mountpoint
			header.Name = strings.TrimPrefix(header.Name, volumeDir)
			if err := volume.ImportArchiveHeader(header, tarfile, mountpoint); err != nil {
				return err
			}
		} else if strings.HasPrefix(header.Name, metaDir) {

			// Untar into the metadata
			header.Name = strings.TrimPrefix(header.Name, metaDir)
			if err := volume.ImportArchiveHeader(header, tarfile, metaPath); err != nil {
				return err
			}
		}
	}

	// Add device as a snapshot of this volume.
	if err := v.Metadata.AddSnapshot(label, deviceHash); err != nil {
		glog.Errorf("Could not save device %s as snapshot %s: %s", deviceHash, label, err)
		return err
	}

	// Set the snapshot metadata path
	if err := os.Rename(metaPath, filepath.Join(v.driver.MetadataDir(), label)); err != nil {
		glog.Errorf("Could not set device metadata for snapshot %s: %s", label, err)
		return err
	}

	return nil
}
1084915
func loadUglyTable(table []byte, dumpZeros bool) (map[string]interface{}, error) {
	entries := map[string]interface{}{}
	// split the lines by newline
	lines := bytes.Split(table, newLineByte)
	var value int64
	var err error
	// iterate over lines, take 2 lines each time
	// first line contains header names
	// second line contains values
	for i := 0; i < len(lines); i = i + 2 {
		if len(lines[i]) == 0 {
			continue
		}
		headers := bytes.Fields(lines[i])
		prefix := bytes.TrimSuffix(headers[0], colonByte)
		metrics := bytes.Fields(lines[i+1])

		for j := 1; j < len(headers); j++ {
			// counter is zero
			if bytes.Equal(metrics[j], zeroByte) {
				if !dumpZeros {
					continue
				} else {
					entries[string(append(prefix, headers[j]...))] = int64(0)
					continue
				}
			}
			// the counter is not zero, so parse it.
			value, err = strconv.ParseInt(string(metrics[j]), 10, 64)
			if err == nil {
				entries[string(append(prefix, headers[j]...))] = value
			}
		}
	}
	return entries, nil
}
662555
func Load(dir string) (train, test *Set, err error) {
	if train, err = ReadSet(path.Join(dir, "train-images-idx3-ubyte.gz"), path.Join(dir, "train-labels-idx1-ubyte.gz")); err != nil {
		return nil, nil, err
	}
	if test, err = ReadSet(path.Join(dir, "t10k-images-idx3-ubyte.gz"), path.Join(dir, "t10k-labels-idx1-ubyte.gz")); err != nil {
		return nil, nil, err
	}
	return
}
925431
func Mount(r mountRunner, source string, target string, c *MountConfig) error {
	if err := Unmount(r, target); err != nil {
		return errors.Wrap(err, "umount")
	}

	cmd := fmt.Sprintf("sudo mkdir -m %o -p %s && %s", c.Mode, target, mntCmd(source, target, c))
	glog.Infof("Will run: %s", cmd)
	out, err := r.CombinedOutput(cmd)
	glog.Infof("mount err=%s, out=%s", err, out)
	if err != nil {
		return errors.Wrap(err, out)
	}
	return nil
}
1110760
func (m *Mount) Mount(target string) error {
	if m.Type != "windows-layer" {
		return errors.Errorf("invalid windows mount type: '%s'", m.Type)
	}

	home, layerID := filepath.Split(m.Source)

	parentLayerPaths, err := m.GetParentPaths()
	if err != nil {
		return err
	}

	var di = hcsshim.DriverInfo{
		HomeDir: home,
	}

	if err = hcsshim.ActivateLayer(di, layerID); err != nil {
		return errors.Wrapf(err, "failed to activate layer %s", m.Source)
	}
	defer func() {
		if err != nil {
			hcsshim.DeactivateLayer(di, layerID)
		}
	}()

	if err = hcsshim.PrepareLayer(di, layerID, parentLayerPaths); err != nil {
		return errors.Wrapf(err, "failed to prepare layer %s", m.Source)
	}
	return nil
}
1225080
func (d *database) Load(ctx context.Context, i interface{}) error {
	return ctxPool.GetSelect(ctx, d, d.e).Load(i)
}
334795
func (ms *MatStack) Load(m mgl64.Mat4) {
	(*ms)[len(*ms)-1] = m
}
352109
func LoadTable(db *sql.DB, name string) (*Table, error) {
	t := makeTable(name)
	err := t.loadColumns(db)
	if err != nil {
		return nil, err
	}
	err = t.loadKeys(db)
	if err != nil {
		return nil, err
	}
	return t, nil
}
88020
func (api *LocalClient) Load(name string) (*host.Host, error) {
	h, err := api.Filestore.Load(name)
	if err != nil {
		return nil, errors.Wrap(err, "filestore")
	}

	var def registry.DriverDef
	if def, err = registry.Driver(h.DriverName); err != nil {
		return nil, err
	} else if !def.Builtin || def.DriverCreator == nil {
		return api.legacyClient.Load(name)
	}

	h.Driver = def.DriverCreator()
	return h, json.Unmarshal(h.RawDriver, h.Driver)
}
599017
func (t *tmxLoader) Load(url string, data io.Reader) error {
	lvl, err := createLevelFromTmx(data, url)
	if err != nil {
		return err
	}

	t.levels[url] = TMXResource{Level: lvl, url: url}
	return nil
}
1078127
func (mount *MountInfo) Mount() error {
	ret := C.ceph_mount(mount.mount, nil)
	if ret != 0 {
		log.Errorf("Mount: Failed to mount")
		return cephError(ret)
	}
	return nil
}
614124
func (s Session) Load(data map[string]string) {
	for key, value := range data {
		if key == SessionObjectKeyName {
			target := map[string]string{}
			if err := json.Unmarshal([]byte(value), &target); err != nil {
				sessionLog.Error("Unable to unmarshal session ", "key", SessionObjectKeyName, "error", err)
			} else {
				s[key] = target
			}
		} else {
			s[key] = value
		}

	}
}
412970
func (m *nfsMounter) Reload(source string) error {
	newNFSm, err := NewNFSMounter([]string{NFSAllServers},
		m.mountImpl,
		m.Mounter.allowedDirs,
	)
	if err != nil {
		return err
	}
	newNFSmounter, ok := newNFSm.(*nfsMounter)
	if !ok {
		return fmt.Errorf("Internal error failed to convert %T",
			newNFSmounter)
	}

	return m.reload(source, newNFSmounter.mounts[source])
}
981406
func (d *driver) Mount(
	ctx types.Context,
	volumeID, volumeName string,
	opts *types.VolumeMountOpts) (string, *types.Volume, error) {

	ctx.WithFields(log.Fields{
		"volumeName": volumeName,
		"volumeID":   volumeID,
		"opts":       opts}).Info("mounting volume")

	lsAtt := types.VolAttReqWithDevMapOnlyVolsAttachedToInstanceOrUnattachedVols
	if opts.Preempt {
		lsAtt = types.VolAttReqWithDevMapForInstance
	}

	vol, err := d.volumeInspectByIDOrName(
		ctx, volumeID, volumeName, lsAtt, opts.Opts)
	if isErrNotFound(err) && d.volumeCreateImplicit() {
		if vol, err = d.Create(ctx, volumeName, &types.VolumeCreateOpts{
			Opts: utils.NewStore(),
		}); err != nil {
			return "", nil, goof.WithError(
				"problem creating volume implicitly", err)
		}
	} else if err != nil {
		return "", nil, err
	}

	if vol == nil {
		return "", nil, goof.New("no volume returned or created")
	}

	client := context.MustClient(ctx)
	if vol.AttachmentState == types.VolumeAvailable ||
		(opts.Preempt && vol.AttachmentState != types.VolumeAttached) {

		mp, err := d.getVolumeMountPath(vol.Name)
		if err != nil {
			return "", nil, err
		}

		ctx.Debug("performing precautionary unmount")
		_ = client.OS().Unmount(ctx, mp, opts.Opts)

		var token string
		vol, token, err = client.Storage().VolumeAttach(
			ctx, vol.ID, &types.VolumeAttachOpts{
				Force: opts.Preempt,
				Opts:  utils.NewStore(),
			})
		if err != nil {
			return "", nil, err
		}

		if token != "" {
			opts := &types.WaitForDeviceOpts{
				LocalDevicesOpts: types.LocalDevicesOpts{
					ScanType: apiconfig.DeviceScanType(d.config),
					Opts:     opts.Opts,
				},
				Token:   token,
				Timeout: apiconfig.DeviceAttachTimeout(d.config),
			}

			_, _, err = client.Executor().WaitForDevice(ctx, opts)
			if err != nil {
				return "", nil, goof.WithError(
					"problem with device discovery", err)
			}
		}

		vol, err = d.volumeInspectByIDOrName(
			ctx, vol.ID, "", types.VolAttReqTrue, opts.Opts)
		if err != nil {
			return "", nil, err
		}

	}

	if len(vol.Attachments) == 0 {
		return "", nil, goof.New("volume did not attach")
	}

	inst, err := client.Storage().InstanceInspect(ctx, utils.NewStore())
	if err != nil {
		return "", nil, goof.New("problem getting instance ID")
	}
	var ma *types.VolumeAttachment
	for _, att := range vol.Attachments {
		if att.InstanceID.ID == inst.InstanceID.ID {
			ma = att
			break
		}
	}

	if ma == nil {
		return "", nil, goof.New("no local attachment found")
	}

	if ma.DeviceName == "" {
		return "", nil, goof.New("no device name returned")
	}

	mounts, err := client.OS().Mounts(
		ctx, ma.DeviceName, "", opts.Opts)
	if err != nil {
		return "", nil, err
	}

	if len(mounts) > 0 {
		return d.volumeMountPath(mounts[0].MountPoint), vol, nil
	}

	if opts.NewFSType == "" {
		opts.NewFSType = d.fsType()
	}
	if err := client.OS().Format(
		ctx,
		ma.DeviceName,
		&types.DeviceFormatOpts{
			NewFSType:   opts.NewFSType,
			OverwriteFS: opts.OverwriteFS,
		}); err != nil {
		return "", nil, err
	}

	mountPath, err := d.getVolumeMountPath(vol.Name)
	if err != nil {
		return "", nil, err
	}

	if err := os.MkdirAll(mountPath, 0755); err != nil {
		return "", nil, err
	}

	if err := client.OS().Mount(
		ctx,
		ma.DeviceName,
		mountPath,
		&types.DeviceMountOpts{}); err != nil {
		return "", nil, err
	}

	mntPath := d.volumeMountPath(mountPath)

	fields := log.Fields{
		"vol":     vol,
		"mntPath": mntPath,
	}
	ctx.WithFields(fields).Info("volume mounted")

	return mntPath, vol, nil
}