udevadm-trigger.c revision 44433ebdb14d83750e0acdc4b3630b64f1fa18af
/*
* 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"
#include "udev-util.h"
#include "util.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;
}
static void help(void) {
printf("Usage: udevadm trigger OPTIONS\n"
" -v,--verbose print the list of devices while running\n"
" -n,--dry-run do not actually trigger the events\n"
" -t,--type= type of events to trigger\n"
" devices sys devices (default)\n"
" subsystems sys subsystems and drivers\n"
" -c,--action=<action> event action value, default is \"change\"\n"
" -s,--subsystem-match=<subsystem> trigger 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-nomatch=<file[=<value>]> exclude devices with a matching attribute\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"
" -y,--sysname-match=<name> trigger devices with a matching name\n"
" -b,--parent-match=<name> trigger devices with that parent device\n"
" -h,--help\n\n");
}
{
{}
};
enum {
} device_type = TYPE_DEVICES;
const char *action = "change";
int c;
if (udev_enumerate == NULL)
return 1;
const char *key;
const char *val;
char buf[UTIL_PATH_SIZE];
switch (c) {
case 'v':
verbose = 1;
break;
case 'n':
dry_run = 1;
break;
case 't':
else {
return 2;
}
break;
case 'c':
return 2;
} else
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
return 2;
}
/* drop reference immediately, enumerate pins the device as long as needed */
break;
}
case 'h':
help();
return 0;
case '?':
return 1;
default:
assert_not_reached("Unknown option");
}
}
return 1;
}
switch (device_type) {
case TYPE_SUBSYSTEMS:
return 0;
case TYPE_DEVICES:
return 0;
default:
assert_not_reached("device_type");
}
}
const struct udevadm_cmd udevadm_trigger = {
.name = "trigger",
.cmd = adm_trigger,
.help = "request events from the kernel",
};