1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>media open()</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API"><link rel="up" href="media-user-func.html" title="Appendix&#160;L.&#160;Function Reference"><link rel="prev" href="media-user-func.html" title="Appendix&#160;L.&#160;Function Reference"><link rel="next" href="media-func-close.html" title="media close()"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">media open()</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="media-user-func.html">Prev</a>&#160;</td><th width="60%" align="center">Appendix&#160;L.&#160;Function Reference</th><td width="20%" align="right">&#160;<a accesskey="n" href="media-func-close.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="media-func-open"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>media-open &#8212; Open a media device</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;fcntl.h&gt;</pre><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">open</b>(</code></td><td>const char *<var class="pdparam">device_name</var>, </td></tr><tr><td>&#160;</td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1134071092"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>device_name</code></em></span></dt><dd><p>Device to be opened.</p></dd><dt><span class="term"><em class="parameter"><code>flags</code></em></span></dt><dd><p>Open flags. Access mode must be either <code class="constant">O_RDONLY</code>
2	  or <code class="constant">O_RDWR</code>. Other flags have no effect.</p></dd></dl></div></div><div class="refsect1"><a name="idp1134074164"></a><h2>Description</h2><p>To open a media device applications call <code class="function">open()</code>
3    with the desired device name. The function has no side effects; the device
4    configuration remain unchanged.</p><p>When the device is opened in read-only mode, attemps to modify its
5    configuration will result in an error, and <code class="varname">errno</code> will be
6    set to <span class="errorcode">EBADF</span>.</p></div><div class="refsect1"><a name="idp1134076164"></a><h2>Return Value</h2><p><code class="function">open</code> returns the new file descriptor on success.
7    On error, -1 is returned, and <code class="varname">errno</code> is set appropriately.
8    Possible error codes are:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">EACCES</span></span></dt><dd><p>The requested access to the file is not allowed.</p></dd><dt><span class="term"><span class="errorcode">EMFILE</span></span></dt><dd><p>The  process  already  has  the  maximum number of files open.
9	  </p></dd><dt><span class="term"><span class="errorcode">ENFILE</span></span></dt><dd><p>The system limit on the total number of open files has been
10	  reached.</p></dd><dt><span class="term"><span class="errorcode">ENOMEM</span></span></dt><dd><p>Insufficient kernel memory was available.</p></dd><dt><span class="term"><span class="errorcode">ENXIO</span></span></dt><dd><p>No device corresponding to this device special file exists.
11	  </p></dd></dl></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="media-user-func.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="media-user-func.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="media-func-close.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix&#160;L.&#160;Function Reference&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;media close()</td></tr></table></div></body></html>
12