udevadm-trigger.c revision 4dd1de72e8e7ece77e8831e77eea650de404af75
/*
* Copyright (C) 2008-2009 Kay Sievers <kay@vrfy.org>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <dirent.h>
#include <fcntl.h>
#include <syslog.h>
#include <fnmatch.h>
#include "udev.h"
static int verbose;
static int dry_run;
{
struct udev_list_entry *entry;
char filename[UTIL_PATH_SIZE];
int fd;
if (verbose)
if (dry_run)
continue;
if (fd < 0)
continue;
}
}
{
char *pos;
pos[0] = 0;
pos++;
}
return buf;
}
{
{}
};
enum {
} device_type = TYPE_DEVICES;
const char *action = "change";
struct udev_enumerate *udev_enumerate;
int rc = 0;
if (udev_enumerate == NULL) {
rc = 1;
goto exit;
}
for (;;) {
int option;
const char *key;
const char *val;
char buf[UTIL_PATH_SIZE];
if (option == -1)
break;
switch (option) {
case 'v':
verbose = 1;
break;
case 'n':
dry_run = 1;
break;
case 't':
} else {
rc = 2;
goto exit;
}
break;
case 'c':
break;
case 's':
break;
case 'S':
break;
case 'a':
break;
case 'A':
break;
case 'p':
break;
case 'g':
break;
case 'y':
break;
case 'b': {
char path[UTIL_PATH_SIZE];
struct udev_device *dev;
/* add sys dir if needed */
else
rc = 2;
goto exit;
}
/* drop reference immediately, enumerate pins the device as long as needed */
break;
}
case 'h':
printf("Usage: udevadm trigger OPTIONS\n"
" --verbose print the list of devices while running\n"
" --dry-run do not actually trigger the events\n"
" --type= type of events to trigger\n"
" devices sys devices (default)\n"
" subsystems sys subsystems and drivers\n"
" --action=<action> event action value, default is \"change\"\n"
" --subsystem-match=<subsystem> trigger devices from a matching subsystem\n"
" --subsystem-nomatch=<subsystem> exclude devices from a matching subsystem\n"
" --attr-match=<file[=<value>]> trigger devices with a matching attribute\n"
" --attr-nomatch=<file[=<value>]> exclude devices with a matching attribute\n"
" --property-match=<key>=<value> trigger devices with a matching property\n"
" --tag-match=<key>=<value> trigger devices with a matching property\n"
" --sysname-match=<name> trigger devices with a matching name\n"
" --parent-match=<name> trigger devices with that parent device\n"
" --help\n\n");
goto exit;
default:
rc = 1;
goto exit;
}
}
switch (device_type) {
case TYPE_SUBSYSTEMS:
goto exit;
case TYPE_DEVICES:
goto exit;
default:
assert_not_reached("device_type");
}
exit:
return rc;
}
const struct udevadm_cmd udevadm_trigger = {
.name = "trigger",
.cmd = adm_trigger,
.help = "request events from the kernel",
};