diff options
Diffstat (limited to 'tcp.c')
-rw-r--r-- | tcp.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -179,6 +179,32 @@ int unix_connect(char *path) return sock; } +int cdev_connect(char *path) +{ + struct stat st; + char *opts; + int fd; + + opts = strchr(path,','); + if (opts) { + *opts = 0; + opts++; + } + + fd = open(path, O_RDWR); + if (fd == -1) { + fprintf(stderr, "open %s: %s\n", path, strerror(errno)); + return -1; + } + fstat(fd, &st); + if (!S_ISCHR(st.st_mode)) { + fprintf(stderr, "not a character device: %s\n", path); + close(fd); + return -1; + } + return fd; +} + int pipe_connect(char *path) { struct stat st; |