Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/geom_dev.c
Show First 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | g_dev_print(void) | ||||
LIST_FOREACH(gp, &g_dev_class.geom, geom) { | LIST_FOREACH(gp, &g_dev_class.geom, geom) { | ||||
printf("%s%s", p, gp->name); | printf("%s%s", p, gp->name); | ||||
p = " "; | p = " "; | ||||
} | } | ||||
printf("\n"); | printf("\n"); | ||||
} | } | ||||
static void | static void | ||||
g_dev_attrchanged(struct g_consumer *cp, const char *attr) | g_dev_set_physpath(struct g_consumer *cp) | ||||
{ | { | ||||
struct g_dev_softc *sc; | struct g_dev_softc *sc; | ||||
struct cdev *dev; | |||||
char buf[SPECNAMELEN + 6]; | |||||
sc = cp->private; | |||||
if (strcmp(attr, "GEOM::media") == 0) { | |||||
dev = sc->sc_dev; | |||||
snprintf(buf, sizeof(buf), "cdev=%s", dev->si_name); | |||||
devctl_notify_f("DEVFS", "CDEV", "MEDIACHANGE", buf, M_WAITOK); | |||||
devctl_notify_f("GEOM", "DEV", "MEDIACHANGE", buf, M_WAITOK); | |||||
dev = sc->sc_alias; | |||||
if (dev != NULL) { | |||||
snprintf(buf, sizeof(buf), "cdev=%s", dev->si_name); | |||||
devctl_notify_f("DEVFS", "CDEV", "MEDIACHANGE", buf, | |||||
M_WAITOK); | |||||
devctl_notify_f("GEOM", "DEV", "MEDIACHANGE", buf, | |||||
M_WAITOK); | |||||
} | |||||
return; | |||||
} | |||||
if (strcmp(attr, "GEOM::physpath") != 0) | |||||
return; | |||||
if (g_access(cp, 1, 0, 0) == 0) { | |||||
char *physpath; | char *physpath; | ||||
int error, physpath_len; | int error, physpath_len; | ||||
if (g_access(cp, 1, 0, 0) != 0) | |||||
return; | |||||
sc = cp->private; | |||||
physpath_len = MAXPATHLEN; | physpath_len = MAXPATHLEN; | ||||
physpath = g_malloc(physpath_len, M_WAITOK|M_ZERO); | physpath = g_malloc(physpath_len, M_WAITOK|M_ZERO); | ||||
error = | error = g_io_getattr("GEOM::physpath", cp, &physpath_len, physpath); | ||||
g_io_getattr("GEOM::physpath", cp, &physpath_len, physpath); | |||||
g_access(cp, -1, 0, 0); | g_access(cp, -1, 0, 0); | ||||
if (error == 0 && strlen(physpath) != 0) { | if (error == 0 && strlen(physpath) != 0) { | ||||
struct cdev *old_alias_dev; | struct cdev *dev, *old_alias_dev; | ||||
struct cdev **alias_devp; | struct cdev **alias_devp; | ||||
dev = sc->sc_dev; | dev = sc->sc_dev; | ||||
old_alias_dev = sc->sc_alias; | old_alias_dev = sc->sc_alias; | ||||
alias_devp = (struct cdev **)&sc->sc_alias; | alias_devp = (struct cdev **)&sc->sc_alias; | ||||
make_dev_physpath_alias(MAKEDEV_WAITOK, alias_devp, | make_dev_physpath_alias(MAKEDEV_WAITOK, alias_devp, dev, | ||||
dev, old_alias_dev, physpath); | old_alias_dev, physpath); | ||||
} else if (sc->sc_alias) { | } else if (sc->sc_alias) { | ||||
destroy_dev((struct cdev *)sc->sc_alias); | destroy_dev((struct cdev *)sc->sc_alias); | ||||
sc->sc_alias = NULL; | sc->sc_alias = NULL; | ||||
} | } | ||||
g_free(physpath); | g_free(physpath); | ||||
} | |||||
static void | |||||
g_dev_set_media(struct g_consumer *cp) | |||||
{ | |||||
struct g_dev_softc *sc; | |||||
struct cdev *dev; | |||||
char buf[SPECNAMELEN + 6]; | |||||
sc = cp->private; | |||||
dev = sc->sc_dev; | |||||
snprintf(buf, sizeof(buf), "cdev=%s", dev->si_name); | |||||
devctl_notify_f("DEVFS", "CDEV", "MEDIACHANGE", buf, M_WAITOK); | |||||
devctl_notify_f("GEOM", "DEV", "MEDIACHANGE", buf, M_WAITOK); | |||||
dev = sc->sc_alias; | |||||
if (dev != NULL) { | |||||
snprintf(buf, sizeof(buf), "cdev=%s", dev->si_name); | |||||
devctl_notify_f("DEVFS", "CDEV", "MEDIACHANGE", buf, M_WAITOK); | |||||
devctl_notify_f("GEOM", "DEV", "MEDIACHANGE", buf, M_WAITOK); | |||||
} | |||||
} | |||||
static void | |||||
g_dev_attrchanged(struct g_consumer *cp, const char *attr) | |||||
{ | |||||
if (strcmp(attr, "GEOM::media") == 0) { | |||||
g_dev_set_media(cp); | |||||
return; | |||||
} | |||||
if (strcmp(attr, "GEOM::physpath") == 0) { | |||||
g_dev_set_physpath(cp); | |||||
return; | |||||
} | } | ||||
} | } | ||||
struct g_provider * | struct g_provider * | ||||
g_dev_getprovider(struct cdev *dev) | g_dev_getprovider(struct cdev *dev) | ||||
{ | { | ||||
struct g_consumer *cp; | struct g_consumer *cp; | ||||
▲ Show 20 Lines • Show All 430 Lines • Show Last 20 Lines |