udevadm-control.c revision ca508dd94dc785492b5c62f56b02c0eeb3775f38
/*
* Copyright (C) 2005-2008 Kay Sievers <kay.sievers@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.
*/
#include <time.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include "udev.h"
static void print_help(void)
{
printf("Usage: udevadm control COMMAND\n"
" --log-priority=<level> set the udev log level for the daemon\n"
" --stop-exec-queue keep udevd from executing events, queue only\n"
" --start-exec-queue execute events, flush queue\n"
" --reload-rules reloads the rules files\n"
" --property=<KEY>=<value> set a global property for all events\n"
" --max-childs=<N> maximum number of childs\n"
" --help print this help text\n\n");
}
{
int rc = 1;
/* compat values with '_' will be removed in a future release */
{}
};
if (getuid() != 0) {
return 1;
}
return 2;
while (1) {
int option;
int i;
char *endp;
if (option == -1)
break;
switch (option) {
case 'l':
i = util_log_priority(optarg);
if (i < 0) {
goto exit;
}
rc = 2;
else
rc = 0;
break;
case 's':
if (udev_ctrl_send_stop_exec_queue(uctrl) < 0)
rc = 2;
else
rc = 0;
break;
case 'S':
if (udev_ctrl_send_start_exec_queue(uctrl) < 0)
rc = 2;
else
rc = 0;
break;
case 'R':
if (udev_ctrl_send_reload_rules(uctrl) < 0)
rc = 2;
else
rc = 0;
break;
case 'p':
goto exit;
}
rc = 2;
else
rc = 0;
break;
case 'm':
goto exit;
}
if (udev_ctrl_send_set_max_childs(uctrl, i) < 0)
rc = 2;
else
rc = 0;
break;
case 'h':
print_help();
rc = 0;
break;
}
}
if (rc == 1)
exit:
return rc;
}