udevadm-trigger.c | udevadm-trigger.c | |||
---|---|---|---|---|
skipping to change at line 27 | skipping to change at line 27 | |||
#include <stdlib.h> | #include <stdlib.h> | |||
#include <stddef.h> | #include <stddef.h> | |||
#include <string.h> | #include <string.h> | |||
#include <stdio.h> | #include <stdio.h> | |||
#include <unistd.h> | #include <unistd.h> | |||
#include <getopt.h> | #include <getopt.h> | |||
#include <errno.h> | #include <errno.h> | |||
#include <dirent.h> | #include <dirent.h> | |||
#include <fcntl.h> | #include <fcntl.h> | |||
#include <syslog.h> | ||||
#include <fnmatch.h> | #include <fnmatch.h> | |||
#include <sys/stat.h> | #include <sys/stat.h> | |||
#include <sys/types.h> | #include <sys/types.h> | |||
#include <sys/socket.h> | #include <sys/socket.h> | |||
#include <sys/un.h> | #include <sys/un.h> | |||
#include "udev.h" | #include "udev.h" | |||
#include "udev-util.h" | #include "udev-util.h" | |||
#include "util.h" | #include "util.h" | |||
static int verbose; | static int verbose; | |||
static int dry_run; | static int dry_run; | |||
static void exec_list(struct udev_enumerate *udev_enumerate, const char *ac | static void exec_list(struct udev_enumerate *udev_enumerate, const char *ac | |||
tion) | tion) { | |||
{ | ||||
struct udev_list_entry *entry; | struct udev_list_entry *entry; | |||
udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(udev_e numerate)) { | udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(udev_e numerate)) { | |||
char filename[UTIL_PATH_SIZE]; | char filename[UTIL_PATH_SIZE]; | |||
int fd; | int fd; | |||
if (verbose) | if (verbose) | |||
printf("%s\n", udev_list_entry_get_name(entry)); | printf("%s\n", udev_list_entry_get_name(entry)); | |||
if (dry_run) | if (dry_run) | |||
continue; | continue; | |||
strscpyl(filename, sizeof(filename), udev_list_entry_get_na me(entry), "/uevent", NULL); | strscpyl(filename, sizeof(filename), udev_list_entry_get_na me(entry), "/uevent", NULL); | |||
fd = open(filename, O_WRONLY|O_CLOEXEC); | fd = open(filename, O_WRONLY|O_CLOEXEC); | |||
if (fd < 0) | if (fd < 0) | |||
continue; | continue; | |||
if (write(fd, action, strlen(action)) < 0) | if (write(fd, action, strlen(action)) < 0) | |||
log_debug("error writing '%s' to '%s': %m", action, filename); | log_debug("error writing '%s' to '%s': %m", action, filename); | |||
close(fd); | close(fd); | |||
} | } | |||
} | } | |||
static const char *keyval(const char *str, const char **val, char *buf, siz | static const char *keyval(const char *str, const char **val, char *buf, siz | |||
e_t size) | e_t size) { | |||
{ | ||||
char *pos; | char *pos; | |||
strscpy(buf, size,str); | strscpy(buf, size,str); | |||
pos = strchr(buf, '='); | pos = strchr(buf, '='); | |||
if (pos != NULL) { | if (pos != NULL) { | |||
pos[0] = 0; | pos[0] = 0; | |||
pos++; | pos++; | |||
} | } | |||
*val = pos; | *val = pos; | |||
return buf; | return buf; | |||
skipping to change at line 96 | skipping to change at line 93 | |||
" -S,--subsystem-nomatch=<subsystem> exclude devices from a matching subsystem\n" | " -S,--subsystem-nomatch=<subsystem> exclude devices from a matching subsystem\n" | |||
" -a,--attr-match=<file[=<value>]> trigger devices with a matching attribute\n" | " -a,--attr-match=<file[=<value>]> trigger devices with a matching attribute\n" | |||
" -A,--attr-nomatch=<file[=<value>]> exclude devices with a matching attribute\n" | " -A,--attr-nomatch=<file[=<value>]> exclude devices with a matching attribute\n" | |||
" -p,--property-match=<key>=<value> trigger devices with a matching property\n" | " -p,--property-match=<key>=<value> trigger devices with a matching property\n" | |||
" -g,--tag-match=<key>=<value> trigger devices with a matching property\n" | " -g,--tag-match=<key>=<value> trigger devices with a matching property\n" | |||
" -y,--sysname-match=<name> trigger devices with a matching name\n" | " -y,--sysname-match=<name> trigger devices with a matching name\n" | |||
" -b,--parent-match=<name> trigger devices with t hat parent device\n" | " -b,--parent-match=<name> trigger devices with t hat parent device\n" | |||
" -h,--help\n\n"); | " -h,--help\n\n"); | |||
} | } | |||
static int adm_trigger(struct udev *udev, int argc, char *argv[]) | static int adm_trigger(struct udev *udev, int argc, char *argv[]) { | |||
{ | ||||
static const struct option options[] = { | static const struct option options[] = { | |||
{ "verbose", no_argument, NULL, 'v' }, | { "verbose", no_argument, NULL, 'v' }, | |||
{ "dry-run", no_argument, NULL, 'n' }, | { "dry-run", no_argument, NULL, 'n' }, | |||
{ "type", required_argument, NULL, 't' }, | { "type", required_argument, NULL, 't' }, | |||
{ "action", required_argument, NULL, 'c' }, | { "action", required_argument, NULL, 'c' }, | |||
{ "subsystem-match", required_argument, NULL, 's' }, | { "subsystem-match", required_argument, NULL, 's' }, | |||
{ "subsystem-nomatch", required_argument, NULL, 'S' }, | { "subsystem-nomatch", required_argument, NULL, 'S' }, | |||
{ "attr-match", required_argument, NULL, 'a' }, | { "attr-match", required_argument, NULL, 'a' }, | |||
{ "attr-nomatch", required_argument, NULL, 'A' }, | { "attr-nomatch", required_argument, NULL, 'A' }, | |||
{ "property-match", required_argument, NULL, 'p' }, | { "property-match", required_argument, NULL, 'p' }, | |||
End of changes. 4 change blocks. | ||||
9 lines changed or deleted | 5 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |