{"id":4157,"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\/proc_dir_entry-man9\/"},"modified":"2022-12-20T17:39:33","modified_gmt":"2022-12-20T20:39:33","slug":"proc_dir_entry-man9","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/proc_dir_entry-man9\/","title":{"rendered":"proc_dir_entry (man9)"},"content":{"rendered":"<h1 align=\"center\">proc_dir_entry<\/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=\"#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\">proc_dir_entry, proc_register, proc_register_dynamic, proc_unregister \u2212 register entries in the \/proc filesystem.<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <linux\/proc_fs.h> int\u00a0proc_register(struct\u00a0proc_dir_entry\u00a0*\u00a0<\/b><i>parent<\/i><b>, <br \/> struct\u00a0proc_dir_entry\u00a0*\u00a0<\/b><i>child<\/i><b>); <br \/> int\u00a0proc_unregister(struct\u00a0proc_dir_entry\u00a0*\u00a0<\/b><i>parent<\/i><b>, int\u00a0<\/b><i>inode<\/i><b>); <br \/> int\u00a0proc_register_dynamic(struct\u00a0proc_dir_entry\u00a0*\u00a0<\/b><i>parent<\/i><b>, <br \/> struct\u00a0proc_dir_entry\u00a0*\u00a0<\/b><i>child<\/i><b>);<\/b><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>proc_register<\/b> functions add file or directory entries to the \/proc file system. They associate processing routines with each node of the \/proc tree. The structure <b>proc_dir_entry<\/b> is defined as<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>struct proc_dir_entry { <br \/> unsigned short low_ino; <br \/> unsigned short namelen; <br \/> const char *name; <br \/> mode_t mode; <br \/> nlink_t nlink; <br \/> uid_t uid; <br \/> gid_t gid; <br \/> unsigned long size; <br \/> struct inode_operations bodies manpages.csv script_extrae_body.sh script.sh usr ops; <br \/> int (*get_info)(char *buffer, char **start, <br \/> off_t offset, int length, int unused); <br \/> void (*fill_inode)(struct inode *); <br \/> struct proc_dir_entry *next, *parent, *subdir; <br \/> void *data; <br \/> };<\/b><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p>low_ino<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"77%\">\n<p>The inode number of this directory entry. For <b>proc_register<\/b> this number should be unique within the \/proc filesystem, values are defined in <i><linux\/proc_fs.h><\/i>. For <b>proc_register_dynamic<\/b> the inode number is dynamically assigned.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p>namelen<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"77%\">\n<p>The length of the name, excluding the trailing null.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p>name<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"77%\">\n<p>The name of this node.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p>mode<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"77%\">\n<p>The node\u2019s type and permissions. Drawn from <i><linux\/stat.h><\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p>nlink<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"77%\">\n<p>Number of links to the node. Initialise to 2 if mode includes S_IFDIR, 1 otherwise.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p>uid<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"77%\">\n<p>The uid that owns the node, normally 0.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p>gid<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"77%\">\n<p>The gid that owns the node. normally 0.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p>size<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"77%\">\n<p>Sets the size of the node, the value will appear as the inode size in listings and be returned by <b>stat<\/b>. Unless you really need a size, set this to zero.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p>ops<\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"77%\">\n<p>Defines the set of inode operations to perform for your \/proc node. For a directory node, use <i>&#038;proc_dir_inode_operations<\/i> unless you have special requirements. For a leaf node, set to NULL unless you have special requirements.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%;\">get_info<\/p>\n<p style=\"margin-left:23%;\">If defined, this proc is called when the node is read. Should be NULL for directory nodes. <b>NOTE:<\/b> If you need to return large amounts of data, the proc must return the data in chunks and reposition itself on the next call, using the <i>offset<\/i> variable. See <i>ip_masq_procinfo<\/i> for example code with large output.<\/p>\n<p style=\"margin-left:11%;\">fill_inode<\/p>\n<p style=\"margin-left:23%;\">Dynamically fill in the inode characteristics during directory operations. Not normally required and set to NULL. See proc_pid_fill_inode for example code.<\/p>\n<p style=\"margin-left:11%;\">next, parent, subdir<\/p>\n<p style=\"margin-left:23%;\">Maintained by \/proc routines. Initial value is irrelevant, set to NULL.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"6%\">\n<p>data<\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"77%\">\n<p>An opaque pointer which can be used by proc handlers to pass local data around. Set to whatever you like when calling <b>proc_register<\/b>, normally NULL. This pointer is copied into the inode u.ip_generic field (by proc_get_inode) so it is available to any proc routines that are passed an inode.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>proc_register<\/b> adds the <b>child<\/b> as a node under the <b>parent<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>proc_register_dynamic<\/b> dynamically assigns an inode number then adds the <b>child<\/b> as a node under the <b>parent<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>proc_unregister<\/b> scans the inode list under the <b>parent<\/b> for the specified <b>inode<\/b> number and removes the matching entry.<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>proc_register<\/b> always returns 0.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>proc_register_dynamic<\/b> returns 0 for success or <b>-EAGAIN<\/b> if there are no free dynamic inode numbers.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>proc_unregister<\/b> returns 0 for success or <b>-EINVAL<\/b> if the node was not found.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>proc_net_register<\/b>(9), <b>proc_net_unregister<\/b>(9), <b>proc_scsi_register<\/b>(9), <b>proc_scsi_unregister<\/b>(9), <b>stat<\/b>(2).<\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Keith Owens <kaos@ocs.com.au><\/p>\n<h2>BUGS <a name=\"BUGS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The uniqueness of \/proc inode numbers is assumed, not enforced. It is possible to add two nodes with the same inode number.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  proc_dir_entry, proc_register, proc_register_dynamic, proc_unregister \u2212 register entries in the \/proc filesystem. <\/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,1237],"class_list":["post-4157","post","type-post","status-publish","format-standard","hentry","category-9-rutinas-del-nucleo","tag-1226","tag-kernel","tag-man9","tag-proc_dir_entry"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4157","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=4157"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4157\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=4157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=4157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=4157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}