]>
git.proxmox.com Git - systemd.git/blob - src/libudev/libudev-device-private.c
2 This file is part of systemd.
4 Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
5 Copyright 2015 Tom Gundersen <teg@jklm.no>
7 systemd is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
12 systemd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 #include "device-private.h"
24 #include "libudev-device-internal.h"
25 #include "libudev-private.h"
27 int udev_device_tag_index(struct udev_device
*udev_device
, struct udev_device
*udev_device_old
, bool add
) {
28 sd_device
*device_old
= NULL
;
34 device_old
= udev_device_old
->device
;
36 r
= device_tag_index(udev_device
->device
, device_old
, add
);
43 int udev_device_update_db(struct udev_device
*udev_device
) {
48 r
= device_update_db(udev_device
->device
);
55 int udev_device_delete_db(struct udev_device
*udev_device
) {
60 r
= device_delete_db(udev_device
->device
);
67 int udev_device_get_ifindex(struct udev_device
*udev_device
) {
72 r
= sd_device_get_ifindex(udev_device
->device
, &ifindex
);
79 const char *udev_device_get_devpath_old(struct udev_device
*udev_device
) {
80 const char *devpath_old
= NULL
;
85 r
= sd_device_get_property_value(udev_device
->device
, "DEVPATH_OLD", &devpath_old
);
86 if (r
< 0 && r
!= -ENOENT
) {
94 mode_t
udev_device_get_devnode_mode(struct udev_device
*udev_device
) {
100 r
= device_get_devnode_mode(udev_device
->device
, &mode
);
109 uid_t
udev_device_get_devnode_uid(struct udev_device
*udev_device
) {
115 r
= device_get_devnode_uid(udev_device
->device
, &uid
);
124 gid_t
udev_device_get_devnode_gid(struct udev_device
*udev_device
) {
130 r
= device_get_devnode_gid(udev_device
->device
, &gid
);
139 void udev_device_ensure_usec_initialized(struct udev_device
*udev_device
, struct udev_device
*udev_device_old
) {
140 sd_device
*device_old
= NULL
;
145 device_old
= udev_device_old
->device
;
147 device_ensure_usec_initialized(udev_device
->device
, device_old
);
150 char **udev_device_get_properties_envp(struct udev_device
*udev_device
) {
156 r
= device_get_properties_strv(udev_device
->device
, &envp
);
165 ssize_t
udev_device_get_properties_monitor_buf(struct udev_device
*udev_device
, const char **buf
) {
173 r
= device_get_properties_nulstr(udev_device
->device
, (const uint8_t **)&nulstr
, &len
);
182 int udev_device_get_devlink_priority(struct udev_device
*udev_device
) {
187 r
= device_get_devlink_priority(udev_device
->device
, &priority
);
194 int udev_device_get_watch_handle(struct udev_device
*udev_device
) {
199 r
= device_get_watch_handle(udev_device
->device
, &handle
);
206 void udev_device_set_is_initialized(struct udev_device
*udev_device
) {
209 device_set_is_initialized(udev_device
->device
);
212 int udev_device_rename(struct udev_device
*udev_device
, const char *name
) {
217 r
= device_rename(udev_device
->device
, name
);
224 struct udev_device
*udev_device_shallow_clone(struct udev_device
*old_device
) {
225 struct udev_device
*device
;
230 device
= udev_device_new(old_device
->udev
);
234 r
= device_shallow_clone(old_device
->device
, &device
->device
);
236 udev_device_unref(device
);
244 struct udev_device
*udev_device_clone_with_db(struct udev_device
*udev_device_old
) {
245 struct udev_device
*udev_device
;
248 assert(udev_device_old
);
250 udev_device
= udev_device_new(udev_device_old
->udev
);
254 r
= device_clone_with_db(udev_device_old
->device
, &udev_device
->device
);
256 udev_device_unref(udev_device
);
264 struct udev_device
*udev_device_new_from_nulstr(struct udev
*udev
, char *nulstr
, ssize_t buflen
) {
265 struct udev_device
*device
;
268 device
= udev_device_new(udev
);
272 r
= device_new_from_nulstr(&device
->device
, (uint8_t*)nulstr
, buflen
);
274 udev_device_unref(device
);
282 struct udev_device
*udev_device_new_from_synthetic_event(struct udev
*udev
, const char *syspath
, const char *action
) {
283 struct udev_device
*device
;
286 device
= udev_device_new(udev
);
290 r
= device_new_from_synthetic_event(&device
->device
, syspath
, action
);
292 udev_device_unref(device
);
300 int udev_device_copy_properties(struct udev_device
*udev_device_dst
, struct udev_device
*udev_device_src
) {
303 assert(udev_device_dst
);
304 assert(udev_device_src
);
306 r
= device_copy_properties(udev_device_dst
->device
, udev_device_src
->device
);
313 const char *udev_device_get_id_filename(struct udev_device
*udev_device
) {
314 const char *filename
;
319 r
= device_get_id_filename(udev_device
->device
, &filename
);
328 int udev_device_set_watch_handle(struct udev_device
*udev_device
, int handle
) {
332 device_set_watch_handle(udev_device
->device
, handle
);
337 void udev_device_set_db_persist(struct udev_device
*udev_device
) {
340 device_set_db_persist(udev_device
->device
);
343 int udev_device_set_devlink_priority(struct udev_device
*udev_device
, int priority
) {
346 device_set_devlink_priority(udev_device
->device
, priority
);
351 int udev_device_add_devlink(struct udev_device
*udev_device
, const char *devlink
) {
356 r
= device_add_devlink(udev_device
->device
, devlink
);
363 int udev_device_add_property(struct udev_device
*udev_device
, const char *property
, const char *value
) {
368 r
= device_add_property(udev_device
->device
, property
, value
);
375 int udev_device_add_tag(struct udev_device
*udev_device
, const char *tag
) {
380 r
= device_add_tag(udev_device
->device
, tag
);
387 void udev_device_remove_tag(struct udev_device
*udev_device
, const char *tag
) {
390 device_remove_tag(udev_device
->device
, tag
);
393 void udev_device_cleanup_tags_list(struct udev_device
*udev_device
) {
396 device_cleanup_tags(udev_device
->device
);
399 void udev_device_cleanup_devlinks_list(struct udev_device
*udev_device
) {
402 device_cleanup_devlinks(udev_device
->device
);
405 void udev_device_set_info_loaded(struct udev_device
*udev_device
) {
408 device_seal(udev_device
->device
);
411 void udev_device_read_db(struct udev_device
*udev_device
) {
414 device_read_db_force(udev_device
->device
);