2c2
< * Copyright (c) 2014-2015 ARM Limited
---
> * Copyright (c) 2014-2017 ARM Limited
46a47
> #include <sys/un.h>
48a50,52
> #include <fstream>
>
> #include "base/output.hh"
336a341,342
> DPRINTF(VIO9P, "Using diod at %s \n", p->diod.c_str());
>
355a362,388
> // Create Unix domain socket
> int socket_id = socket(AF_UNIX, SOCK_STREAM, 0);
> if (socket_id == -1) {
> panic("Socket creation failed %i \n", errno);
> }
> // Bind the socket to a path which will not be read
> struct sockaddr_un socket_address;
> memset(&socket_address, 0, sizeof(struct sockaddr_un));
> socket_address.sun_family = AF_UNIX;
>
> const std::string socket_path = simout.resolve(p->socketPath);
> fatal_if(!OutputDirectory::isAbsolute(socket_path), "Please make the" \
> " output directory an absolute path, else diod will fail!\n");
>
> // Prevent overflow in strcpy
> fatal_if(sizeof(socket_address.sun_path) <= socket_path.length(),
> "Incorrect length of socket path");
> strncpy(socket_address.sun_path, socket_path.c_str(),
> sizeof(socket_address.sun_path));
>
> if (bind(socket_id, (struct sockaddr*) &socket_address,
> sizeof(struct sockaddr_un)) == -1){
> perror("Socket binding");
> panic("Socket binding to %i failed - most likely the output dir" \
> " and hence unused socket already exists \n", socket_id);
> }
>
362a396
> "-l", socket_path.c_str(), // pass the socket
364c398,399
< panic("Failed to execute diod: %i\n", errno);
---
> perror("Starting DIOD");
> panic("Failed to execute diod to %s: %i\n",socket_path, errno);