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:
Vladimir 'phcoder' Serbinenko 2013-10-19 16:21:08 +02:00
parent 31de274d29
commit a4012f0764
9 changed files with 358 additions and 235 deletions

View file

@ -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)
{