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

Diff for /src/usr.bin/ssh/sftp.c between version 1.127 and 1.128

version 1.127, 2010/09/23 13:34:43 version 1.128, 2010/09/25 09:30:16
Line 738 
Line 738 
         glob_t g;          glob_t g;
         u_int i, c = 1, colspace = 0, columns = 1;          u_int i, c = 1, colspace = 0, columns = 1;
         Attrib *a = NULL;          Attrib *a = NULL;
           int err;
           char *fname, *lname;
   
         memset(&g, 0, sizeof(g));          memset(&g, 0, sizeof(g));
   
         if (remote_glob(conn, path, GLOB_MARK|GLOB_NOCHECK|GLOB_BRACE,          if (remote_glob(conn, path,
             NULL, &g) || (g.gl_pathc && !g.gl_matchc)) {              GLOB_MARK|GLOB_NOCHECK|GLOB_BRACE|GLOB_KEEPSTAT, NULL, &g) ||
               (g.gl_pathc && !g.gl_matchc)) {
                 if (g.gl_pathc)                  if (g.gl_pathc)
                         globfree(&g);                          globfree(&g);
                 error("Can't ls: \"%s\" not found", path);                  error("Can't ls: \"%s\" not found", path);
                 return (-1);                  return -1;
         }          }
   
         if (interrupted)          if (interrupted)
Line 756 
Line 759 
          * If the glob returns a single match and it is a directory,           * If the glob returns a single match and it is a directory,
          * then just list its contents.           * then just list its contents.
          */           */
         if (g.gl_matchc == 1) {          if (g.gl_matchc == 1 && g.gl_statv[0] != NULL &&
                 if ((a = do_lstat(conn, g.gl_pathv[0], 1)) == NULL) {              S_ISDIR(g.gl_statv[0]->st_mode)) {
                         globfree(&g);                  err = do_ls_dir(conn, g.gl_pathv[0], strip_path, lflag);
                         return (-1);                  globfree(&g);
                 }                  return err;
                 if ((a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) &&  
                     S_ISDIR(a->perm)) {  
                         int err;  
   
                         err = do_ls_dir(conn, g.gl_pathv[0], strip_path, lflag);  
                         globfree(&g);  
                         return (err);  
                 }  
         }          }
   
         if (!(lflag & LS_SHORT_VIEW)) {          if (!(lflag & LS_SHORT_VIEW)) {
Line 788 
Line 783 
         }          }
   
         for (i = 0; g.gl_pathv[i] && !interrupted; i++, a = NULL) {          for (i = 0; g.gl_pathv[i] && !interrupted; i++, a = NULL) {
                 char *fname;  
   
                 fname = path_strip(g.gl_pathv[i], strip_path);                  fname = path_strip(g.gl_pathv[i], strip_path);
   
                 if (lflag & LS_LONG_VIEW) {                  if (lflag & LS_LONG_VIEW) {
                         char *lname;                          if (g.gl_statv[i] == NULL) {
                         struct stat sb;                                  error("no stat information for %s", fname);
                                   continue;
                         /*                          }
                          * XXX: this is slow - 1 roundtrip per path                          lname = ls_file(fname, g.gl_statv[i], 1,
                          * A solution to this is to fork glob() and                              (lflag & LS_SI_UNITS));
                          * build a sftp specific version which keeps the  
                          * attribs (which currently get thrown away)  
                          * that the server returns as well as the filenames.  
                          */  
                         memset(&sb, 0, sizeof(sb));  
                         if (a == NULL)  
                                 a = do_lstat(conn, g.gl_pathv[i], 1);  
                         if (a != NULL)  
                                 attrib_to_stat(a, &sb);  
                         lname = ls_file(fname, &sb, 1, (lflag & LS_SI_UNITS));  
                         printf("%s\n", lname);                          printf("%s\n", lname);
                         xfree(lname);                          xfree(lname);
                 } else {                  } else {
Line 829 
Line 811 
         if (g.gl_pathc)          if (g.gl_pathc)
                 globfree(&g);                  globfree(&g);
   
         return (0);          return 0;
 }  }
   
 static int  static int

Legend:
Removed from v.1.127  
changed lines
  Added in v.1.128