struct acd * acd_init_lun(struct atapi *ata, int unit, struct atapi_params *ap, int lun, struct devstat *device_stats) { struct acd *ptr; dev_t pdev; if (!(ptr = malloc(sizeof(struct acd), M_TEMP, M_NOWAIT | M_ZERO))) return NULL; bioq_init(&ptr->bio_queue); ptr->ata = ata; ptr->unit = unit; ptr->lun = lun; ptr->param = ap; ptr->flags = F_MEDIA_CHANGED; ptr->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED); ptr->block_size = 2048; ptr->refcnt = 0; ptr->slot = -1; ptr->changer_info = NULL; if (device_stats == NULL) { if (!(ptr->device_stats = malloc(sizeof(struct devstat), M_TEMP, M_NOWAIT | M_ZERO))) return NULL; } else ptr->device_stats = device_stats; pdev = make_dev(&acd_cdevsw, dkmakeminor(lun, 0, 0), UID_ROOT, GID_OPERATOR, 0640, "wcd%da", lun); make_dev_alias(pdev, "rwcd%da", lun); pdev->si_drv1 = ptr; pdev = make_dev(&acd_cdevsw, dkmakeminor(lun, 0, RAW_PART), UID_ROOT, GID_OPERATOR, 0640, "wcd%dc", lun); make_dev_alias(pdev, "rwcd%dc", lun); pdev->si_drv1 = ptr; return ptr; }
static void cn_drvinit(void *unused) { phandle_t options; char output[32]; if (ofw_consdev.cn_dev != NULL) { if ((options = OF_finddevice("/options")) == -1 || OF_getprop(options, "output-device", output, sizeof(output)) == -1) return; make_dev(&ofw_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "ofwcons"); make_dev_alias(ofw_consdev.cn_dev, "%s", output); } }
int cardbus_device_create(struct cardbus_softc *sc, struct cardbus_devinfo *devi, device_t parent, device_t child) { uint32_t minor; int unit; cardbus_device_buffer_cis(parent, child, &devi->sc_cis); minor = (device_get_unit(sc->sc_dev) << 8) + devi->pci.cfg.func; unit = device_get_unit(sc->sc_dev); devi->sc_cisdev = make_dev(&cardbus_cdevsw, minor, 0, 0, 0666, "cardbus%d.%d.cis", unit, devi->pci.cfg.func); if (devi->pci.cfg.func == 0) make_dev_alias(devi->sc_cisdev, "cardbus%d.cis", unit); devi->sc_cisdev->si_drv1 = devi; return (0); }
static int disk_probe_slice(struct disk *dp, cdev_t dev, int slice, int reprobe) { struct disk_info *info = &dp->d_info; struct diskslice *sp = &dp->d_slice->dss_slices[slice]; disklabel_ops_t ops; struct partinfo part; const char *msg; char uuid_buf[128]; cdev_t ndev; int sno; u_int i; disk_debug(2, "disk_probe_slice (begin): %s (%s)\n", dev->si_name, dp->d_cdev->si_name); sno = slice ? slice - 1 : 0; ops = &disklabel32_ops; msg = ops->op_readdisklabel(dev, sp, &sp->ds_label, info); if (msg && !strcmp(msg, "no disk label")) { ops = &disklabel64_ops; msg = ops->op_readdisklabel(dev, sp, &sp->ds_label, info); } if (msg == NULL) { if (slice != WHOLE_DISK_SLICE) ops->op_adjust_label_reserved(dp->d_slice, slice, sp); else sp->ds_reserved = 0; sp->ds_ops = ops; for (i = 0; i < ops->op_getnumparts(sp->ds_label); i++) { ops->op_loadpartinfo(sp->ds_label, i, &part); if (part.fstype) { if (reprobe && (ndev = devfs_find_device_by_name("%s%c", dev->si_name, 'a' + i)) ) { /* * Device already exists and * is still valid. */ ndev->si_flags |= SI_REPROBE_TEST; /* * Destroy old UUID alias */ destroy_dev_alias(ndev, "part-by-uuid/*"); /* Create UUID alias */ if (!kuuid_is_nil(&part.storage_uuid)) { snprintf_uuid(uuid_buf, sizeof(uuid_buf), &part.storage_uuid); make_dev_alias(ndev, "part-by-uuid/%s", uuid_buf); udev_dict_set_cstr(ndev, "uuid", uuid_buf); } } else { ndev = make_dev_covering(&disk_ops, dp->d_rawdev->si_ops, dkmakeminor(dkunit(dp->d_cdev), slice, i), UID_ROOT, GID_OPERATOR, 0640, "%s%c", dev->si_name, 'a'+ i); ndev->si_parent = dev; ndev->si_iosize_max = dev->si_iosize_max; ndev->si_disk = dp; udev_dict_set_cstr(ndev, "subsystem", "disk"); /* Inherit parent's disk type */ if (dp->d_disktype) { udev_dict_set_cstr(ndev, "disk-type", __DECONST(char *, dp->d_disktype)); } /* Create serno alias */ if (dp->d_info.d_serialno) { make_dev_alias(ndev, "serno/%s.s%d%c", dp->d_info.d_serialno, sno, 'a' + i); } /* Create UUID alias */ if (!kuuid_is_nil(&part.storage_uuid)) { snprintf_uuid(uuid_buf, sizeof(uuid_buf), &part.storage_uuid); make_dev_alias(ndev, "part-by-uuid/%s", uuid_buf); udev_dict_set_cstr(ndev, "uuid", uuid_buf); } ndev->si_flags |= SI_REPROBE_TEST; } } } } else if (info->d_dsflags & DSO_COMPATLABEL) {