- /* only allow one patcher of ptrace */
- if (old_ptrace == (sy_call_t *) ptrace) {
- callp->sy_call = (sy_call_t *) new_ptrace;
+ lck_mtx_lock_spin(&devsw_lock_list_mtx);
+retry:
+ TAILQ_FOREACH(tmplock, &devsw_locks, dl_list) {
+ if (tmplock->dl_dev == dev && tmplock->dl_mode == mode) {
+ res = msleep(tmplock, &devsw_lock_list_mtx, PVFS, "devsw_lock", NULL);
+ assert(res == 0);
+ goto retry;
+ }
+ }
+
+ TAILQ_INSERT_TAIL(&devsw_locks, newlock, dl_list);
+ lck_mtx_unlock(&devsw_lock_list_mtx);
+
+}
+void
+devsw_unlock(dev_t dev, int mode)
+{
+ devsw_lock_t tmplock;
+
+ assert(0 <= major(dev) && major(dev) < nchrdev);
+
+ lck_mtx_lock_spin(&devsw_lock_list_mtx);
+
+ TAILQ_FOREACH(tmplock, &devsw_locks, dl_list) {
+ if (tmplock->dl_dev == dev && tmplock->dl_mode == mode) {
+ break;
+ }