...

Source file src/github.com/Microsoft/hcsshim/internal/vm/hcs/vsmb.go

Documentation: github.com/Microsoft/hcsshim/internal/vm/hcs

     1  //go:build windows
     2  
     3  package hcs
     4  
     5  import (
     6  	"context"
     7  
     8  	"github.com/Microsoft/hcsshim/internal/hcs/resourcepaths"
     9  	hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2"
    10  	"github.com/Microsoft/hcsshim/internal/protocol/guestrequest"
    11  	"github.com/Microsoft/hcsshim/internal/vm"
    12  )
    13  
    14  func (uvmb *utilityVMBuilder) AddVSMB(ctx context.Context, path string, name string, allowed []string, options *vm.VSMBOptions) error {
    15  	uvmb.doc.VirtualMachine.Devices.VirtualSmb = &hcsschema.VirtualSmb{
    16  		DirectFileMappingInMB: 1024, // Sensible default, but could be a tuning parameter somewhere
    17  		Shares: []hcsschema.VirtualSmbShare{
    18  			{
    19  				Name:         name,
    20  				Path:         path,
    21  				AllowedFiles: allowed,
    22  				Options:      vmVSMBOptionsToHCS(options),
    23  			},
    24  		},
    25  	}
    26  	return nil
    27  }
    28  
    29  func (uvmb *utilityVMBuilder) RemoveVSMB(ctx context.Context, name string) error {
    30  	return vm.ErrNotSupported
    31  }
    32  
    33  func vmVSMBOptionsToHCS(options *vm.VSMBOptions) *hcsschema.VirtualSmbShareOptions {
    34  	return &hcsschema.VirtualSmbShareOptions{
    35  		ReadOnly:            options.ReadOnly,
    36  		ShareRead:           options.ShareRead,
    37  		CacheIo:             options.CacheIo,
    38  		NoOplocks:           options.NoOplocks,
    39  		NoDirectmap:         options.NoDirectMap,
    40  		TakeBackupPrivilege: options.TakeBackupPrivilege,
    41  		PseudoOplocks:       options.PseudoOplocks,
    42  		PseudoDirnotify:     options.PseudoDirnotify,
    43  	}
    44  }
    45  
    46  func (uvm *utilityVM) AddVSMB(ctx context.Context, path string, name string, allowed []string, options *vm.VSMBOptions) error {
    47  	modification := &hcsschema.ModifySettingRequest{
    48  		RequestType: guestrequest.RequestTypeAdd,
    49  		Settings: hcsschema.VirtualSmbShare{
    50  			Name:         name,
    51  			Options:      vmVSMBOptionsToHCS(options),
    52  			Path:         path,
    53  			AllowedFiles: allowed,
    54  		},
    55  		ResourcePath: resourcepaths.VSMBShareResourcePath,
    56  	}
    57  	return uvm.cs.Modify(ctx, modification)
    58  }
    59  
    60  func (uvm *utilityVM) RemoveVSMB(ctx context.Context, name string) error {
    61  	modification := &hcsschema.ModifySettingRequest{
    62  		RequestType:  guestrequest.RequestTypeRemove,
    63  		Settings:     hcsschema.VirtualSmbShare{Name: name},
    64  		ResourcePath: resourcepaths.VSMBShareResourcePath,
    65  	}
    66  	return uvm.cs.Modify(ctx, modification)
    67  }
    68  

View as plain text