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