* [Buildroot] [PATCH] e2fsprogs: Disable elf shared library when BR2_PREFER_STATIC_LIB is selected.
@ 2013-11-15 8:31 sonic.adi at gmail.com
2013-11-15 8:31 ` [Buildroot] [PATCH 1/3] e2fsprogs: nommu: Add patch to use vfork in nommu arch sonic.adi at gmail.com
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: sonic.adi at gmail.com @ 2013-11-15 8:31 UTC (permalink / raw)
To: buildroot
From: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
package/e2fsprogs/e2fsprogs.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package/e2fsprogs/e2fsprogs.mk b/package/e2fsprogs/e2fsprogs.mk
index 0670c74..cdca906 100644
--- a/package/e2fsprogs/e2fsprogs.mk
+++ b/package/e2fsprogs/e2fsprogs.mk
@@ -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) \
--
1.8.2.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 1/3] e2fsprogs: nommu: Add patch to use vfork in nommu arch.
2013-11-15 8:31 [Buildroot] [PATCH] e2fsprogs: Disable elf shared library when BR2_PREFER_STATIC_LIB is selected sonic.adi at gmail.com
@ 2013-11-15 8:31 ` sonic.adi at gmail.com
2013-11-15 8:40 ` Thomas De Schampheleire
2013-11-16 0:59 ` Arnout Vandecappelle
2013-11-15 8:31 ` [Buildroot] [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 sonic.adi at gmail.com
2013-11-15 8:31 ` [Buildroot] [PATCH 3/3] e2fsprogs: Disable elf shared library when BR2_PREFER_STATIC_LIB is selected sonic.adi at gmail.com
2 siblings, 2 replies; 8+ messages in thread
From: sonic.adi at gmail.com @ 2013-11-15 8:31 UTC (permalink / raw)
To: buildroot
From: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
package/e2fsprogs/e2fsprogs-nommu.patch | 231 ++++++++++++++++++++++++++++++++
1 file changed, 231 insertions(+)
create mode 100644 package/e2fsprogs/e2fsprogs-nommu.patch
diff --git a/package/e2fsprogs/e2fsprogs-nommu.patch b/package/e2fsprogs/e2fsprogs-nommu.patch
new file mode 100644
index 0000000..6aef365
--- /dev/null
+++ b/package/e2fsprogs/e2fsprogs-nommu.patch
@@ -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
--
1.8.2.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Buildroot] [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.
2013-11-15 8:31 [Buildroot] [PATCH] e2fsprogs: Disable elf shared library when BR2_PREFER_STATIC_LIB is selected sonic.adi at gmail.com
2013-11-15 8:31 ` [Buildroot] [PATCH 1/3] e2fsprogs: nommu: Add patch to use vfork in nommu arch sonic.adi at gmail.com
@ 2013-11-15 8:31 ` sonic.adi at gmail.com
2013-11-15 8:56 ` Thomas De Schampheleire
2013-11-15 8:31 ` [Buildroot] [PATCH 3/3] e2fsprogs: Disable elf shared library when BR2_PREFER_STATIC_LIB is selected sonic.adi at gmail.com
2 siblings, 1 reply; 8+ messages in thread
From: sonic.adi at gmail.com @ 2013-11-15 8:31 UTC (permalink / raw)
To: buildroot
From: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
package/e2fsprogs/e2fsprogs-flat.patch | 12 ++++++++++++
1 file changed, 12 insertions(+)
create mode 100644 package/e2fsprogs/e2fsprogs-flat.patch
diff --git a/package/e2fsprogs/e2fsprogs-flat.patch b/package/e2fsprogs/e2fsprogs-flat.patch
new file mode 100644
index 0000000..5abd696
--- /dev/null
+++ b/package/e2fsprogs/e2fsprogs-flat.patch
@@ -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. */
+
--
1.8.2.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 3/3] e2fsprogs: Disable elf shared library when BR2_PREFER_STATIC_LIB is selected.
2013-11-15 8:31 [Buildroot] [PATCH] e2fsprogs: Disable elf shared library when BR2_PREFER_STATIC_LIB is selected sonic.adi at gmail.com
2013-11-15 8:31 ` [Buildroot] [PATCH 1/3] e2fsprogs: nommu: Add patch to use vfork in nommu arch sonic.adi at gmail.com
2013-11-15 8:31 ` [Buildroot] [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 sonic.adi at gmail.com
@ 2013-11-15 8:31 ` sonic.adi at gmail.com
2 siblings, 0 replies; 8+ messages in thread
From: sonic.adi at gmail.com @ 2013-11-15 8:31 UTC (permalink / raw)
To: buildroot
From: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
package/e2fsprogs/e2fsprogs.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package/e2fsprogs/e2fsprogs.mk b/package/e2fsprogs/e2fsprogs.mk
index 0670c74..cdca906 100644
--- a/package/e2fsprogs/e2fsprogs.mk
+++ b/package/e2fsprogs/e2fsprogs.mk
@@ -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) \
--
1.8.2.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 1/3] e2fsprogs: nommu: Add patch to use vfork in nommu arch.
2013-11-15 8:31 ` [Buildroot] [PATCH 1/3] e2fsprogs: nommu: Add patch to use vfork in nommu arch sonic.adi at gmail.com
@ 2013-11-15 8:40 ` Thomas De Schampheleire
2013-11-16 0:59 ` Arnout Vandecappelle
1 sibling, 0 replies; 8+ messages in thread
From: Thomas De Schampheleire @ 2013-11-15 8:40 UTC (permalink / raw)
To: buildroot
Hi Sonic,
On Fri, Nov 15, 2013 at 9:31 AM, <sonic.adi@gmail.com> wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> ---
> package/e2fsprogs/e2fsprogs-nommu.patch | 231 ++++++++++++++++++++++++++++++++
> 1 file changed, 231 insertions(+)
> create mode 100644 package/e2fsprogs/e2fsprogs-nommu.patch
>
> diff --git a/package/e2fsprogs/e2fsprogs-nommu.patch b/package/e2fsprogs/e2fsprogs-nommu.patch
> new file mode 100644
> index 0000000..6aef365
> --- /dev/null
> +++ b/package/e2fsprogs/e2fsprogs-nommu.patch
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [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.
2013-11-15 8:31 ` [Buildroot] [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 sonic.adi at gmail.com
@ 2013-11-15 8:56 ` Thomas De Schampheleire
0 siblings, 0 replies; 8+ messages in thread
From: Thomas De Schampheleire @ 2013-11-15 8:56 UTC (permalink / raw)
To: buildroot
On Fri, Nov 15, 2013 at 9:31 AM, <sonic.adi@gmail.com> wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> ---
> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 1/3] e2fsprogs: nommu: Add patch to use vfork in nommu arch.
2013-11-15 8:31 ` [Buildroot] [PATCH 1/3] e2fsprogs: nommu: Add patch to use vfork in nommu arch sonic.adi at gmail.com
2013-11-15 8:40 ` Thomas De Schampheleire
@ 2013-11-16 0:59 ` Arnout Vandecappelle
2013-11-16 9:42 ` Thomas Petazzoni
1 sibling, 1 reply; 8+ messages in thread
From: Arnout Vandecappelle @ 2013-11-16 0:59 UTC (permalink / raw)
To: buildroot
Hi Sonic,
Again, it doesn't look like these fork replacements will work...
On 15/11/13 09:31, sonic.adi at gmail.com wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> ---
> package/e2fsprogs/e2fsprogs-nommu.patch | 231 ++++++++++++++++++++++++++++++++
> 1 file changed, 231 insertions(+)
> create mode 100644 package/e2fsprogs/e2fsprogs-nommu.patch
>
> diff --git a/package/e2fsprogs/e2fsprogs-nommu.patch b/package/e2fsprogs/e2fsprogs-nommu.patch
> new file mode 100644
> index 0000000..6aef365
> --- /dev/null
> +++ b/package/e2fsprogs/e2fsprogs-nommu.patch
> @@ -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
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?
> + 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
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.
> + 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
Hm, this looks like cut and paste code from util-linux, where I
commented on a better way to implement this.
> + }
> + } 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
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
> + 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
>
--
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 1/3] e2fsprogs: nommu: Add patch to use vfork in nommu arch.
2013-11-16 0:59 ` Arnout Vandecappelle
@ 2013-11-16 9:42 ` Thomas Petazzoni
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2013-11-16 9:42 UTC (permalink / raw)
To: buildroot
Sonic,
On Sat, 16 Nov 2013 01:59:52 +0100, Arnout Vandecappelle wrote:
> 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
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-11-16 9:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-15 8:31 [Buildroot] [PATCH] e2fsprogs: Disable elf shared library when BR2_PREFER_STATIC_LIB is selected sonic.adi at gmail.com
2013-11-15 8:31 ` [Buildroot] [PATCH 1/3] e2fsprogs: nommu: Add patch to use vfork in nommu arch sonic.adi at gmail.com
2013-11-15 8:40 ` Thomas De Schampheleire
2013-11-16 0:59 ` Arnout Vandecappelle
2013-11-16 9:42 ` Thomas Petazzoni
2013-11-15 8:31 ` [Buildroot] [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 sonic.adi at gmail.com
2013-11-15 8:56 ` Thomas De Schampheleire
2013-11-15 8:31 ` [Buildroot] [PATCH 3/3] e2fsprogs: Disable elf shared library when BR2_PREFER_STATIC_LIB is selected sonic.adi at gmail.com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox