From a5b0365ab2778e0e0da3c5fd48390e159a405f82 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 8 Oct 2013 17:04:46 +0200 Subject: [PATCH] * grub-core/kern/emu/misc.c (canonicalize_file_name): Move to ... * grub-core/kern/emu/hostdisk_*.c (canonicalize_file_name): ... here. --- ChangeLog | 5 +++ grub-core/kern/emu/hostdisk_aros.c | 25 ++++++++++++ grub-core/kern/emu/hostdisk_unix.c | 15 +++++++ grub-core/kern/emu/hostdisk_windows.c | 16 ++++++++ grub-core/kern/emu/misc.c | 58 --------------------------- 5 files changed, 61 insertions(+), 58 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f2fa1504..70ff1c0f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-10-08 Vladimir Serbinenko + + * 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 * grub-core/kern/arm/misc.S: Remove leftover ARM and THUMB. diff --git a/grub-core/kern/emu/hostdisk_aros.c b/grub-core/kern/emu/hostdisk_aros.c index feb0ee120..b6a2de9ba 100644 --- a/grub-core/kern/emu/hostdisk_aros.c +++ b/grub-core/kern/emu/hostdisk_aros.c @@ -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, diff --git a/grub-core/kern/emu/hostdisk_unix.c b/grub-core/kern/emu/hostdisk_unix.c index 96b517e07..52572498b 100644 --- a/grub-core/kern/emu/hostdisk_unix.c +++ b/grub-core/kern/emu/hostdisk_unix.c @@ -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 diff --git a/grub-core/kern/emu/hostdisk_windows.c b/grub-core/kern/emu/hostdisk_windows.c index 39f944936..69353d6c5 100644 --- a/grub-core/kern/emu/hostdisk_windows.c +++ b/grub-core/kern/emu/hostdisk_windows.c @@ -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; +} diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c index 4dee33ae2..fe9673247 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c @@ -42,26 +42,6 @@ #include #include -#ifdef HAVE_SYS_PARAM_H -# include -#endif - -#ifdef HAVE_SYS_MOUNT_H -# include -#endif - -#ifdef HAVE_SYS_MNTTAB_H -# include /* Needed by sys/mnttab.h. */ -# include -#endif - -#ifdef __AROS__ -#include -#include -#include -#include -#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; -} -