From 857a06c71e7c09486c188b118b83e42eb3acc370 Mon Sep 17 00:00:00 2001 From: luowei Date: Wed, 25 Jun 2025 14:19:17 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=8E=BB=E9=99=A4ipcs=20-s=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luowei --- generated/flags.h | 22 ++++++++++++++++++++++ generated/help.h | 5 +++++ generated/newtoys.h | 5 +++++ toys/pending/ipcs.c | 38 +++++++++++++++++++++++++++++++++++++- 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/generated/flags.h b/generated/flags.h index 6b76062..baa240b 100644 --- a/generated/flags.h +++ b/generated/flags.h @@ -1483,6 +1483,23 @@ // ipcs acptulsqmi# #undef OPTSTR_ipcs +#ifdef TOYBOX_OH_ADAPT +//delete 'ipcs -s' fail problem: kernel is not configured for semaphores +#define OPTSTR_ipcs "acptulqmi#" +#ifdef CLEANUP_ipcs +#undef CLEANUP_ipcs +#undef FOR_ipcs +#undef FLAG_i +#undef FLAG_m +#undef FLAG_q +#undef FLAG_l +#undef FLAG_u +#undef FLAG_t +#undef FLAG_p +#undef FLAG_c +#undef FLAG_a +#endif +#else #define OPTSTR_ipcs "acptulsqmi#" #ifdef CLEANUP_ipcs #undef CLEANUP_ipcs @@ -1498,6 +1515,7 @@ #undef FLAG_c #undef FLAG_a #endif +#endif // kill ?ls: ?ls: #undef OPTSTR_kill @@ -4761,7 +4779,11 @@ #define FLAG_i (1LL<<0) #define FLAG_m (1LL<<1) #define FLAG_q (1LL<<2) +#ifdef TOYBOX_OH_ADAPT +//delete 'ipcs -s' fail problem: kernel is not configured for semaphores +#else #define FLAG_s (1LL<<3) +#endif #define FLAG_l (1LL<<4) #define FLAG_u (1LL<<5) #define FLAG_t (1LL<<6) diff --git a/generated/help.h b/generated/help.h index 4df3639..5d95fc8 100644 --- a/generated/help.h +++ b/generated/help.h @@ -396,7 +396,12 @@ #define HELP_klogd "usage: klogd [-n] [-c N]\n\n-c N Print to console messages more urgent than prio N (1-8)\"\n-n Run in foreground" +#ifdef TOYBOX_OH_ADAPT +//delete 'ipcs -s' fail problem: kernel is not configured for semaphores +#define HELP_ipcs "usage: ipcs [[-mq] -i shmid] | [[-amq] [-tcplu]]\n\n-i Show specific resource\nResource specification:\n-a All (default)\n-m Shared memory segments\n-q Message queues\nOutput format:\n-c Creator\n-l Limits\n-p Pid\n-t Time\n-u Summary" +#else #define HELP_ipcs "usage: ipcs [[-smq] -i shmid] | [[-asmq] [-tcplu]]\n\n-i Show specific resource\nResource specification:\n-a All (default)\n-m Shared memory segments\n-q Message queues\n-s Semaphore arrays\nOutput format:\n-c Creator\n-l Limits\n-p Pid\n-t Time\n-u Summary" +#endif #define HELP_ipcrm "usage: ipcrm [ [-q msqid] [-m shmid] [-s semid]\n [-Q msgkey] [-M shmkey] [-S semkey] ... ]\n\n-mM Remove memory segment after last detach\n-qQ Remove message queue\n-sS Remove semaphore" diff --git a/generated/newtoys.h b/generated/newtoys.h index 6abd3a8..d7c9e0b 100644 --- a/generated/newtoys.h +++ b/generated/newtoys.h @@ -130,7 +130,12 @@ USE_IOTOP(NEWTOY(iotop, ">0AaKO" "Hk*o*p*u*s#<1=7d%<100=3000m#n#<1bq", TOYFLAG_U USE_IP(NEWTOY(ip, NULL, TOYFLAG_SBIN)) USE_IP(OLDTOY(ipaddr, ip, TOYFLAG_SBIN)) USE_IPCRM(NEWTOY(ipcrm, "m*M*s*S*q*Q*", TOYFLAG_USR|TOYFLAG_BIN)) +#ifdef TOYBOX_OH_ADAPT +//delete 'ipcs -s' fail problem: kernel is not configured for semaphores +USE_IPCS(NEWTOY(ipcs, "acptulqmi#", TOYFLAG_USR|TOYFLAG_BIN)) +#else USE_IPCS(NEWTOY(ipcs, "acptulsqmi#", TOYFLAG_USR|TOYFLAG_BIN)) +#endif USE_IP(OLDTOY(iplink, ip, TOYFLAG_SBIN)) USE_IP(OLDTOY(iproute, ip, TOYFLAG_SBIN)) USE_IP(OLDTOY(iprule, ip, TOYFLAG_SBIN)) diff --git a/toys/pending/ipcs.c b/toys/pending/ipcs.c index b5986af..9789f2d 100644 --- a/toys/pending/ipcs.c +++ b/toys/pending/ipcs.c @@ -4,7 +4,12 @@ * * see http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ipcs.html +#ifdef TOYBOX_OH_ADAPT +//delete 'ipcs -s' fail problem: kernel is not configured for semaphores +USE_IPCS(NEWTOY(ipcs, "acptulqmi#", TOYFLAG_USR|TOYFLAG_BIN)) +#else USE_IPCS(NEWTOY(ipcs, "acptulsqmi#", TOYFLAG_USR|TOYFLAG_BIN)) +#endif config IPCS bool "ipcs" @@ -256,11 +261,20 @@ static void sem_array(void) struct group *gr; u.array = (unsigned short *)&info_buf; + +#ifdef TOYBOX_OH_ADAPT +//delete 'ipcs -s' fail problem: kernel is not configured for semaphores if ((max_nr = semctl(0, 0, SEM_INFO, u)) < 0) { + if (errno == EINVAL) return; perror_msg("kernel is not configured for semaphores"); return; } - +#else + if ((max_nr = semctl(0, 0, SEM_INFO, u)) < 0) { + perror_msg("kernel is not configured for semaphores"); + return; + } +#endif if (flag(u)) { printf("------ Semaphore Status --------\n"); @@ -421,6 +435,18 @@ static void msg_array(void) void ipcs_main(void) { +#ifdef TOYBOX_OH_ADAPT +//delete 'ipcs -s' fail problem: kernel is not configured for semaphores + if (flag(s)) { + error_exit("Unknown option 's' (see \"ipcs --help\")"); + } + if (flag(i)) { + if (flag(m)) show_shm_id(); + else if (flag(q)) show_msg_id(); + else help_exit(0); + return; + } +#else if (flag(i)) { if (flag(m)) show_shm_id(); else if (flag(s)) show_sem_id(); @@ -428,18 +454,28 @@ void ipcs_main(void) else help_exit(0); return; } +#endif +#ifdef TOYBOX_OH_ADAPT +//delete 'ipcs -s' fail problem: kernel is not configured for semaphores + if (!(flag(m) || flag(q)) || flag(a)) toys.optflags |= (FLAG_m|FLAG_q); +#else if (!(flag(m) || flag(s) || flag(q)) || flag(a)) toys.optflags |= (FLAG_m|FLAG_s|FLAG_q); +#endif xputc('\n'); if (flag(m)) { shm_array(); xputc('\n'); } +#ifdef TOYBOX_OH_ADAPT +//delete 'ipcs -s' fail problem: kernel is not configured for semaphores +#else if (flag(s)) { sem_array(); xputc('\n'); } +#endif if (flag(q)) { msg_array(); xputc('\n'); -- Gitee From 46aacbd8b1040a6170d1b976a2a3f50919cceec3 Mon Sep 17 00:00:00 2001 From: luowei Date: Wed, 25 Jun 2025 16:01:18 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=8E=BB=E9=99=A4ipcs=20-s=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luowei --- toys/pending/ipcs.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/toys/pending/ipcs.c b/toys/pending/ipcs.c index 9789f2d..73c6ed7 100644 --- a/toys/pending/ipcs.c +++ b/toys/pending/ipcs.c @@ -251,6 +251,9 @@ static void shm_array(void) } } +#ifdef TOYBOX_OH_ADAPT +//delete 'ipcs -s' fail problem: kernel is not configured for semaphores +#else static void sem_array(void) { struct seminfo info_buf; @@ -262,19 +265,11 @@ static void sem_array(void) u.array = (unsigned short *)&info_buf; -#ifdef TOYBOX_OH_ADAPT -//delete 'ipcs -s' fail problem: kernel is not configured for semaphores if ((max_nr = semctl(0, 0, SEM_INFO, u)) < 0) { if (errno == EINVAL) return; perror_msg("kernel is not configured for semaphores"); return; } -#else - if ((max_nr = semctl(0, 0, SEM_INFO, u)) < 0) { - perror_msg("kernel is not configured for semaphores"); - return; - } -#endif if (flag(u)) { printf("------ Semaphore Status --------\n"); @@ -347,6 +342,7 @@ static void sem_array(void) } } } +#endif static void msg_array(void) { -- Gitee From 9b87f35d0a09feac5caae28932aace280f81fa2f Mon Sep 17 00:00:00 2001 From: luowei Date: Wed, 25 Jun 2025 09:29:06 +0000 Subject: [PATCH 3/4] =?UTF-8?q?update=20toys/pending/ipcs.c.=20=E5=8E=BB?= =?UTF-8?q?=E9=99=A4ipcs=20-s=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luowei --- toys/pending/ipcs.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/toys/pending/ipcs.c b/toys/pending/ipcs.c index 73c6ed7..92e8f3f 100644 --- a/toys/pending/ipcs.c +++ b/toys/pending/ipcs.c @@ -264,9 +264,7 @@ static void sem_array(void) struct group *gr; u.array = (unsigned short *)&info_buf; - if ((max_nr = semctl(0, 0, SEM_INFO, u)) < 0) { - if (errno == EINVAL) return; perror_msg("kernel is not configured for semaphores"); return; } -- Gitee From 84b31162fc06d1e46ee904a79ae082bec01402dc Mon Sep 17 00:00:00 2001 From: luowei Date: Wed, 25 Jun 2025 09:32:03 +0000 Subject: [PATCH 4/4] =?UTF-8?q?update=20toys/pending/ipcs.c.=20=E5=8E=BB?= =?UTF-8?q?=E9=99=A4ipcs=20-s=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luowei --- toys/pending/ipcs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/toys/pending/ipcs.c b/toys/pending/ipcs.c index 92e8f3f..55f8d98 100644 --- a/toys/pending/ipcs.c +++ b/toys/pending/ipcs.c @@ -269,6 +269,7 @@ static void sem_array(void) return; } + if (flag(u)) { printf("------ Semaphore Status --------\n"); printf("used arrays = %d\n" -- Gitee