MCPcopy Create free account
hub / github.com/coder/envbox / CreateTUNDevice

Function CreateTUNDevice

xunix/device.go:34–61  ·  view source on GitHub ↗
(ctx context.Context, path string)

Source from the content-addressed store, hash-verified

32}
33
34func CreateTUNDevice(ctx context.Context, path string) (Device, error) {
35 const (
36 major uint = 10
37 // See https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/devices.txt#L336
38 minor uint = 200
39 )
40
41 // TODO offset (from legacy.go)
42 err := createDevice(ctx, deviceConfig{
43 path: path,
44 mode: charDevMode,
45 dev: dev(major, minor),
46 major: major,
47 minor: minor,
48 ftype: charFileType,
49 })
50 if err != nil {
51 return Device{}, xerrors.Errorf("create device: %w", err)
52 }
53
54 return Device{
55 Path: path,
56 Type: DeviceTypeChar,
57 Major: int64(major),
58 Minor: int64(minor),
59 FileMode: charDevMode,
60 }, nil
61}
62
63func CreateFuseDevice(ctx context.Context, path string) (Device, error) {
64 const (

Callers 1

runDockerCVMFunction · 0.92

Calls 3

createDeviceFunction · 0.85
devFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected