From 1ce104ccfcd0e4e4876da90d8879bef73ca00cf4 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 28 Sep 2014 11:06:21 -0600 Subject: Move drive from fs/. to fs/driver/. --- nuttx/fs/Makefile | 5 +- nuttx/fs/driver/fs_closeblockdriver.c | 112 ++++++++++++++++++++++++ nuttx/fs/driver/fs_findblockdriver.c | 131 +++++++++++++++++++++++++++++ nuttx/fs/driver/fs_openblockdriver.c | 128 ++++++++++++++++++++++++++++ nuttx/fs/driver/fs_registerblockdriver.c | 124 +++++++++++++++++++++++++++ nuttx/fs/driver/fs_registerdriver.c | 120 ++++++++++++++++++++++++++ nuttx/fs/driver/fs_unregisterblockdriver.c | 86 +++++++++++++++++++ nuttx/fs/driver/fs_unregisterdriver.c | 86 +++++++++++++++++++ nuttx/fs/fs_closeblockdriver.c | 112 ------------------------ nuttx/fs/fs_findblockdriver.c | 131 ----------------------------- nuttx/fs/fs_openblockdriver.c | 128 ---------------------------- nuttx/fs/fs_registerblockdriver.c | 124 --------------------------- nuttx/fs/fs_registerdriver.c | 120 -------------------------- nuttx/fs/fs_unregisterblockdriver.c | 86 ------------------- nuttx/fs/fs_unregisterdriver.c | 86 ------------------- nuttx/fs/inode/fs_files.c | 2 +- nuttx/fs/inode/fs_foreachinode.c | 2 +- nuttx/fs/inode/fs_inode.c | 2 +- nuttx/fs/inode/fs_inodeaddref.c | 2 +- nuttx/fs/inode/fs_inodebasename.c | 2 +- nuttx/fs/inode/fs_inodefind.c | 2 +- nuttx/fs/inode/fs_inoderelease.c | 2 +- nuttx/fs/inode/fs_inoderemove.c | 2 +- nuttx/fs/inode/fs_inodereserve.c | 2 +- 24 files changed, 797 insertions(+), 800 deletions(-) create mode 100644 nuttx/fs/driver/fs_closeblockdriver.c create mode 100644 nuttx/fs/driver/fs_findblockdriver.c create mode 100644 nuttx/fs/driver/fs_openblockdriver.c create mode 100644 nuttx/fs/driver/fs_registerblockdriver.c create mode 100644 nuttx/fs/driver/fs_registerdriver.c create mode 100644 nuttx/fs/driver/fs_unregisterblockdriver.c create mode 100644 nuttx/fs/driver/fs_unregisterdriver.c delete mode 100644 nuttx/fs/fs_closeblockdriver.c delete mode 100644 nuttx/fs/fs_findblockdriver.c delete mode 100644 nuttx/fs/fs_openblockdriver.c delete mode 100644 nuttx/fs/fs_registerblockdriver.c delete mode 100644 nuttx/fs/fs_registerdriver.c delete mode 100644 nuttx/fs/fs_unregisterblockdriver.c delete mode 100644 nuttx/fs/fs_unregisterdriver.c diff --git a/nuttx/fs/Makefile b/nuttx/fs/Makefile index c5c61a6d2..856cc231c 100644 --- a/nuttx/fs/Makefile +++ b/nuttx/fs/Makefile @@ -67,14 +67,11 @@ CSRCS += fs_open.c fs_opendir.c fs_poll.c fs_read.c fs_readdir.c CSRCS += fs_rename.c fs_rewinddir.c fs_rmdir.c fs_seekdir.c fs_stat.c CSRCS += fs_statfs.c fs_select.c fs_unlink.c fs_write.c -CSRCS += fs_registerdriver.c fs_unregisterdriver.c -CSRCS += fs_registerblockdriver.c fs_unregisterblockdriver.c -CSRCS += fs_findblockdriver.c fs_openblockdriver.c fs_closeblockdriver.c - DEPPATH = --dep-path . VPATH = . include inode/Make.defs +include driver/Make.defs include mmap/Make.defs # Stream support diff --git a/nuttx/fs/driver/fs_closeblockdriver.c b/nuttx/fs/driver/fs_closeblockdriver.c new file mode 100644 index 000000000..a0add5cc7 --- /dev/null +++ b/nuttx/fs/driver/fs_closeblockdriver.c @@ -0,0 +1,112 @@ +/**************************************************************************** + * fs/driver/fs_closeblockdriver.c + * + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in pathname and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of pathname code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include "fs.h" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: close_blockdriver + * + * Description: + * Call the close method and release the inode + * + * Inputs: + * inode - reference to the inode of a block driver opened by open_blockdriver + * + * Return: + * Returns zero on success or a negated errno on failure: + * + * EINVAL - inode is NULL + * ENOTBLK - The inode is not a block driver + * + ****************************************************************************/ + +int close_blockdriver(FAR struct inode *inode) +{ + int ret = 0; /* Assume success */ + + /* Sanity checks */ + +#ifdef CONFIG_DEBUG + if (!inode || !inode->u.i_bops) + { + ret = -EINVAL; + goto errout; + } +#endif + + /* Verify that the inode is a block driver. */ + + if (!INODE_IS_BLOCK(inode)) + { + fdbg("inode is not a block driver\n"); + ret = -ENOTBLK; + goto errout; + } + + /* Close the block driver. Not that no mutually exclusive access + * to the driver is enforced here. That must be done in the driver + * if needed. + */ + + if (inode->u.i_bops->close) + { + ret = inode->u.i_bops->close(inode); + } + + /* Then release the reference on the inode */ + + inode_release(inode); + +errout: + return ret; +} diff --git a/nuttx/fs/driver/fs_findblockdriver.c b/nuttx/fs/driver/fs_findblockdriver.c new file mode 100644 index 000000000..73133f25f --- /dev/null +++ b/nuttx/fs/driver/fs_findblockdriver.c @@ -0,0 +1,131 @@ +/**************************************************************************** + * fs/driver/fs_openblockdriver.c + * + * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in pathname and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of pathname code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "fs.h" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: find_blockdriver + * + * Description: + * Return the inode of the block driver specified by 'pathname' + * + * Inputs: + * pathname - the full path to the block driver to be located + * mountflags - if MS_RDONLY is not set, then driver must support write + * operations (see include/sys/mount.h) + * ppinode - address of the location to return the inode reference + * + * Return: + * Returns zero on success or a negated errno on failure: + * + * EINVAL - pathname or pinode is NULL + * ENOENT - No block driver of this name is registered + * ENOTBLK - The inode associated with the pathname is not a block driver + * EACCESS - The MS_RDONLY option was not set but this driver does not + * support write access + * + ****************************************************************************/ + +int find_blockdriver(FAR const char *pathname, int mountflags, FAR struct inode **ppinode) +{ + FAR struct inode *inode; + int ret = 0; /* Assume success */ + + /* Sanity checks */ + +#ifdef CONFIG_DEBUG + if (!pathname || !ppinode) + { + ret = -EINVAL; + goto errout; + } +#endif + + /* Find the inode registered with this pathname */ + + inode = inode_find(pathname, NULL); + if (!inode) + { + fdbg("Failed to find %s\n", pathname); + ret = -ENOENT; + goto errout; + } + + /* Verify that the inode is a block driver. */ + + if (!INODE_IS_BLOCK(inode)) + { + fdbg("%s is not a block driver\n", pathname); + ret = -ENOTBLK; + goto errout_with_inode; + } + + /* Make sure that the inode supports the requested access */ + + if (!inode->u.i_bops || !inode->u.i_bops->read || + (!inode->u.i_bops->write && (mountflags & MS_RDONLY) == 0)) + { + fdbg("%s does not support requested access\n", pathname); + ret = -EACCES; + goto errout_with_inode; + } + + *ppinode = inode; + return OK; + +errout_with_inode: + inode_release(inode); +errout: + return ret; +} diff --git a/nuttx/fs/driver/fs_openblockdriver.c b/nuttx/fs/driver/fs_openblockdriver.c new file mode 100644 index 000000000..8c89572d1 --- /dev/null +++ b/nuttx/fs/driver/fs_openblockdriver.c @@ -0,0 +1,128 @@ +/**************************************************************************** + * fs/driver/fs_openblockdriver.c + * + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in pathname and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of pathname code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include "fs.h" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: open_blockdriver + * + * Description: + * Return the inode of the block driver specified by 'pathname' + * + * Inputs: + * pathname - the full path to the block driver to be opened + * mountflags - if MS_RDONLY is not set, then driver must support write + * operations (see include/sys/mount.h) + * ppinode - address of the location to return the inode reference + * + * Return: + * Returns zero on success or a negated errno on failure: + * + * EINVAL - pathname or pinode is NULL + * ENOENT - No block driver of this name is registered + * ENOTBLK - The inode associated with the pathname is not a block driver + * EACCESS - The MS_RDONLY option was not set but this driver does not + * support write access + * + ****************************************************************************/ + +int open_blockdriver(FAR const char *pathname, int mountflags, + FAR struct inode **ppinode) +{ + FAR struct inode *inode; + int ret; + + /* Minimal sanity checks */ + +#ifdef CONFIG_DEBUG + if (!ppinode) + { + ret = -EINVAL; + goto errout; + } +#endif + + /* Find the inode associated with this block driver name. find_blockdriver + * will perform all additional error checking. + */ + + ret = find_blockdriver(pathname, mountflags, &inode); + if (ret < 0) + { + fdbg("Failed to file %s block driver\n", pathname); + goto errout; + } + + /* Open the block driver. Note that no mutually exclusive access + * to the driver is enforced here. That must be done in the driver + * if needed. + */ + + if (inode->u.i_bops->open) + { + ret = inode->u.i_bops->open(inode); + if (ret < 0) + { + fdbg("%s driver open failed\n", pathname); + goto errout_with_inode; + } + } + + *ppinode = inode; + return OK; + +errout_with_inode: + inode_release(inode); +errout: + return ret; +} diff --git a/nuttx/fs/driver/fs_registerblockdriver.c b/nuttx/fs/driver/fs_registerblockdriver.c new file mode 100644 index 000000000..671ca2fa1 --- /dev/null +++ b/nuttx/fs/driver/fs_registerblockdriver.c @@ -0,0 +1,124 @@ +/**************************************************************************** + * fs/driver/fs_registerblockdriver.c + * + * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include + +#include "fs.h" + +/**************************************************************************** + * Pre-processor oDefinitions + ****************************************************************************/ + +/**************************************************************************** + * Private Variables + ****************************************************************************/ + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: register_blockdriver + * + * Description: + * Register a block driver inode the pseudo file system. + * + * Input parameters: + * path - The path to the inode to create + * bops - The block driver operations structure + * mode - inmode priviledges (not used) + * priv - Private, user data that will be associated with the inode. + * + * Returned Value: + * Zero on success (with the inode point in 'inode'); A negated errno + * value is returned on a failure (all error values returned by + * inode_reserve): + * + * EINVAL - 'path' is invalid for this operation + * EEXIST - An inode already exists at 'path' + * ENOMEM - Failed to allocate in-memory resources for the operation + * + ****************************************************************************/ + +int register_blockdriver(FAR const char *path, + FAR const struct block_operations *bops, + mode_t mode, FAR void *priv) +{ + FAR struct inode *node; + int ret; + + /* Insert an inode for the device driver -- we need to hold the inode + * semaphore to prevent access to the tree while we this. This is because + * we will have a momentarily bad true until we populate the inode with + * valid data. + */ + + inode_semtake(); + ret = inode_reserve(path, &node); + if (ret >= 0) + { + /* We have it, now populate it with block driver specific information. */ + + INODE_SET_BLOCK(node); + + node->u.i_bops = bops; +#ifdef CONFIG_FILE_MODE + node->i_mode = mode; +#endif + node->i_private = priv; + ret = OK; + } + + inode_semgive(); + return ret; +} + diff --git a/nuttx/fs/driver/fs_registerdriver.c b/nuttx/fs/driver/fs_registerdriver.c new file mode 100644 index 000000000..b249861d1 --- /dev/null +++ b/nuttx/fs/driver/fs_registerdriver.c @@ -0,0 +1,120 @@ +/**************************************************************************** + * fs/driver/fs_registerdriver.c + * + * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include + +#include "fs.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Variables + ****************************************************************************/ + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: register_driver + * + * Description: + * Register a character driver inode the pseudo file system. + * + * Input parameters: + * path - The path to the inode to create + * fops - The file operations structure + * mode - inmode priviledges (not used) + * priv - Private, user data that will be associated with the inode. + * + * Returned Value: + * Zero on success (with the inode point in 'inode'); A negated errno + * value is returned on a failure (all error values returned by + * inode_reserve): + * + * EINVAL - 'path' is invalid for this operation + * EEXIST - An inode already exists at 'path' + * ENOMEM - Failed to allocate in-memory resources for the operation + * + ****************************************************************************/ + +int register_driver(FAR const char *path, FAR const struct file_operations *fops, + mode_t mode, FAR void *priv) +{ + FAR struct inode *node; + int ret; + + /* Insert a dummy node -- we need to hold the inode semaphore because we + * will have a momentarily bad structure. + */ + + inode_semtake(); + ret = inode_reserve(path, &node); + if (ret >= 0) + { + /* We have it, now populate it with driver specific information. */ + + INODE_SET_DRIVER(node); + + node->u.i_ops = fops; +#ifdef CONFIG_FILE_MODE + node->i_mode = mode; +#endif + node->i_private = priv; + ret = OK; + } + + inode_semgive(); + return ret; +} diff --git a/nuttx/fs/driver/fs_unregisterblockdriver.c b/nuttx/fs/driver/fs_unregisterblockdriver.c new file mode 100644 index 000000000..f886cdce4 --- /dev/null +++ b/nuttx/fs/driver/fs_unregisterblockdriver.c @@ -0,0 +1,86 @@ +/**************************************************************************** + * fs/driver/fs_unregisterblockdriver.c + * + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include "fs.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Variables + ****************************************************************************/ + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: unregister_blockdriver + * + * Description: + * Remove the block driver inode at 'path' from the pseudo-file system + * + ****************************************************************************/ + +int unregister_blockdriver(const char *path) +{ + int ret; + + inode_semtake(); + ret = inode_remove(path); + inode_semgive(); + return ret; +} diff --git a/nuttx/fs/driver/fs_unregisterdriver.c b/nuttx/fs/driver/fs_unregisterdriver.c new file mode 100644 index 000000000..f9a073e19 --- /dev/null +++ b/nuttx/fs/driver/fs_unregisterdriver.c @@ -0,0 +1,86 @@ +/**************************************************************************** + * fs/driver/fs_unregisterdriver.c + * + * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include "fs.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Variables + ****************************************************************************/ + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: unregister_driver + * + * Description: + * Remove the character driver inode at 'path' from the pseudo-file system + * + ****************************************************************************/ + +int unregister_driver(FAR const char *path) +{ + int ret; + + inode_semtake(); + ret = inode_remove(path); + inode_semgive(); + return ret; +} diff --git a/nuttx/fs/fs_closeblockdriver.c b/nuttx/fs/fs_closeblockdriver.c deleted file mode 100644 index cc0e3e2bf..000000000 --- a/nuttx/fs/fs_closeblockdriver.c +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** - * fs/fs_closeblockdriver.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in pathname and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of pathname code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include "fs.h" - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: close_blockdriver - * - * Description: - * Call the close method and release the inode - * - * Inputs: - * inode - reference to the inode of a block driver opened by open_blockdriver - * - * Return: - * Returns zero on success or a negated errno on failure: - * - * EINVAL - inode is NULL - * ENOTBLK - The inode is not a block driver - * - ****************************************************************************/ - -int close_blockdriver(FAR struct inode *inode) -{ - int ret = 0; /* Assume success */ - - /* Sanity checks */ - -#ifdef CONFIG_DEBUG - if (!inode || !inode->u.i_bops) - { - ret = -EINVAL; - goto errout; - } -#endif - - /* Verify that the inode is a block driver. */ - - if (!INODE_IS_BLOCK(inode)) - { - fdbg("inode is not a block driver\n"); - ret = -ENOTBLK; - goto errout; - } - - /* Close the block driver. Not that no mutually exclusive access - * to the driver is enforced here. That must be done in the driver - * if needed. - */ - - if (inode->u.i_bops->close) - { - ret = inode->u.i_bops->close(inode); - } - - /* Then release the reference on the inode */ - - inode_release(inode); - -errout: - return ret; -} diff --git a/nuttx/fs/fs_findblockdriver.c b/nuttx/fs/fs_findblockdriver.c deleted file mode 100644 index afc1bb2b8..000000000 --- a/nuttx/fs/fs_findblockdriver.c +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** - * fs/fs_openblockdriver.c - * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in pathname and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of pathname code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -#include "fs.h" - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: find_blockdriver - * - * Description: - * Return the inode of the block driver specified by 'pathname' - * - * Inputs: - * pathname - the full path to the block driver to be located - * mountflags - if MS_RDONLY is not set, then driver must support write - * operations (see include/sys/mount.h) - * ppinode - address of the location to return the inode reference - * - * Return: - * Returns zero on success or a negated errno on failure: - * - * EINVAL - pathname or pinode is NULL - * ENOENT - No block driver of this name is registered - * ENOTBLK - The inode associated with the pathname is not a block driver - * EACCESS - The MS_RDONLY option was not set but this driver does not - * support write access - * - ****************************************************************************/ - -int find_blockdriver(FAR const char *pathname, int mountflags, FAR struct inode **ppinode) -{ - FAR struct inode *inode; - int ret = 0; /* Assume success */ - - /* Sanity checks */ - -#ifdef CONFIG_DEBUG - if (!pathname || !ppinode) - { - ret = -EINVAL; - goto errout; - } -#endif - - /* Find the inode registered with this pathname */ - - inode = inode_find(pathname, NULL); - if (!inode) - { - fdbg("Failed to find %s\n", pathname); - ret = -ENOENT; - goto errout; - } - - /* Verify that the inode is a block driver. */ - - if (!INODE_IS_BLOCK(inode)) - { - fdbg("%s is not a block driver\n", pathname); - ret = -ENOTBLK; - goto errout_with_inode; - } - - /* Make sure that the inode supports the requested access */ - - if (!inode->u.i_bops || !inode->u.i_bops->read || - (!inode->u.i_bops->write && (mountflags & MS_RDONLY) == 0)) - { - fdbg("%s does not support requested access\n", pathname); - ret = -EACCES; - goto errout_with_inode; - } - - *ppinode = inode; - return OK; - -errout_with_inode: - inode_release(inode); -errout: - return ret; -} diff --git a/nuttx/fs/fs_openblockdriver.c b/nuttx/fs/fs_openblockdriver.c deleted file mode 100644 index 5bd7b1a6f..000000000 --- a/nuttx/fs/fs_openblockdriver.c +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** - * fs/fs_openblockdriver.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in pathname and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of pathname code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include "fs.h" - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: open_blockdriver - * - * Description: - * Return the inode of the block driver specified by 'pathname' - * - * Inputs: - * pathname - the full path to the block driver to be opened - * mountflags - if MS_RDONLY is not set, then driver must support write - * operations (see include/sys/mount.h) - * ppinode - address of the location to return the inode reference - * - * Return: - * Returns zero on success or a negated errno on failure: - * - * EINVAL - pathname or pinode is NULL - * ENOENT - No block driver of this name is registered - * ENOTBLK - The inode associated with the pathname is not a block driver - * EACCESS - The MS_RDONLY option was not set but this driver does not - * support write access - * - ****************************************************************************/ - -int open_blockdriver(FAR const char *pathname, int mountflags, - FAR struct inode **ppinode) -{ - FAR struct inode *inode; - int ret; - - /* Minimal sanity checks */ - -#ifdef CONFIG_DEBUG - if (!ppinode) - { - ret = -EINVAL; - goto errout; - } -#endif - - /* Find the inode associated with this block driver name. find_blockdriver - * will perform all additional error checking. - */ - - ret = find_blockdriver(pathname, mountflags, &inode); - if (ret < 0) - { - fdbg("Failed to file %s block driver\n", pathname); - goto errout; - } - - /* Open the block driver. Note that no mutually exclusive access - * to the driver is enforced here. That must be done in the driver - * if needed. - */ - - if (inode->u.i_bops->open) - { - ret = inode->u.i_bops->open(inode); - if (ret < 0) - { - fdbg("%s driver open failed\n", pathname); - goto errout_with_inode; - } - } - - *ppinode = inode; - return OK; - -errout_with_inode: - inode_release(inode); -errout: - return ret; -} diff --git a/nuttx/fs/fs_registerblockdriver.c b/nuttx/fs/fs_registerblockdriver.c deleted file mode 100644 index d55407ff8..000000000 --- a/nuttx/fs/fs_registerblockdriver.c +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** - * fs/fs_registerblockdriver.c - * - * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include - -#include "fs.h" - -/**************************************************************************** - * Pre-processor oDefinitions - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Public Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: register_blockdriver - * - * Description: - * Register a block driver inode the pseudo file system. - * - * Input parameters: - * path - The path to the inode to create - * bops - The block driver operations structure - * mode - inmode priviledges (not used) - * priv - Private, user data that will be associated with the inode. - * - * Returned Value: - * Zero on success (with the inode point in 'inode'); A negated errno - * value is returned on a failure (all error values returned by - * inode_reserve): - * - * EINVAL - 'path' is invalid for this operation - * EEXIST - An inode already exists at 'path' - * ENOMEM - Failed to allocate in-memory resources for the operation - * - ****************************************************************************/ - -int register_blockdriver(FAR const char *path, - FAR const struct block_operations *bops, - mode_t mode, FAR void *priv) -{ - FAR struct inode *node; - int ret; - - /* Insert an inode for the device driver -- we need to hold the inode - * semaphore to prevent access to the tree while we this. This is because - * we will have a momentarily bad true until we populate the inode with - * valid data. - */ - - inode_semtake(); - ret = inode_reserve(path, &node); - if (ret >= 0) - { - /* We have it, now populate it with block driver specific information. */ - - INODE_SET_BLOCK(node); - - node->u.i_bops = bops; -#ifdef CONFIG_FILE_MODE - node->i_mode = mode; -#endif - node->i_private = priv; - ret = OK; - } - - inode_semgive(); - return ret; -} - diff --git a/nuttx/fs/fs_registerdriver.c b/nuttx/fs/fs_registerdriver.c deleted file mode 100644 index db2aa617d..000000000 --- a/nuttx/fs/fs_registerdriver.c +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** - * fs/fs_registerdriver.c - * - * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include - -#include "fs.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Public Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: register_driver - * - * Description: - * Register a character driver inode the pseudo file system. - * - * Input parameters: - * path - The path to the inode to create - * fops - The file operations structure - * mode - inmode priviledges (not used) - * priv - Private, user data that will be associated with the inode. - * - * Returned Value: - * Zero on success (with the inode point in 'inode'); A negated errno - * value is returned on a failure (all error values returned by - * inode_reserve): - * - * EINVAL - 'path' is invalid for this operation - * EEXIST - An inode already exists at 'path' - * ENOMEM - Failed to allocate in-memory resources for the operation - * - ****************************************************************************/ - -int register_driver(FAR const char *path, FAR const struct file_operations *fops, - mode_t mode, FAR void *priv) -{ - FAR struct inode *node; - int ret; - - /* Insert a dummy node -- we need to hold the inode semaphore because we - * will have a momentarily bad structure. - */ - - inode_semtake(); - ret = inode_reserve(path, &node); - if (ret >= 0) - { - /* We have it, now populate it with driver specific information. */ - - INODE_SET_DRIVER(node); - - node->u.i_ops = fops; -#ifdef CONFIG_FILE_MODE - node->i_mode = mode; -#endif - node->i_private = priv; - ret = OK; - } - - inode_semgive(); - return ret; -} diff --git a/nuttx/fs/fs_unregisterblockdriver.c b/nuttx/fs/fs_unregisterblockdriver.c deleted file mode 100644 index 206525461..000000000 --- a/nuttx/fs/fs_unregisterblockdriver.c +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** - * fs/fs_unregisterblockdriver.c - * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -#include "fs.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Public Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: unregister_blockdriver - * - * Description: - * Remove the block driver inode at 'path' from the pseudo-file system - * - ****************************************************************************/ - -int unregister_blockdriver(const char *path) -{ - int ret; - - inode_semtake(); - ret = inode_remove(path); - inode_semgive(); - return ret; -} diff --git a/nuttx/fs/fs_unregisterdriver.c b/nuttx/fs/fs_unregisterdriver.c deleted file mode 100644 index ffd287383..000000000 --- a/nuttx/fs/fs_unregisterdriver.c +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** - * fs/fs_unregisterdriver.c - * - * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -#include "fs.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Variables - ****************************************************************************/ - -/**************************************************************************** - * Public Variables - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: unregister_driver - * - * Description: - * Remove the character driver inode at 'path' from the pseudo-file system - * - ****************************************************************************/ - -int unregister_driver(FAR const char *path) -{ - int ret; - - inode_semtake(); - ret = inode_remove(path); - inode_semgive(); - return ret; -} diff --git a/nuttx/fs/inode/fs_files.c b/nuttx/fs/inode/fs_files.c index d9db965c7..839cf4f21 100644 --- a/nuttx/fs/inode/fs_files.c +++ b/nuttx/fs/inode/fs_files.c @@ -1,5 +1,5 @@ /**************************************************************************** - * fs/fs_files.c + * fs/inode/fs_files.c * * Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/nuttx/fs/inode/fs_foreachinode.c b/nuttx/fs/inode/fs_foreachinode.c index 06412d6ea..a5f32b7c0 100644 --- a/nuttx/fs/inode/fs_foreachinode.c +++ b/nuttx/fs/inode/fs_foreachinode.c @@ -1,5 +1,5 @@ /**************************************************************************** - * fs/fs_foreachinode.c + * fs/inode/fs_foreachinode.c * * Copyright (C) 2012-2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/nuttx/fs/inode/fs_inode.c b/nuttx/fs/inode/fs_inode.c index 3eb89ab4f..bcb0d2854 100644 --- a/nuttx/fs/inode/fs_inode.c +++ b/nuttx/fs/inode/fs_inode.c @@ -1,5 +1,5 @@ /**************************************************************************** - * fs/fs_inode.c + * fs/inode/fs_inode.c * * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/nuttx/fs/inode/fs_inodeaddref.c b/nuttx/fs/inode/fs_inodeaddref.c index b5c14e0b0..c0365dfca 100644 --- a/nuttx/fs/inode/fs_inodeaddref.c +++ b/nuttx/fs/inode/fs_inodeaddref.c @@ -1,5 +1,5 @@ /**************************************************************************** - * fs/fs_inodeaddref.c + * fs/inode/fs_inodeaddref.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/nuttx/fs/inode/fs_inodebasename.c b/nuttx/fs/inode/fs_inodebasename.c index 4fa78e028..d2a2ad46f 100644 --- a/nuttx/fs/inode/fs_inodebasename.c +++ b/nuttx/fs/inode/fs_inodebasename.c @@ -1,5 +1,5 @@ /**************************************************************************** - * fs/fs_basename.c + * fs/inode/fs_basename.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/nuttx/fs/inode/fs_inodefind.c b/nuttx/fs/inode/fs_inodefind.c index 88f34c87d..d91567b91 100644 --- a/nuttx/fs/inode/fs_inodefind.c +++ b/nuttx/fs/inode/fs_inodefind.c @@ -1,5 +1,5 @@ /**************************************************************************** - * fs/fs_inodefind.c + * fs/inode/fs_inodefind.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/nuttx/fs/inode/fs_inoderelease.c b/nuttx/fs/inode/fs_inoderelease.c index 5fef133de..134a59ce2 100644 --- a/nuttx/fs/inode/fs_inoderelease.c +++ b/nuttx/fs/inode/fs_inoderelease.c @@ -1,5 +1,5 @@ /**************************************************************************** - * fs_inoderelease.c + * fs/inode/fs_inoderelease.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/nuttx/fs/inode/fs_inoderemove.c b/nuttx/fs/inode/fs_inoderemove.c index 9cc6e0907..b78bf651c 100644 --- a/nuttx/fs/inode/fs_inoderemove.c +++ b/nuttx/fs/inode/fs_inoderemove.c @@ -1,5 +1,5 @@ /**************************************************************************** - * fs/fs_inoderemove.c + * fs/inode/fs_inoderemove.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/nuttx/fs/inode/fs_inodereserve.c b/nuttx/fs/inode/fs_inodereserve.c index 72d2ff031..563be7f76 100644 --- a/nuttx/fs/inode/fs_inodereserve.c +++ b/nuttx/fs/inode/fs_inodereserve.c @@ -1,5 +1,5 @@ /**************************************************************************** - * fs/fs_registerreserve.c + * fs/inode/fs_registerreserve.c * * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt -- cgit v1.2.3