chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
libudev: device - read database only when needed
[elogind.git]
/
udev
/
udevadm-trigger.c
diff --git
a/udev/udevadm-trigger.c
b/udev/udevadm-trigger.c
index 04fb9bcbcc9b3991426b84011c5500d508324bc2..e7940ef92d608a6274690e75f6d8cb1571645c69 100644
(file)
--- a/
udev/udevadm-trigger.c
+++ b/
udev/udevadm-trigger.c
@@
-47,7
+47,7
@@
static struct sockaddr_un saddr;
static socklen_t saddrlen;
/* devices that should run last cause of their dependencies */
static socklen_t saddrlen;
/* devices that should run last cause of their dependencies */
-static int delay_device(const char *
dev
path)
+static int delay_device(const char *
sys
path)
{
static const char *delay_device_list[] = {
"*/md*",
{
static const char *delay_device_list[] = {
"*/md*",
@@
-57,15
+57,14
@@
static int delay_device(const char *devpath)
int i;
for (i = 0; delay_device_list[i] != NULL; i++)
int i;
for (i = 0; delay_device_list[i] != NULL; i++)
- if (fnmatch(delay_device_list[i],
dev
path, 0) == 0)
+ if (fnmatch(delay_device_list[i],
sys
path, 0) == 0)
return 1;
return 0;
}
static int device_list_insert(struct udev *udev, const char *path)
{
return 1;
return 0;
}
static int device_list_insert(struct udev *udev, const char *path)
{
- char filename[PATH_SIZE];
- char devpath[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
struct stat statbuf;
dbg(udev, "add '%s'\n" , path);
struct stat statbuf;
dbg(udev, "add '%s'\n" , path);
@@
-78,30
+77,28
@@
static int device_list_insert(struct udev *udev, const char *path)
if (!(statbuf.st_mode & S_IWUSR))
return -1;
if (!(statbuf.st_mode & S_IWUSR))
return -1;
- util_strlcpy(devpath, &path[strlen(udev_get_sys_path(udev))], sizeof(devpath));
-
/* resolve possible link to real target */
/* resolve possible link to real target */
- if (lstat(path, &statbuf) < 0)
+ util_strlcpy(filename, path, sizeof(filename));
+ if (lstat(filename, &statbuf) < 0)
return -1;
if (S_ISLNK(statbuf.st_mode))
return -1;
if (S_ISLNK(statbuf.st_mode))
- if (
sysfs_resolve_link(udev, devpath, sizeof(devpath
)) != 0)
+ if (
util_resolve_sys_link(udev, filename, sizeof(filename
)) != 0)
return -1;
return -1;
- name_list_add(udev, &device_list,
devpath
, 1);
+ name_list_add(udev, &device_list,
filename
, 1);
return 0;
}
return 0;
}
-static void trigger_uevent(struct udev *udev, const char *
dev
path, const char *action)
+static void trigger_uevent(struct udev *udev, const char *
sys
path, const char *action)
{
{
- char filename[PATH_SIZE];
+ char filename[
UTIL_
PATH_SIZE];
int fd;
int fd;
- util_strlcpy(filename, udev_get_sys_path(udev), sizeof(filename));
- util_strlcat(filename, devpath, sizeof(filename));
+ util_strlcpy(filename, syspath, sizeof(filename));
util_strlcat(filename, "/uevent", sizeof(filename));
if (verbose)
util_strlcat(filename, "/uevent", sizeof(filename));
if (verbose)
- printf("%s\n",
dev
path);
+ printf("%s\n",
sys
path);
if (dry_run)
return;
if (dry_run)
return;
@@
-118,17
+115,18
@@
static void trigger_uevent(struct udev *udev, const char *devpath, const char *a
close(fd);
}
close(fd);
}
-static int pass_to_socket(struct udev *udev, const char *
dev
path, const char *action, const char *env)
+static int pass_to_socket(struct udev *udev, const char *
sys
path, const char *action, const char *env)
{
struct udevice *udevice;
struct name_entry *name_loop;
char buf[4096];
size_t bufpos = 0;
ssize_t count;
{
struct udevice *udevice;
struct name_entry *name_loop;
char buf[4096];
size_t bufpos = 0;
ssize_t count;
- char path[PATH_SIZE];
+ char path[
UTIL_
PATH_SIZE];
int fd;
int fd;
- char link_target[PATH_SIZE];
+ char link_target[
UTIL_
PATH_SIZE];
int len;
int len;
+ const char *devpath = &syspath[strlen(udev_get_sys_path(udev))];
int err = 0;
if (verbose)
int err = 0;
if (verbose)
@@
-193,8
+191,7
@@
static int pass_to_socket(struct udev *udev, const char *devpath, const char *ac
}
/* add keys from device "uevent" file */
}
/* add keys from device "uevent" file */
- util_strlcpy(path, udev_get_sys_path(udev), sizeof(path));
- util_strlcat(path, devpath, sizeof(path));
+ util_strlcpy(path, syspath, sizeof(path));
util_strlcat(path, "/uevent", sizeof(path));
fd = open(path, O_RDONLY);
if (fd >= 0) {
util_strlcat(path, "/uevent", sizeof(path));
fd = open(path, O_RDONLY);
if (fd >= 0) {
@@
-285,8
+282,8
@@
static int subsystem_filtered(const char *subsystem)
static int attr_match(const char *path, const char *attr_value)
{
static int attr_match(const char *path, const char *attr_value)
{
- char attr[NAME_SIZE];
- char file[PATH_SIZE];
+ char attr[
UTIL_
NAME_SIZE];
+ char file[
UTIL_
PATH_SIZE];
char *match_value;
util_strlcpy(attr, attr_value, sizeof(attr));
char *match_value;
util_strlcpy(attr, attr_value, sizeof(attr));
@@
-304,7
+301,7
@@
static int attr_match(const char *path, const char *attr_value)
if (match_value != NULL) {
/* match file content */
if (match_value != NULL) {
/* match file content */
- char value[NAME_SIZE];
+ char value[
UTIL_
NAME_SIZE];
int fd;
ssize_t size;
int fd;
ssize_t size;
@@
-357,7
+354,7
@@
enum scan_type {
static void scan_subsystem(struct udev *udev, const char *subsys, enum scan_type scan)
{
static void scan_subsystem(struct udev *udev, const char *subsys, enum scan_type scan)
{
- char base[PATH_SIZE];
+ char base[
UTIL_
PATH_SIZE];
DIR *dir;
struct dirent *dent;
const char *subdir;
DIR *dir;
struct dirent *dent;
const char *subdir;
@@
-376,7
+373,7
@@
static void scan_subsystem(struct udev *udev, const char *subsys, enum scan_type
dir = opendir(base);
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
dir = opendir(base);
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- char dirname[PATH_SIZE];
+ char dirname[
UTIL_
PATH_SIZE];
DIR *dir2;
struct dirent *dent2;
DIR *dir2;
struct dirent *dent2;
@@
-406,7
+403,7
@@
static void scan_subsystem(struct udev *udev, const char *subsys, enum scan_type
dir2 = opendir(dirname);
if (dir2 != NULL) {
for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
dir2 = opendir(dirname);
if (dir2 != NULL) {
for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
- char dirname2[PATH_SIZE];
+ char dirname2[
UTIL_
PATH_SIZE];
if (dent2->d_name[0] == '.')
continue;
if (dent2->d_name[0] == '.')
continue;
@@
-427,7
+424,7
@@
static void scan_subsystem(struct udev *udev, const char *subsys, enum scan_type
static void scan_block(struct udev *udev)
{
static void scan_block(struct udev *udev)
{
- char base[PATH_SIZE];
+ char base[
UTIL_
PATH_SIZE];
DIR *dir;
struct dirent *dent;
DIR *dir;
struct dirent *dent;
@@
-440,7
+437,7
@@
static void scan_block(struct udev *udev)
dir = opendir(base);
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
dir = opendir(base);
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- char dirname[PATH_SIZE];
+ char dirname[
UTIL_
PATH_SIZE];
DIR *dir2;
struct dirent *dent2;
DIR *dir2;
struct dirent *dent2;
@@
-459,7
+456,7
@@
static void scan_block(struct udev *udev)
dir2 = opendir(dirname);
if (dir2 != NULL) {
for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
dir2 = opendir(dirname);
if (dir2 != NULL) {
for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
- char dirname2[PATH_SIZE];
+ char dirname2[
UTIL_
PATH_SIZE];
if (dent2->d_name[0] == '.')
continue;
if (dent2->d_name[0] == '.')
continue;
@@
-483,7
+480,7
@@
static void scan_block(struct udev *udev)
static void scan_class(struct udev *udev)
{
static void scan_class(struct udev *udev)
{
- char base[PATH_SIZE];
+ char base[
UTIL_
PATH_SIZE];
DIR *dir;
struct dirent *dent;
DIR *dir;
struct dirent *dent;
@@
-493,7
+490,7
@@
static void scan_class(struct udev *udev)
dir = opendir(base);
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
dir = opendir(base);
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- char dirname[PATH_SIZE];
+ char dirname[
UTIL_
PATH_SIZE];
DIR *dir2;
struct dirent *dent2;
DIR *dir2;
struct dirent *dent2;
@@
-509,7
+506,7
@@
static void scan_class(struct udev *udev)
dir2 = opendir(dirname);
if (dir2 != NULL) {
for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
dir2 = opendir(dirname);
if (dir2 != NULL) {
for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
- char dirname2[PATH_SIZE];
+ char dirname2[
UTIL_
PATH_SIZE];
if (dent2->d_name[0] == '.')
continue;
if (dent2->d_name[0] == '.')
continue;
@@
-533,7
+530,7
@@
static void scan_class(struct udev *udev)
static void scan_failed(struct udev *udev)
{
static void scan_failed(struct udev *udev)
{
- char base[PATH_SIZE];
+ char base[
UTIL_
PATH_SIZE];
DIR *dir;
struct dirent *dent;
DIR *dir;
struct dirent *dent;
@@
-543,7
+540,7
@@
static void scan_failed(struct udev *udev)
dir = opendir(base);
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
dir = opendir(base);
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- char device[PATH_SIZE];
+ char device[
UTIL_
PATH_SIZE];
size_t start;
if (dent->d_name[0] == '.')
size_t start;
if (dent->d_name[0] == '.')
@@
-671,7
+668,7
@@
int udevadm_trigger(struct udev *udev, int argc, char *argv[])
scan_failed(udev);
exec_list(udev, action, env);
} else {
scan_failed(udev);
exec_list(udev, action, env);
} else {
- char base[PATH_SIZE];
+ char base[
UTIL_
PATH_SIZE];
struct stat statbuf;
/* if we have /sys/subsystem, forget all the old stuff */
struct stat statbuf;
/* if we have /sys/subsystem, forget all the old stuff */