diff options
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/Kbuild.src | 55 | ||||
-rw-r--r-- | libbb/appletlib.c | 117 | ||||
-rw-r--r-- | libbb/copy_file.c | 3 | ||||
-rw-r--r-- | libbb/executable.c | 29 | ||||
-rw-r--r-- | libbb/find_mount_point.c | 45 | ||||
-rw-r--r-- | libbb/find_pid_by_name.c | 6 | ||||
-rw-r--r-- | libbb/get_last_path_component.c | 28 | ||||
-rw-r--r-- | libbb/get_line_from_file.c | 4 | ||||
-rw-r--r-- | libbb/human_readable.c | 6 | ||||
-rw-r--r-- | libbb/lineedit.c | 83 | ||||
-rw-r--r-- | libbb/make_directory.c | 29 | ||||
-rw-r--r-- | libbb/messages.c | 2 | ||||
-rw-r--r-- | libbb/mode_string.c | 2 | ||||
-rw-r--r-- | libbb/printable_string.c | 2 | ||||
-rw-r--r-- | libbb/procps.c | 3 | ||||
-rw-r--r-- | libbb/read_printf.c | 5 | ||||
-rw-r--r-- | libbb/setup_environment.c | 11 | ||||
-rw-r--r-- | libbb/vfork_daemon_rexec.c | 6 | ||||
-rw-r--r-- | libbb/xatonum_template.c | 5 | ||||
-rw-r--r-- | libbb/xconnect.c | 14 | ||||
-rw-r--r-- | libbb/xfuncs.c | 4 | ||||
-rw-r--r-- | libbb/xfuncs_printf.c | 2 | ||||
-rw-r--r-- | libbb/xreadlink.c | 2 |
23 files changed, 415 insertions, 48 deletions
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index 8c9ba8cca..9323a8968 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src | |||
@@ -12,14 +12,11 @@ INSERT | |||
12 | 12 | ||
13 | lib-y += appletlib.o | 13 | lib-y += appletlib.o |
14 | lib-y += ask_confirmation.o | 14 | lib-y += ask_confirmation.o |
15 | lib-y += bb_askpass.o | ||
16 | lib-y += bb_bswap_64.o | 15 | lib-y += bb_bswap_64.o |
17 | lib-y += bb_do_delay.o | ||
18 | lib-y += bb_pwd.o | 16 | lib-y += bb_pwd.o |
19 | lib-y += bb_qsort.o | 17 | lib-y += bb_qsort.o |
20 | #lib-y += bb_strtod.o | 18 | #lib-y += bb_strtod.o |
21 | lib-y += bb_strtonum.o | 19 | lib-y += bb_strtonum.o |
22 | lib-y += change_identity.o | ||
23 | lib-y += chomp.o | 20 | lib-y += chomp.o |
24 | lib-y += compare_string_array.o | 21 | lib-y += compare_string_array.o |
25 | lib-y += concat_path_file.o | 22 | lib-y += concat_path_file.o |
@@ -28,32 +25,23 @@ lib-y += copy_file.o | |||
28 | lib-y += copyfd.o | 25 | lib-y += copyfd.o |
29 | lib-y += crc32.o | 26 | lib-y += crc32.o |
30 | lib-y += default_error_retval.o | 27 | lib-y += default_error_retval.o |
31 | lib-y += device_open.o | ||
32 | lib-y += dump.o | 28 | lib-y += dump.o |
33 | lib-y += executable.o | 29 | lib-y += executable.o |
34 | lib-y += fclose_nonstdin.o | 30 | lib-y += fclose_nonstdin.o |
35 | lib-y += fflush_stdout_and_exit.o | 31 | lib-y += fflush_stdout_and_exit.o |
36 | lib-y += fgets_str.o | 32 | lib-y += fgets_str.o |
37 | lib-y += find_pid_by_name.o | 33 | lib-y += find_pid_by_name.o |
38 | lib-y += find_root_device.o | ||
39 | lib-y += full_write.o | 34 | lib-y += full_write.o |
40 | lib-y += get_console.o | ||
41 | lib-y += get_last_path_component.o | 35 | lib-y += get_last_path_component.o |
42 | lib-y += get_line_from_file.o | 36 | lib-y += get_line_from_file.o |
43 | lib-y += getpty.o | 37 | lib-y += getopt32.o |
44 | lib-y += get_volsize.o | ||
45 | lib-y += herror_msg.o | 38 | lib-y += herror_msg.o |
46 | lib-y += human_readable.o | 39 | lib-y += human_readable.o |
47 | lib-y += inet_common.o | ||
48 | lib-y += inode_hash.o | ||
49 | lib-y += isdirectory.o | 40 | lib-y += isdirectory.o |
50 | lib-y += kernel_version.o | ||
51 | lib-y += last_char_is.o | 41 | lib-y += last_char_is.o |
52 | lib-y += lineedit.o lineedit_ptr_hack.o | 42 | lib-y += lineedit.o lineedit_ptr_hack.o |
53 | lib-y += llist.o | 43 | lib-y += llist.o |
54 | lib-y += login.o | ||
55 | lib-y += make_directory.o | 44 | lib-y += make_directory.o |
56 | lib-y += makedev.o | ||
57 | lib-y += hash_md5_sha.o | 45 | lib-y += hash_md5_sha.o |
58 | # Alternative (disabled) MD5 implementation | 46 | # Alternative (disabled) MD5 implementation |
59 | #lib-y += hash_md5prime.o | 47 | #lib-y += hash_md5prime.o |
@@ -61,20 +49,15 @@ lib-y += messages.o | |||
61 | lib-y += mode_string.o | 49 | lib-y += mode_string.o |
62 | lib-y += parse_mode.o | 50 | lib-y += parse_mode.o |
63 | lib-y += perror_msg.o | 51 | lib-y += perror_msg.o |
64 | lib-y += perror_nomsg.o | ||
65 | lib-y += perror_nomsg_and_die.o | 52 | lib-y += perror_nomsg_and_die.o |
66 | lib-y += pidfile.o | ||
67 | lib-y += platform.o | 53 | lib-y += platform.o |
68 | lib-y += printable.o | 54 | lib-y += printable.o |
69 | lib-y += printable_string.o | 55 | lib-y += printable_string.o |
70 | lib-y += print_flags.o | ||
71 | lib-y += process_escape_sequence.o | 56 | lib-y += process_escape_sequence.o |
72 | lib-y += procps.o | 57 | lib-y += procps.o |
73 | lib-y += progress.o | ||
74 | lib-y += ptr_to_globals.o | 58 | lib-y += ptr_to_globals.o |
75 | lib-y += read.o | 59 | lib-y += read.o |
76 | lib-y += read_printf.o | 60 | lib-y += read_printf.o |
77 | lib-y += read_key.o | ||
78 | lib-y += recursive_action.o | 61 | lib-y += recursive_action.o |
79 | lib-y += remove_file.o | 62 | lib-y += remove_file.o |
80 | lib-y += run_shell.o | 63 | lib-y += run_shell.o |
@@ -84,13 +67,9 @@ lib-y += safe_strncpy.o | |||
84 | lib-y += safe_write.o | 67 | lib-y += safe_write.o |
85 | lib-y += securetty.o | 68 | lib-y += securetty.o |
86 | lib-y += setup_environment.o | 69 | lib-y += setup_environment.o |
87 | lib-y += signals.o | ||
88 | lib-y += simplify_path.o | ||
89 | lib-y += single_argv.o | 70 | lib-y += single_argv.o |
90 | lib-y += skip_whitespace.o | 71 | lib-y += skip_whitespace.o |
91 | lib-y += speed_table.o | ||
92 | lib-y += str_tolower.o | 72 | lib-y += str_tolower.o |
93 | lib-y += strrstr.o | ||
94 | lib-y += sysconf.o | 73 | lib-y += sysconf.o |
95 | lib-y += time.o | 74 | lib-y += time.o |
96 | lib-y += trim.o | 75 | lib-y += trim.o |
@@ -98,20 +77,44 @@ lib-y += u_signal_names.o | |||
98 | lib-y += uuencode.o | 77 | lib-y += uuencode.o |
99 | lib-y += verror_msg.o | 78 | lib-y += verror_msg.o |
100 | lib-y += vfork_daemon_rexec.o | 79 | lib-y += vfork_daemon_rexec.o |
101 | lib-y += warn_ignoring_args.o | ||
102 | lib-y += wfopen.o | 80 | lib-y += wfopen.o |
103 | lib-y += wfopen_input.o | 81 | lib-y += wfopen_input.o |
104 | lib-y += write.o | ||
105 | lib-y += xatonum.o | 82 | lib-y += xatonum.o |
106 | lib-y += xconnect.o | 83 | lib-y += xconnect.o |
107 | lib-y += xfuncs.o | 84 | lib-y += xfuncs.o |
108 | lib-y += xfuncs_printf.o | 85 | lib-y += xfuncs_printf.o |
109 | lib-y += xfunc_die.o | 86 | lib-y += xfunc_die.o |
110 | lib-y += xgetcwd.o | 87 | lib-y += xgetcwd.o |
111 | lib-y += xgethostbyname.o | ||
112 | lib-y += xreadlink.o | 88 | lib-y += xreadlink.o |
113 | lib-y += xrealloc_vector.o | 89 | lib-y += xrealloc_vector.o |
114 | 90 | ||
91 | lib-$(CONFIG_PLATFORM_POSIX) += bb_askpass.o | ||
92 | lib-$(CONFIG_PLATFORM_POSIX) += bb_do_delay.o | ||
93 | lib-$(CONFIG_PLATFORM_POSIX) += change_identity.o | ||
94 | lib-$(CONFIG_PLATFORM_POSIX) += device_open.o | ||
95 | lib-$(CONFIG_PLATFORM_POSIX) += find_root_device.o | ||
96 | lib-$(CONFIG_PLATFORM_POSIX) += get_console.o | ||
97 | lib-$(CONFIG_PLATFORM_POSIX) += getpty.o | ||
98 | lib-$(CONFIG_PLATFORM_POSIX) += get_volsize.o | ||
99 | lib-$(CONFIG_PLATFORM_POSIX) += inet_common.o | ||
100 | lib-$(CONFIG_PLATFORM_POSIX) += inode_hash.o | ||
101 | lib-$(CONFIG_PLATFORM_POSIX) += kernel_version.o | ||
102 | lib-$(CONFIG_PLATFORM_POSIX) += login.o | ||
103 | lib-$(CONFIG_PLATFORM_POSIX) += makedev.o | ||
104 | lib-$(CONFIG_PLATFORM_POSIX) += perror_nomsg.o | ||
105 | lib-$(CONFIG_PLATFORM_POSIX) += pidfile.o | ||
106 | lib-$(CONFIG_PLATFORM_POSIX) += print_flags.o | ||
107 | lib-$(CONFIG_PLATFORM_POSIX) += progress.o | ||
108 | lib-$(CONFIG_PLATFORM_POSIX) += read_key.o | ||
109 | lib-$(CONFIG_PLATFORM_POSIX) += signals.o | ||
110 | lib-$(CONFIG_PLATFORM_POSIX) += simplify_path.o | ||
111 | lib-$(CONFIG_PLATFORM_POSIX) += speed_table.o | ||
112 | lib-$(CONFIG_PLATFORM_POSIX) += strrstr.o | ||
113 | lib-$(CONFIG_PLATFORM_POSIX) += udp_io.o | ||
114 | lib-$(CONFIG_PLATFORM_POSIX) += warn_ignoring_args.o | ||
115 | lib-$(CONFIG_PLATFORM_POSIX) += write.o | ||
116 | lib-$(CONFIG_PLATFORM_POSIX) += xgethostbyname.o | ||
117 | |||
115 | lib-$(CONFIG_PLATFORM_LINUX) += match_fstype.o | 118 | lib-$(CONFIG_PLATFORM_LINUX) += match_fstype.o |
116 | 119 | ||
117 | lib-$(CONFIG_FEATURE_UTMP) += utmp.o | 120 | lib-$(CONFIG_FEATURE_UTMP) += utmp.o |
@@ -123,7 +126,7 @@ lib-$(CONFIG_FEATURE_MTAB_SUPPORT) += mtab.o | |||
123 | lib-$(CONFIG_UNICODE_SUPPORT) += unicode.o | 126 | lib-$(CONFIG_UNICODE_SUPPORT) += unicode.o |
124 | lib-$(CONFIG_FEATURE_CHECK_NAMES) += die_if_bad_username.o | 127 | lib-$(CONFIG_FEATURE_CHECK_NAMES) += die_if_bad_username.o |
125 | 128 | ||
126 | lib-$(CONFIG_NC) += udp_io.o | 129 | lib-$(CONFIG_NC_110_COMPAT) += udp_io.o |
127 | lib-$(CONFIG_NETCAT) += udp_io.o | 130 | lib-$(CONFIG_NETCAT) += udp_io.o |
128 | lib-$(CONFIG_DNSD) += udp_io.o | 131 | lib-$(CONFIG_DNSD) += udp_io.o |
129 | lib-$(CONFIG_NTPD) += udp_io.o | 132 | lib-$(CONFIG_NTPD) += udp_io.o |
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 319bcc263..7df75c665 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -48,6 +48,13 @@ | |||
48 | # define IF_FEATURE_INDIVIDUAL(...) __VA_ARGS__ | 48 | # define IF_FEATURE_INDIVIDUAL(...) __VA_ARGS__ |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | #if (ENABLE_FEATURE_INSTALLER && !ENABLE_PLATFORM_MINGW32) || \ | ||
52 | (ENABLE_PLATFORM_MINGW32 && (ENABLE_FEATURE_PREFER_APPLETS \ | ||
53 | || ENABLE_FEATURE_SH_STANDALONE \ | ||
54 | || ENABLE_FEATURE_SH_NOFORK)) | ||
55 | # define IF_FULL_LIST_OPTION(...) __VA_ARGS__ | ||
56 | #endif | ||
57 | |||
51 | #include "usage_compressed.h" | 58 | #include "usage_compressed.h" |
52 | 59 | ||
53 | 60 | ||
@@ -96,6 +103,7 @@ static const char usage_messages[] ALIGN1 = UNPACKED_USAGE; | |||
96 | #if ENABLE_FEATURE_COMPRESS_USAGE | 103 | #if ENABLE_FEATURE_COMPRESS_USAGE |
97 | 104 | ||
98 | static const char packed_usage[] ALIGN1 = { PACKED_USAGE }; | 105 | static const char packed_usage[] ALIGN1 = { PACKED_USAGE }; |
106 | #define BB_ARCHIVE_PUBLIC | ||
99 | # include "bb_archive.h" | 107 | # include "bb_archive.h" |
100 | static const char *unpack_usage_messages(void) | 108 | static const char *unpack_usage_messages(void) |
101 | { | 109 | { |
@@ -163,7 +171,7 @@ void FAST_FUNC bb_show_usage(void) | |||
163 | ap--; | 171 | ap--; |
164 | } | 172 | } |
165 | full_write2_str(bb_banner); | 173 | full_write2_str(bb_banner); |
166 | full_write2_str(" multi-call binary.\n"); | 174 | full_write2_str(" multi-call binary\n"); |
167 | if (*p == '\b') | 175 | if (*p == '\b') |
168 | full_write2_str("\nNo help available.\n\n"); | 176 | full_write2_str("\nNo help available.\n\n"); |
169 | else { | 177 | else { |
@@ -326,6 +334,10 @@ void lbb_prepare(const char *applet | |||
326 | if (ENABLE_LOCALE_SUPPORT) | 334 | if (ENABLE_LOCALE_SUPPORT) |
327 | setlocale(LC_ALL, ""); | 335 | setlocale(LC_ALL, ""); |
328 | 336 | ||
337 | #if ENABLE_PLATFORM_MINGW32 | ||
338 | init_winsock(); | ||
339 | #endif | ||
340 | |||
329 | #if ENABLE_FEATURE_INDIVIDUAL | 341 | #if ENABLE_FEATURE_INDIVIDUAL |
330 | /* Redundant for busybox (run_applet_and_exit covers that case) | 342 | /* Redundant for busybox (run_applet_and_exit covers that case) |
331 | * but needed for "individual applet" mode */ | 343 | * but needed for "individual applet" mode */ |
@@ -716,6 +728,7 @@ static void check_suid(int applet_no) | |||
716 | 728 | ||
717 | 729 | ||
718 | # if ENABLE_FEATURE_INSTALLER | 730 | # if ENABLE_FEATURE_INSTALLER |
731 | # if !ENABLE_PLATFORM_MINGW32 | ||
719 | static const char usr_bin [] ALIGN1 = "/usr/bin/"; | 732 | static const char usr_bin [] ALIGN1 = "/usr/bin/"; |
720 | static const char usr_sbin[] ALIGN1 = "/usr/sbin/"; | 733 | static const char usr_sbin[] ALIGN1 = "/usr/sbin/"; |
721 | static const char *const install_dir[] = { | 734 | static const char *const install_dir[] = { |
@@ -760,6 +773,29 @@ static void install_links(const char *busybox, int use_symbolic_links, | |||
760 | continue; | 773 | continue; |
761 | } | 774 | } |
762 | } | 775 | } |
776 | # else /* ENABLE_PLATFORM_MINGW32 */ | ||
777 | static void install_links(const char *busybox, | ||
778 | int use_symbolic_links UNUSED_PARAM, char *custom_install_dir) | ||
779 | { | ||
780 | char *fpc; | ||
781 | const char *appname = applet_names; | ||
782 | int rc; | ||
783 | |||
784 | if (!is_directory(custom_install_dir, FALSE)) | ||
785 | bb_error_msg_and_die("'%s' is not a directory", custom_install_dir); | ||
786 | |||
787 | while (*appname) { | ||
788 | fpc = xasprintf("%s/%s.exe", custom_install_dir, appname); | ||
789 | rc = link(busybox, fpc); | ||
790 | if (rc != 0 && errno != EEXIST) { | ||
791 | bb_simple_perror_msg(fpc); | ||
792 | } | ||
793 | free(fpc); | ||
794 | while (*appname++ != '\0') | ||
795 | continue; | ||
796 | } | ||
797 | } | ||
798 | # endif | ||
763 | # elif ENABLE_BUSYBOX | 799 | # elif ENABLE_BUSYBOX |
764 | static void install_links(const char *busybox UNUSED_PARAM, | 800 | static void install_links(const char *busybox UNUSED_PARAM, |
765 | int use_symbolic_links UNUSED_PARAM, | 801 | int use_symbolic_links UNUSED_PARAM, |
@@ -799,16 +835,21 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) | |||
799 | 835 | ||
800 | dup2(1, 2); | 836 | dup2(1, 2); |
801 | full_write2_str(bb_banner); /* reuse const string */ | 837 | full_write2_str(bb_banner); /* reuse const string */ |
802 | full_write2_str(" multi-call binary.\n"); /* reuse */ | 838 | full_write2_str(" multi-call binary\n"); /* reuse */ |
839 | #if defined(MINGW_VER) | ||
840 | if (sizeof(MINGW_VER) > 5) { | ||
841 | full_write2_str(MINGW_VER "\n\n"); | ||
842 | } | ||
843 | #endif | ||
803 | full_write2_str( | 844 | full_write2_str( |
804 | "BusyBox is copyrighted by many authors between 1998-2015.\n" | 845 | "BusyBox is copyrighted by many authors between 1998-2018.\n" |
805 | "Licensed under GPLv2. See source distribution for detailed\n" | 846 | "Licensed under GPLv2. See source distribution for detailed\n" |
806 | "copyright notices.\n" | 847 | "copyright notices.\n" |
807 | "\n" | 848 | "\n" |
808 | "Usage: busybox [function [arguments]...]\n" | 849 | "Usage: busybox [function [arguments]...]\n" |
809 | " or: busybox --list"IF_FEATURE_INSTALLER("[-full]")"\n" | 850 | " or: busybox --list"IF_FULL_LIST_OPTION("[-full]")"\n" |
810 | IF_FEATURE_INSTALLER( | 851 | IF_FEATURE_INSTALLER( |
811 | " or: busybox --install [-s] [DIR]\n" | 852 | " or: busybox --install "IF_NOT_PLATFORM_MINGW32("[-s] ")"[DIR]\n" |
812 | ) | 853 | ) |
813 | " or: function [arguments]...\n" | 854 | " or: function [arguments]...\n" |
814 | "\n" | 855 | "\n" |
@@ -826,6 +867,11 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) | |||
826 | "\tTo run external program, use full path (/sbin/ip instead of ip).\n" | 867 | "\tTo run external program, use full path (/sbin/ip instead of ip).\n" |
827 | ) | 868 | ) |
828 | "\n" | 869 | "\n" |
870 | #if ENABLE_GLOBBING | ||
871 | "\tSupport for native Windows wildcards is enabled. In some\n" | ||
872 | "\tcases this may result in wildcards being processed twice.\n" | ||
873 | "\n" | ||
874 | #endif | ||
829 | "Currently defined functions:\n" | 875 | "Currently defined functions:\n" |
830 | ); | 876 | ); |
831 | col = 0; | 877 | col = 0; |
@@ -857,9 +903,23 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) | |||
857 | const char *a = applet_names; | 903 | const char *a = applet_names; |
858 | dup2(1, 2); | 904 | dup2(1, 2); |
859 | while (*a) { | 905 | while (*a) { |
860 | # if ENABLE_FEATURE_INSTALLER | 906 | # if ENABLE_FEATURE_INSTALLER && !ENABLE_PLATFORM_MINGW32 |
861 | if (argv[1][6]) /* --list-full? */ | 907 | if (argv[1][6]) /* --list-full? */ |
862 | full_write2_str(install_dir[APPLET_INSTALL_LOC(i)] + 1); | 908 | full_write2_str(install_dir[APPLET_INSTALL_LOC(i)] + 1); |
909 | # elif ENABLE_PLATFORM_MINGW32 && (ENABLE_FEATURE_PREFER_APPLETS \ | ||
910 | || ENABLE_FEATURE_SH_STANDALONE \ | ||
911 | || ENABLE_FEATURE_SH_NOFORK) | ||
912 | if (argv[1][6]) { /* --list-full? */ | ||
913 | const char *str; | ||
914 | |||
915 | if (APPLET_IS_NOFORK(i)) | ||
916 | str = "NOFORK "; | ||
917 | else if (APPLET_IS_NOEXEC(i)) | ||
918 | str = "noexec "; | ||
919 | else | ||
920 | str = " "; | ||
921 | full_write2_str(str); | ||
922 | } | ||
863 | # endif | 923 | # endif |
864 | full_write2_str(a); | 924 | full_write2_str(a); |
865 | full_write2_str("\n"); | 925 | full_write2_str("\n"); |
@@ -871,6 +931,7 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) | |||
871 | } | 931 | } |
872 | 932 | ||
873 | if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) { | 933 | if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) { |
934 | #if !ENABLE_PLATFORM_MINGW32 | ||
874 | int use_symbolic_links; | 935 | int use_symbolic_links; |
875 | const char *busybox; | 936 | const char *busybox; |
876 | 937 | ||
@@ -891,6 +952,14 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) | |||
891 | */ | 952 | */ |
892 | use_symbolic_links = (argv[2] && strcmp(argv[2], "-s") == 0 && ++argv); | 953 | use_symbolic_links = (argv[2] && strcmp(argv[2], "-s") == 0 && ++argv); |
893 | install_links(busybox, use_symbolic_links, argv[2]); | 954 | install_links(busybox, use_symbolic_links, argv[2]); |
955 | #else | ||
956 | /* busybox --install [DIR] | ||
957 | * where DIR is the directory to install to. If DIR is not | ||
958 | * provided put the links in the same directory as busybox. | ||
959 | */ | ||
960 | install_links(bb_busybox_exec_path, FALSE, argv[2] ? argv[2] : | ||
961 | dirname(xstrdup(bb_busybox_exec_path))); | ||
962 | #endif | ||
894 | return 0; | 963 | return 0; |
895 | } | 964 | } |
896 | 965 | ||
@@ -913,6 +982,11 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) | |||
913 | # endif | 982 | # endif |
914 | 983 | ||
915 | # if NUM_APPLETS > 0 | 984 | # if NUM_APPLETS > 0 |
985 | |||
986 | # if ENABLE_PLATFORM_MINGW32 | ||
987 | char bb_applet_name[MAX_APPLET_NAME_LEN+1]; | ||
988 | # endif | ||
989 | |||
916 | void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **argv) | 990 | void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **argv) |
917 | { | 991 | { |
918 | int argc = string_array_len(argv); | 992 | int argc = string_array_len(argv); |
@@ -922,6 +996,9 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **ar | |||
922 | * "-/sbin/halt" -> "halt", for example. | 996 | * "-/sbin/halt" -> "halt", for example. |
923 | */ | 997 | */ |
924 | applet_name = name; | 998 | applet_name = name; |
999 | #if ENABLE_PLATFORM_MINGW32 | ||
1000 | strcpy(bb_applet_name, applet_name); | ||
1001 | #endif | ||
925 | 1002 | ||
926 | /* Special case. POSIX says "test --help" | 1003 | /* Special case. POSIX says "test --help" |
927 | * should be no different from e.g. "test --foo". | 1004 | * should be no different from e.g. "test --foo". |
@@ -947,6 +1024,7 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **ar | |||
947 | } | 1024 | } |
948 | if (ENABLE_FEATURE_SUID) | 1025 | if (ENABLE_FEATURE_SUID) |
949 | check_suid(applet_no); | 1026 | check_suid(applet_no); |
1027 | |||
950 | xfunc_error_retval = applet_main[applet_no](argc, argv); | 1028 | xfunc_error_retval = applet_main[applet_no](argc, argv); |
951 | /* Note: applet_main() may also not return (die on a xfunc or such) */ | 1029 | /* Note: applet_main() may also not return (die on a xfunc or such) */ |
952 | xfunc_die(); | 1030 | xfunc_die(); |
@@ -1030,6 +1108,18 @@ int main(int argc UNUSED_PARAM, char **argv) | |||
1030 | } | 1108 | } |
1031 | #endif | 1109 | #endif |
1032 | 1110 | ||
1111 | #if defined(__MINGW64_VERSION_MAJOR) | ||
1112 | if ( stdin ) { | ||
1113 | _setmode(fileno(stdin), _O_BINARY); | ||
1114 | } | ||
1115 | if ( stdout ) { | ||
1116 | _setmode(fileno(stdout), _O_BINARY); | ||
1117 | } | ||
1118 | if ( stderr ) { | ||
1119 | _setmode(fileno(stderr), _O_BINARY); | ||
1120 | } | ||
1121 | #endif | ||
1122 | |||
1033 | #if defined(SINGLE_APPLET_MAIN) | 1123 | #if defined(SINGLE_APPLET_MAIN) |
1034 | 1124 | ||
1035 | /* Only one applet is selected in .config */ | 1125 | /* Only one applet is selected in .config */ |
@@ -1061,6 +1151,21 @@ int main(int argc UNUSED_PARAM, char **argv) | |||
1061 | applet_name = argv[0]; | 1151 | applet_name = argv[0]; |
1062 | if (applet_name[0] == '-') | 1152 | if (applet_name[0] == '-') |
1063 | applet_name++; | 1153 | applet_name++; |
1154 | # if ENABLE_PLATFORM_MINGW32 | ||
1155 | if ( argv[1] && argv[2] && strcmp(argv[1], "--busybox") == 0 ) { | ||
1156 | argv += 2; | ||
1157 | applet_name = argv[0]; | ||
1158 | } | ||
1159 | else { | ||
1160 | char *s; | ||
1161 | |||
1162 | str_tolower(argv[0]); | ||
1163 | convert_slashes(argv[0]); | ||
1164 | if (has_exe_suffix_or_dot(argv[0]) && (s=strrchr(argv[0], '.'))) { | ||
1165 | *s = '\0'; | ||
1166 | } | ||
1167 | } | ||
1168 | # endif | ||
1064 | applet_name = bb_basename(applet_name); | 1169 | applet_name = bb_basename(applet_name); |
1065 | 1170 | ||
1066 | /* If we are a result of execv("/proc/self/exe"), fix ugly comm of "exe" */ | 1171 | /* If we are a result of execv("/proc/self/exe"), fix ugly comm of "exe" */ |
diff --git a/libbb/copy_file.c b/libbb/copy_file.c index 2d6557cd4..299cd7bea 100644 --- a/libbb/copy_file.c +++ b/libbb/copy_file.c | |||
@@ -105,12 +105,15 @@ int FAST_FUNC copy_file(const char *source, const char *dest, int flags) | |||
105 | return -1; | 105 | return -1; |
106 | } | 106 | } |
107 | } else { | 107 | } else { |
108 | #if !ENABLE_PLATFORM_MINGW32 | ||
109 | /* MinGW does not have inode, and does not use device */ | ||
108 | if (source_stat.st_dev == dest_stat.st_dev | 110 | if (source_stat.st_dev == dest_stat.st_dev |
109 | && source_stat.st_ino == dest_stat.st_ino | 111 | && source_stat.st_ino == dest_stat.st_ino |
110 | ) { | 112 | ) { |
111 | bb_error_msg("'%s' and '%s' are the same file", source, dest); | 113 | bb_error_msg("'%s' and '%s' are the same file", source, dest); |
112 | return -1; | 114 | return -1; |
113 | } | 115 | } |
116 | #endif | ||
114 | dest_exists = 1; | 117 | dest_exists = 1; |
115 | } | 118 | } |
116 | 119 | ||
diff --git a/libbb/executable.c b/libbb/executable.c index 29d2a2c85..aec829945 100644 --- a/libbb/executable.c +++ b/libbb/executable.c | |||
@@ -28,6 +28,10 @@ int FAST_FUNC file_is_executable(const char *name) | |||
28 | * in all cases (*PATHp) contents are temporarily modified | 28 | * in all cases (*PATHp) contents are temporarily modified |
29 | * but are restored on return (s/:/NUL/ and back). | 29 | * but are restored on return (s/:/NUL/ and back). |
30 | */ | 30 | */ |
31 | #if !ENABLE_PLATFORM_MINGW32 | ||
32 | #define next_path_sep(s) strchr(s, ':') | ||
33 | #endif | ||
34 | |||
31 | char* FAST_FUNC find_executable(const char *filename, char **PATHp) | 35 | char* FAST_FUNC find_executable(const char *filename, char **PATHp) |
32 | { | 36 | { |
33 | /* About empty components in $PATH: | 37 | /* About empty components in $PATH: |
@@ -39,19 +43,42 @@ char* FAST_FUNC find_executable(const char *filename, char **PATHp) | |||
39 | * following the rest of the list. | 43 | * following the rest of the list. |
40 | */ | 44 | */ |
41 | char *p, *n; | 45 | char *p, *n; |
46 | #if ENABLE_PLATFORM_MINGW32 | ||
47 | char *w; | ||
48 | #endif | ||
42 | 49 | ||
43 | p = *PATHp; | 50 | p = *PATHp; |
44 | while (p) { | 51 | while (p) { |
45 | int ex; | 52 | int ex; |
53 | #if ENABLE_PLATFORM_MINGW32 | ||
54 | char sep; | ||
46 | 55 | ||
56 | n = (char*)next_path_sep(p); | ||
57 | if (n) { | ||
58 | sep = *n; | ||
59 | *n = '\0'; | ||
60 | } | ||
61 | #else | ||
47 | n = strchr(p, ':'); | 62 | n = strchr(p, ':'); |
48 | if (n) *n = '\0'; | 63 | if (n) *n = '\0'; |
64 | #endif | ||
49 | p = concat_path_file( | 65 | p = concat_path_file( |
50 | p[0] ? p : ".", /* handle "::" case */ | 66 | p[0] ? p : ".", /* handle "::" case */ |
51 | filename | 67 | filename |
52 | ); | 68 | ); |
53 | ex = file_is_executable(p); | 69 | #if ENABLE_PLATFORM_MINGW32 |
70 | if (n) *n++ = sep; | ||
71 | #else | ||
54 | if (n) *n++ = ':'; | 72 | if (n) *n++ = ':'; |
73 | #endif | ||
74 | #if ENABLE_PLATFORM_MINGW32 | ||
75 | if ((w=add_win32_extension(p))) { | ||
76 | *PATHp = n; | ||
77 | free(p); | ||
78 | return w; | ||
79 | } | ||
80 | #endif | ||
81 | ex = file_is_executable(p); | ||
55 | if (ex) { | 82 | if (ex) { |
56 | *PATHp = n; | 83 | *PATHp = n; |
57 | return p; | 84 | return p; |
diff --git a/libbb/find_mount_point.c b/libbb/find_mount_point.c index 94bbf1d4a..341c30102 100644 --- a/libbb/find_mount_point.c +++ b/libbb/find_mount_point.c | |||
@@ -19,14 +19,28 @@ | |||
19 | struct mntent* FAST_FUNC find_mount_point(const char *name, int subdir_too) | 19 | struct mntent* FAST_FUNC find_mount_point(const char *name, int subdir_too) |
20 | { | 20 | { |
21 | struct stat s; | 21 | struct stat s; |
22 | FILE *mtab_fp; | ||
23 | struct mntent *mountEntry; | 22 | struct mntent *mountEntry; |
23 | #if !ENABLE_PLATFORM_MINGW32 | ||
24 | FILE *mtab_fp; | ||
24 | dev_t devno_of_name; | 25 | dev_t devno_of_name; |
25 | bool block_dev; | 26 | bool block_dev; |
27 | #else | ||
28 | static char mnt_fsname[4]; | ||
29 | static char mnt_dir[4]; | ||
30 | static char mnt_type[1]; | ||
31 | static char mnt_opts[1]; | ||
32 | static struct mntent my_mount_entry = { | ||
33 | mnt_fsname, mnt_dir, mnt_type, mnt_opts, 0, 0 | ||
34 | }; | ||
35 | char *current; | ||
36 | const char *path; | ||
37 | DWORD len; | ||
38 | #endif | ||
26 | 39 | ||
27 | if (stat(name, &s) != 0) | 40 | if (stat(name, &s) != 0) |
28 | return NULL; | 41 | return NULL; |
29 | 42 | ||
43 | #if !ENABLE_PLATFORM_MINGW32 | ||
30 | devno_of_name = s.st_dev; | 44 | devno_of_name = s.st_dev; |
31 | block_dev = 0; | 45 | block_dev = 0; |
32 | /* Why S_ISCHR? - UBI volumes use char devices, not block */ | 46 | /* Why S_ISCHR? - UBI volumes use char devices, not block */ |
@@ -63,6 +77,35 @@ struct mntent* FAST_FUNC find_mount_point(const char *name, int subdir_too) | |||
63 | break; | 77 | break; |
64 | } | 78 | } |
65 | endmntent(mtab_fp); | 79 | endmntent(mtab_fp); |
80 | #else | ||
81 | mountEntry = NULL; | ||
82 | path = NULL; | ||
83 | current = NULL; | ||
84 | |||
85 | if ( isalpha(name[0]) && name[1] == ':' ) { | ||
86 | path = name; | ||
87 | } | ||
88 | else { | ||
89 | if ( (len=GetCurrentDirectory(0, NULL)) > 0 && | ||
90 | (current=malloc(len+1)) != NULL && | ||
91 | GetCurrentDirectory(len, current) ) { | ||
92 | path = current; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | if ( path && isalpha(path[0]) && path[1] == ':' ) { | ||
97 | mnt_fsname[0] = path[0]; | ||
98 | mnt_fsname[1] = path[1]; | ||
99 | mnt_fsname[2] = '\0'; | ||
100 | mnt_dir[0] = path[0]; | ||
101 | mnt_dir[1] = path[1]; | ||
102 | mnt_dir[2] = '\\'; | ||
103 | mnt_dir[3] = '\0'; | ||
104 | |||
105 | mountEntry = &my_mount_entry; | ||
106 | } | ||
107 | free(current); | ||
108 | #endif | ||
66 | 109 | ||
67 | return mountEntry; | 110 | return mountEntry; |
68 | } | 111 | } |
diff --git a/libbb/find_pid_by_name.c b/libbb/find_pid_by_name.c index abbf293e8..52debb171 100644 --- a/libbb/find_pid_by_name.c +++ b/libbb/find_pid_by_name.c | |||
@@ -39,8 +39,10 @@ and therefore comm field contains "exe". | |||
39 | 39 | ||
40 | static int comm_match(procps_status_t *p, const char *procName) | 40 | static int comm_match(procps_status_t *p, const char *procName) |
41 | { | 41 | { |
42 | #if !ENABLE_PLATFORM_MINGW32 | ||
42 | int argv1idx; | 43 | int argv1idx; |
43 | const char *argv1; | 44 | const char *argv1; |
45 | #endif | ||
44 | 46 | ||
45 | if (strncmp(p->comm, procName, 15) != 0) | 47 | if (strncmp(p->comm, procName, 15) != 0) |
46 | return 0; /* comm does not match */ | 48 | return 0; /* comm does not match */ |
@@ -55,6 +57,7 @@ static int comm_match(procps_status_t *p, const char *procName) | |||
55 | * This can be crazily_long_script_name.sh! | 57 | * This can be crazily_long_script_name.sh! |
56 | * The telltale sign is basename(argv[1]) == procName */ | 58 | * The telltale sign is basename(argv[1]) == procName */ |
57 | 59 | ||
60 | #if !ENABLE_PLATFORM_MINGW32 | ||
58 | if (!p->argv0) | 61 | if (!p->argv0) |
59 | return 0; | 62 | return 0; |
60 | 63 | ||
@@ -65,6 +68,7 @@ static int comm_match(procps_status_t *p, const char *procName) | |||
65 | 68 | ||
66 | if (strcmp(bb_basename(argv1), procName) != 0) | 69 | if (strcmp(bb_basename(argv1), procName) != 0) |
67 | return 0; | 70 | return 0; |
71 | #endif | ||
68 | 72 | ||
69 | return 1; | 73 | return 1; |
70 | } | 74 | } |
@@ -87,10 +91,12 @@ pid_t* FAST_FUNC find_pid_by_name(const char *procName) | |||
87 | pidList = xzalloc(sizeof(*pidList)); | 91 | pidList = xzalloc(sizeof(*pidList)); |
88 | while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_COMM|PSSCAN_ARGVN|PSSCAN_EXE))) { | 92 | while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_COMM|PSSCAN_ARGVN|PSSCAN_EXE))) { |
89 | if (comm_match(p, procName) | 93 | if (comm_match(p, procName) |
94 | #if !ENABLE_PLATFORM_MINGW32 | ||
90 | /* or we require argv0 to match (essential for matching reexeced /proc/self/exe)*/ | 95 | /* or we require argv0 to match (essential for matching reexeced /proc/self/exe)*/ |
91 | || (p->argv0 && strcmp(bb_basename(p->argv0), procName) == 0) | 96 | || (p->argv0 && strcmp(bb_basename(p->argv0), procName) == 0) |
92 | /* or we require /proc/PID/exe link to match */ | 97 | /* or we require /proc/PID/exe link to match */ |
93 | || (p->exe && strcmp(bb_basename(p->exe), procName) == 0) | 98 | || (p->exe && strcmp(bb_basename(p->exe), procName) == 0) |
99 | #endif | ||
94 | ) { | 100 | ) { |
95 | pidList = xrealloc_vector(pidList, 2, i); | 101 | pidList = xrealloc_vector(pidList, 2, i); |
96 | pidList[i++] = p->pid; | 102 | pidList[i++] = p->pid; |
diff --git a/libbb/get_last_path_component.c b/libbb/get_last_path_component.c index 04fdf2a3e..3a9b9237e 100644 --- a/libbb/get_last_path_component.c +++ b/libbb/get_last_path_component.c | |||
@@ -10,9 +10,16 @@ | |||
10 | 10 | ||
11 | const char* FAST_FUNC bb_basename(const char *name) | 11 | const char* FAST_FUNC bb_basename(const char *name) |
12 | { | 12 | { |
13 | #if ENABLE_PLATFORM_MINGW32 | ||
14 | const char *cp; | ||
15 | for (cp = name; *cp; cp++) | ||
16 | if (*cp == '/' || *cp == '\\') | ||
17 | name = cp + 1; | ||
18 | #else | ||
13 | const char *cp = strrchr(name, '/'); | 19 | const char *cp = strrchr(name, '/'); |
14 | if (cp) | 20 | if (cp) |
15 | return cp + 1; | 21 | return cp + 1; |
22 | #endif | ||
16 | return name; | 23 | return name; |
17 | } | 24 | } |
18 | 25 | ||
@@ -26,8 +33,18 @@ char* FAST_FUNC bb_get_last_path_component_nostrip(const char *path) | |||
26 | { | 33 | { |
27 | char *slash = strrchr(path, '/'); | 34 | char *slash = strrchr(path, '/'); |
28 | 35 | ||
36 | #if ENABLE_PLATFORM_MINGW32 | ||
37 | const char *start = has_dos_drive_prefix(path) ? path+2 : path; | ||
38 | |||
39 | if (!slash) | ||
40 | slash = strrchr(path, '\\'); | ||
41 | |||
42 | if (!slash || (slash == start && !slash[1])) | ||
43 | return (char*)path; | ||
44 | #else | ||
29 | if (!slash || (slash == path && !slash[1])) | 45 | if (!slash || (slash == path && !slash[1])) |
30 | return (char*)path; | 46 | return (char*)path; |
47 | #endif | ||
31 | 48 | ||
32 | return slash + 1; | 49 | return slash + 1; |
33 | } | 50 | } |
@@ -42,9 +59,20 @@ char* FAST_FUNC bb_get_last_path_component_strip(char *path) | |||
42 | { | 59 | { |
43 | char *slash = last_char_is(path, '/'); | 60 | char *slash = last_char_is(path, '/'); |
44 | 61 | ||
62 | #if ENABLE_PLATFORM_MINGW32 | ||
63 | const char *start = has_dos_drive_prefix(path) ? path+2 : path; | ||
64 | |||
65 | if (!slash) | ||
66 | slash = last_char_is(path, '\\'); | ||
67 | |||
68 | if (slash) | ||
69 | while ((*slash == '/' || *slash == '\\') && slash != start) | ||
70 | *slash-- = '\0'; | ||
71 | #else | ||
45 | if (slash) | 72 | if (slash) |
46 | while (*slash == '/' && slash != path) | 73 | while (*slash == '/' && slash != path) |
47 | *slash-- = '\0'; | 74 | *slash-- = '\0'; |
75 | #endif | ||
48 | 76 | ||
49 | return bb_get_last_path_component_nostrip(path); | 77 | return bb_get_last_path_component_nostrip(path); |
50 | } | 78 | } |
diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c index 903ff1fb6..929bab78a 100644 --- a/libbb/get_line_from_file.c +++ b/libbb/get_line_from_file.c | |||
@@ -59,6 +59,10 @@ char* FAST_FUNC xmalloc_fgetline(FILE *file) | |||
59 | 59 | ||
60 | if (i && c[--i] == '\n') | 60 | if (i && c[--i] == '\n') |
61 | c[i] = '\0'; | 61 | c[i] = '\0'; |
62 | #if ENABLE_PLATFORM_MINGW32 | ||
63 | if (i && c[--i] == '\r') | ||
64 | c[i] = '\0'; | ||
65 | #endif | ||
62 | 66 | ||
63 | return c; | 67 | return c; |
64 | } | 68 | } |
diff --git a/libbb/human_readable.c b/libbb/human_readable.c index 09221a186..3199ede6e 100644 --- a/libbb/human_readable.c +++ b/libbb/human_readable.c | |||
@@ -38,7 +38,7 @@ const char* FAST_FUNC make_human_readable_str(unsigned long long val, | |||
38 | if (val == 0) | 38 | if (val == 0) |
39 | return "0"; | 39 | return "0"; |
40 | 40 | ||
41 | fmt = "%llu"; | 41 | fmt = "%"LL_FMT"u"; |
42 | if (block_size > 1) | 42 | if (block_size > 1) |
43 | val *= block_size; | 43 | val *= block_size; |
44 | frac = 0; | 44 | frac = 0; |
@@ -52,7 +52,7 @@ const char* FAST_FUNC make_human_readable_str(unsigned long long val, | |||
52 | while ((val >= 1024) | 52 | while ((val >= 1024) |
53 | /* && (u < unit_chars + sizeof(unit_chars) - 1) - always true */ | 53 | /* && (u < unit_chars + sizeof(unit_chars) - 1) - always true */ |
54 | ) { | 54 | ) { |
55 | fmt = "%llu.%u%c"; | 55 | fmt = "%"LL_FMT"u.%u%c"; |
56 | u++; | 56 | u++; |
57 | frac = (((unsigned)val % 1024) * 10 + 1024/2) / 1024; | 57 | frac = (((unsigned)val % 1024) * 10 + 1024/2) / 1024; |
58 | val /= 1024; | 58 | val /= 1024; |
@@ -67,7 +67,7 @@ const char* FAST_FUNC make_human_readable_str(unsigned long long val, | |||
67 | if (frac >= 5) { | 67 | if (frac >= 5) { |
68 | ++val; | 68 | ++val; |
69 | } | 69 | } |
70 | fmt = "%llu%*c"; | 70 | fmt = "%"LL_FMT"u%*c"; |
71 | frac = 1; | 71 | frac = 1; |
72 | } | 72 | } |
73 | #endif | 73 | #endif |
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index b1e971f88..19b579782 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -356,7 +356,7 @@ int adjust_width_and_validate_wc(unsigned *width_adj, int wc); | |||
356 | /* Put 'command_ps[cursor]', cursor++. | 356 | /* Put 'command_ps[cursor]', cursor++. |
357 | * Advance cursor on screen. If we reached right margin, scroll text up | 357 | * Advance cursor on screen. If we reached right margin, scroll text up |
358 | * and remove terminal margin effect by printing 'next_char' */ | 358 | * and remove terminal margin effect by printing 'next_char' */ |
359 | #define HACK_FOR_WRONG_WIDTH 1 | 359 | #define HACK_FOR_WRONG_WIDTH 1 && !ENABLE_PLATFORM_MINGW32 |
360 | static void put_cur_glyph_and_inc_cursor(void) | 360 | static void put_cur_glyph_and_inc_cursor(void) |
361 | { | 361 | { |
362 | CHAR_T c = command_ps[cursor]; | 362 | CHAR_T c = command_ps[cursor]; |
@@ -419,6 +419,42 @@ static void put_cur_glyph_and_inc_cursor(void) | |||
419 | } | 419 | } |
420 | } | 420 | } |
421 | 421 | ||
422 | #if ENABLE_PLATFORM_MINGW32 | ||
423 | static void inc_cursor(void) | ||
424 | { | ||
425 | CHAR_T c = command_ps[cursor]; | ||
426 | unsigned width = 0; | ||
427 | int ofs_to_right; | ||
428 | |||
429 | /* advance cursor */ | ||
430 | cursor++; | ||
431 | if (unicode_status == UNICODE_ON) { | ||
432 | IF_UNICODE_WIDE_WCHARS(width = cmdedit_x;) | ||
433 | c = adjust_width_and_validate_wc(&cmdedit_x, c); | ||
434 | IF_UNICODE_WIDE_WCHARS(width = cmdedit_x - width;) | ||
435 | } else { | ||
436 | cmdedit_x++; | ||
437 | } | ||
438 | |||
439 | ofs_to_right = cmdedit_x - cmdedit_termw; | ||
440 | if (!ENABLE_UNICODE_WIDE_WCHARS || ofs_to_right <= 0) { | ||
441 | /* cursor remains on this line */ | ||
442 | printf(ESC"[1C"); | ||
443 | } | ||
444 | |||
445 | if (ofs_to_right >= 0) { | ||
446 | /* we go to the next line */ | ||
447 | printf(ESC"[1B"); | ||
448 | bb_putchar('\r'); | ||
449 | cmdedit_y++; | ||
450 | if (!ENABLE_UNICODE_WIDE_WCHARS || ofs_to_right == 0) { | ||
451 | width = 0; | ||
452 | } | ||
453 | cmdedit_x = width; | ||
454 | } | ||
455 | } | ||
456 | #endif | ||
457 | |||
422 | /* Move to end of line (by printing all chars till the end) */ | 458 | /* Move to end of line (by printing all chars till the end) */ |
423 | static void put_till_end_and_adv_cursor(void) | 459 | static void put_till_end_and_adv_cursor(void) |
424 | { | 460 | { |
@@ -478,6 +514,7 @@ static void input_backward(unsigned num) | |||
478 | 514 | ||
479 | if (cmdedit_x >= num) { | 515 | if (cmdedit_x >= num) { |
480 | cmdedit_x -= num; | 516 | cmdedit_x -= num; |
517 | #if !ENABLE_PLATFORM_MINGW32 | ||
481 | if (num <= 4) { | 518 | if (num <= 4) { |
482 | /* This is longer by 5 bytes on x86. | 519 | /* This is longer by 5 bytes on x86. |
483 | * Also gets miscompiled for ARM users | 520 | * Also gets miscompiled for ARM users |
@@ -490,6 +527,7 @@ static void input_backward(unsigned num) | |||
490 | } while (--num); | 527 | } while (--num); |
491 | return; | 528 | return; |
492 | } | 529 | } |
530 | #endif | ||
493 | printf(ESC"[%uD", num); | 531 | printf(ESC"[%uD", num); |
494 | return; | 532 | return; |
495 | } | 533 | } |
@@ -628,7 +666,11 @@ static void input_backspace(void) | |||
628 | static void input_forward(void) | 666 | static void input_forward(void) |
629 | { | 667 | { |
630 | if (cursor < command_len) | 668 | if (cursor < command_len) |
669 | #if !ENABLE_PLATFORM_MINGW32 | ||
631 | put_cur_glyph_and_inc_cursor(); | 670 | put_cur_glyph_and_inc_cursor(); |
671 | #else | ||
672 | inc_cursor(); | ||
673 | #endif | ||
632 | } | 674 | } |
633 | 675 | ||
634 | #if ENABLE_FEATURE_TAB_COMPLETION | 676 | #if ENABLE_FEATURE_TAB_COMPLETION |
@@ -748,7 +790,11 @@ static int path_parse(char ***p) | |||
748 | tmp = (char*)pth; | 790 | tmp = (char*)pth; |
749 | npth = 1; /* path component count */ | 791 | npth = 1; /* path component count */ |
750 | while (1) { | 792 | while (1) { |
793 | #if ENABLE_PLATFORM_MINGW32 | ||
794 | tmp = (char *)next_path_sep(tmp); | ||
795 | #else | ||
751 | tmp = strchr(tmp, ':'); | 796 | tmp = strchr(tmp, ':'); |
797 | #endif | ||
752 | if (!tmp) | 798 | if (!tmp) |
753 | break; | 799 | break; |
754 | tmp++; | 800 | tmp++; |
@@ -761,7 +807,11 @@ static int path_parse(char ***p) | |||
761 | res[0] = tmp = xstrdup(pth); | 807 | res[0] = tmp = xstrdup(pth); |
762 | npth = 1; | 808 | npth = 1; |
763 | while (1) { | 809 | while (1) { |
810 | #if ENABLE_PLATFORM_MINGW32 | ||
811 | tmp = (char *)next_path_sep(tmp); | ||
812 | #else | ||
764 | tmp = strchr(tmp, ':'); | 813 | tmp = strchr(tmp, ':'); |
814 | #endif | ||
765 | if (!tmp) | 815 | if (!tmp) |
766 | break; | 816 | break; |
767 | *tmp++ = '\0'; /* ':' -> '\0' */ | 817 | *tmp++ = '\0'; /* ':' -> '\0' */ |
@@ -847,6 +897,9 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type) | |||
847 | if (stat(found, &st) && lstat(found, &st)) | 897 | if (stat(found, &st) && lstat(found, &st)) |
848 | goto cont; /* hmm, remove in progress? */ | 898 | goto cont; /* hmm, remove in progress? */ |
849 | 899 | ||
900 | if (type == FIND_EXE_ONLY && !file_is_executable(found)) | ||
901 | goto cont; | ||
902 | |||
850 | /* Save only name */ | 903 | /* Save only name */ |
851 | len = strlen(name_found); | 904 | len = strlen(name_found); |
852 | found = xrealloc(found, len + 2); /* +2: for slash and NUL */ | 905 | found = xrealloc(found, len + 2); /* +2: for slash and NUL */ |
@@ -1952,7 +2005,16 @@ static void parse_and_put_prompt(const char *prmt_ptr) | |||
1952 | char *after_home_user; | 2005 | char *after_home_user; |
1953 | 2006 | ||
1954 | /* /home/user[/something] -> ~[/something] */ | 2007 | /* /home/user[/something] -> ~[/something] */ |
2008 | #if !ENABLE_PLATFORM_MINGW32 | ||
1955 | after_home_user = is_prefixed_with(cwd_buf, home_pwd_buf); | 2009 | after_home_user = is_prefixed_with(cwd_buf, home_pwd_buf); |
2010 | #else | ||
2011 | after_home_user = NULL; | ||
2012 | l = strlen(home_pwd_buf); | ||
2013 | if (l != 0 | ||
2014 | && strncasecmp(home_pwd_buf, cwd_buf, l) == 0) { | ||
2015 | after_home_user = cwd_buf + l; | ||
2016 | } | ||
2017 | #endif | ||
1956 | if (after_home_user | 2018 | if (after_home_user |
1957 | && (*after_home_user == '/' || *after_home_user == '\0') | 2019 | && (*after_home_user == '/' || *after_home_user == '\0') |
1958 | ) { | 2020 | ) { |
@@ -2318,7 +2380,7 @@ static int32_t reverse_i_search(int timeout) | |||
2318 | */ | 2380 | */ |
2319 | int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize) | 2381 | int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize) |
2320 | { | 2382 | { |
2321 | int len, n; | 2383 | int len IF_NOT_PLATFORM_MINGW32(, n); |
2322 | int timeout; | 2384 | int timeout; |
2323 | #if ENABLE_FEATURE_TAB_COMPLETION | 2385 | #if ENABLE_FEATURE_TAB_COMPLETION |
2324 | smallint lastWasTab = 0; | 2386 | smallint lastWasTab = 0; |
@@ -2328,15 +2390,23 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
2328 | smallint vi_cmdmode = 0; | 2390 | smallint vi_cmdmode = 0; |
2329 | #endif | 2391 | #endif |
2330 | struct termios initial_settings; | 2392 | struct termios initial_settings; |
2393 | #if !ENABLE_PLATFORM_MINGW32 | ||
2331 | struct termios new_settings; | 2394 | struct termios new_settings; |
2395 | #endif | ||
2332 | char read_key_buffer[KEYCODE_BUFFER_SIZE]; | 2396 | char read_key_buffer[KEYCODE_BUFFER_SIZE]; |
2333 | 2397 | ||
2334 | INIT_S(); | 2398 | INIT_S(); |
2335 | 2399 | ||
2400 | #if !ENABLE_PLATFORM_MINGW32 | ||
2336 | n = get_termios_and_make_raw(STDIN_FILENO, &new_settings, &initial_settings, 0 | 2401 | n = get_termios_and_make_raw(STDIN_FILENO, &new_settings, &initial_settings, 0 |
2337 | | TERMIOS_CLEAR_ISIG /* turn off INTR (ctrl-C), QUIT, SUSP */ | 2402 | | TERMIOS_CLEAR_ISIG /* turn off INTR (ctrl-C), QUIT, SUSP */ |
2338 | ); | 2403 | ); |
2339 | if (n != 0 || (initial_settings.c_lflag & (ECHO|ICANON)) == ICANON) { | 2404 | if (n != 0 || (initial_settings.c_lflag & (ECHO|ICANON)) == ICANON) { |
2405 | #else | ||
2406 | initial_settings.c_cc[VINTR] = CTRL('C'); | ||
2407 | initial_settings.c_cc[VEOF] = CTRL('D'); | ||
2408 | if (!isatty(0) || !isatty(1)) { | ||
2409 | #endif | ||
2340 | /* Happens when e.g. stty -echo was run before. | 2410 | /* Happens when e.g. stty -echo was run before. |
2341 | * But if ICANON is not set, we don't come here. | 2411 | * But if ICANON is not set, we don't come here. |
2342 | * (example: interactive python ^Z-backgrounded, | 2412 | * (example: interactive python ^Z-backgrounded, |
@@ -2389,7 +2459,9 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
2389 | #endif | 2459 | #endif |
2390 | #define command command_must_not_be_used | 2460 | #define command command_must_not_be_used |
2391 | 2461 | ||
2462 | #if !ENABLE_PLATFORM_MINGW32 | ||
2392 | tcsetattr_stdin_TCSANOW(&new_settings); | 2463 | tcsetattr_stdin_TCSANOW(&new_settings); |
2464 | #endif | ||
2393 | 2465 | ||
2394 | #if ENABLE_USERNAME_OR_HOMEDIR | 2466 | #if ENABLE_USERNAME_OR_HOMEDIR |
2395 | { | 2467 | { |
@@ -2442,6 +2514,11 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
2442 | } | 2514 | } |
2443 | #endif | 2515 | #endif |
2444 | ic = ic_raw = lineedit_read_key(read_key_buffer, timeout); | 2516 | ic = ic_raw = lineedit_read_key(read_key_buffer, timeout); |
2517 | #if ENABLE_PLATFORM_MINGW32 | ||
2518 | /* scroll to cursor position on any keypress */ | ||
2519 | if (isatty(fileno(stdin)) && isatty(fileno(stdout))) | ||
2520 | move_cursor_row(0); | ||
2521 | #endif | ||
2445 | 2522 | ||
2446 | #if ENABLE_FEATURE_REVERSE_SEARCH | 2523 | #if ENABLE_FEATURE_REVERSE_SEARCH |
2447 | again: | 2524 | again: |
@@ -2875,8 +2952,10 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
2875 | free_tab_completion_data(); | 2952 | free_tab_completion_data(); |
2876 | #endif | 2953 | #endif |
2877 | 2954 | ||
2955 | #if !ENABLE_PLATFORM_MINGW32 | ||
2878 | /* restore initial_settings */ | 2956 | /* restore initial_settings */ |
2879 | tcsetattr_stdin_TCSANOW(&initial_settings); | 2957 | tcsetattr_stdin_TCSANOW(&initial_settings); |
2958 | #endif | ||
2880 | #if ENABLE_FEATURE_EDITING_WINCH | 2959 | #if ENABLE_FEATURE_EDITING_WINCH |
2881 | /* restore SIGWINCH handler */ | 2960 | /* restore SIGWINCH handler */ |
2882 | sigaction_set(SIGWINCH, &S.SIGWINCH_handler); | 2961 | sigaction_set(SIGWINCH, &S.SIGWINCH_handler); |
diff --git a/libbb/make_directory.c b/libbb/make_directory.c index 9b03bb8d0..ef0a8acd8 100644 --- a/libbb/make_directory.c +++ b/libbb/make_directory.c | |||
@@ -49,11 +49,40 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags) | |||
49 | } | 49 | } |
50 | 50 | ||
51 | org_mask = cur_mask = (mode_t)-1L; | 51 | org_mask = cur_mask = (mode_t)-1L; |
52 | #if ENABLE_PLATFORM_MINGW32 | ||
53 | /* normalise path separators, path is already assumed writable */ | ||
54 | convert_slashes(path); | ||
55 | #endif | ||
52 | s = path; | 56 | s = path; |
53 | while (1) { | 57 | while (1) { |
54 | c = '\0'; | 58 | c = '\0'; |
55 | 59 | ||
56 | if (flags & FILEUTILS_RECUR) { /* Get the parent */ | 60 | if (flags & FILEUTILS_RECUR) { /* Get the parent */ |
61 | #if ENABLE_PLATFORM_MINGW32 | ||
62 | if (s == path && *s && s[1] == ':') { | ||
63 | /* skip drive letter */ | ||
64 | s += 2; | ||
65 | } | ||
66 | else if (s == path && s[0] == '/' && s[1] == '/' ) { | ||
67 | /* skip UNC server and share */ | ||
68 | int count = 0; | ||
69 | s += 2; | ||
70 | while (*s) { | ||
71 | if (*s == '/') { | ||
72 | do { | ||
73 | ++s; | ||
74 | } while (*s == '/'); | ||
75 | if (++count == 2) { | ||
76 | --s; | ||
77 | break; | ||
78 | } | ||
79 | } | ||
80 | else { | ||
81 | ++s; | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | #endif | ||
57 | /* Bypass leading non-'/'s and then subsequent '/'s */ | 86 | /* Bypass leading non-'/'s and then subsequent '/'s */ |
58 | while (*s) { | 87 | while (*s) { |
59 | if (*s == '/') { | 88 | if (*s == '/') { |
diff --git a/libbb/messages.c b/libbb/messages.c index 6914d5701..f5bbd3e32 100644 --- a/libbb/messages.c +++ b/libbb/messages.c | |||
@@ -27,7 +27,9 @@ const char bb_msg_standard_output[] ALIGN1 = "standard output"; | |||
27 | 27 | ||
28 | const char bb_hexdigits_upcase[] ALIGN1 = "0123456789ABCDEF"; | 28 | const char bb_hexdigits_upcase[] ALIGN1 = "0123456789ABCDEF"; |
29 | 29 | ||
30 | #if !ENABLE_PLATFORM_MINGW32 | ||
30 | const char bb_busybox_exec_path[] ALIGN1 = CONFIG_BUSYBOX_EXEC_PATH; | 31 | const char bb_busybox_exec_path[] ALIGN1 = CONFIG_BUSYBOX_EXEC_PATH; |
32 | #endif | ||
31 | const char bb_default_login_shell[] ALIGN1 = LIBBB_DEFAULT_LOGIN_SHELL; | 33 | const char bb_default_login_shell[] ALIGN1 = LIBBB_DEFAULT_LOGIN_SHELL; |
32 | /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, | 34 | /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, |
33 | * but I want to save a few bytes here. Check libbb.h before changing! */ | 35 | * but I want to save a few bytes here. Check libbb.h before changing! */ |
diff --git a/libbb/mode_string.c b/libbb/mode_string.c index 5ffd5683e..6c5c08acd 100644 --- a/libbb/mode_string.c +++ b/libbb/mode_string.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #endif | 17 | #endif |
18 | 18 | ||
19 | #if ( S_IFSOCK!= 0140000 ) || ( S_IFLNK != 0120000 ) \ | 19 | #if ( S_IFSOCK!= 0140000 ) || ( S_IFLNK != 0120000 ) \ |
20 | || ( S_IFREG != 0100000 ) || ( S_IFBLK != 0060000 ) \ | 20 | || ( S_IFREG != 0100000 ) || ( S_IFBLK != 0060000 && S_IFBLK != 0030000 ) \ |
21 | || ( S_IFDIR != 0040000 ) || ( S_IFCHR != 0020000 ) \ | 21 | || ( S_IFDIR != 0040000 ) || ( S_IFCHR != 0020000 ) \ |
22 | || ( S_IFIFO != 0010000 ) | 22 | || ( S_IFIFO != 0010000 ) |
23 | #warning mode type bitflag value assumption(s) violated! falling back to larger version | 23 | #warning mode type bitflag value assumption(s) violated! falling back to larger version |
diff --git a/libbb/printable_string.c b/libbb/printable_string.c index a814fd03c..2e8895a4f 100644 --- a/libbb/printable_string.c +++ b/libbb/printable_string.c | |||
@@ -42,7 +42,7 @@ const char* FAST_FUNC printable_string2(uni_stat_t *stats, const char *str) | |||
42 | unsigned char c = *d; | 42 | unsigned char c = *d; |
43 | if (c == '\0') | 43 | if (c == '\0') |
44 | break; | 44 | break; |
45 | if (c < ' ' || c >= 0x7f) | 45 | if (c < ' ' || (c >= 0x7f && !ENABLE_PLATFORM_MINGW32)) |
46 | *d = '?'; | 46 | *d = '?'; |
47 | d++; | 47 | d++; |
48 | } | 48 | } |
diff --git a/libbb/procps.c b/libbb/procps.c index 9d8a921df..2484ab2d9 100644 --- a/libbb/procps.c +++ b/libbb/procps.c | |||
@@ -74,6 +74,7 @@ const char* FAST_FUNC get_cached_groupname(gid_t gid) | |||
74 | return get_cached(&groupname, gid, gid2group_utoa); | 74 | return get_cached(&groupname, gid, gid2group_utoa); |
75 | } | 75 | } |
76 | 76 | ||
77 | #if !ENABLE_PLATFORM_MINGW32 | ||
77 | 78 | ||
78 | #define PROCPS_BUFSIZE 1024 | 79 | #define PROCPS_BUFSIZE 1024 |
79 | 80 | ||
@@ -621,6 +622,8 @@ void FAST_FUNC read_cmdline(char *buf, int col, unsigned pid, const char *comm) | |||
621 | } | 622 | } |
622 | } | 623 | } |
623 | 624 | ||
625 | #endif /* ENABLE_PLATFORM_MINGW32 */ | ||
626 | |||
624 | /* from kernel: | 627 | /* from kernel: |
625 | // pid comm S ppid pgid sid tty_nr tty_pgrp flg | 628 | // pid comm S ppid pgid sid tty_nr tty_pgrp flg |
626 | sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \ | 629 | sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \ |
diff --git a/libbb/read_printf.c b/libbb/read_printf.c index b6a17cc36..e47ac7afe 100644 --- a/libbb/read_printf.c +++ b/libbb/read_printf.c | |||
@@ -93,6 +93,11 @@ char* FAST_FUNC xmalloc_reads(int fd, size_t *maxsz_p) | |||
93 | break; | 93 | break; |
94 | p++; | 94 | p++; |
95 | } | 95 | } |
96 | #if ENABLE_PLATFORM_MINGW32 | ||
97 | if ( p != buf && *(p-1) == '\r' ) { | ||
98 | --p; | ||
99 | } | ||
100 | #endif | ||
96 | *p = '\0'; | 101 | *p = '\0'; |
97 | if (maxsz_p) | 102 | if (maxsz_p) |
98 | *maxsz_p = p - buf; | 103 | *maxsz_p = p - buf; |
diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c index f8de44967..c583206f0 100644 --- a/libbb/setup_environment.c +++ b/libbb/setup_environment.c | |||
@@ -29,6 +29,14 @@ | |||
29 | */ | 29 | */ |
30 | #include "libbb.h" | 30 | #include "libbb.h" |
31 | 31 | ||
32 | #if ENABLE_PLATFORM_MINGW32 | ||
33 | static void xsetenv_if_unset(const char *key, const char *value) | ||
34 | { | ||
35 | if (!getenv(key)) | ||
36 | xsetenv(key, value); | ||
37 | } | ||
38 | #endif | ||
39 | |||
32 | void FAST_FUNC setup_environment(const char *shell, int flags, const struct passwd *pw) | 40 | void FAST_FUNC setup_environment(const char *shell, int flags, const struct passwd *pw) |
33 | { | 41 | { |
34 | if (!shell || !shell[0]) | 42 | if (!shell || !shell[0]) |
@@ -60,6 +68,9 @@ void FAST_FUNC setup_environment(const char *shell, int flags, const struct pass | |||
60 | //xsetenv("HOME", pw->pw_dir); | 68 | //xsetenv("HOME", pw->pw_dir); |
61 | //xsetenv("SHELL", shell); | 69 | //xsetenv("SHELL", shell); |
62 | } else if (flags & SETUP_ENV_CHANGEENV) { | 70 | } else if (flags & SETUP_ENV_CHANGEENV) { |
71 | #if ENABLE_PLATFORM_MINGW32 | ||
72 | #define xsetenv(k, v) xsetenv_if_unset(k, v) | ||
73 | #endif | ||
63 | /* Set HOME, SHELL, and if not becoming a super-user, | 74 | /* Set HOME, SHELL, and if not becoming a super-user, |
64 | * USER and LOGNAME. */ | 75 | * USER and LOGNAME. */ |
65 | if (pw->pw_uid) { | 76 | if (pw->pw_uid) { |
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index c0bea0ed2..569a6fc34 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c | |||
@@ -150,6 +150,7 @@ void FAST_FUNC run_noexec_applet_and_exit(int a, const char *name, char **argv) | |||
150 | * Higher-level code, hiding optional NOFORK/NOEXEC trickery. | 150 | * Higher-level code, hiding optional NOFORK/NOEXEC trickery. |
151 | */ | 151 | */ |
152 | 152 | ||
153 | #if !ENABLE_PLATFORM_MINGW32 | ||
153 | /* This does a fork/exec in one call, using vfork(). Returns PID of new child, | 154 | /* This does a fork/exec in one call, using vfork(). Returns PID of new child, |
154 | * -1 for failure. Runs argv[0], searching path if that has no / in it. */ | 155 | * -1 for failure. Runs argv[0], searching path if that has no / in it. */ |
155 | pid_t FAST_FUNC spawn(char **argv) | 156 | pid_t FAST_FUNC spawn(char **argv) |
@@ -191,6 +192,7 @@ pid_t FAST_FUNC spawn(char **argv) | |||
191 | } | 192 | } |
192 | return pid; | 193 | return pid; |
193 | } | 194 | } |
195 | #endif | ||
194 | 196 | ||
195 | /* Die with an error message if we can't spawn a child process. */ | 197 | /* Die with an error message if we can't spawn a child process. */ |
196 | pid_t FAST_FUNC xspawn(char **argv) | 198 | pid_t FAST_FUNC xspawn(char **argv) |
@@ -211,6 +213,7 @@ int FAST_FUNC spawn_and_wait(char **argv) | |||
211 | if (APPLET_IS_NOFORK(a)) | 213 | if (APPLET_IS_NOFORK(a)) |
212 | return run_nofork_applet(a, argv); | 214 | return run_nofork_applet(a, argv); |
213 | # if BB_MMU /* NOEXEC needs fork(), thus this is done only on MMU machines: */ | 215 | # if BB_MMU /* NOEXEC needs fork(), thus this is done only on MMU machines: */ |
216 | # if !ENABLE_PLATFORM_MINGW32 /* and then only if not on Microsoft Windows */ | ||
214 | if (APPLET_IS_NOEXEC(a)) { | 217 | if (APPLET_IS_NOEXEC(a)) { |
215 | fflush_all(); | 218 | fflush_all(); |
216 | rc = fork(); | 219 | rc = fork(); |
@@ -220,6 +223,7 @@ int FAST_FUNC spawn_and_wait(char **argv) | |||
220 | /* child */ | 223 | /* child */ |
221 | run_noexec_applet_and_exit(a, argv[0], argv); | 224 | run_noexec_applet_and_exit(a, argv[0], argv); |
222 | } | 225 | } |
226 | # endif | ||
223 | # endif | 227 | # endif |
224 | } | 228 | } |
225 | #endif | 229 | #endif |
@@ -227,6 +231,7 @@ int FAST_FUNC spawn_and_wait(char **argv) | |||
227 | return wait4pid(rc); | 231 | return wait4pid(rc); |
228 | } | 232 | } |
229 | 233 | ||
234 | #if !ENABLE_PLATFORM_MINGW32 | ||
230 | #if !BB_MMU | 235 | #if !BB_MMU |
231 | void FAST_FUNC re_exec(char **argv) | 236 | void FAST_FUNC re_exec(char **argv) |
232 | { | 237 | { |
@@ -313,3 +318,4 @@ void FAST_FUNC bb_sanitize_stdio(void) | |||
313 | { | 318 | { |
314 | bb_daemonize_or_rexec(DAEMON_ONLY_SANITIZE, NULL); | 319 | bb_daemonize_or_rexec(DAEMON_ONLY_SANITIZE, NULL); |
315 | } | 320 | } |
321 | #endif /* !MINGW32 */ | ||
diff --git a/libbb/xatonum_template.c b/libbb/xatonum_template.c index e0471983c..0d5d35b47 100644 --- a/libbb/xatonum_template.c +++ b/libbb/xatonum_template.c | |||
@@ -67,7 +67,7 @@ unsigned type FAST_FUNC xstrtou(_range_sfx)(const char *numstr, int base, | |||
67 | if (r >= lower && r <= upper) | 67 | if (r >= lower && r <= upper) |
68 | return r; | 68 | return r; |
69 | range: | 69 | range: |
70 | bb_error_msg_and_die("number %s is not in %llu..%llu range", | 70 | bb_error_msg_and_die("number %s is not in %"LL_FMT"u..%"LL_FMT"u range", |
71 | numstr, (unsigned long long)lower, | 71 | numstr, (unsigned long long)lower, |
72 | (unsigned long long)upper); | 72 | (unsigned long long)upper); |
73 | inval: | 73 | inval: |
@@ -144,7 +144,8 @@ type FAST_FUNC xstrto(_range_sfx)(const char *numstr, int base, | |||
144 | } | 144 | } |
145 | 145 | ||
146 | if (r < lower || r > upper) { | 146 | if (r < lower || r > upper) { |
147 | bb_error_msg_and_die("number %s is not in %lld..%lld range", | 147 | bb_error_msg_and_die("number %s is not in " |
148 | "%"LL_FMT"d..%"LL_FMT"d range", | ||
148 | numstr, (long long)lower, (long long)upper); | 149 | numstr, (long long)lower, (long long)upper); |
149 | } | 150 | } |
150 | 151 | ||
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 39e56b223..a6127508b 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c | |||
@@ -68,6 +68,7 @@ int FAST_FUNC setsockopt_bindtodevice(int fd UNUSED_PARAM, | |||
68 | } | 68 | } |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | #if !ENABLE_PLATFORM_MINGW32 | ||
71 | static len_and_sockaddr* get_lsa(int fd, int (*get_name)(int fd, struct sockaddr *addr, socklen_t *addrlen)) | 72 | static len_and_sockaddr* get_lsa(int fd, int (*get_name)(int fd, struct sockaddr *addr, socklen_t *addrlen)) |
72 | { | 73 | { |
73 | len_and_sockaddr lsa; | 74 | len_and_sockaddr lsa; |
@@ -96,16 +97,17 @@ len_and_sockaddr* FAST_FUNC get_peer_lsa(int fd) | |||
96 | { | 97 | { |
97 | return get_lsa(fd, getpeername); | 98 | return get_lsa(fd, getpeername); |
98 | } | 99 | } |
100 | #endif | ||
99 | 101 | ||
100 | void FAST_FUNC xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen) | 102 | void FAST_FUNC xconnect(int s, const struct sockaddr *saddr, socklen_t addrlen) |
101 | { | 103 | { |
102 | if (connect(s, s_addr, addrlen) < 0) { | 104 | if (connect(s, saddr, addrlen) < 0) { |
103 | if (ENABLE_FEATURE_CLEAN_UP) | 105 | if (ENABLE_FEATURE_CLEAN_UP) |
104 | close(s); | 106 | close(s); |
105 | if (s_addr->sa_family == AF_INET) | 107 | if (saddr->sa_family == AF_INET) |
106 | bb_perror_msg_and_die("%s (%s)", | 108 | bb_perror_msg_and_die("%s (%s)", |
107 | "can't connect to remote host", | 109 | "can't connect to remote host", |
108 | inet_ntoa(((struct sockaddr_in *)s_addr)->sin_addr)); | 110 | inet_ntoa(((struct sockaddr_in *)saddr)->sin_addr)); |
109 | bb_perror_msg_and_die("can't connect to remote host"); | 111 | bb_perror_msg_and_die("can't connect to remote host"); |
110 | } | 112 | } |
111 | } | 113 | } |
@@ -352,6 +354,10 @@ int FAST_FUNC xsocket_type(len_and_sockaddr **lsap, int family, int sock_type) | |||
352 | #if ENABLE_FEATURE_IPV6 | 354 | #if ENABLE_FEATURE_IPV6 |
353 | fd = socket(AF_INET6, sock_type, 0); | 355 | fd = socket(AF_INET6, sock_type, 0); |
354 | if (fd >= 0) { | 356 | if (fd >= 0) { |
357 | #if ENABLE_PLATFORM_MINGW32 | ||
358 | DWORD buffer = 0; | ||
359 | setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &buffer, sizeof(DWORD)); | ||
360 | #endif | ||
355 | family = AF_INET6; | 361 | family = AF_INET6; |
356 | goto done; | 362 | goto done; |
357 | } | 363 | } |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index b4d512bd6..57bda6204 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -268,6 +268,7 @@ int FAST_FUNC get_terminal_width_height(int fd, unsigned *width, unsigned *heigh | |||
268 | int err; | 268 | int err; |
269 | int close_me = -1; | 269 | int close_me = -1; |
270 | 270 | ||
271 | #if !ENABLE_PLATFORM_MINGW32 | ||
271 | if (fd == -1) { | 272 | if (fd == -1) { |
272 | if (isatty(STDOUT_FILENO)) | 273 | if (isatty(STDOUT_FILENO)) |
273 | fd = STDOUT_FILENO; | 274 | fd = STDOUT_FILENO; |
@@ -280,6 +281,7 @@ int FAST_FUNC get_terminal_width_height(int fd, unsigned *width, unsigned *heigh | |||
280 | else | 281 | else |
281 | close_me = fd = open("/dev/tty", O_RDONLY); | 282 | close_me = fd = open("/dev/tty", O_RDONLY); |
282 | } | 283 | } |
284 | #endif | ||
283 | 285 | ||
284 | win.ws_row = 0; | 286 | win.ws_row = 0; |
285 | win.ws_col = 0; | 287 | win.ws_col = 0; |
@@ -303,6 +305,7 @@ int FAST_FUNC get_terminal_width(int fd) | |||
303 | return width; | 305 | return width; |
304 | } | 306 | } |
305 | 307 | ||
308 | #if !ENABLE_PLATFORM_MINGW32 | ||
306 | int FAST_FUNC tcsetattr_stdin_TCSANOW(const struct termios *tp) | 309 | int FAST_FUNC tcsetattr_stdin_TCSANOW(const struct termios *tp) |
307 | { | 310 | { |
308 | return tcsetattr(STDIN_FILENO, TCSANOW, tp); | 311 | return tcsetattr(STDIN_FILENO, TCSANOW, tp); |
@@ -383,6 +386,7 @@ int FAST_FUNC set_termios_to_raw(int fd, struct termios *oldterm, int flags) | |||
383 | get_termios_and_make_raw(fd, &newterm, oldterm, flags); | 386 | get_termios_and_make_raw(fd, &newterm, oldterm, flags); |
384 | return tcsetattr(fd, TCSANOW, &newterm); | 387 | return tcsetattr(fd, TCSANOW, &newterm); |
385 | } | 388 | } |
389 | #endif | ||
386 | 390 | ||
387 | pid_t FAST_FUNC safe_waitpid(pid_t pid, int *wstat, int options) | 391 | pid_t FAST_FUNC safe_waitpid(pid_t pid, int *wstat, int options) |
388 | { | 392 | { |
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 6cc60f6c0..a0db2b86e 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -513,6 +513,7 @@ void FAST_FUNC xfstat(int fd, struct stat *stat_buf, const char *errmsg) | |||
513 | bb_simple_perror_msg_and_die(errmsg); | 513 | bb_simple_perror_msg_and_die(errmsg); |
514 | } | 514 | } |
515 | 515 | ||
516 | #if !ENABLE_PLATFORM_MINGW32 | ||
516 | // selinux_or_die() - die if SELinux is disabled. | 517 | // selinux_or_die() - die if SELinux is disabled. |
517 | void FAST_FUNC selinux_or_die(void) | 518 | void FAST_FUNC selinux_or_die(void) |
518 | { | 519 | { |
@@ -695,3 +696,4 @@ void FAST_FUNC xvfork_parent_waits_and_exits(void) | |||
695 | } | 696 | } |
696 | /* Child continues */ | 697 | /* Child continues */ |
697 | } | 698 | } |
699 | #endif /* !ENABLE_PLATFORM_MINGW32 */ | ||
diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c index ead30e499..9ae70de99 100644 --- a/libbb/xreadlink.c +++ b/libbb/xreadlink.c | |||
@@ -64,7 +64,7 @@ char* FAST_FUNC xmalloc_follow_symlinks(const char *path) | |||
64 | linkpath = xmalloc_readlink(buf); | 64 | linkpath = xmalloc_readlink(buf); |
65 | if (!linkpath) { | 65 | if (!linkpath) { |
66 | /* not a symlink, or doesn't exist */ | 66 | /* not a symlink, or doesn't exist */ |
67 | if (errno == EINVAL || errno == ENOENT) | 67 | if (errno == EINVAL || errno == ENOENT || (ENABLE_PLATFORM_MINGW32 && errno == ENOSYS)) |
68 | return buf; | 68 | return buf; |
69 | goto free_buf_ret_null; | 69 | goto free_buf_ret_null; |
70 | } | 70 | } |