mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-22 15:22:39 +00:00
* 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:
1 parent
29072e994e
commit
a5b0365ab2
5 files changed
+61
-58
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user