]> andersk Git - openssh.git/blobdiff - sftp-client.c
- djm@cvs.openbsd.org 2010/01/30 02:54:53
[openssh.git] / sftp-client.c
index a9c895a0d61e813c5a54957753620c67d1b81a31..6124c0f408cc2ed731786a28b3bdcb47b069a4b1 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp-client.c,v 1.89 2009/08/18 18:36:20 djm Exp $ */
+/* $OpenBSD: sftp-client.c,v 1.90 2009/10/11 10:41:26 dtucker Exp $ */
 /*
  * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
  *
@@ -37,9 +37,6 @@
 #include <sys/uio.h>
 
 #include <dirent.h>
-#ifdef DTTOIF_IN_FS_FFS_DIR_H
-# include <fs/ffs/dir.h>
-#endif
 #include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
@@ -1454,20 +1451,6 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
        return status;
 }
 
-static mode_t
-dirent_to_mode(struct dirent *dp)
-{
-#if defined(HAVE_STRUCT_DIRENT_D_TYPE) && defined(DTTOIF)
-       return DTTOIF(dp->d_type);
-#else
-       struct stat sb;
-
-       if (stat(dp->d_name, &sb) == -1)
-               return 0;
-       return sb.st_mode;
-#endif
-}      
-
 static int
 upload_dir_internal(struct sftp_conn *conn, char *src, char *dst,
     int pflag, int printflag, int depth)
@@ -1529,7 +1512,11 @@ upload_dir_internal(struct sftp_conn *conn, char *src, char *dst,
                new_dst = path_append(dst, filename);
                new_src = path_append(src, filename);
 
-               if (S_ISDIR(dirent_to_mode(dp))) {
+               if (lstat(new_src, &sb) == -1) {
+                       logit("%s: lstat failed: %s", filename,
+                           strerror(errno));
+                       ret = -1;
+               } else if (S_ISDIR(sb.st_mode)) {
                        if (strcmp(filename, ".") == 0 ||
                            strcmp(filename, "..") == 0)
                                continue;
@@ -1537,7 +1524,7 @@ upload_dir_internal(struct sftp_conn *conn, char *src, char *dst,
                        if (upload_dir_internal(conn, new_src, new_dst,
                            pflag, depth + 1, printflag) == -1)
                                ret = -1;
-               } else if (S_ISREG(dirent_to_mode(dp))) {
+               } else if (S_ISREG(sb.st_mode)) {
                        if (do_upload(conn, new_src, new_dst, pflag) == -1) {
                                error("Uploading of file %s to %s failed!",
                                    new_src, new_dst);
This page took 0.0667 seconds and 4 git commands to generate.