Re: [PATCH v4] tree: new applet

2022-05-01 Thread tito
On Mon, 2 May 2022 01:40:39 +0800
Kang-Che Sung  wrote:

> Hi Roger,
> 
> May I suggest you add an option to draw the tree lines using ASCII
> characters only, and make the Unicode support optional at build time?
> 
> I just feel uncomfortable when I see source code containing embedded UTF-8
> characters and the strings have no ASCII alternative.
> 
> The DOS tree command has the "/a" option. You know what I mean.
> 
> Thank you.

Hi,
something like ?:

#ifdef CONFIG_TREE_ASCII_ONLY
#define PREFIX_CHILD "|- "
#define PREFIX_LAST_CHILD "|_ "
#define PREFIX_GRAND_CHILD "|  "
#define PREFIX_LAST_GRAND_CHILD "   "
#else
#define PREFIX_CHILD "├── "
#define PREFIX_LAST_CHILD "└── "
#define PREFIX_GRAND_CHILD "│   "
#define PREFIX_LAST_GRAND_CHILD "    "
#endif

Ciao,
Tito

> On Sunday, May 1, 2022, Roger Knecht  wrote:
> > Add new applet which resembles the MS-DOS tree program to list
> directories and files in a tree structure.
> >
> > function old new   delta
> > tree_print - 388+388
> > .rodata95678   95767 +89
> > tree_main  -  73 +73
> > tree_print_prefix  -  28 +28
> > packed_usage   34417   34429 +12
> > globals-   8  +8
> > applet_main 31923200  +8
> > applet_names27472752  +5
> >
> --
> > (add/remove: 5/0 grow/shrink: 4/0 up/down: 611/0) Total: 611
> bytes
> >
> > Signed-off-by: Roger Knecht 
> > ---
> > Changelog:
> >
> > V4:
> > - Rephrase commit message
> > - Updated bloatcheck to latest master
> >
> > V3:
> > - Fixed symlink handling
> > - Handle multiple directories in command line arguments
> > - Extended tests for symlink and multiple directories
> > - Reduced size by using libbb functions
> >
> > V2:
> > - Fixed tree help text
> > - Reduced size by 644 bytes
> >

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH v4] tree: new applet

2022-05-01 Thread Kang-Che Sung
Hi Roger,

May I suggest you add an option to draw the tree lines using ASCII
characters only, and make the Unicode support optional at build time?

I just feel uncomfortable when I see source code containing embedded UTF-8
characters and the strings have no ASCII alternative.

The DOS tree command has the "/a" option. You know what I mean.

Thank you.

On Sunday, May 1, 2022, Roger Knecht  wrote:
> Add new applet which resembles the MS-DOS tree program to list
directories and files in a tree structure.
>
> function old new   delta
> tree_print - 388+388
> .rodata95678   95767 +89
> tree_main  -  73 +73
> tree_print_prefix  -  28 +28
> packed_usage   34417   34429 +12
> globals-   8  +8
> applet_main 31923200  +8
> applet_names27472752  +5
>
--
> (add/remove: 5/0 grow/shrink: 4/0 up/down: 611/0) Total: 611
bytes
>
> Signed-off-by: Roger Knecht 
> ---
> Changelog:
>
> V4:
> - Rephrase commit message
> - Updated bloatcheck to latest master
>
> V3:
> - Fixed symlink handling
> - Handle multiple directories in command line arguments
> - Extended tests for symlink and multiple directories
> - Reduced size by using libbb functions
>
> V2:
> - Fixed tree help text
> - Reduced size by 644 bytes
>
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH v4] tree: new applet

2022-05-01 Thread tito
On Sun, 01 May 2022 12:51:16 +
Roger Knecht  wrote:

