-
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #281 from stgraber/main
Allow configuring OVN SSL settings through server configuration
- Loading branch information
Showing
7 changed files
with
229 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package linux | ||
|
||
import ( | ||
"os" | ||
|
||
"golang.org/x/sys/unix" | ||
|
||
"github.com/lxc/incus/internal/revert" | ||
) | ||
|
||
// CreateMemfd creates a new memfd for the provided byte slice. | ||
func CreateMemfd(content []byte) (*os.File, error) { | ||
revert := revert.New() | ||
defer revert.Fail() | ||
|
||
// Create the memfd. | ||
fd, err := unix.MemfdCreate("memfd", unix.MFD_CLOEXEC) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
revert.Add(func() { unix.Close(fd) }) | ||
|
||
// Set its size. | ||
err = unix.Ftruncate(fd, int64(len(content))) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Prepare the storage. | ||
data, err := unix.Mmap(fd, 0, len(content), unix.PROT_READ|unix.PROT_WRITE, unix.MAP_SHARED) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Write the content. | ||
copy(data, content) | ||
|
||
// Cleanup. | ||
err = unix.Munmap(data) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
revert.Success() | ||
return os.NewFile(uintptr(fd), "memfd"), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters