* grub-core/kern/emu/misc.c (canonicalize_file_name): Move to ...

* grub-core/kern/emu/hostdisk_*.c (canonicalize_file_name): ... here.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-10-08 17:04:46 +02:00
parent 29072e994e
commit a5b0365ab2
5 changed files with 61 additions and 58 deletions

View File

@ -1,3 +1,8 @@
2013-10-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/emu/misc.c (canonicalize_file_name): Move to ...
* grub-core/kern/emu/hostdisk_*.c (canonicalize_file_name): ... here.
2013-10-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/arm/misc.S: Remove leftover ARM and THUMB.

View File

@ -59,6 +59,31 @@
static ULONG *bounce;
char *
canonicalize_file_name (const char *path)
{
char *ret;
BPTR lck;
const char *p;
p = strchr (path, ':');
if (p && !p[1])
return xstrdup (path);
ret = xmalloc (2048);
lck = Lock ((const unsigned char *) path, SHARED_LOCK);
if (!lck || !NameFromLock (lck, (unsigned char *) ret, 2040))
{
free (ret);
ret = xstrdup (path);
}
if (lck)
UnLock (lck);
return ret;
}
static grub_uint64_t
grub_util_get_fd_size_volume (grub_util_fd_t fd __attribute__ ((unused)),
const char *dev,

View File

@ -190,4 +190,19 @@ grub_util_fd_close (grub_util_fd_t fd)
close (fd);
}
char *
canonicalize_file_name (const char *path)
{
#if defined (PATH_MAX)
char *ret;
ret = xmalloc (PATH_MAX);
if (!realpath (path, ret))
return NULL;
return ret;
#else
return realpath (path, NULL);
#endif
}
#endif

View File

@ -239,3 +239,19 @@ grub_util_fd_strerror (void)
#error "Unsupported TCHAR size"
#endif
}
char *
canonicalize_file_name (const char *path)
{
char *ret;
ret = xmalloc (PATH_MAX);
#ifndef __CYGWIN__
if (!_fullpath (ret, path, PATH_MAX))
return NULL;
#else
if (!realpath (path, ret))
return NULL;
#endif
return ret;
}

View File

@ -42,26 +42,6 @@
#include <grub/time.h>
#include <grub/emu/misc.h>
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
#ifdef HAVE_SYS_MOUNT_H
# include <sys/mount.h>
#endif
#ifdef HAVE_SYS_MNTTAB_H
# include <stdio.h> /* Needed by sys/mnttab.h. */
# include <sys/mnttab.h>
#endif
#ifdef __AROS__
#include <dos/dos.h>
#include <dos/filesystem.h>
#include <dos/exall.h>
#include <proto/dos.h>
#endif
int verbosity;
void
@ -196,41 +176,3 @@ int fsync (int fno __attribute__ ((unused)))
}
#endif
char *
canonicalize_file_name (const char *path)
{
char *ret;
#ifdef __AROS__
BPTR lck;
const char *p;
p = strchr (path, ':');
if (p && !p[1])
return xstrdup (path);
ret = xmalloc (2048);
lck = Lock ((const unsigned char *) path, SHARED_LOCK);
if (!lck || !NameFromLock (lck, (unsigned char *) ret, 2040))
{
free (ret);
ret = xstrdup (path);
}
if (lck)
UnLock (lck);
#elif defined (__MINGW32__)
ret = xmalloc (PATH_MAX);
if (!_fullpath (ret, path, PATH_MAX))
return NULL;
#elif defined (PATH_MAX)
ret = xmalloc (PATH_MAX);
if (!realpath (path, ret))
return NULL;
#else
ret = realpath (path, NULL);
#endif
return ret;
}