Initial commit to Gerrit
[profile/ivi/ntp.git] / packaging / ntp-4.2.4p8-mlock.patch
1 diff -uNpr ntp-4.2.4p8/html/ntpd.html ntp-4.2.4p8-fixed/html/ntpd.html
2 --- ntp-4.2.4p8/html/ntpd.html  2006-12-28 20:02:57.000000000 +0800
3 +++ ntp-4.2.4p8-fixed/html/ntpd.html    2009-12-14 18:02:33.000000000 +0800
4 @@ -89,6 +89,8 @@
5                         <dd>Specify the name and path of the log file. The default is the system log file. This is the same operation as the <tt>logfile <i>logfile</i></tt> configuration command.
6                         <dt><tt>-L</tt>
7                         <dd>Do not listen to virtual IPs. The default is to listen.
8 +                       <dt><tt>-m</tt>
9 +                       <dd>Lock memory.
10                         <dt><tt>-n</tt>
11                         <dd>Don't fork.
12                         <dt><tt>-N</tt>
13 diff -uNpr ntp-4.2.4p8/ntpd/ntpd.c ntp-4.2.4p8-fixed/ntpd/ntpd.c
14 --- ntp-4.2.4p8/ntpd/ntpd.c     2009-12-08 19:55:58.000000000 +0800
15 +++ ntp-4.2.4p8-fixed/ntpd/ntpd.c       2009-12-14 18:02:33.000000000 +0800
16 @@ -696,7 +696,8 @@ ntpdmain(
17         }
18  #endif
19  
20 -#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && defined(MCL_FUTURE)
21 +#if defined(MCL_CURRENT) && defined(MCL_FUTURE)
22 +    if (HAVE_OPT( MLOCK )) {
23  # ifdef HAVE_SETRLIMIT
24         /*
25          * Set the stack limit to something smaller, so that we don't lock a lot
26 @@ -722,7 +723,7 @@ ntpdmain(
27              * fail if we drop root privlege.  To be useful the value
28              * has to be larger than the largest ntpd resident set size.
29              */
30 -           rl.rlim_cur = rl.rlim_max = 32*1024*1024;
31 +           rl.rlim_cur = rl.rlim_max = 64*1024*1024;
32             if (setrlimit(RLIMIT_MEMLOCK, &rl) == -1) {
33                 msyslog(LOG_ERR, "Cannot set RLIMIT_MEMLOCK: %m");
34             }
35 @@ -734,6 +735,7 @@ ntpdmain(
36          */
37         if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0)
38                 msyslog(LOG_ERR, "mlockall(): %m");
39 +    }
40  #else /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */
41  # ifdef HAVE_PLOCK
42  #  ifdef PROCLOCK
43 diff -uNpr ntp-4.2.4p8/ntpd/ntpd-opts.c ntp-4.2.4p8-fixed/ntpd/ntpd-opts.c
44 --- ntp-4.2.4p8/ntpd/ntpd-opts.c        2009-12-08 21:13:09.000000000 +0800
45 +++ ntp-4.2.4p8-fixed/ntpd/ntpd-opts.c  2009-12-14 18:02:33.000000000 +0800
46 @@ -264,6 +264,15 @@ tSCC    zNice_Name[]               = "ni
47  #define NICE_FLAGS       (OPTST_DISABLED)
48  
49  /*
50 + *  Mlock option description:
51 + */
52 +tSCC    zMlockText[] =
53 +        "Lock memory";
54 +tSCC    zMlock_NAME[]               = "MLOCK";
55 +tSCC    zMlock_Name[]               = "mlock";
56 +#define MLOCK_FLAGS       (OPTST_DISABLED)
57 +
58 +/*
59   *  Pidfile option description:
60   */
61  tSCC    zPidfileText[] =
62 @@ -789,6 +798,18 @@ static tOptDesc optDesc[ OPTION_CT ] = {
63                                  OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
64  #endif
65  
66 +  {  /* entry idx, value */ 29, VALUE_OPT_MLOCK,
67 +     /* equiv idx, value */ 29, VALUE_OPT_MLOCK,
68 +     /* equivalenced to  */ NO_EQUIVALENT,
69 +     /* min, max, act ct */ 0, 1, 0,
70 +     /* opt state flags  */ MLOCK_FLAGS, 0,
71 +     /* last opt argumnt */ { NULL },
72 +     /* arg list/cookie  */ NULL,
73 +     /* must/cannot opts */ NULL, NULL,
74 +     /* option proc      */ NULL,
75 +     /* desc, NAME, name */ zMlockText, zMlock_NAME, zMlock_Name,
76 +     /* disablement strs */ NULL, NULL },
77 +
78    {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
79       /* equiv idx value  */ NO_EQUIVALENT, 0,
80       /* equivalenced to  */ NO_EQUIVALENT,
81 @@ -881,7 +902,7 @@ tOptions ntpdOptions = {
82        NO_EQUIVALENT /* index of '-#' option */,
83        NO_EQUIVALENT /* index of default opt */
84      },
85 -    32 /* full option count */, 29 /* user option count */
86 +    33 /* full option count */, 30 /* user option count */
87  };
88  
89  /*
90 diff -uNpr ntp-4.2.4p8/ntpd/ntpd-opts.h ntp-4.2.4p8-fixed/ntpd/ntpd-opts.h
91 --- ntp-4.2.4p8/ntpd/ntpd-opts.h        2009-12-08 21:13:09.000000000 +0800
92 +++ ntp-4.2.4p8-fixed/ntpd/ntpd-opts.h  2009-12-14 18:04:13.000000000 +0800
93 @@ -81,12 +81,13 @@ typedef enum {
94          INDEX_OPT_VAR              = 26,
95          INDEX_OPT_DVAR             = 27,
96          INDEX_OPT_SLEW             = 28,
97 -        INDEX_OPT_VERSION          = 29,
98 -        INDEX_OPT_HELP             = 30,
99 -        INDEX_OPT_MORE_HELP        = 31
100 +        INDEX_OPT_MLOCK            = 29,
101 +        INDEX_OPT_VERSION          = 30,
102 +        INDEX_OPT_HELP             = 31,
103 +        INDEX_OPT_MORE_HELP        = 32
104  } teOptIndex;
105  
106 -#define OPTION_CT    32
107 +#define OPTION_CT    33
108  #define NTPD_VERSION       "4.2.4p8"
109  #define NTPD_FULL_VERSION  "ntpd - NTP daemon program - Ver. 4.2.4p8"
110  
111 @@ -179,6 +180,10 @@ typedef enum {
112  #  warning undefining MODIFYMMTIMER due to option name conflict
113  #  undef   MODIFYMMTIMER
114  # endif
115 +# ifdef    MLOCK
116 +#  warning undefining MLOCK due to option name conflict
117 +#  undef   MLOCK
118 +# endif
119  # ifdef    NOFORK
120  #  warning undefining NOFORK due to option name conflict
121  #  undef   NOFORK
122 @@ -248,6 +253,7 @@ typedef enum {
123  # undef LOGFILE
124  # undef NOVIRTUALIPS
125  # undef MODIFYMMTIMER
126 +# undef MLOCK
127  # undef NOFORK
128  # undef NICE
129  # undef PIDFILE
130 @@ -290,6 +296,7 @@ typedef enum {
131  #ifdef SYS_WINNT
132  #define VALUE_OPT_MODIFYMMTIMER  'M'
133  #endif /* SYS_WINNT */
134 +#define VALUE_OPT_MLOCK          'm'
135  #define VALUE_OPT_NOFORK         'n'
136  #define VALUE_OPT_NICE           'N'
137  #define VALUE_OPT_PIDFILE        'p'