Skip to content

Commit

Permalink
update libroot using libroothide
Browse files Browse the repository at this point in the history
  • Loading branch information
roothider committed May 7, 2024
1 parent 54a4f74 commit 9f2e20e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Packages/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
libkrw-provider/libkrw-plugin.*
libroot/libroot.*
libroot/libroot.deb
basebin-link/basebin-link.*
47 changes: 47 additions & 0 deletions Packages/libroot/libroot.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <roothide.h>
#include <uuid/uuid.h>
#include <limits.h>

static char g_jbroot_prefix[PATH_MAX] = {0};
static uuid_string_t g_boot_uuid = {0};

__attribute__((constructor)) static void initializer(void)
{
uint64_t jbranduuid[2] = {jbrand(), jbrand()};
uuid_unparse(*(uuid_t*)&jbranduuid, g_boot_uuid);

strcpy(g_jbroot_prefix, jbroot("/"));
size_t len = strlen(g_jbroot_prefix);
if(g_jbroot_prefix[len]=='/') g_jbroot_prefix[len]='\0';
}

const char *libroot_get_root_prefix(void)
{
return "/rootfs/";
}

const char *libroot_get_jbroot_prefix(void)
{
return g_jbroot_prefix;
}

const char *libroot_get_boot_uuid(void)
{
return g_boot_uuid;
}

char *libroot_dyn_rootfspath(const char *path, char *resolvedPath)
{
const char* newpath = rootfs(path);
if(!newpath) return NULL;
strcpy(resolvedPath, newpath);
return resolvedPath;
}

char *libroot_dyn_jbrootpath(const char *path, char *resolvedPath)
{
const char* newpath = jbroot(path);
if(!newpath) return NULL;
strcpy(resolvedPath, newpath);
return resolvedPath;
}
10 changes: 10 additions & 0 deletions Packages/libroot/libroot.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef LIBROOT_PATHS_H
#define LIBROOT_PATHS_H

const char *libroot_get_root_prefix(void);
const char *libroot_get_jbroot_prefix(void);
const char *libroot_get_boot_uuid(void);
char *libroot_dyn_rootfspath(const char *path, char *resolvedPath);
char *libroot_dyn_jbrootpath(const char *path, char *resolvedPath);

#endif

0 comments on commit 9f2e20e

Please sign in to comment.