aboutsummaryrefslogtreecommitdiffstats
path: root/scd
diff options
context:
space:
mode:
Diffstat (limited to 'scd')
-rw-r--r--scd/ChangeLog6
-rw-r--r--scd/ccid-driver.c17
-rw-r--r--scd/command.c21
3 files changed, 40 insertions, 4 deletions
diff --git a/scd/ChangeLog b/scd/ChangeLog
index 571457576..769ef0a14 100644
--- a/scd/ChangeLog
+++ b/scd/ChangeLog
@@ -1,3 +1,9 @@
+2007-04-03 Werner Koch <[email protected]>
+
+ * command.c (cmd_getinfo): New subcommand "reader_list".
+ * ccid-driver.c (scan_or_find_devices): Ignore EBUSY in scan mode
+ for special transports.
+
2007-03-07 Werner Koch <[email protected]>
* app-dinsig.c: Include i18n.h.
diff --git a/scd/ccid-driver.c b/scd/ccid-driver.c
index 8ad329d67..33de4921b 100644
--- a/scd/ccid-driver.c
+++ b/scd/ccid-driver.c
@@ -989,7 +989,13 @@ scan_or_find_devices (int readerno, const char *readerid,
char *rid, *p;
fd = open (transports[i].name, O_RDWR);
- if (fd == -1)
+ if (fd == -1 && scan_mode && errno == EBUSY)
+ {
+ /* Ignore this error in scan mode because it indicates that
+ the device exists but is already open (most likely by us)
+ and thus in general suitable as a reader. */
+ }
+ else if (fd == -1)
{
DEBUGOUT_2 ("failed to open `%s': %s\n",
transports[i].name, strerror (errno));
@@ -999,7 +1005,8 @@ scan_or_find_devices (int readerno, const char *readerid,
rid = malloc (strlen (transports[i].name) + 30 + 10);
if (!rid)
{
- close (fd);
+ if (fd != -1)
+ close (fd);
free (rid_list);
return -1; /* Error. */
}
@@ -1010,7 +1017,8 @@ scan_or_find_devices (int readerno, const char *readerid,
p = malloc ((rid_list? strlen (rid_list):0) + 1 + strlen (rid) + 1);
if (!p)
{
- close (fd);
+ if (fd != -1)
+ close (fd);
free (rid_list);
free (rid);
return -1; /* Error. */
@@ -1046,7 +1054,8 @@ scan_or_find_devices (int readerno, const char *readerid,
--readerno;
}
free (rid);
- close (fd);
+ if (fd != -1)
+ close (fd);
}
if (scan_mode)
diff --git a/scd/command.c b/scd/command.c
index 579145711..93df064af 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -38,6 +38,9 @@
#include "app-common.h"
#include "apdu.h" /* Required for apdu_*_reader (). */
#include "exechelp.h"
+#ifdef HAVE_LIBUSB
+#include "ccid-driver.h"
+#endif
/* Maximum length allowed as a PIN; used for INQUIRE NEEDPIN */
#define MAXLEN_PIN 100
@@ -1382,12 +1385,16 @@ cmd_unlock (assuan_context_t ctx, char *line)
Supported values of WHAT are:
socket_name - Return the name of the socket.
+
status - Return the status of the current slot (in the future, may
also return the status of all slots). The status is a list of
one-character flags. The following flags are currently defined:
'u' Usable card present. This is the normal state during operation.
'r' Card removed. A reset is necessary.
These flags are exclusive.
+
+ reader_list - Return a list of detected card readers. Does
+ currently only work with the internal CCID driver.
*/
static int
@@ -1427,6 +1434,20 @@ cmd_getinfo (assuan_context_t ctx, char *line)
}
rc = assuan_send_data (ctx, &flag, 1);
}
+ else if (!strcmp (line, "reader_list"))
+ {
+#ifdef HAVE_LIBUSB
+ char *s = ccid_get_reader_list ();
+#else
+ char *s = NULL;
+#endif
+
+ if (s)
+ rc = assuan_send_data (ctx, s, strlen (s));
+ else
+ rc = gpg_error (GPG_ERR_NO_DATA);
+ xfree (s);
+ }
else
rc = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT");
return rc;