-__DEFINE_LXSYSCALL3(int, ioctl, int, fd, int, req, va_list, args)
+struct device_meta*
+resolve_device_meta(void* maybe_dev) {
+ if (!valid_device_ref(maybe_dev)) {
+ return NULL;
+ }
+
+ struct device_meta* dm = (struct device_meta*)maybe_dev;
+ unsigned int subtype = dm->magic ^ DEV_STRUCT_MAGIC_MASK;
+
+ switch (subtype)
+ {
+ case DEV_STRUCT:
+ case DEV_CAT:
+ return dm;
+
+ case DEV_ALIAS: {
+ struct device_meta* aliased_dm = dm;
+
+ while(valid_device_subtype_ref(aliased_dm, DEV_ALIAS)) {
+ aliased_dm = to_aliasdev(aliased_dm)->alias;
+ }
+
+ return aliased_dm;
+ }
+ default:
+ return NULL;
+ }
+}
+
+struct device*
+resolve_device(void* maybe_dev) {
+ struct device_meta* dm = resolve_device_meta(maybe_dev);
+
+ if (!valid_device_subtype_ref(dm, DEV_STRUCT)) {
+ return NULL;
+ }
+
+ return to_dev(dm);
+}
+
+void
+device_alert_poller(struct device* dev, int poll_evt)
+{
+ dev->poll_evflags = poll_evt;
+ iopoll_wake_pollers(&dev->pollers);
+}
+
+__DEFINE_LXSYSCALL3(int, ioctl, int, fd, int, req, sc_va_list, _args)