]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/libudev/libudev-device.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
7 #include <linux/sockios.h>
14 #include <sys/ioctl.h>
15 #include <sys/socket.h>
20 #include "sd-device.h"
22 #include "alloc-util.h"
23 #include "device-private.h"
24 #include "device-util.h"
25 #include "libudev-device-internal.h"
26 #include "libudev-list-internal.h"
27 #include "parse-util.h"
28 #include "time-util.h"
31 * SECTION:libudev-device
32 * @short_description: kernel sys devices
34 * Representation of kernel sys devices. Devices are uniquely identified
35 * by their syspath, every device has exactly one path in the kernel sys
36 * filesystem. Devices usually belong to a kernel subsystem, and have
37 * a unique name inside that subsystem.
43 * Opaque object representing one kernel sys device.
48 /* real device object */
54 struct udev_device
*parent
;
57 struct udev_list
*properties
;
58 uint64_t properties_generation
;
59 struct udev_list
*all_tags
, *current_tags
;
60 uint64_t all_tags_generation
, current_tags_generation
;
61 struct udev_list
*devlinks
;
62 uint64_t devlinks_generation
;
63 bool properties_read
:1;
65 bool current_tags_read
:1;
67 struct udev_list
*sysattrs
;
72 * udev_device_get_seqnum:
73 * @udev_device: udev device
75 * This is only valid if the device was received through a monitor. Devices read from
76 * sys do not have a sequence number.
78 * Returns: the kernel event sequence number, or 0 if there is no sequence number available.
80 _public_
unsigned long long udev_device_get_seqnum(struct udev_device
*udev_device
) {
83 assert_return_errno(udev_device
, 0, EINVAL
);
85 if (device_get_seqnum(udev_device
->device
, &seqnum
) < 0)
92 * udev_device_get_devnum:
93 * @udev_device: udev device
95 * Get the device major/minor number.
97 * Returns: the dev_t number.
99 _public_ dev_t
udev_device_get_devnum(struct udev_device
*udev_device
) {
103 assert_return_errno(udev_device
, makedev(0, 0), EINVAL
);
105 r
= sd_device_get_devnum(udev_device
->device
, &devnum
);
107 return makedev(0, 0);
109 return_with_errno(makedev(0, 0), r
);
115 * udev_device_get_driver:
116 * @udev_device: udev device
118 * Get the kernel driver name.
120 * Returns: the driver name string, or #NULL if there is no driver attached.
122 _public_
const char *udev_device_get_driver(struct udev_device
*udev_device
) {
126 assert_return_errno(udev_device
, NULL
, EINVAL
);
128 r
= sd_device_get_driver(udev_device
->device
, &driver
);
130 return_with_errno(NULL
, r
);
136 * udev_device_get_devtype:
137 * @udev_device: udev device
139 * Retrieve the devtype string of the udev device.
141 * Returns: the devtype name of the udev device, or #NULL if it cannot be determined
143 _public_
const char *udev_device_get_devtype(struct udev_device
*udev_device
) {
147 assert_return_errno(udev_device
, NULL
, EINVAL
);
149 r
= sd_device_get_devtype(udev_device
->device
, &devtype
);
153 return_with_errno(NULL
, r
);
159 * udev_device_get_subsystem:
160 * @udev_device: udev device
162 * Retrieve the subsystem string of the udev device. The string does not
165 * Returns: the subsystem name of the udev device, or #NULL if it cannot be determined
167 _public_
const char *udev_device_get_subsystem(struct udev_device
*udev_device
) {
168 const char *subsystem
;
171 assert_return_errno(udev_device
, NULL
, EINVAL
);
173 r
= sd_device_get_subsystem(udev_device
->device
, &subsystem
);
175 return_with_errno(NULL
, r
);
181 * udev_device_get_property_value:
182 * @udev_device: udev device
183 * @key: property name
185 * Get the value of a given property.
187 * Returns: the property string, or #NULL if there is no such property.
189 _public_
const char *udev_device_get_property_value(struct udev_device
*udev_device
, const char *key
) {
193 assert_return_errno(udev_device
&& key
, NULL
, EINVAL
);
195 r
= sd_device_get_property_value(udev_device
->device
, key
, &value
);
197 return_with_errno(NULL
, r
);
202 struct udev_device
*udev_device_new(struct udev
*udev
, sd_device
*device
) {
203 _cleanup_(udev_list_freep
) struct udev_list
*properties
= NULL
, *all_tags
= NULL
, *current_tags
= NULL
, *sysattrs
= NULL
, *devlinks
= NULL
;
204 struct udev_device
*udev_device
;
208 properties
= udev_list_new(true);
210 return_with_errno(NULL
, ENOMEM
);
211 all_tags
= udev_list_new(true);
213 return_with_errno(NULL
, ENOMEM
);
214 current_tags
= udev_list_new(true);
216 return_with_errno(NULL
, ENOMEM
);
217 sysattrs
= udev_list_new(true);
219 return_with_errno(NULL
, ENOMEM
);
220 devlinks
= udev_list_new(true);
222 return_with_errno(NULL
, ENOMEM
);
224 udev_device
= new(struct udev_device
, 1);
226 return_with_errno(NULL
, ENOMEM
);
228 *udev_device
= (struct udev_device
) {
231 .device
= sd_device_ref(device
),
232 .properties
= TAKE_PTR(properties
),
233 .all_tags
= TAKE_PTR(all_tags
),
234 .current_tags
= TAKE_PTR(current_tags
),
235 .sysattrs
= TAKE_PTR(sysattrs
),
236 .devlinks
= TAKE_PTR(devlinks
),
243 * udev_device_new_from_syspath:
244 * @udev: udev library context
245 * @syspath: sys device path including sys directory
247 * Create new udev device, and fill in information from the sys
248 * device and the udev database entry. The syspath is the absolute
249 * path to the device, including the sys mount point.
251 * The initial refcount is 1, and needs to be decremented to
252 * release the resources of the udev device.
254 * Returns: a new udev device, or #NULL, if it does not exist
256 _public_
struct udev_device
*udev_device_new_from_syspath(struct udev
*udev
, const char *syspath
) {
257 _cleanup_(sd_device_unrefp
) sd_device
*device
= NULL
;
260 r
= sd_device_new_from_syspath(&device
, syspath
);
262 return_with_errno(NULL
, r
);
264 return udev_device_new(udev
, device
);
268 * udev_device_new_from_devnum:
269 * @udev: udev library context
270 * @type: char or block device
271 * @devnum: device major/minor number
273 * Create new udev device, and fill in information from the sys
274 * device and the udev database entry. The device is looked-up
275 * by its major/minor number and type. Character and block device
276 * numbers are not unique across the two types.
278 * The initial refcount is 1, and needs to be decremented to
279 * release the resources of the udev device.
281 * Returns: a new udev device, or #NULL, if it does not exist
283 _public_
struct udev_device
*udev_device_new_from_devnum(struct udev
*udev
, char type
, dev_t devnum
) {
284 _cleanup_(sd_device_unrefp
) sd_device
*device
= NULL
;
287 r
= sd_device_new_from_devnum(&device
, type
, devnum
);
289 return_with_errno(NULL
, r
);
291 return udev_device_new(udev
, device
);
295 * udev_device_new_from_device_id:
296 * @udev: udev library context
297 * @id: text string identifying a kernel device
299 * Create new udev device, and fill in information from the sys
300 * device and the udev database entry. The device is looked-up
301 * by a special string:
302 * b8:2 - block device major:minor
303 * c128:1 - char device major:minor
304 * n3 - network device ifindex
305 * +sound:card29 - kernel driver core subsystem:device name
307 * The initial refcount is 1, and needs to be decremented to
308 * release the resources of the udev device.
310 * Returns: a new udev device, or #NULL, if it does not exist
312 _public_
struct udev_device
*udev_device_new_from_device_id(struct udev
*udev
, const char *id
) {
313 _cleanup_(sd_device_unrefp
) sd_device
*device
= NULL
;
316 r
= sd_device_new_from_device_id(&device
, id
);
318 return_with_errno(NULL
, r
);
320 return udev_device_new(udev
, device
);
324 * udev_device_new_from_subsystem_sysname:
325 * @udev: udev library context
326 * @subsystem: the subsystem of the device
327 * @sysname: the name of the device
329 * Create new udev device, and fill in information from the sys device
330 * and the udev database entry. The device is looked up by the subsystem
331 * and name string of the device, like "mem" / "zero", or "block" / "sda".
333 * The initial refcount is 1, and needs to be decremented to
334 * release the resources of the udev device.
336 * Returns: a new udev device, or #NULL, if it does not exist
338 _public_
struct udev_device
*udev_device_new_from_subsystem_sysname(struct udev
*udev
, const char *subsystem
, const char *sysname
) {
339 _cleanup_(sd_device_unrefp
) sd_device
*device
= NULL
;
342 r
= sd_device_new_from_subsystem_sysname(&device
, subsystem
, sysname
);
344 return_with_errno(NULL
, r
);
346 return udev_device_new(udev
, device
);
350 * udev_device_new_from_environment
351 * @udev: udev library context
353 * Create new udev device, and fill in information from the
354 * current process environment. This only works reliable if
355 * the process is called from a udev rule. It is usually used
356 * for tools executed from IMPORT= rules.
358 * The initial refcount is 1, and needs to be decremented to
359 * release the resources of the udev device.
361 * Returns: a new udev device, or #NULL, if it does not exist
363 _public_
struct udev_device
*udev_device_new_from_environment(struct udev
*udev
) {
364 _cleanup_(sd_device_unrefp
) sd_device
*device
= NULL
;
367 r
= device_new_from_strv(&device
, environ
);
369 return_with_errno(NULL
, r
);
371 return udev_device_new(udev
, device
);
374 static struct udev_device
*device_new_from_parent(struct udev_device
*child
) {
378 assert_return_errno(child
, NULL
, EINVAL
);
380 r
= sd_device_get_parent(child
->device
, &parent
);
382 return_with_errno(NULL
, r
);
384 return udev_device_new(child
->udev
, parent
);
388 * udev_device_get_parent:
389 * @udev_device: the device to start searching from
391 * Find the next parent device, and fill in information from the sys
392 * device and the udev database entry.
394 * Returned device is not referenced. It is attached to the child
395 * device, and will be cleaned up when the child device is cleaned up.
397 * It is not necessarily just the upper level directory, empty or not
398 * recognized sys directories are ignored.
400 * It can be called as many times as needed, without caring about
403 * Returns: a new udev device, or #NULL, if it no parent exist.
405 _public_
struct udev_device
*udev_device_get_parent(struct udev_device
*udev_device
) {
406 assert_return_errno(udev_device
, NULL
, EINVAL
);
408 if (!udev_device
->parent_set
) {
409 udev_device
->parent_set
= true;
410 udev_device
->parent
= device_new_from_parent(udev_device
);
413 /* TODO: errno will differ here in case parent == NULL */
414 return udev_device
->parent
;
418 * udev_device_get_parent_with_subsystem_devtype:
419 * @udev_device: udev device to start searching from
420 * @subsystem: the subsystem of the device
421 * @devtype: the type (DEVTYPE) of the device
423 * Find the next parent device, with a matching subsystem and devtype
424 * value, and fill in information from the sys device and the udev
427 * If devtype is #NULL, only subsystem is checked, and any devtype will
430 * Returned device is not referenced. It is attached to the child
431 * device, and will be cleaned up when the child device is cleaned up.
433 * It can be called as many times as needed, without caring about
436 * Returns: a new udev device, or #NULL if no matching parent exists.
438 _public_
struct udev_device
*udev_device_get_parent_with_subsystem_devtype(struct udev_device
*udev_device
, const char *subsystem
, const char *devtype
) {
442 assert_return_errno(udev_device
, NULL
, EINVAL
);
444 /* this relies on the fact that finding the subdevice of a parent or the
445 parent of a subdevice commute */
447 /* first find the correct sd_device */
448 r
= sd_device_get_parent_with_subsystem_devtype(udev_device
->device
, subsystem
, devtype
, &parent
);
450 return_with_errno(NULL
, r
);
452 /* then walk the chain of udev_device parents until the corresponding
454 while ((udev_device
= udev_device_get_parent(udev_device
)))
455 if (udev_device
->device
== parent
)
458 return_with_errno(NULL
, ENOENT
);
462 * udev_device_get_udev:
463 * @udev_device: udev device
465 * Retrieve the udev library context the device was created with.
467 * Returns: the udev library context
469 _public_
struct udev
*udev_device_get_udev(struct udev_device
*udev_device
) {
470 assert_return_errno(udev_device
, NULL
, EINVAL
);
472 return udev_device
->udev
;
475 static struct udev_device
*udev_device_free(struct udev_device
*udev_device
) {
478 sd_device_unref(udev_device
->device
);
479 udev_device_unref(udev_device
->parent
);
481 udev_list_free(udev_device
->properties
);
482 udev_list_free(udev_device
->sysattrs
);
483 udev_list_free(udev_device
->all_tags
);
484 udev_list_free(udev_device
->current_tags
);
485 udev_list_free(udev_device
->devlinks
);
487 return mfree(udev_device
);
492 * @udev_device: udev device
494 * Take a reference of a udev device.
496 * Returns: the passed udev device
501 * @udev_device: udev device
503 * Drop a reference of a udev device. If the refcount reaches zero,
504 * the resources of the device will be released.
508 DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(struct udev_device
, udev_device
, udev_device_free
);
511 * udev_device_get_devpath:
512 * @udev_device: udev device
514 * Retrieve the kernel devpath value of the udev device. The path
515 * does not contain the sys mount point, and starts with a '/'.
517 * Returns: the devpath of the udev device
519 _public_
const char *udev_device_get_devpath(struct udev_device
*udev_device
) {
523 assert_return_errno(udev_device
, NULL
, EINVAL
);
525 r
= sd_device_get_devpath(udev_device
->device
, &devpath
);
527 return_with_errno(NULL
, r
);
533 * udev_device_get_syspath:
534 * @udev_device: udev device
536 * Retrieve the sys path of the udev device. The path is an
537 * absolute path and starts with the sys mount point.
539 * Returns: the sys path of the udev device
541 _public_
const char *udev_device_get_syspath(struct udev_device
*udev_device
) {
545 assert_return_errno(udev_device
, NULL
, EINVAL
);
547 r
= sd_device_get_syspath(udev_device
->device
, &syspath
);
549 return_with_errno(NULL
, r
);
555 * udev_device_get_sysname:
556 * @udev_device: udev device
558 * Get the kernel device name in /sys.
560 * Returns: the name string of the device
562 _public_
const char *udev_device_get_sysname(struct udev_device
*udev_device
) {
566 assert_return_errno(udev_device
, NULL
, EINVAL
);
568 r
= sd_device_get_sysname(udev_device
->device
, &sysname
);
570 return_with_errno(NULL
, r
);
576 * udev_device_get_sysnum:
577 * @udev_device: udev device
579 * Get the instance number of the device.
581 * Returns: the trailing number string of the device name
583 _public_
const char *udev_device_get_sysnum(struct udev_device
*udev_device
) {
587 assert_return_errno(udev_device
, NULL
, EINVAL
);
589 r
= sd_device_get_sysnum(udev_device
->device
, &sysnum
);
593 return_with_errno(NULL
, r
);
599 * udev_device_get_devnode:
600 * @udev_device: udev device
602 * Retrieve the device node file name belonging to the udev device.
603 * The path is an absolute path, and starts with the device directory.
605 * Returns: the device node file name of the udev device, or #NULL if no device node exists
607 _public_
const char *udev_device_get_devnode(struct udev_device
*udev_device
) {
611 assert_return_errno(udev_device
, NULL
, EINVAL
);
613 r
= sd_device_get_devname(udev_device
->device
, &devnode
);
615 return_with_errno(NULL
, r
);
621 * udev_device_get_devlinks_list_entry:
622 * @udev_device: udev device
624 * Retrieve the list of device links pointing to the device file of
625 * the udev device. The next list entry can be retrieved with
626 * udev_list_entry_get_next(), which returns #NULL if no more entries exist.
627 * The devlink path can be retrieved from the list entry by
628 * udev_list_entry_get_name(). The path is an absolute path, and starts with
629 * the device directory.
631 * Returns: the first entry of the device node link list
633 _public_
struct udev_list_entry
*udev_device_get_devlinks_list_entry(struct udev_device
*udev_device
) {
634 assert_return_errno(udev_device
, NULL
, EINVAL
);
636 if (device_get_devlinks_generation(udev_device
->device
) != udev_device
->devlinks_generation
||
637 !udev_device
->devlinks_read
) {
640 udev_list_cleanup(udev_device
->devlinks
);
642 FOREACH_DEVICE_DEVLINK(udev_device
->device
, devlink
)
643 if (!udev_list_entry_add(udev_device
->devlinks
, devlink
, NULL
))
644 return_with_errno(NULL
, ENOMEM
);
646 udev_device
->devlinks_read
= true;
647 udev_device
->devlinks_generation
= device_get_devlinks_generation(udev_device
->device
);
650 return udev_list_get_entry(udev_device
->devlinks
);
654 * udev_device_get_event_properties_entry:
655 * @udev_device: udev device
657 * Retrieve the list of key/value device properties of the udev
658 * device. The next list entry can be retrieved with udev_list_entry_get_next(),
659 * which returns #NULL if no more entries exist. The property name
660 * can be retrieved from the list entry by udev_list_entry_get_name(),
661 * the property value by udev_list_entry_get_value().
663 * Returns: the first entry of the property list
665 _public_
struct udev_list_entry
*udev_device_get_properties_list_entry(struct udev_device
*udev_device
) {
666 assert_return_errno(udev_device
, NULL
, EINVAL
);
668 if (device_get_properties_generation(udev_device
->device
) != udev_device
->properties_generation
||
669 !udev_device
->properties_read
) {
670 const char *key
, *value
;
672 udev_list_cleanup(udev_device
->properties
);
674 FOREACH_DEVICE_PROPERTY(udev_device
->device
, key
, value
)
675 if (!udev_list_entry_add(udev_device
->properties
, key
, value
))
676 return_with_errno(NULL
, ENOMEM
);
678 udev_device
->properties_read
= true;
679 udev_device
->properties_generation
= device_get_properties_generation(udev_device
->device
);
682 return udev_list_get_entry(udev_device
->properties
);
686 * udev_device_get_action:
687 * @udev_device: udev device
689 * This is only valid if the device was received through a monitor. Devices read from
690 * sys do not have an action string. Usual actions are: add, remove, change, move,
693 * Returns: the kernel action value, or #NULL if there is no action value available.
695 _public_
const char *udev_device_get_action(struct udev_device
*udev_device
) {
698 assert_return_errno(udev_device
, NULL
, EINVAL
);
700 if (device_get_action(udev_device
->device
, &action
) < 0)
703 return device_action_to_string(action
);
707 * udev_device_get_usec_since_initialized:
708 * @udev_device: udev device
710 * Return the number of microseconds passed since udev set up the
711 * device for the first time.
713 * This is only implemented for devices with need to store properties
714 * in the udev database. All other devices return 0 here.
716 * Returns: the number of microseconds since the device was first seen.
718 _public_
unsigned long long int udev_device_get_usec_since_initialized(struct udev_device
*udev_device
) {
722 assert_return(udev_device
, -EINVAL
);
724 r
= sd_device_get_usec_since_initialized(udev_device
->device
, &ts
);
726 return_with_errno(0, r
);
732 * udev_device_get_sysattr_value:
733 * @udev_device: udev device
734 * @sysattr: attribute name
736 * The retrieved value is cached in the device. Repeated calls will return the same
737 * value and not open the attribute again.
739 * Returns: the content of a sys attribute file, or #NULL if there is no sys attribute value.
741 _public_
const char *udev_device_get_sysattr_value(struct udev_device
*udev_device
, const char *sysattr
) {
745 assert_return_errno(udev_device
, NULL
, EINVAL
);
747 r
= sd_device_get_sysattr_value(udev_device
->device
, sysattr
, &value
);
749 return_with_errno(NULL
, r
);
755 * udev_device_set_sysattr_value:
756 * @udev_device: udev device
757 * @sysattr: attribute name
758 * @value: new value to be set
760 * Update the contents of the sys attribute and the cached value of the device.
762 * Returns: Negative error code on failure or 0 on success.
764 _public_
int udev_device_set_sysattr_value(struct udev_device
*udev_device
, const char *sysattr
, const char *value
) {
767 assert_return(udev_device
, -EINVAL
);
769 r
= sd_device_set_sysattr_value(udev_device
->device
, sysattr
, value
);
777 * udev_device_get_sysattr_list_entry:
778 * @udev_device: udev device
780 * Retrieve the list of available sysattrs, with value being empty;
781 * This just return all available sysfs attributes for a particular
782 * device without reading their values.
784 * Returns: the first entry of the property list
786 _public_
struct udev_list_entry
*udev_device_get_sysattr_list_entry(struct udev_device
*udev_device
) {
787 assert_return_errno(udev_device
, NULL
, EINVAL
);
789 if (!udev_device
->sysattrs_read
) {
792 udev_list_cleanup(udev_device
->sysattrs
);
794 FOREACH_DEVICE_SYSATTR(udev_device
->device
, sysattr
)
795 if (!udev_list_entry_add(udev_device
->sysattrs
, sysattr
, NULL
))
796 return_with_errno(NULL
, ENOMEM
);
798 udev_device
->sysattrs_read
= true;
801 return udev_list_get_entry(udev_device
->sysattrs
);
805 * udev_device_get_is_initialized:
806 * @udev_device: udev device
808 * Check if udev has already handled the device and has set up
809 * device node permissions and context, or has renamed a network
812 * This is only implemented for devices with a device node
813 * or network interfaces. All other devices return 1 here.
815 * Returns: 1 if the device is set up. 0 otherwise.
817 _public_
int udev_device_get_is_initialized(struct udev_device
*udev_device
) {
820 assert_return(udev_device
, -EINVAL
);
822 r
= sd_device_get_is_initialized(udev_device
->device
);
824 return_with_errno(0, r
);
830 * udev_device_get_tags_list_entry:
831 * @udev_device: udev device
833 * Retrieve the list of tags attached to the udev device. The next
834 * list entry can be retrieved with udev_list_entry_get_next(),
835 * which returns #NULL if no more entries exist. The tag string
836 * can be retrieved from the list entry by udev_list_entry_get_name().
838 * Returns: the first entry of the tag list
840 _public_
struct udev_list_entry
*udev_device_get_tags_list_entry(struct udev_device
*udev_device
) {
841 assert_return_errno(udev_device
, NULL
, EINVAL
);
843 if (device_get_tags_generation(udev_device
->device
) != udev_device
->all_tags_generation
||
844 !udev_device
->all_tags_read
) {
847 udev_list_cleanup(udev_device
->all_tags
);
849 FOREACH_DEVICE_TAG(udev_device
->device
, tag
)
850 if (!udev_list_entry_add(udev_device
->all_tags
, tag
, NULL
))
851 return_with_errno(NULL
, ENOMEM
);
853 udev_device
->all_tags_read
= true;
854 udev_device
->all_tags_generation
= device_get_tags_generation(udev_device
->device
);
857 return udev_list_get_entry(udev_device
->all_tags
);
860 _public_
struct udev_list_entry
*udev_device_get_current_tags_list_entry(struct udev_device
*udev_device
) {
861 assert_return_errno(udev_device
, NULL
, EINVAL
);
863 if (device_get_tags_generation(udev_device
->device
) != udev_device
->current_tags_generation
||
864 !udev_device
->current_tags_read
) {
867 udev_list_cleanup(udev_device
->current_tags
);
869 FOREACH_DEVICE_CURRENT_TAG(udev_device
->device
, tag
)
870 if (!udev_list_entry_add(udev_device
->current_tags
, tag
, NULL
))
871 return_with_errno(NULL
, ENOMEM
);
873 udev_device
->current_tags_read
= true;
874 udev_device
->current_tags_generation
= device_get_tags_generation(udev_device
->device
);
877 return udev_list_get_entry(udev_device
->current_tags
);
881 * udev_device_has_tag:
882 * @udev_device: udev device
885 * Check if a given device has a certain tag associated.
887 * Returns: 1 if the tag is found. 0 otherwise.
889 _public_
int udev_device_has_tag(struct udev_device
*udev_device
, const char *tag
) {
890 assert_return(udev_device
, 0);
892 return sd_device_has_tag(udev_device
->device
, tag
) > 0;
895 _public_
int udev_device_has_current_tag(struct udev_device
*udev_device
, const char *tag
) {
896 assert_return(udev_device
, 0);
898 return sd_device_has_current_tag(udev_device
->device
, tag
) > 0;
901 sd_device
*udev_device_get_sd_device(struct udev_device
*udev_device
) {
904 return udev_device
->device
;