X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Frtapelib.c;h=cfc64dadce8fbbb102187c924787bafbd6cf0ca4;hb=133a9e5b8687b0d0c0d1db32fe51fb8a937d7270;hp=c9cd90e6010471966ad2e139478e5a703ff18383;hpb=1521a94b11b0b7a2fe2a8318207d7d6b4bdbf76b;p=chaz%2Ftar diff --git a/src/rtapelib.c b/src/rtapelib.c index c9cd90e..cfc64da 100644 --- a/src/rtapelib.c +++ b/src/rtapelib.c @@ -1,5 +1,5 @@ /* Functions for communicating with a remote tape drive. - Copyright (C) 1988, 1992, 1994, 1996 Free Software Foundation, Inc. + Copyright 1988, 1992, 1994, 1996, 1997, 1999 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -32,6 +32,9 @@ #include "system.h" +#include "basename.h" +#include "safe-read.h" + /* Try hard to get EOPNOTSUPP defined. 486/ISC has it in net/errno.h, 3B2/SVR3 has it in sys/inet.h. Otherwise, like on MSDOS, use EINVAL. */ @@ -144,7 +147,7 @@ get_status_string (int handle, char *command_buffer) counter < COMMAND_BUFFER_SIZE; counter++, cursor++) { - if (full_read (READ_SIDE (handle), cursor, 1) != 1) + if (safe_read (READ_SIDE (handle), cursor, 1) != 1) { _rmt_shutdown (handle, EIO); return 0; @@ -180,7 +183,7 @@ get_status_string (int handle, char *command_buffer) { char character; - while (full_read (READ_SIDE (handle), &character, 1) == 1) + while (safe_read (READ_SIDE (handle), &character, 1) == 1) if (character == '\n') break; } @@ -410,11 +413,7 @@ rmt_open__ (const char *path, int open_mode, int bias, const char *remote_shell) return -1; #endif } - remote_shell_basename = strrchr (remote_shell, '/'); - if (remote_shell_basename) - remote_shell_basename++; - else - remote_shell_basename = remote_shell; + remote_shell_basename = base_name (remote_shell); /* Set up the pipes for the `rsh' command, and fork. */ @@ -527,7 +526,7 @@ rmt_read__ (int handle, char *buffer, size_t length) for (counter = 0; counter < status; counter += rlen, buffer += rlen) { - rlen = full_read (READ_SIDE (handle), buffer, status - counter); + rlen = safe_read (READ_SIDE (handle), buffer, status - counter); if (rlen <= 0) { _rmt_shutdown (handle, EIO); @@ -586,6 +585,14 @@ rmt_lseek__ (int handle, off_t offset, int whence) if (offset < 0) *--p = '-'; + switch (whence) + { + case SEEK_SET: whence = 0; break; + case SEEK_CUR: whence = 1; break; + case SEEK_END: whence = 2; break; + default: abort (); + } + sprintf (command_buffer, "L%s\n%d\n", p, whence); if (do_command (handle, command_buffer) == -1) @@ -653,7 +660,7 @@ rmt_ioctl__ (int handle, int operation, char *argument) for (; status > 0; status -= counter, argument += counter) { - counter = full_read (READ_SIDE (handle), + counter = safe_read (READ_SIDE (handle), argument, (size_t) status); if (counter <= 0) {