Split make_system_path_relative_to_its_root into separate file
relpath.c from getroot.c as it's common between unix and haiku but otherwise haiku doesn't use any functions from unix getroot.c.
This commit is contained in:
parent
31de274d29
commit
a4012f0764
9 changed files with 358 additions and 235 deletions
|
@ -130,45 +130,6 @@ grub_util_find_partition_start_os (const char *dev)
|
|||
* (grub_uint64_t) envec->de_SizeBlock) >> 7;
|
||||
}
|
||||
|
||||
char *
|
||||
grub_make_system_path_relative_to_its_root (const char *path)
|
||||
{
|
||||
char *p;
|
||||
unsigned char *tmp;
|
||||
char *ret;
|
||||
BPTR lck;
|
||||
|
||||
if (path[0] == '/' && path[1] == '/' && path[2] == ':')
|
||||
return xstrdup (path);
|
||||
|
||||
tmp = xmalloc (2048);
|
||||
|
||||
lck = Lock ((const unsigned char *) path, SHARED_LOCK);
|
||||
if (!lck || !NameFromLock (lck, tmp, 2040))
|
||||
{
|
||||
free (tmp);
|
||||
tmp = (unsigned char *) xstrdup (path);
|
||||
}
|
||||
if (lck)
|
||||
UnLock (lck);
|
||||
p = strchr ((char *) tmp, ':');
|
||||
if (!p)
|
||||
return (char *) tmp;
|
||||
if (p[1] == '/' || p[1] == '\0')
|
||||
{
|
||||
ret = xstrdup (p + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = xmalloc (strlen (p + 1) + 2);
|
||||
ret[0] = '/';
|
||||
strcpy (ret + 1, p + 1);
|
||||
}
|
||||
|
||||
free (tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char **
|
||||
grub_guess_root_devices (const char *path)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue