diff options
Diffstat (limited to 'sftp-client.c')
-rw-r--r-- | sftp-client.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/sftp-client.c b/sftp-client.c index b49e81b91..a9c895a0d 100644 --- a/sftp-client.c +++ b/sftp-client.c | |||
@@ -1454,6 +1454,20 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path, | |||
1454 | return status; | 1454 | return status; |
1455 | } | 1455 | } |
1456 | 1456 | ||
1457 | static mode_t | ||
1458 | dirent_to_mode(struct dirent *dp) | ||
1459 | { | ||
1460 | #if defined(HAVE_STRUCT_DIRENT_D_TYPE) && defined(DTTOIF) | ||
1461 | return DTTOIF(dp->d_type); | ||
1462 | #else | ||
1463 | struct stat sb; | ||
1464 | |||
1465 | if (stat(dp->d_name, &sb) == -1) | ||
1466 | return 0; | ||
1467 | return sb.st_mode; | ||
1468 | #endif | ||
1469 | } | ||
1470 | |||
1457 | static int | 1471 | static int |
1458 | upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, | 1472 | upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, |
1459 | int pflag, int printflag, int depth) | 1473 | int pflag, int printflag, int depth) |
@@ -1515,7 +1529,7 @@ upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, | |||
1515 | new_dst = path_append(dst, filename); | 1529 | new_dst = path_append(dst, filename); |
1516 | new_src = path_append(src, filename); | 1530 | new_src = path_append(src, filename); |
1517 | 1531 | ||
1518 | if (S_ISDIR(DTTOIF(dp->d_type))) { | 1532 | if (S_ISDIR(dirent_to_mode(dp))) { |
1519 | if (strcmp(filename, ".") == 0 || | 1533 | if (strcmp(filename, ".") == 0 || |
1520 | strcmp(filename, "..") == 0) | 1534 | strcmp(filename, "..") == 0) |
1521 | continue; | 1535 | continue; |
@@ -1523,7 +1537,7 @@ upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, | |||
1523 | if (upload_dir_internal(conn, new_src, new_dst, | 1537 | if (upload_dir_internal(conn, new_src, new_dst, |
1524 | pflag, depth + 1, printflag) == -1) | 1538 | pflag, depth + 1, printflag) == -1) |
1525 | ret = -1; | 1539 | ret = -1; |
1526 | } else if (S_ISREG(DTTOIF(dp->d_type)) ) { | 1540 | } else if (S_ISREG(dirent_to_mode(dp))) { |
1527 | if (do_upload(conn, new_src, new_dst, pflag) == -1) { | 1541 | if (do_upload(conn, new_src, new_dst, pflag) == -1) { |
1528 | error("Uploading of file %s to %s failed!", | 1542 | error("Uploading of file %s to %s failed!", |
1529 | new_src, new_dst); | 1543 | new_src, new_dst); |