static int dmioctl(struct dev_ioctl_args *ap) { cdev_t dev = ap->a_head.a_dev; u_long cmd = ap->a_cmd; void *data = ap->a_data; int r, err; prop_dictionary_t dm_dict_in; err = r = 0; aprint_debug("dmioctl called\n"); KKASSERT(data != NULL); if (( r = disk_ioctl_switch(dev, cmd, data)) == ENOTTY) { struct plistref *pref = (struct plistref *) data; /* Check if we were called with NETBSD_DM_IOCTL ioctl otherwise quit. */ if ((r = dm_ioctl_switch(cmd)) != 0) return r; if((r = prop_dictionary_copyin_ioctl(pref, cmd, &dm_dict_in)) != 0) return r; if ((r = dm_check_version(dm_dict_in)) != 0) goto cleanup_exit; /* run ioctl routine */ if ((err = dm_cmd_to_fun(dm_dict_in)) != 0) goto cleanup_exit; cleanup_exit: r = prop_dictionary_copyout_ioctl(pref, cmd, dm_dict_in); prop_object_release(dm_dict_in); } /* * Return the error of the actual command if one one has * happened. Otherwise return 'r' which indicates errors * that occurred during helper operations. */ return (err != 0)?err:r; }
static int dmioctl(dev_t dev, const u_long cmd, void *data, int flag, struct lwp *l) { int r; prop_dictionary_t dm_dict_in; r = 0; aprint_debug("dmioctl called\n"); KASSERT(data != NULL); if (( r = disk_ioctl_switch(dev, cmd, data)) == ENOTTY) { struct plistref *pref = (struct plistref *) data; /* Check if we were called with NETBSD_DM_IOCTL ioctl otherwise quit. */ if ((r = dm_ioctl_switch(cmd)) != 0) return r; if((r = prop_dictionary_copyin_ioctl(pref, cmd, &dm_dict_in)) != 0) return r; if ((r = dm_check_version(dm_dict_in)) != 0) goto cleanup_exit; /* run ioctl routine */ if ((r = dm_cmd_to_fun(dm_dict_in)) != 0) goto cleanup_exit; cleanup_exit: r = prop_dictionary_copyout_ioctl(pref, cmd, dm_dict_in); prop_object_release(dm_dict_in); } return r; }