Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(774)

Side by Side Diff: tddl/tddl_unix.h

Issue 660204: Upgrade to tpm-emulator version 0.7. (Closed)
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tddl/tddl.c ('k') | tddl/tddl_windows.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* Software-based Trusted Platform Module (TPM) Emulator
2 * Copyright (C) 2004-2010 Mario Strasser <mast@gmx.net>
3 *
4 * This module is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
8 *
9 * This module is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * $Id: tddl.c 364 2010-02-11 10:24:45Z mast $
15 */
16
17 #include <sys/types.h>
18 #include <sys/socket.h>
19 #include <sys/un.h>
20 #include <fcntl.h>
21 #include <unistd.h>
22 #include <string.h>
23 #include <errno.h>
24 #include <pthread.h>
25
26 /* library lock */
27 static pthread_mutex_t tddli_lock = PTHREAD_MUTEX_INITIALIZER;
28
29 #define tddli_mutex_lock(a) pthread_mutex_lock(a)
30 #define tddli_mutex_unlock(a) pthread_mutex_unlock(a)
31
32 static TSS_RESULT open_device(const char *device_name)
33 {
34 tddli_dh = open(device_name, O_RDWR);
35 if (tddli_dh < 0) {
36 if (errno == ENOENT || errno == ENXIO) {
37 tddli_driver_status = TDDL_DRIVER_FAILED;
38 tddli_device_status = TDDL_DEVICE_NOT_FOUND;
39 } else {
40 tddli_driver_status = TDDL_DRIVER_NOT_OPENED;
41 tddli_device_status = TDDL_DEVICE_RECOVERABLE;
42 }
43 return TDDL_E_FAIL;
44 } else {
45 tddli_driver_status = TDDL_DRIVER_OK;
46 tddli_device_status = TDDL_DEVICE_OK;
47 return TDDL_SUCCESS;
48 }
49 }
50
51 static TSS_RESULT open_socket(const char *socket_name)
52 {
53 struct sockaddr_un addr;
54 tddli_dh = socket(AF_UNIX, SOCK_STREAM, 0);
55 if (tddli_dh < 0) {
56 tddli_driver_status = TDDL_DRIVER_FAILED;
57 tddli_device_status = TDDL_DEVICE_NOT_FOUND;
58 return TDDL_E_FAIL;
59 }
60 addr.sun_family = AF_UNIX;
61 strncpy(addr.sun_path, socket_name, sizeof(addr.sun_path));
62 if (connect(tddli_dh, (struct sockaddr*)&addr, sizeof(struct sockaddr_un)) < 0 ) {
63 tddli_driver_status = TDDL_DRIVER_FAILED;
64 tddli_device_status = TDDL_DEVICE_NOT_FOUND;
65 return TDDL_E_FAIL;
66 }
67 tddli_driver_status = TDDL_DRIVER_OK;
68 tddli_device_status = TDDL_DEVICE_OK;
69 return TDDL_SUCCESS;
70 }
71
OLDNEW
« no previous file with comments | « tddl/tddl.c ('k') | tddl/tddl_windows.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698