@@ -119,6 +119,19 @@ index fe3cb9e75..a039708ae 100644
119119 } else {
120120 /* SysV style init assumed */
121121 /* runlevels:
122+ diff --git a/init/init.c b/init/init.c
123+ index efab5dcb4..a62f1e8df 100644
124+ --- a/init/init.c
125+ +++ b/init/init.c
126+ @@ -131,7 +131,7 @@
127+ #include "common_bufsiz.h"
128+ #include <syslog.h>
129+ #ifdef __linux__
130+ - # include <linux/vt.h>
131+ + //# include <linux/vt.h>
132+ # include <sys/sysinfo.h>
133+ #endif
134+ #include "reboot.h" /* reboot() constants */
122135diff --git a/libbb/copyfd.c b/libbb/copyfd.c
123136index 7f9d92ea9..e88c62e5a 100644
124137--- a/libbb/copyfd.c
@@ -139,6 +152,31 @@ index 7f9d92ea9..e88c62e5a 100644
139152 size > buffer_size ? buffer_size : size);
140153 if (rd < 0) {
141154 bb_simple_perror_msg(bb_msg_read_error);
155+ diff --git a/libbb/find_pid_by_name.c b/libbb/find_pid_by_name.c
156+ index fe13f7211..8bddb20f1 100644
157+ --- a/libbb/find_pid_by_name.c
158+ +++ b/libbb/find_pid_by_name.c
159+ @@ -85,16 +85,19 @@ pid_t* FAST_FUNC find_pid_by_name(const char *procName)
160+ procps_status_t* p = NULL;
161+
162+ pidList = xzalloc(sizeof(*pidList));
163+ - while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_COMM|PSSCAN_ARGVN|PSSCAN_EXE))) {
164+ + //while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_COMM|PSSCAN_ARGVN|PSSCAN_EXE))) {
165+ + while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_COMM|PSSCAN_ARGVN))) {
166+ if (comm_match(p, procName)
167+ /* or we require argv0 to match (essential for matching reexeced /proc/self/exe)*/
168+ || (p->argv0 && strcmp(bb_basename(p->argv0), procName) == 0)
169+ /* or we require /proc/PID/exe link to match */
170+ + #if 0
171+ || (p->exe && strcmp(
172+ procName[0] == '/' ? p->exe /* support "pidof /path/to/binary" case too */
173+ : bb_basename(p->exe),
174+ procName
175+ ) == 0)
176+ + #endif
177+ ) {
178+ pidList = xrealloc_vector(pidList, 2, i);
179+ pidList[i++] = p->pid;
142180diff --git a/libbb/loop.c b/libbb/loop.c
143181index cb8fa2442..58677486b 100644
144182--- a/libbb/loop.c
@@ -340,6 +378,210 @@ index cb8fa2442..58677486b 100644
340378 typedef struct loop_info64 bb_loop_info;
341379 # define BB_LOOP_SET_STATUS LOOP_SET_STATUS64
342380 # define BB_LOOP_GET_STATUS LOOP_GET_STATUS64
381+ diff --git a/libbb/wfopen.c b/libbb/wfopen.c
382+ index 1c7f7f3d7..a3f255b0c 100644
383+ --- a/libbb/wfopen.c
384+ +++ b/libbb/wfopen.c
385+ @@ -12,7 +12,7 @@ FILE* FAST_FUNC fopen_or_warn(const char *path, const char *mode)
386+ {
387+ FILE *fp = fopen(path, mode);
388+ if (!fp) {
389+ - bb_simple_perror_msg(path);
390+ + //bb_simple_perror_msg(path);
391+ //errno = 0; /* why? */
392+ }
393+ return fp;
394+ diff --git a/miscutils/devmem2.c b/miscutils/devmem2.c
395+ new file mode 100644
396+ index 000000000..8a9cf44fd
397+ --- /dev/null
398+ +++ b/miscutils/devmem2.c
399+ @@ -0,0 +1,185 @@
400+ + /*
401+ + * Copyright (C) 2000, Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
402+ + * Copyright (C) 2008, BusyBox Team. -solar 4/26/08
403+ + * Licensed under GPLv2 or later, see file LICENSE in this source tree.
404+ + */
405+ + //config:config DEVMEM2
406+ + //config: bool "devmem2 (2.5 kb)"
407+ + //config: default y
408+ + //config: help
409+ + //config: devmem2_main is a small program that reads and writes from physical
410+ + //config: memory using /dev/mem.
411+ +
412+ + //applet:IF_DEVMEM2(APPLET(devmem2, BB_DIR_SBIN, BB_SUID_DROP))
413+ +
414+ + //kbuild:lib-$(CONFIG_DEVMEM2) += devmem2.o
415+ +
416+ + //usage:#define devmem2_trivial_usage
417+ + //usage: "ADDRESS [WIDTH [VALUE]]"
418+ + //usage:#define devmem2_full_usage "\n\n"
419+ + //usage: "Read/write from physical address\n"
420+ + //usage: "\n ADDRESS Address to act upon"
421+ + //usage: "\n WIDTH Width (8/16/...)"
422+ + //usage: "\n VALUE Data to be written"
423+ +
424+ + #include "libbb.h"
425+ + #include <stdio.h>
426+ + #include <stdlib.h>
427+ + #include <stdint.h>
428+ + #include <unistd.h>
429+ + #include <fcntl.h>
430+ + #include <sys/ioctl.h>
431+ +
432+ + #define MEM_DEVICE_NAME "/dev/mem"
433+ +
434+ + int flag = 0;//read
435+ + uint64_t writeval = 0; //write
436+ +
437+ + #define MEM_IOCTL_MMAP_BASE 'm'
438+ + #define MEM_IOCTL_USER_MMAP _IO(MEM_IOCTL_MMAP_BASE, 1)
439+ + #define MEM_IOCTL_USER_MUNMAP _IO(MEM_IOCTL_MMAP_BASE, 2)
440+ +
441+ + #pragma pack(push) /* push current alignment to stack */
442+ + #pragma pack(4) /* set alignment to 4 byte boundary */
443+ +
444+ + struct mem_query_phys
445+ + {
446+ + int fd;
447+ + uint64_t phys_addrs;
448+ + uint64_t size;
449+ + void *data;
450+ + };
451+ +
452+ + static int mem_fd = -1;
453+ +
454+ + struct map_addr_info
455+ + {
456+ + uint32_t phyAddr;
457+ + size_t mapSize;
458+ + size_t mapMode;
459+ + void *virtAddr;
460+ + };
461+ +
462+ + int phys_addr_map(struct map_addr_info *info)
463+ + {
464+ + int ret;
465+ + struct mem_query_phys mem_info = { 0 };
466+ +
467+ + if (!info)
468+ + return -1;
469+ +
470+ + mem_fd = open(MEM_DEVICE_NAME, O_RDWR);
471+ + if (mem_fd < 0)
472+ + {
473+ + printf("mem device open failed\n");
474+ + return -1;
475+ + }
476+ +
477+ + mem_info.phys_addrs = (uint64_t)info->phyAddr;
478+ + mem_info.size = (uint64_t)info->mapSize;
479+ +
480+ + ret = ioctl(mem_fd, MEM_IOCTL_USER_MMAP, &mem_info);
481+ + if (ret)
482+ + {
483+ + printf("mmap failed\n");
484+ + return -1;
485+ + }
486+ +
487+ + info->virtAddr = mem_info.data;
488+ +
489+ + return 0;
490+ + }
491+ +
492+ + int phys_addr_unmap(struct map_addr_info *info)
493+ + {
494+ + struct mem_query_phys mem_info;
495+ + mem_info.data = info->virtAddr;
496+ + mem_info.size = (uint64_t)info->mapSize;
497+ + mem_info.phys_addrs = (uint64_t)info->phyAddr;
498+ +
499+ + if (mem_fd < 0)
500+ + {
501+ + return -1;
502+ + }
503+ +
504+ + return ioctl(mem_fd, MEM_IOCTL_USER_MUNMAP, &mem_info);
505+ + }
506+ +
507+ + void devmem2(uint32_t trace_dump_hdr, uint32_t dump_len, int flag)
508+ + {
509+ + uint64_t read_result;
510+ + int ret;
511+ +
512+ + struct map_addr_info info =
513+ + {
514+ + .phyAddr = trace_dump_hdr,
515+ + .mapSize = dump_len,
516+ + .mapMode = 0,
517+ + };
518+ +
519+ + ret= phys_addr_map(&info);
520+ +
521+ + if (!flag) {
522+ + switch (dump_len) {
523+ + case 8:
524+ + read_result = *(volatile uint8_t*)info.virtAddr;
525+ + break;
526+ + case 16:
527+ + read_result = *(volatile uint16_t*)info.virtAddr;
528+ + break;
529+ + case 32:
530+ + read_result = *(volatile uint32_t*)info.virtAddr;
531+ + break;
532+ + case 64:
533+ + read_result = *(volatile uint64_t*)info.virtAddr;
534+ + break;
535+ + default:
536+ + bb_simple_error_msg_and_die("bad width");
537+ + }
538+ + printf("0x%0*llX\n", (dump_len >> 2), (unsigned long long)read_result);
539+ + } else {
540+ + switch (dump_len) {
541+ + case 8:
542+ + *(volatile uint8_t*)info.virtAddr = writeval;
543+ + break;
544+ + case 16:
545+ + *(volatile uint16_t*)info.virtAddr = writeval;
546+ + break;
547+ + case 32:
548+ + *(volatile uint32_t*)info.virtAddr = writeval;
549+ + break;
550+ + case 64:
551+ + *(volatile uint64_t*)info.virtAddr = writeval;
552+ + break;
553+ + default:
554+ + bb_simple_error_msg_and_die("bad width");
555+ + }
556+ + }
557+ + }
558+ +
559+ + int devmem2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
560+ + int devmem2_main(int argc UNUSED_PARAM, char **argv)
561+ + {
562+ + uint32_t dump_addr;
563+ + uint32_t dump_len;
564+ +
565+ + if (argc > 1)
566+ + dump_addr = strtoul(argv[1], 0, 0);
567+ + else
568+ + bb_show_usage();
569+ +
570+ + if (argc > 2)
571+ + dump_len = strtoul(argv[2], 0, 0);
572+ + else
573+ + dump_len = 8 * sizeof(int);
574+ +
575+ + if (argc > 3)
576+ + {
577+ + flag = 1;
578+ + writeval = bb_strtoull(argv[3], NULL, 0);
579+ + }
580+ +
581+ + devmem2(dump_addr, dump_len, flag);
582+ +
583+ + return EXIT_SUCCESS;
584+ + }
343585diff --git a/miscutils/partprobe.c b/miscutils/partprobe.c
344586index 0fb1927b7..5a2915ef5 100644
345587--- a/miscutils/partprobe.c
@@ -803,6 +1045,102 @@ index 0d6a289c7..358b5aae1 100644
8031045- }
8041046+ }
8051047 }
1048+ diff --git a/networking/ping.c b/networking/ping.c
1049+ index 86d8088de..a7d96f589 100644
1050+ --- a/networking/ping.c
1051+ +++ b/networking/ping.c
1052+ @@ -530,6 +530,38 @@ static void sendping_tail(void (*sp)(int), int size_pkt)
1053+ bb_simple_error_msg_and_die(bb_msg_write_error);
1054+
1055+ if (pingcount == 0 || G.ntransmitted < pingcount) {
1056+ + struct sigaction sa;
1057+ + sa.sa_handler = sp;
1058+ + sigemptyset(&sa.sa_mask);
1059+ + sa.sa_flags = 0;
1060+ +
1061+ + if (sigaction(SIGALRM, &sa, NULL) == -1) {
1062+ + perror("Error setting SIGALRM signal handler");
1063+ + return 1;
1064+ + }
1065+ +
1066+ + timer_t timerid;
1067+ + struct sigevent sev;
1068+ + sev.sigev_notify = SIGEV_SIGNAL;
1069+ + sev.sigev_signo = SIGALRM;
1070+ + sev.sigev_value.sival_ptr = &timerid;
1071+ +
1072+ + if (timer_create(CLOCK_REALTIME, &sev, &timerid) == -1) {
1073+ + perror("Error creating timer");
1074+ + return 1;
1075+ + }
1076+ +
1077+ + struct itimerspec its;
1078+ + its.it_value.tv_sec = G.interval_us / 1000000;
1079+ + its.it_value.tv_nsec = G.interval_us % 1000000 /1000;
1080+ + its.it_interval.tv_sec = 0;
1081+ + its.it_interval.tv_nsec = 0;
1082+ +
1083+ + if (timer_settime(timerid, 0, &its, NULL) == -1) {
1084+ + perror("Error setting timer");
1085+ + return 1;
1086+ + }
1087+ + #if 0
1088+ /* Didn't send all pings yet - schedule next in -i SEC interval */
1089+ struct itimerval i;
1090+ signal(SIGALRM, sp);
1091+ @@ -539,6 +571,7 @@ static void sendping_tail(void (*sp)(int), int size_pkt)
1092+ i.it_value.tv_sec = G.interval_us / 1000000;
1093+ i.it_value.tv_usec = G.interval_us % 1000000;
1094+ setitimer(ITIMER_REAL, &i, NULL);
1095+ + #endif
1096+ } else { /* -c NN, and all NN are sent */
1097+ /* Wait for the last ping to come back.
1098+ * -W timeout: wait for a response in seconds.
1099+ @@ -801,7 +834,7 @@ static void ping4(len_and_sockaddr *lsa)
1100+ c = recvfrom(pingsock, G.rcv_packet, G.sizeof_rcv_packet, 0,
1101+ (struct sockaddr *) &from, &fromlen);
1102+ if (c < 0) {
1103+ - if (errno != EINTR)
1104+ + if (errno != EINTR && errno != EAGAIN)
1105+ bb_simple_perror_msg("recvfrom");
1106+ continue;
1107+ }
1108+ diff --git a/procps/top.c b/procps/top.c
1109+ index 4cd545c69..56c54ee03 100644
1110+ --- a/procps/top.c
1111+ +++ b/procps/top.c
1112+ @@ -596,7 +596,7 @@ static unsigned long display_header(int scr_width, int *lines_rem_p)
1113+ open_read_close("loadavg", buf, sizeof(scrbuf) - sizeof("Load average: "));
1114+ scrbuf[scr_width - 1] = '\0';
1115+ strchrnul(buf, '\n')[0] = '\0';
1116+ - puts(scrbuf);
1117+ + //puts(scrbuf);
1118+ (*lines_rem_p)--;
1119+
1120+ return meminfo[MI_MEMTOTAL];
1121+ @@ -621,7 +621,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width)
1122+
1123+ /* what info of the processes is shown */
1124+ printf(OPT_BATCH_MODE ? "%.*s" : ESC"[7m" "%.*s" ESC"[m", scr_width,
1125+ - " PID PPID USER STAT VSZ %VSZ"
1126+ + " PID PPID STAT VSZ %VSZ"
1127+ IF_FEATURE_TOP_SMP_PROCESS(" CPU")
1128+ IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU")
1129+ " COMMAND");
1130+ @@ -700,11 +700,11 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width)
1131+ smart_ulltoa5(s->vsz, vsz_str_buf, " mgtpezy");
1132+ /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */
1133+ col = snprintf(line_buf, scr_width,
1134+ - "\n" "%5u%6u %-8.8s %s %.5s" FMT
1135+ + "\n" " %-5u%-6u %s %.5s " FMT
1136+ IF_FEATURE_TOP_SMP_PROCESS(" %3d")
1137+ IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(FMT)
1138+ " ",
1139+ - s->pid, s->ppid, get_cached_username(s->uid),
1140+ + s->pid, s->ppid,
1141+ s->state, vsz_str_buf,
1142+ SHOW_STAT(pmem)
1143+ IF_FEATURE_TOP_SMP_PROCESS(, s->last_seen_on_cpu)
8061144diff --git a/shell/ash.c b/shell/ash.c
8071145index 827643808..d98d58ec9 100644
8081146--- a/shell/ash.c
@@ -842,6 +1180,26 @@ index 827643808..d98d58ec9 100644
8421180 }
8431181 static int
8441182 dup2_or_raise(int from, int to)
1183+ diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
1184+ index 1c2a7d683..9004a06d8 100644
1185+ --- a/util-linux/fdisk.c
1186+ +++ b/util-linux/fdisk.c
1187+ @@ -2969,6 +2969,7 @@ open_list_and_close(const char *device, int user_specified)
1188+ static int is_whole_disk(const char *disk)
1189+ {
1190+ unsigned len;
1191+ + #if 0
1192+ int fd = open(disk, O_RDONLY);
1193+
1194+ if (fd != -1) {
1195+ @@ -2978,6 +2979,7 @@ static int is_whole_disk(const char *disk)
1196+ if (!err)
1197+ return (geometry.start == 0);
1198+ }
1199+ + #endif
1200+
1201+ /* Treat "nameN" as a partition name, not whole disk */
1202+ /* note: mmcblk0 should work from the geometry check above */
8451203diff --git a/util-linux/fdisk_gpt.c b/util-linux/fdisk_gpt.c
8461204index 4c30f31f8..a152d3a73 100644
8471205--- a/util-linux/fdisk_gpt.c
0 commit comments