]> rtime.felk.cvut.cz Git - edu/osp-wiki.git/blob - student/janovji3/index.mdwn
(no commit message)
[edu/osp-wiki.git] / student / janovji3 / index.mdwn
1 [[!meta title="Janovec Jiří"]]
2
3
4 **Project name and homepage:** [Busybox](http://busybox.net)
5
6 Assignment
7 ======
8
9   [Bug #8626](https://bugs.busybox.net/show_bug.cgi?id=8626):
10  Add support -i option to command logger in busybox to log PID.
11
12 (This can be done using [syslog man pages](http://linux.die.net/man/3/syslog). )
13
14
15 ----------
16
17
18 <!---
19
20  not completed yet
21
22
23 Links documenting the results of my work
24 ======
25
26 Here, I'll add links similar to the examples below and describe what
27 is being linked.
28
29 * [[Example] My communication with developers in a public mailing list archive](http://groups.google.com/group/comp.os.minix/browse_thread/thread/e3df794a2bce97da/2194d253268b0a1b?#2194d253268b0a1b)
30 * [[Example] Version control repository with the actual state of my work](http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=summary)
31 * [[Example] My commit in the project repository](http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ea90002b0fa7bdee86ec22eba1d951f30bf043a6)
32 * [[Example] Additional supporting material](http://lwn.net/Articles/385586/)
33
34 Presentation
35 ==========
36
37 * [[Presentation of the aim of my work in PDF or OpenDocument format (upload it as an *Attachment* to this page)|prezentace1.pdf]]
38 * [[Presentation of the results of my work|prezentace2.pdf]]
39
40 OpenHub
41 =======
42
43 Here, I'll fill in the HTML code of the [OpenHub widget][w] showing my KudoRank.
44
45 For example:
46 <a href='https://www.openhub.net/accounts/9897?ref=Detailed' target='_blank'>
47 <img alt='Ohloh profile for wentasah' border='0' height='35' src='https://www.openhub.net/accounts/9897/widgets/account_detailed.gif' width='230' />
48 </a>
49
50 [w]:https://www.openhub.net/accounts/janovji3/widgets
51
52 --->
53
54 Poznámky 
55 ========
56   -   8.3. 2016, 10.h , busybox found, browsing bugzilla
57   -   8.3. 2016, 12-15.h, making patch
58   - 10.3. 2016, 10:34:00 consultations on RM35OSP
59   - 10.3. 2016, 12:52:29 CET , mailto:busybox@busybox.net, Předmět: [PATCH] - Bugfix #8626, adds "option -i" to "lo... (zatím nevím kde je na to odkaz)
60   - waiting to response 
61
62 Malá verze:
63    <pre>
64 diff --git a/sysklogd/logger.c b/sysklogd/logger.c
65 index b3ca857..58f9374 100644
66 --- a/sysklogd/logger.c
67 +++ b/sysklogd/logger.c
68 @@ -103,10 +103,12 @@ int logger_main(int argc UNUSED_PARAM, char **argv)
69         str_t = uid2uname_utoa(geteuid());
70  
71         /* Parse any options */
72 -       opt = getopt32(argv, "p:st:", &str_p, &str_t);
73 +       opt = getopt32(argv, "p:st:i", &str_p, &str_t);
74  
75         if (opt & 0x2) /* -s */
76                 i |= LOG_PERROR;
77 +       if (opt & 0x8) /* -i */
78 +               i |= LOG_PID;
79         //if (opt & 0x4) /* -t */
80         openlog(str_t, i, 0);
81         i = LOG_USER | LOG_NOTICE;
82    </pre>
83
84 Pořádná verze:
85    <pre>
86 diff --git a/sysklogd/logger.c b/sysklogd/logger.c
87 index b3ca857..25b82cc 100644
88 --- a/sysklogd/logger.c
89 +++ b/sysklogd/logger.c
90 @@ -15,6 +15,13 @@
91  //config:          messages to the system log (i.e. the 'syslogd' utility) so
92  //config:          they can be logged. This is generally used to help locate
93  //config:          problems that occur within programs and scripts.
94 +//config:
95 +//config:config FEATURE_LOG_PID
96 +//config:       bool "Log PID of logger"
97 +//config:       default n
98 +//config:       depends on LOGGER
99 +//config:       help
100 +//config:         This enables logger to log process id (PID).
101  
102  //applet:IF_LOGGER(APPLET(logger, BB_DIR_USR_BIN, BB_SUID_DROP))
103  
104 @@ -24,6 +31,9 @@
105  //usage:       "[OPTIONS] [MESSAGE]"
106  //usage:#define logger_full_usage "\n\n"
107  //usage:       "Write MESSAGE (or stdin) to syslog\n"
108 +//usage:        IF_FEATURE_LOG_PID(
109 +//usage:     "\n       -i      Log the process ID too"
110 +//usage:        )
111  //usage:     "\n       -s      Log to stderr as well as the system log"
112  //usage:     "\n       -t TAG  Log using the specified tag (defaults to user name)"
113  //usage:     "\n       -p PRIO Priority (numeric or facility.level pair)"
114 @@ -39,6 +49,23 @@
115  #include <syslog.h>
116  */
117  
118 +/* Options */
119 +enum {
120 +        OPTBIT_priority = 0, // -p
121 +        OPTBIT_stderr, // -s
122 +        OPTBIT_tag, // -t
123 +        IF_FEATURE_LOG_PID(OPTBIT_pid   ,)  // -i
124 +
125 +        OPT_priority    = 1 << OPTBIT_priority   ,
126 +        OPT_stderr      = 1 << OPTBIT_stderr     ,
127 +        OPT_tag         = 1 << OPTBIT_tag        ,
128 +        OPT_pid         = IF_FEATURE_LOG_PID((1 << OPTBIT_pid   )) + 0,
129 +};
130 +#define OPTION_STR "p:st:" \
131 +        IF_FEATURE_LOG_PID("i:" )
132 +#define OPTION_DECL *str_p, *str_t
133 +#define OPTION_PARAM &str_p, &str_t
134 +
135  /* Decode a symbolic name to a numeric value
136   * this function is based on code
137   * Copyright (c) 1983, 1993
138 @@ -95,7 +122,7 @@ static int pencode(char *s)
139  int logger_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
140  int logger_main(int argc UNUSED_PARAM, char **argv)
141  {
142 -       char *str_p, *str_t;
143 +       char OPTION_DECL;
144         int opt;
145         int i = 0;
146  
147 @@ -103,14 +130,19 @@ int logger_main(int argc UNUSED_PARAM, char **argv)
148         str_t = uid2uname_utoa(geteuid());
149  
150         /* Parse any options */
151 -       opt = getopt32(argv, "p:st:", &str_p, &str_t);
152 +       opt = getopt32(argv, OPTION_STR, OPTION_PARAM);
153 +getopt32(argv, "p:st:i", &str_p, &str_t);
154  
155 -       if (opt & 0x2) /* -s */
156 +       if (opt & OPT_stderr) /* -s */
157                 i |= LOG_PERROR;
158 -       //if (opt & 0x4) /* -t */
159 +#if ENABLE_FEATURE_LOG_PID
160 +       if (opt & OPT_pid) /* -i */
161 +               i |= LOG_PID;
162 +#endif
163 +       //if (opt & OPT_tag) /* -t */
164         openlog(str_t, i, 0);
165         i = LOG_USER | LOG_NOTICE;
166 -       if (opt & 0x1) /* -p */
167 +       if (opt & OPT_priority) /* -p */
168                 i = pencode(str_p);
169  
170         argv += optind;
171    </pre>