/* ofpath.c - calculate OpenFirmware path names given an OS device */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OFPATH_STANDALONE
#endif
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <malloc.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#ifdef OFPATH_STANDALONE
void
{
exit (1);
}
#define _(x) x
#endif
static void
{
{
if (*end != '/')
{
end--;
continue;
}
*end = '\0';
break;
}
}
static void
{
while (*end == '\n')
*end-- = '\0';
}
static int
{
while (1)
{
int fd;
#if 0
#endif
if (fd < 0)
{
{
grub_util_info (_("'obppath' not found in parent dirs of %s,"
" no IEEE1275 name discovery"),
free (sysfs_path);
return 1;
}
continue;
}
break;
}
free (sysfs_path);
return 0;
}
static void
char *sysfs_path, int sysfs_path_len)
{
}
static const char *
trailing_digits (const char *p)
{
const char *end;
while (end >= p)
{
break;
end--;
}
return end + 1;
}
static int
{
const char *digit_string;
return 1;
if (*digit_string == '\0')
{
}
else
{
int part;
}
return 0;
}
static char *
get_basename(char *p)
{
char *ret = p;
while (*p)
{
if (*p == '/')
ret = p + 1;
p++;
}
return ret;
}
static int
const char *device,
const char *devicenode)
{
char *sysfs_path, *p;
int ret;
p = get_basename (sysfs_path);
free (sysfs_path);
return ret;
}
static int
const char *devicenode)
{
char *sysfs_path, *p;
int ret;
p = get_basename (sysfs_path);
free (sysfs_path);
return ret;
}
static int
{
char *buf;
if (fd < 0)
if (err < 0)
{
return 1;
}
return 0;
}
static void
{
char *p, *q, *path;
int fd;
if (!ed)
return;
/* SAS devices are identified using disk@$PHY_ID */
p = strdup (sysfs_path);
q = ed;
while (*q && *q != '/')
q++;
*q = '\0';
if (fd < 0)
free (p);
}
static int
const char *devicenode)
{
int ret;
p = get_basename (sysfs_path);
if (vendor_is_ATA(sysfs_path))
{
free (sysfs_path);
return ret;
}
free (sysfs_path);
if (ret)
return 1;
disk_name = "sd";
else
disk_name = "disk";
if (*digit_string == '\0')
{
}
else
{
int part;
}
return 0;
}
static char *
strip_trailing_digits (const char *p)
{
{
break;
*end-- = '\0';
}
return new;
}
char *
{
int ret;
if (! name_buf)
else if (device[0] == 's'
/* All the models I've seen have a devalias "floppy".
New models have no floppy at all. */
{
ret = 0;
}
else
{
free (devicenode);
return NULL;
}
free (devicenode);
if (ret)
{
return NULL;
}
return ofpath;
}
#ifdef OFPATH_STANDALONE
{
char *of_path;
if (argc != 2)
{
return 1;
}
return 0;
}
#endif