{"id":4154,"date":"2022-12-20T17:39:33","date_gmt":"2022-12-20T20:39:33","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/printk-man9\/"},"modified":"2022-12-20T17:39:33","modified_gmt":"2022-12-20T20:39:33","slug":"printk-man9","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/printk-man9\/","title":{"rendered":"printk (man9)"},"content":{"rendered":"<h1 align=\"center\">printk<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#RETURN VALUE\">RETURN VALUE<\/a><br \/> <a href=\"#AVAILABILITY\">AVAILABILITY<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#AUTHOR\">AUTHOR<\/a><br \/> <a href=\"#BUGS\">BUGS<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">printk \u2212 print messages to console log<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <linux\/kernel.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>int printk(const char*<\/b><i>fmt<\/i><b>, &#8230;)<\/b><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Print a formatted message to the kernel console, much like the <b>printf<\/b> function of the stdio library. Normally, the message is written to the physical console device of the computer, although this behavior can be changed with the <b>register_console<\/b> function. Messages are also stored in a message log book.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The generated string may also start with a message priority code, which sets the priority of the message. The priority code strings are of the form <i><n><\/i> where n is a number from 0 &#8211; 7. The following macros are defined in the <i><linux\/kernel.h><\/i> header file:<\/p>\n<p style=\"margin-left:22%;\">KERN_EMERG<\/p>\n<p style=\"margin-left:32%;\">System is unuseable<\/p>\n<p style=\"margin-left:22%;\">KERN_ALERT<\/p>\n<p style=\"margin-left:32%;\">Action must be taken immediately<\/p>\n<p style=\"margin-left:22%;\">KERN_CRIT<\/p>\n<p style=\"margin-left:32%;\">Critical conditions<\/p>\n<p style=\"margin-left:22%;\">KERN_ERR<\/p>\n<p style=\"margin-left:32%;\">Error conditions<\/p>\n<p style=\"margin-left:22%;\">KERN_WARNING<\/p>\n<p style=\"margin-left:32%;\">Warning conditions<\/p>\n<p style=\"margin-left:22%;\">KERN_NOTICE<\/p>\n<p style=\"margin-left:32%;\">Normal but significant condition<\/p>\n<p style=\"margin-left:22%;\">KERN_INFO<\/p>\n<p style=\"margin-left:32%;\">Informational<\/p>\n<p style=\"margin-left:22%;\">KERN_DEBUG<\/p>\n<p style=\"margin-left:32%;\">Debug-level messages<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For example<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"85%\">\n<p>printk(KERN_NOTICE &#8220;Hello, world.n&#8221;);<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">does the expected thing.<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the number of characters written to the log.<\/p>\n<h2>AVAILABILITY <a name=\"AVAILABILITY\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Linux 1.0+<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>register_console<\/b>(9), <b>syslog<\/b>(2)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>kernel\/printk.c<\/i><\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Stephen Williams (steve@icarus.com)<\/p>\n<h2>BUGS <a name=\"BUGS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">float and double formats are not supported. Floats and doubles do not belong inside the kernel anyhow.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>printk<\/b> implementation protects itself from interruption, so in principle it can be used in interrupts handlers and critical sections. However, there are no guarantees about the console function that is registered.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  printk \u2212 print messages to console log <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1222],"tags":[1226,1223,1225,1234],"class_list":["post-4154","post","type-post","status-publish","format-standard","hentry","category-9-rutinas-del-nucleo","tag-1226","tag-kernel","tag-man9","tag-printk"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=4154"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4154\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=4154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=4154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=4154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}