* grub-core/osdep/aros/getroot.c: Change to //: prefix as discussed

with AROS devs.
	* grub-core/osdep/aros/hostdisk.c: Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-10-10 09:21:33 +02:00
parent 71c1d67a34
commit 2fe53a22b8
3 changed files with 53 additions and 57 deletions

View file

@ -1,3 +1,9 @@
2013-10-10 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/osdep/aros/getroot.c: Change to //: prefix as discussed
with AROS devs.
* grub-core/osdep/aros/hostdisk.c: Likewise.
2013-10-10 Vladimir Serbinenko <phcoder@gmail.com> 2013-10-10 Vladimir Serbinenko <phcoder@gmail.com>
Avoid including hostfile.h when not necessarry as it pulls Avoid including hostfile.h when not necessarry as it pulls

View file

@ -40,35 +40,27 @@ grub_util_part_to_disk (const char *dev,
struct stat *st __attribute__ ((unused)), struct stat *st __attribute__ ((unused)),
int *is_part) int *is_part)
{ {
const char *p; const char *dname;
char *dname;
char *ret; char *ret;
struct DosList *dl; struct DosList *dl;
struct DeviceNode *dn; struct DeviceNode *dn;
struct FileSysStartupMsg *fm; struct FileSysStartupMsg *fm;
struct DosEnvec *envec; struct DosEnvec *envec;
if (!dev[0]) if (dev[0] != '/' || dev[1] != '/' || dev[2] != ':')
return xstrdup (dev); return xstrdup (dev);
p = dev + strlen (dev) - 1; dname = dev + 3;
if (*p != ':')
return xstrdup (dev);
dname = xmalloc (p - dev + 1);
memcpy (dname, dev, p - dev);
dname[p - dev] = '\0';
dl = LockDosList(LDF_READ); dl = LockDosList(LDF_READ);
if (!dl) if (!dl)
{ {
free (dname);
return xstrdup (dev); return xstrdup (dev);
} }
dn = (struct DeviceNode *) FindDosEntry (dl, (unsigned char *) dname, dn = (struct DeviceNode *) FindDosEntry (dl, (unsigned char *) dname,
LDF_DEVICES); LDF_DEVICES);
UnLockDosList (LDF_READ); UnLockDosList (LDF_READ);
free (dname);
if (!dn) if (!dn)
return xstrdup (dev); return xstrdup (dev);
@ -80,7 +72,7 @@ grub_util_part_to_disk (const char *dev,
*is_part = 1; *is_part = 1;
ret = xasprintf ("%s/%lx/%lx:", fm->fssm_Device, fm->fssm_Unit, (unsigned long) fm->fssm_Flags); ret = xasprintf ("//:%s/%lx/%lx", fm->fssm_Device, fm->fssm_Unit, (unsigned long) fm->fssm_Flags);
return ret; return ret;
} }
@ -108,32 +100,24 @@ grub_util_get_grub_dev_os (const char *os_dev __attribute__ ((unused)))
grub_disk_addr_t grub_disk_addr_t
grub_util_find_partition_start_os (const char *dev) grub_util_find_partition_start_os (const char *dev)
{ {
const char *p; const char *dname;
char *dname;
struct DosList *dl; struct DosList *dl;
struct DeviceNode *dn; struct DeviceNode *dn;
struct FileSysStartupMsg *fm; struct FileSysStartupMsg *fm;
struct DosEnvec *envec; struct DosEnvec *envec;
if (!dev[0]) if (dev[0] != '/' || dev[1] != '/' || dev[2] != ':')
return 0; return 0;
p = dev + strlen (dev) - 1; dname = dev + 3;
if (*p != ':')
return 0;
dname = xmalloc (p - dev + 1);
memcpy (dname, dev, p - dev);
dname[p - dev] = '\0';
dl = LockDosList(LDF_READ); dl = LockDosList(LDF_READ);
if (!dl) if (!dl)
{ {
free (dname);
return 0; return 0;
} }
dn = (struct DeviceNode *) FindDosEntry (dl, (unsigned char *) dname, dn = (struct DeviceNode *) FindDosEntry (dl, (unsigned char *) dname,
LDF_DEVICES); LDF_DEVICES);
UnLockDosList (LDF_READ); UnLockDosList (LDF_READ);
free (dname);
if (!dn) if (!dn)
return 0; return 0;
@ -150,9 +134,15 @@ char *
grub_make_system_path_relative_to_its_root (const char *path) grub_make_system_path_relative_to_its_root (const char *path)
{ {
char *p; char *p;
unsigned char *tmp = xmalloc (2048); unsigned char *tmp;
char *ret; char *ret;
BPTR lck; BPTR lck;
if (path[0] == '/' && path[1] == '/' && path[2] == ':')
return xstrdup (path);
tmp = xmalloc (2048);
lck = Lock ((const unsigned char *) path, SHARED_LOCK); lck = Lock ((const unsigned char *) path, SHARED_LOCK);
if (!lck || !NameFromLock (lck, tmp, 2040)) if (!lck || !NameFromLock (lck, tmp, 2040))
{ {
@ -201,12 +191,15 @@ grub_guess_root_devices (const char *path)
grub_util_info ("Info(%s) failed", path); grub_util_info ("Info(%s) failed", path);
os_dev = xmalloc (2 * sizeof (os_dev[0])); os_dev = xmalloc (2 * sizeof (os_dev[0]));
sz = strlen (path); sz = strlen (path);
os_dev[0] = xmalloc (sz + 2); os_dev[0] = xmalloc (sz + 5);
memcpy (os_dev[0], path, sz); os_dev[0][0] = '/';
os_dev[0][sz] = ':'; os_dev[0][1] = '/';
os_dev[0][sz+1] = '\0'; os_dev[0][2] = ':';
p = strchr (os_dev[0], ':'); memcpy (os_dev[0] + 3, path, sz);
*(p + 1) = '\0'; os_dev[0][sz + 3] = ':';
os_dev[0][sz + 4] = '\0';
p = strchr (os_dev[0] + 3, ':');
*p = '\0';
os_dev[1] = NULL; os_dev[1] = NULL;
return os_dev; return os_dev;
} }
@ -240,10 +233,12 @@ grub_guess_root_devices (const char *path)
os_dev = xmalloc (2 * sizeof (os_dev[0])); os_dev = xmalloc (2 * sizeof (os_dev[0]));
sz = strlen (nm); sz = strlen (nm);
os_dev[0] = xmalloc (sz + 2); os_dev[0] = xmalloc (sz + 4);
memcpy (os_dev[0], nm, sz); os_dev[0][0] = '/';
os_dev[0][sz] = ':'; os_dev[0][1] = '/';
os_dev[0][sz+1] = '\0'; os_dev[0][2] = ':';
memcpy (os_dev[0] + 3, nm, sz);
os_dev[0][sz+3] = '\0';
os_dev[1] = NULL; os_dev[1] = NULL;
UnLockDosList (LDF_READ | LDF_DEVICES); UnLockDosList (LDF_READ | LDF_DEVICES);
@ -254,17 +249,18 @@ grub_guess_root_devices (const char *path)
int int
grub_util_biosdisk_is_floppy (grub_disk_t disk) grub_util_biosdisk_is_floppy (grub_disk_t disk)
{ {
const char *dname, *p; const char *dname;
dname = grub_util_biosdisk_get_osdev (disk); dname = grub_util_biosdisk_get_osdev (disk);
p = strchr (dname, ':'); if (dname[0] != '/' || dname[1] != '/' || dname[2] != ':')
if (!p || p[1])
return 0; return 0;
dname += 3;
if (strncmp (dname, TD_NAME, sizeof (TD_NAME) - 1) == 0 if (strncmp (dname, TD_NAME, sizeof (TD_NAME) - 1) == 0
&& (TD_NAME[sizeof (TD_NAME) - 1] == '/' && (TD_NAME[sizeof (TD_NAME) - 1] == '/'
|| TD_NAME[sizeof (TD_NAME) - 1] == ':')) || TD_NAME[sizeof (TD_NAME) - 1] == '\0'))
return 1; return 1;
return 0; return 0;
} }

View file

@ -64,10 +64,8 @@ canonicalize_file_name (const char *path)
{ {
char *ret; char *ret;
BPTR lck; BPTR lck;
const char *p;
p = strchr (path, ':'); if (path[0] == '/' && path[1] == '/' && path[2] == ':')
if (p && !p[1])
return xstrdup (path); return xstrdup (path);
ret = xmalloc (2048); ret = xmalloc (2048);
@ -164,7 +162,8 @@ grub_util_fd_t
grub_util_fd_open (const char *dev, int flg) grub_util_fd_open (const char *dev, int flg)
{ {
grub_util_fd_t ret = xmalloc (sizeof (*ret)); grub_util_fd_t ret = xmalloc (sizeof (*ret));
const char *p, *p1, *p2; const char *p1, *p2;
const char *dname;
char *tmp; char *tmp;
IPTR unit = 0; IPTR unit = 0;
ULONG flags = 0; ULONG flags = 0;
@ -178,15 +177,7 @@ grub_util_fd_open (const char *dev, int flg)
ret->off = 0; ret->off = 0;
if (dev[0] == '\0') if (dev[0] != '/' || dev[1] != '/' || dev[2] != ':')
{
free (ret);
return NULL;
}
p = strchr (dev, ':');
if (!p || p[1])
{ {
ret->type = GRUB_UTIL_FD_FILE; ret->type = GRUB_UTIL_FD_FILE;
ret->fd = open (dev, flg); ret->fd = open (dev, flg);
@ -198,9 +189,9 @@ grub_util_fd_open (const char *dev, int flg)
return ret; return ret;
} }
p1 = strchr (dev, '/'); p1 = strchr (dev + 3, '/');
if (!p1) if (!p1)
p1 = p; p1 = dev + strlen (dev);
else else
{ {
unit = grub_strtoul (p1 + 1, (char **) &p2, 16); unit = grub_strtoul (p1 + 1, (char **) &p2, 16);
@ -223,15 +214,18 @@ grub_util_fd_open (const char *dev, int flg)
return NULL; return NULL;
} }
tmp = xmalloc (p1 - dev + 1); dname = dev + 3;
memcpy (tmp, dev, p1 - dev);
tmp[p1 - dev] = '\0';
ret->type = GRUB_UTIL_FD_DISK; ret->type = GRUB_UTIL_FD_DISK;
tmp = xmalloc (p1 - dname + 1);
memcpy (tmp, dname, p1 - dname);
tmp[p1 - dname] = '\0';
ret->is_floppy = (strcmp (tmp, TD_NAME) == 0); ret->is_floppy = (strcmp (tmp, TD_NAME) == 0);
ret->is_64 = 1; ret->is_64 = 1;
if (OpenDevice ((unsigned char *) tmp, unit, (struct IORequest *) ret->ioreq, flags)) if (OpenDevice ((unsigned char *) tmp, unit,
(struct IORequest *) ret->ioreq, flags))
{ {
free (tmp); free (tmp);
free (ret); free (ret);