-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
45 lines (37 loc) · 1.24 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"fmt"
"log"
"os"
"ranjankuldeep/test/snapshot"
)
func main() {
baseFile := "../ubuntu-22.04.ext4"
overlayDir := "../overlays"
uid := 123
gid := 100
device, err := snapshot.CreateDeviceMapper(baseFile, overlayDir)
if err != nil {
log.Fatalf("Failed to create device mapper: %v", err)
}
defer func() {
if err := device.Cleanup(); err != nil {
log.Fatalf("Failed to cleanup device mapper: %v", err)
}
}()
if err := os.Chown(device.OverlayFilename, uid, gid); err != nil {
log.Fatalf("Failed to change ownership of overlay file: %v", err)
}
fmt.Printf("Ownership of overlay file %s changed to UID: %d and GID: %d\n", device.OverlayFilename, uid, gid)
fmt.Printf("Device Mapper created:\n")
fmt.Printf("Base Device: %s\n", device.BaseDev.Path())
fmt.Printf("Overlay Device: %s\n", device.OverlayDev.Path())
fmt.Printf("Base Name: %s\n", device.BaseName)
fmt.Printf("Overlay Name: %s\n", device.OverlayName)
fmt.Printf("Overlay Filename: %s\n", device.OverlayFilename)
// The overlay device you will pass to Firecracker
overlayDevicePath := fmt.Sprintf("/dev/mapper/%s", device.OverlayName)
fmt.Printf("Overlay Device Path: %s\n", overlayDevicePath)
// methods.ExampleJailerConfig_enablingJailer()
select {}
}