Skip to content

Commit

Permalink
feat(vfscore): Introduce vfscore automount parameterization
Browse files Browse the repository at this point in the history
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
nderjung committed Jul 15, 2023
1 parent c2be572 commit f5fb9e9
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
7 changes: 7 additions & 0 deletions unikraft/export/v0/vfscore/library.go
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"
50 changes: 50 additions & 0 deletions unikraft/export/v0/vfscore/params.go
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,
}, ":")
}

0 comments on commit f5fb9e9

Please sign in to comment.