[BACK]Return to scp.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/scp.c between version 1.108.2.2 and 1.109

version 1.108.2.2, 2004/08/19 22:37:32 version 1.109, 2003/09/19 17:40:20
Line 88 
Line 88 
 arglist args;  arglist args;
   
 /* Bandwidth limit */  /* Bandwidth limit */
 off_t limit_rate = 0;  off_t limit = 0;
   
 /* Name of current file being transferred. */  /* Name of current file being transferred. */
 char *curfile;  char *curfile;
Line 251 
Line 251 
                         speed = strtod(optarg, &endp);                          speed = strtod(optarg, &endp);
                         if (speed <= 0 || *endp != '\0')                          if (speed <= 0 || *endp != '\0')
                                 usage();                                  usage();
                         limit_rate = speed * 1024;                          limit = speed * 1024;
                         break;                          break;
                 case 'p':                  case 'p':
                         pflag = 1;                          pflag = 1;
Line 267 
Line 267 
                         verbose_mode = 1;                          verbose_mode = 1;
                         break;                          break;
                 case 'q':                  case 'q':
                         addargs(&args, "-q");  
                         showprogress = 0;                          showprogress = 0;
                         break;                          break;
   
Line 580 
Line 579 
                                         haderr = result >= 0 ? EIO : errno;                                          haderr = result >= 0 ? EIO : errno;
                                 statbytes += result;                                  statbytes += result;
                         }                          }
                         if (limit_rate)                          if (limit)
                                 bwlimit(amt);                                  bwlimit(amt);
                 }                  }
                 if (showprogress)                  if (showprogress)
Line 654 
Line 653 
 {  {
         static struct timeval bwstart, bwend;          static struct timeval bwstart, bwend;
         static int lamt, thresh = 16384;          static int lamt, thresh = 16384;
         u_int64_t waitlen;          u_int64_t wait;
         struct timespec ts, rm;          struct timespec ts, rm;
   
         if (!timerisset(&bwstart)) {          if (!timerisset(&bwstart)) {
Line 672 
Line 671 
                 return;                  return;
   
         lamt *= 8;          lamt *= 8;
         waitlen = (double)1000000L * lamt / limit_rate;          wait = (double)1000000L * lamt / limit;
   
         bwstart.tv_sec = waitlen / 1000000L;          bwstart.tv_sec = wait / 1000000L;
         bwstart.tv_usec = waitlen % 1000000L;          bwstart.tv_usec = wait % 1000000L;
   
         if (timercmp(&bwstart, &bwend, >)) {          if (timercmp(&bwstart, &bwend, >)) {
                 timersub(&bwstart, &bwend, &bwend);                  timersub(&bwstart, &bwend, &bwend);
Line 750 
Line 749 
                         *cp++ = ch;                          *cp++ = ch;
                 } while (cp < &buf[sizeof(buf) - 1] && ch != '\n');                  } while (cp < &buf[sizeof(buf) - 1] && ch != '\n');
                 *cp = 0;                  *cp = 0;
                 if (verbose_mode)  
                         fprintf(stderr, "Sink: %s", buf);  
   
                 if (buf[0] == '\01' || buf[0] == '\02') {                  if (buf[0] == '\01' || buf[0] == '\02') {
                         if (iamremote == 0)                          if (iamremote == 0)
Line 815 
Line 812 
                         size = size * 10 + (*cp++ - '0');                          size = size * 10 + (*cp++ - '0');
                 if (*cp++ != ' ')                  if (*cp++ != ' ')
                         SCREWUP("size not delimited");                          SCREWUP("size not delimited");
                 if ((strchr(cp, '/') != NULL) || (strcmp(cp, "..") == 0)) {  
                         run_err("error: unexpected filename: %s", cp);  
                         exit(1);  
                 }  
                 if (targisdir) {                  if (targisdir) {
                         static char *namebuf;                          static char *namebuf;
                         static int cursize;                          static int cursize;
Line 840 
Line 833 
                 exists = stat(np, &stb) == 0;                  exists = stat(np, &stb) == 0;
                 if (buf[0] == 'D') {                  if (buf[0] == 'D') {
                         int mod_flag = pflag;                          int mod_flag = pflag;
                         if (!iamrecursive)  
                                 SCREWUP("received directory without -r");  
                         if (exists) {                          if (exists) {
                                 if (!S_ISDIR(stb.st_mode)) {                                  if (!S_ISDIR(stb.st_mode)) {
                                         errno = ENOTDIR;                                          errno = ENOTDIR;
Line 893 
Line 884 
                                 amt = size - i;                                  amt = size - i;
                         count += amt;                          count += amt;
                         do {                          do {
                                 j = atomicio(read, remin, cp, amt);                                  j = read(remin, cp, amt);
                                 if (j <= 0) {                                  if (j == -1 && (errno == EINTR ||
                                       errno == EAGAIN)) {
                                           continue;
                                   } else if (j <= 0) {
                                         run_err("%s", j ? strerror(errno) :                                          run_err("%s", j ? strerror(errno) :
                                             "dropped connection");                                              "dropped connection");
                                         exit(1);                                          exit(1);
Line 903 
Line 897 
                                 cp += j;                                  cp += j;
                                 statbytes += j;                                  statbytes += j;
                         } while (amt > 0);                          } while (amt > 0);
   
                         if (limit_rate)                          if (limit)
                                 bwlimit(4096);                                  bwlimit(4096);
   
                         if (count == bp->cnt) {                          if (count == bp->cnt) {
Line 933 
Line 927 
                 }                  }
                 if (pflag) {                  if (pflag) {
                         if (exists || omode != mode)                          if (exists || omode != mode)
                                 if (fchmod(ofd, omode)) {                                  if (fchmod(ofd, omode))
                                         run_err("%s: set mode: %s",                                          run_err("%s: set mode: %s",
                                             np, strerror(errno));                                              np, strerror(errno));
                                         wrerr = DISPLAYED;  
                                 }  
                 } else {                  } else {
                         if (!exists && omode != mode)                          if (!exists && omode != mode)
                                 if (fchmod(ofd, omode & ~mask)) {                                  if (fchmod(ofd, omode & ~mask))
                                         run_err("%s: set mode: %s",                                          run_err("%s: set mode: %s",
                                             np, strerror(errno));                                              np, strerror(errno));
                                         wrerr = DISPLAYED;  
                                 }  
                 }                  }
                 if (close(ofd) == -1) {                  if (close(ofd) == -1) {
                         wrerr = YES;                          wrerr = YES;
Line 1012 
Line 1002 
 usage(void)  usage(void)
 {  {
         (void) fprintf(stderr,          (void) fprintf(stderr,
             "usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]\n"              "usage: scp [-pqrvBC1246] [-F config] [-S program] [-P port]\n"
             "           [-l limit] [-o ssh_option] [-P port] [-S program]\n"              "           [-c cipher] [-i identity] [-l limit] [-o option]\n"
             "           [[user@]host1:]file1 [...] [[user@]host2:]file2\n");              "           [[user@]host1:]file1 [...] [[user@]host2:]file2\n");
         exit(1);          exit(1);
 }  }

Legend:
Removed from v.1.108.2.2  
changed lines
  Added in v.1.109