e2fsprogs: Disable elf shared library when BR2_PREFER_STATIC_LIB is selected.
PATCH 1/1 e2fsprogs: Disable elf shared library when BR2_PREFER_STATIC_LIB is selected.
From: Sonic Zhang <[email protected]>
--- package/e2fsprogs/e2fsprogs.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
package/e2fsprogs/e2fsprogs.mk +1 -1
@@ -11,7 +11,7 @@ E2FSPROGS_LICENSE_FILES = COPYING lib/uuid/COPYING lib/ss/mit-sipb-copyright.h l E2FSPROGS_CONF_OPT = \ --disable-tls \ - --enable-elf-shlibs \ + $(if $(BR2_PREFER_STATIC_LIB),,--enable-elf-shlibs) \ $(if $(BR2_PACKAGE_E2FSPROGS_DEBUGFS),,--disable-debugfs) \ $(if $(BR2_PACKAGE_E2FSPROGS_E2IMAGE),,--disable-imager) \ $(if $(BR2_PACKAGE_E2FSPROGS_E4DEFRAG),,--disable-defrag) \
Signature · 1 line
1.8.2.3
PATCH 1/3 e2fsprogs: nommu: Add patch to use vfork in nommu arch.
From: Sonic Zhang <[email protected]>
--- package/e2fsprogs/e2fsprogs-nommu.patch | 231 ++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 package/e2fsprogs/e2fsprogs-nommu.patch
package/e2fsprogs/e2fsprogs-nommu.patch new file +231 -0
@@ -0,0 +1,231 @@ +--- e2fsprogs-1.42.4/e2fsck/logfile.c 2012-05-29 09:29:48.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/e2fsck/logfile.c 2012-09-24 17:49:18.878104451 +0800 +@@ -220,7 +220,11 @@ + exit(1); + } + ++#ifndef HAVE_FORK ++ pid = vfork(); ++#else + pid = fork(); ++#endif + if (pid < 0) { + perror("fork"); + exit(1); +@@ -264,7 +268,11 @@ + outbufsize -= c; + cp += c; + } ++#ifndef HAVE_FORK ++ _exit(0); ++#else + exit(0); ++#endif + } + + close(fds[0]); +--- e2fsprogs-1.42.4/lib/ss/pager.c 2012-03-19 02:18:33.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/lib/ss/pager.c 2012-09-24 17:54:33.862356418 +0800 +@@ -79,7 +79,11 @@ + if (pipe(filedes) != 0) + return(-1); + ++#ifndef HAVE_FORK ++ switch(vfork()) { ++#else + switch(fork()) { ++#endif + case -1: + return(-1); + case 0: +--- e2fsprogs-1.42.4/lib/ss/help.c 2012-03-19 02:18:33.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/lib/ss/help.c 2012-09-24 17:55:00.326105930 +0800 +@@ -107,7 +107,11 @@ + free(buf); + return; + } ++#ifndef HAVE_FORK ++ switch (child = vfork()) { ++#else + switch (child = fork()) { ++#endif + case -1: + ss_perror(sci_idx, errno, "Can't fork for pager"); + return; +--- e2fsprogs-1.42.4/lib/fpopen.c 2012-03-19 02:18:33.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/lib/fpopen.c 2012-09-24 17:55:54.050106645 +0800 +@@ -94,7 +94,11 @@ + return NULL; + + /* Fork and execute the correct program. */ ++#ifndef HAVE_FORK ++ if ((pid = vfork()) < 0) { ++#else + if ((pid = fork()) < 0) { ++#endif + perror("fork"); + return NULL; + } else if (pid == 0) { +@@ -109,7 +113,11 @@ + } + (void) execvp(prog, argv); + perror(prog); ++#ifndef HAVE_FORK ++ _exit(1); ++#else + exit(1); ++#endif + } + return fdopen(do_stdin ? fds[1] : fds[0], mode); + } +--- e2fsprogs-1.42.4/lib/uuid/gen_uuid.c 2012-03-19 02:18:33.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/lib/uuid/gen_uuid.c 2012-09-24 17:56:41.186106057 +0800 +@@ -504,11 +504,19 @@ + if (access_ret == 0 && (st.st_mode & (S_ISUID | S_ISGID)) == 0) + access_ret = access(UUIDD_DIR, W_OK); + if (access_ret == 0 && start_attempts++ < 5) { ++#ifndef HAVE_FORK ++ if ((pid = vfork()) == 0) { ++#else + if ((pid = fork()) == 0) { ++#endif + close_all_fds(); + execl(uuidd_path, "uuidd", "-qT", "300", + (char *) NULL); ++#ifndef HAVE_FORK ++ _exit(1); ++#else + exit(1); ++#endif + } + (void) waitpid(pid, 0, 0); + if (connect(s, (const struct sockaddr *) &srv_addr, +--- e2fsprogs-1.42.4/misc/uuidd.c 2012-03-19 02:18:33.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/misc/uuidd.c 2012-09-24 17:57:49.630106531 +0800 +@@ -56,7 +56,11 @@ + static void die(const char *msg) + { + perror(msg); ++#ifndef HAVE_FORK ++ _exit(1); ++#else + exit(1); ++#endif + } + + static void create_daemon(void) +@@ -64,7 +68,11 @@ + pid_t pid; + uid_t euid; + ++#ifndef HAVE_FORK ++ pid = vfork(); ++#else + pid = fork(); ++#endif + if (pid == -1) { + perror("fork"); + exit(1); +--- e2fsprogs-1.42.4/misc/fsck.c 2012-04-27 06:44:12.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/misc/fsck.c 2012-09-24 17:52:49.297070304 +0800 +@@ -491,7 +491,11 @@ + /* Fork and execute the correct program. */ + if (noexecute) + pid = -1; ++#ifndef HAVE_FORK ++ else if ((pid = vfork()) < 0) { ++#else + else if ((pid = fork()) < 0) { ++#endif + perror("fork"); + free(inst); + return errno; +@@ -501,7 +505,11 @@ + (void) execv(s, argv); + perror(argv[0]); + free(inst); ++#ifndef HAVE_FORK ++ _exit(EXIT_ERROR); ++#else + exit(EXIT_ERROR); ++#endif + } + + for (i=0; i < argc; i++) +@@ -641,10 +649,18 @@ + * time to set up the signal handler + */ + if (inst2->start_time < time(0)+2) { ++#ifndef HAVE_FORK ++ if (vfork() == 0) { ++#else + if (fork() == 0) { ++#endif + sleep(1); + kill(inst2->pid, SIGUSR1); ++#ifndef HAVE_FORK ++ _exit(0); ++#else + exit(0); ++#endif + } + } else + kill(inst2->pid, SIGUSR1); +--- e2fsprogs-1.42.4/misc/logsave.c 2012-03-19 02:18:33.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/misc/logsave.c 2012-09-24 17:51:18.062105881 +0800 +@@ -181,7 +181,11 @@ + #endif + #endif + ++#ifndef HAVE_FORK ++ pid = vfork(); ++#else + pid = fork(); ++#endif + if (pid < 0) { + perror("vfork"); + exit(1); +@@ -193,7 +197,11 @@ + + execvp(argv[0], argv); + perror(argv[0]); ++#ifndef HAVE_FORK ++ _exit(1); ++#else + exit(1); ++#endif + } + child_pid = pid; + close(fds[1]); +@@ -307,7 +315,11 @@ + send_output("----------------\n", 0, send_flag); + + if (outbuf) { ++#ifndef HAVE_FORK ++ pid = vfork(); ++#else + pid = fork(); ++#endif + if (pid < 0) { + perror("fork"); + exit(1); +@@ -329,5 +341,9 @@ + if (outfd >= 0) + close(outfd); + ++#ifndef HAVE_FORK ++ _exit(rc); ++#else + exit(rc); ++#endif + } +--- e2fsprogs-1.42.8/configure.in.old 2013-11-11 15:31:35.626098053 +0800 ++++ e2fsprogs-1.42.8/configure.in 2013-11-11 15:31:08.652956982 +0800 +@@ -1020,6 +1020,7 @@ + fallocate64 + fchown + fdatasync ++ fork + fstat64 + ftruncate64 + getdtablesize
Signature · 1 line
1.8.2.3
PATCH 1/3 e2fsprogs: nommu: Add patch to use vfork in nommu arch.
Hi Sonic,
package/e2fsprogs/e2fsprogs-nommu.patch
Quoted 13 lines · On Fri, Nov 15, 2013 at 9:31 AM, <[email protected]> wrote:
From: Sonic Zhang <[email protected]>
Signed-off-by Sonic Zhang <[email protected]>--- package/e2fsprogs/e2fsprogs-nommu.patch | 231 ++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 package/e2fsprogs/e2fsprogs-nommu.patchpackage/e2fsprogs/e2fsprogs-nommu.patch new file +0
-0
The patch itself should also contain a description and a signed-off-by line...
Additionally, patches should be named <pkg>-<number>-<description>.patch, so for example:
e2fsprogs-0001-add-nommu-support.patch
Best regards,
Thomas
PATCH 1/3 e2fsprogs: nommu: Add patch to use vfork in nommu arch.
In reply to sonic.adi at gmail.comHi Sonic,
Again, it doesn't look like these fork replacements will work...
Quoted 15 lines · sonic.adi at gmail.com
From: Sonic Zhang <[email protected]>
Signed-off-by Sonic Zhang <[email protected]>--- package/e2fsprogs/e2fsprogs-nommu.patch | 231 ++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+)create mode 100644
package/e2fsprogs/e2fsprogs-nommu.patchpackage/e2fsprogs/e2fsprogs-nommu.patch new file +1
-0@@ -0,0 +1,231 @@ +--- e2fsprogs-1.42.4/e2fsck/logfile.c 2012-05-29 09:29:48.000000000 +0800
package/e2fsprogs/e2fsprogs-nommu.patch line 11
Quoted 10 lines
package/e2fsprogs/e2fsprogs-nommu.patch new file +10
-0++++ e2fsprogs-1.42.4.nommu/e2fsck/logfile.c 2012-09-24 17:49:18.878104451 +0800 +@@ -220,7 +220,11 @@ + exit(1); + } + ++#ifndef HAVE_FORK ++ pid = vfork(); ++#else + pid = fork(); ++#endif
This one creates a child process that will read from an fd that is
written by its parent, so I don't think this will work (parent is suspended until child exec's or exits). However, because of the call to daemon() in-between, it might work. Have you tested it?
Quoted 104 lines
package/e2fsprogs/e2fsprogs-nommu.patch new file +104
-0+ if (pid < 0) { + perror("fork"); + exit(1); +@@ -264,7 +268,11 @@ + outbufsize -= c; + cp += c; + } ++#ifndef HAVE_FORK ++ _exit(0); ++#else + exit(0); ++#endif + } + + close(fds[0]); +--- e2fsprogs-1.42.4/lib/ss/pager.c 2012-03-19 02:18:33.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/lib/ss/pager.c 2012-09-24 17:54:33.862356418 +0800 +@@ -79,7 +79,11 @@ + if (pipe(filedes) != 0) + return(-1); + ++#ifndef HAVE_FORK ++ switch(vfork()) { ++#else + switch(fork()) { ++#endif + case -1: + return(-1); + case 0: +--- e2fsprogs-1.42.4/lib/ss/help.c 2012-03-19 02:18:33.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/lib/ss/help.c 2012-09-24 17:55:00.326105930 +0800 +@@ -107,7 +107,11 @@ + free(buf); + return; + } ++#ifndef HAVE_FORK ++ switch (child = vfork()) { ++#else + switch (child = fork()) { ++#endif + case -1: + ss_perror(sci_idx, errno, "Can't fork for pager"); + return; +--- e2fsprogs-1.42.4/lib/fpopen.c 2012-03-19 02:18:33.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/lib/fpopen.c 2012-09-24 17:55:54.050106645 +0800 +@@ -94,7 +94,11 @@ + return NULL; + + /* Fork and execute the correct program. */ ++#ifndef HAVE_FORK ++ if ((pid = vfork()) < 0) { ++#else + if ((pid = fork()) < 0) { ++#endif + perror("fork"); + return NULL; + } else if (pid == 0) { +@@ -109,7 +113,11 @@ + } + (void) execvp(prog, argv); + perror(prog); ++#ifndef HAVE_FORK ++ _exit(1); ++#else + exit(1); ++#endif + } + return fdopen(do_stdin ? fds[1] : fds[0], mode); + } +--- e2fsprogs-1.42.4/lib/uuid/gen_uuid.c 2012-03-19 02:18:33.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/lib/uuid/gen_uuid.c 2012-09-24 17:56:41.186106057 +0800 +@@ -504,11 +504,19 @@ + if (access_ret == 0 && (st.st_mode & (S_ISUID | S_ISGID)) == 0) + access_ret = access(UUIDD_DIR, W_OK); + if (access_ret == 0 && start_attempts++ < 5) { ++#ifndef HAVE_FORK ++ if ((pid = vfork()) == 0) { ++#else + if ((pid = fork()) == 0) { ++#endif + close_all_fds(); + execl(uuidd_path, "uuidd", "-qT", "300", + (char *) NULL); ++#ifndef HAVE_FORK ++ _exit(1); ++#else + exit(1); ++#endif + } + (void) waitpid(pid, 0, 0); + if (connect(s, (const struct sockaddr *) &srv_addr, +--- e2fsprogs-1.42.4/misc/uuidd.c 2012-03-19 02:18:33.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/misc/uuidd.c 2012-09-24 17:57:49.630106531 +0800 +@@ -56,7 +56,11 @@ + static void die(const char *msg) + { + perror(msg); ++#ifndef HAVE_FORK ++ _exit(1); ++#else + exit(1); ++#endif + } +
package/e2fsprogs/e2fsprogs-nommu.patch line 125
Quoted 10 lines
package/e2fsprogs/e2fsprogs-nommu.patch new file +10
-0+ static void create_daemon(void) +@@ -64,7 +68,11 @@ + pid_t pid; + uid_t euid; + ++#ifndef HAVE_FORK ++ pid = vfork(); ++#else + pid = fork(); ++#endif
This looks like a home-grown implementation of daemon() - why didn't
T.T'so just you daemon()? Anyway, it probably won't work because the child returns from the function, thereby corrupting the parent's stack frame. It may work accidentally, though.
Quoted 35 lines
package/e2fsprogs/e2fsprogs-nommu.patch new file +35
-0+ if (pid == -1) { + perror("fork"); + exit(1); +--- e2fsprogs-1.42.4/misc/fsck.c 2012-04-27 06:44:12.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/misc/fsck.c 2012-09-24 17:52:49.297070304 +0800 +@@ -491,7 +491,11 @@ + /* Fork and execute the correct program. */ + if (noexecute) + pid = -1; ++#ifndef HAVE_FORK ++ else if ((pid = vfork()) < 0) { ++#else + else if ((pid = fork()) < 0) { ++#endif + perror("fork"); + free(inst); + return errno; +@@ -501,7 +505,11 @@ + (void) execv(s, argv); + perror(argv[0]); + free(inst); ++#ifndef HAVE_FORK ++ _exit(EXIT_ERROR); ++#else + exit(EXIT_ERROR); ++#endif + } + + for (i=0; i < argc; i++) +@@ -641,10 +649,18 @@ + * time to set up the signal handler + */ + if (inst2->start_time < time(0)+2) { ++#ifndef HAVE_FORK ++ if (vfork() == 0) {
package/e2fsprogs/e2fsprogs-nommu.patch line 170
Quoted 10 lines
package/e2fsprogs/e2fsprogs-nommu.patch new file +10
-0++#else + if (fork() == 0) { ++#endif + sleep(1); + kill(inst2->pid, SIGUSR1); ++#ifndef HAVE_FORK ++ _exit(0); ++#else + exit(0); ++#endif
Hm, this looks like cut and paste code from util-linux, where I
commented on a better way to implement this.
Quoted 28 lines
package/e2fsprogs/e2fsprogs-nommu.patch new file +28
-0+ } + } else + kill(inst2->pid, SIGUSR1); +--- e2fsprogs-1.42.4/misc/logsave.c 2012-03-19 02:18:33.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/misc/logsave.c 2012-09-24 17:51:18.062105881 +0800 +@@ -181,7 +181,11 @@ + #endif + #endif + ++#ifndef HAVE_FORK ++ pid = vfork(); ++#else + pid = fork(); ++#endif + if (pid < 0) { + perror("vfork"); + exit(1); +@@ -193,7 +197,11 @@ + + execvp(argv[0], argv); + perror(argv[0]); ++#ifndef HAVE_FORK ++ _exit(1); ++#else + exit(1); ++#endif + } + child_pid = pid;
package/e2fsprogs/e2fsprogs-nommu.patch line 208
Quoted 10 lines
package/e2fsprogs/e2fsprogs-nommu.patch new file +10
-0+ close(fds[1]); +@@ -307,7 +315,11 @@ + send_output("----------------\n", 0, send_flag); + + if (outbuf) { ++#ifndef HAVE_FORK ++ pid = vfork(); ++#else + pid = fork(); ++#endif
The idea here is to background the process, but vfork doesn't actually
background so you could just as well skip it completely. Or use daemon(1,1).
Regards,
Arnout
Quoted 24 lines
package/e2fsprogs/e2fsprogs-nommu.patch new file +23
-0+ if (pid < 0) { + perror("fork"); + exit(1); +@@ -329,5 +341,9 @@ + if (outfd >= 0) + close(outfd); + ++#ifndef HAVE_FORK ++ _exit(rc); ++#else + exit(rc); ++#endif + } +--- e2fsprogs-1.42.8/configure.in.old 2013-11-11 15:31:35.626098053 +0800 ++++ e2fsprogs-1.42.8/configure.in 2013-11-11 15:31:08.652956982 +0800 +@@ -1020,6 +1020,7 @@ + fallocate64 + fchown + fdatasync ++ fork + fstat64 + ftruncate64 + getdtablesize
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
PATCH 1/3 e2fsprogs: nommu: Add patch to use vfork in nommu arch.
Sonic,
Quoted 1 line · Arnout Vandecappelle
Again, it doesn't look like these fork replacements will work...
I'd like to maybe give more details about this. What we are concerned about is that the noMMU patches you are doing seem to simply be patches that replace every invocation of fork() by vfork(), just for the sake of making things build. But they should not only build, but also work :)
However, vfork() clearly doesn't have the same implications and constraints as fork(), so each replacement of fork() by vfork() need a careful study and analysis, with a proper justification as to why it is actually possible. Ideally, such patches should go upstream, and therefore really be working patches.
So I think what would be good is probably to require something like a comment on top of each fork -> vfork replacement that justifies why it is possible, like:
/* * This is what happens, and which allows us to simply replace * fork() by vfork(). Some more details here... */ #ifdef HAVE_FORK p = fork(); #else p = vfork();
#endif
Or, even better: instead of sending patches to Buildroot, simply send them upstream. So upstream can study them, give feedback on fork() vs. vfork() usage. Once a patch is upstream, it can get accepted immediately into Buildroot, since we know upstream has accepted it, and it will be part of the next upstream release.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 2/3 e2fsprogs: flat: Add patch to append uuid link flag after the blkid link flags when checking the blkid library in the FLAT binary mode.
In reply to sonic.adi at gmail.comFrom: Sonic Zhang <[email protected]>
--- package/e2fsprogs/e2fsprogs-flat.patch | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 package/e2fsprogs/e2fsprogs-flat.patch
package/e2fsprogs/e2fsprogs-flat.patch new file +12 -0
@@ -0,0 +1,12 @@ +--- e2fsprogs-1.42.4/configure 2012-05-29 09:29:48.000000000 +0800 ++++ e2fsprogs-1.42.4.nommu/configure 2012-09-25 11:28:39.822106303 +0800 +@@ -5039,6 +5039,9 @@ + else + ac_check_lib_save_LIBS=$LIBS + LIBS="-lblkid $LIBBLKID $LIBS" ++if test "x$ac_cv_lib_uuid_uuid_generate" = x""yes; then ++ LIBS="$LIBS -luuid" ++fi + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +
Signature · 1 line
1.8.2.3
PATCH 2/3 e2fsprogs: flat: Add patch to append uuid link flag after the blkid link flags when checking the blkid library in the FLAT binary mode.
Quoted 8 lines · On Fri, Nov 15, 2013 at 9:31 AM, <[email protected]> wrote:
From: Sonic Zhang <[email protected]>
Signed-off-by Sonic Zhang <[email protected]>--- package/e2fsprogs/e2fsprogs-flat.patch | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 package/e2fsprogs/e2fsprogs-flat.patch
Same comment on the naming of the patch and the patch header.
Best regards,
Thomas
PATCH 3/3 e2fsprogs: Disable elf shared library when BR2_PREFER_STATIC_LIB is selected.
In reply to sonic.adi at gmail.comFrom: Sonic Zhang <[email protected]>
--- package/e2fsprogs/e2fsprogs.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
package/e2fsprogs/e2fsprogs.mk +1 -1
@@ -11,7 +11,7 @@ E2FSPROGS_LICENSE_FILES = COPYING lib/uuid/COPYING lib/ss/mit-sipb-copyright.h l E2FSPROGS_CONF_OPT = \ --disable-tls \ - --enable-elf-shlibs \ + $(if $(BR2_PREFER_STATIC_LIB),,--enable-elf-shlibs) \ $(if $(BR2_PACKAGE_E2FSPROGS_DEBUGFS),,--disable-debugfs) \ $(if $(BR2_PACKAGE_E2FSPROGS_E2IMAGE),,--disable-imager) \ $(if $(BR2_PACKAGE_E2FSPROGS_E4DEFRAG),,--disable-defrag) \
Signature · 1 line
1.8.2.3