12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #define LOG_TAG "libtrusty"
- #include <errno.h>
- #include <fcntl.h>
- #include <stdbool.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/ioctl.h>
- #include <unistd.h>
- #include <log/log.h>
- #include "tipc_ioctl.h"
- int tipc_connect(const char *dev_name, const char *srv_name)
- {
- int fd;
- int rc;
- fd = open(dev_name, O_RDWR);
- if (fd < 0) {
- rc = -errno;
- ALOGE("%s: cannot open tipc device \"%s\": %s\n",
- __func__, dev_name, strerror(errno));
- return rc < 0 ? rc : -1;
- }
- rc = ioctl(fd, TIPC_IOC_CONNECT, srv_name);
- if (rc < 0) {
- rc = -errno;
- ALOGE("%s: can't connect to tipc service \"%s\" (err=%d)\n",
- __func__, srv_name, errno);
- close(fd);
- return rc < 0 ? rc : -1;
- }
- ALOGV("%s: connected to \"%s\" fd %d\n", __func__, srv_name, fd);
- return fd;
- }
- void tipc_close(int fd)
- {
- close(fd);
- }
|