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 badbases;
|
||||||
int badsizes;
|
int badsizes;
|
||||||
int badorders;
|
int badorders;
|
||||||
char *devname;
|
char *dev_name;
|
||||||
int nhead;
|
int nhead;
|
||||||
int nsec;
|
int nsec;
|
||||||
int ncyl = 1024;
|
int ncyl = 1024;
|
||||||
|
@ -161,9 +161,9 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argn == argc)
|
if (argn == argc)
|
||||||
devname = DEFAULT_DEV;
|
dev_name = DEFAULT_DEV;
|
||||||
else if (argn == argc - 1)
|
else if (argn == argc - 1)
|
||||||
devname = argv[argn];
|
dev_name = argv[argn];
|
||||||
else
|
else
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ void getgeom(void)
|
||||||
|
|
||||||
if (override) return;
|
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);
|
r = ioctl(fd, DIOCGETP, &geom);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -242,21 +242,21 @@ void getgeom(void)
|
||||||
nsec = geom.sectors;
|
nsec = geom.sectors;
|
||||||
ncyl = geom.cylinders;
|
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;
|
static int devfd;
|
||||||
|
|
||||||
void getboot(char *buffer)
|
void getboot(char *buffer)
|
||||||
{
|
{
|
||||||
devfd = open(devname, 2);
|
devfd = open(dev_name, 2);
|
||||||
if (devfd < 0) {
|
if (devfd < 0) {
|
||||||
printf("No write permission on %s\n", devname);
|
printf("No write permission on %s\n", dev_name);
|
||||||
readonly = 1;
|
readonly = 1;
|
||||||
devfd = open(devname, 0);
|
devfd = open(dev_name, 0);
|
||||||
}
|
}
|
||||||
if (devfd < 0) {
|
if (devfd < 0) {
|
||||||
printf("Cannot open device %s\n", devname);
|
printf("Cannot open device %s\n", dev_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (read(devfd, buffer, SECSIZE) != SECSIZE) {
|
if (read(devfd, buffer, SECSIZE) != SECSIZE) {
|
||||||
|
@ -264,7 +264,7 @@ void getboot(char *buffer)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (* (unsigned short *) &buffer[510] != 0xAA55) {
|
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");
|
printf("Partition table reset and boot code installed.\n");
|
||||||
memset(buffer, 0, 512);
|
memset(buffer, 0, 512);
|
||||||
memcpy(buffer, bootstrap, sizeof(bootstrap));
|
memcpy(buffer, bootstrap, sizeof(bootstrap));
|
||||||
|
@ -514,8 +514,8 @@ int chk_table(void)
|
||||||
printf(
|
printf(
|
||||||
"Disk appears to have mis-specified number of heads or sectors.\n");
|
"Disk appears to have mis-specified number of heads or sectors.\n");
|
||||||
printf("Try fdisk -h%d -s%d %s instead of\n",
|
printf("Try fdisk -h%d -s%d %s instead of\n",
|
||||||
maxhead + 1, maxsec, devname);
|
maxhead + 1, maxsec, dev_name);
|
||||||
printf(" fdisk -h%d -s%d %s\n", nhead, nsec, devname);
|
printf(" fdisk -h%d -s%d %s\n", nhead, nsec, dev_name);
|
||||||
seenpart = 0;
|
seenpart = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -695,12 +695,12 @@ void getboot(char *buffer)
|
||||||
|
|
||||||
segread(&sregs); /* get ds */
|
segread(&sregs); /* get ds */
|
||||||
|
|
||||||
if (devname[1] != ':') {
|
if (dev_name[1] != ':') {
|
||||||
printf("Invalid drive %s\n", devname);
|
printf("Invalid drive %s\n", dev_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (*devname >= 'a') *devname += 'A' - 'a';
|
if (*dev_name >= 'a') *dev_name += 'A' - 'a';
|
||||||
drivenum = (*devname - 'C') & 0xff;
|
drivenum = (*dev_name - 'C') & 0xff;
|
||||||
if (drivenum < 0 || drivenum > 7) {
|
if (drivenum < 0 || drivenum > 7) {
|
||||||
printf("Funny drive number %d\n", drivenum);
|
printf("Funny drive number %d\n", drivenum);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -272,12 +272,10 @@ int cgetustr(char *, const char *, char **);
|
||||||
void csetexpandtc(int);
|
void csetexpandtc(int);
|
||||||
|
|
||||||
int daemon(int, int);
|
int daemon(int, int);
|
||||||
#ifndef __minix
|
|
||||||
int devname_r(dev_t, mode_t, char *, size_t);
|
int devname_r(dev_t, mode_t, char *, size_t);
|
||||||
#ifndef __LIBC12_SOURCE__
|
#ifndef __LIBC12_SOURCE__
|
||||||
__aconst char *devname(dev_t, mode_t) __RENAME(__devname50);
|
__aconst char *devname(dev_t, mode_t) __RENAME(__devname50);
|
||||||
#endif
|
#endif
|
||||||
#endif /* !__minix */
|
|
||||||
|
|
||||||
#define HN_DECIMAL 0x01
|
#define HN_DECIMAL 0x01
|
||||||
#define HN_NOSPACE 0x02
|
#define HN_NOSPACE 0x02
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# closefrom.c confstr.c extattr.c getdevmajor.c \
|
# closefrom.c confstr.c extattr.c getdevmajor.c \
|
||||||
# pthread_atfork.c setdomainname.c sethostname.c setproctitle.c \
|
# pthread_atfork.c setdomainname.c sethostname.c setproctitle.c \
|
||||||
# sysctl.c sysctlbyname.c sysctlgetmibinfo.c sysctlnametomib.c \
|
# sysctl.c sysctlbyname.c sysctlgetmibinfo.c sysctlnametomib.c \
|
||||||
# devname.c wait3.c
|
# wait3.c
|
||||||
|
|
||||||
# To be ported
|
# To be ported
|
||||||
# nlist.c nlist_aout.c nlist_coff.c nlist_ecoff.c nlist_elf32.c nlist_elf64.c
|
# 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 \
|
SRCS+= _errno.c alarm.c alphasort.c arc4random.c assert.c basename.c clock.c \
|
||||||
closedir.c \
|
closedir.c \
|
||||||
ctermid.c ctype_.c daemon.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 \
|
errlist.c errno.c execl.c execle.c execlp.c execv.c execvp.c \
|
||||||
fmtcheck.c fmtmsg.c fnmatch.c fstab.c ftok.c \
|
fmtcheck.c fmtmsg.c fnmatch.c fstab.c ftok.c \
|
||||||
fts.c ftw.c getbsize.c getcap.c getcwd.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)
|
__weak_alias(devname_r,_devname_r)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __minix
|
||||||
static once_t db_opened = ONCE_INITIALIZER;
|
static once_t db_opened = ONCE_INITIALIZER;
|
||||||
static struct cdbr *db;
|
static struct cdbr *db;
|
||||||
static devmajor_t pts;
|
static devmajor_t pts;
|
||||||
|
@ -101,6 +102,7 @@ devname_ptslookup(dev_t dev, mode_t type, char *path, size_t len)
|
||||||
return ERANGE;
|
return ERANGE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
devname_fts(dev_t dev, mode_t type, char *path, size_t len)
|
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;
|
int rv;
|
||||||
|
|
||||||
|
#ifndef __minix
|
||||||
thr_once(&db_opened, devname_dbopen);
|
thr_once(&db_opened, devname_dbopen);
|
||||||
|
|
||||||
if (db != NULL) {
|
if (db != NULL) {
|
||||||
|
@ -154,6 +157,7 @@ devname_r(dev_t dev, mode_t type, char *path, size_t len)
|
||||||
|
|
||||||
if (db != NULL)
|
if (db != NULL)
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
|
#endif
|
||||||
rv = devname_fts(dev, type, path, len);
|
rv = devname_fts(dev, type, path, len);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,11 +267,10 @@ int cgetustr(char *, const char *, char **);
|
||||||
void csetexpandtc(int);
|
void csetexpandtc(int);
|
||||||
|
|
||||||
int daemon(int, int);
|
int daemon(int, int);
|
||||||
#ifndef __minix
|
int devname_r(dev_t, mode_t, char *, size_t);
|
||||||
#if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE)
|
#if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE)
|
||||||
__aconst char *devname(dev_t, mode_t) __RENAME(__devname50);
|
__aconst char *devname(dev_t, mode_t) __RENAME(__devname50);
|
||||||
#endif
|
#endif
|
||||||
#endif /* !__minix */
|
|
||||||
|
|
||||||
#define HN_DECIMAL 0x01
|
#define HN_DECIMAL 0x01
|
||||||
#define HN_NOSPACE 0x02
|
#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_BIRTHTIME 1
|
||||||
#define HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC 1
|
#define HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC 1
|
||||||
#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1
|
#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1
|
||||||
#ifdef __minix
|
|
||||||
/* Not supported in Minix. */
|
|
||||||
#define HAVE_DEVNAME 0
|
|
||||||
#else /* __minix */
|
|
||||||
#define HAVE_DEVNAME 1
|
#define HAVE_DEVNAME 1
|
||||||
#endif /* __minx */
|
|
||||||
#endif /* HAVE_NBTOOL_CONFIG_H */
|
#endif /* HAVE_NBTOOL_CONFIG_H */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
Loading…
Reference in a new issue