]> andersk Git - openssh.git/blobdiff - sftp-client.c
- (dtucker) d_type is not mandated by POSIX, so add fallback code using
[openssh.git] / sftp-client.c
index b49e81b9179ef0a89f47a2ec6936754b0f558470..a9c895a0d61e813c5a54957753620c67d1b81a31 100644 (file)
@@ -1454,6 +1454,20 @@ 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)
@@ -1515,7 +1529,7 @@ 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(DTTOIF(dp->d_type))) {
+               if (S_ISDIR(dirent_to_mode(dp))) {
                        if (strcmp(filename, ".") == 0 ||
                            strcmp(filename, "..") == 0)
                                continue;
@@ -1523,7 +1537,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(DTTOIF(dp->d_type)) ) {
+               } else if (S_ISREG(dirent_to_mode(dp))) {
                        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.037853 seconds and 4 git commands to generate.