udevadm: move init from commands to udevadm

This commit is contained in:
Kay Sievers 2008-09-04 10:34:48 +02:00
parent 8a3c06af21
commit 60865f33a1
5 changed files with 6 additions and 19 deletions

View File

@ -279,10 +279,6 @@ int udevadm_info(int argc, char *argv[])
struct name_entry *name_loop; struct name_entry *name_loop;
int rc = 0; int rc = 0;
logging_init("udevinfo");
udev_config_init();
sysfs_init();
while (1) { while (1) {
option = getopt_long(argc, argv, "aed:n:p:q:rxPVh", options, NULL); option = getopt_long(argc, argv, "aed:n:p:q:rxPVh", options, NULL);
if (option == -1) if (option == -1)
@ -501,7 +497,5 @@ int udevadm_info(int argc, char *argv[])
exit: exit:
udev_device_cleanup(udev); udev_device_cleanup(udev);
sysfs_cleanup();
logging_close();
return rc; return rc;
} }

View File

@ -87,10 +87,7 @@ int udevadm_settle(int argc, char *argv[])
int rc = 1; int rc = 1;
int seconds; int seconds;
logging_init("udevsettle");
udev_config_init();
dbg("version %s\n", VERSION); dbg("version %s\n", VERSION);
sysfs_init();
while (1) { while (1) {
option = getopt_long(argc, argv, "t:h", options, NULL); option = getopt_long(argc, argv, "t:h", options, NULL);
@ -172,7 +169,5 @@ int udevadm_settle(int argc, char *argv[])
} }
exit: exit:
sysfs_cleanup();
logging_close();
return rc; return rc;
} }

View File

@ -92,7 +92,6 @@ int udevadm_test(int argc, char *argv[])
}; };
info("version %s\n", VERSION); info("version %s\n", VERSION);
udev_config_init();
if (udev_log_priority < LOG_INFO) { if (udev_log_priority < LOG_INFO) {
char priority[32]; char priority[32];
@ -143,7 +142,6 @@ int udevadm_test(int argc, char *argv[])
"some values may be different, or not available at a simulation run.\n" "some values may be different, or not available at a simulation run.\n"
"\n"); "\n");
sysfs_init();
udev_rules_init(&rules, 0); udev_rules_init(&rules, 0);
/* remove /sys if given */ /* remove /sys if given */
@ -202,6 +200,5 @@ int udevadm_test(int argc, char *argv[])
exit: exit:
udev_rules_cleanup(&rules); udev_rules_cleanup(&rules);
sysfs_cleanup();
return rc; return rc;
} }

View File

@ -584,10 +584,7 @@ int udevadm_trigger(int argc, char *argv[])
{} {}
}; };
logging_init("udevtrigger");
udev_config_init();
dbg("version %s\n", VERSION); dbg("version %s\n", VERSION);
sysfs_init();
while (1) { while (1) {
option = getopt_long(argc, argv, "vnFo:hce::s:S:a:A:", options, NULL); option = getopt_long(argc, argv, "vnFo:hce::s:S:a:A:", options, NULL);
@ -710,7 +707,5 @@ exit:
if (sock >= 0) if (sock >= 0)
close(sock); close(sock);
sysfs_cleanup();
logging_close();
return 0; return 0;
} }

View File

@ -125,6 +125,10 @@ int main(int argc, char *argv[])
const char *pos; const char *pos;
int rc; int rc;
logging_init("udevadm");
udev_config_init();
sysfs_init();
/* find command */ /* find command */
if (command != NULL) if (command != NULL)
for (i = 0; cmds[i].cmd != NULL; i++) { for (i = 0; cmds[i].cmd != NULL; i++) {
@ -169,5 +173,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "unknown command, try help\n\n"); fprintf(stderr, "unknown command, try help\n\n");
rc = 2; rc = 2;
out: out:
sysfs_cleanup();
logging_close();
return rc; return rc;
} }