mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 05:55:46 +08:00
Clean up some naming: fd vs. fildes vs. filedes and filep vs filp
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
<h1><big><font color="#3c34ec">
|
<h1><big><font color="#3c34ec">
|
||||||
<i>NuttX RTOS Porting Guide</i>
|
<i>NuttX RTOS Porting Guide</i>
|
||||||
</font></big></h1>
|
</font></big></h1>
|
||||||
<p>Last Updated: August 13, 2013</p>
|
<p>Last Updated: September 28, 2013</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -2806,13 +2806,13 @@ extern void up_ledoff(int led);
|
|||||||
Each character device driver must implement an instance of <code>struct file_operations</code>.
|
Each character device driver must implement an instance of <code>struct file_operations</code>.
|
||||||
That structure defines a call table with the following methods:
|
That structure defines a call table with the following methods:
|
||||||
<ul>
|
<ul>
|
||||||
<p><code>int open(FAR struct file *filp);</code><br>
|
<p><code>int open(FAR struct file *filep);</code><br>
|
||||||
<code>int close(FAR struct file *filp);</code><br>
|
<code>int close(FAR struct file *filep);</code><br>
|
||||||
<code>ssize_t read(FAR struct file *filp, FAR char *buffer, size_t buflen);</code><br>
|
<code>ssize_t read(FAR struct file *filep, FAR char *buffer, size_t buflen);</code><br>
|
||||||
<code>ssize_t write(FAR struct file *filp, FAR const char *buffer, size_t buflen);</code><br>
|
<code>ssize_t write(FAR struct file *filep, FAR const char *buffer, size_t buflen);</code><br>
|
||||||
<code>off_t seek(FAR struct file *filp, off_t offset, int whence);</code><br>
|
<code>off_t seek(FAR struct file *filep, off_t offset, int whence);</code><br>
|
||||||
<code>int ioctl(FAR struct file *filp, int cmd, unsigned long arg);</code><br>
|
<code>int ioctl(FAR struct file *filep, int cmd, unsigned long arg);</code><br>
|
||||||
<code>int poll(FAR struct file *filp, struct pollfd *fds, bool setup);</code></p>
|
<code>int poll(FAR struct file *filep, struct pollfd *fds, bool setup);</code></p>
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
+302
-302
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* c5471/c5471_watchdog.c
|
* arch/arm/src/c5471/c5471_watchdog.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007, 2009, 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007, 2009, 2012-2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -100,7 +100,7 @@ static int wdt_open(struct file *filep);
|
|||||||
static int wdt_close(struct file *filep);
|
static int wdt_close(struct file *filep);
|
||||||
static ssize_t wdt_read(struct file *filep, char *buffer, size_t buflen);
|
static ssize_t wdt_read(struct file *filep, char *buffer, size_t buflen);
|
||||||
static ssize_t wdt_write(struct file *filep, const char *buffer, size_t buflen);
|
static ssize_t wdt_write(struct file *filep, const char *buffer, size_t buflen);
|
||||||
static int wdt_ioctl(FAR struct file *filp, int cmd, unsigned long arg);
|
static int wdt_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
@@ -190,7 +190,7 @@ static int wdt_setusec(uint32_t usec)
|
|||||||
if (divisor >= 0x10000)
|
if (divisor >= 0x10000)
|
||||||
{
|
{
|
||||||
if (prescaler == MAX_PRESCALER)
|
if (prescaler == MAX_PRESCALER)
|
||||||
{
|
{
|
||||||
/* This is the max possible ~2.5 seconds. */
|
/* This is the max possible ~2.5 seconds. */
|
||||||
|
|
||||||
dbg("prescaler=0x%x too big!\n", prescaler);
|
dbg("prescaler=0x%x too big!\n", prescaler);
|
||||||
@@ -289,7 +289,7 @@ static ssize_t wdt_write(struct file *filep, const char *buffer, size_t buflen)
|
|||||||
* Name: wdt_ioctl
|
* Name: wdt_ioctl
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
static int wdt_ioctl(FAR struct file *filp, int cmd, unsigned long arg)
|
static int wdt_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
dbg("ioctl Call: cmd=0x%x arg=0x%x", cmd, arg);
|
dbg("ioctl Call: cmd=0x%x arg=0x%x", cmd, arg);
|
||||||
|
|
||||||
|
|||||||
@@ -104,14 +104,14 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg)
|
|||||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||||
{
|
{
|
||||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||||
if (filep->fs_filedes >= 0)
|
if (filep->fs_fd >= 0)
|
||||||
{
|
{
|
||||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||||
sdbg(" fd=%d nbytes=%d\n",
|
sdbg(" fd=%d nbytes=%d\n",
|
||||||
filep->fs_filedes,
|
filep->fs_fd,
|
||||||
filep->fs_bufpos - filep->fs_bufstart);
|
filep->fs_bufpos - filep->fs_bufstart);
|
||||||
#else
|
#else
|
||||||
sdbg(" fd=%d\n", filep->fs_filedes);
|
sdbg(" fd=%d\n", filep->fs_fd);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+101
-101
@@ -1,101 +1,101 @@
|
|||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* arch/arm/src/arm/lpc2378/lpc23xx_head.S
|
* arch/arm/src/arm/lpc2378/lpc23xx_head.S
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Rommel Marcelo. All rights reserved.
|
* Copyright (C) 2010 Rommel Marcelo. All rights reserved.
|
||||||
* Author: Rommel Marcelo
|
* Author: Rommel Marcelo
|
||||||
*
|
*
|
||||||
* This file is part of the NuttX RTOS:
|
* This file is part of the NuttX RTOS:
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* notice, this list of conditions and the following disclaimer in
|
||||||
* the documentation and/or other materials provided with the
|
* the documentation and/or other materials provided with the
|
||||||
* distribution.
|
* distribution.
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
* used to endorse or promote products derived from this software
|
* used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Included files
|
* Included files
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
#include "up_arch.h"
|
#include "up_arch.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "lpc23xx_scb.h"
|
#include "lpc23xx_scb.h"
|
||||||
#include "lpc23xx_pinsel.h"
|
#include "lpc23xx_pinsel.h"
|
||||||
#include "lpc23xx_uart.h"
|
#include "lpc23xx_uart.h"
|
||||||
#include "lpc23xx_gpio.h"
|
#include "lpc23xx_gpio.h"
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Definitions
|
* Definitions
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Name: IO_Init()
|
* Name: IO_Init()
|
||||||
*
|
*
|
||||||
* Descriptions: Initialize the target board before running the main()
|
* Descriptions: Initialize the target board before running the main()
|
||||||
*
|
*
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void IO_Init( void )
|
void IO_Init( void )
|
||||||
{
|
{
|
||||||
uint32_t regval;
|
uint32_t regval;
|
||||||
|
|
||||||
/* Reset all GPIO pins to default */
|
/* Reset all GPIO pins to default */
|
||||||
|
|
||||||
pinsel_putreg(0, PINSEL0_OFFSET);
|
pinsel_putreg(0, PINSEL0_OFFSET);
|
||||||
pinsel_putreg(0, PINSEL1_OFFSET);
|
pinsel_putreg(0, PINSEL1_OFFSET);
|
||||||
pinsel_putreg(0, PINSEL2_OFFSET);
|
pinsel_putreg(0, PINSEL2_OFFSET);
|
||||||
pinsel_putreg(0, PINSEL3_OFFSET);
|
pinsel_putreg(0, PINSEL3_OFFSET);
|
||||||
pinsel_putreg(0, PINSEL4_OFFSET);
|
pinsel_putreg(0, PINSEL4_OFFSET);
|
||||||
pinsel_putreg(0, PINSEL5_OFFSET);
|
pinsel_putreg(0, PINSEL5_OFFSET);
|
||||||
pinsel_putreg(0, PINSEL6_OFFSET);
|
pinsel_putreg(0, PINSEL6_OFFSET);
|
||||||
pinsel_putreg(0, PINSEL7_OFFSET);
|
pinsel_putreg(0, PINSEL7_OFFSET);
|
||||||
pinsel_putreg(0, PINSEL8_OFFSET);
|
pinsel_putreg(0, PINSEL8_OFFSET);
|
||||||
pinsel_putreg(0, PINSEL9_OFFSET);
|
pinsel_putreg(0, PINSEL9_OFFSET);
|
||||||
pinsel_putreg(0, PINSEL10_OFFSET);
|
pinsel_putreg(0, PINSEL10_OFFSET);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
regval = scb_getreg(SCB_PCONP_OFFSET) & ~(PCSDC | PCUART1 | PCI2C0 | PCSSP1 | PCEMC | );
|
regval = scb_getreg(SCB_PCONP_OFFSET) & ~(PCSDC | PCUART1 | PCI2C0 | PCSSP1 | PCEMC | );
|
||||||
scb_getreg(regval, SCB_PCONP_OFFSET );
|
scb_getreg(regval, SCB_PCONP_OFFSET );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Turn off all peripheral power */
|
/* Turn off all peripheral power */
|
||||||
|
|
||||||
scb_putreg(0, SCB_PCONP_OFFSET );
|
scb_putreg(0, SCB_PCONP_OFFSET );
|
||||||
|
|
||||||
/* Turn on UART0/2 / Timer0 */
|
/* Turn on UART0/2 / Timer0 */
|
||||||
/* regval = PCUART0 | PCUART2 | PCTIM0 | PCRTC ; */
|
/* regval = PCUART0 | PCUART2 | PCTIM0 | PCRTC ; */
|
||||||
|
|
||||||
regval = PCUART0 | PCUART2 | PCTIM0 ;
|
regval = PCUART0 | PCUART2 | PCTIM0 ;
|
||||||
scb_putreg(regval , SCB_PCONP_OFFSET );
|
scb_putreg(regval , SCB_PCONP_OFFSET );
|
||||||
|
|
||||||
/* Status LED P1.19 */
|
/* Status LED P1.19 */
|
||||||
|
|
||||||
dir_putreg8((1 << 3), FIO1DIR2_OFFSET);
|
dir_putreg8((1 << 3), FIO1DIR2_OFFSET);
|
||||||
|
|
||||||
/* other io setup here */
|
/* other io setup here */
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,14 +104,14 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg)
|
|||||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||||
{
|
{
|
||||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||||
if (filep->fs_filedes >= 0)
|
if (filep->fs_fd >= 0)
|
||||||
{
|
{
|
||||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||||
sdbg(" fd=%d nbytes=%d\n",
|
sdbg(" fd=%d nbytes=%d\n",
|
||||||
filep->fs_filedes,
|
filep->fs_fd,
|
||||||
filep->fs_bufpos - filep->fs_bufstart);
|
filep->fs_bufpos - filep->fs_bufstart);
|
||||||
#else
|
#else
|
||||||
sdbg(" fd=%d\n", filep->fs_filedes);
|
sdbg(" fd=%d\n", filep->fs_fd);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,14 +104,14 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg)
|
|||||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||||
{
|
{
|
||||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||||
if (filep->fs_filedes >= 0)
|
if (filep->fs_fd >= 0)
|
||||||
{
|
{
|
||||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||||
sdbg(" fd=%d nbytes=%d\n",
|
sdbg(" fd=%d nbytes=%d\n",
|
||||||
filep->fs_filedes,
|
filep->fs_fd,
|
||||||
filep->fs_bufpos - filep->fs_bufstart);
|
filep->fs_bufpos - filep->fs_bufstart);
|
||||||
#else
|
#else
|
||||||
sdbg(" fd=%d\n", filep->fs_filedes);
|
sdbg(" fd=%d\n", filep->fs_fd);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,14 +106,14 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg)
|
|||||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||||
{
|
{
|
||||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||||
if (filep->fs_filedes >= 0)
|
if (filep->fs_fd >= 0)
|
||||||
{
|
{
|
||||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||||
sdbg(" fd=%d nbytes=%d\n",
|
sdbg(" fd=%d nbytes=%d\n",
|
||||||
filep->fs_filedes,
|
filep->fs_fd,
|
||||||
filep->fs_bufpos - filep->fs_bufstart);
|
filep->fs_bufpos - filep->fs_bufstart);
|
||||||
#else
|
#else
|
||||||
sdbg(" fd=%d\n", filep->fs_filedes);
|
sdbg(" fd=%d\n", filep->fs_fd);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -49,16 +49,17 @@
|
|||||||
#include <rgmp/string.h>
|
#include <rgmp/string.h>
|
||||||
#include <rgmp/stdio.h>
|
#include <rgmp/stdio.h>
|
||||||
|
|
||||||
struct bridge {
|
struct bridge
|
||||||
|
{
|
||||||
struct rgmp_bridge *b;
|
struct rgmp_bridge *b;
|
||||||
sem_t rd_lock;
|
sem_t rd_lock;
|
||||||
sem_t wr_lock;
|
sem_t wr_lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
static ssize_t up_bridge_read(struct file *filp, char *buffer, size_t len)
|
static ssize_t up_bridge_read(struct file *filep, char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
struct bridge *b = filp->f_inode->i_private;
|
struct bridge *b = filep->f_inode->i_private;
|
||||||
|
|
||||||
sem_wait(&b->rd_lock);
|
sem_wait(&b->rd_lock);
|
||||||
ret = rgmp_bridge_read(b->b, buffer, len, 0);
|
ret = rgmp_bridge_read(b->b, buffer, len, 0);
|
||||||
@@ -66,10 +67,10 @@ static ssize_t up_bridge_read(struct file *filp, char *buffer, size_t len)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t up_bridge_write(struct file *filp, const char *buffer, size_t len)
|
static ssize_t up_bridge_write(struct file *filep, const char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
struct bridge *b = filp->f_inode->i_private;
|
struct bridge *b = filep->f_inode->i_private;
|
||||||
|
|
||||||
sem_wait(&b->wr_lock);
|
sem_wait(&b->wr_lock);
|
||||||
ret = rgmp_bridge_write(b->b, (char *)buffer, len, 0);
|
ret = rgmp_bridge_write(b->b, (char *)buffer, len, 0);
|
||||||
@@ -77,17 +78,18 @@ static ssize_t up_bridge_write(struct file *filp, const char *buffer, size_t len
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int up_bridge_open(struct file *filp)
|
static int up_bridge_open(struct file *filep)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int up_bridge_close(struct file *filp)
|
static int up_bridge_close(struct file *filep)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct file_operations up_bridge_fops = {
|
static const struct file_operations up_bridge_fops =
|
||||||
|
{
|
||||||
.read = up_bridge_read,
|
.read = up_bridge_read,
|
||||||
.write = up_bridge_write,
|
.write = up_bridge_write,
|
||||||
.open = up_bridge_open,
|
.open = up_bridge_open,
|
||||||
@@ -127,5 +129,3 @@ err1:
|
|||||||
err0:
|
err0:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -105,14 +105,14 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg)
|
|||||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||||
{
|
{
|
||||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||||
if (filep->fs_filedes >= 0)
|
if (filep->fs_fd >= 0)
|
||||||
{
|
{
|
||||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||||
sdbg(" fd=%d nbytes=%d\n",
|
sdbg(" fd=%d nbytes=%d\n",
|
||||||
filep->fs_filedes,
|
filep->fs_fd,
|
||||||
filep->fs_bufpos - filep->fs_bufstart);
|
filep->fs_bufpos - filep->fs_bufstart);
|
||||||
#else
|
#else
|
||||||
sdbg(" fd=%d\n", filep->fs_filedes);
|
sdbg(" fd=%d\n", filep->fs_fd);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* up_devconsole.c
|
* arch/sim/src/up_devconsole.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -78,12 +78,12 @@ static const struct file_operations devconsole_fops =
|
|||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t devconsole_read(struct file *filp, char *buffer, size_t len)
|
static ssize_t devconsole_read(struct file *filep, char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
return up_hostread(buffer, len);
|
return up_hostread(buffer, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t devconsole_write(struct file *filp, const char *buffer, size_t len)
|
static ssize_t devconsole_write(struct file *filep, const char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
return up_hostwrite(buffer, len);
|
return up_hostwrite(buffer, len);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,14 +104,14 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg)
|
|||||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||||
{
|
{
|
||||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||||
if (filep->fs_filedes >= 0)
|
if (filep->fs_fd >= 0)
|
||||||
{
|
{
|
||||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||||
sdbg(" fd=%d nbytes=%d\n",
|
sdbg(" fd=%d nbytes=%d\n",
|
||||||
filep->fs_filedes,
|
filep->fs_fd,
|
||||||
filep->fs_bufpos - filep->fs_bufstart);
|
filep->fs_bufpos - filep->fs_bufstart);
|
||||||
#else
|
#else
|
||||||
sdbg(" fd=%d\n", filep->fs_filedes);
|
sdbg(" fd=%d\n", filep->fs_fd);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,14 +106,14 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg)
|
|||||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||||
{
|
{
|
||||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||||
if (filep->fs_filedes >= 0)
|
if (filep->fs_fd >= 0)
|
||||||
{
|
{
|
||||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||||
lldbg(" fd=%d nbytes=%d\n",
|
lldbg(" fd=%d nbytes=%d\n",
|
||||||
filep->fs_filedes,
|
filep->fs_fd,
|
||||||
filep->fs_bufpos - filep->fs_bufstart);
|
filep->fs_bufpos - filep->fs_bufstart);
|
||||||
#else
|
#else
|
||||||
lldbg(" fd=%d\n", filep->fs_filedes);
|
lldbg(" fd=%d\n", filep->fs_fd);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,14 +107,14 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg)
|
|||||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||||
{
|
{
|
||||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||||
if (filep->fs_filedes >= 0)
|
if (filep->fs_fd >= 0)
|
||||||
{
|
{
|
||||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||||
lldbg(" fd=%d nbytes=%d\n",
|
lldbg(" fd=%d nbytes=%d\n",
|
||||||
filep->fs_filedes,
|
filep->fs_fd,
|
||||||
filep->fs_bufpos - filep->fs_bufstart);
|
filep->fs_bufpos - filep->fs_bufstart);
|
||||||
#else
|
#else
|
||||||
lldbg(" fd=%d\n", filep->fs_filedes);
|
lldbg(" fd=%d\n", filep->fs_fd);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,9 +198,9 @@ static void lcd_action(enum slcdcode_e code, uint8_t count);
|
|||||||
|
|
||||||
static ssize_t lcd_read(FAR struct file *, FAR char *, size_t);
|
static ssize_t lcd_read(FAR struct file *, FAR char *, size_t);
|
||||||
static ssize_t lcd_write(FAR struct file *, FAR const char *, size_t);
|
static ssize_t lcd_write(FAR struct file *, FAR const char *, size_t);
|
||||||
static int lcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg);
|
static int lcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
static int lcd_poll(FAR struct file *filp, FAR struct pollfd *fds, bool setup);
|
static int lcd_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -662,14 +662,14 @@ static void lcd_action(enum slcdcode_e code, uint8_t count)
|
|||||||
* Name: lcd_read
|
* Name: lcd_read
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t lcd_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
static ssize_t lcd_read(FAR struct file *filep, FAR char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
uint8_t row;
|
uint8_t row;
|
||||||
uint8_t column;
|
uint8_t column;
|
||||||
int nread;
|
int nread;
|
||||||
|
|
||||||
/* Try to read the entire display. Notice that the seek offset
|
/* Try to read the entire display. Notice that the seek offset
|
||||||
* (filp->f_pos) is ignored. It probably should be taken into account
|
* (filep->f_pos) is ignored. It probably should be taken into account
|
||||||
* and also updated after each read and write.
|
* and also updated after each read and write.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -696,7 +696,7 @@ static ssize_t lcd_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
|||||||
* Name: lcd_write
|
* Name: lcd_write
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t lcd_write(FAR struct file *filp, FAR const char *buffer,
|
static ssize_t lcd_write(FAR struct file *filep, FAR const char *buffer,
|
||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
struct lcd_instream_s instream;
|
struct lcd_instream_s instream;
|
||||||
@@ -781,7 +781,7 @@ static ssize_t lcd_write(FAR struct file *filp, FAR const char *buffer,
|
|||||||
* Name: lcd_ioctl
|
* Name: lcd_ioctl
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int lcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg)
|
static int lcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
@@ -851,7 +851,7 @@ static int lcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
static int lcd_poll(FAR struct file *filp, FAR struct pollfd *fds,
|
static int lcd_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||||
bool setup)
|
bool setup)
|
||||||
{
|
{
|
||||||
if (setup)
|
if (setup)
|
||||||
|
|||||||
@@ -321,9 +321,9 @@ static void slcd_action(enum slcdcode_e code, uint8_t count);
|
|||||||
|
|
||||||
static ssize_t slcd_read(FAR struct file *, FAR char *, size_t);
|
static ssize_t slcd_read(FAR struct file *, FAR char *, size_t);
|
||||||
static ssize_t slcd_write(FAR struct file *, FAR const char *, size_t);
|
static ssize_t slcd_write(FAR struct file *, FAR const char *, size_t);
|
||||||
static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg);
|
static int slcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
static int slcd_poll(FAR struct file *filp, FAR struct pollfd *fds, bool setup);
|
static int slcd_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -856,13 +856,13 @@ static void slcd_action(enum slcdcode_e code, uint8_t count)
|
|||||||
* Name: slcd_read
|
* Name: slcd_read
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t slcd_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
static ssize_t slcd_read(FAR struct file *filep, FAR char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Try to read the entire display. Notice that the seek offset
|
/* Try to read the entire display. Notice that the seek offset
|
||||||
* (filp->f_pos) is ignored. It probably should be taken into account
|
* (filep->f_pos) is ignored. It probably should be taken into account
|
||||||
* and also updated after each read and write.
|
* and also updated after each read and write.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -892,7 +892,7 @@ static ssize_t slcd_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
|||||||
* Name: slcd_write
|
* Name: slcd_write
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t slcd_write(FAR struct file *filp,
|
static ssize_t slcd_write(FAR struct file *filep,
|
||||||
FAR const char *buffer, size_t len)
|
FAR const char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
struct slcd_instream_s instream;
|
struct slcd_instream_s instream;
|
||||||
@@ -1006,7 +1006,7 @@ static ssize_t slcd_write(FAR struct file *filp,
|
|||||||
* Name: slcd_poll
|
* Name: slcd_poll
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg)
|
static int slcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
@@ -1156,7 +1156,7 @@ static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
static int slcd_poll(FAR struct file *filp, FAR struct pollfd *fds,
|
static int slcd_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||||
bool setup)
|
bool setup)
|
||||||
{
|
{
|
||||||
if (setup)
|
if (setup)
|
||||||
|
|||||||
@@ -323,9 +323,9 @@ static void slcd_action(enum slcdcode_e code, uint8_t count);
|
|||||||
|
|
||||||
static ssize_t slcd_read(FAR struct file *, FAR char *, size_t);
|
static ssize_t slcd_read(FAR struct file *, FAR char *, size_t);
|
||||||
static ssize_t slcd_write(FAR struct file *, FAR const char *, size_t);
|
static ssize_t slcd_write(FAR struct file *, FAR const char *, size_t);
|
||||||
static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg);
|
static int slcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
static int slcd_poll(FAR struct file *filp, FAR struct pollfd *fds, bool setup);
|
static int slcd_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -1085,13 +1085,13 @@ static void slcd_action(enum slcdcode_e code, uint8_t count)
|
|||||||
* Name: slcd_read
|
* Name: slcd_read
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t slcd_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
static ssize_t slcd_read(FAR struct file *filep, FAR char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Try to read the entire display. Notice that the seek offset
|
/* Try to read the entire display. Notice that the seek offset
|
||||||
* (filp->f_pos) is ignored. It probably should be taken into account
|
* (filep->f_pos) is ignored. It probably should be taken into account
|
||||||
* and also updated after each read and write.
|
* and also updated after each read and write.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -1127,7 +1127,7 @@ static ssize_t slcd_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
|||||||
* Name: slcd_write
|
* Name: slcd_write
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t slcd_write(FAR struct file *filp,
|
static ssize_t slcd_write(FAR struct file *filep,
|
||||||
FAR const char *buffer, size_t len)
|
FAR const char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
struct slcd_instream_s instream;
|
struct slcd_instream_s instream;
|
||||||
@@ -1314,7 +1314,7 @@ static ssize_t slcd_write(FAR struct file *filp,
|
|||||||
* Name: slcd_poll
|
* Name: slcd_poll
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg)
|
static int slcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
@@ -1457,7 +1457,7 @@ static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
static int slcd_poll(FAR struct file *filp, FAR struct pollfd *fds,
|
static int slcd_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||||
bool setup)
|
bool setup)
|
||||||
{
|
{
|
||||||
if (setup)
|
if (setup)
|
||||||
|
|||||||
@@ -207,9 +207,9 @@ static void lcd_action(enum slcdcode_e code, uint8_t count);
|
|||||||
|
|
||||||
static ssize_t lcd_read(FAR struct file *, FAR char *, size_t);
|
static ssize_t lcd_read(FAR struct file *, FAR char *, size_t);
|
||||||
static ssize_t lcd_write(FAR struct file *, FAR const char *, size_t);
|
static ssize_t lcd_write(FAR struct file *, FAR const char *, size_t);
|
||||||
static int lcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg);
|
static int lcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
static int lcd_poll(FAR struct file *filp, FAR struct pollfd *fds, bool setup);
|
static int lcd_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -817,14 +817,14 @@ static void lcd_action(enum slcdcode_e code, uint8_t count)
|
|||||||
* Name: lcd_read
|
* Name: lcd_read
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t lcd_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
static ssize_t lcd_read(FAR struct file *filep, FAR char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
uint8_t row;
|
uint8_t row;
|
||||||
uint8_t column;
|
uint8_t column;
|
||||||
int nread;
|
int nread;
|
||||||
|
|
||||||
/* Try to read the entire display. Notice that the seek offset
|
/* Try to read the entire display. Notice that the seek offset
|
||||||
* (filp->f_pos) is ignored. It probably should be taken into account
|
* (filep->f_pos) is ignored. It probably should be taken into account
|
||||||
* and also updated after each read and write.
|
* and also updated after each read and write.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -851,7 +851,7 @@ static ssize_t lcd_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
|||||||
* Name: lcd_write
|
* Name: lcd_write
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t lcd_write(FAR struct file *filp, FAR const char *buffer,
|
static ssize_t lcd_write(FAR struct file *filep, FAR const char *buffer,
|
||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
struct lcd_instream_s instream;
|
struct lcd_instream_s instream;
|
||||||
@@ -936,7 +936,7 @@ static ssize_t lcd_write(FAR struct file *filp, FAR const char *buffer,
|
|||||||
* Name: lcd_ioctl
|
* Name: lcd_ioctl
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int lcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg)
|
static int lcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
@@ -1041,7 +1041,7 @@ static int lcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
static int lcd_poll(FAR struct file *filp, FAR struct pollfd *fds,
|
static int lcd_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||||
bool setup)
|
bool setup)
|
||||||
{
|
{
|
||||||
if (setup)
|
if (setup)
|
||||||
|
|||||||
@@ -475,7 +475,7 @@ int devsif_close(FAR struct file *filep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ssize_t devsif_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
static ssize_t devsif_read(FAR struct file *filep, FAR char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
sif_sem_wait();
|
sif_sem_wait();
|
||||||
memset(buffer, 0, len);
|
memset(buffer, 0, len);
|
||||||
@@ -484,7 +484,7 @@ static ssize_t devsif_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ssize_t devsif_write(FAR struct file *filp, FAR const char *buffer, size_t len)
|
static ssize_t devsif_write(FAR struct file *filep, FAR const char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
sif_sem_wait();
|
sif_sem_wait();
|
||||||
printf("getpid: %d\n", getpid() );
|
printf("getpid: %d\n", getpid() );
|
||||||
@@ -494,7 +494,7 @@ static ssize_t devsif_write(FAR struct file *filp, FAR const char *buffer, size_
|
|||||||
|
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
static int devsif_poll(FAR struct file *filp, FAR struct pollfd *fds,
|
static int devsif_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||||
bool setup)
|
bool setup)
|
||||||
{
|
{
|
||||||
if (setup) {
|
if (setup) {
|
||||||
|
|||||||
+22
-19
@@ -68,11 +68,14 @@
|
|||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int bch_open(FAR struct file *filp);
|
static int bch_open(FAR struct file *filep);
|
||||||
static int bch_close(FAR struct file *filp);
|
static int bch_close(FAR struct file *filep);
|
||||||
static ssize_t bch_read(FAR struct file *, FAR char *, size_t);
|
static ssize_t bch_read(FAR struct file *filep, FAR char *buffer,
|
||||||
static ssize_t bch_write(FAR struct file *, FAR const char *, size_t);
|
size_t buflen);
|
||||||
static int bch_ioctl(FAR struct file *filp, int cmd, unsigned long arg);
|
static ssize_t bch_write(FAR struct file *filep, FAR const char *buffer,
|
||||||
|
size_t buflen);
|
||||||
|
static int bch_ioctl(FAR struct file *filep, int cmd,
|
||||||
|
unsigned long arg);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
@@ -102,9 +105,9 @@ const struct file_operations bch_fops =
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int bch_open(FAR struct file *filp)
|
static int bch_open(FAR struct file *filep)
|
||||||
{
|
{
|
||||||
FAR struct inode *inode = filp->f_inode;
|
FAR struct inode *inode = filep->f_inode;
|
||||||
FAR struct bchlib_s *bch;
|
FAR struct bchlib_s *bch;
|
||||||
|
|
||||||
DEBUGASSERT(inode && inode->i_private);
|
DEBUGASSERT(inode && inode->i_private);
|
||||||
@@ -133,9 +136,9 @@ static int bch_open(FAR struct file *filp)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int bch_close(FAR struct file *filp)
|
static int bch_close(FAR struct file *filep)
|
||||||
{
|
{
|
||||||
FAR struct inode *inode = filp->f_inode;
|
FAR struct inode *inode = filep->f_inode;
|
||||||
FAR struct bchlib_s *bch;
|
FAR struct bchlib_s *bch;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
@@ -168,9 +171,9 @@ static int bch_close(FAR struct file *filp)
|
|||||||
* Name:bch_read
|
* Name:bch_read
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t bch_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
static ssize_t bch_read(FAR struct file *filep, FAR char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
FAR struct inode *inode = filp->f_inode;
|
FAR struct inode *inode = filep->f_inode;
|
||||||
FAR struct bchlib_s *bch;
|
FAR struct bchlib_s *bch;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -178,10 +181,10 @@ static ssize_t bch_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
|||||||
bch = (FAR struct bchlib_s *)inode->i_private;
|
bch = (FAR struct bchlib_s *)inode->i_private;
|
||||||
|
|
||||||
bchlib_semtake(bch);
|
bchlib_semtake(bch);
|
||||||
ret = bchlib_read(bch, buffer, filp->f_pos, len);
|
ret = bchlib_read(bch, buffer, filep->f_pos, len);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
filp->f_pos += len;
|
filep->f_pos += len;
|
||||||
}
|
}
|
||||||
bchlib_semgive(bch);
|
bchlib_semgive(bch);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -191,9 +194,9 @@ static ssize_t bch_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
|||||||
* Name:bch_write
|
* Name:bch_write
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t bch_write(FAR struct file *filp, FAR const char *buffer, size_t len)
|
static ssize_t bch_write(FAR struct file *filep, FAR const char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
FAR struct inode *inode = filp->f_inode;
|
FAR struct inode *inode = filep->f_inode;
|
||||||
FAR struct bchlib_s *bch;
|
FAR struct bchlib_s *bch;
|
||||||
int ret = -EACCES;
|
int ret = -EACCES;
|
||||||
|
|
||||||
@@ -203,10 +206,10 @@ static ssize_t bch_write(FAR struct file *filp, FAR const char *buffer, size_t l
|
|||||||
if (!bch->readonly)
|
if (!bch->readonly)
|
||||||
{
|
{
|
||||||
bchlib_semtake(bch);
|
bchlib_semtake(bch);
|
||||||
ret = bchlib_write(bch, buffer, filp->f_pos, len);
|
ret = bchlib_write(bch, buffer, filep->f_pos, len);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
filp->f_pos += len;
|
filep->f_pos += len;
|
||||||
}
|
}
|
||||||
bchlib_semgive(bch);
|
bchlib_semgive(bch);
|
||||||
}
|
}
|
||||||
@@ -221,9 +224,9 @@ static ssize_t bch_write(FAR struct file *filp, FAR const char *buffer, size_t l
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int bch_ioctl(FAR struct file *filp, int cmd, unsigned long arg)
|
static int bch_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
FAR struct inode *inode = filp->f_inode;
|
FAR struct inode *inode = filep->f_inode;
|
||||||
FAR struct bchlib_s *bch;
|
FAR struct bchlib_s *bch;
|
||||||
int ret = -ENOTTY;
|
int ret = -ENOTTY;
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/dev_null.c
|
* drivers/dev_null.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007, 2008, 2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
static ssize_t devnull_read(FAR struct file *, FAR char *, size_t);
|
static ssize_t devnull_read(FAR struct file *, FAR char *, size_t);
|
||||||
static ssize_t devnull_write(FAR struct file *, FAR const char *, size_t);
|
static ssize_t devnull_write(FAR struct file *, FAR const char *, size_t);
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
static int devnull_poll(FAR struct file *filp, FAR struct pollfd *fds,
|
static int devnull_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||||
bool setup);
|
bool setup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ static const struct file_operations devnull_fops =
|
|||||||
* Name: devnull_read
|
* Name: devnull_read
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t devnull_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
static ssize_t devnull_read(FAR struct file *filep, FAR char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
return 0; /* Return EOF */
|
return 0; /* Return EOF */
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ static ssize_t devnull_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
|||||||
* Name: devnull_write
|
* Name: devnull_write
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t devnull_write(FAR struct file *filp, FAR const char *buffer, size_t len)
|
static ssize_t devnull_write(FAR struct file *filep, FAR const char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
return len; /* Say that everything was written */
|
return len; /* Say that everything was written */
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ static ssize_t devnull_write(FAR struct file *filp, FAR const char *buffer, size
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
static int devnull_poll(FAR struct file *filp, FAR struct pollfd *fds,
|
static int devnull_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||||
bool setup)
|
bool setup)
|
||||||
{
|
{
|
||||||
if (setup)
|
if (setup)
|
||||||
|
|||||||
+8
-6
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/dev_null.c
|
* drivers/dev_zero.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
static ssize_t devzero_read(FAR struct file *, FAR char *, size_t);
|
static ssize_t devzero_read(FAR struct file *, FAR char *, size_t);
|
||||||
static ssize_t devzero_write(FAR struct file *, FAR const char *, size_t);
|
static ssize_t devzero_write(FAR struct file *, FAR const char *, size_t);
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
static int devzero_poll(FAR struct file *filp, FAR struct pollfd *fds,
|
static int devzero_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||||
bool setup);
|
bool setup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -82,7 +82,8 @@ static const struct file_operations devzero_fops =
|
|||||||
* Name: devzero_read
|
* Name: devzero_read
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t devzero_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
static ssize_t devzero_read(FAR struct file *filep, FAR char *buffer,
|
||||||
|
size_t len)
|
||||||
{
|
{
|
||||||
memset(buffer, 0, len);
|
memset(buffer, 0, len);
|
||||||
return len;
|
return len;
|
||||||
@@ -92,7 +93,8 @@ static ssize_t devzero_read(FAR struct file *filp, FAR char *buffer, size_t len)
|
|||||||
* Name: devzero_write
|
* Name: devzero_write
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t devzero_write(FAR struct file *filp, FAR const char *buffer, size_t len)
|
static ssize_t devzero_write(FAR struct file *filep, FAR const char *buffer,
|
||||||
|
size_t len)
|
||||||
{
|
{
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
@@ -102,7 +104,7 @@ static ssize_t devzero_write(FAR struct file *filp, FAR const char *buffer, size
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
static int devzero_poll(FAR struct file *filp, FAR struct pollfd *fds,
|
static int devzero_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||||
bool setup)
|
bool setup)
|
||||||
{
|
{
|
||||||
if (setup)
|
if (setup)
|
||||||
|
|||||||
+12
-12
@@ -172,11 +172,11 @@ static int pipe_close(FAR struct file *filep)
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* pipe() creates a pair of file descriptors, pointing to a pipe inode, and
|
* pipe() creates a pair of file descriptors, pointing to a pipe inode, and
|
||||||
* places them in the array pointed to by 'filedes'. filedes[0] is for reading,
|
* places them in the array pointed to by 'fd'. fd[0] is for reading,
|
||||||
* filedes[1] is for writing.
|
* fd[1] is for writing.
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* filedes[2] - The user provided array in which to catch the pipe file
|
* fd[2] - The user provided array in which to catch the pipe file
|
||||||
* descriptors
|
* descriptors
|
||||||
*
|
*
|
||||||
* Return:
|
* Return:
|
||||||
@@ -185,7 +185,7 @@ static int pipe_close(FAR struct file *filep)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int pipe(int filedes[2])
|
int pipe(int fd[2])
|
||||||
{
|
{
|
||||||
struct pipe_dev_s *dev = NULL;
|
struct pipe_dev_s *dev = NULL;
|
||||||
char devname[16];
|
char devname[16];
|
||||||
@@ -249,29 +249,29 @@ int pipe(int filedes[2])
|
|||||||
}
|
}
|
||||||
|
|
||||||
(void)sem_post(&g_pipesem);
|
(void)sem_post(&g_pipesem);
|
||||||
|
|
||||||
/* Get a write file descriptor */
|
/* Get a write file descriptor */
|
||||||
|
|
||||||
filedes[1] = open(devname, O_WRONLY);
|
fd[1] = open(devname, O_WRONLY);
|
||||||
if (filedes[1] < 0)
|
if (fd[1] < 0)
|
||||||
{
|
{
|
||||||
err = -filedes[1];
|
err = -fd[1];
|
||||||
goto errout_with_driver;
|
goto errout_with_driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get a read file descriptor */
|
/* Get a read file descriptor */
|
||||||
|
|
||||||
filedes[0] = open(devname, O_RDONLY);
|
fd[0] = open(devname, O_RDONLY);
|
||||||
if (filedes[0] < 0)
|
if (fd[0] < 0)
|
||||||
{
|
{
|
||||||
err = -filedes[0];
|
err = -fd[0];
|
||||||
goto errout_with_wrfd;
|
goto errout_with_wrfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
errout_with_wrfd:
|
errout_with_wrfd:
|
||||||
close(filedes[1]);
|
close(fd[1]);
|
||||||
errout_with_driver:
|
errout_with_driver:
|
||||||
unregister_driver(devname);
|
unregister_driver(devname);
|
||||||
errout_with_dev:
|
errout_with_dev:
|
||||||
|
|||||||
+5
-5
@@ -66,7 +66,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int dup(int fildes)
|
int dup(int fd)
|
||||||
{
|
{
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
@@ -74,12 +74,12 @@ int dup(int fildes)
|
|||||||
* descriptor. */
|
* descriptor. */
|
||||||
|
|
||||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
if ((unsigned int)fildes < CONFIG_NFILE_DESCRIPTORS)
|
if ((unsigned int)fd < CONFIG_NFILE_DESCRIPTORS)
|
||||||
{
|
{
|
||||||
/* Its a valid file descriptor.. dup the file descriptor using any
|
/* Its a valid file descriptor.. dup the file descriptor using any
|
||||||
* other file descriptor*/
|
* other file descriptor*/
|
||||||
|
|
||||||
ret = file_dup(fildes, 0);
|
ret = file_dup(fd, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -87,11 +87,11 @@ int dup(int fildes)
|
|||||||
/* Not a vailid file descriptor. Did we get a valid socket descriptor? */
|
/* Not a vailid file descriptor. Did we get a valid socket descriptor? */
|
||||||
|
|
||||||
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||||
if ((unsigned int)fildes < (CONFIG_NFILE_DESCRIPTORS+CONFIG_NSOCKET_DESCRIPTORS))
|
if ((unsigned int)fd < (CONFIG_NFILE_DESCRIPTORS+CONFIG_NSOCKET_DESCRIPTORS))
|
||||||
{
|
{
|
||||||
/* Yes.. dup the socket descriptor */
|
/* Yes.. dup the socket descriptor */
|
||||||
|
|
||||||
ret = net_dup(fildes, CONFIG_NFILE_DESCRIPTORS);
|
ret = net_dup(fd, CONFIG_NFILE_DESCRIPTORS);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+6
-6
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* fs/fs_dup2.c
|
* fs/fs_dup2.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -73,21 +73,21 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int dup2(int fildes1, int fildes2)
|
int dup2(int fd1, int fd2)
|
||||||
{
|
{
|
||||||
/* Check the range of the descriptor to see if we got a file or a socket
|
/* Check the range of the descriptor to see if we got a file or a socket
|
||||||
* descriptor.
|
* descriptor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((unsigned int)fildes1 >= CONFIG_NFILE_DESCRIPTORS)
|
if ((unsigned int)fd1 >= CONFIG_NFILE_DESCRIPTORS)
|
||||||
{
|
{
|
||||||
/* Not a valid file descriptor. Did we get a valid socket descriptor? */
|
/* Not a valid file descriptor. Did we get a valid socket descriptor? */
|
||||||
|
|
||||||
if ((unsigned int)fildes1 < (CONFIG_NFILE_DESCRIPTORS+CONFIG_NSOCKET_DESCRIPTORS))
|
if ((unsigned int)fd1 < (CONFIG_NFILE_DESCRIPTORS+CONFIG_NSOCKET_DESCRIPTORS))
|
||||||
{
|
{
|
||||||
/* Yes.. dup the socket descriptor */
|
/* Yes.. dup the socket descriptor */
|
||||||
|
|
||||||
return net_dup2(fildes1, fildes2);
|
return net_dup2(fd1, fd2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -101,7 +101,7 @@ int dup2(int fildes1, int fildes2)
|
|||||||
{
|
{
|
||||||
/* Its a valid file descriptor.. dup the file descriptor */
|
/* Its a valid file descriptor.. dup the file descriptor */
|
||||||
|
|
||||||
return file_dup2(fildes1, fildes2);
|
return file_dup2(fd1, fd2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -210,7 +210,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb)
|
|||||||
for (i = 0 ; i < CONFIG_NFILE_STREAMS; i++)
|
for (i = 0 ; i < CONFIG_NFILE_STREAMS; i++)
|
||||||
{
|
{
|
||||||
stream = &slist->sl_streams[i];
|
stream = &slist->sl_streams[i];
|
||||||
if (stream->fs_filedes < 0)
|
if (stream->fs_fd < 0)
|
||||||
{
|
{
|
||||||
/* Zero the structure */
|
/* Zero the structure */
|
||||||
|
|
||||||
@@ -245,7 +245,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb)
|
|||||||
* file descriptor locks this stream.
|
* file descriptor locks this stream.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
stream->fs_filedes = fd;
|
stream->fs_fd = fd;
|
||||||
stream->fs_oflags = (uint16_t)oflags;
|
stream->fs_oflags = (uint16_t)oflags;
|
||||||
|
|
||||||
sem_post(&slist->sl_sem);
|
sem_post(&slist->sl_sem);
|
||||||
|
|||||||
+13
-13
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* fs/fs_filedup.c
|
* fs/fs_filedup.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -77,19 +77,19 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int file_dup(int fildes, int minfd)
|
int file_dup(int fd, int minfd)
|
||||||
{
|
{
|
||||||
FAR struct filelist *list;
|
FAR struct filelist *list;
|
||||||
int fildes2;
|
int fd2;
|
||||||
|
|
||||||
/* Get the thread-specific file list */
|
/* Get the thread-specific file list */
|
||||||
|
|
||||||
list = sched_getfiles();
|
list = sched_getfiles();
|
||||||
DEBUGASSERT(list);
|
DEBUGASSERT(list);
|
||||||
|
|
||||||
/* Verify that fildes is a valid, open file descriptor */
|
/* Verify that fd is a valid, open file descriptor */
|
||||||
|
|
||||||
if (!DUP_ISOPEN(fildes, list))
|
if (!DUP_ISOPEN(fd, list))
|
||||||
{
|
{
|
||||||
set_errno(EBADF);
|
set_errno(EBADF);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
@@ -97,22 +97,22 @@ int file_dup(int fildes, int minfd)
|
|||||||
|
|
||||||
/* Increment the reference count on the contained inode */
|
/* Increment the reference count on the contained inode */
|
||||||
|
|
||||||
inode_addref(list->fl_files[fildes].f_inode);
|
inode_addref(list->fl_files[fd].f_inode);
|
||||||
|
|
||||||
/* Then allocate a new file descriptor for the inode */
|
/* Then allocate a new file descriptor for the inode */
|
||||||
|
|
||||||
fildes2 = files_allocate(list->fl_files[fildes].f_inode,
|
fd2 = files_allocate(list->fl_files[fd].f_inode,
|
||||||
list->fl_files[fildes].f_oflags,
|
list->fl_files[fd].f_oflags,
|
||||||
list->fl_files[fildes].f_pos,
|
list->fl_files[fd].f_pos,
|
||||||
minfd);
|
minfd);
|
||||||
if (fildes2 < 0)
|
if (fd2 < 0)
|
||||||
{
|
{
|
||||||
set_errno(EMFILE);
|
set_errno(EMFILE);
|
||||||
inode_release(list->fl_files[fildes].f_inode);
|
inode_release(list->fl_files[fd].f_inode);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fildes2;
|
return fd2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 */
|
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 */
|
||||||
|
|||||||
+10
-10
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* fs/fs_filedup2.c
|
* fs/fs_filedup2.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -75,9 +75,9 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||||
int file_dup2(int fildes1, int fildes2)
|
int file_dup2(int fd1, int fd2)
|
||||||
#else
|
#else
|
||||||
int dup2(int fildes1, int fildes2)
|
int dup2(int fd1, int fd2)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
FAR struct filelist *list;
|
FAR struct filelist *list;
|
||||||
@@ -91,9 +91,9 @@ int dup2(int fildes1, int fildes2)
|
|||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Verify that fildes is a valid, open file descriptor */
|
/* Verify that fd is a valid, open file descriptor */
|
||||||
|
|
||||||
if (!DUP_ISOPEN(fildes1, list))
|
if (!DUP_ISOPEN(fd1, list))
|
||||||
{
|
{
|
||||||
set_errno(EBADF);
|
set_errno(EBADF);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
@@ -101,20 +101,20 @@ int dup2(int fildes1, int fildes2)
|
|||||||
|
|
||||||
/* Handle a special case */
|
/* Handle a special case */
|
||||||
|
|
||||||
if (fildes1 == fildes2)
|
if (fd1 == fd2)
|
||||||
{
|
{
|
||||||
return fildes1;
|
return fd1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Verify fildes2 */
|
/* Verify fd2 */
|
||||||
|
|
||||||
if ((unsigned int)fildes2 >= CONFIG_NFILE_DESCRIPTORS)
|
if ((unsigned int)fd2 >= CONFIG_NFILE_DESCRIPTORS)
|
||||||
{
|
{
|
||||||
set_errno(EBADF);
|
set_errno(EBADF);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return files_dup(&list->fl_files[fildes1], &list->fl_files[fildes2]);
|
return files_dup(&list->fl_files[fd1], &list->fl_files[fd2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 */
|
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 */
|
||||||
|
|||||||
+8
-9
@@ -344,7 +344,7 @@ int files_allocate(FAR struct inode *inode, int oflags, off_t pos, int minfd)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int files_close(int filedes)
|
int files_close(int fd)
|
||||||
{
|
{
|
||||||
FAR struct filelist *list;
|
FAR struct filelist *list;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -356,7 +356,7 @@ int files_close(int filedes)
|
|||||||
|
|
||||||
/* If the file was properly opened, there should be an inode assigned */
|
/* If the file was properly opened, there should be an inode assigned */
|
||||||
|
|
||||||
if (filedes < 0 || filedes >= CONFIG_NFILE_DESCRIPTORS || !list->fl_files[filedes].f_inode)
|
if (fd < 0 || fd >= CONFIG_NFILE_DESCRIPTORS || !list->fl_files[fd].f_inode)
|
||||||
{
|
{
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
}
|
}
|
||||||
@@ -364,7 +364,7 @@ int files_close(int filedes)
|
|||||||
/* Perform the protected close operation */
|
/* Perform the protected close operation */
|
||||||
|
|
||||||
_files_semtake(list);
|
_files_semtake(list);
|
||||||
ret = _files_close(&list->fl_files[filedes]);
|
ret = _files_close(&list->fl_files[fd]);
|
||||||
_files_semgive(list);
|
_files_semgive(list);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -378,20 +378,19 @@ int files_close(int filedes)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void files_release(int filedes)
|
void files_release(int fd)
|
||||||
{
|
{
|
||||||
FAR struct filelist *list;
|
FAR struct filelist *list;
|
||||||
|
|
||||||
list = sched_getfiles();
|
list = sched_getfiles();
|
||||||
DEBUGASSERT(list);
|
DEBUGASSERT(list);
|
||||||
|
|
||||||
if (filedes >=0 && filedes < CONFIG_NFILE_DESCRIPTORS)
|
if (fd >=0 && fd < CONFIG_NFILE_DESCRIPTORS)
|
||||||
{
|
{
|
||||||
_files_semtake(list);
|
_files_semtake(list);
|
||||||
list->fl_files[filedes].f_oflags = 0;
|
list->fl_files[fd].f_oflags = 0;
|
||||||
list->fl_files[filedes].f_pos = 0;
|
list->fl_files[fd].f_pos = 0;
|
||||||
list->fl_files[filedes].f_inode = NULL;
|
list->fl_files[fd].f_inode = NULL;
|
||||||
_files_semgive(list);
|
_files_semgive(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-20
@@ -119,7 +119,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN void inode_semtake(void);
|
void inode_semtake(void);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: inode_semgive
|
* Name: inode_semgive
|
||||||
@@ -129,7 +129,7 @@ EXTERN void inode_semtake(void);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN void inode_semgive(void);
|
void inode_semgive(void);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: inode_search
|
* Name: inode_search
|
||||||
@@ -143,10 +143,10 @@ EXTERN void inode_semgive(void);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN FAR struct inode *inode_search(FAR const char **path,
|
FAR struct inode *inode_search(FAR const char **path,
|
||||||
FAR struct inode **peer,
|
FAR struct inode **peer,
|
||||||
FAR struct inode **parent,
|
FAR struct inode **parent,
|
||||||
FAR const char **relpath);
|
FAR const char **relpath);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: inode_free
|
* Name: inode_free
|
||||||
@@ -156,7 +156,7 @@ EXTERN FAR struct inode *inode_search(FAR const char **path,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN void inode_free(FAR struct inode *node);
|
void inode_free(FAR struct inode *node);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: inode_nextname
|
* Name: inode_nextname
|
||||||
@@ -167,7 +167,7 @@ EXTERN void inode_free(FAR struct inode *node);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN const char *inode_nextname(FAR const char *name);
|
const char *inode_nextname(FAR const char *name);
|
||||||
|
|
||||||
/* fs_inodereserver.c *******************************************************/
|
/* fs_inodereserver.c *******************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -192,7 +192,7 @@ EXTERN const char *inode_nextname(FAR const char *name);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN int inode_reserve(FAR const char *path, FAR struct inode **inode);
|
int inode_reserve(FAR const char *path, FAR struct inode **inode);
|
||||||
|
|
||||||
/* fs_inoderemove.c *********************************************************/
|
/* fs_inoderemove.c *********************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -205,7 +205,7 @@ EXTERN int inode_reserve(FAR const char *path, FAR struct inode **inode);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN int inode_remove(FAR const char *path);
|
int inode_remove(FAR const char *path);
|
||||||
|
|
||||||
/* fs_inodefind.c ***********************************************************/
|
/* fs_inodefind.c ***********************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -217,15 +217,15 @@ EXTERN int inode_remove(FAR const char *path);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN FAR struct inode *inode_find(FAR const char *path, const char **relpath);
|
FAR struct inode *inode_find(FAR const char *path, const char **relpath);
|
||||||
|
|
||||||
/* fs_inodeaddref.c *********************************************************/
|
/* fs_inodeaddref.c *********************************************************/
|
||||||
|
|
||||||
EXTERN void inode_addref(FAR struct inode *inode);
|
void inode_addref(FAR struct inode *inode);
|
||||||
|
|
||||||
/* fs_inoderelease.c ********************************************************/
|
/* fs_inoderelease.c ********************************************************/
|
||||||
|
|
||||||
EXTERN void inode_release(FAR struct inode *inode);
|
void inode_release(FAR struct inode *inode);
|
||||||
|
|
||||||
/* fs_foreachinode.c ********************************************************/
|
/* fs_foreachinode.c ********************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -244,7 +244,7 @@ EXTERN void inode_release(FAR struct inode *inode);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN int foreach_inode(foreach_inode_t handler, FAR void *arg);
|
int foreach_inode(foreach_inode_t handler, FAR void *arg);
|
||||||
|
|
||||||
/* fs_files.c ***************************************************************/
|
/* fs_files.c ***************************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -255,7 +255,7 @@ EXTERN int foreach_inode(foreach_inode_t handler, FAR void *arg);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN void weak_function files_initialize(void);
|
void weak_function files_initialize(void);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: files_allocate
|
* Name: files_allocate
|
||||||
@@ -266,7 +266,7 @@ EXTERN void weak_function files_initialize(void);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN int files_allocate(FAR struct inode *inode, int oflags, off_t pos, int minfd);
|
int files_allocate(FAR struct inode *inode, int oflags, off_t pos, int minfd);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: files_close
|
* Name: files_close
|
||||||
@@ -279,7 +279,7 @@ EXTERN int files_allocate(FAR struct inode *inode, int oflags, off_t pos, int m
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN int files_close(int filedes);
|
int files_close(int fd);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: files_release
|
* Name: files_release
|
||||||
@@ -290,7 +290,7 @@ EXTERN int files_close(int filedes);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN void files_release(int filedes);
|
void files_release(int fd);
|
||||||
|
|
||||||
/* fs_findblockdriver.c *****************************************************/
|
/* fs_findblockdriver.c *****************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -316,8 +316,8 @@ EXTERN void files_release(int filedes);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
EXTERN int find_blockdriver(FAR const char *pathname, int mountflags,
|
int find_blockdriver(FAR const char *pathname, int mountflags,
|
||||||
FAR struct inode **ppinode);
|
FAR struct inode **ppinode);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|||||||
+3
-3
@@ -138,7 +138,7 @@ errout:
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* The lseek() function repositions the offset of the open file associated
|
* The lseek() function repositions the offset of the open file associated
|
||||||
* with the file descriptor fildes to the argument 'offset' according to the
|
* with the file descriptor fd to the argument 'offset' according to the
|
||||||
* directive 'whence' as follows:
|
* directive 'whence' as follows:
|
||||||
*
|
*
|
||||||
* SEEK_SET
|
* SEEK_SET
|
||||||
@@ -161,12 +161,12 @@ errout:
|
|||||||
* Return:
|
* Return:
|
||||||
* The resulting offset on success. -1 on failure withi errno set properly:
|
* The resulting offset on success. -1 on failure withi errno set properly:
|
||||||
*
|
*
|
||||||
* EBADF fildes is not an open file descriptor.
|
* EBADF fd is not an open file descriptor.
|
||||||
* EINVAL whence is not one of SEEK_SET, SEEK_CUR, SEEK_END; or the
|
* EINVAL whence is not one of SEEK_SET, SEEK_CUR, SEEK_END; or the
|
||||||
* resulting file offset would be negative, or beyond the end of a
|
* resulting file offset would be negative, or beyond the end of a
|
||||||
* seekable device.
|
* seekable device.
|
||||||
* EOVERFLOW The resulting file offset cannot be represented in an off_t.
|
* EOVERFLOW The resulting file offset cannot be represented in an off_t.
|
||||||
* ESPIPE fildes is associated with a pipe, socket, or FIFO.
|
* ESPIPE fd is associated with a pipe, socket, or FIFO.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|||||||
+17
-17
@@ -71,20 +71,20 @@ struct file_operations
|
|||||||
{
|
{
|
||||||
/* The device driver open method differs from the mountpoint open method */
|
/* The device driver open method differs from the mountpoint open method */
|
||||||
|
|
||||||
int (*open)(FAR struct file *filp);
|
int (*open)(FAR struct file *filep);
|
||||||
|
|
||||||
/* The following methods must be identical in signature and position because
|
/* The following methods must be identical in signature and position because
|
||||||
* the struct file_operations and struct mountp_operations are treated like
|
* the struct file_operations and struct mountp_operations are treated like
|
||||||
* unions.
|
* unions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int (*close)(FAR struct file *filp);
|
int (*close)(FAR struct file *filep);
|
||||||
ssize_t (*read)(FAR struct file *filp, FAR char *buffer, size_t buflen);
|
ssize_t (*read)(FAR struct file *filep, FAR char *buffer, size_t buflen);
|
||||||
ssize_t (*write)(FAR struct file *filp, FAR const char *buffer, size_t buflen);
|
ssize_t (*write)(FAR struct file *filep, FAR const char *buffer, size_t buflen);
|
||||||
off_t (*seek)(FAR struct file *filp, off_t offset, int whence);
|
off_t (*seek)(FAR struct file *filep, off_t offset, int whence);
|
||||||
int (*ioctl)(FAR struct file *filp, int cmd, unsigned long arg);
|
int (*ioctl)(FAR struct file *filep, int cmd, unsigned long arg);
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
int (*poll)(FAR struct file *filp, struct pollfd *fds, bool setup);
|
int (*poll)(FAR struct file *filep, struct pollfd *fds, bool setup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The two structures need not be common after this point */
|
/* The two structures need not be common after this point */
|
||||||
@@ -139,7 +139,7 @@ struct mountpt_operations
|
|||||||
* information to manage privileges.
|
* information to manage privileges.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int (*open)(FAR struct file *filp, FAR const char *relpath,
|
int (*open)(FAR struct file *filep, FAR const char *relpath,
|
||||||
int oflags, mode_t mode);
|
int oflags, mode_t mode);
|
||||||
|
|
||||||
/* The following methods must be identical in signature and position because
|
/* The following methods must be identical in signature and position because
|
||||||
@@ -147,11 +147,11 @@ struct mountpt_operations
|
|||||||
* unions.
|
* unions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int (*close)(FAR struct file *filp);
|
int (*close)(FAR struct file *filep);
|
||||||
ssize_t (*read)(FAR struct file *filp, FAR char *buffer, size_t buflen);
|
ssize_t (*read)(FAR struct file *filep, FAR char *buffer, size_t buflen);
|
||||||
ssize_t (*write)(FAR struct file *filp, FAR const char *buffer, size_t buflen);
|
ssize_t (*write)(FAR struct file *filep, FAR const char *buffer, size_t buflen);
|
||||||
off_t (*seek)(FAR struct file *filp, off_t offset, int whence);
|
off_t (*seek)(FAR struct file *filep, off_t offset, int whence);
|
||||||
int (*ioctl)(FAR struct file *filp, int cmd, unsigned long arg);
|
int (*ioctl)(FAR struct file *filep, int cmd, unsigned long arg);
|
||||||
|
|
||||||
/* The two structures need not be common after this point. The following
|
/* The two structures need not be common after this point. The following
|
||||||
* are extended methods needed to deal with the unique needs of mounted
|
* are extended methods needed to deal with the unique needs of mounted
|
||||||
@@ -160,7 +160,7 @@ struct mountpt_operations
|
|||||||
* Additional open-file-specific mountpoint operations:
|
* Additional open-file-specific mountpoint operations:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int (*sync)(FAR struct file *filp);
|
int (*sync)(FAR struct file *filep);
|
||||||
int (*dup)(FAR const struct file *oldp, FAR struct file *newp);
|
int (*dup)(FAR const struct file *oldp, FAR struct file *newp);
|
||||||
|
|
||||||
/* Directory operations */
|
/* Directory operations */
|
||||||
@@ -273,7 +273,7 @@ struct filelist
|
|||||||
#if CONFIG_NFILE_STREAMS > 0
|
#if CONFIG_NFILE_STREAMS > 0
|
||||||
struct file_struct
|
struct file_struct
|
||||||
{
|
{
|
||||||
int fs_filedes; /* File descriptor associated with stream */
|
int fs_fd; /* File descriptor associated with stream */
|
||||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||||
sem_t fs_sem; /* For thread safety */
|
sem_t fs_sem; /* For thread safety */
|
||||||
pid_t fs_holder; /* Holder of sem */
|
pid_t fs_holder; /* Holder of sem */
|
||||||
@@ -621,7 +621,7 @@ int lib_flushall(FAR struct streamlist *list);
|
|||||||
ssize_t lib_sendfile(int outfd, int infd, off_t *offset, size_t count);
|
ssize_t lib_sendfile(int outfd, int infd, off_t *offset, size_t count);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* fs/fs_read.c *************************************************************/
|
/* fs/fs_fileread.c *********************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: file_read
|
* Name: file_read
|
||||||
*
|
*
|
||||||
@@ -636,7 +636,7 @@ ssize_t lib_sendfile(int outfd, int infd, off_t *offset, size_t count);
|
|||||||
ssize_t file_read(FAR struct file *filep, FAR void *buf, size_t nbytes);
|
ssize_t file_read(FAR struct file *filep, FAR void *buf, size_t nbytes);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* fs/fs_lseek.c ************************************************************/
|
/* fs/fs_fileread.c *********************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: file_seek
|
* Name: file_seek
|
||||||
*
|
*
|
||||||
|
|||||||
+26
-26
@@ -129,62 +129,62 @@ EXTERN int optopt; /* unrecognized option character */
|
|||||||
|
|
||||||
/* Task Control Interfaces */
|
/* Task Control Interfaces */
|
||||||
|
|
||||||
EXTERN pid_t vfork(void);
|
pid_t vfork(void);
|
||||||
EXTERN pid_t getpid(void);
|
pid_t getpid(void);
|
||||||
EXTERN void _exit(int status) noreturn_function;
|
void _exit(int status) noreturn_function;
|
||||||
EXTERN unsigned int sleep(unsigned int seconds);
|
unsigned int sleep(unsigned int seconds);
|
||||||
EXTERN int usleep(useconds_t usec);
|
int usleep(useconds_t usec);
|
||||||
EXTERN int pause(void);
|
int pause(void);
|
||||||
|
|
||||||
/* File descriptor operations */
|
/* File descriptor operations */
|
||||||
|
|
||||||
EXTERN int close(int fd);
|
int close(int fd);
|
||||||
EXTERN int dup(int fd);
|
int dup(int fd);
|
||||||
EXTERN int dup2(int fd1, int fd2);
|
int dup2(int fd1, int fd2);
|
||||||
EXTERN int fsync(int fd);
|
int fsync(int fd);
|
||||||
EXTERN off_t lseek(int fd, off_t offset, int whence);
|
off_t lseek(int fd, off_t offset, int whence);
|
||||||
EXTERN ssize_t read(int fd, FAR void *buf, size_t nbytes);
|
ssize_t read(int fd, FAR void *buf, size_t nbytes);
|
||||||
EXTERN ssize_t write(int fd, FAR const void *buf, size_t nbytes);
|
ssize_t write(int fd, FAR const void *buf, size_t nbytes);
|
||||||
|
|
||||||
/* Special devices */
|
/* Special devices */
|
||||||
|
|
||||||
EXTERN int pipe(int filedes[2]);
|
int pipe(int fd[2]);
|
||||||
|
|
||||||
/* Working directory operations */
|
/* Working directory operations */
|
||||||
|
|
||||||
EXTERN int chdir(FAR const char *path);
|
int chdir(FAR const char *path);
|
||||||
EXTERN FAR char *getcwd(FAR char *buf, size_t size);
|
FAR char *getcwd(FAR char *buf, size_t size);
|
||||||
|
|
||||||
/* File path operations */
|
/* File path operations */
|
||||||
|
|
||||||
EXTERN int unlink(FAR const char *pathname);
|
int unlink(FAR const char *pathname);
|
||||||
EXTERN int rmdir(FAR const char *pathname);
|
int rmdir(FAR const char *pathname);
|
||||||
|
|
||||||
/* Execution of programs from files */
|
/* Execution of programs from files */
|
||||||
|
|
||||||
#ifdef CONFIG_LIBC_EXECFUNCS
|
#ifdef CONFIG_LIBC_EXECFUNCS
|
||||||
EXTERN int execl(FAR const char *path, ...);
|
int execl(FAR const char *path, ...);
|
||||||
EXTERN int execv(FAR const char *path, FAR char *const argv[]);
|
int execv(FAR const char *path, FAR char *const argv[]);
|
||||||
|
|
||||||
/* Non-standard functions to manage symbol tables */
|
/* Non-standard functions to manage symbol tables */
|
||||||
|
|
||||||
struct symtab_s; /* See include/nuttx/binfmt/symtab.h */
|
struct symtab_s; /* See include/nuttx/binfmt/symtab.h */
|
||||||
EXTERN void exec_getsymtab(FAR const struct symtab_s **symtab, FAR int *nsymbols);
|
void exec_getsymtab(FAR const struct symtab_s **symtab, FAR int *nsymbols);
|
||||||
EXTERN void exec_setsymtab(FAR const struct symtab_s *symtab, int nsymbols);
|
void exec_setsymtab(FAR const struct symtab_s *symtab, int nsymbols);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Other */
|
/* Other */
|
||||||
|
|
||||||
EXTERN int getopt(int argc, FAR char *const argv[], FAR const char *optstring);
|
int getopt(int argc, FAR char *const argv[], FAR const char *optstring);
|
||||||
|
|
||||||
/* Accessor functions intended for use only by external NXFLAT
|
/* Accessor functions intended for use only by external NXFLAT
|
||||||
* modules. The global variables optarg, optind, and optopt cannot
|
* modules. The global variables optarg, optind, and optopt cannot
|
||||||
* be referenced directly from external modules.
|
* be referenced directly from external modules.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EXTERN FAR char **getoptargp(void); /* Optional argument following option */
|
FAR char **getoptargp(void); /* Optional argument following option */
|
||||||
EXTERN int *getopindgp(void); /* Index into argv */
|
int *getopindgp(void); /* Index into argv */
|
||||||
EXTERN int *getoptoptp(void); /* unrecognized option character */
|
int *getoptoptp(void); /* unrecognized option character */
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ void lib_streaminit(FAR struct streamlist *list)
|
|||||||
|
|
||||||
/* Indicate not opened */
|
/* Indicate not opened */
|
||||||
|
|
||||||
list->sl_streams[i].fs_filedes = -1;
|
list->sl_streams[i].fs_fd = -1;
|
||||||
|
|
||||||
/* Initialize the stream semaphore to one to support one-at-
|
/* Initialize the stream semaphore to one to support one-at-
|
||||||
* a-time access to private data sets.
|
* a-time access to private data sets.
|
||||||
@@ -152,5 +152,3 @@ void lib_releaselist(FAR struct streamlist *list)
|
|||||||
|
|
||||||
#endif /* !CONFIG_NUTTX_KERNEL || __KERNEL__ */
|
#endif /* !CONFIG_NUTTX_KERNEL || __KERNEL__ */
|
||||||
#endif /* CONFIG_NFILE_STREAMS */
|
#endif /* CONFIG_NFILE_STREAMS */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* libc/stdio/lib_fclose.c
|
* libc/stdio/lib_fclose.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011, 3013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -80,9 +80,9 @@ int fclose(FAR FILE *stream)
|
|||||||
/* Check that the underlying file descriptor corresponds to an an open
|
/* Check that the underlying file descriptor corresponds to an an open
|
||||||
* file.
|
* file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = OK;
|
ret = OK;
|
||||||
if (stream->fs_filedes >= 0)
|
if (stream->fs_fd >= 0)
|
||||||
{
|
{
|
||||||
/* If the stream was opened for writing, then flush the stream */
|
/* If the stream was opened for writing, then flush the stream */
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ int fclose(FAR FILE *stream)
|
|||||||
|
|
||||||
/* Close the underlying file descriptor and save the return status */
|
/* Close the underlying file descriptor and save the return status */
|
||||||
|
|
||||||
status = close(stream->fs_filedes);
|
status = close(stream->fs_fd);
|
||||||
|
|
||||||
/* If close() returns an error but flush() did not then make sure
|
/* If close() returns an error but flush() did not then make sure
|
||||||
* that we return the close() error condition.
|
* that we return the close() error condition.
|
||||||
@@ -132,9 +132,9 @@ int fclose(FAR FILE *stream)
|
|||||||
|
|
||||||
stream->fs_oflags = 0;
|
stream->fs_oflags = 0;
|
||||||
#endif
|
#endif
|
||||||
/* Setting the fs_filedescriptor to -1 makes the stream available for reuse */
|
/* Setting the file descriptor to -1 makes the stream available for reuse */
|
||||||
|
|
||||||
stream->fs_filedes = -1;
|
stream->fs_fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* On an error, reset the errno to the first error encountered and return
|
/* On an error, reset the errno to the first error encountered and return
|
||||||
@@ -151,4 +151,3 @@ int fclose(FAR FILE *stream)
|
|||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* libc/stdio/lib_fgets.c
|
* libc/stdio/lib_fgets.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2008, 2011-2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2008, 2011-2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -119,7 +119,7 @@ char *fgets(FAR char *buf, int buflen, FILE *stream)
|
|||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
||||||
if (!stream || !buf || buflen < 1 || stream->fs_filedes < 0)
|
if (!stream || !buf || buflen < 1 || stream->fs_fd < 0)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -204,4 +204,3 @@ char *fgets(FAR char *buf, int buflen, FILE *stream)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* libc/stdio/lib_fileno.c
|
* libc/stdio/lib_fileno.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -55,7 +55,7 @@ int fileno(FAR FILE *stream)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
if (stream)
|
if (stream)
|
||||||
{
|
{
|
||||||
ret = stream->fs_filedes;
|
ret = stream->fs_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -67,4 +67,3 @@ int fileno(FAR FILE *stream)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NFILE_STREAMS */
|
#endif /* CONFIG_NFILE_STREAMS */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* libc/stdio/lib_fseek.c
|
* libc/stdio/lib_fseek.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007, 2008, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
* function on the same stream.
|
* function on the same stream.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Zero on succes; -1 on failure with errno set appropriately.
|
* Zero on succes; -1 on failure with errno set appropriately.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -132,7 +132,5 @@ int fseek(FAR FILE *stream, long int offset, int whence)
|
|||||||
|
|
||||||
/* Perform the fseek on the underlying file descriptor */
|
/* Perform the fseek on the underlying file descriptor */
|
||||||
|
|
||||||
return lseek(stream->fs_filedes, offset, whence) == (off_t)-1 ? ERROR : OK;
|
return lseek(stream->fs_fd, offset, whence) == (off_t)-1 ? ERROR : OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* libc/stdio/lib_ftell.c
|
* libc/stdio/lib_ftell.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -95,7 +95,7 @@
|
|||||||
* stream pointed to by stream.
|
* stream pointed to by stream.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Zero on succes; -1 on failure with errno set appropriately.
|
* Zero on succes; -1 on failure with errno set appropriately.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ long ftell(FAR FILE *stream)
|
|||||||
* file pointer, but will return its current setting
|
* file pointer, but will return its current setting
|
||||||
*/
|
*/
|
||||||
|
|
||||||
position = lseek(stream->fs_filedes, 0, SEEK_CUR);
|
position = lseek(stream->fs_fd, 0, SEEK_CUR);
|
||||||
if (position != (off_t)-1)
|
if (position != (off_t)-1)
|
||||||
{
|
{
|
||||||
return (long)position;
|
return (long)position;
|
||||||
@@ -125,5 +125,3 @@ long ftell(FAR FILE *stream)
|
|||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* libc/stdio/lib_libfflush.c
|
* libc/stdio/lib_libfflush.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2008, 2011-2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2008, 2011-2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -112,7 +112,7 @@ ssize_t lib_fflush(FAR FILE *stream, bool bforce)
|
|||||||
|
|
||||||
/* Return EBADF if the file is not opened for writing */
|
/* Return EBADF if the file is not opened for writing */
|
||||||
|
|
||||||
if (stream->fs_filedes < 0 || (stream->fs_oflags & O_WROK) == 0)
|
if (stream->fs_fd < 0 || (stream->fs_oflags & O_WROK) == 0)
|
||||||
{
|
{
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ ssize_t lib_fflush(FAR FILE *stream, bool bforce)
|
|||||||
{
|
{
|
||||||
/* Perform the write */
|
/* Perform the write */
|
||||||
|
|
||||||
bytes_written = write(stream->fs_filedes, src, nbuffer);
|
bytes_written = write(stream->fs_fd, src, nbuffer);
|
||||||
if (bytes_written < 0)
|
if (bytes_written < 0)
|
||||||
{
|
{
|
||||||
/* Write failed. The cause of the failure is in 'errno'.
|
/* Write failed. The cause of the failure is in 'errno'.
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ int lib_flushall(FAR struct streamlist *list)
|
|||||||
* write data in the stream.
|
* write data in the stream.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (stream->fs_filedes >= 0 && (stream->fs_oflags & O_WROK) != 0)
|
if (stream->fs_fd >= 0 && (stream->fs_oflags & O_WROK) != 0)
|
||||||
{
|
{
|
||||||
/* Flush the writable FILE */
|
/* Flush the writable FILE */
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE *stream)
|
|||||||
|
|
||||||
if (count > buffer_available)
|
if (count > buffer_available)
|
||||||
{
|
{
|
||||||
bytes_read = read(stream->fs_filedes, dest, count);
|
bytes_read = read(stream->fs_fd, dest, count);
|
||||||
if (bytes_read < 0)
|
if (bytes_read < 0)
|
||||||
{
|
{
|
||||||
/* An error occurred on the read. The error code is
|
/* An error occurred on the read. The error code is
|
||||||
@@ -226,7 +226,7 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE *stream)
|
|||||||
* into the buffer.
|
* into the buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bytes_read = read(stream->fs_filedes, stream->fs_bufread, buffer_available);
|
bytes_read = read(stream->fs_fd, stream->fs_bufread, buffer_available);
|
||||||
if (bytes_read < 0)
|
if (bytes_read < 0)
|
||||||
{
|
{
|
||||||
/* An error occurred on the read. The error code is
|
/* An error occurred on the read. The error code is
|
||||||
@@ -258,7 +258,7 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE *stream)
|
|||||||
|
|
||||||
while (count > 0)
|
while (count > 0)
|
||||||
{
|
{
|
||||||
bytes_read = read(stream->fs_filedes, dest, count);
|
bytes_read = read(stream->fs_fd, dest, count);
|
||||||
if (bytes_read < 0)
|
if (bytes_read < 0)
|
||||||
{
|
{
|
||||||
/* An error occurred on the read. The error code is
|
/* An error occurred on the read. The error code is
|
||||||
@@ -307,12 +307,11 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE *stream)
|
|||||||
lib_give_semaphore(stream);
|
lib_give_semaphore(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytes_read;
|
return bytes_read;
|
||||||
|
|
||||||
/* Error exits */
|
/* Error exits */
|
||||||
|
|
||||||
errout_with_errno:
|
errout_with_errno:
|
||||||
lib_give_semaphore(stream);
|
lib_give_semaphore(stream);
|
||||||
return -get_errno();
|
return -get_errno();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* libc/stdio/lib_libfwrite.c
|
* libc/stdio/lib_libfwrite.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -173,7 +173,6 @@ errout:
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
return write(stream->fs_filedes, ptr, count);
|
return write(stream->fs_fd, ptr, count);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_STDIO_BUFFER_SIZE */
|
#endif /* CONFIG_STDIO_BUFFER_SIZE */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* libc/stdio/lib_ungetc.c
|
* libc/stdio/lib_ungetc.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007, 2008, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -96,7 +96,7 @@ int ungetc(int c, FAR FILE *stream)
|
|||||||
|
|
||||||
/* Stream must be open for read access */
|
/* Stream must be open for read access */
|
||||||
|
|
||||||
if ((stream && stream->fs_filedes < 0) ||
|
if ((stream && stream->fs_fd < 0) ||
|
||||||
((stream->fs_oflags & O_RDOK) == 0))
|
((stream->fs_oflags & O_RDOK) == 0))
|
||||||
{
|
{
|
||||||
set_errno(EBADF);
|
set_errno(EBADF);
|
||||||
|
|||||||
+10
-10
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* net/net_vfcntl.c
|
* net/net_vfcntl.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009, 2012-2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -97,14 +97,14 @@ int net_vfcntl(int sockfd, int cmd, va_list ap)
|
|||||||
|
|
||||||
case F_GETFD:
|
case F_GETFD:
|
||||||
/* Get the file descriptor flags defined in <fcntl.h> that are associated
|
/* Get the file descriptor flags defined in <fcntl.h> that are associated
|
||||||
* with the file descriptor fildes. File descriptor flags are associated
|
* with the file descriptor fd. File descriptor flags are associated
|
||||||
* with a single file descriptor and do not affect other file descriptors
|
* with a single file descriptor and do not affect other file descriptors
|
||||||
* that refer to the same file.
|
* that refer to the same file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case F_SETFD:
|
case F_SETFD:
|
||||||
/* Set the file descriptor flags defined in <fcntl.h>, that are associated
|
/* Set the file descriptor flags defined in <fcntl.h>, that are associated
|
||||||
* with fildes, to the third argument, arg, taken as type int. If the
|
* with fd, to the third argument, arg, taken as type int. If the
|
||||||
* FD_CLOEXEC flag in the third argument is 0, the file shall remain open
|
* FD_CLOEXEC flag in the third argument is 0, the file shall remain open
|
||||||
* across the exec functions; otherwise, the file shall be closed upon
|
* across the exec functions; otherwise, the file shall be closed upon
|
||||||
* successful execution of one of the exec functions.
|
* successful execution of one of the exec functions.
|
||||||
@@ -115,7 +115,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap)
|
|||||||
|
|
||||||
case F_GETFL:
|
case F_GETFL:
|
||||||
/* Get the file status flags and file access modes, defined in <fcntl.h>,
|
/* Get the file status flags and file access modes, defined in <fcntl.h>,
|
||||||
* for the file description associated with fildes. The file access modes
|
* for the file description associated with fd. The file access modes
|
||||||
* can be extracted from the return value using the mask O_ACCMODE, which is
|
* can be extracted from the return value using the mask O_ACCMODE, which is
|
||||||
* defined in <fcntl.h>. File status flags and file access modes are associated
|
* defined in <fcntl.h>. File status flags and file access modes are associated
|
||||||
* with the file description and do not affect other file descriptors that
|
* with the file description and do not affect other file descriptors that
|
||||||
@@ -140,7 +140,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap)
|
|||||||
|
|
||||||
case F_SETFL:
|
case F_SETFL:
|
||||||
/* Set the file status flags, defined in <fcntl.h>, for the file description
|
/* Set the file status flags, defined in <fcntl.h>, for the file description
|
||||||
* associated with fildes from the corresponding bits in the third argument,
|
* associated with fd from the corresponding bits in the third argument,
|
||||||
* arg, taken as type int. Bits corresponding to the file access mode and
|
* arg, taken as type int. Bits corresponding to the file access mode and
|
||||||
* the file creation flags, as defined in <fcntl.h>, that are set in arg shall
|
* the file creation flags, as defined in <fcntl.h>, that are set in arg shall
|
||||||
* be ignored. If any bits in arg other than those mentioned here are changed
|
* be ignored. If any bits in arg other than those mentioned here are changed
|
||||||
@@ -170,18 +170,18 @@ int net_vfcntl(int sockfd, int cmd, va_list ap)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case F_GETOWN:
|
case F_GETOWN:
|
||||||
/* If fildes refers to a socket, get the process or process group ID specified
|
/* If fd refers to a socket, get the process or process group ID specified
|
||||||
* to receive SIGURG signals when out-of-band data is available. Positive values
|
* to receive SIGURG signals when out-of-band data is available. Positive values
|
||||||
* indicate a process ID; negative values, other than -1, indicate a process group
|
* indicate a process ID; negative values, other than -1, indicate a process group
|
||||||
* ID. If fildes does not refer to a socket, the results are unspecified.
|
* ID. If fd does not refer to a socket, the results are unspecified.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case F_SETOWN:
|
case F_SETOWN:
|
||||||
/* If fildes refers to a socket, set the process or process group ID specified
|
/* If fd refers to a socket, set the process or process group ID specified
|
||||||
* to receive SIGURG signals when out-of-band data is available, using the value
|
* to receive SIGURG signals when out-of-band data is available, using the value
|
||||||
* of the third argument, arg, taken as type int. Positive values indicate a
|
* of the third argument, arg, taken as type int. Positive values indicate a
|
||||||
* process ID; negative values, other than -1, indicate a process group ID. If
|
* process ID; negative values, other than -1, indicate a process group ID. If
|
||||||
* fildes does not refer to a socket, the results are unspecified.
|
* fd does not refer to a socket, the results are unspecified.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case F_GETLK:
|
case F_GETLK:
|
||||||
|
|||||||
Reference in New Issue
Block a user