Enable devname(3)
There is no support for a device name database yet, so this call is expected to be fairly slow. Change-Id: I73aa5f267e2b6921b7d3bbdcc4beac463931132c
This commit is contained in:
parent
32c9b6653b
commit
d266a94fea
6 changed files with 23 additions and 27 deletions
|
@ -75,7 +75,7 @@ char *secbuf;
|
|||
int badbases;
|
||||
int badsizes;
|
||||
int badorders;
|
||||
char *devname;
|
||||
char *dev_name;
|
||||
int nhead;
|
||||
int nsec;
|
||||
int ncyl = 1024;
|
||||
|
@ -161,9 +161,9 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (argn == argc)
|
||||
devname = DEFAULT_DEV;
|
||||
dev_name = DEFAULT_DEV;
|
||||
else if (argn == argc - 1)
|
||||
devname = argv[argn];
|
||||
dev_name = argv[argn];
|
||||
else
|
||||
usage();
|
||||
|
||||
|
@ -232,7 +232,7 @@ void getgeom(void)
|
|||
|
||||
if (override) return;
|
||||
|
||||
if ((fd= open(devname, O_RDONLY)) < 0) return;
|
||||
if ((fd= open(dev_name, O_RDONLY)) < 0) return;
|
||||
|
||||
r = ioctl(fd, DIOCGETP, &geom);
|
||||
close(fd);
|
||||
|
@ -242,21 +242,21 @@ void getgeom(void)
|
|||
nsec = geom.sectors;
|
||||
ncyl = geom.cylinders;
|
||||
|
||||
printf("Geometry of %s: %dx%dx%d\n", devname, ncyl, nhead, nsec);
|
||||
printf("Geometry of %s: %dx%dx%d\n", dev_name, ncyl, nhead, nsec);
|
||||
}
|
||||
|
||||
static int devfd;
|
||||
|
||||
void getboot(char *buffer)
|
||||
{
|
||||
devfd = open(devname, 2);
|
||||
devfd = open(dev_name, 2);
|
||||
if (devfd < 0) {
|
||||
printf("No write permission on %s\n", devname);
|
||||
printf("No write permission on %s\n", dev_name);
|
||||
readonly = 1;
|
||||
devfd = open(devname, 0);
|
||||
devfd = open(dev_name, 0);
|
||||
}
|
||||
if (devfd < 0) {
|
||||
printf("Cannot open device %s\n", devname);
|
||||
printf("Cannot open device %s\n", dev_name);
|
||||
exit(1);
|
||||
}
|
||||
if (read(devfd, buffer, SECSIZE) != SECSIZE) {
|
||||
|
@ -264,7 +264,7 @@ void getboot(char *buffer)
|
|||
exit(1);
|
||||
}
|
||||
if (* (unsigned short *) &buffer[510] != 0xAA55) {
|
||||
printf("Invalid boot sector on %s.\n", devname);
|
||||
printf("Invalid boot sector on %s.\n", dev_name);
|
||||
printf("Partition table reset and boot code installed.\n");
|
||||
memset(buffer, 0, 512);
|
||||
memcpy(buffer, bootstrap, sizeof(bootstrap));
|
||||
|
@ -514,8 +514,8 @@ int chk_table(void)
|
|||
printf(
|
||||
"Disk appears to have mis-specified number of heads or sectors.\n");
|
||||
printf("Try fdisk -h%d -s%d %s instead of\n",
|
||||
maxhead + 1, maxsec, devname);
|
||||
printf(" fdisk -h%d -s%d %s\n", nhead, nsec, devname);
|
||||
maxhead + 1, maxsec, dev_name);
|
||||
printf(" fdisk -h%d -s%d %s\n", nhead, nsec, dev_name);
|
||||
seenpart = 0;
|
||||
}
|
||||
} else {
|
||||
|
@ -695,12 +695,12 @@ void getboot(char *buffer)
|
|||
|
||||
segread(&sregs); /* get ds */
|
||||
|
||||
if (devname[1] != ':') {
|
||||
printf("Invalid drive %s\n", devname);
|
||||
if (dev_name[1] != ':') {
|
||||
printf("Invalid drive %s\n", dev_name);
|
||||
exit(1);
|
||||
}
|
||||
if (*devname >= 'a') *devname += 'A' - 'a';
|
||||
drivenum = (*devname - 'C') & 0xff;
|
||||
if (*dev_name >= 'a') *dev_name += 'A' - 'a';
|
||||
drivenum = (*dev_name - 'C') & 0xff;
|
||||
if (drivenum < 0 || drivenum > 7) {
|
||||
printf("Funny drive number %d\n", drivenum);
|
||||
exit(1);
|
||||
|
|
|
@ -272,12 +272,10 @@ int cgetustr(char *, const char *, char **);
|
|||
void csetexpandtc(int);
|
||||
|
||||
int daemon(int, int);
|
||||
#ifndef __minix
|
||||
int devname_r(dev_t, mode_t, char *, size_t);
|
||||
#ifndef __LIBC12_SOURCE__
|
||||
__aconst char *devname(dev_t, mode_t) __RENAME(__devname50);
|
||||
#endif
|
||||
#endif /* !__minix */
|
||||
|
||||
#define HN_DECIMAL 0x01
|
||||
#define HN_NOSPACE 0x02
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# closefrom.c confstr.c extattr.c getdevmajor.c \
|
||||
# pthread_atfork.c setdomainname.c sethostname.c setproctitle.c \
|
||||
# sysctl.c sysctlbyname.c sysctlgetmibinfo.c sysctlnametomib.c \
|
||||
# devname.c wait3.c
|
||||
# wait3.c
|
||||
|
||||
# To be ported
|
||||
# nlist.c nlist_aout.c nlist_coff.c nlist_ecoff.c nlist_elf32.c nlist_elf64.c
|
||||
|
@ -26,7 +26,7 @@
|
|||
SRCS+= _errno.c alarm.c alphasort.c arc4random.c assert.c basename.c clock.c \
|
||||
closedir.c \
|
||||
ctermid.c ctype_.c daemon.c \
|
||||
dehumanize_number.c dirname.c err.c errx.c \
|
||||
dehumanize_number.c devname.c dirname.c err.c errx.c \
|
||||
errlist.c errno.c execl.c execle.c execlp.c execv.c execvp.c \
|
||||
fmtcheck.c fmtmsg.c fnmatch.c fstab.c ftok.c \
|
||||
fts.c ftw.c getbsize.c getcap.c getcwd.c \
|
||||
|
|
|
@ -49,6 +49,7 @@ __RCSID("$NetBSD: devname.c,v 1.22 2012/06/03 21:42:46 joerg Exp $");
|
|||
__weak_alias(devname_r,_devname_r)
|
||||
#endif
|
||||
|
||||
#ifndef __minix
|
||||
static once_t db_opened = ONCE_INITIALIZER;
|
||||
static struct cdbr *db;
|
||||
static devmajor_t pts;
|
||||
|
@ -101,6 +102,7 @@ devname_ptslookup(dev_t dev, mode_t type, char *path, size_t len)
|
|||
return ERANGE;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
devname_fts(dev_t dev, mode_t type, char *path, size_t len)
|
||||
|
@ -140,6 +142,7 @@ devname_r(dev_t dev, mode_t type, char *path, size_t len)
|
|||
{
|
||||
int rv;
|
||||
|
||||
#ifndef __minix
|
||||
thr_once(&db_opened, devname_dbopen);
|
||||
|
||||
if (db != NULL) {
|
||||
|
@ -154,6 +157,7 @@ devname_r(dev_t dev, mode_t type, char *path, size_t len)
|
|||
|
||||
if (db != NULL)
|
||||
return ENOENT;
|
||||
#endif
|
||||
rv = devname_fts(dev, type, path, len);
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -267,11 +267,10 @@ int cgetustr(char *, const char *, char **);
|
|||
void csetexpandtc(int);
|
||||
|
||||
int daemon(int, int);
|
||||
#ifndef __minix
|
||||
int devname_r(dev_t, mode_t, char *, size_t);
|
||||
#if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE)
|
||||
__aconst char *devname(dev_t, mode_t) __RENAME(__devname50);
|
||||
#endif
|
||||
#endif /* !__minix */
|
||||
|
||||
#define HN_DECIMAL 0x01
|
||||
#define HN_NOSPACE 0x02
|
||||
|
|
|
@ -44,12 +44,7 @@ __RCSID("$NetBSD: stat.c,v 1.36 2011/09/22 20:23:56 apb Exp $");
|
|||
#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
|
||||
#define HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC 1
|
||||
#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1
|
||||
#ifdef __minix
|
||||
/* Not supported in Minix. */
|
||||
#define HAVE_DEVNAME 0
|
||||
#else /* __minix */
|
||||
#define HAVE_DEVNAME 1
|
||||
#endif /* __minx */
|
||||
#endif /* HAVE_NBTOOL_CONFIG_H */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
|
Loading…
Reference in a new issue