2022-06-20 11:53:16 +00:00
|
|
|
/**
|
|
|
|
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
**/
|
|
|
|
|
2022-11-01 19:05:23 +00:00
|
|
|
package generate
|
2022-06-20 11:53:16 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
|
2022-09-29 09:48:08 +00:00
|
|
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/discover"
|
2022-11-23 15:29:18 +00:00
|
|
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/edits"
|
2022-10-21 11:29:21 +00:00
|
|
|
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
|
2022-06-20 11:53:16 +00:00
|
|
|
specs "github.com/container-orchestrated-devices/container-device-interface/specs-go"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvlib/device"
|
|
|
|
"gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvml"
|
|
|
|
"sigs.k8s.io/yaml"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2022-11-23 20:39:06 +00:00
|
|
|
formatJSON = "json"
|
|
|
|
formatYAML = "yaml"
|
2022-06-20 11:53:16 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type command struct {
|
|
|
|
logger *logrus.Logger
|
|
|
|
}
|
|
|
|
|
|
|
|
type config struct {
|
2023-01-20 14:58:04 +00:00
|
|
|
output string
|
|
|
|
format string
|
|
|
|
deviceNameStrategy string
|
|
|
|
root string
|
|
|
|
nvidiaCTKPath string
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewCommand constructs a generate-cdi command with the specified logger
|
|
|
|
func NewCommand(logger *logrus.Logger) *cli.Command {
|
|
|
|
c := command{
|
|
|
|
logger: logger,
|
|
|
|
}
|
|
|
|
return c.build()
|
|
|
|
}
|
|
|
|
|
|
|
|
// build creates the CLI command
|
|
|
|
func (m command) build() *cli.Command {
|
|
|
|
cfg := config{}
|
|
|
|
|
|
|
|
// Create the 'generate-cdi' command
|
|
|
|
c := cli.Command{
|
2022-11-01 19:05:23 +00:00
|
|
|
Name: "generate",
|
2022-06-20 11:53:16 +00:00
|
|
|
Usage: "Generate CDI specifications for use with CDI-enabled runtimes",
|
2022-11-23 20:39:06 +00:00
|
|
|
Before: func(c *cli.Context) error {
|
|
|
|
return m.validateFlags(c, &cfg)
|
|
|
|
},
|
2022-06-20 11:53:16 +00:00
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
return m.run(c, &cfg)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
c.Flags = []cli.Flag{
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "output",
|
2022-11-23 20:39:06 +00:00
|
|
|
Usage: "Specify the file to output the generated CDI specification to. If this is '' the specification is output to STDOUT",
|
2022-06-20 11:53:16 +00:00
|
|
|
Destination: &cfg.output,
|
|
|
|
},
|
2022-11-23 20:39:06 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "format",
|
|
|
|
Usage: "The output format for the generated spec [json | yaml]. This overrides the format defined by the output file extension (if specified).",
|
|
|
|
Value: formatYAML,
|
|
|
|
Destination: &cfg.format,
|
2022-06-20 11:53:16 +00:00
|
|
|
},
|
2023-01-20 14:58:04 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "device-name-strategy",
|
2023-01-30 12:36:11 +00:00
|
|
|
Usage: "Specify the strategy for generating device names. One of [index | uuid | type-index]",
|
|
|
|
Value: deviceNameStrategyIndex,
|
2023-01-20 14:58:04 +00:00
|
|
|
Destination: &cfg.deviceNameStrategy,
|
|
|
|
},
|
2022-12-01 16:21:35 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "root",
|
|
|
|
Usage: "Specify the root to use when discovering the entities that should be included in the CDI specification.",
|
|
|
|
Destination: &cfg.root,
|
|
|
|
},
|
2022-12-12 14:26:21 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "nvidia-ctk-path",
|
|
|
|
Usage: "Specify the path to use for the nvidia-ctk in the generated CDI specification. If this is left empty, the path will be searched.",
|
|
|
|
Destination: &cfg.nvidiaCTKPath,
|
|
|
|
},
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return &c
|
|
|
|
}
|
|
|
|
|
2022-11-23 20:39:06 +00:00
|
|
|
func (m command) validateFlags(r *cli.Context, cfg *config) error {
|
|
|
|
cfg.format = strings.ToLower(cfg.format)
|
|
|
|
switch cfg.format {
|
|
|
|
case formatJSON:
|
|
|
|
case formatYAML:
|
|
|
|
default:
|
|
|
|
return fmt.Errorf("invalid output format: %v", cfg.format)
|
|
|
|
}
|
|
|
|
|
2023-01-20 14:58:04 +00:00
|
|
|
_, err := NewDeviceNamer(cfg.deviceNameStrategy)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-11-23 20:39:06 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-06-20 11:53:16 +00:00
|
|
|
func (m command) run(c *cli.Context, cfg *config) error {
|
2023-01-20 14:58:04 +00:00
|
|
|
deviceNamer, err := NewDeviceNamer(cfg.deviceNameStrategy)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to create device namer: %v", err)
|
|
|
|
}
|
|
|
|
|
2023-01-19 11:03:07 +00:00
|
|
|
spec, err := m.generateSpec(
|
|
|
|
cfg.root,
|
|
|
|
discover.FindNvidiaCTK(m.logger, cfg.nvidiaCTKPath),
|
2023-01-20 14:58:04 +00:00
|
|
|
deviceNamer,
|
2023-01-19 11:03:07 +00:00
|
|
|
)
|
2022-06-20 11:53:16 +00:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to generate CDI spec: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var outputTo io.Writer
|
2022-11-23 20:39:06 +00:00
|
|
|
if cfg.output == "" {
|
2022-06-20 11:53:16 +00:00
|
|
|
outputTo = os.Stdout
|
|
|
|
} else {
|
2022-11-24 09:13:21 +00:00
|
|
|
err := createParentDirsIfRequired(cfg.output)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to create parent folders for output file: %v", err)
|
|
|
|
}
|
2022-06-20 11:53:16 +00:00
|
|
|
outputFile, err := os.Create(cfg.output)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to create output file: %v", err)
|
|
|
|
}
|
|
|
|
defer outputFile.Close()
|
|
|
|
outputTo = outputFile
|
|
|
|
}
|
|
|
|
|
2022-11-23 20:39:06 +00:00
|
|
|
if outputFileFormat := formatFromFilename(cfg.output); outputFileFormat != "" {
|
|
|
|
m.logger.Debugf("Inferred output format as %q from output file name", outputFileFormat)
|
|
|
|
if !c.IsSet("format") {
|
|
|
|
cfg.format = outputFileFormat
|
|
|
|
} else if outputFileFormat != cfg.format {
|
|
|
|
m.logger.Warningf("Requested output format %q does not match format implied by output file name: %q", cfg.format, outputFileFormat)
|
|
|
|
}
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data, err := yaml.Marshal(spec)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to marshal CDI spec: %v", err)
|
|
|
|
}
|
|
|
|
|
2022-11-23 20:39:06 +00:00
|
|
|
if strings.ToLower(cfg.format) == formatJSON {
|
2022-06-20 11:53:16 +00:00
|
|
|
data, err = yaml.YAMLToJSONStrict(data)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to convert CDI spec from YAML to JSON: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-01 15:21:50 +00:00
|
|
|
err = writeToOutput(cfg.format, data, outputTo)
|
2022-06-20 11:53:16 +00:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to write output: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-11-23 20:39:06 +00:00
|
|
|
func formatFromFilename(filename string) string {
|
|
|
|
ext := filepath.Ext(filename)
|
|
|
|
switch strings.ToLower(ext) {
|
|
|
|
case ".json":
|
|
|
|
return formatJSON
|
|
|
|
case ".yaml":
|
|
|
|
return formatYAML
|
|
|
|
case ".yml":
|
|
|
|
return formatYAML
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2022-12-01 15:21:50 +00:00
|
|
|
func writeToOutput(format string, data []byte, output io.Writer) error {
|
|
|
|
if format == formatYAML {
|
2022-11-02 13:59:04 +00:00
|
|
|
_, err := output.Write([]byte("---\n"))
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to write YAML separator: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_, err := output.Write(data)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to write data: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-01-20 14:58:04 +00:00
|
|
|
func (m command) generateSpec(root string, nvidiaCTKPath string, namer deviceNamer) (*specs.Spec, error) {
|
2022-06-20 11:53:16 +00:00
|
|
|
nvmllib := nvml.New()
|
|
|
|
if r := nvmllib.Init(); r != nvml.SUCCESS {
|
|
|
|
return nil, r
|
|
|
|
}
|
|
|
|
defer nvmllib.Shutdown()
|
|
|
|
|
|
|
|
devicelib := device.New(device.WithNvml(nvmllib))
|
|
|
|
|
2023-01-20 14:58:04 +00:00
|
|
|
deviceSpecs, err := m.generateDeviceSpecs(devicelib, root, nvidiaCTKPath, namer)
|
2022-06-20 11:53:16 +00:00
|
|
|
if err != nil {
|
2022-11-23 15:29:18 +00:00
|
|
|
return nil, fmt.Errorf("failed to create device CDI specs: %v", err)
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
allDevice := createAllDevice(deviceSpecs)
|
2022-06-20 11:53:16 +00:00
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
deviceSpecs = append(deviceSpecs, allDevice)
|
2022-10-10 08:19:08 +00:00
|
|
|
|
2022-12-07 10:09:19 +00:00
|
|
|
allEdits := edits.NewContainerEdits()
|
2022-10-07 14:23:18 +00:00
|
|
|
|
2022-12-01 16:21:35 +00:00
|
|
|
ipcs, err := NewIPCDiscoverer(m.logger, root)
|
2022-06-20 11:53:16 +00:00
|
|
|
if err != nil {
|
2022-11-23 15:29:18 +00:00
|
|
|
return nil, fmt.Errorf("failed to create discoverer for IPC sockets: %v", err)
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
ipcEdits, err := edits.FromDiscoverer(ipcs)
|
2022-06-20 11:53:16 +00:00
|
|
|
if err != nil {
|
2022-11-23 15:29:18 +00:00
|
|
|
return nil, fmt.Errorf("failed to create container edits for IPC sockets: %v", err)
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
2022-11-23 15:29:18 +00:00
|
|
|
// TODO: We should not have to update this after the fact
|
|
|
|
for _, s := range ipcEdits.Mounts {
|
|
|
|
s.Options = append(s.Options, "noexec")
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
allEdits.Append(ipcEdits)
|
2022-11-14 11:20:22 +00:00
|
|
|
|
2022-12-12 14:26:21 +00:00
|
|
|
common, err := NewCommonDiscoverer(m.logger, root, nvidiaCTKPath, nvmllib)
|
2022-11-23 15:29:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to create discoverer for common entities: %v", err)
|
2022-10-21 13:28:45 +00:00
|
|
|
}
|
2022-11-14 11:20:22 +00:00
|
|
|
|
2022-12-12 14:26:21 +00:00
|
|
|
deviceFolderPermissionHooks, err := NewDeviceFolderPermissionHookDiscoverer(m.logger, root, nvidiaCTKPath, deviceSpecs)
|
2022-10-21 11:29:21 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to generated permission hooks for device nodes: %v", err)
|
|
|
|
}
|
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
commonEdits, err := edits.FromDiscoverer(discover.Merge(common, deviceFolderPermissionHooks))
|
2022-06-20 11:53:16 +00:00
|
|
|
if err != nil {
|
2022-11-23 15:29:18 +00:00
|
|
|
return nil, fmt.Errorf("failed to create container edits for common entities: %v", err)
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
2022-10-07 14:23:18 +00:00
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
allEdits.Append(commonEdits)
|
2022-10-07 14:23:18 +00:00
|
|
|
|
2023-01-19 10:48:36 +00:00
|
|
|
// We construct the spec and determine the minimum required version based on the specification.
|
2022-11-23 15:29:18 +00:00
|
|
|
spec := specs.Spec{
|
2023-01-19 10:48:36 +00:00
|
|
|
Version: "NOT_SET",
|
2022-11-23 15:29:18 +00:00
|
|
|
Kind: "nvidia.com/gpu",
|
|
|
|
Devices: deviceSpecs,
|
|
|
|
ContainerEdits: *allEdits.ContainerEdits,
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
|
|
|
|
2023-01-19 10:48:36 +00:00
|
|
|
minVersion, err := cdi.MinimumRequiredVersion(&spec)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to get minumum required CDI spec version: %v", err)
|
|
|
|
}
|
2023-01-30 12:39:08 +00:00
|
|
|
m.logger.Infof("Using minimum required CDI spec version: %s", minVersion)
|
|
|
|
|
2023-01-19 10:48:36 +00:00
|
|
|
spec.Version = minVersion
|
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
return &spec, nil
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
|
|
|
|
2023-01-20 14:58:04 +00:00
|
|
|
func (m command) generateDeviceSpecs(devicelib device.Interface, root string, nvidiaCTKPath string, namer deviceNamer) ([]specs.Device, error) {
|
2022-11-23 15:29:18 +00:00
|
|
|
var deviceSpecs []specs.Device
|
2022-11-14 11:20:22 +00:00
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
err := devicelib.VisitDevices(func(i int, d device.Device) error {
|
|
|
|
isMigEnabled, err := d.IsMigEnabled()
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to check whether device is MIG device: %v", err)
|
2022-11-14 11:20:22 +00:00
|
|
|
}
|
2022-11-23 15:29:18 +00:00
|
|
|
if isMigEnabled {
|
|
|
|
return nil
|
2022-11-14 11:20:22 +00:00
|
|
|
}
|
2022-12-12 14:26:21 +00:00
|
|
|
device, err := NewFullGPUDiscoverer(m.logger, root, nvidiaCTKPath, d)
|
2022-11-23 15:29:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to create device: %v", err)
|
2022-11-14 11:20:22 +00:00
|
|
|
}
|
2022-10-07 14:23:18 +00:00
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
deviceEdits, err := edits.FromDiscoverer(device)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to create container edits for device: %v", err)
|
2022-10-07 14:23:18 +00:00
|
|
|
}
|
|
|
|
|
2023-01-20 14:58:04 +00:00
|
|
|
deviceName, err := namer.GetDeviceName(i, d)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to get device name: %v", err)
|
|
|
|
}
|
2022-11-23 15:29:18 +00:00
|
|
|
deviceSpec := specs.Device{
|
2023-01-20 14:58:04 +00:00
|
|
|
Name: deviceName,
|
2022-11-23 15:29:18 +00:00
|
|
|
ContainerEdits: *deviceEdits.ContainerEdits,
|
2022-10-07 14:23:18 +00:00
|
|
|
}
|
2022-06-20 11:53:16 +00:00
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
deviceSpecs = append(deviceSpecs, deviceSpec)
|
|
|
|
return nil
|
|
|
|
})
|
2022-06-20 11:53:16 +00:00
|
|
|
if err != nil {
|
2022-11-23 15:29:18 +00:00
|
|
|
return nil, fmt.Errorf("failed to generate CDI spec for GPU devices: %v", err)
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
err = devicelib.VisitMigDevices(func(i int, d device.Device, j int, mig device.MigDevice) error {
|
|
|
|
device, err := NewMigDeviceDiscoverer(m.logger, "", d, mig)
|
2022-06-20 11:53:16 +00:00
|
|
|
if err != nil {
|
2022-11-23 15:29:18 +00:00
|
|
|
return fmt.Errorf("failed to create MIG device: %v", err)
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
deviceEdits, err := edits.FromDiscoverer(device)
|
2022-06-20 11:53:16 +00:00
|
|
|
if err != nil {
|
2022-11-23 15:29:18 +00:00
|
|
|
return fmt.Errorf("failed to create container edits for MIG device: %v", err)
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
|
|
|
|
2023-01-20 14:58:04 +00:00
|
|
|
deviceName, err := namer.GetMigDeviceName(i, j, mig)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to get device name: %v", err)
|
|
|
|
}
|
2022-11-23 15:29:18 +00:00
|
|
|
deviceSpec := specs.Device{
|
2023-01-20 14:58:04 +00:00
|
|
|
Name: deviceName,
|
2022-11-23 15:29:18 +00:00
|
|
|
ContainerEdits: *deviceEdits.ContainerEdits,
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
deviceSpecs = append(deviceSpecs, deviceSpec)
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("falied to generate CDI spec for MIG devices: %v", err)
|
2022-06-20 11:53:16 +00:00
|
|
|
}
|
2022-10-21 11:29:21 +00:00
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
return deviceSpecs, nil
|
|
|
|
}
|
2022-10-21 11:29:21 +00:00
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
// createAllDevice creates an 'all' device which combines the edits from the previous devices
|
|
|
|
func createAllDevice(deviceSpecs []specs.Device) specs.Device {
|
2022-12-07 10:09:19 +00:00
|
|
|
edits := edits.NewContainerEdits()
|
2022-10-21 11:29:21 +00:00
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
for _, d := range deviceSpecs {
|
|
|
|
edit := cdi.ContainerEdits{
|
|
|
|
ContainerEdits: &d.ContainerEdits,
|
2022-10-21 11:29:21 +00:00
|
|
|
}
|
2022-11-23 15:29:18 +00:00
|
|
|
edits.Append(&edit)
|
2022-10-21 11:29:21 +00:00
|
|
|
}
|
|
|
|
|
2022-11-23 15:29:18 +00:00
|
|
|
all := specs.Device{
|
|
|
|
Name: "all",
|
|
|
|
ContainerEdits: *edits.ContainerEdits,
|
2022-10-21 11:29:21 +00:00
|
|
|
}
|
2022-11-23 15:29:18 +00:00
|
|
|
return all
|
2022-10-21 11:29:21 +00:00
|
|
|
}
|
2022-11-24 09:13:21 +00:00
|
|
|
|
|
|
|
// createParentDirsIfRequired creates the parent folders of the specified path if requried.
|
|
|
|
// Note that MkdirAll does not specifically check whether the specified path is non-empty and raises an error if it is.
|
|
|
|
// The path will be empty if filename in the current folder is specified, for example
|
|
|
|
func createParentDirsIfRequired(filename string) error {
|
|
|
|
dir := filepath.Dir(filename)
|
|
|
|
if dir == "" {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return os.MkdirAll(dir, 0755)
|
|
|
|
}
|