2017-11-18 17:14:42 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2016-02-16 20:05:15 +01:00
|
|
|
#pragma once
|
|
|
|
|
2005-04-27 05:59:47 +02:00
|
|
|
/*
|
2018-06-12 17:15:23 +02:00
|
|
|
* Copyright © 2003 Greg Kroah-Hartman <greg@kroah.com>
|
2005-04-27 05:59:47 +02:00
|
|
|
*/
|
|
|
|
|
2003-12-02 09:26:46 +01:00
|
|
|
#include <sys/param.h>
|
2016-03-14 22:44:49 +01:00
|
|
|
#include <sys/sysmacros.h>
|
2015-10-24 22:58:24 +02:00
|
|
|
#include <sys/types.h>
|
2006-01-09 21:18:00 +01:00
|
|
|
|
2009-06-08 21:36:06 +02:00
|
|
|
#include "libudev.h"
|
2018-09-14 21:13:29 +02:00
|
|
|
#include "sd-device.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "sd-netlink.h"
|
|
|
|
|
2018-10-16 22:37:34 +02:00
|
|
|
#include "hashmap.h"
|
2012-04-17 16:05:03 +02:00
|
|
|
#include "label.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "libudev-private.h"
|
|
|
|
#include "macro.h"
|
2012-05-07 13:21:05 +02:00
|
|
|
#include "strv.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "util.h"
|
2005-04-27 05:59:47 +02:00
|
|
|
|
2008-10-16 17:16:58 +02:00
|
|
|
struct udev_event {
|
2012-01-10 01:34:15 +01:00
|
|
|
struct udev_device *dev;
|
|
|
|
struct udev_device *dev_parent;
|
|
|
|
struct udev_device *dev_db;
|
|
|
|
char *name;
|
|
|
|
char *program_result;
|
|
|
|
mode_t mode;
|
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
2018-10-16 22:37:34 +02:00
|
|
|
Hashmap *seclabel_list;
|
2018-10-16 23:11:33 +02:00
|
|
|
Hashmap *run_list;
|
2012-01-10 01:34:15 +01:00
|
|
|
int exec_delay;
|
2012-11-11 20:45:05 +01:00
|
|
|
usec_t birth_usec;
|
2015-06-12 16:31:33 +02:00
|
|
|
sd_netlink *rtnl;
|
2012-01-10 01:34:15 +01:00
|
|
|
unsigned int builtin_run;
|
|
|
|
unsigned int builtin_ret;
|
|
|
|
bool inotify_watch;
|
|
|
|
bool inotify_watch_final;
|
2012-12-31 04:48:44 +01:00
|
|
|
bool group_set;
|
2012-01-10 01:34:15 +01:00
|
|
|
bool group_final;
|
2012-12-31 04:48:44 +01:00
|
|
|
bool owner_set;
|
2012-01-10 01:34:15 +01:00
|
|
|
bool owner_final;
|
|
|
|
bool mode_set;
|
|
|
|
bool mode_final;
|
|
|
|
bool name_final;
|
|
|
|
bool devlink_final;
|
|
|
|
bool run_final;
|
2008-10-16 17:16:58 +02:00
|
|
|
};
|
|
|
|
|
2008-10-18 14:33:37 +02:00
|
|
|
/* udev-rules.c */
|
2008-10-18 19:19:56 +02:00
|
|
|
struct udev_rules;
|
2018-08-22 12:57:32 +02:00
|
|
|
struct udev_rules *udev_rules_new(int resolve_names);
|
2011-12-25 16:37:15 +01:00
|
|
|
struct udev_rules *udev_rules_unref(struct udev_rules *rules);
|
2012-04-16 17:21:22 +02:00
|
|
|
bool udev_rules_check_timestamp(struct udev_rules *rules);
|
2018-10-16 22:37:34 +02:00
|
|
|
int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event,
|
|
|
|
usec_t timeout_usec, usec_t timeout_warn_usec,
|
2018-10-16 23:47:16 +02:00
|
|
|
Hashmap *properties_list);
|
2013-07-07 18:32:34 +02:00
|
|
|
int udev_rules_apply_static_dev_perms(struct udev_rules *rules);
|
2008-10-18 19:19:56 +02:00
|
|
|
|
|
|
|
/* udev-event.c */
|
2009-04-26 13:59:39 +02:00
|
|
|
struct udev_event *udev_event_new(struct udev_device *dev);
|
|
|
|
void udev_event_unref(struct udev_event *event);
|
2017-01-03 20:37:59 +01:00
|
|
|
size_t udev_event_apply_format(struct udev_event *event,
|
|
|
|
const char *src, char *dest, size_t size,
|
|
|
|
bool replace_whitespace);
|
2009-04-26 13:59:39 +02:00
|
|
|
int udev_event_apply_subsys_kernel(struct udev_event *event, const char *string,
|
2012-01-10 01:34:15 +01:00
|
|
|
char *result, size_t maxsize, int read_value);
|
2011-04-20 01:53:03 +02:00
|
|
|
int udev_event_spawn(struct udev_event *event,
|
2014-07-29 15:18:27 +02:00
|
|
|
usec_t timeout_usec,
|
2014-09-11 18:49:04 +02:00
|
|
|
usec_t timeout_warn_usec,
|
2015-06-10 15:20:02 +02:00
|
|
|
bool accept_failure,
|
2015-06-28 23:42:52 +02:00
|
|
|
const char *cmd, char *result, size_t ressize);
|
2014-11-13 20:35:06 +01:00
|
|
|
void udev_event_execute_rules(struct udev_event *event,
|
|
|
|
usec_t timeout_usec, usec_t timeout_warn_usec,
|
2018-10-16 23:47:16 +02:00
|
|
|
Hashmap *properties_list,
|
2015-06-02 17:07:21 +02:00
|
|
|
struct udev_rules *rules);
|
|
|
|
void udev_event_execute_run(struct udev_event *event, usec_t timeout_usec, usec_t timeout_warn_usec);
|
2008-10-18 14:33:37 +02:00
|
|
|
|
2018-08-22 09:25:17 +02:00
|
|
|
/* Cleanup functions */
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_event*, udev_event_unref);
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_rules*, udev_rules_unref);
|