199ca880aSopenharmony_ci/*** 299ca880aSopenharmony_ci This file is part of systemd. 399ca880aSopenharmony_ci 499ca880aSopenharmony_ci Copyright 2008-2012 Kay Sievers <kay@vrfy.org> 599ca880aSopenharmony_ci 699ca880aSopenharmony_ci systemd is free software; you can redistribute it and/or modify it 799ca880aSopenharmony_ci under the terms of the GNU Lesser General Public License as published by 899ca880aSopenharmony_ci the Free Software Foundation; either version 2.1 of the License, or 999ca880aSopenharmony_ci (at your option) any later version. 1099ca880aSopenharmony_ci 1199ca880aSopenharmony_ci systemd is distributed in the hope that it will be useful, but 1299ca880aSopenharmony_ci WITHOUT ANY WARRANTY; without even the implied warranty of 1399ca880aSopenharmony_ci MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1499ca880aSopenharmony_ci Lesser General Public License for more details. 1599ca880aSopenharmony_ci 1699ca880aSopenharmony_ci You should have received a copy of the GNU Lesser General Public License 1799ca880aSopenharmony_ci along with systemd; If not, see <http://www.gnu.org/licenses/>. 1899ca880aSopenharmony_ci***/ 1999ca880aSopenharmony_ci 2099ca880aSopenharmony_ci#pragma once 2199ca880aSopenharmony_ci 2299ca880aSopenharmony_ci#include <signal.h> 2399ca880aSopenharmony_ci#include <stdint.h> 2499ca880aSopenharmony_ci#include <stdbool.h> 2599ca880aSopenharmony_ci 2699ca880aSopenharmony_ci#include "libudev.h" 2799ca880aSopenharmony_ci#include "macro.h" 2899ca880aSopenharmony_ci#include "util.h" 2999ca880aSopenharmony_ci#include "mkdir.h" 3099ca880aSopenharmony_ci#include "strxcpyx.h" 3199ca880aSopenharmony_ci 3299ca880aSopenharmony_ci#define READ_END 0 3399ca880aSopenharmony_ci#define WRITE_END 1 3499ca880aSopenharmony_ci 3599ca880aSopenharmony_ci/* libudev.c */ 3699ca880aSopenharmony_ciint udev_get_rules_path(struct udev *udev, char **path[], usec_t *ts_usec[]); 3799ca880aSopenharmony_ci 3899ca880aSopenharmony_ci/* libudev-device.c */ 3999ca880aSopenharmony_cistruct udev_device *udev_device_new_from_nulstr(struct udev *udev, char *nulstr, ssize_t buflen); 4099ca880aSopenharmony_cistruct udev_device *udev_device_new_from_synthetic_event(struct udev *udev, const char *syspath, const char *action); 4199ca880aSopenharmony_cistruct udev_device *udev_device_shallow_clone(struct udev_device *old_device); 4299ca880aSopenharmony_cistruct udev_device *udev_device_clone_with_db(struct udev_device *old_device); 4399ca880aSopenharmony_ciint udev_device_copy_properties(struct udev_device *dst, struct udev_device *src); 4499ca880aSopenharmony_cimode_t udev_device_get_devnode_mode(struct udev_device *udev_device); 4599ca880aSopenharmony_ciuid_t udev_device_get_devnode_uid(struct udev_device *udev_device); 4699ca880aSopenharmony_cigid_t udev_device_get_devnode_gid(struct udev_device *udev_device); 4799ca880aSopenharmony_ciint udev_device_rename(struct udev_device *udev_device, const char *new_name); 4899ca880aSopenharmony_ciint udev_device_add_devlink(struct udev_device *udev_device, const char *devlink); 4999ca880aSopenharmony_civoid udev_device_cleanup_devlinks_list(struct udev_device *udev_device); 5099ca880aSopenharmony_ciint udev_device_add_property(struct udev_device *udev_device, const char *key, const char *value); 5199ca880aSopenharmony_cichar **udev_device_get_properties_envp(struct udev_device *udev_device); 5299ca880aSopenharmony_cissize_t udev_device_get_properties_monitor_buf(struct udev_device *udev_device, const char **buf); 5399ca880aSopenharmony_ciconst char *udev_device_get_devpath_old(struct udev_device *udev_device); 5499ca880aSopenharmony_ciconst char *udev_device_get_id_filename(struct udev_device *udev_device); 5599ca880aSopenharmony_civoid udev_device_set_is_initialized(struct udev_device *udev_device); 5699ca880aSopenharmony_ciint udev_device_add_tag(struct udev_device *udev_device, const char *tag); 5799ca880aSopenharmony_civoid udev_device_remove_tag(struct udev_device *udev_device, const char *tag); 5899ca880aSopenharmony_civoid udev_device_cleanup_tags_list(struct udev_device *udev_device); 5999ca880aSopenharmony_ciusec_t udev_device_get_usec_initialized(struct udev_device *udev_device); 6099ca880aSopenharmony_civoid udev_device_ensure_usec_initialized(struct udev_device *udev_device, struct udev_device *old_device); 6199ca880aSopenharmony_ciint udev_device_get_devlink_priority(struct udev_device *udev_device); 6299ca880aSopenharmony_ciint udev_device_set_devlink_priority(struct udev_device *udev_device, int prio); 6399ca880aSopenharmony_ciint udev_device_get_watch_handle(struct udev_device *udev_device); 6499ca880aSopenharmony_ciint udev_device_set_watch_handle(struct udev_device *udev_device, int handle); 6599ca880aSopenharmony_ciint udev_device_get_ifindex(struct udev_device *udev_device); 6699ca880aSopenharmony_civoid udev_device_set_info_loaded(struct udev_device *device); 6799ca880aSopenharmony_cibool udev_device_get_db_persist(struct udev_device *udev_device); 6899ca880aSopenharmony_civoid udev_device_set_db_persist(struct udev_device *udev_device); 6999ca880aSopenharmony_ci 7099ca880aSopenharmony_ci/* libudev-device-private.c */ 7199ca880aSopenharmony_ciint udev_device_update_db(struct udev_device *udev_device); 7299ca880aSopenharmony_ciint udev_device_delete_db(struct udev_device *udev_device); 7399ca880aSopenharmony_ciint udev_device_tag_index(struct udev_device *dev, struct udev_device *dev_old, bool add); 7499ca880aSopenharmony_ci 7599ca880aSopenharmony_ci/* libudev-monitor.c - netlink/unix socket communication */ 7699ca880aSopenharmony_ciint udev_monitor_disconnect(struct udev_monitor *udev_monitor); 7799ca880aSopenharmony_ciint udev_monitor_allow_unicast_sender(struct udev_monitor *udev_monitor, struct udev_monitor *sender); 7899ca880aSopenharmony_ciint udev_monitor_send_device(struct udev_monitor *udev_monitor, 7999ca880aSopenharmony_ci struct udev_monitor *destination, struct udev_device *udev_device); 8099ca880aSopenharmony_cistruct udev_monitor *udev_monitor_new_from_netlink_fd(struct udev *udev, const char *name, int fd); 8199ca880aSopenharmony_ci 8299ca880aSopenharmony_ci/* libudev-list.c */ 8399ca880aSopenharmony_cistruct udev_list_node { 8499ca880aSopenharmony_ci struct udev_list_node *next, *prev; 8599ca880aSopenharmony_ci}; 8699ca880aSopenharmony_cistruct udev_list { 8799ca880aSopenharmony_ci struct udev *udev; 8899ca880aSopenharmony_ci struct udev_list_node node; 8999ca880aSopenharmony_ci struct udev_list_entry **entries; 9099ca880aSopenharmony_ci unsigned int entries_cur; 9199ca880aSopenharmony_ci unsigned int entries_max; 9299ca880aSopenharmony_ci bool unique; 9399ca880aSopenharmony_ci}; 9499ca880aSopenharmony_ci#define UDEV_LIST(list) struct udev_list_node list = { &(list), &(list) } 9599ca880aSopenharmony_civoid udev_list_node_init(struct udev_list_node *list); 9699ca880aSopenharmony_ciint udev_list_node_is_empty(struct udev_list_node *list); 9799ca880aSopenharmony_civoid udev_list_node_append(struct udev_list_node *new, struct udev_list_node *list); 9899ca880aSopenharmony_civoid udev_list_node_remove(struct udev_list_node *entry); 9999ca880aSopenharmony_ci#define udev_list_node_foreach(node, list) \ 10099ca880aSopenharmony_ci for (node = (list)->next; \ 10199ca880aSopenharmony_ci node != list; \ 10299ca880aSopenharmony_ci node = (node)->next) 10399ca880aSopenharmony_ci#define udev_list_node_foreach_safe(node, tmp, list) \ 10499ca880aSopenharmony_ci for (node = (list)->next, tmp = (node)->next; \ 10599ca880aSopenharmony_ci node != list; \ 10699ca880aSopenharmony_ci node = tmp, tmp = (tmp)->next) 10799ca880aSopenharmony_civoid udev_list_init(struct udev *udev, struct udev_list *list, bool unique); 10899ca880aSopenharmony_civoid udev_list_cleanup(struct udev_list *list); 10999ca880aSopenharmony_cistruct udev_list_entry *udev_list_get_entry(struct udev_list *list); 11099ca880aSopenharmony_cistruct udev_list_entry *udev_list_entry_add(struct udev_list *list, const char *name, const char *value); 11199ca880aSopenharmony_civoid udev_list_entry_delete(struct udev_list_entry *entry); 11299ca880aSopenharmony_ciint udev_list_entry_get_num(struct udev_list_entry *list_entry); 11399ca880aSopenharmony_civoid udev_list_entry_set_num(struct udev_list_entry *list_entry, int num); 11499ca880aSopenharmony_ci#define udev_list_entry_foreach_safe(entry, tmp, first) \ 11599ca880aSopenharmony_ci for (entry = first, tmp = udev_list_entry_get_next(entry); \ 11699ca880aSopenharmony_ci entry != NULL; \ 11799ca880aSopenharmony_ci entry = tmp, tmp = udev_list_entry_get_next(tmp)) 11899ca880aSopenharmony_ci 11999ca880aSopenharmony_ci/* libudev-queue.c */ 12099ca880aSopenharmony_ciunsigned long long int udev_get_kernel_seqnum(struct udev *udev); 12199ca880aSopenharmony_ciint udev_queue_read_seqnum(FILE *queue_file, unsigned long long int *seqnum); 12299ca880aSopenharmony_cissize_t udev_queue_read_devpath(FILE *queue_file, char *devpath, size_t size); 12399ca880aSopenharmony_cissize_t udev_queue_skip_devpath(FILE *queue_file); 12499ca880aSopenharmony_ci 12599ca880aSopenharmony_ci/* libudev-queue-private.c */ 12699ca880aSopenharmony_cistruct udev_queue_export *udev_queue_export_new(struct udev *udev); 12799ca880aSopenharmony_cistruct udev_queue_export *udev_queue_export_unref(struct udev_queue_export *udev_queue_export); 12899ca880aSopenharmony_civoid udev_queue_export_cleanup(struct udev_queue_export *udev_queue_export); 12999ca880aSopenharmony_ciint udev_queue_export_device_queued(struct udev_queue_export *udev_queue_export, struct udev_device *udev_device); 13099ca880aSopenharmony_ciint udev_queue_export_device_finished(struct udev_queue_export *udev_queue_export, struct udev_device *udev_device); 13199ca880aSopenharmony_ci 13299ca880aSopenharmony_ci/* libudev-hwdb.c */ 13399ca880aSopenharmony_cibool udev_hwdb_validate(struct udev_hwdb *hwdb); 13499ca880aSopenharmony_ci 13599ca880aSopenharmony_ci/* libudev-util.c */ 13699ca880aSopenharmony_ci#define UTIL_PATH_SIZE 1024 13799ca880aSopenharmony_ci#define UTIL_NAME_SIZE 512 13899ca880aSopenharmony_ci#define UTIL_LINE_SIZE 16384 13999ca880aSopenharmony_ci#define UDEV_ALLOWED_CHARS_INPUT "/ $%?," 14099ca880aSopenharmony_cissize_t util_get_sys_core_link_value(struct udev *udev, const char *slink, const char *syspath, char *value, size_t size); 14199ca880aSopenharmony_ciint util_resolve_sys_link(struct udev *udev, char *syspath, size_t size); 14299ca880aSopenharmony_ciint util_log_priority(const char *priority); 14399ca880aSopenharmony_cisize_t util_path_encode(const char *src, char *dest, size_t size); 14499ca880aSopenharmony_civoid util_remove_trailing_chars(char *path, char c); 14599ca880aSopenharmony_ciint util_replace_whitespace(const char *str, char *to, size_t len); 14699ca880aSopenharmony_ciint util_replace_chars(char *str, const char *white); 14799ca880aSopenharmony_ciunsigned int util_string_hash32(const char *key); 14899ca880aSopenharmony_ciuint64_t util_string_bloom64(const char *str); 14999ca880aSopenharmony_ci 15099ca880aSopenharmony_ci/* libudev-util-private.c */ 15199ca880aSopenharmony_ciint util_resolve_subsys_kernel(struct udev *udev, const char *string, char *result, size_t maxsize, int read_value); 152