init
[vuplus_openvuplus_3.0] / meta-openvuplus / recipes-core / busybox / busybox-1.19.4 / 0007-ifplugd-move-read_pid-to-libbb-pidfile.c-and-rename-.patch
1 From 4119652f74ce6f8f370df3c80076792d509bc941 Mon Sep 17 00:00:00 2001
2 From: Andreas Oberritter <obi@opendreambox.org>
3 Date: Mon, 14 May 2012 16:15:50 +0200
4 Subject: [PATCH 7/9] ifplugd: move read_pid to libbb/pidfile.c and rename it
5  to read_pidfile
6
7 Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
8 ---
9  include/libbb.h      |    2 ++
10  libbb/pidfile.c      |   14 ++++++++++++++
11  networking/ifplugd.c |   18 +-----------------
12  3 files changed, 17 insertions(+), 17 deletions(-)
13
14 diff --git a/include/libbb.h b/include/libbb.h
15 index 63d0419..e9538e7 100644
16 --- a/include/libbb.h
17 +++ b/include/libbb.h
18 @@ -1031,10 +1031,12 @@ llist_t *llist_find_str(llist_t *first, const char *str) FAST_FUNC;
19  #if ENABLE_FEATURE_PIDFILE || defined(WANT_PIDFILE)
20  /* True only if we created pidfile which is *file*, not /dev/null etc */
21  extern smallint wrote_pidfile;
22 +pid_t read_pidfile(const char *path) FAST_FUNC;
23  void write_pidfile(const char *path) FAST_FUNC;
24  #define remove_pidfile(path) do { if (wrote_pidfile) unlink(path); } while (0)
25  #else
26  enum { wrote_pidfile = 0 };
27 +#define read_pidfile(path)   ((void)0)
28  #define write_pidfile(path)  ((void)0)
29  #define remove_pidfile(path) ((void)0)
30  #endif
31 diff --git a/libbb/pidfile.c b/libbb/pidfile.c
32 index a48dfc3..6734a2d 100644
33 --- a/libbb/pidfile.c
34 +++ b/libbb/pidfile.c
35 @@ -13,6 +13,20 @@
36  
37  smallint wrote_pidfile;
38  
39 +pid_t FAST_FUNC read_pidfile(const char *filename)
40 +{
41 +       int len;
42 +       char buf[128];
43 +
44 +       len = open_read_close(filename, buf, 127);
45 +       if (len > 0) {
46 +               buf[len] = '\0';
47 +               /* returns ULONG_MAX on error => -1 */
48 +               return bb_strtoul(buf, NULL, 10);
49 +       }
50 +       return 0;
51 +}
52 +
53  void FAST_FUNC write_pidfile(const char *path)
54  {
55         int pid_fd;
56 diff --git a/networking/ifplugd.c b/networking/ifplugd.c
57 index d8358cd..9a15576 100644
58 --- a/networking/ifplugd.c
59 +++ b/networking/ifplugd.c
60 @@ -510,22 +510,6 @@ static NOINLINE int check_existence_through_netlink(void)
61         return G.iface_exists;
62  }
63  
64 -#if ENABLE_FEATURE_PIDFILE
65 -static NOINLINE pid_t read_pid(const char *filename)
66 -{
67 -       int len;
68 -       char buf[128];
69 -
70 -       len = open_read_close(filename, buf, 127);
71 -       if (len > 0) {
72 -               buf[len] = '\0';
73 -               /* returns ULONG_MAX on error => -1 */
74 -               return bb_strtoul(buf, NULL, 10);
75 -       }
76 -       return 0;
77 -}
78 -#endif
79 -
80  int ifplugd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
81  int ifplugd_main(int argc UNUSED_PARAM, char **argv)
82  {
83 @@ -552,7 +536,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
84  
85  #if ENABLE_FEATURE_PIDFILE
86         pidfile_name = xasprintf(_PATH_VARRUN"ifplugd.%s.pid", G.iface);
87 -       pid_from_pidfile = read_pid(pidfile_name);
88 +       pid_from_pidfile = read_pidfile(pidfile_name);
89  
90         if (opts & FLAG_KILL) {
91                 if (pid_from_pidfile > 0)
92 -- 
93 1.7.9.5
94