blob: 59b2f00c9004fca144159a51b33fbf862d19ff3f [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>Apache Mesos: ns Namespace Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">Apache Mesos
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
<li class="current"><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="namespaces.html"><span>Namespace&#160;List</span></a></li>
<li><a href="namespacemembers.html"><span>Namespace&#160;Members</span></a></li>
</ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#namespaces">Namespaces</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">ns Namespace Reference</div> </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="namespaces"></a>
Namespaces</h2></td></tr>
<tr class="memitem:namespacens_1_1pid"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacens_1_1pid.html">pid</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a1c4fd4fd04bde294d2d7477dfee8427e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classTry.html">Try</a>&lt; int &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacens.html#a1c4fd4fd04bde294d2d7477dfee8427e">nstype</a> (const std::string &amp;ns)</td></tr>
<tr class="separator:a1c4fd4fd04bde294d2d7477dfee8427e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aab01ae26d9da2efc741aa838c69db6e2"><td class="memItemLeft" align="right" valign="top">std::set&lt; std::string &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacens.html#aab01ae26d9da2efc741aa838c69db6e2">namespaces</a> ()</td></tr>
<tr class="separator:aab01ae26d9da2efc741aa838c69db6e2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae308e5fb79986971a85717365f2258d4"><td class="memItemLeft" align="right" valign="top">std::set&lt; int &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacens.html#ae308e5fb79986971a85717365f2258d4">nstypes</a> ()</td></tr>
<tr class="separator:ae308e5fb79986971a85717365f2258d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aff4db8d452eb5c8f07fba2ceeb5a7d83"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classTry.html">Try</a>&lt; <a class="el" href="structNothing.html">Nothing</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacens.html#aff4db8d452eb5c8f07fba2ceeb5a7d83">setns</a> (const std::string &amp;path, const std::string &amp;ns, bool checkMultithreaded=true)</td></tr>
<tr class="separator:aff4db8d452eb5c8f07fba2ceeb5a7d83"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7e58011de0d8219645c27912fc3bc8f4"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classTry.html">Try</a>&lt; <a class="el" href="structNothing.html">Nothing</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacens.html#a7e58011de0d8219645c27912fc3bc8f4">setns</a> (<a class="el" href="3rdparty_2stout_2include_2stout_2windows_8hpp.html#ab03ced250ed239bc3b50b669493997f9">pid_t</a> pid, const std::string &amp;ns)</td></tr>
<tr class="separator:a7e58011de0d8219645c27912fc3bc8f4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0f104f8776ccb934a05efeaeeebab328"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classTry.html">Try</a>&lt; ino_t &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacens.html#a0f104f8776ccb934a05efeaeeebab328">getns</a> (<a class="el" href="3rdparty_2stout_2include_2stout_2windows_8hpp.html#ab03ced250ed239bc3b50b669493997f9">pid_t</a> pid, const std::string &amp;ns)</td></tr>
<tr class="separator:a0f104f8776ccb934a05efeaeeebab328"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a98bf4d9e11d546326250997a6493f835"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classTry.html">Try</a>&lt; <a class="el" href="3rdparty_2stout_2include_2stout_2windows_8hpp.html#ab03ced250ed239bc3b50b669493997f9">pid_t</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacens.html#a98bf4d9e11d546326250997a6493f835">clone</a> (<a class="el" href="3rdparty_2stout_2include_2stout_2windows_8hpp.html#ab03ced250ed239bc3b50b669493997f9">pid_t</a> target, int <a class="el" href="namespacens.html#ae308e5fb79986971a85717365f2258d4">nstypes</a>, const lambda::function&lt; int()&gt; &amp;f, int flags)</td></tr>
<tr class="memdesc:a98bf4d9e11d546326250997a6493f835"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs an <code><a class="el" href="namespaceos.html#a06b5d831710f3993abe32fbb3ff69f12">os::clone</a></code> after entering a set of namespaces for the specified <code>target</code> process. <a href="#a98bf4d9e11d546326250997a6493f835">More...</a><br/></td></tr>
<tr class="separator:a98bf4d9e11d546326250997a6493f835"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a28116b46e6543597a11733424cd1aa20"><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacens.html#a28116b46e6543597a11733424cd1aa20">stringify</a> (int flags)</td></tr>
<tr class="separator:a28116b46e6543597a11733424cd1aa20"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a98bf4d9e11d546326250997a6493f835"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classTry.html">Try</a>&lt;<a class="el" href="3rdparty_2stout_2include_2stout_2windows_8hpp.html#ab03ced250ed239bc3b50b669493997f9">pid_t</a>&gt; ns::clone </td>
<td>(</td>
<td class="paramtype"><a class="el" href="3rdparty_2stout_2include_2stout_2windows_8hpp.html#ab03ced250ed239bc3b50b669493997f9">pid_t</a>&#160;</td>
<td class="paramname"><em>target</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>nstypes</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const lambda::function&lt; int()&gt; &amp;&#160;</td>
<td class="paramname"><em>f</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>flags</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Performs an <code><a class="el" href="namespaceos.html#a06b5d831710f3993abe32fbb3ff69f12">os::clone</a></code> after entering a set of namespaces for the specified <code>target</code> process. </p>
<p>This function provides two steps of functionality: (1) Enter a set of namespaces via two <code>fork</code> calls. (1) Perform a <code>clone</code> within that set of namespaces.</p>
<p>Step (1) of functionality is similar to the <code>nsenter</code> command line utility. Step (2) allows us to perform a clone that itself might create a nested set of namespaces, which enables us to have nested containers.</p>
<p>Double Fork:</p>
<p>In order to enter a PID namespace we need to do a double fork because doing a <code>setns</code> for a PID namespace only effects future children.</p>
<p>Moreover, attempting to <code>setns</code> before we do any forks and then have the parent <code>setns</code> back to the original namespaces does not work because entering a depriviledged user namespace will not let us reassociate back with the original namespace, even if we keep the file descriptor of the original namespace open.</p>
<p>Because we have to double fork we need to send back the actual PID of the final process that's executing the provided function <code>f</code>. We use domain sockets for this because in the event we've entered a PID namespace we need the kernel to translate the PID to the PID in our PID namespace.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">target</td><td>Target process whose namespaces we should enter. </td></tr>
<tr><td class="paramname">nstypes</td><td>Namespaces we should enter. </td></tr>
<tr><td class="paramname">f</td><td>Function to invoke after entering the namespaces and cloning. </td></tr>
<tr><td class="paramname">flags</td><td>Flags to pass to <code>clone</code>.</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>pid_t</code> of the child process. </dd></dl>
</div>
</div>
<a class="anchor" id="a0f104f8776ccb934a05efeaeeebab328"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classTry.html">Try</a>&lt;ino_t&gt; ns::getns </td>
<td>(</td>
<td class="paramtype"><a class="el" href="3rdparty_2stout_2include_2stout_2windows_8hpp.html#ab03ced250ed239bc3b50b669493997f9">pid_t</a>&#160;</td>
<td class="paramname"><em>pid</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::string &amp;&#160;</td>
<td class="paramname"><em>ns</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a class="anchor" id="aab01ae26d9da2efc741aa838c69db6e2"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">std::set&lt;std::string&gt; ns::namespaces </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a class="anchor" id="a1c4fd4fd04bde294d2d7477dfee8427e"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classTry.html">Try</a>&lt;int&gt; ns::nstype </td>
<td>(</td>
<td class="paramtype">const std::string &amp;&#160;</td>
<td class="paramname"><em>ns</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a class="anchor" id="ae308e5fb79986971a85717365f2258d4"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">std::set&lt;int&gt; ns::nstypes </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a class="anchor" id="aff4db8d452eb5c8f07fba2ceeb5a7d83"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classTry.html">Try</a>&lt;<a class="el" href="structNothing.html">Nothing</a>&gt; ns::setns </td>
<td>(</td>
<td class="paramtype">const std::string &amp;&#160;</td>
<td class="paramname"><em>path</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::string &amp;&#160;</td>
<td class="paramname"><em>ns</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool&#160;</td>
<td class="paramname"><em>checkMultithreaded</em> = <code>true</code>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a class="anchor" id="a7e58011de0d8219645c27912fc3bc8f4"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classTry.html">Try</a>&lt;<a class="el" href="structNothing.html">Nothing</a>&gt; ns::setns </td>
<td>(</td>
<td class="paramtype"><a class="el" href="3rdparty_2stout_2include_2stout_2windows_8hpp.html#ab03ced250ed239bc3b50b669493997f9">pid_t</a>&#160;</td>
<td class="paramname"><em>pid</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::string &amp;&#160;</td>
<td class="paramname"><em>ns</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a class="anchor" id="a28116b46e6543597a11733424cd1aa20"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">std::string ns::stringify </td>
<td>(</td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>flags</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.5
</small></address>
</body>
</html>