udevadm.c revision 01618658fd82dbc5e6315b639f00e87c6fee3c54
/*
* Copyright (C) 2007 Kay Sievers <kay.sievers@vrfy.org>
*
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2 of the License.
*
* 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "config.h"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include "udev.h"
static int debug;
#ifdef USE_LOG
{
if (priority > udev_log_priority)
return;
if (debug)
else
}
#endif
struct command {
const char *name;
const char *help;
int debug;
};
{
return 0;
}
{
printf("Usage: udevadm COMMAND [OPTIONS]\n");
printf("\n");
return 0;
}
{
.name = "info",
.help = "query sysfs or the udev database",
},
{
.name = "trigger",
.cmd = udevtrigger,
.help = "request events from the kernel",
},
{
.name = "settle",
.help = "wait for the event queue to finish",
},
{
.name = "control",
.cmd = udevcontrol,
.help = "control the udev daemon",
},
{
.name = "monitor",
.cmd = udevmonitor,
.help = "listen to kernel and udev events",
},
{
.name = "test",
.help = "simulation run",
.debug = 1,
},
{
.name = "version",
.help = "print the version number",
},
{
.name = "help",
.help = "print this help text",
},
{}
};
{
const char *command;
const char *pos;
int rc;
/* get binary or symlink name */
else
/* the trailing part of the binary or symlink name is the command */
goto err_unknown;
/* udevadm itself needs to strip its name from the passed options */
argv++;
argc--;
}
goto err_unknown;
/* allow command to be specified as an option */
command += 2;
/* find and execute command */
goto out;
}
}
rc = 2;
out:
return rc;
}