[Pcsclite-cvs-commit] r2157 - trunk/PCSC/src
Ludovic Rousseau
rousseau at costa.debian.org
Wed Sep 13 10:26:59 CEST 2006
Author: rousseau
Date: 2006-09-13 08:26:59 +0000 (Wed, 13 Sep 2006)
New Revision: 2157
Modified:
trunk/PCSC/src/pcscdaemon.c
Log:
add -H --hotplug argument to ask the daemon to rescan the avaiable
readers
Modified: trunk/PCSC/src/pcscdaemon.c
===================================================================
--- trunk/PCSC/src/pcscdaemon.c 2006-09-11 07:01:55 UTC (rev 2156)
+++ trunk/PCSC/src/pcscdaemon.c 2006-09-13 08:26:59 UTC (rev 2157)
@@ -187,6 +187,7 @@
{
int rv;
char setToForeground;
+ char HotPlug;
char *newReaderConfig;
struct stat fStatBuf;
int opt;
@@ -202,6 +203,7 @@
{"info", 0, 0, 0},
{"error", 0, 0, 'e'},
{"critical", 0, 0, 'C'},
+ {"hotplug", 0, 0, 'H'},
{0, 0, 0, 0}
};
#endif
@@ -209,6 +211,7 @@
rv = 0;
newReaderConfig = 0;
setToForeground = FALSE;
+ HotPlug = FALSE;
/*
* test the version
@@ -233,9 +236,9 @@
* Handle any command line arguments
*/
#ifdef HAVE_GETOPT_LONG
- while ((opt = getopt_long (argc, argv, "c:fdhvaeC", long_options, &option_index)) != -1) {
+ while ((opt = getopt_long (argc, argv, "c:fdhvaeCH", long_options, &option_index)) != -1) {
#else
- while ((opt = getopt (argc, argv, "c:fdhvaeC")) != -1) {
+ while ((opt = getopt (argc, argv, "c:fdhvaeCH")) != -1) {
#endif
switch (opt) {
case 'c':
@@ -275,6 +278,12 @@
DebugLogSetCategory(DEBUG_CATEGORY_APDU);
break;
+ case 'H':
+ /* debug to stderr instead of default syslog */
+ DebugLogSetLogType(DEBUGLOG_STDERR_DEBUG);
+ HotPlug = TRUE;
+ break;
+
default:
print_usage (argv[0]);
return EXIT_FAILURE;
@@ -317,6 +326,19 @@
pid = atoi(pid_ascii);
+ if (HotPlug)
+ {
+ Log2(PCSC_LOG_INFO, "Send hotplug signal to pcscd (pid=%d)",
+ pid);
+ if (kill(pid, SIGUSR1) < 0)
+ {
+ Log3(PCSC_LOG_CRITICAL, "Can't signal pcscd (pid=%d): %s",
+ pid, strerror(errno));
+ return EXIT_FAILURE ;
+ }
+ return EXIT_SUCCESS;
+ }
+
if (kill(pid, 0) == 0)
{
Log1(PCSC_LOG_CRITICAL,
@@ -330,30 +352,29 @@
clean_temp_files();
}
else
+#endif
{
+ if (HotPlug)
+ {
+ Log1(PCSC_LOG_CRITICAL, "file " USE_RUN_PID " do not exist");
+ Log1(PCSC_LOG_CRITICAL, "Hotplug failed");
+ return EXIT_FAILURE;
+ }
+
Log1(PCSC_LOG_CRITICAL,
"file " PCSCLITE_PUBSHM_FILE " already exists.");
Log1(PCSC_LOG_CRITICAL,
"Maybe another pcscd is running?");
+#ifdef USE_RUN_PID
Log1(PCSC_LOG_CRITICAL,
"I can't read process pid from " USE_RUN_PID);
+#endif
Log1(PCSC_LOG_CRITICAL,
"Remove " PCSCLITE_PUBSHM_FILE " and " PCSCLITE_CSOCK_NAME);
Log1(PCSC_LOG_CRITICAL,
"if pcscd is not running to clear this message.");
return EXIT_FAILURE;
}
-#else
- Log1(PCSC_LOG_CRITICAL,
- "file " PCSCLITE_PUBSHM_FILE " already exists.");
- Log1(PCSC_LOG_CRITICAL,
- "Maybe another pcscd is running?");
- Log1(PCSC_LOG_CRITICAL,
- "Remove " PCSCLITE_PUBSHM_FILE " and " PCSCLITE_CSOCK_NAME);
- Log1(PCSC_LOG_CRITICAL,
- "if pcscd is not running to clear this message.");
- return EXIT_FAILURE;
-#endif
}
/*
@@ -551,6 +572,7 @@
printf(" -f, --foreground run in foreground (no daemon),\n");
printf(" send logs to stderr instead of syslog\n");
printf(" -h, --help display usage information\n");
+ printf(" -H, --hotplug ask the daemon to rescan the avaiable readers\n");
printf(" -v, --version display the program version number\n");
printf(" -d, --debug display lower level debug messages\n");
printf(" --info display info level debug messages (default level)\n");
@@ -562,6 +584,7 @@
printf(" -f run in foreground (no daemon), send logs to stderr instead of syslog\n");
printf(" -d display debug messages. Output may be:\n");
printf(" -h display usage information\n");
+ printf(" -H ask the daemon to rescan the avaiable readers\n");
printf(" -v display the program version number\n");
#endif
}
More information about the Pcsclite-cvs-commit
mailing list