summaryrefslogtreecommitdiff
path: root/nuttx/fs/fs_ioctl.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-02-01 22:19:20 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-02-01 22:19:20 +0000
commit51f96a502ea130e3d83eff679b560608a8246a75 (patch)
treee369db19378fc1244ded2d76e0c5e86765305eeb /nuttx/fs/fs_ioctl.c
parent5551ed84bf3a90972b46c67808d8ed24e6ca07d8 (diff)
downloadpx4-nuttx-51f96a502ea130e3d83eff679b560608a8246a75.tar.gz
px4-nuttx-51f96a502ea130e3d83eff679b560608a8246a75.tar.bz2
px4-nuttx-51f96a502ea130e3d83eff679b560608a8246a75.zip
Added lseek()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@612 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/fs/fs_ioctl.c')
-rw-r--r--nuttx/fs/fs_ioctl.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/nuttx/fs/fs_ioctl.c b/nuttx/fs/fs_ioctl.c
index ba81228c1..0d0889164 100644
--- a/nuttx/fs/fs_ioctl.c
+++ b/nuttx/fs/fs_ioctl.c
@@ -1,7 +1,7 @@
/****************************************************************************
* fs/fs_ioctl.c
*
- * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
- * 3. Neither the name Gregory Nutt 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
* without specific prior written permission.
*
@@ -42,9 +42,9 @@
****************************************************************************/
#include <nuttx/config.h>
+
#include <sys/types.h>
#include <sys/ioctl.h>
-
#include <sched.h>
#include <errno.h>
@@ -67,7 +67,7 @@
* Perform device specific operations.
*
* Parameters:
- * fd Filt/socket descriptor of device
+ * fd File/socket descriptor of device
* req The ioctl command
* arg The argument of the ioctl cmd
*
@@ -94,7 +94,9 @@ int ioctl(int fd, int req, unsigned long arg)
int err;
#if CONFIG_NFILE_DESCRIPTORS > 0
FAR struct filelist *list;
- int ret = OK;
+ FAR struct file *this_file;
+ FAR struct inode *inode;
+ int ret = OK;
/* Did we get a valid file descriptor? */
@@ -126,25 +128,20 @@ int ioctl(int fd, int req, unsigned long arg)
goto errout;
}
- /* Were we give a valid file descriptor? */
+ /* Is a driver registered? Does it support the ioctl method? */
- if ((unsigned int)fd < CONFIG_NFILE_DESCRIPTORS)
- {
- FAR struct file *this_file = &list->fl_files[fd];
- struct inode *inode = this_file->f_inode;
+ this_file = &list->fl_files[fd];
+ inode = this_file->f_inode;
- /* Is a driver registered? Does it support the ioctl method? */
+ if (inode && inode->u.i_ops && inode->u.i_ops->ioctl)
+ {
+ /* Yes, then let it perform the ioctl */
- if (inode && inode->u.i_ops && inode->u.i_ops->ioctl)
+ ret = (int)inode->u.i_ops->ioctl(this_file, req, arg);
+ if (ret < 0)
{
- /* Yes, then let it perform the ioctl */
-
- ret = (int)inode->u.i_ops->ioctl(this_file, req, arg);
- if (ret < 0)
- {
- err = -ret;
- goto errout;
- }
+ err = -ret;
+ goto errout;
}
}
return ret;