int rmtopen(char *tape, int mode) { struct mtget mt; char buf[256]; int fd; (void) snprintf(buf, sizeof (buf), "O%s\n%d\n", tape, mode); rmtstate = TS_OPEN; fd = rmtcall(tape, buf); if (fd != -1) { /* see if the rmt server supports the extended protocol */ rmtversion = rmtioctl(-1, 0); /* * Some rmt daemons apparently close the connection * when they get a bogus ioctl. See 1210852 (ignore * the evaluation). Make sure we can still talk to * the device, re-opening it if necessary. */ if (rmtversion < 1) { if (rmtstatus(&mt) < 0) { rmtclose(); rmtgetconn(); rmtversion = 0; } } } return (fd); }
int rmthost(char *host) { if ((rmtpeer = strdup(host)) == NULL) err(1, "strdup"); signal(SIGPIPE, sigrmtconnaborted); rmtgetconn(); if (rmtape < 0) return (0); return (1); }
int rmthost(const char *hostname) { if ((rmtpeer = strdup(hostname)) == NULL) err(1, "strdup failed"); signal(SIGPIPE, rmtconnaborted); rmtgetconn(); if (rmtape < 0) return (0); return (1); }
int rmthost(const char *host) { rmtpeer = strdup(host); if (rmtpeer == NULL) return (0); signal(SIGPIPE, rmtconnaborted); rmtgetconn(); if (rmtape < 0) return (0); return (1); }
int rmthost(char *host) { int len = strlen(host) + 1; rmtpeer = malloc(len); if (rmtpeer) strlcpy(rmtpeer, host, len); else rmtpeer = host; signal(SIGPIPE, rmtconnaborted); rmtgetconn(); if (rmtape < 0) return (0); return (1); }
int rmthost(char *host, uint_t blocksize) { struct sigvec sv; #ifdef __STDC__ if (print == (void (*)(const char *, ...))0) #else if (print == (void (*)())0) #endif print = rmtmsg; #ifdef __STDC__ if (Exit == (void (*)(int))0) #else if (Exit == (void (*)())0) #endif Exit = exit; if (rmtape >= 0 && rmtstate != TS_OPEN) { (void) close(rmtape); rmtape = -1; } if (rmtpeer_malloc) (void) free(rmtpeer_malloc); rmtpeer = rmtpeer_malloc = strdup(host); if (rmtpeer == (char *)0) return (0); ntrec = blocksize; sv.sa_flags = SA_RESTART; (void) sigemptyset(&sv.sa_mask); sv.sv_handler = rmtconnaborted; (void) sigvec(SIGPIPE, &sv, (struct sigvec *)0); rmtgetconn(); if (rmtape < 0) return (0); return (1); }