Systemd/src/udev/udev.h

82 lines
2.6 KiB
C
Raw Normal View History

/* SPDX-License-Identifier: GPL-2.0+ */
#pragma once
2005-04-27 05:59:47 +02:00
/*
* Copyright © 2003 Greg Kroah-Hartman <greg@kroah.com>
2005-04-27 05:59:47 +02:00
*/
#include <sys/param.h>
#include <sys/sysmacros.h>
#include <sys/types.h>
2009-06-08 21:36:06 +02:00
#include "libudev.h"
#include "sd-device.h"
#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"
#include "libudev-private.h"
#include "macro.h"
#include "strv.h"
#include "util.h"
2005-04-27 05:59:47 +02:00
2008-10-16 17:16:58 +02:00
struct udev_event {
struct udev_device *dev;
sd_device *dev_parent;
sd_device *dev_db_clone;
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;
Hashmap *run_list;
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;
unsigned builtin_run;
unsigned builtin_ret;
bool inotify_watch;
bool inotify_watch_final;
bool group_set;
bool group_final;
bool owner_set;
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
};
/* udev-rules.c */
struct udev_rules;
2018-08-22 12:57:32 +02:00
struct udev_rules *udev_rules_new(int resolve_names);
struct udev_rules *udev_rules_unref(struct udev_rules *rules);
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,
Hashmap *properties_list);
int udev_rules_apply_static_dev_perms(struct udev_rules *rules);
/* udev-event.c */
struct udev_event *udev_event_new(struct udev_device *dev, int exec_delay, sd_netlink *rtnl);
struct udev_event *udev_event_free(struct udev_event *event);
ssize_t udev_event_apply_format(struct udev_event *event,
const char *src, char *dest, size_t size,
bool replace_whitespace);
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,
usec_t timeout_warn_usec,
bool accept_failure,
const char *cmd, char *result, size_t ressize);
int udev_event_execute_rules(struct udev_event *event,
usec_t timeout_usec, usec_t timeout_warn_usec,
Hashmap *properties_list,
struct udev_rules *rules);
void udev_event_execute_run(struct udev_event *event, usec_t timeout_usec, usec_t timeout_warn_usec);
/* Cleanup functions */
DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_event*, udev_event_free);
DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_rules*, udev_rules_unref);