media-func-open.xml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <refentry id="media-func-open">
  2. <refmeta>
  3. <refentrytitle>media open()</refentrytitle>
  4. &manvol;
  5. </refmeta>
  6. <refnamediv>
  7. <refname>media-open</refname>
  8. <refpurpose>Open a media device</refpurpose>
  9. </refnamediv>
  10. <refsynopsisdiv>
  11. <funcsynopsis>
  12. <funcsynopsisinfo>#include &lt;fcntl.h&gt;</funcsynopsisinfo>
  13. <funcprototype>
  14. <funcdef>int <function>open</function></funcdef>
  15. <paramdef>const char *<parameter>device_name</parameter></paramdef>
  16. <paramdef>int <parameter>flags</parameter></paramdef>
  17. </funcprototype>
  18. </funcsynopsis>
  19. </refsynopsisdiv>
  20. <refsect1>
  21. <title>Arguments</title>
  22. <variablelist>
  23. <varlistentry>
  24. <term><parameter>device_name</parameter></term>
  25. <listitem>
  26. <para>Device to be opened.</para>
  27. </listitem>
  28. </varlistentry>
  29. <varlistentry>
  30. <term><parameter>flags</parameter></term>
  31. <listitem>
  32. <para>Open flags. Access mode must be either <constant>O_RDONLY</constant>
  33. or <constant>O_RDWR</constant>. Other flags have no effect.</para>
  34. </listitem>
  35. </varlistentry>
  36. </variablelist>
  37. </refsect1>
  38. <refsect1>
  39. <title>Description</title>
  40. <para>To open a media device applications call <function>open()</function>
  41. with the desired device name. The function has no side effects; the device
  42. configuration remain unchanged.</para>
  43. <para>When the device is opened in read-only mode, attempts to modify its
  44. configuration will result in an error, and <varname>errno</varname> will be
  45. set to <errorcode>EBADF</errorcode>.</para>
  46. </refsect1>
  47. <refsect1>
  48. <title>Return Value</title>
  49. <para><function>open</function> returns the new file descriptor on success.
  50. On error, -1 is returned, and <varname>errno</varname> is set appropriately.
  51. Possible error codes are:</para>
  52. <variablelist>
  53. <varlistentry>
  54. <term><errorcode>EACCES</errorcode></term>
  55. <listitem>
  56. <para>The requested access to the file is not allowed.</para>
  57. </listitem>
  58. </varlistentry>
  59. <varlistentry>
  60. <term><errorcode>EMFILE</errorcode></term>
  61. <listitem>
  62. <para>The process already has the maximum number of files open.
  63. </para>
  64. </listitem>
  65. </varlistentry>
  66. <varlistentry>
  67. <term><errorcode>ENFILE</errorcode></term>
  68. <listitem>
  69. <para>The system limit on the total number of open files has been
  70. reached.</para>
  71. </listitem>
  72. </varlistentry>
  73. <varlistentry>
  74. <term><errorcode>ENOMEM</errorcode></term>
  75. <listitem>
  76. <para>Insufficient kernel memory was available.</para>
  77. </listitem>
  78. </varlistentry>
  79. <varlistentry>
  80. <term><errorcode>ENXIO</errorcode></term>
  81. <listitem>
  82. <para>No device corresponding to this device special file exists.
  83. </para>
  84. </listitem>
  85. </varlistentry>
  86. </variablelist>
  87. </refsect1>
  88. </refentry>