> Add new applet which resembles the MS-DOS tree program to list directories 
> and files in a tree structure.
> 
> function old new   delta
> tree_print - 388+388
> .rodata95678   95767 +89
> tree_main  -  73 +73
> tree_print_prefix  -  28 +28
> packed_usage   34417   34429 +12
> globals-   8  +8
> applet_main 31923200  +8
> applet_names27472752  +5
> --
> (add/remove: 5/0 grow/shrink: 4/0 up/down: 611/0) Total: 611 bytes
> 
> Signed-off-by: Roger Knecht 
> ---
> Changelog:
> 
> V4:
> - Rephrase commit message
> - Updated bloatcheck to latest master
> 
> V3:
> - Fixed symlink handling
> - Handle multiple directories in command line arguments
> - Extended tests for symlink and multiple directories
> - Reduced size by using libbb functions
> 
> V2:
> - Fixed tree help text
> - Reduced size by 644 bytes
> 
>  AUTHORS  |   3 +
>  miscutils/tree.c | 135 +++
>  testsuite/tree.tests |  97 +++
>  3 files changed, 235 insertions(+)
>  create mode 100644 miscutils/tree.c
>  create mode 100755 testsuite/tree.tests
> 
> diff --git a/AUTHORS b/AUTHORS
> index 5c9a634c9..9ec0e2ee4 100644
> --- a/AUTHORS
> +++ b/AUTHORS
> @@ -181,3 +181,6 @@ Jie Zhang 
> 
>  Maxime Coste 
>  paste implementation
> +
> +Roger Knecht 
> +tree
> diff --git a/miscutils/tree.c b/miscutils/tree.c
> new file mode 100644
> index 0..e053e8483
> --- /dev/null
> +++ b/miscutils/tree.c
> @@ -0,0 +1,135 @@
> +/* vi: set sw=4 ts=4: */
> +/*
> + * Copyright (C) 2022 Roger Knecht 
> + *
> + * Licensed under GPLv2, see file LICENSE in this source tree.
> + */
> +//config:config TREE
> +//config:bool "tree (0.6 kb)"
> +//config:default n
> +//config:help
> +//config:List files and directories in a tree structure.
> +//config:
> +
> +//applet:IF_TREE(APPLET(tree, BB_DIR_USR_BIN, BB_SUID_DROP))
> +
> +//kbuild:lib-$(CONFIG_TREE) += tree.o
> +
> +//usage:#define tree_trivial_usage NOUSAGE_STR
> +//usage:#define tree_full_usage ""
> +
> +#include "libbb.h"
> +
> +#define PREFIX_CHILD "├── "
> +#define PREFIX_LAST_CHILD "└── "
> +#define PREFIX_GRAND_CHILD "│   "
> +#define PREFIX_LAST_GRAND_CHILD ""
> +#define DEFAULT_PATH "."
> +
> +struct directory {
> + struct directory* parent;
> + const char* prefix;
> +};
> +
> +static struct globals {
> + int directories;
> + int files;
> +} globals;
> +
> +static void tree_print_prefix(struct directory* directory) {
> + if (directory) {
> + tree_print_prefix(directory->parent);
> + fputs_stdout(directory->prefix);
> + }
> +}
> +
> +static void tree_print(const char* directory_name, struct directory* 
> directory) {
> + struct dirent **entries, *dirent;
> + struct directory child_directory;
> + char* symlink_path;
> + int index, size;
//> +   bool is_not_last, is_file;
> +
> + // read directory entries
> + size = scandir(directory_name, , NULL, alphasort);
> +
> + if (size < 0) {
> + fputs_stdout(directory_name);
> + puts(" [error opening dir]");
> + return;
> + }
> +
> + // print directory name
> + puts(directory_name);
> +
> + // switch to sub directory
> + xchdir(directory_name);
> +
> + child_directory.parent = directory;
> +
> + // print all directory entries
> + for (index = 0; index < size; index++) {
> +     dirent = entries[index];
> +
> + // filter hidden files and directories
Hi,
if (dirent->d_name[0] != '.') {
> + if (strncmp(dirent->d_name, ".", 1) != 0) {

twisted logic?

> + is_file = !is_directory(dirent->d_name, 1);

is_not_last is used only once

> + is_not_last = (index + 1) < size;
> + symlink_path = xmalloc_readlink(dirent->d_na

[PATCH v2 2/2] tree-wide: use xopen_as

2021-03-04 Thread Rasmus Villemoes
Typical saving per callsite (on x86-64) is 7 bytes, so net win at 3
conversions.

function old new   delta
xopen_as   -  18 +18
xargs_main   871 864  -7
vlock_main   409 402  -7
uniq_main463 456  -7
ubi_tools_main  12981291  -7
split_main   581 574  -7
sort_main   10651058  -7
shuf_main550 543  -7
reinitialize 206 199  -7
nc_main 12251218  -7
mkfs_minix_main 28652858  -7
mkfs_ext2_main  24052398  -7
fsck_minix_main 31453138  -7
acpid_main  13261319  -7
cpio_main654 645  -9
close_dev_fd  28  19  -9
watchdog_main335 321 -14
dd_main 16421628 -14
--
(add/remove: 1/0 grow/shrink: 0/17 up/down: 18/-137) Total: -119 bytes

Signed-off-by: Rasmus Villemoes 
---
 archival/cpio.c | 6 +++---
 coreutils/dd.c  | 4 ++--
 coreutils/shuf.c| 2 +-
 coreutils/sort.c| 2 +-
 coreutils/split.c   | 2 +-
 coreutils/uniq.c| 2 +-
 findutils/xargs.c   | 2 +-
 loginutils/vlock.c  | 2 +-
 miscutils/less.c| 2 +-
 miscutils/ubi_tools.c   | 2 +-
 miscutils/watchdog.c| 4 ++--
 networking/nc_bloaty.c  | 2 +-
 util-linux/acpid.c  | 2 +-
 util-linux/fdisk.c  | 2 +-
 util-linux/fsck_minix.c | 2 +-
 util-linux/mkfs_ext2.c  | 2 +-
 util-linux/mkfs_minix.c | 2 +-
 17 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/archival/cpio.c b/archival/cpio.c
index 94303389e..0d25ead91 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -405,11 +405,11 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
}
 #if !ENABLE_FEATURE_CPIO_O
if (opt & OPT_FILE) { /* -F */
-   xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO);
+   xopen_as(cpio_filename, O_RDONLY, STDIN_FILENO);
}
 #else
if ((opt & (OPT_FILE|OPT_CREATE)) == OPT_FILE) { /* -F without -o */
-   xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO);
+   xopen_as(cpio_filename, O_RDONLY, STDIN_FILENO);
}
if (opt & OPT_PASSTHROUGH) {
pid_t pid;
@@ -459,7 +459,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
if (cpio_fmt[0] != 'n') /* we _require_ "-H newc" */
bb_show_usage();
if (opt & OPT_FILE) {
-   xmove_fd(xopen(cpio_filename, O_WRONLY | O_CREAT | 
O_TRUNC), STDOUT_FILENO);
+   xopen_as(cpio_filename, O_WRONLY | O_CREAT | O_TRUNC, 
STDOUT_FILENO);
}
  dump:
return cpio_o();
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 24d7f0b84..6fd8b1daf 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -500,7 +500,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
if (G.flags & FLAG_IDIRECT)
iflag |= O_DIRECT;
 #endif
-   xmove_fd(xopen(infile, iflag), ifd);
+   xopen_as(infile, iflag, ifd);
} else {
infile = bb_msg_standard_input;
}
@@ -515,7 +515,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
if (G.flags & FLAG_ODIRECT)
oflag |= O_DIRECT;
 #endif
-   xmove_fd(xopen(outfile, oflag), ofd);
+   xopen_as(outfile, oflag, ofd);
 
if (seek && !(G.flags & FLAG_NOTRUNC)) {
size_t blocksz = (G.flags & FLAG_SEEK_BYTES) ? 1 : obs;
diff --git a/coreutils/shuf.c b/coreutils/shuf.c
index fdbd3e9b2..b9daaaf38 100644
--- a/coreutils/shuf.c
+++ b/coreutils/shuf.c
@@ -132,7 +132,7 @@ int shuf_main(int argc, char **argv)
shuffle_lines(lines, numlines);
 
if (opts & OPT_o)
-   xmove_fd(xopen(opt_o_str, O_WRONLY|O_CREAT|O_TRUNC), 
STDOUT_FILENO);
+   xopen_as(opt_o_str, O_WRONLY | O_CREAT | O_TRUNC, 
STDOUT_FILENO);
 
if (opts & OPT_n) {
unsigned maxlines;
diff --git a/coreutils/sort.c b/coreutils/sort.c
index b194847d1..899f2cc51 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -635,7 +635,7 @@ int sort_main(int argc 

[PATCH 2/2] tree-wide: use xopen_fd

2021-03-01 Thread Rasmus Villemoes
Typical saving per callsite (on x86-64) is 7 bytes, so net win at 3
conversions.

function old new   delta
xopen_fd   -  18 +18
xargs_main   871 864  -7
vlock_main   409 402  -7
uniq_main463 456  -7
ubi_tools_main  12981291  -7
split_main   581 574  -7
sort_main   10651058  -7
shuf_main550 543  -7
reinitialize 206 199  -7
nc_main 12251218  -7
mkfs_minix_main 28652858  -7
mkfs_ext2_main  24052398  -7
fsck_minix_main 31453138  -7
acpid_main  13261319  -7
cpio_main654 645  -9
close_dev_fd  28  19  -9
watchdog_main335 321 -14
dd_main 16421628 -14
--
(add/remove: 1/0 grow/shrink: 0/17 up/down: 18/-137) Total: -119 bytes

Signed-off-by: Rasmus Villemoes 
---
 archival/cpio.c | 6 +++---
 coreutils/dd.c  | 4 ++--
 coreutils/shuf.c| 2 +-
 coreutils/sort.c| 2 +-
 coreutils/split.c   | 2 +-
 coreutils/uniq.c| 2 +-
 findutils/xargs.c   | 2 +-
 loginutils/vlock.c  | 2 +-
 miscutils/less.c| 2 +-
 miscutils/ubi_tools.c   | 2 +-
 miscutils/watchdog.c| 4 ++--
 networking/nc_bloaty.c  | 2 +-
 util-linux/acpid.c  | 2 +-
 util-linux/fdisk.c  | 2 +-
 util-linux/fsck_minix.c | 2 +-
 util-linux/mkfs_ext2.c  | 2 +-
 util-linux/mkfs_minix.c | 2 +-
 17 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/archival/cpio.c b/archival/cpio.c
index 94303389e..ab918f61a 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -405,11 +405,11 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
}
 #if !ENABLE_FEATURE_CPIO_O
if (opt & OPT_FILE) { /* -F */
-   xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO);
+   xopen_fd(cpio_filename, O_RDONLY, STDIN_FILENO);
}
 #else
if ((opt & (OPT_FILE|OPT_CREATE)) == OPT_FILE) { /* -F without -o */
-   xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO);
+   xopen_fd(cpio_filename, O_RDONLY, STDIN_FILENO);
}
if (opt & OPT_PASSTHROUGH) {
pid_t pid;
@@ -459,7 +459,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
if (cpio_fmt[0] != 'n') /* we _require_ "-H newc" */
bb_show_usage();
if (opt & OPT_FILE) {
-   xmove_fd(xopen(cpio_filename, O_WRONLY | O_CREAT | 
O_TRUNC), STDOUT_FILENO);
+   xopen_fd(cpio_filename, O_WRONLY | O_CREAT | O_TRUNC, 
STDOUT_FILENO);
}
  dump:
return cpio_o();
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 24d7f0b84..215c61de9 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -500,7 +500,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
if (G.flags & FLAG_IDIRECT)
iflag |= O_DIRECT;
 #endif
-   xmove_fd(xopen(infile, iflag), ifd);
+   xopen_fd(infile, iflag, ifd);
} else {
infile = bb_msg_standard_input;
}
@@ -515,7 +515,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
if (G.flags & FLAG_ODIRECT)
oflag |= O_DIRECT;
 #endif
-   xmove_fd(xopen(outfile, oflag), ofd);
+   xopen_fd(outfile, oflag, ofd);
 
if (seek && !(G.flags & FLAG_NOTRUNC)) {
size_t blocksz = (G.flags & FLAG_SEEK_BYTES) ? 1 : obs;
diff --git a/coreutils/shuf.c b/coreutils/shuf.c
index fdbd3e9b2..a347eb645 100644
--- a/coreutils/shuf.c
+++ b/coreutils/shuf.c
@@ -132,7 +132,7 @@ int shuf_main(int argc, char **argv)
shuffle_lines(lines, numlines);
 
if (opts & OPT_o)
-   xmove_fd(xopen(opt_o_str, O_WRONLY|O_CREAT|O_TRUNC), 
STDOUT_FILENO);
+   xopen_fd(opt_o_str, O_WRONLY | O_CREAT | O_TRUNC, 
STDOUT_FILENO);
 
if (opts & OPT_n) {
unsigned maxlines;
diff --git a/coreutils/sort.c b/coreutils/sort.c
index b194847d1..36c160c16 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -635,7 +635,7 @@ int sort_main(int argc 

Re: Out-of-tree build broken

2019-10-30 Thread Samuel Ainsworth
I tried recreating and I’m no longer able to reproduce. Must have been 
something weird…

Thanks,
Samuel 

> On Oct 30, 2019, at 7:51 AM, Denys Vlasenko  wrote:
> 
> On Tue, Oct 29, 2019 at 1:49 AM Samuel Ainsworth  <mailto:skainswo...@gmail.com>> wrote:
>> 
>> Hello busybox overlords,
>> 
>> I have a fresh checkout of busybox version 1.31.1 (git hash 
>> bd754746394a382e04d116df02547f61b2026da9), and I’m trying to build it on 
>> Ubuntu 18.04 with gcc 7.4 with an out-of-tree build (per per 
>> https://github.com/jgunthorpe/busybox/blob/master/INSTALL#L95) with 
>> defconfig. But I’m getting some build errors:
>> 
>> root@e581c80974df:~/bbbuild# make
>> make -C /src O=/root/bbbuild
>>  Using /src as source for busybox
>>  GEN /root/bbbuild/Makefile
>>  SPLIT   include/autoconf.h -> include/config/*
>>  GEN include/bbconfigopts.h
>>  GEN include/common_bufsiz.h
>>  GEN include/embedded_scripts.h
>>  HOSTCC  applets/usage
>> In file included from /src/applets/usage.c:30:0:
>> /src/include/applets.h:338:1: warning: implicit declaration of function 
>> 'IF_RMMOD'; did you mean 'IF_CHMOD'? [-Wimplicit-function-declaration]
>> IF_RMMOD(   IF_MODPROBE_SMALL(APPLET_NOEXEC( rmmod,modprobe, 
>> BB_DIR_SBIN, BB_SUID_DROP, rmmod   )))
>> ^~~~
>> IF_CHMOD
>> In file included from /src/applets/usage.c:11:0:
>> /src/applets/usage.c:25:34: error: expected expression before '{' token
> 
> Works for me.
> git hash bd754746394a382e04d116df02547f61b2026da9
> gcc 9.0.1

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Out-of-tree build broken

2019-10-30 Thread Denys Vlasenko
On Tue, Oct 29, 2019 at 1:49 AM Samuel Ainsworth  wrote:
>
> Hello busybox overlords,
>
> I have a fresh checkout of busybox version 1.31.1 (git hash 
> bd754746394a382e04d116df02547f61b2026da9), and I’m trying to build it on 
> Ubuntu 18.04 with gcc 7.4 with an out-of-tree build (per per 
> https://github.com/jgunthorpe/busybox/blob/master/INSTALL#L95) with 
> defconfig. But I’m getting some build errors:
>
> root@e581c80974df:~/bbbuild# make
> make -C /src O=/root/bbbuild
>   Using /src as source for busybox
>   GEN /root/bbbuild/Makefile
>   SPLIT   include/autoconf.h -> include/config/*
>   GEN include/bbconfigopts.h
>   GEN include/common_bufsiz.h
>   GEN include/embedded_scripts.h
>   HOSTCC  applets/usage
> In file included from /src/applets/usage.c:30:0:
> /src/include/applets.h:338:1: warning: implicit declaration of function 
> 'IF_RMMOD'; did you mean 'IF_CHMOD'? [-Wimplicit-function-declaration]
>  IF_RMMOD(   IF_MODPROBE_SMALL(APPLET_NOEXEC( rmmod,modprobe, 
> BB_DIR_SBIN, BB_SUID_DROP, rmmod   )))
>  ^~~~
>  IF_CHMOD
> In file included from /src/applets/usage.c:11:0:
> /src/applets/usage.c:25:34: error: expected expression before '{' token

Works for me.
git hash bd754746394a382e04d116df02547f61b2026da9
gcc 9.0.1
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Out-of-tree build broken

2019-10-28 Thread Samuel Ainsworth
Correction: the actual out-of-tree building link is 
https://github.com/mirror/busybox/blob/master/INSTALL#L125 
<https://github.com/mirror/busybox/blob/master/INSTALL#L125>.

> On Oct 28, 2019, at 5:49 PM, Samuel Ainsworth  wrote:
> 
> Hello busybox overlords,
> 
> I have a fresh checkout of busybox version 1.31.1 (git hash 
> bd754746394a382e04d116df02547f61b2026da9), and I’m trying to build it on 
> Ubuntu 18.04 with gcc 7.4 with an out-of-tree build (per per 
> https://github.com/jgunthorpe/busybox/blob/master/INSTALL#L95 
> <https://github.com/jgunthorpe/busybox/blob/master/INSTALL#L95>) with 
> defconfig. But I’m getting some build errors:
> 
> root@e581c80974df:~/bbbuild# make
> make -C /src O=/root/bbbuild
>   Using /src as source for busybox
>   GEN /root/bbbuild/Makefile
>   SPLIT   include/autoconf.h -> include/config/*
>   GEN include/bbconfigopts.h
>   GEN include/common_bufsiz.h
>   GEN include/embedded_scripts.h
>   HOSTCC  applets/usage
> In file included from /src/applets/usage.c:30:0:
> /src/include/applets.h:338:1: warning: implicit declaration of function 
> 'IF_RMMOD'; did you mean 'IF_CHMOD'? [-Wimplicit-function-declaration]
>  IF_RMMOD(   IF_MODPROBE_SMALL(APPLET_NOEXEC( rmmod,modprobe, 
> BB_DIR_SBIN, BB_SUID_DROP, rmmod   )))
>  ^~~~
>  IF_CHMOD
> In file included from /src/applets/usage.c:11:0:
> /src/applets/usage.c:25:34: error: expected expression before '{' token
>  #define MAKE_USAGE(aname, usage) { aname, usage },
>   ^
> /src/include/autoconf.h:3528:33: note: in definition of macro 
> 'IF_MODPROBE_SMALL'
>  # define IF_MODPROBE_SMALL(...) __VA_ARGS__
>  ^~~
> /src/include/applets.h:43:46: note: in expansion of macro 'MAKE_USAGE'
>  # define APPLET_NOEXEC(name,main,l,s,help)   MAKE_USAGE(#name, 
> help##_trivial_usage help##_full_usage)
>   ^~
> /src/include/applets.h:338:31: note: in expansion of macro 'APPLET_NOEXEC'
>  IF_RMMOD(   IF_MODPROBE_SMALL(APPLET_NOEXEC( rmmod,modprobe, 
> BB_DIR_SBIN, BB_SUID_DROP, rmmod   )))
>^
> /src/applets/usage.c: In function 'main':
> /src/applets/usage.c:52:3: warning: ignoring return value of 'write', 
> declared with attribute warn_unused_result [-Wunused-result]
>write(STDOUT_FILENO, usage_array[i].usage, strlen(usage_array[i].usage) + 
> 1);
>
> ^~~~
> scripts/Makefile.host:104: recipe for target 'applets/usage' failed
> make[3]: *** [applets/usage] Error 1
> /src/Makefile:372: recipe for target 'applets_dir' failed
> make[2]: *** [applets_dir] Error 2
> Makefile:112: recipe for target '_all' failed
> make[1]: *** [_all] Error 2
> Makefile:14: recipe for target 'all' failed
> make: *** [all] Error 2
> root@e581c80974df:~/bbbuild# cc --version
> cc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
> Copyright (C) 2017 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> root@e581c80974df:~/bbbuild# gcc --version
> gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
> Copyright (C) 2017 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> root@e581c80974df:~/bbbuild#
> 
> Building works fine if I don’t try to do it out-of-tree.
> 
> Best,
> Samuel 

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Out-of-tree build broken

2019-10-28 Thread Samuel Ainsworth
Hello busybox overlords,

I have a fresh checkout of busybox version 1.31.1 (git hash 
bd754746394a382e04d116df02547f61b2026da9), and I’m trying to build it on Ubuntu 
18.04 with gcc 7.4 with an out-of-tree build (per per 
https://github.com/jgunthorpe/busybox/blob/master/INSTALL#L95 
<https://github.com/jgunthorpe/busybox/blob/master/INSTALL#L95>) with 
defconfig. But I’m getting some build errors:

root@e581c80974df:~/bbbuild# make
make -C /src O=/root/bbbuild
  Using /src as source for busybox
  GEN /root/bbbuild/Makefile
  SPLIT   include/autoconf.h -> include/config/*
  GEN include/bbconfigopts.h
  GEN include/common_bufsiz.h
  GEN include/embedded_scripts.h
  HOSTCC  applets/usage
In file included from /src/applets/usage.c:30:0:
/src/include/applets.h:338:1: warning: implicit declaration of function 
'IF_RMMOD'; did you mean 'IF_CHMOD'? [-Wimplicit-function-declaration]
 IF_RMMOD(   IF_MODPROBE_SMALL(APPLET_NOEXEC( rmmod,modprobe, BB_DIR_SBIN, 
BB_SUID_DROP, rmmod   )))
 ^~~~
 IF_CHMOD
In file included from /src/applets/usage.c:11:0:
/src/applets/usage.c:25:34: error: expected expression before '{' token
 #define MAKE_USAGE(aname, usage) { aname, usage },
  ^
/src/include/autoconf.h:3528:33: note: in definition of macro 
'IF_MODPROBE_SMALL'
 # define IF_MODPROBE_SMALL(...) __VA_ARGS__
 ^~~
/src/include/applets.h:43:46: note: in expansion of macro 'MAKE_USAGE'
 # define APPLET_NOEXEC(name,main,l,s,help)   MAKE_USAGE(#name, 
help##_trivial_usage help##_full_usage)
  ^~
/src/include/applets.h:338:31: note: in expansion of macro 'APPLET_NOEXEC'
 IF_RMMOD(   IF_MODPROBE_SMALL(APPLET_NOEXEC( rmmod,modprobe, BB_DIR_SBIN, 
BB_SUID_DROP, rmmod   )))
   ^
/src/applets/usage.c: In function 'main':
/src/applets/usage.c:52:3: warning: ignoring return value of 'write', declared 
with attribute warn_unused_result [-Wunused-result]
   write(STDOUT_FILENO, usage_array[i].usage, strlen(usage_array[i].usage) + 1);
   ^~~~
scripts/Makefile.host:104: recipe for target 'applets/usage' failed
make[3]: *** [applets/usage] Error 1
/src/Makefile:372: recipe for target 'applets_dir' failed
make[2]: *** [applets_dir] Error 2
Makefile:112: recipe for target '_all' failed
make[1]: *** [_all] Error 2
Makefile:14: recipe for target 'all' failed
make: *** [all] Error 2
root@e581c80974df:~/bbbuild# cc --version
cc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

root@e581c80974df:~/bbbuild# gcc --version
gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

root@e581c80974df:~/bbbuild#

Building works fine if I don’t try to do it out-of-tree.

Best,
Samuel ___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: tree

2017-05-03 Thread Kang-Che Sung
On Wed, May 3, 2017 at 6:00 AM, Jethro Tull <heavyt...@hotmail.com> wrote:
> why tree is not in busybox?

Short answer: Because no one has been implementing it in Busybox yet.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


tree

2017-05-02 Thread Jethro Tull
why tree is not in busybox?
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: ash parse tree and stack boundaries

2010-12-01 Thread Denys Vlasenko
On Tue, Nov 30, 2010 at 1:57 PM, Phil Carmody
ext-phil.2.carm...@nokia.com wrote:
  There's a problem in busybox ash, which is running out of stack when 
  parsing
  very long input (funnily same bug also exists in bash), like
 
  $ for i in $(seq 10); do echo -n :;; done | busybox sh
  Segmentation fault

 On a 32-bit system, 10 needs 7 Mb of stack.
 The default limit is 8. Therefore it does not crash.

 On your 32 bit system, with your toolchain, it might not crash. However, on
 two unrelated 32-bit systems it crashes for me, and clearly it crashes for
 Alexander too. To boldly assert Therefore it does not crash. is quite
 absurd.

?!
I merely stated that it does not crash on (my) 32-bit system.

 Add to that the fact that Alexander clearly wrote like, implying that
 the exact value was somewhat arbitrary, and your response looks even more
 absurd.

My response is factually correct. Moreover, I confirmed that the problem
is, indeed, real, since I was able to reproduce it with bigger value:

 I reproduced this SEGV with 20.

 Well, that's OK then, we'll consider the problem solved, shall we?

Apparently you interpreted my response that way, even though
it does not say anything like that anywhere.

I hope at least you feel better after venting your anger.
Because I don't.

-- 
vda
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: ash parse tree and stack boundaries

2010-12-01 Thread Denys Vlasenko
On Mon, Nov 29, 2010 at 2:47 PM, Alexander Shishkin virtu...@slind.org wrote:
 I'm
 thinking of how to go about solving it.

 1) introduce recursion depth counter to all the eval*() functions; stack
 limits might differ, thus calculating the maximum depth might be tricky
 and error prone;

How that will help? Instead of a SEGV, you'd get an error message,
but it will still be a failure to execute a perfectly valid script.

 2) install a SEGV handler; ugly;

And similarly to the above, doesn't solve the problem.

 3) optimise evaltree() to iterate through similar nodes; won't help against
 large amounts of ::;;
 4) try to optimise the whole parser to get rid of recursion entirely;

This will fix the problem, but is hard to do.

 5) switch to hush and be done with it (how good is it for a drop-in ash
 replacement)?

There are known ash features which aren't implemented in hush.
But overall, something like 90% or more is already there.
There are even things which work in hush but not in ash.

I am waiting for user reports on their experience and on what
are the most needed missing features.

-- 
vda
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


ash parse tree and stack boundaries

2010-11-29 Thread Alexander Shishkin
Hi,

There's a problem in busybox ash, which is running out of stack when parsing
very long input (funnily same bug also exists in bash), like

$ for i in $(seq 10); do echo -n :;; done | busybox sh
Segmentation fault

which happens in evaltree() calling itself for each : node. Now, I'm
thinking of how to go about solving it.

1) introduce recursion depth counter to all the eval*() functions; stack
limits might differ, thus calculating the maximum depth might be tricky
and error prone;
2) install a SEGV handler; ugly;
3) optimise evaltree() to iterate through similar nodes; won't help against
large amounts of ::;;
4) try to optimise the whole parser to get rid of recursion entirely;
5) switch to hush and be done with it (how good is it for a drop-in ash
replacement)?

Regards,
--
Alex
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: ash parse tree and stack boundaries

2010-11-29 Thread Denys Vlasenko
On Mon, Nov 29, 2010 at 2:47 PM, Alexander Shishkin virtu...@slind.org wrote:
 Hi,

 There's a problem in busybox ash, which is running out of stack when parsing
 very long input (funnily same bug also exists in bash), like

 $ for i in $(seq 10); do echo -n :;; done | busybox sh
 Segmentation fault

On a 32-bit system, 10 needs 7 Mb of stack.
The default limit is 8. Therefore it does not crash.

I reproduced this SEGV with 20.

-- 
vda
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] Fix out-of-tree build's recursion

2010-07-18 Thread Denys Vlasenko
On Thursday 15 July 2010 16:39, Alexander Shishkin wrote:
 While doing O=build build I've noticed that it was getting gradually
 slower with each invocation. The reason turned out to be that the build
 directory was inside the source tree and got recreated inside itself
 with all its subdirectories.
 
 This patch changes the behavior so that only the directories with
 Kbuild.src or Config.src in them are created in the out-of-tree build
 directory. A quick rebuild from scratch revealed no problems with this.

Applied, thanks!
-- 
vda
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] Fix out-of-tree build's recursion

2010-07-15 Thread Alexander Shishkin
While doing O=build build I've noticed that it was getting gradually
slower with each invocation. The reason turned out to be that the build
directory was inside the source tree and got recreated inside itself
with all its subdirectories.

This patch changes the behavior so that only the directories with
Kbuild.src or Config.src in them are created in the out-of-tree build
directory. A quick rebuild from scratch revealed no problems with this.

Signed-off-by: Alexander Shishkin virtu...@slind.org
---
 scripts/gen_build_files.sh |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh
index 9681587..18c172d 100755
--- a/scripts/gen_build_files.sh
+++ b/scripts/gen_build_files.sh
@@ -53,8 +53,8 @@ fi
 
src=$srctree/$d/Kbuild.src
dst=$d/Kbuild
-   mkdir -p -- $d 2/dev/null
if test -f $src; then
+   mkdir -p -- $d 2/dev/null
#echo   CHK $dst
 
s=`sed -n 's...@^//kbuild:@@p' -- $srctree/$d/*.c`
@@ -73,8 +73,8 @@ fi
 
src=$srctree/$d/Config.src
dst=$d/Config.in
-   mkdir -p -- $d 2/dev/null
if test -f $src; then
+   mkdir -p -- $d 2/dev/null
#echo   CHK $dst
 
s=`sed -n 's...@^//config:@@p' -- $srctree/$d/*.c`
-- 
1.7.1

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Failing out-of-tree build since r26139

2009-04-19 Thread Denys Vlasenko
On Saturday 18 April 2009 19:15, Bjørn Forsman wrote:
 Hi all,
 
 I have found that BusyBox SVN r26139 (and up to the latest r26151) breaks
 out-of-tree builds. r26138 works. Below is the log of my breaking r26139
 build:
 
 busybox $ make O=../../build/busybox/ install
   Using
 /media/raid/bjornfor/documents/dev/os/linux/minibuildroot/src/busybox as
 source for busybox
   GEN
 /media/raid/bjornfor/documents/dev/os/linux/minibuildroot/build/busybox/Makefile
   SPLIT   include/autoconf.h - include/config/*
   GEN include/bbconfigopts.h
   HOSTCC  applets/usage
 /media/raid/bjornfor/documents/dev/os/linux/minibuildroot/src/busybox/applets/usage.c:
 In function ‘main’:
 /media/raid/bjornfor/documents/dev/os/linux/minibuildroot/src/busybox/applets/usage.c:32:
 warning: ignoring return value of ‘write’, declared with attribute
 warn_unused_result
   GEN include/usage_compressed.h
 /bin/sh: applets/usage_compressed: No such file or directory
 make[2]: *** [include/usage_compressed.h] Error 127
 make[1]: *** [applets] Error 2
 make: *** [install] Error 2
 
 I am no build system expert so I was hoping someone else could look into
 this :-)

Does it work if you replace applets/Kbuild with attached file?
--
vda


applets/Kbuild
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen ander...@codepoet.org
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.

obj-y :=
obj-y += applets.o

hostprogs-y:=
hostprogs-y += usage applet_tables

always:= $(hostprogs-y)

# Generated files need additional love

# This trick decreases amount of rebuilds
# if tree is merely renamed/copied
ifeq ($(src),$(obj))
srctree_slash =
else
srctree_slash = $(srctree)/
endif


HOSTCFLAGS_usage.o = -I$(srctree_slash)include

applets/applets.o: include/usage_compressed.h include/applet_tables.h

applets/usage: .config $(srctree_slash)applets/usage_compressed
applets/applet_tables: .config

quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h
  cmd_gen_usage_compressed = $(srctree_slash)applets/usage_compressed 
include/usage_compressed.h applets

include/usage_compressed.h: applets/usage 
$(srctree_slash)applets/usage_compressed
$(call cmd,gen_usage_compressed)

quiet_cmd_gen_applet_tables = GEN include/applet_tables.h
  cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h

include/applet_tables.h: applets/applet_tables
$(call cmd,gen_applet_tables)
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Re: Failing out-of-tree build since r26139

2009-04-19 Thread Bjørn Forsman
2009/4/19 Denys Vlasenko vda.li...@googlemail.com

 On Saturday 18 April 2009 19:15, Bjørn Forsman wrote:
  Hi all,
 
  I have found that BusyBox SVN r26139 (and up to the latest r26151) breaks
  out-of-tree builds. r26138 works. Below is the log of my breaking r26139
  build:
 
  busybox $ make O=../../build/busybox/ install
Using
  /media/raid/bjornfor/documents/dev/os/linux/minibuildroot/src/busybox as
  source for busybox
GEN
 
 /media/raid/bjornfor/documents/dev/os/linux/minibuildroot/build/busybox/Makefile
SPLIT   include/autoconf.h - include/config/*
GEN include/bbconfigopts.h
HOSTCC  applets/usage
 
 /media/raid/bjornfor/documents/dev/os/linux/minibuildroot/src/busybox/applets/usage.c:
  In function ‘main’:
 
 /media/raid/bjornfor/documents/dev/os/linux/minibuildroot/src/busybox/applets/usage.c:32:
  warning: ignoring return value of ‘write’, declared with attribute
  warn_unused_result
GEN include/usage_compressed.h
  /bin/sh: applets/usage_compressed: No such file or directory
  make[2]: *** [include/usage_compressed.h] Error 127
  make[1]: *** [applets] Error 2
  make: *** [install] Error 2
 
  I am no build system expert so I was hoping someone else could look into
  this :-)

 Does it work if you replace applets/Kbuild with attached file?


No, it still fails with the same error.



 --
 vda


 applets/Kbuild

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Re: Failing out-of-tree build since r26139

2009-04-19 Thread Denys Vlasenko
On Sunday 19 April 2009 15:33, Bjørn Forsman wrote:
  /media/raid/bjornfor/documents/dev/os/linux/minibuildroot/src/busybox/applets/usage.c:32:
   warning: ignoring return value of ‘write’, declared with attribute
   warn_unused_result
 GEN include/usage_compressed.h
   /bin/sh: applets/usage_compressed: No such file or directory
   make[2]: *** [include/usage_compressed.h] Error 127
   make[1]: *** [applets] Error 2
   make: *** [install] Error 2
  
   I am no build system expert so I was hoping someone else could look into
   this :-)
 
  Does it work if you replace applets/Kbuild with attached file?
 
 
 No, it still fails with the same error.

Hmm

# This trick decreases amount of rebuilds
# if tree is merely renamed/copied
ifeq ($(src),$(obj))

Can you replace this last line with

ifeq ($(srctree),$(objtree))

and try again?
--
vda



srctree_slash =
else
srctree_slash = $(srctree)/
endif
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Re: Failing out-of-tree build since r26139

2009-04-19 Thread Bjørn Forsman
2009/4/19 Denys Vlasenko vda.li...@googlemail.com

 On Sunday 19 April 2009 15:33, Bjørn Forsman wrote:
  
 /media/raid/bjornfor/documents/dev/os/linux/minibuildroot/src/busybox/applets/usage.c:32:
warning: ignoring return value of ‘write’, declared with attribute
warn_unused_result
  GEN include/usage_compressed.h
/bin/sh: applets/usage_compressed: No such file or directory
make[2]: *** [include/usage_compressed.h] Error 127
make[1]: *** [applets] Error 2
make: *** [install] Error 2
   
I am no build system expert so I was hoping someone else could look
 into
this :-)
  
   Does it work if you replace applets/Kbuild with attached file?
 
 
  No, it still fails with the same error.

 Hmm

 # This trick decreases amount of rebuilds
 # if tree is merely renamed/copied
 ifeq ($(src),$(obj))

 Can you replace this last line with

 ifeq ($(srctree),$(objtree))

 and try again?


Yes, after modifying applets/Kbuild as you suggested, out-of-tree build
works again. Thanks!



 --
 vda



 srctree_slash =
 else
 srctree_slash = $(srctree)/
 endif

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Failing out-of-tree build since r26139

2009-04-18 Thread Bjørn Forsman
Hi all,

I have found that BusyBox SVN r26139 (and up to the latest r26151) breaks
out-of-tree builds. r26138 works. Below is the log of my breaking r26139
build:

busybox $ make O=../../build/busybox/ install
  Using
/media/raid/bjornfor/documents/dev/os/linux/minibuildroot/src/busybox as
source for busybox
  GEN
/media/raid/bjornfor/documents/dev/os/linux/minibuildroot/build/busybox/Makefile
  SPLIT   include/autoconf.h - include/config/*
  GEN include/bbconfigopts.h
  HOSTCC  applets/usage
/media/raid/bjornfor/documents/dev/os/linux/minibuildroot/src/busybox/applets/usage.c:
In function ‘main’:
/media/raid/bjornfor/documents/dev/os/linux/minibuildroot/src/busybox/applets/usage.c:32:
warning: ignoring return value of ‘write’, declared with attribute
warn_unused_result
  GEN include/usage_compressed.h
/bin/sh: applets/usage_compressed: No such file or directory
make[2]: *** [include/usage_compressed.h] Error 127
make[1]: *** [applets] Error 2
make: *** [install] Error 2

I am no build system expert so I was hoping someone else could look into
this :-)

Regards,
Bjørn Forsman
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

RE: Current git tree broke busybox start-stop-daemon

2008-04-22 Thread Joakim Tjernlund
 -Original Message-
 From: Alexey Dobriyan [mailto:[EMAIL PROTECTED]
 Sent: den 16 april 2008 21:47
 To: Al Viro
 Cc: Joakim Tjernlund; [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: Current git tree broke busybox start-stop-daemon
 
 On Wed, Apr 16, 2008 at 08:34:17PM +0100, Al Viro wrote:
  On Wed, Apr 16, 2008 at 11:00:57PM +0400, Alexey Dobriyan wrote:
   On Wed, Apr 16, 2008 at 07:25:02PM +0200, Joakim Tjernlund wrote:
open(/proc/1/stat, O_RDONLY|O_LARGEFILE) = 4
_llseek(4, 0, 0xbfb94898, SEEK_END) = -1 EINVAL (Invalid argument)
  
So it appears that lseek is no longer allowed for /proc/1/stat
Bug or feature?
start-stop-daemon works fine in 2.6.23
  
   That's what happens when switching -llseek method from NULL
   (effectively, default_llseek), to seq_lseek (which rejects SEEK_END).
  
   commit be614086a4aff163d5aa0dc160638d1193b59cde
   commit ee992744ea53db0a90c986fd0a70fbbf91e7f8bd
  
   Al, do you remember why SEEK_END was omitted back then?
 
  Because there's no sane way to implement it?
 
 Ugly -index games, sigh...
 
  Note that original cheerfully
  did nothing, since it had zero -i_size for that file.  Which makes program
  in question very odd - what behaviour does it rely upon?
 
 Busybox just wants to estimate size of a file. And it knows about
 zero-length /proc/*/stat .
 
 libbb/read.c:
 
 void *xmalloc_open_read_close(const char *filename, size_t *sizep)
 {
   char *buf;
   size_t size = sizep ? *sizep : INT_MAX;
   int fd;
   off_t len;
 
   fd = xopen(filename, O_RDONLY);
   /* /proc/N/stat files report len 0 here */
   /* In order to make such files readable, we add small const */
   len = xlseek(fd, 0, SEEK_END) | 0x3ff; /* + up to 1k */
   ...

So maybe bb should change to fstat() instead? But it would be nice if
you could restore the old behavior for one or two releases so bb has a can
catch up.

   Jocke


___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox


Re: start-stop-daemon broke on linus tree

2008-04-17 Thread Joakim Tjernlund

On Thu, 2008-04-17 at 03:40 +0200, Denys Vlasenko wrote:
 On Thursday 17 April 2008 00:47, Joakim Tjernlund wrote:
   -Original Message-
   From: Denys Vlasenko [mailto:[EMAIL PROTECTED]
   Sent: den 16 april 2008 20:47
   To: busybox@busybox.net; [EMAIL PROTECTED]
   Subject: Re: start-stop-daemon broke on linus tree
   
   On Wednesday 16 April 2008 19:56, Joakim Tjernlund wrote:
Just sent this to the kernel list, figured you might want a copy too,
see last in this mail. One more note, stracing
 strace -s 120 start-stop-daemon --stop --exec 
/opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbear
shows alot of
 readlink(/proc/371/exe, 
/opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit, 49) = 49
 readlink(/proc/373/exe, 
/opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit, 49) = 49
 readlink(/proc/375/exe, 
/opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit, 49) = 49
 readlink(/proc/411/exe, 
/opt/appl/cuappl02a-r11a-080416jt2/bin/dropbearmu, 49) = 49
   
49 bytes seems a little short, we have longer path names than 49 bytes.
   
   Not really. strlen(/opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbear) = 
   48.
   We can safely read 48+1 byte only if we only want to know whether it is
   equal to that or not:
  
  I also noticed that readlink(/proc/411/exe,..) returns the real file name 
  so
  the start-stop-daemon command above won't work when 
  /opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbear is a symlink pointing to
  /opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbearmulti
 
 start-stop-daemon have serious design problems, judging by the amount
 of people complaining about it not doing that and not doing this.
 
 Fixing one issue makes something else break.
 
 Why you guys wouldn't try something more sensible, like runsvdir?

Legacy, got a system that has years on its neck in the field.

Now that 2.6.25 is out with the changed lseek behaviour I wonder if
there is a bb solution in sight? Perhaps fstat() would do?

  Jocke
___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox


Re: start-stop-daemon broke on linus tree

2008-04-17 Thread Joakim Tjernlund

On Thu, 2008-04-17 at 13:37 +0200, Joakim Tjernlund wrote:
 On Thu, 2008-04-17 at 03:40 +0200, Denys Vlasenko wrote:
  On Thursday 17 April 2008 00:47, Joakim Tjernlund wrote:
-Original Message-
From: Denys Vlasenko [mailto:[EMAIL PROTECTED]
Sent: den 16 april 2008 20:47
To: busybox@busybox.net; [EMAIL PROTECTED]
Subject: Re: start-stop-daemon broke on linus tree

On Wednesday 16 April 2008 19:56, Joakim Tjernlund wrote:
 Just sent this to the kernel list, figured you might want a copy too,
 see last in this mail. One more note, stracing
  strace -s 120 start-stop-daemon --stop --exec 
 /opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbear
 shows alot of
  readlink(/proc/371/exe, 
 /opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit, 49) = 49
  readlink(/proc/373/exe, 
 /opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit, 49) = 49
  readlink(/proc/375/exe, 
 /opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit, 49) = 49
  readlink(/proc/411/exe, 
 /opt/appl/cuappl02a-r11a-080416jt2/bin/dropbearmu, 49) = 49

 49 bytes seems a little short, we have longer path names than 49 
 bytes.

Not really. strlen(/opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbear) 
= 48.
We can safely read 48+1 byte only if we only want to know whether it is
equal to that or not:
   
   I also noticed that readlink(/proc/411/exe,..) returns the real file 
   name so
   the start-stop-daemon command above won't work when 
   /opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbear is a symlink pointing to
   /opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbearmulti
  
  start-stop-daemon have serious design problems, judging by the amount
  of people complaining about it not doing that and not doing this.
  
  Fixing one issue makes something else break.
  
  Why you guys wouldn't try something more sensible, like runsvdir?
 
 Legacy, got a system that has years on its neck in the field.
 
 Now that 2.6.25 is out with the changed lseek behaviour I wonder if
 there is a bb solution in sight? Perhaps fstat() would do?
 
   Jocke

The patch I just sent will also solve the lseek problem on 2.6.25

 Jocke
___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox


Re: start-stop-daemon broke on linus tree

2008-04-16 Thread Denys Vlasenko
On Wednesday 16 April 2008 19:56, Joakim Tjernlund wrote:
 Just sent this to the kernel list, figured you might want a copy too,
 see last in this mail. One more note, stracing
  strace -s 120 start-stop-daemon --stop --exec 
 /opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbear
 shows alot of
  readlink(/proc/371/exe, 
 /opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit, 49) = 49
  readlink(/proc/373/exe, 
 /opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit, 49) = 49
  readlink(/proc/375/exe, 
 /opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit, 49) = 49
  readlink(/proc/411/exe, 
 /opt/appl/cuappl02a-r11a-080416jt2/bin/dropbearmu, 49) = 49
 
 49 bytes seems a little short, we have longer path names than 49 bytes.

Not really. strlen(/opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbear) = 48.
We can safely read 48+1 byte only if we only want to know whether it is
equal to that or not:

static int pid_is_exec(pid_t pid, const char *name)
{
char buf[sizeof(/proc//exe) + sizeof(int)*3];
char *execbuf;
int n;

sprintf(buf, /proc/%u/exe, pid);
n = strlen(name) + 1;
execbuf = xzalloc(n + 1);
readlink(buf, execbuf, n);
/* if readlink fails because link target is longer than strlen(name),
 * execbuf still contains , and strcmp will return !0. */
n = strcmp(execbuf, name);
if (ENABLE_FEATURE_CLEAN_UP)
free(execbuf);
return !n; /* nonzero (true) if execbuf == name */
}

 
 -- Kernel list mail ---
 
 [EMAIL PROTECTED]:~# start-stop-daemon --stop --name eq_ppp_mgr
 start-stop-daemon: lseek: Invalid argument
 
 [EMAIL PROTECTED]:~# strace start-stop-daemon --stop --name eq_ppp_mgr
 execve(/sbin/start-stop-daemon, [start-stop-daemon, --stop, --name, 
 eq_ppp_mgr], [/* 12 vars */]) = 0
 uname({sys=Linux, node=localhost.localdomain, ...}) = 0
 brk(0)  = 0x1007c000
 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
 0x48017000
 access(/etc/ld.so.preload, R_OK)  = -1 ENOENT (No such file or 
 directory)
 open(/opt/appl/executing/lib/tls/ppc603/libc.so.6, O_RDONLY) = -1 ENOENT 
 (No such file or directory)
 stat64(/opt/appl/executing/lib/tls/ppc603, 0xbfb940a0) = -1 ENOENT (No such 
 file or directory)
 open(/opt/appl/executing/lib/tls/libc.so.6, O_RDONLY) = -1 ENOENT (No such 
 file or directory)
 stat64(/opt/appl/executing/lib/tls, 0xbfb940a0) = -1 ENOENT (No such file 
 or directory)
 open(/opt/appl/executing/lib/ppc603/libc.so.6, O_RDONLY) = -1 ENOENT (No 
 such file or directory)
 stat64(/opt/appl/executing/lib/ppc603, 0xbfb940a0) = -1 ENOENT (No such 
 file or directory)
 open(/opt/appl/executing/lib/libc.so.6, O_RDONLY) = -1 ENOENT (No such file 
 or directory)
 stat64(/opt/appl/executing/lib, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
 open(/opt/appl/started/lib/tls/ppc603/libc.so.6, O_RDONLY) = -1 ENOENT (No 
 such file or directory)
 stat64(/opt/appl/started/lib/tls/ppc603, 0xbfb940a0) = -1 ENOENT (No such 
 file or directory)
 open(/opt/appl/started/lib/tls/libc.so.6, O_RDONLY) = -1 ENOENT (No such 
 file or directory)
 stat64(/opt/appl/started/lib/tls, 0xbfb940a0) = -1 ENOENT (No such file or 
 directory)
 open(/opt/appl/started/lib/ppc603/libc.so.6, O_RDONLY) = -1 ENOENT (No such 
 file or directory)
 stat64(/opt/appl/started/lib/ppc603, 0xbfb940a0) = -1 ENOENT (No such file 
 or directory)
 open(/opt/appl/started/lib/libc.so.6, O_RDONLY) = -1 ENOENT (No such file 
 or directory)
 stat64(/opt/appl/started/lib, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
 open(/opt/appl/next/lib/tls/ppc603/libc.so.6, O_RDONLY) = -1 ENOENT (No 
 such file or directory)
 stat64(/opt/appl/next/lib/tls/ppc603, 0xbfb940a0) = -1 ENOENT (No such file 
 or directory)
 open(/opt/appl/next/lib/tls/libc.so.6, O_RDONLY) = -1 ENOENT (No such file 
 or directory)
 stat64(/opt/appl/next/lib/tls, 0xbfb940a0) = -1 ENOENT (No such file or 
 directory)
 open(/opt/appl/next/lib/ppc603/libc.so.6, O_RDONLY) = -1 ENOENT (No such 
 file or directory)
 stat64(/opt/appl/next/lib/ppc603, 0xbfb940a0) = -1 ENOENT (No such file or 
 directory)
 open(/opt/appl/next/lib/libc.so.6, O_RDONLY) = -1 ENOENT (No such file or 
 directory)
 stat64(/opt/appl/next/lib, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
 open(/etc/ld.so.cache, O_RDONLY)  = 3
 fstat64(3, {st_mode=S_IFREG|0644, st_size=64, ...}) = 0
 mmap(NULL, 64, PROT_READ, MAP_PRIVATE, 3, 0) = 0x48018000
 close(3)= 0
 open(/lib/tls/ppc603/libc.so.6, O_RDONLY) = -1 ENOENT (No such file or 
 directory)
 stat64(/lib/tls/ppc603, 0xbfb940a0)   = -1 ENOENT (No such file or 
 directory)
 open(/lib/tls/libc.so.6, O_RDONLY)= -1 ENOENT (No such file or 
 directory)
 stat64(/lib/tls, 0xbfb940a0)  = -1 ENOENT (No such file or 
 directory)
 open(/lib/ppc603/libc.so.6, O_RDONLY) = -1 ENOENT (No such file or 
 directory)
 stat64(/lib/ppc603, 0xbfb940a0)   = -1 ENOENT (No such file or 
 directory)
 

RE: start-stop-daemon broke on linus tree

2008-04-16 Thread Joakim Tjernlund
 -Original Message-
 From: Denys Vlasenko [mailto:[EMAIL PROTECTED]
 Sent: den 16 april 2008 20:47
 To: busybox@busybox.net; [EMAIL PROTECTED]
 Subject: Re: start-stop-daemon broke on linus tree
 
 On Wednesday 16 April 2008 19:56, Joakim Tjernlund wrote:
  Just sent this to the kernel list, figured you might want a copy too,
  see last in this mail. One more note, stracing
   strace -s 120 start-stop-daemon --stop --exec 
  /opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbear
  shows alot of
   readlink(/proc/371/exe, 
  /opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit, 49) = 49
   readlink(/proc/373/exe, 
  /opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit, 49) = 49
   readlink(/proc/375/exe, 
  /opt/appl/cuappl02a-r11a-080416jt2/bin/eq_monolit, 49) = 49
   readlink(/proc/411/exe, 
  /opt/appl/cuappl02a-r11a-080416jt2/bin/dropbearmu, 49) = 49
 
  49 bytes seems a little short, we have longer path names than 49 bytes.
 
 Not really. strlen(/opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbear) = 48.
 We can safely read 48+1 byte only if we only want to know whether it is
 equal to that or not:

I also noticed that readlink(/proc/411/exe,..) returns the real file name so
the start-stop-daemon command above won't work when 
/opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbear is a symlink pointing to
/opt/appl/cuappl02a-r11a-080416jt2/sbin/dropbearmulti

 Jocke

___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox