Commit c26c1c4b3d5d4b7bd9f986ab67608419e7abefe1

Authored by ths
1 parent c032e2a9

Support for unidirectional pipes, by Ed Swierk.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2267 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 17 additions and 6 deletions
... ... @@ -1297,12 +1297,23 @@ CharDriverState *qemu_chr_open_file_out(const char *file_out)
1297 1297  
1298 1298 CharDriverState *qemu_chr_open_pipe(const char *filename)
1299 1299 {
1300   - int fd;
1301   -
1302   - fd = open(filename, O_RDWR | O_BINARY);
1303   - if (fd < 0)
1304   - return NULL;
1305   - return qemu_chr_open_fd(fd, fd);
  1300 + int fd_in, fd_out;
  1301 + char filename_in[256], filename_out[256];
  1302 +
  1303 + snprintf(filename_in, 256, "%s.in", filename);
  1304 + snprintf(filename_out, 256, "%s.out", filename);
  1305 + fd_in = open(filename_in, O_RDWR | O_BINARY);
  1306 + fd_out = open(filename_out, O_RDWR | O_BINARY);
  1307 + if (fd_in < 0 || fd_out < 0) {
  1308 + if (fd_in >= 0)
  1309 + close(fd_in);
  1310 + if (fd_out >= 0)
  1311 + close(fd_out);
  1312 + fd_in = fd_out = open(filename, O_RDWR | O_BINARY);
  1313 + if (fd_in < 0)
  1314 + return NULL;
  1315 + }
  1316 + return qemu_chr_open_fd(fd_in, fd_out);
1306 1317 }
1307 1318  
1308 1319  
... ...