/*ARGSUSED*/ int devpts_validate(struct sdev_node *dv) { minor_t min; uid_t uid; gid_t gid; timestruc_t now; char *nm = dv->sdev_name; ASSERT(!(dv->sdev_flags & SDEV_STALE)); ASSERT(dv->sdev_state == SDEV_READY); /* validate only READY nodes */ if (dv->sdev_state != SDEV_READY) { sdcmn_err(("dev fs: skipping: node not ready %s(%p)", nm, (void *)dv)); return (SDEV_VTOR_SKIP); } if (devpts_strtol(nm, &min) != 0) { sdcmn_err7(("devpts_validate: not a valid minor: %s\n", nm)); return (SDEV_VTOR_INVALID); } /* * Check if pts driver is attached */ if (ptms_slave_attached() == (major_t)-1) { sdcmn_err7(("devpts_validate: slave not attached\n")); return (SDEV_VTOR_INVALID); } if (ptms_minor_valid(min, &uid, &gid) == 0) { if (ptms_minor_exists(min)) { sdcmn_err7(("devpts_validate: valid in different zone " "%s\n", nm)); return (SDEV_VTOR_SKIP); } else { sdcmn_err7(("devpts_validate: %s not valid pty\n", nm)); return (SDEV_VTOR_INVALID); } } ASSERT(dv->sdev_attr); if (dv->sdev_attr->va_uid != uid || dv->sdev_attr->va_gid != gid) { ASSERT(uid >= 0); ASSERT(gid >= 0); dv->sdev_attr->va_uid = uid; dv->sdev_attr->va_gid = gid; gethrestime(&now); dv->sdev_attr->va_atime = now; dv->sdev_attr->va_mtime = now; dv->sdev_attr->va_ctime = now; sdcmn_err7(("devpts_validate: update uid/gid/times%s\n", nm)); } return (SDEV_VTOR_VALID); }
/* * Validate that a node is up-to-date and correct. * A validator may not update the node state or * contents as a read lock permits entry by * multiple threads. */ int devvt_validate(struct sdev_node *dv) { minor_t min; char *nm = dv->sdev_name; int rval; ASSERT(dv->sdev_state == SDEV_READY); ASSERT(RW_LOCK_HELD(&(dv->sdev_dotdot)->sdev_contents)); /* validate only READY nodes */ if (dv->sdev_state != SDEV_READY) { sdcmn_err(("dev fs: skipping: node not ready %s(%p)", nm, (void *)dv)); return (SDEV_VTOR_SKIP); } if (vt_wc_attached() == (major_t)-1) return (SDEV_VTOR_INVALID); if (strcmp(nm, DEVVT_ACTIVE_NAME) == 0) { char *link = kmem_zalloc(MAXPATHLEN, KM_SLEEP); (void) vt_getactive(link, MAXPATHLEN); rval = (strcmp(link, dv->sdev_symlink) == 0) ? SDEV_VTOR_VALID : SDEV_VTOR_STALE; kmem_free(link, MAXPATHLEN); return (rval); } if (strcmp(nm, DEVVT_CONSUSER_NAME) == 0) { char *link = kmem_zalloc(MAXPATHLEN, KM_SLEEP); (void) vt_getconsuser(link, MAXPATHLEN); rval = (strcmp(link, dv->sdev_symlink) == 0) ? SDEV_VTOR_VALID : SDEV_VTOR_STALE; kmem_free(link, MAXPATHLEN); return (rval); } if (devvt_str2minor(nm, &min) != 0) { return (SDEV_VTOR_INVALID); } if (vt_minor_valid(min) == B_FALSE) return (SDEV_VTOR_INVALID); return (SDEV_VTOR_VALID); }