forked from unikraft/kraftkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vfscore): Introduce vfscore automount parameterization
In preparation for individual volume auto-mounting to Unikraft[0], introduce a helper library to serialize command-line arguments representing the in-kernel mount path for a device and its options. [0]: unikraft/unikraft#979 Signed-off-by: Alexander Jung <alex@unikraft.io>
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. | ||
// Licensed under the BSD-3-Clause License (the "License"). | ||
// You may not use this file except in compliance with the License. | ||
package vfscore | ||
|
||
const LibraryName = "vfscore" |
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,50 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. | ||
// Licensed under the BSD-3-Clause License (the "License"). | ||
// You may not use this file except in compliance with the License. | ||
package vfscore | ||
|
||
import ( | ||
"strings" | ||
|
||
"kraftkit.sh/unikraft/export/v0/ukargparse" | ||
) | ||
|
||
var ParamVfsAutomount = ukargparse.NewParamStrSlice("vfs", "automount", nil) | ||
|
||
// ExportedParams returns the parameters available by this exported library. | ||
func ExportedParams() []ukargparse.Param { | ||
return []ukargparse.Param{ | ||
ParamVfsAutomount, | ||
} | ||
} | ||
|
||
// Automount is a vfscore mount entry. | ||
type Automount struct { | ||
sourceDevice string | ||
mountTarget string | ||
fsDriver string | ||
options string | ||
} | ||
|
||
// NewAutomount generates a structure that is representative of one of | ||
// Unikraft's vfscore automounts. | ||
func NewAutomount(sourceDevice, mountTarget, fsDriver, options string) Automount { | ||
return Automount{ | ||
sourceDevice, | ||
mountTarget, | ||
fsDriver, | ||
options, | ||
} | ||
} | ||
|
||
// String implements fmt.Stringer and returns a valid vfs.automount-formatted | ||
// entry. | ||
func (automount Automount) String() string { | ||
return strings.Join([]string{ | ||
automount.sourceDevice, | ||
automount.mountTarget, | ||
automount.fsDriver, | ||
automount.options, | ||
}, ":") | ||
} |