Second half of the dev_t cleanup.

The big lines are:
	NODEV -> NULL
	NOUDEV -> NODEV
	udev_t -> dev_t
	udev2dev() -> findcdev()

Various minor adjustments including handling of userland access to kernel
space struct cdev etc.
This commit is contained in:
phk 2004-06-17 17:16:53 +00:00
parent 9acfe1e733
commit 40dd98a3bd
73 changed files with 186 additions and 205 deletions

View File

@ -251,7 +251,7 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
"can't read tty at %x", sess.s_ttyp);
return (-1);
}
kp->ki_tdev = tty.t_dev;
kp->ki_tdev = tty.t_dev; /* XXX: wrong */
if (tty.t_pgrp != NULL) {
if (KREAD(kd, (u_long)tty.t_pgrp, &pgrp)) {
_kvm_err(kd, kd->program,

View File

@ -1035,7 +1035,7 @@ targclone(void *arg, char *name, int namelen, struct cdev **dev)
{
int u;
if (*dev != NODEV)
if (*dev != NULL)
return;
if (dev_stdclone(name, NULL, "targ", &u) != 1)
return;

View File

@ -87,7 +87,7 @@ typedef unsigned long long u_quad_t;
typedef unsigned long long u_quad_t;
#endif
#else
#define cdev_t udev_t
#define cdev_t dev_t
#endif
#ifdef __CYGWIN32__

View File

@ -186,7 +186,7 @@ static void coda_fbsd_clone(arg, name, namelen, dev)
{
int u;
if (*dev != NODEV)
if (*dev != NULL)
return;
if (dev_stdclone(name,NULL,"cfs",&u) != 1)
return;

View File

@ -212,7 +212,7 @@ venus_open(void *mdp, CodaFid *fid, int flag,
error = coda_call(mdp, Isize, &Osize, (char *)inp);
if (!error) {
*dev = udev2dev(outp->dev);
*dev = findcdev(outp->dev);
*inode = outp->inode;
}

View File

@ -1083,13 +1083,13 @@ freebsd32_sendfile(struct thread *td, struct freebsd32_sendfile_args *uap)
}
struct stat32 {
udev_t st_dev;
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
udev_t st_rdev;
dev_t st_rdev;
struct timespec32 st_atimespec;
struct timespec32 st_mtimespec;
struct timespec32 st_ctimespec;

View File

@ -76,7 +76,7 @@ newstat_copyout(struct stat *buf, void *ubuf)
* in FreeBSD but block devices under Linux.
*/
if (S_ISCHR(tbuf.st_mode) &&
(dev = udev2dev(buf->st_rdev)) != NODEV) {
(dev = findcdev(buf->st_rdev)) != NULL) {
cdevsw = devsw(dev);
if (cdevsw != NULL && (cdevsw->d_flags & D_DISK)) {
tbuf.st_mode &= ~S_IFMT;
@ -365,8 +365,8 @@ linux_ustat(struct thread *td, struct linux_ustat_args *args)
* struct cdev *returned from previous syscalls. Just return a bzeroed
* ustat in that case.
*/
dev = udev2dev(makeudev(args->dev >> 8, args->dev & 0xFF));
if (dev != NODEV && vfinddev(dev, &vp)) {
dev = findcdev(makedev(args->dev >> 8, args->dev & 0xFF));
if (dev != NULL && vfinddev(dev, &vp)) {
if (vp->v_mount == NULL)
return (EINVAL);
#ifdef MAC
@ -414,7 +414,7 @@ stat64_copyout(struct stat *buf, void *ubuf)
* in FreeBSD but block devices under Linux.
*/
if (S_ISCHR(lbuf.st_mode) &&
(dev = udev2dev(buf->st_rdev)) != NODEV) {
(dev = findcdev(buf->st_rdev)) != NULL) {
cdevsw = devsw(dev);
if (cdevsw != NULL && (cdevsw->d_flags & D_DISK)) {
lbuf.st_mode &= ~S_IFMT;

View File

@ -67,7 +67,7 @@ struct sockaddr_un *
svr4_find_socket(td, fp, dev, ino)
struct thread *td;
struct file *fp;
udev_t dev;
dev_t dev;
ino_t ino;
{
struct svr4_sockcache_entry *e;

View File

@ -49,7 +49,7 @@ struct svr4_sockaddr_in {
};
struct sockaddr_un *svr4_find_socket(struct thread *, struct file *,
udev_t, ino_t);
dev_t, ino_t);
void svr4_delete_socket(struct proc *, struct file *);
int svr4_add_socket(struct thread *, const char *, struct stat *);
@ -57,7 +57,7 @@ struct svr4_sockcache_entry {
struct proc *p; /* Process for the socket */
void *cookie; /* Internal cookie used for matching */
struct sockaddr_un sock;/* Pathname for the socket */
udev_t dev; /* Device where the socket lives on */
dev_t dev; /* Device where the socket lives on */
ino_t ino; /* Inode where the socket lives on */
TAILQ_ENTRY(svr4_sockcache_entry) entries;
};

View File

@ -1873,7 +1873,7 @@ svr4_do_putmsg(td, uap, fp)
}
else {
/* Maybe we've been given a device/inode pair */
udev_t *dev = SVR4_ADDROF(&sc);
dev_t *dev = SVR4_ADDROF(&sc);
ino_t *ino = (ino_t *) &dev[1];
skp = svr4_find_socket(td, fp, *dev, *ino);
if (skp == NULL) {

View File

@ -68,14 +68,14 @@ typedef struct timespec svr4_timestruc_t;
#define svr4_omakedev(x,y) ((svr4_o_dev_t)((((x) << 8) & 0x7f00) | \
(((y) << 0) & 0x00ff)))
#define svr4_to_bsd_odev_t(d) makeudev(svr4_omajor(d), svr4_ominor(d))
#define svr4_to_bsd_odev_t(d) makedev(svr4_omajor(d), svr4_ominor(d))
#define bsd_to_svr4_odev_t(d) svr4_omakedev(umajor(d), uminor(d))
#define svr4_major(x) ((int32_t)((((x) & 0xfffc0000) >> 18)))
#define svr4_minor(x) ((int32_t)((((x) & 0x0003ffff) >> 0)))
#define svr4_makedev(x,y) ((svr4_dev_t)((((x) << 18) & 0xfffc0000) | \
(((y) << 0) & 0x0003ffff)))
#define svr4_to_bsd_dev_t(d) makeudev(svr4_major(d), svr4_minor(d))
#define svr4_to_bsd_dev_t(d) makedev(svr4_major(d), svr4_minor(d))
#define bsd_to_svr4_dev_t(d) svr4_makedev(umajor(d), uminor(d))
#endif /* !_SVR4_TYPES_H_ */

View File

@ -2657,13 +2657,13 @@ static int cp_modevent (module_t mod, int type, void *unused)
struct cdevsw *cdsw;
#if __FreeBSD_version >= 502103
dev = udev2dev (makeudev(CDEV_MAJOR, 0));
dev = findcdev (makedev(CDEV_MAJOR, 0));
#else
dev = makedev (CDEV_MAJOR, 0);
#endif
switch (type) {
case MOD_LOAD:
if (dev != NODEV &&
if (dev != NULL &&
(cdsw = devsw (dev)) &&
cdsw->d_maj == CDEV_MAJOR) {
printf ("Tau-PCI driver is already in system\n");

View File

@ -2629,13 +2629,13 @@ static int ct_modevent (module_t mod, int type, void *unused)
struct cdevsw *cdsw;
#if __FreeBSD_version >= 502103
dev = udev2dev (makeudev(CDEV_MAJOR, 0));
dev = findcdev (makedev(CDEV_MAJOR, 0));
#else
dev = makedev (CDEV_MAJOR, 0);
#endif
switch (type) {
case MOD_LOAD:
if (dev != NODEV &&
if (dev != NULL &&
(cdsw = devsw (dev)) &&
cdsw->d_maj == CDEV_MAJOR) {
printf ("Tau-ISA driver is already in system\n");

View File

@ -3177,13 +3177,13 @@ static int cx_modevent (module_t mod, int type, void *unused)
struct cdevsw *cdsw;
#if __FreeBSD_version >= 502103
dev = udev2dev (makeudev(CDEV_MAJOR, 0));
dev = findcdev (makedev(CDEV_MAJOR, 0));
#else
dev = makedev (CDEV_MAJOR, 0);
#endif
switch (type) {
case MOD_LOAD:
if (dev != NODEV &&
if (dev != NULL &&
(cdsw = devsw (dev)) &&
cdsw->d_maj == CDEV_MAJOR) {
printf ("Sigma driver is already in system\n");

View File

@ -162,7 +162,7 @@ __FBSDID("$FreeBSD$");
#define MINOR_MAGIC_MASK (CALLOUT_MASK | CONTROL_MASK)
/*
* Not all of the magic is parametrized in the following macros. 16 and
* 0xff are related to the bitfields in a udev_t. CY_MAX_PORTS must be
* 0xff are related to the bitfields in a dev_t. CY_MAX_PORTS must be
* ((0xff & ~MINOR_MAGIC_MASK) + 1) for things to work.
*/
#define MINOR_TO_UNIT(mynor) (((mynor) >> 16) * CY_MAX_PORTS \

View File

@ -598,7 +598,7 @@ dcons_modevent(module_t mode, int type, void *data)
#if CONS_NODEV
gdb_arg = NULL;
#else
gdbdev = NODEV;
gdbdev = NULL;
#endif
#endif
#if __FreeBSD_version >= 500000

View File

@ -1017,7 +1017,7 @@ digi_loadmoduledata(struct digi_softc *sc)
modfile = malloc(modlen + 6, M_TEMP, M_WAITOK);
snprintf(modfile, modlen + 6, "digi_%s", sc->module);
if ((res = linker_reference_module(modfile, NULL, &lf)) != 0) {
if (res == ENOENT && rootdev == NODEV)
if (res == ENOENT && rootdev == NULL)
printf("%s: Failed to autoload module: No filesystem\n",
modfile);
else

View File

@ -848,7 +848,7 @@ fwdev_clone(void *arg, char *name, int namelen, struct cdev **dev)
int devflag[NDEVTYPE] = {0, FWMEM_FLAG};
int i, unit = 0, sub = 0;
if (*dev != NODEV)
if (*dev != NULL)
return;
for (i = 0; i < NDEVTYPE; i++)

View File

@ -234,13 +234,13 @@ led_create(led_t *func, void *priv, char const *name)
sb = sbuf_new(NULL, NULL, SPECNAMELEN, SBUF_FIXEDLEN);
if (sb == NULL)
return (NODEV);
return (NULL);
sbuf_cpy(sb, "led/");
sbuf_cat(sb, name);
sbuf_finish(sb);
if (sbuf_overflowed(sb)) {
sbuf_delete(sb);
return (NODEV);
return (NULL);
}
sc = malloc(sizeof *sc, M_LED, M_WAITOK | M_ZERO);

View File

@ -100,7 +100,7 @@ nmdm_clone(void *arg, char *name, int nameen, struct cdev **dev)
char *p;
struct cdev *d1, *d2;
if (*dev != NODEV)
if (*dev != NULL)
return;
if (strcmp(name, "nmdm") == 0) {
p = NULL;

View File

@ -406,7 +406,7 @@ snpopen(dev, flag, mode, td)
* snp_tty == NULL is for inactive snoop devices.
*/
snp->snp_tty = NULL;
snp->snp_target = NODEV;
snp->snp_target = NULL;
LIST_INSERT_HEAD(&snp_sclist, snp, snp_list);
return (0);
@ -439,7 +439,7 @@ snp_detach(snp)
printf("snp%d: bad attached tty data\n", snp->snp_unit);
snp->snp_tty = NULL;
snp->snp_target = NODEV;
snp->snp_target = NULL;
detach_notty:
selwakeuppri(&snp->snp_sel, PZERO + 1);
@ -500,8 +500,8 @@ snpioctl(dev, cmd, data, flags, td)
snp = dev->si_drv1;
switch (cmd) {
case SNPSTTY:
tdev = udev2dev(*((udev_t *)data));
if (tdev == NODEV)
tdev = findcdev(*((dev_t *)data));
if (tdev == NULL)
return (snp_down(snp));
tp = snpdevtotty(tdev);
@ -512,7 +512,7 @@ snpioctl(dev, cmd, data, flags, td)
s = spltty();
if (snp->snp_target == NODEV) {
if (snp->snp_target == NULL) {
tpo = snp->snp_tty;
if (tpo)
tpo->t_state &= ~TS_SNOOP;
@ -540,7 +540,7 @@ snpioctl(dev, cmd, data, flags, td)
* SNPGTTY happy, else we can't know what is device
* major/minor for tty.
*/
*((udev_t *)data) = dev2udev(snp->snp_target);
*((dev_t *)data) = dev2udev(snp->snp_target);
break;
case FIONBIO:
@ -609,7 +609,7 @@ snp_clone(arg, name, namelen, dev)
{
int u, i;
if (*dev != NODEV)
if (*dev != NULL)
return;
if (dev_stdclone(name, NULL, "snp", &u) != 1)
return;

View File

@ -1123,7 +1123,7 @@ dsp_clone(void *arg, char *name, int namelen, struct cdev **dev)
int devtypes[3] = {SND_DEV_DSP, SND_DEV_DSP16, SND_DEV_AUDIO};
char *devnames[3] = {"dsp", "dspW", "audio"};
if (*dev != NODEV)
if (*dev != NULL)
return;
if (pcm_devclass == NULL)
return;

View File

@ -483,7 +483,7 @@ mixer_clone(void *arg, char *name, int namelen, struct cdev **dev)
{
struct snddev_info *sd;
if (*dev != NODEV)
if (*dev != NULL)
return;
if (strcmp(name, "mixer") == 0) {
sd = devclass_get_softc(pcm_devclass, snd_unit);

View File

@ -2622,7 +2622,7 @@ sc_change_cursor_shape(scr_stat *scp, int flags, int base, int height)
}
for (i = sc->first_vty; i < sc->first_vty + sc->vtys; ++i) {
if ((dev = SC_DEV(sc, i)) == NODEV)
if ((dev = SC_DEV(sc, i)) == NULL)
continue;
if ((scp = sc_get_stat(dev)) == NULL)
continue;

View File

@ -522,7 +522,7 @@ vinum_clone(void *arg, char *name, int namelen, struct cdev ** dev)
struct volume *vol;
int i;
if (*dev != NODEV)
if (*dev != NULL)
return;
if (strncmp(name, "vinum/", sizeof("vinum/") - 1) != 0)
return;

View File

@ -476,7 +476,7 @@ get_empty_drive(void)
bzero(drive, sizeof(struct drive));
drive->driveno = driveno; /* put number in structure */
drive->flags |= VF_NEWBORN; /* newly born drive */
drive->dev = NODEV;
drive->dev = NULL;
strcpy(drive->devicename, "unknown"); /* and make the name ``unknown'' */
return driveno; /* return the index */
}
@ -595,7 +595,7 @@ free_drive(struct drive *drive)
close_locked_drive(drive); /* close it */
if (drive->freelist)
Free(drive->freelist);
if (drive->dev != NODEV)
if (drive->dev != NULL)
dev_rel(drive->dev);
bzero(drive, sizeof(struct drive)); /* this also sets drive_unallocated */
unlockdrive(drive);

View File

@ -56,7 +56,7 @@ open_drive(struct drive *drive, struct thread *td, int verbose)
return EBUSY; /* don't do it again */
drive->dev = getdiskbyname(drive->devicename);
if (drive->dev == NODEV) /* didn't find anything */
if (drive->dev == NULL) /* didn't find anything */
return ENOENT;
dev_ref(drive->dev);

View File

@ -52,7 +52,7 @@ typedef struct {
uid_t iso_uid; /* owner user id */
gid_t iso_gid; /* owner group id */
short iso_links; /* links of file */
udev_t iso_rdev; /* Major/Minor number for special */
dev_t iso_rdev; /* Major/Minor number for special */
} ISO_RRIP_INODE;

View File

@ -413,9 +413,9 @@ cd9660_rrip_device(p,ana)
low = isonum_733(p->dev_t_low);
if (high == 0)
ana->inop->inode.iso_rdev = makeudev(umajor(low), uminor(low));
ana->inop->inode.iso_rdev = makedev(umajor(low), uminor(low));
else
ana->inop->inode.iso_rdev = makeudev(high, uminor(low));
ana->inop->inode.iso_rdev = makedev(high, uminor(low));
ana->fields &= ~ISO_SUSP_DEVICE;
return ISO_SUSP_DEVICE;
}

View File

@ -87,7 +87,7 @@ typedef unsigned long long u_quad_t;
typedef unsigned long long u_quad_t;
#endif
#else
#define cdev_t udev_t
#define cdev_t dev_t
#endif
#ifdef __CYGWIN32__

View File

@ -186,7 +186,7 @@ static void coda_fbsd_clone(arg, name, namelen, dev)
{
int u;
if (*dev != NODEV)
if (*dev != NULL)
return;
if (dev_stdclone(name,NULL,"cfs",&u) != 1)
return;

View File

@ -212,7 +212,7 @@ venus_open(void *mdp, CodaFid *fid, int flag,
error = coda_call(mdp, Isize, &Osize, (char *)inp);
if (!error) {
*dev = udev2dev(outp->dev);
*dev = findcdev(outp->dev);
*inode = outp->inode;
}

View File

@ -140,7 +140,7 @@ devfs_allocv(struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, stru
if (dev == NULL)
return (ENOENT);
} else {
dev = NODEV;
dev = NULL;
}
error = getnewvnode("devfs", mp, devfs_vnodeop_p, &vp);
if (error != 0) {
@ -382,9 +382,9 @@ devfs_lookupx(ap)
if (pname == NULL)
goto notfound;
cdev = NODEV;
cdev = NULL;
EVENTHANDLER_INVOKE(dev_clone, pname, strlen(pname), &cdev);
if (cdev == NODEV)
if (cdev == NULL)
goto notfound;
devfs_populate(dmp);
@ -660,7 +660,7 @@ devfs_reclaim(ap)
if (de != NULL)
de->de_vnode = NULL;
vp->v_data = NULL;
if (vp->v_rdev != NODEV && vp->v_rdev != NULL) {
if (vp->v_rdev != NULL && vp->v_rdev != NULL) {
i = vcount(vp);
if ((vp->v_rdev->si_flags & SI_CHEAPCLONE) && i == 0 &&
(vp->v_rdev->si_flags & SI_NAMED))

View File

@ -144,7 +144,7 @@ spec_open(ap)
if (vp->v_mount && (vp->v_mount->mnt_flag & MNT_NODEV))
return (ENXIO);
if (dev == NODEV)
if (dev == NULL)
return (ENXIO);
dsw = devsw(dev);

View File

@ -103,7 +103,7 @@ g_dev_clone(void *arg __unused, char *name, int namelen __unused, struct cdev **
{
struct g_geom *gp;
if (*dev != NODEV)
if (*dev != NULL)
return;
g_waitidle();

View File

@ -52,7 +52,7 @@ typedef struct {
uid_t iso_uid; /* owner user id */
gid_t iso_gid; /* owner group id */
short iso_links; /* links of file */
udev_t iso_rdev; /* Major/Minor number for special */
dev_t iso_rdev; /* Major/Minor number for special */
} ISO_RRIP_INODE;

View File

@ -413,9 +413,9 @@ cd9660_rrip_device(p,ana)
low = isonum_733(p->dev_t_low);
if (high == 0)
ana->inop->inode.iso_rdev = makeudev(umajor(low), uminor(low));
ana->inop->inode.iso_rdev = makedev(umajor(low), uminor(low));
else
ana->inop->inode.iso_rdev = makeudev(high, uminor(low));
ana->inop->inode.iso_rdev = makedev(high, uminor(low));
ana->fields &= ~ISO_SUSP_DEVICE;
return ISO_SUSP_DEVICE;
}

View File

@ -285,7 +285,7 @@ acct_process(td)
if ((p->p_flag & P_CONTROLT) && p->p_pgrp->pg_session->s_ttyp)
acct.ac_tty = dev2udev(p->p_pgrp->pg_session->s_ttyp->t_dev);
else
acct.ac_tty = NOUDEV;
acct.ac_tty = NODEV;
SESS_UNLOCK(p->p_session);
/* (8) The boolean flags that tell how the process terminated, etc. */

View File

@ -51,7 +51,7 @@ extern unsigned char reserved_majors[256];
/*
* This is the number of hash-buckets. Experiements with 'real-life'
* udev_t's show that a prime halfway between two powers of two works
* dev_t's show that a prime halfway between two powers of two works
* best.
*/
#define DEVT_HASH 83
@ -70,6 +70,8 @@ SYSCTL_INT(_debug, OID_AUTO, free_devt, CTLFLAG_RW, &free_devt, 0, "");
static struct mtx devmtx;
static void freedev(struct cdev *dev);
static struct cdev *newdev(int x, int y);
static void
devlock(void)
@ -125,8 +127,6 @@ cdevsw_rel(struct cdevsw *csw)
devunlock();
}
static struct cdev *makedev(int x, int y);
int
nullop(void)
{
@ -247,16 +247,16 @@ devsw(struct cdev *dev)
int
major(struct cdev *x)
{
if (x == NODEV)
return NOUDEV;
if (x == NULL)
return NODEV;
return((x->si_udev >> 8) & 0xff);
}
int
minor(struct cdev *x)
{
if (x == NODEV)
return NOUDEV;
if (x == NULL)
return NODEV;
return(x->si_udev & 0xffff00ff);
}
@ -265,8 +265,8 @@ dev2unit(struct cdev *x)
{
int i;
if (x == NODEV)
return NOUDEV;
if (x == NULL)
return NODEV;
i = minor(x);
return ((i & 0xff) | (i >> 8));
}
@ -304,14 +304,14 @@ allocdev(void)
}
static struct cdev *
makedev(int x, int y)
newdev(int x, int y)
{
struct cdev *si;
udev_t udev;
dev_t udev;
int hash;
if (x == umajor(NOUDEV) && y == uminor(NOUDEV))
panic("makedev of NOUDEV");
if (x == umajor(NODEV) && y == uminor(NODEV))
panic("newdev of NODEV");
udev = (x << 8) | y;
hash = udev % DEVT_HASH;
LIST_FOREACH(si, &dev_hash[hash], si_hash) {
@ -337,48 +337,42 @@ freedev(struct cdev *dev)
}
}
udev_t
dev_t
dev2udev(struct cdev *x)
{
if (x == NODEV)
return (NOUDEV);
if (x == NULL)
return (NODEV);
return (x->si_udev);
}
struct cdev *
udev2dev(udev_t udev)
findcdev(dev_t udev)
{
struct cdev *si;
int hash;
if (udev == NOUDEV)
return (NODEV);
if (udev == NODEV)
return (NULL);
hash = udev % DEVT_HASH;
LIST_FOREACH(si, &dev_hash[hash], si_hash) {
if (si->si_udev == udev)
return (si);
}
return (NODEV);
return (NULL);
}
int
uminor(udev_t dev)
uminor(dev_t dev)
{
return (dev & 0xffff00ff);
}
int
umajor(udev_t dev)
umajor(dev_t dev)
{
return ((dev & 0xff00) >> 8);
}
udev_t
makeudev(int x, int y)
{
return ((x << 8) | y);
}
static void
find_major(struct cdevsw *devsw)
{
@ -479,7 +473,7 @@ make_dev(struct cdevsw *devsw, int minornr, uid_t uid, gid_t gid, int perms, con
if (!(devsw->d_flags & D_INIT))
prep_cdevsw(devsw);
dev = makedev(devsw->d_maj, minornr);
dev = newdev(devsw->d_maj, minornr);
if (dev->si_flags & SI_CHEAPCLONE &&
dev->si_flags & SI_NAMED &&
dev->si_devsw == devsw) {
@ -750,7 +744,7 @@ clone_create(struct clonedevs **cdp, struct cdevsw *csw, int *up, struct cdev **
}
if (unit == -1)
unit = low & CLONE_UNITMASK;
dev = makedev(csw->d_maj, unit2minor(unit | extra));
dev = newdev(csw->d_maj, unit2minor(unit | extra));
KASSERT(!(dev->si_flags & SI_CLONELIST),
("Dev %p should not be on clonelist", dev));
if (dl != NULL)
@ -794,16 +788,16 @@ static int
sysctl_devname(SYSCTL_HANDLER_ARGS)
{
int error;
udev_t ud;
dev_t ud;
struct cdev *dev;
error = SYSCTL_IN(req, &ud, sizeof (ud));
if (error)
return (error);
if (ud == NOUDEV)
if (ud == NODEV)
return(EINVAL);
dev = udev2dev(ud);
if (dev == NODEV)
dev = findcdev(ud);
if (dev == NULL)
error = ENOENT;
else
error = SYSCTL_OUT(req, dev->si_name, strlen(dev->si_name) + 1);

View File

@ -800,7 +800,7 @@ fill_kinfo_thread(struct thread *td, struct kinfo_proc *kp)
if (tp->t_session)
kp->ki_tsid = tp->t_session->s_sid;
} else
kp->ki_tdev = NOUDEV;
kp->ki_tdev = NODEV;
if (p->p_comm[0] != '\0') {
strlcpy(kp->ki_comm, p->p_comm, sizeof(kp->ki_comm));
strlcpy(kp->ki_ocomm, p->p_comm, sizeof(kp->ki_ocomm));
@ -1012,7 +1012,7 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS)
SESS_LOCK(p->p_session);
if (p->p_session->s_ttyp == NULL ||
dev2udev(p->p_session->s_ttyp->t_dev) !=
(udev_t)name[0]) {
(dev_t)name[0]) {
SESS_UNLOCK(p->p_session);
PROC_UNLOCK(p);
continue;

View File

@ -324,7 +324,7 @@ boot(int howto)
for (bp = &buf[nbuf]; --bp >= buf; ) {
if (((bp->b_flags&B_INVAL) == 0 && BUF_REFCNT(bp)) ||
((bp->b_flags & (B_DELWRI|B_INVAL)) == B_DELWRI)) {
if (bp->b_dev == NODEV) {
if (bp->b_dev == NULL) {
TAILQ_REMOVE(&mountlist,
bp->b_vp->v_mount, mnt_list);
continue;

View File

@ -103,7 +103,7 @@ static STAILQ_HEAD(, cn_device) cn_devlist =
(cnd == NULL || cnd->cnd_vp == NULL || \
(cnd->cnd_vp->v_type == VBAD && !cn_devopen(cnd, td, 1)))
static udev_t cn_udev_t;
static dev_t cn_udev_t;
SYSCTL_OPAQUE(_machdep, CPU_CONSDEV, consdev, CTLFLAG_RD,
&cn_udev_t, sizeof cn_udev_t, "T,struct cdev *", "");
@ -371,9 +371,9 @@ sysctl_kern_consmute(SYSCTL_HANDLER_ARGS)
if (error != 0 || req->newptr == NULL)
return (error);
if (ocn_mute && !cn_mute && cn_is_open)
error = cnopen(NODEV, openflag, 0, curthread);
error = cnopen(NULL, openflag, 0, curthread);
else if (!ocn_mute && cn_mute && cn_is_open) {
error = cnclose(NODEV, openflag, 0, curthread);
error = cnclose(NULL, openflag, 0, curthread);
cn_is_open = 1; /* XXX hack */
}
return (error);

View File

@ -143,7 +143,7 @@ ptyinit(struct cdev *devc)
n = minor(devc);
/* For now we only map the lower 8 bits of the minor */
if (n & ~0xff)
return (NODEV);
return (NULL);
devc->si_flags &= ~SI_CHEAPCLONE;
@ -777,7 +777,7 @@ pty_clone(void *arg, char *name, int namelen, struct cdev **dev)
{
int u;
if (*dev != NODEV)
if (*dev != NULL)
return;
if (bcmp(name, "pty", 3) != 0)
return;

View File

@ -58,7 +58,7 @@ static void
ctty_clone(void *arg, char *name, int namelen, struct cdev **dev)
{
if (*dev != NODEV)
if (*dev != NULL)
return;
if (strcmp(name, "tty"))
return;

View File

@ -447,7 +447,7 @@ uipc_sense(struct socket *so, struct stat *sb)
so2 = unp->unp_conn->unp_socket;
sb->st_blksize += so2->so_rcv.sb_cc;
}
sb->st_dev = NOUDEV;
sb->st_dev = NODEV;
if (unp->unp_ino == 0)
unp->unp_ino = (++unp_ino == 0) ? ++unp_ino : unp_ino;
sb->st_ino = unp->unp_ino;

View File

@ -517,7 +517,7 @@ bufinit(void)
bp = &buf[i];
bzero(bp, sizeof *bp);
bp->b_flags = B_INVAL; /* we're just an empty header */
bp->b_dev = NODEV;
bp->b_dev = NULL;
bp->b_rcred = NOCRED;
bp->b_wcred = NOCRED;
bp->b_qindex = QUEUE_EMPTY;
@ -1413,7 +1413,7 @@ brelse(struct buf * bp)
bp->b_qindex = QUEUE_EMPTY;
}
TAILQ_INSERT_HEAD(&bufqueues[bp->b_qindex], bp, b_freelist);
bp->b_dev = NODEV;
bp->b_dev = NULL;
/* buffers with junk contents */
} else if (bp->b_flags & (B_INVAL | B_NOCACHE | B_RELBUF) ||
(bp->b_ioflags & BIO_ERROR)) {
@ -1423,7 +1423,7 @@ brelse(struct buf * bp)
panic("losing buffer 2");
bp->b_qindex = QUEUE_CLEAN;
TAILQ_INSERT_HEAD(&bufqueues[QUEUE_CLEAN], bp, b_freelist);
bp->b_dev = NODEV;
bp->b_dev = NULL;
/* remaining buffers */
} else {
if (bp->b_flags & B_DELWRI)
@ -1917,7 +1917,7 @@ getnewbuf(int slpflag, int slptimeo, int size, int maxsize)
bp->b_ioflags = 0;
bp->b_xflags = 0;
bp->b_vflags = 0;
bp->b_dev = NODEV;
bp->b_dev = NULL;
bp->b_vp = NULL;
bp->b_blkno = bp->b_lblkno = 0;
bp->b_offset = NOOFFSET;

View File

@ -147,7 +147,7 @@ static char *cdrom_rootdevnames[] = {
/* legacy find-root code */
char *rootdevnames[2] = {NULL, NULL};
static int setrootbyname(char *name);
struct cdev *rootdev = NODEV;
struct cdev *rootdev = NULL;
/*
* Has to be dynamic as the value of rootdev can change; however, it can't
@ -162,7 +162,7 @@ sysctl_rootdev(SYSCTL_HANDLER_ARGS)
/* _RD prevents this from happening. */
KASSERT(req->newptr == NULL, ("Attempt to change root device name"));
if (rootdev != NODEV)
if (rootdev != NULL)
error = sysctl_handle_string(oidp, rootdev->si_name, 0, req);
else
error = sysctl_handle_string(oidp, "", 0, req);
@ -1339,7 +1339,7 @@ vfs_mountroot_try(char *mountfrom)
printf("setrootbyname failed\n");
/* If the root device is a type "memory disk", mount RW */
if (rootdev != NODEV && devsw(rootdev) != NULL) {
if (rootdev != NULL && devsw(rootdev) != NULL) {
devname = devtoname(rootdev);
if (devname[0] == 'm' && devname[1] == 'd')
mp->mnt_flag &= ~MNT_RDONLY;
@ -1457,7 +1457,7 @@ getdiskbyname(char *name) {
if (!bcmp(cp, "/dev/", 5))
cp += 5;
dev = NODEV;
dev = NULL;
EVENTHANDLER_INVOKE(dev_clone, cp, strlen(cp), &dev);
return (dev);
}
@ -1472,7 +1472,7 @@ setrootbyname(char *name)
struct cdev *diskdev;
diskdev = getdiskbyname(name);
if (diskdev != NODEV) {
if (diskdev != NULL) {
rootdev = diskdev;
return (0);
}
@ -1491,7 +1491,7 @@ DB_SHOW_COMMAND(disk, db_getdiskbyname)
return;
}
dev = getdiskbyname(modif);
if (dev != NODEV)
if (dev != NULL)
db_printf("struct cdev *= %p\n", dev);
else
db_printf("No disk device matched.\n");

View File

@ -367,7 +367,7 @@ vfs_getnewfsid(mp)
tfsid.val[1] = mtype;
mtype = (mtype & 0xFF) << 24;
for (;;) {
tfsid.val[0] = makeudev(255,
tfsid.val[0] = makedev(255,
mtype | ((mntid_base & 0xFF00) << 8) | (mntid_base & 0xFF));
mntid_base++;
if (vfs_getvfs(&tfsid) == NULL)
@ -1744,7 +1744,7 @@ bdevvp(dev, vpp)
struct vnode *nvp;
int error;
if (dev == NODEV) {
if (dev == NULL) {
*vpp = NULLVP;
return (ENXIO);
}
@ -1786,7 +1786,7 @@ v_incr_usecount(struct vnode *vp, int delta)
struct vnode *
addaliasu(nvp, nvp_rdev)
struct vnode *nvp;
udev_t nvp_rdev;
dev_t nvp_rdev;
{
struct vnode *ovp;
vop_t **ops;
@ -1796,8 +1796,8 @@ addaliasu(nvp, nvp_rdev)
return (nvp);
if (nvp->v_type != VCHR)
panic("addaliasu on non-special vnode");
dev = udev2dev(nvp_rdev);
if (dev == NODEV)
dev = findcdev(nvp_rdev);
if (dev == NULL)
return (nvp);
/*
* Check to see if we have a bdevvp vnode with no associated
@ -1836,7 +1836,7 @@ addaliasu(nvp, nvp_rdev)
}
/* This is a local helper function that do the same as addaliasu, but for a
* struct cdev *instead of an udev_t. */
* struct cdev *instead of an dev_t. */
static void
addalias(nvp, dev)
struct vnode *nvp;
@ -2581,7 +2581,7 @@ vgonel(vp, td)
* if it is on one.
*/
VI_LOCK(vp);
if (vp->v_type == VCHR && vp->v_rdev != NODEV) {
if (vp->v_type == VCHR && vp->v_rdev != NULL) {
mtx_lock(&spechash_mtx);
SLIST_REMOVE(&vp->v_rdev->si_hlist, vp, vnode, v_specnext);
vp->v_rdev->si_usecount -= vp->v_usecount;
@ -3407,7 +3407,7 @@ vn_todev(vp)
{
if (vp->v_type != VCHR)
return (NODEV);
return (NULL);
return (vp->v_rdev);
}

View File

@ -1578,7 +1578,7 @@ bpf_clone(arg, name, namelen, dev)
{
int u;
if (*dev != NODEV)
if (*dev != NULL)
return;
if (dev_stdclone(name, NULL, "bpf", &u) != 1)
return;

View File

@ -228,7 +228,7 @@ tapclone(arg, name, namelen, dev)
int i, unit;
char *device_name = name;
if (*dev != NODEV)
if (*dev != NULL)
return;
device_name = TAP;

View File

@ -138,7 +138,7 @@ tunclone(void *arg, char *name, int namelen, struct cdev **dev)
{
int u, i;
if (*dev != NODEV)
if (*dev != NULL)
return;
if (strcmp(name, TUNNAME) == 0) {

View File

@ -408,7 +408,7 @@ USB_ATTACH(ubt)
sc->sc_hook = NULL;
/* Device part */
sc->sc_ctrl_dev = sc->sc_intr_dev = sc->sc_bulk_dev = NODEV;
sc->sc_ctrl_dev = sc->sc_intr_dev = sc->sc_bulk_dev = NULL;
sc->sc_refcnt = sc->sc_dying = 0;
/*
@ -1903,8 +1903,8 @@ ng_ubt_newhook(node_p node, hook_p hook, char const *name)
ubt_softc_p sc = (ubt_softc_p) NG_NODE_PRIVATE(node);
/* Refuse to create new hook if device interface is active */
if (sc->sc_ctrl_dev != NODEV || sc->sc_intr_dev != NODEV ||
sc->sc_bulk_dev != NODEV)
if (sc->sc_ctrl_dev != NULL || sc->sc_intr_dev != NULL ||
sc->sc_bulk_dev != NULL)
return (EBUSY);
if (strcmp(name, NG_UBT_HOOK) != 0)
@ -1929,8 +1929,8 @@ ng_ubt_connect(hook_p hook)
usbd_status status;
/* Refuse to connect hook if device interface is active */
if (sc->sc_ctrl_dev != NODEV || sc->sc_intr_dev != NODEV ||
sc->sc_bulk_dev != NODEV)
if (sc->sc_ctrl_dev != NULL || sc->sc_intr_dev != NULL ||
sc->sc_bulk_dev != NULL)
return (EBUSY);
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
@ -2658,14 +2658,14 @@ ubt_create_device_nodes(ubt_softc_p sc)
"%s: %s - hook != NULL!\n", __func__, USBDEVNAME(sc->sc_dev)));
/* Control device */
if (sc->sc_ctrl_dev == NODEV)
if (sc->sc_ctrl_dev == NULL)
sc->sc_ctrl_dev = make_dev(&ubt_cdevsw,
UBT_MINOR(USBDEVUNIT(sc->sc_dev), 0),
UID_ROOT, GID_OPERATOR, 0644,
"%s", USBDEVNAME(sc->sc_dev));
/* Interrupt device */
if (sc->sc_intr_dev == NODEV && sc->sc_intr_ep != -1) {
if (sc->sc_intr_dev == NULL && sc->sc_intr_ep != -1) {
ep = UE_GET_ADDR(sc->sc_intr_ep);
sc->sc_intr_dev = make_dev(&ubt_cdevsw,
UBT_MINOR(USBDEVUNIT(sc->sc_dev), ep),
@ -2679,7 +2679,7 @@ ubt_create_device_nodes(ubt_softc_p sc)
* XXX note that address of the in and out endpoint should be the same
*/
if (sc->sc_bulk_dev == NODEV &&
if (sc->sc_bulk_dev == NULL &&
sc->sc_bulk_in_ep != -1 && sc->sc_bulk_out_ep != -1 &&
UE_GET_ADDR(sc->sc_bulk_in_ep) == UE_GET_ADDR(sc->sc_bulk_out_ep)) {
ep = UE_GET_ADDR(sc->sc_bulk_in_ep);
@ -2712,19 +2712,19 @@ ubt_destroy_device_nodes(ubt_softc_p sc)
sc->sc_refcnt = 0;
/* Destroy device nodes */
if (sc->sc_bulk_dev != NODEV) {
if (sc->sc_bulk_dev != NULL) {
destroy_dev(sc->sc_bulk_dev);
sc->sc_bulk_dev = NODEV;
sc->sc_bulk_dev = NULL;
}
if (sc->sc_intr_dev != NODEV) {
if (sc->sc_intr_dev != NULL) {
destroy_dev(sc->sc_intr_dev);
sc->sc_intr_dev = NODEV;
sc->sc_intr_dev = NULL;
}
if (sc->sc_ctrl_dev != NODEV) {
if (sc->sc_ctrl_dev != NULL) {
destroy_dev(sc->sc_ctrl_dev);
sc->sc_ctrl_dev = NODEV;
sc->sc_ctrl_dev = NULL;
}
} /* ubt_destroy_device_nodes */

View File

@ -149,7 +149,7 @@ USB_ATTACH(ubtbcmfw)
USB_ATTACH_SETUP;
printf("%s: %s\n", USBDEVNAME(sc->sc_dev), devinfo);
sc->sc_ctrl_dev = sc->sc_intr_in_dev = sc->sc_bulk_out_dev = NODEV;
sc->sc_ctrl_dev = sc->sc_intr_in_dev = sc->sc_bulk_out_dev = NULL;
sc->sc_intr_in_pipe = sc->sc_bulk_out_pipe = NULL;
sc->sc_flags = sc->sc_refcnt = sc->sc_dying = 0;
@ -229,19 +229,19 @@ USB_DETACH(ubtbcmfw)
}
/* Destroy device nodes */
if (sc->sc_bulk_out_dev != NODEV) {
if (sc->sc_bulk_out_dev != NULL) {
destroy_dev(sc->sc_bulk_out_dev);
sc->sc_bulk_out_dev = NODEV;
sc->sc_bulk_out_dev = NULL;
}
if (sc->sc_intr_in_dev != NODEV) {
if (sc->sc_intr_in_dev != NULL) {
destroy_dev(sc->sc_intr_in_dev);
sc->sc_intr_in_dev = NODEV;
sc->sc_intr_in_dev = NULL;
}
if (sc->sc_ctrl_dev != NODEV) {
if (sc->sc_ctrl_dev != NULL) {
destroy_dev(sc->sc_ctrl_dev);
sc->sc_ctrl_dev = NODEV;
sc->sc_ctrl_dev = NULL;
}
/* Close pipes */

View File

@ -103,7 +103,7 @@ nsmb_dev_clone(void *arg, char *name, int namelen, struct cdev **dev)
{
int u;
if (*dev != NODEV)
if (*dev != NULL)
return;
if (dev_stdclone(name, NULL, NSMB_NAME, &u) != 1)
return;
@ -397,7 +397,7 @@ smb_dev2share(int fd, int mode, struct smb_cred *scred,
return EBADF;
}
dev = vn_todev(vp);
if (dev == NODEV) {
if (dev == NULL) {
fdrop(fp, curthread);
return EBADF;
}

View File

@ -83,7 +83,7 @@ nfs4_vnop_loadattrcache(struct vnode *vp, struct nfsv4_fattr *fap,
vtyp = nv3tov_type[fap->fa4_type & 0x7];
vmode = (fap->fa4_valid & FA4V_MODE) ? fap->fa4_mode : 0777;
rdev = (fap->fa4_valid & FA4V_RDEV) ?
makeudev(fap->fa4_rdev_major, fap->fa4_rdev_minor) : 0;
makedev(fap->fa4_rdev_major, fap->fa4_rdev_minor) : 0;
if (fap->fa4_valid & FA4V_MTIME)
mtime = fap->fa4_mtime;
else

View File

@ -495,7 +495,7 @@ nfs_loadattrcache(struct vnode **vpp, struct mbuf **mdp, caddr_t *dposp,
if (v3) {
vtyp = nfsv3tov_type(fp->fa_type);
vmode = fxdr_unsigned(u_short, fp->fa_mode);
rdev = makeudev(fxdr_unsigned(int, fp->fa3_rdev.specdata1),
rdev = makedev(fxdr_unsigned(int, fp->fa3_rdev.specdata1),
fxdr_unsigned(int, fp->fa3_rdev.specdata2));
fxdr_nfsv3time(&fp->fa3_mtime, &mtime);
} else {

View File

@ -2060,7 +2060,7 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
tl = nfsm_dissect(u_int32_t *, 2 * NFSX_UNSIGNED);
major = fxdr_unsigned(u_int32_t, *tl++);
minor = fxdr_unsigned(u_int32_t, *tl);
vap->va_rdev = makeudev(major, minor);
vap->va_rdev = makedev(major, minor);
}
/*

View File

@ -53,7 +53,6 @@ typedef __uint8_t __sa_family_t;
typedef __uint32_t __socklen_t;
typedef long __suseconds_t; /* microseconds (signed) */
typedef __int32_t __timer_t; /* timer_gettime()... */
typedef __uint32_t __udev_t; /* device number */
typedef __uint32_t __uid_t;
typedef unsigned int __useconds_t; /* microseconds (unsigned) */
@ -80,9 +79,7 @@ typedef __ct_rune_t __rune_t; /* rune_t (see above) */
typedef __ct_rune_t __wchar_t; /* wchar_t (see above) */
typedef __ct_rune_t __wint_t; /* wint_t (see above) */
#ifndef _KERNEL
typedef __udev_t __dev_t; /* device number */
#endif
typedef __uint32_t __dev_t; /* device number */
typedef __uint32_t __fixpt_t; /* fixed point number */

View File

@ -56,7 +56,7 @@ struct acct {
gid_t ac_gid; /* group id */
u_int16_t ac_mem; /* average memory usage */
comp_t ac_io; /* count of IO blocks */
__udev_t ac_tty; /* controlling tty */
__dev_t ac_tty; /* controlling tty */
#define AFORK 0x01 /* forked but not exec'ed */
/* ASU is no longer supported */

View File

@ -64,7 +64,7 @@ struct cdev {
struct timespec si_atime;
struct timespec si_ctime;
struct timespec si_mtime;
udev_t si_udev;
dev_t si_udev;
int si_refcount;
LIST_ENTRY(cdev) si_list;
LIST_ENTRY(cdev) si_clone;

View File

@ -55,7 +55,7 @@
* scheme is: <major><two digit minor><0 if release branch, otherwise 1>xx
*/
#undef __FreeBSD_version
#define __FreeBSD_version 502116 /* Master, propagated to newvers */
#define __FreeBSD_version 502117 /* Master, propagated to newvers */
#ifndef LOCORE
#include <sys/types.h>
@ -185,13 +185,8 @@
#define NBPW sizeof(int) /* number of bytes per word (integer) */
#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
#ifdef _KERNEL
#define NOUDEV (udev_t)(-1) /* non-existent device */
#define NOMAJ 256 /* non-existent device */
#define NODEV NULL /* non-existent device */
#else
#define NODEV (dev_t)(-1) /* non-existent device */
#endif
#define CBLOCK 128 /* Clist block size, must be a power of 2. */
#define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */

View File

@ -30,8 +30,8 @@
* detached from its current tty.
*/
#define SNPSTTY _IOW('T', 90, udev_t)
#define SNPGTTY _IOR('T', 89, udev_t)
#define SNPSTTY _IOW('T', 90, dev_t)
#define SNPGTTY _IOR('T', 89, dev_t)
/*
* These values would be returned by FIONREAD ioctl

View File

@ -44,9 +44,7 @@
/* XXX missing blkcnt_t, blksize_t. */
#ifndef _DEV_T_DECLARED
#ifndef _KERNEL
typedef __dev_t dev_t;
#endif
#define _DEV_T_DECLARED
#endif
@ -123,13 +121,13 @@ struct ostat {
#endif /* __BSD_VISIBLE */
struct stat {
__udev_t st_dev; /* inode's device */
__dev_t st_dev; /* inode's device */
ino_t st_ino; /* inode's number */
mode_t st_mode; /* inode protection mode */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of the file's owner */
gid_t st_gid; /* group ID of the file's group */
__udev_t st_rdev; /* device type */
__dev_t st_rdev; /* device type */
#if __BSD_VISIBLE
struct timespec st_atimespec; /* time of last access */
struct timespec st_mtimespec; /* time of last data modification */
@ -170,13 +168,13 @@ struct stat {
#if __BSD_VISIBLE
struct nstat {
__udev_t st_dev; /* inode's device */
__dev_t st_dev; /* inode's device */
ino_t st_ino; /* inode's number */
__uint32_t st_mode; /* inode protection mode */
__uint32_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of the file's owner */
gid_t st_gid; /* group ID of the file's group */
__udev_t st_rdev; /* device type */
__dev_t st_rdev; /* device type */
struct timespec st_atimespec; /* time of last access */
struct timespec st_mtimespec; /* time of last data modification */
struct timespec st_ctimespec; /* time of last file status change */

View File

@ -316,11 +316,10 @@ void wakeup_one(void *chan) __nonnull(1);
int major(struct cdev *x);
int minor(struct cdev *x);
udev_t dev2udev(struct cdev *x);
struct cdev *udev2dev(udev_t x);
int uminor(udev_t dev);
int umajor(udev_t dev);
udev_t makeudev(int x, int y);
dev_t dev2udev(struct cdev *x);
struct cdev *findcdev(dev_t x);
int uminor(dev_t dev);
int umajor(dev_t dev);
/* XXX: Should be void nanodelay(u_int nsec); */
void DELAY(int usec);

View File

@ -82,7 +82,7 @@ struct tty {
int t_line; /* Interface to device drivers. */
union {
struct cdev *t_kdev; /* Device. */
udev_t t_udev; /* Userland (sysctl) instance. */
dev_t t_udev; /* Userland (sysctl) instance. */
void *t_devp; /* Keep user/kernel size in sync. */
} ttyu;
int t_state; /* Device and driver (TS*) state. */
@ -141,7 +141,7 @@ struct xtty {
long xt_cancc; /* Canonical queue statistics. */
long xt_outcc; /* Output queue statistics. */
int xt_line; /* Interface to device drivers. */
udev_t xt_dev; /* Userland (sysctl) instance. */
dev_t xt_dev; /* Userland (sysctl) instance. */
int xt_state; /* Device and driver (TS*) state. */
int xt_flags; /* Tty flags. */
int xt_timeout; /* Timeout for ttywait(). */

View File

@ -131,9 +131,7 @@ typedef __critical_t critical_t; /* Critical section value */
typedef __int64_t daddr_t; /* disk address */
#ifndef _DEV_T_DECLARED
#ifndef _KERNEL
typedef __dev_t dev_t; /* device number or struct cdev */
#endif
#define _DEV_T_DECLARED
#endif
@ -235,7 +233,6 @@ typedef __timer_t timer_t;
#endif
typedef __u_register_t u_register_t;
typedef __udev_t udev_t; /* device number */
#ifndef _UID_T_DECLARED
typedef __uid_t uid_t; /* user id */
@ -292,9 +289,10 @@ typedef struct vm_page *vm_page_t;
*/
#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */
#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */
#endif /* !_KERNEL */
#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */
/*
* These declarations belong elsewhere, but are repeated here and in
* <stdio.h> to give broken programs a better chance of working with

View File

@ -108,7 +108,7 @@ struct kinfo_proc {
pid_t ki_sid; /* Process session ID */
pid_t ki_tsid; /* Terminal session ID */
short ki_jobc; /* job control counter */
udev_t ki_tdev; /* controlling tty dev */
dev_t ki_tdev; /* controlling tty dev */
sigset_t ki_siglist; /* Signals arrived but not delivered */
sigset_t ki_sigmask; /* Current signal mask */
sigset_t ki_sigignore; /* Signals being ignored */

View File

@ -153,7 +153,7 @@ struct vnode {
const char *filename; /* Source file doing locking */
int line; /* Line number doing locking */
#endif
udev_t v_cachedfs; /* cached fs id */
dev_t v_cachedfs; /* cached fs id */
ino_t v_cachedid; /* cached file id */
};
#define v_mountedhere v_un.vu_mountedhere
@ -179,9 +179,9 @@ struct xvnode {
union {
void *xvu_socket; /* socket, if VSOCK */
void *xvu_fifo; /* fifo, if VFIFO */
udev_t xvu_rdev; /* maj/min, if VBLK/VCHR */
dev_t xvu_rdev; /* maj/min, if VBLK/VCHR */
struct {
udev_t xvu_dev; /* device, if VDIR/VREG/VLNK */
dev_t xvu_dev; /* device, if VDIR/VREG/VLNK */
ino_t xvu_ino; /* id, if VDIR/VREG/VLNK */
} xv_uns;
} xv_un;
@ -247,7 +247,7 @@ struct vattr {
short va_nlink; /* number of references to file */
uid_t va_uid; /* owner user id */
gid_t va_gid; /* owner group id */
udev_t va_fsid; /* filesystem id */
dev_t va_fsid; /* filesystem id */
long va_fileid; /* file id */
u_quad_t va_size; /* file size in bytes */
long va_blocksize; /* blocksize preferred for i/o */
@ -257,7 +257,7 @@ struct vattr {
struct timespec va_birthtime; /* time file created */
u_long va_gen; /* generation number of file */
u_long va_flags; /* flags defined for file */
udev_t va_rdev; /* device the special file represents */
dev_t va_rdev; /* device the special file represents */
u_quad_t va_bytes; /* bytes of disk space held by file */
u_quad_t va_filerev; /* file modification number */
u_int va_vaflags; /* operations flags, see below */
@ -593,7 +593,7 @@ extern int (*lease_check_hook)(struct vop_lease_args *);
extern int (*softdep_fsync_hook)(struct vnode *);
extern int (*softdep_process_worklist_hook)(struct mount *);
struct vnode *addaliasu(struct vnode *vp, udev_t nvp_rdev);
struct vnode *addaliasu(struct vnode *vp, dev_t nvp_rdev);
int bdevvp(struct cdev *dev, struct vnode **vpp);
/* cache_* may belong in namei.h. */
void cache_enter(struct vnode *dvp, struct vnode *vp,

View File

@ -154,7 +154,7 @@ struct swdevt {
int sw_flags;
int sw_nblks;
int sw_used;
udev_t sw_udev;
dev_t sw_dev;
struct vnode *sw_vp;
void *sw_id;
swblk_t sw_first;
@ -2079,7 +2079,7 @@ swapon(struct thread *td, struct swapon_args *uap)
}
static void
swaponsomething(struct vnode *vp, void *id, u_long nblks, sw_strategy_t *strategy, sw_close_t *close, udev_t udev)
swaponsomething(struct vnode *vp, void *id, u_long nblks, sw_strategy_t *strategy, sw_close_t *close, dev_t dev)
{
struct swdevt *sp, *tsp;
swblk_t dvbase;
@ -2107,7 +2107,7 @@ swaponsomething(struct vnode *vp, void *id, u_long nblks, sw_strategy_t *strateg
sp = malloc(sizeof *sp, M_VMPGDATA, M_WAITOK | M_ZERO);
sp->sw_vp = vp;
sp->sw_id = id;
sp->sw_udev = udev;
sp->sw_dev = dev;
sp->sw_flags = 0;
sp->sw_nblks = nblks;
sp->sw_used = 0;
@ -2293,7 +2293,7 @@ sysctl_vm_swap_info(SYSCTL_HANDLER_ARGS)
if (n == *name) {
mtx_unlock(&sw_dev_mtx);
xs.xsw_version = XSWDEV_VERSION;
xs.xsw_dev = sp->sw_udev;
xs.xsw_dev = sp->sw_dev;
xs.xsw_flags = sp->sw_flags;
xs.xsw_nblks = sp->sw_nblks;
xs.xsw_used = sp->sw_used;
@ -2533,7 +2533,7 @@ swapdev_strategy(struct buf *bp, struct swdevt *sp)
int s;
struct vnode *vp, *vp2;
bp->b_dev = NODEV;
bp->b_dev = NULL;
bp->b_blkno = ctodb(bp->b_blkno - sp->sw_first);
vp2 = sp->sw_id;
@ -2598,6 +2598,6 @@ swaponvp(struct thread *td, struct vnode *vp, u_long nblks)
return (error);
swaponsomething(vp, vp, nblks, swapdev_strategy, swapdev_close,
NOUDEV);
NODEV);
return (0);
}

View File

@ -107,7 +107,7 @@
#define XSWDEV_VERSION 1
struct xswdev {
u_int xsw_version;
udev_t xsw_dev;
dev_t xsw_dev;
int xsw_flags;
int xsw_nblks;
int xsw_used;

View File

@ -585,8 +585,8 @@ ufs_filestat(vp, fsp)
return 0;
}
/*
* The st_dev from stat(2) is a udev_t. These kernel structures
* contain dev_t structures. We need to convert to udev to make
* The st_dev from stat(2) is a dev_t. These kernel structures
* contain cdev pointers. We need to convert to dev_t to make
* comparisons
*/
fsp->fsid = dev2udev(inode.i_dev);
@ -875,10 +875,10 @@ socktrans(sock, i)
/*
* Read the cdev structure in the kernel (as pointed to by a dev_t)
* in order to work out the associated udev_t
* Read the cdev structure in the kernel in order to work out the
* associated dev_t
*/
udev_t
dev_t
dev2udev(dev)
struct cdev *dev;
{
@ -887,7 +887,7 @@ dev2udev(dev)
if (KVM_READ(dev, &si, sizeof si)) {
return si.si_udev;
} else {
dprintf(stderr, "can't convert dev_t %x to a udev_t\n", dev);
dprintf(stderr, "can't convert cdev *%x to a dev_t\n", dev);
return -1;
}
}

View File

@ -64,7 +64,7 @@ extern kvm_t *kd;
extern int vflg;
extern int Pid;
udev_t dev2udev(struct cdev *dev);
dev_t dev2udev(struct cdev *dev);
/* Additional filesystem types */
int isofs_filestat(struct vnode *vp, struct filestat *fsp);

View File

@ -383,7 +383,7 @@ main(int argc, char **argv)
if (li->li_number == -1 &&
(kp->ki_flag & P_CONTROLT) == 0)
break;
if (kp->ki_tdev == (udev_t)li->li_number)
if (kp->ki_tdev == (dev_t)li->li_number)
break;
}
if (SLIST_FIRST(&tdevlist) != NULL && li == NULL) {