gcc-6: use $(GNU_ARCH) in manifest
[unleashed-userland.git] / components / trousers / patches / tddl_tddl.c.patch
blobf91f76560fa961ea0af58cca1f7ee163f7dbd9ff
1 --- a/src/tddl/tddl.c Mon Apr 12 22:24:21 2010
2 +++ b/src/tddl/tddl.c.new Thu Sep 22 12:28:25 2011
3 @@ -18,13 +18,17 @@
5 #include "trousers/tss.h"
6 #include "trousers_types.h"
7 +#ifndef SOLARIS
8 #include "linux/tpm.h"
9 +#endif
10 #include "tcslog.h"
11 #include "tddl.h"
13 struct tpm_device_node tpm_device_nodes[] = {
14 +#ifndef SOLARIS
15 {"/dev/tpm0", TDDL_UNDEF, TDDL_UNDEF},
16 {"/udev/tpm0", TDDL_UNDEF, TDDL_UNDEF},
17 +#endif
18 {"/dev/tpm", TDDL_UNDEF, TDDL_UNDEF},
19 {NULL, 0, 0}
21 @@ -42,6 +46,13 @@
22 #include <netdb.h>
23 #include <fcntl.h>
25 +#ifdef SOLARIS
26 +int
27 +get_device_fd()
29 + return (opened_device->fd);
31 +#endif
33 int
34 open_device()
35 @@ -63,7 +74,7 @@
38 fd = socket(AF_INET, SOCK_STREAM, 0);
39 - if (fd > 0) {
40 + if (fd >= 0) {
41 struct hostent *host = gethostbyname(tcp_device_hostname);
42 if (host != NULL) {
43 struct sockaddr_in addr;
44 @@ -105,12 +116,16 @@
45 /* tpm_device_paths is filled out in tddl.h */
46 for (i = 0; tpm_device_nodes[i].path != NULL; i++) {
47 errno = 0;
48 - if ((fd = open(tpm_device_nodes[i].path, O_RDWR)) >= 0)
49 + if ((fd = open(tpm_device_nodes[i].path, O_RDWR)) >= 0) {
50 break;
51 + } else {
52 + fprintf(stderr, "Error opening %s: %s\n",
53 + tpm_device_nodes[i].path, strerror(errno));
54 + }
58 - if (fd > 0) {
60 + if (fd >= 0) {
61 opened_device = &(tpm_device_nodes[i]);
62 tpm_device_nodes[i].fd = fd;
64 @@ -181,11 +196,13 @@
65 /* fall through */
66 case TDDL_TRANSMIT_IOCTL:
67 errno = 0;
68 +#ifndef SOLARIS
69 if ((sizeResult = ioctl(opened_device->fd, TPMIOC_TRANSMIT, txBuffer)) != -1) {
70 opened_device->transmit = TDDL_TRANSMIT_IOCTL;
71 break;
73 LogWarn("ioctl: (%d) %s", errno, strerror(errno));
74 +#endif
75 LogInfo("Falling back to Read/Write device support.");
76 /* fall through */
77 case TDDL_TRANSMIT_RW:
78 @@ -255,6 +272,7 @@
80 TSS_RESULT Tddli_Cancel(void)
82 +#ifndef SOLARIS
83 int rc;
85 if (opened_device->transmit == TDDL_TRANSMIT_IOCTL) {
86 @@ -270,4 +288,7 @@
87 } else {
88 return TDDLERR(TSS_E_NOTIMPL);
90 +#else
91 + return TDDLERR(TSS_E_NOTIMPL);
92 +#endif /* SOLARIS */