Project

General

Profile

Submit #2872 ยป 0001-boot0cfg-use-getdevpath-instead-of-custom-function.patch

Anonymous, 12/23/2015 06:31 AM

View differences:

usr.sbin/boot0cfg/boot0cfg.c
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fstab.h>
#define MBRSIZE 512 /* master boot record size */
......
static int boot0version(const u_int8_t *);
static int boot0bs(const u_int8_t *);
static void stropt(const char *, int *, int *);
static char *mkrdev(const char *);
static int argtoi(const char *, int, int, int);
static void usage(void);
......
argv += optind;
if (argc != 1)
usage();
disk = mkrdev(*argv);
disk = getdevpath(*argv, 0);
if (!disk)
err(1, "cannot open disk %s", disk);
up = B_flag || d_arg != -1 || m_arg != -1 || o_flag || s_arg != -1
|| t_arg != -1;
......
}
/*
* Produce a device path for a "canonical" name, where appropriate.
*/
static char *
mkrdev(const char *fname)
{
char buf[MAXPATHLEN];
char *s;
if (!strchr(fname, '/')) {
snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname);
s = strdup(buf);
} else
s = strdup(fname);
if (s == NULL)
errx(1, "No more memory");
return s;
}
/*
* Convert and check an option argument.
*/
static int
    (1-1/1)