Skip to content

Commit adcd1a6

Browse files
committed
feat:Enable remoteproc-runtime to be runnable in user space
Signed-off-by: Yejin Seo <yejseo01@arm.com>
1 parent be9b6e0 commit adcd1a6

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

internal/oci/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const (
1414
stateFileName = "state.json"
1515
)
1616

17-
var stateDir = rootpath.Join("run", "remoteproc")
17+
var stateDir = rootpath.Join(os.Getenv("XDG_RUNTIME_DIR"), "run", "remoteproc")
1818

1919
func NewState(containerID string, bundlePath string) *specs.State {
2020
return &specs.State{

internal/remoteproc/remoteproc.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,19 @@ const (
1818
)
1919

2020
var (
21-
rprocFirmwareStorePath = rootpath.Join("lib", "firmware")
21+
rprocFirmwareStorePath string
2222
rprocClassPath = rootpath.Join("sys", "class", "remoteproc")
2323
)
2424

25+
func init() {
26+
user := os.Getenv("USER")
27+
if user == "root" {
28+
rprocFirmwareStorePath = rootpath.Join("lib", "firmware")
29+
} else {
30+
rprocFirmwareStorePath = rootpath.Join("home", user, "firmware")
31+
}
32+
}
33+
2534
func FindDevicePath(name string) (string, error) {
2635
files, err := os.ReadDir(rprocClassPath)
2736
if err != nil {

internal/runtime/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func Create(containerID string, bundlePath string, pidFile string) error {
6161
state.Annotations[oci.StateResolvedPath] = devicePath
6262
state.Annotations[oci.StateFirmware] = storedFirmwareName
6363
if err := oci.WriteState(state); err != nil {
64-
return err
64+
return fmt.Errorf("failed to write state: %w", err)
6565
}
6666

6767
if pidFile != "" {

0 commit comments

Comments
 (0)