From b17f0c0d29fc3ee236a4ff5b42f2e66e0b8a1abf Mon Sep 17 00:00:00 2001 From: Alex Hornung Date: Fri, 25 Sep 2009 22:49:30 +0100 Subject: [PATCH] devfs - Change make_dev_covering to use dev_ops * Change make_dev_covering and all other related functions to use a backing dev_ops instead of a backing cdev. This allows for a more generic use of make_dev_covering, without the need of an explicit backing cdev. * Also change make_autoclone_dev to use the new make_dev_covering to avoid maj/min collision between base clonable devices. --- sys/kern/kern_conf.c | 8 ++++---- sys/kern/subr_disk.c | 6 +++--- sys/sys/conf.h | 2 +- sys/sys/devfs.h | 2 +- sys/sys/device.h | 4 ++-- sys/vfs/devfs/devfs_core.c | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index d933a97ec3..4ff19cd285 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -206,8 +206,8 @@ make_dev(struct dev_ops *ops, int minor, uid_t uid, gid_t gid, * only be used by systems and drivers which create devices covering others */ cdev_t -make_dev_covering(struct dev_ops *ops, cdev_t rdev, int minor, uid_t uid, - gid_t gid, int perms, const char *fmt, ...) +make_dev_covering(struct dev_ops *ops, struct dev_ops *bops, int minor, + uid_t uid, gid_t gid, int perms, const char *fmt, ...) { cdev_t devfs_dev; __va_list ap; @@ -217,7 +217,7 @@ make_dev_covering(struct dev_ops *ops, cdev_t rdev, int minor, uid_t uid, */ compile_dev_ops(ops); - devfs_dev = devfs_new_cdev(ops, minor, rdev); + devfs_dev = devfs_new_cdev(ops, minor, bops); __va_start(ap, fmt); kvsnrprintf(devfs_dev->si_name, sizeof(devfs_dev->si_name), 32, fmt, ap); @@ -370,7 +370,7 @@ make_autoclone_dev(struct dev_ops *ops, struct devfs_bitmap *bitmap, devfs_clone_bitmap_init(bitmap); devfs_clone_handler_add(name, nhandler); - dev = make_dev(&default_dev_ops, 0xffff00ff, + dev = make_dev_covering(&default_dev_ops, ops, 0xffff00ff, uid, gid, perms, "%s", name); kvasfree(&name); return dev; diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 40ae1b5ef4..459f5fe914 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -209,7 +209,7 @@ disk_probe_slice(struct disk *dp, cdev_t dev, int slice, int reprobe) */ ndev->si_flags |= SI_REPROBE_TEST; } else { - ndev = make_dev_covering(&disk_ops, dp->d_rawdev, + ndev = make_dev_covering(&disk_ops, dp->d_rawdev->si_ops, dkmakeminor(dkunit(dp->d_cdev), slice, i), UID_ROOT, GID_OPERATOR, 0640, @@ -309,7 +309,7 @@ disk_probe(struct disk *dp, int reprobe) /* * Else create new device */ - ndev = make_dev_covering(&disk_ops, dp->d_rawdev, + ndev = make_dev_covering(&disk_ops, dp->d_rawdev->si_ops, dkmakewholeslice(dkunit(dev), i), UID_ROOT, GID_OPERATOR, 0640, "%ss%d", dev->si_name, sno); @@ -502,7 +502,7 @@ disk_create(int unit, struct disk *dp, struct dev_ops *raw_ops) dp->d_rawdev = rawdev; dp->d_raw_ops = raw_ops; dp->d_dev_ops = &disk_ops; - dp->d_cdev = make_dev_covering(&disk_ops, dp->d_rawdev, + dp->d_cdev = make_dev_covering(&disk_ops, dp->d_rawdev->si_ops, dkmakewholedisk(unit), UID_ROOT, GID_OPERATOR, 0640, "%s%d", raw_ops->head.name, unit); diff --git a/sys/sys/conf.h b/sys/sys/conf.h index a7ba3e2fdb..6f34933694 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -71,7 +71,6 @@ struct cdev { uid_t si_uid; gid_t si_gid; int si_perms; - struct cdev *si_rdev; TAILQ_ENTRY(cdev) link; int si_uminor; int si_umajor; @@ -81,6 +80,7 @@ struct cdev { void *si_drv1; void *si_drv2; struct dev_ops *si_ops; /* device operations vector */ + struct dev_ops *si_bops; /* backing devops vector */ int si_iosize_max; /* maximum I/O size (for physio &al) */ struct sysref si_sysref; union { diff --git a/sys/sys/devfs.h b/sys/sys/devfs.h index 85b2f9135c..2814b6231e 100644 --- a/sys/sys/devfs.h +++ b/sys/sys/devfs.h @@ -391,7 +391,7 @@ int devfs_destroy_subnames(char *); int devfs_destroy_dev_by_ops(struct dev_ops *, int); struct devfs_node *devfs_find_device_node_by_name(struct devfs_node *, char *); -cdev_t devfs_new_cdev(struct dev_ops *, int, cdev_t); +cdev_t devfs_new_cdev(struct dev_ops *, int, struct dev_ops *); cdev_t devfs_find_device_by_name(const char *, ...); cdev_t devfs_find_device_by_udev(udev_t); diff --git a/sys/sys/device.h b/sys/sys/device.h index ef46a0b3a0..3262285aa2 100644 --- a/sys/sys/device.h +++ b/sys/sys/device.h @@ -364,8 +364,8 @@ void dev_ops_restore(cdev_t, struct dev_ops *); cdev_t make_dev(struct dev_ops *ops, int minor, uid_t uid, gid_t gid, int perms, const char *fmt, ...) __printflike(6, 7); -cdev_t make_dev_covering(struct dev_ops *ops, cdev_t rdev, int minor, uid_t uid, - gid_t gid, int perms, const char *fmt, ...) __printflike(7, 8); +cdev_t make_dev_covering(struct dev_ops *ops, struct dev_ops *bops, int minor, + uid_t uid, gid_t gid, int perms, const char *fmt, ...) __printflike(7, 8); cdev_t make_only_dev(struct dev_ops *ops, int minor, uid_t uid, gid_t gid, int perms, const char *fmt, ...) __printflike(6, 7); cdev_t make_only_devfs_dev(struct dev_ops *ops, int minor, uid_t uid, gid_t gid, diff --git a/sys/vfs/devfs/devfs_core.c b/sys/vfs/devfs/devfs_core.c index 347da7e46b..2a9d62d6c4 100644 --- a/sys/vfs/devfs/devfs_core.c +++ b/sys/vfs/devfs/devfs_core.c @@ -2071,7 +2071,7 @@ devfs_fetch_ino(void) * fields. */ cdev_t -devfs_new_cdev(struct dev_ops *ops, int minor, cdev_t rdev) +devfs_new_cdev(struct dev_ops *ops, int minor, struct dev_ops *bops) { cdev_t dev = sysref_alloc(&cdev_sysref_class); @@ -2091,10 +2091,10 @@ devfs_new_cdev(struct dev_ops *ops, int minor, cdev_t rdev) dev->si_flags = 0; dev->si_umajor = 0; dev->si_uminor = minor; - dev->si_rdev = rdev; + dev->si_bops = bops; /* If there is a backing device, we reference its ops */ dev->si_inode = makeudev( - devfs_reference_ops((rdev)?(rdev->si_ops):(ops)), + devfs_reference_ops((bops)?(bops):(ops)), minor ); return dev; @@ -2119,7 +2119,7 @@ devfs_cdev_terminate(cdev_t dev) lockmgr(&devfs_lock, LK_RELEASE); /* If there is a backing device, we release the backing device's ops */ - devfs_release_ops((dev->si_rdev)?(dev->si_rdev->si_ops):(dev->si_ops)); + devfs_release_ops((dev->si_bops)?(dev->si_bops):(dev->si_ops)); /* Finally destroy the device */ sysref_put(&dev->si_sysref); -- 2.41.0