{"id":7057,"date":"2022-12-20T19:34:48","date_gmt":"2022-12-20T22:34:48","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/ftok-man3\/"},"modified":"2022-12-20T19:34:48","modified_gmt":"2022-12-20T22:34:48","slug":"ftok-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/ftok-man3\/","title":{"rendered":"FTOK (man3)"},"content":{"rendered":"<h1 align=\"center\">FTOK<\/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=\"#ATTRIBUTES\">ATTRIBUTES<\/a><br \/> <a href=\"#CONFORMING TO\">CONFORMING TO<\/a><br \/> <a href=\"#NOTES\">NOTES<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COLOPHON\">COLOPHON<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">ftok \u2212 convert a pathname and a project identifier to a System V IPC key<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <sys\/types.h> <br \/> #include <sys\/ipc.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>key_t ftok(const char *<\/b><i>pathname<\/i><b>, int<\/b> <i>proj_id<\/i><b>);<\/b><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>ftok<\/b>() function uses the identity of the file named by the given <i>pathname<\/i> (which must refer to an existing, accessible file) and the least significant 8 bits of <i>proj_id<\/i> (which must be nonzero) to generate a <i>key_t<\/i> type System V IPC key, suitable for use with <b>msgget<\/b>(2), <b>semget<\/b>(2), or <b>shmget<\/b>(2).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The resulting value is the same for all pathnames that name the same file, when the same value of <i>proj_id<\/i> is used. The value returned should be different when the (simultaneously existing) files or the project IDs differ.<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">On success, the generated <i>key_t<\/i> value is returned. On failure \u22121 is returned, with <i>errno<\/i> indicating the error as for the <b>stat<\/b>(2) system call.<\/p>\n<h2>ATTRIBUTES <a name=\"ATTRIBUTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">For an explanation of the terms used in this section, see <b>attributes<\/b>(7).<\/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=\"8%\"> <\/td>\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"62%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"> <\/td>\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"62%\"> <\/td>\n<\/tr>\n<\/table>\n<p align=\"center\"><img decoding=\"async\" src=\"grohtml-1646331.png\" alt=\"Image grohtml-1646331.png\"><\/p>\n<h2>CONFORMING TO <a name=\"CONFORMING TO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">POSIX.1-2001, POSIX.1-2008.<\/p>\n<h2>NOTES <a name=\"NOTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">On some ancient systems, the prototype was:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>key_t ftok(char *<\/b><i>pathname<\/i><b>, char<\/b> <i>proj_id<\/i><b>);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Today, <i>proj_id<\/i> is an <i>int<\/i>, but still only 8 bits are used. Typical usage has an ASCII character <i>proj_id<\/i>, that is why the behavior is said to be undefined when <i>proj_id<\/i> is zero.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Of course, no guarantee can be given that the resulting <i>key_t<\/i> is unique. Typically, a best-effort attempt combines the given <i>proj_id<\/i> byte, the lower 16 bits of the inode number, and the lower 8 bits of the device number into a 32-bit result. Collisions may easily happen, for example between files on <i>\/dev\/hda1<\/i> and files on <i>\/dev\/sda1<\/i>.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">See <b>semget<\/b>(2).<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>msgget<\/b>(2), <b>semget<\/b>(2), <b>shmget<\/b>(2), <b>stat<\/b>(2), <b>sysvipc<\/b>(7)<\/p>\n<h2>COLOPHON <a name=\"COLOPHON\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This page is part of release 5.10 of the Linux <i>man-pages<\/i> project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https:\/\/www.kernel.org\/doc\/man\u2212pages\/.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  ftok \u2212 convert a pathname and a project identifier to a System V IPC key <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,2138,3007],"class_list":["post-7057","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-ftok","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7057","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=7057"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7057\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}