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