MCPcopy
hub / github.com/lima-vm/lima / InspectDisk

Function InspectDisk

pkg/store/disk.go:31–70  ·  view source on GitHub ↗
(diskName string, fsType *string)

Source from the content-addressed store, hash-verified

29}
30
31func InspectDisk(diskName string, fsType *string) (*Disk, error) {
32 disk := &Disk{
33 Name: diskName,
34 FSType: fsType,
35 }
36
37 diskDir, err := DiskDir(diskName)
38 if err != nil {
39 return nil, err
40 }
41
42 disk.Dir = diskDir
43 dataDisk := filepath.Join(diskDir, filenames.DataDisk)
44 if _, err := os.Stat(dataDisk); err != nil {
45 return nil, err
46 }
47
48 disk.Size, disk.Format, err = inspectDisk(dataDisk)
49 if err != nil {
50 return nil, err
51 }
52
53 instDir, err := os.Readlink(filepath.Join(diskDir, filenames.InUseBy))
54 if err != nil {
55 if !errors.Is(err, fs.ErrNotExist) {
56 return nil, err
57 }
58 } else {
59 disk.Instance = filepath.Base(instDir)
60 disk.InstanceDir = instDir
61 }
62
63 if disk.FSType != nil && *disk.FSType == "swap" {
64 disk.MountPoint = "[SWAP]" // only used for log message
65 } else {
66 disk.MountPoint = fmt.Sprintf("/mnt/lima-%s", diskName)
67 }
68
69 return disk, nil
70}
71
72// inspectDisk attempts to inspect the disk size and format with qcow2reader.
73func inspectDisk(fName string) (size int64, format string, _ error) {

Callers 9

attachDisksFunction · 0.92
CmdlineFunction · 0.92
CmdlineFunction · 0.92
StopForciblyFunction · 0.92
diskListActionFunction · 0.92
diskDeleteActionFunction · 0.92
diskUnlockActionFunction · 0.92
diskResizeActionFunction · 0.92

Calls 2

DiskDirFunction · 0.85
inspectDiskFunction · 0.85

Tested by

no test coverage detected