Check return from nxsem_wait_initialize()
Resolution of Issue 619 will require multiple steps, this part of the first step in that resolution: Every call to nxsem_wait_uninterruptible() must handle the return value from nxsem_wait_uninterruptible properly. This commit is only for those files under fs/inode. Utility functions under fs/incode were modified so the changes do extend to other fs/ sub-directories as well.
This commit is contained in:
parent
156963a903
commit
a4d6af8343
@ -1,36 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/dirent/fs_opendir.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011, 2013-2014, 2017-2018 Gregory Nutt. All
|
||||
* rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -286,7 +270,13 @@ FAR DIR *opendir(FAR const char *path)
|
||||
|
||||
SETUP_SEARCH(&desc, path, false);
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -ret;
|
||||
goto errout_with_alloc;
|
||||
}
|
||||
|
||||
if (path == NULL || *path == '\0' || strcmp(path, "/") == 0)
|
||||
{
|
||||
inode = g_root_inode;
|
||||
@ -428,6 +418,8 @@ errout_with_semaphore:
|
||||
RELEASE_SEARCH(&desc);
|
||||
inode_semgive();
|
||||
|
||||
errout_with_alloc:
|
||||
|
||||
/* Free any allocated string memory */
|
||||
|
||||
if (alloc != NULL)
|
||||
|
@ -1,36 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/dirent/fs_readdir.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011, 2017-2018 Gregory Nutt. All rights
|
||||
* reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -60,6 +44,7 @@
|
||||
static inline int readpseudodir(struct fs_dirent_s *idir)
|
||||
{
|
||||
FAR struct inode *prev;
|
||||
int ret;
|
||||
|
||||
/* Check if we are at the end of the list */
|
||||
|
||||
@ -117,9 +102,13 @@ static inline int readpseudodir(struct fs_dirent_s *idir)
|
||||
idir->fd_dir.d_type |= DTYPE_DIRECTORY;
|
||||
}
|
||||
|
||||
/* Now get the inode to vist next time that readdir() is called */
|
||||
/* Now get the inode to visit next time that readdir() is called */
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
prev = idir->u.pseudo.fd_next;
|
||||
idir->u.pseudo.fd_next = prev->i_peer; /* The next node to visit */
|
||||
@ -181,8 +170,9 @@ FAR struct dirent *readdir(DIR *dirp)
|
||||
}
|
||||
|
||||
/* A special case is when we enumerate an "empty", unused inode. That is
|
||||
* an inode in the pseudo-filesystem that has no operations and no children.
|
||||
* This is a "dangling" directory entry that has lost its children.
|
||||
* an inode in the pseudo-filesystem that has no operations and no
|
||||
* children. This is a "dangling" directory entry that has lost its
|
||||
* children.
|
||||
*/
|
||||
|
||||
inode = idir->fd_root;
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/dirent/fs_rewinddir.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011, 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -58,8 +43,13 @@
|
||||
static inline void rewindpseudodir(struct fs_dirent_s *idir)
|
||||
{
|
||||
struct inode *prev;
|
||||
int ret;
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Reset the position to the beginning */
|
||||
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/dirent/fs_seekdir.c
|
||||
*
|
||||
* Copyright (C) 2007, 2008, 2011, 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -42,6 +27,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/fs/dirent.h>
|
||||
@ -61,6 +47,7 @@ static inline void seekpseudodir(struct fs_dirent_s *idir, off_t offset)
|
||||
struct inode *curr;
|
||||
struct inode *prev;
|
||||
off_t pos;
|
||||
int ret;
|
||||
|
||||
/* Determine a starting point for the seek. If the seek
|
||||
* is "forward" from the current position, then we will
|
||||
@ -85,7 +72,13 @@ static inline void seekpseudodir(struct fs_dirent_s *idir, off_t offset)
|
||||
* be a very unpredictable operation.
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: inode_semtake failed: %d\n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
for (; curr && pos != offset; pos++, curr = curr->i_peer);
|
||||
|
||||
/* Now get the inode to vist next time that readdir() is called */
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/driver/fs_registerblockdriver.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -88,7 +73,12 @@ int register_blockdriver(FAR const char *path,
|
||||
* valid data.
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = inode_reserve(path, &node);
|
||||
if (ret >= 0)
|
||||
{
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/driver/fs_registerdriver.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -73,7 +58,8 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int register_driver(FAR const char *path, FAR const struct file_operations *fops,
|
||||
int register_driver(FAR const char *path,
|
||||
FAR const struct file_operations *fops,
|
||||
mode_t mode, FAR void *priv)
|
||||
{
|
||||
FAR struct inode *node;
|
||||
@ -83,7 +69,12 @@ int register_driver(FAR const char *path, FAR const struct file_operations *fops
|
||||
* will have a momentarily bad structure.
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = inode_reserve(path, &node);
|
||||
if (ret >= 0)
|
||||
{
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/driver/fs_registermtddriver.c
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -88,7 +73,12 @@ int register_mtddriver(FAR const char *path, FAR struct mtd_dev_s *mtd,
|
||||
* valid data.
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = inode_reserve(path, &node);
|
||||
if (ret >= 0)
|
||||
{
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/driver/fs_unregisterblockdriver.c
|
||||
*
|
||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -59,8 +44,12 @@ int unregister_blockdriver(FAR const char *path)
|
||||
{
|
||||
int ret;
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_remove(path);
|
||||
inode_semgive();
|
||||
ret = inode_semtake();
|
||||
if (ret >= 0)
|
||||
{
|
||||
ret = inode_remove(path);
|
||||
inode_semgive();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/driver/fs_unregisterdriver.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -59,8 +44,12 @@ int unregister_driver(FAR const char *path)
|
||||
{
|
||||
int ret;
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_remove(path);
|
||||
inode_semgive();
|
||||
ret = inode_semtake();
|
||||
if (ret >= 0)
|
||||
{
|
||||
ret = inode_remove(path);
|
||||
inode_semgive();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/driver/fs_unregistermtddriver.c
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -60,8 +45,12 @@ int unregister_mtddriver(FAR const char *path)
|
||||
{
|
||||
int ret;
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_remove(path);
|
||||
inode_semgive();
|
||||
ret = inode_semtake();
|
||||
if (ret >= 0)
|
||||
{
|
||||
ret = inode_remove(path);
|
||||
inode_semgive();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/inode/fs_filedetach.c
|
||||
*
|
||||
* Copyright (C) 2016-2017, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -56,9 +41,9 @@
|
||||
* Name: _files_semtake
|
||||
****************************************************************************/
|
||||
|
||||
static inline void _files_semtake(FAR struct filelist *list)
|
||||
static inline int _files_semtake(FAR struct filelist *list)
|
||||
{
|
||||
nxsem_wait_uninterruptible(&list->fl_sem);
|
||||
return nxsem_wait_uninterruptible(&list->fl_sem);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -99,6 +84,7 @@ int file_detach(int fd, FAR struct file *filep)
|
||||
{
|
||||
FAR struct filelist *list;
|
||||
FAR struct file *parent;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(filep != NULL);
|
||||
|
||||
@ -120,7 +106,14 @@ int file_detach(int fd, FAR struct file *filep)
|
||||
|
||||
/* If the file was properly opened, there should be an inode assigned */
|
||||
|
||||
_files_semtake(list);
|
||||
ret = _files_semtake(list);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Probably canceled */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
parent = &list->fl_files[fd];
|
||||
if (parent->f_inode == NULL)
|
||||
{
|
||||
|
@ -1,36 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/inode/fs_files.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011-2013, 2016-2017 Gregory Nutt. All rights
|
||||
* reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -60,9 +44,9 @@
|
||||
* Name: _files_semtake
|
||||
****************************************************************************/
|
||||
|
||||
static void _files_semtake(FAR struct filelist *list)
|
||||
static int _files_semtake(FAR struct filelist *list)
|
||||
{
|
||||
nxsem_wait_uninterruptible(&list->fl_sem);
|
||||
return nxsem_wait_uninterruptible(&list->fl_sem);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -78,7 +62,8 @@ static void _files_semtake(FAR struct filelist *list)
|
||||
* Close an inode (if open)
|
||||
*
|
||||
* Assumptions:
|
||||
* Caller holds the list semaphore because the file descriptor will be freed.
|
||||
* Caller holds the list semaphore because the file descriptor will be
|
||||
* freed.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -161,8 +146,8 @@ void files_releaselist(FAR struct filelist *list)
|
||||
DEBUGASSERT(list);
|
||||
|
||||
/* Close each file descriptor .. Normally, you would need take the list
|
||||
* semaphore, but it is safe to ignore the semaphore in this context because
|
||||
* there should not be any references in this context.
|
||||
* semaphore, but it is safe to ignore the semaphore in this context
|
||||
* because there should not be any references in this context.
|
||||
*/
|
||||
|
||||
for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++)
|
||||
@ -198,7 +183,7 @@ int file_dup2(FAR struct file *filep1, FAR struct file *filep2)
|
||||
FAR struct inode *inode;
|
||||
int ret;
|
||||
|
||||
if (!filep1 || !filep1->f_inode || !filep2)
|
||||
if (filep1 == NULL || filep1->f_inode == NULL || filep2 == NULL)
|
||||
{
|
||||
return -EBADF;
|
||||
}
|
||||
@ -214,7 +199,13 @@ int file_dup2(FAR struct file *filep1, FAR struct file *filep2)
|
||||
|
||||
if (list != NULL)
|
||||
{
|
||||
_files_semtake(list);
|
||||
ret = _files_semtake(list);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Probably canceled */
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* If there is already an inode contained in the new file structure,
|
||||
@ -232,7 +223,11 @@ int file_dup2(FAR struct file *filep1, FAR struct file *filep2)
|
||||
/* Increment the reference count on the contained inode */
|
||||
|
||||
inode = filep1->f_inode;
|
||||
inode_addref(inode);
|
||||
ret = inode_addref(inode);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout_with_sem;
|
||||
}
|
||||
|
||||
/* Then clone the file structure */
|
||||
|
||||
@ -298,14 +293,15 @@ errout_with_sem:
|
||||
* Name: files_allocate
|
||||
*
|
||||
* Description:
|
||||
* Allocate a struct files instance and associate it with an inode instance.
|
||||
* Returns the file descriptor == index into the files array.
|
||||
* Allocate a struct files instance and associate it with an inode
|
||||
* instance. Returns the file descriptor == index into the files array.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int files_allocate(FAR struct inode *inode, int oflags, off_t pos, int minfd)
|
||||
{
|
||||
FAR struct filelist *list;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* Get the file descriptor list. It should not be NULL in this context. */
|
||||
@ -313,7 +309,14 @@ int files_allocate(FAR struct inode *inode, int oflags, off_t pos, int minfd)
|
||||
list = sched_getfiles();
|
||||
DEBUGASSERT(list != NULL);
|
||||
|
||||
_files_semtake(list);
|
||||
ret = _files_semtake(list);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Probably canceled */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (i = minfd; i < CONFIG_NFILE_DESCRIPTORS; i++)
|
||||
{
|
||||
if (!list->fl_files[i].f_inode)
|
||||
@ -338,7 +341,8 @@ int files_allocate(FAR struct inode *inode, int oflags, off_t pos, int minfd)
|
||||
* Close an inode (if open)
|
||||
*
|
||||
* Assumptions:
|
||||
* Caller holds the list semaphore because the file descriptor will be freed.
|
||||
* Caller holds the list semaphore because the file descriptor will be
|
||||
* freed.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -356,16 +360,21 @@ int files_close(int fd)
|
||||
|
||||
/* If the file was properly opened, there should be an inode assigned */
|
||||
|
||||
if (fd < 0 || fd >= CONFIG_NFILE_DESCRIPTORS || !list->fl_files[fd].f_inode)
|
||||
if (fd < 0 || fd >= CONFIG_NFILE_DESCRIPTORS ||
|
||||
!list->fl_files[fd].f_inode)
|
||||
{
|
||||
return -EBADF;
|
||||
}
|
||||
|
||||
/* Perform the protected close operation */
|
||||
|
||||
_files_semtake(list);
|
||||
ret = _files_close(&list->fl_files[fd]);
|
||||
_files_semgive(list);
|
||||
ret = _files_semtake(list);
|
||||
if (ret >= 0)
|
||||
{
|
||||
ret = _files_close(&list->fl_files[fd]);
|
||||
_files_semgive(list);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -381,16 +390,20 @@ int files_close(int fd)
|
||||
void files_release(int fd)
|
||||
{
|
||||
FAR struct filelist *list;
|
||||
int ret;
|
||||
|
||||
list = sched_getfiles();
|
||||
DEBUGASSERT(list);
|
||||
DEBUGASSERT(list != NULL);
|
||||
|
||||
if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS)
|
||||
{
|
||||
_files_semtake(list);
|
||||
list->fl_files[fd].f_oflags = 0;
|
||||
list->fl_files[fd].f_pos = 0;
|
||||
list->fl_files[fd].f_inode = NULL;
|
||||
_files_semgive(list);
|
||||
ret = _files_semtake(list);
|
||||
if (ret >= 0)
|
||||
{
|
||||
list->fl_files[fd].f_oflags = 0;
|
||||
list->fl_files[fd].f_pos = 0;
|
||||
list->fl_files[fd].f_inode = NULL;
|
||||
_files_semgive(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/inode/fs_foreachinode.c
|
||||
*
|
||||
* Copyright (C) 2012-2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -90,7 +75,8 @@ struct inode_path_s
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int foreach_inodelevel(FAR struct inode *node, struct inode_path_s *info)
|
||||
static int foreach_inodelevel(FAR struct inode *node,
|
||||
FAR struct inode_path_s *info)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
@ -197,9 +183,12 @@ int foreach_inode(foreach_inode_t handler, FAR void *arg)
|
||||
|
||||
/* Start the recursion at the root inode */
|
||||
|
||||
inode_semtake();
|
||||
ret = foreach_inodelevel(g_root_inode, info);
|
||||
inode_semgive();
|
||||
ret = inode_semtake();
|
||||
if (ret >= 0)
|
||||
{
|
||||
ret = foreach_inodelevel(g_root_inode, info);
|
||||
inode_semgive();
|
||||
}
|
||||
|
||||
/* Free the info structure and return the result */
|
||||
|
||||
@ -218,9 +207,12 @@ int foreach_inode(foreach_inode_t handler, FAR void *arg)
|
||||
|
||||
/* Start the recursion at the root inode */
|
||||
|
||||
inode_semtake();
|
||||
ret = foreach_inodelevel(g_root_inode, &info);
|
||||
inode_semgive();
|
||||
ret = inode_semtake();
|
||||
if (ret >= 0)
|
||||
{
|
||||
ret = foreach_inodelevel(g_root_inode, &info);
|
||||
inode_semgive();
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
|
@ -1,36 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/inode/fs_inode.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011-2012, 2016-2017 Gregory Nutt. All rights
|
||||
* reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -121,9 +105,10 @@ void inode_initialize(void)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void inode_semtake(void)
|
||||
int inode_semtake(void)
|
||||
{
|
||||
pid_t me;
|
||||
int ret = OK;
|
||||
|
||||
/* Do we already hold the semaphore? */
|
||||
|
||||
@ -140,13 +125,17 @@ void inode_semtake(void)
|
||||
|
||||
else
|
||||
{
|
||||
nxsem_wait_uninterruptible(&g_inode_sem.sem);
|
||||
ret = nxsem_wait_uninterruptible(&g_inode_sem.sem);
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* No we hold the semaphore */
|
||||
|
||||
/* No we hold the semaphore */
|
||||
|
||||
g_inode_sem.holder = me;
|
||||
g_inode_sem.count = 1;
|
||||
g_inode_sem.holder = me;
|
||||
g_inode_sem.count = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/inode/fs_inodeaddref.c
|
||||
*
|
||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -56,12 +41,19 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void inode_addref(FAR struct inode *inode)
|
||||
int inode_addref(FAR struct inode *inode)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
if (inode)
|
||||
{
|
||||
inode_semtake();
|
||||
inode->i_crefs++;
|
||||
inode_semgive();
|
||||
ret = inode_semtake();
|
||||
if (ret >= 0)
|
||||
{
|
||||
inode->i_crefs++;
|
||||
inode_semgive();
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/inode/fs_inodefind.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -70,7 +55,12 @@ int inode_find(FAR struct inode_search_s *desc)
|
||||
* references on the node.
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = inode_search(desc);
|
||||
if (ret >= 0)
|
||||
{
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/inode/fs_inoderelease.c
|
||||
*
|
||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -39,6 +24,7 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
@ -60,11 +46,23 @@
|
||||
|
||||
void inode_release(FAR struct inode *node)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (node)
|
||||
{
|
||||
/* Decrement the references of the inode */
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
/* REVISIT: Reference count will be wrong. This could only
|
||||
* happen on thread cancellation.
|
||||
*/
|
||||
|
||||
ferr("ERROR: inode_semtake failed: %d\n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
if (node->i_crefs)
|
||||
{
|
||||
node->i_crefs--;
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/inode/inode.h
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2012, 2014, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -117,7 +102,8 @@
|
||||
* detected while traversing the path, then the link
|
||||
* will be converted to a mountpoint inode if the
|
||||
* mountpoint link is in an intermediate node of the
|
||||
* path or at the final node of the path with nofollow=true.
|
||||
* path or at the final node of the path with
|
||||
* nofollow=true.
|
||||
* nofollow - INPUT: true: terminal node is returned; false: if the
|
||||
* terminal is a soft link, then return the inode of
|
||||
* the link target.
|
||||
@ -188,7 +174,7 @@ void inode_initialize(void);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void inode_semtake(void);
|
||||
int inode_semtake(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_semgive
|
||||
@ -245,7 +231,8 @@ int inode_find(FAR struct inode_search_s *desc);
|
||||
*
|
||||
* Description:
|
||||
* The inode_stat() function will obtain information about an 'inode' in
|
||||
* the pseudo file system and will write it to the area pointed to by 'buf'.
|
||||
* the pseudo file system and will write it to the area pointed to by
|
||||
* 'buf'.
|
||||
*
|
||||
* The 'buf' argument is a pointer to a stat structure, as defined in
|
||||
* <sys/stat.h>, into which information is placed concerning the file.
|
||||
@ -349,7 +336,7 @@ int inode_remove(FAR const char *path);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void inode_addref(FAR struct inode *inode);
|
||||
int inode_addref(FAR struct inode *inode);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inode_release
|
||||
@ -372,7 +359,7 @@ void inode_release(FAR struct inode *inode);
|
||||
* NOTE 1: Use with caution... The pseudo-file system is locked throughout
|
||||
* the traversal.
|
||||
* NOTE 2: The search algorithm is recursive and could, in principle, use
|
||||
* an indeterminant amount of stack space. This will not usually be a
|
||||
* an indeterminate amount of stack space. This will not usually be a
|
||||
* real work issue.
|
||||
*
|
||||
****************************************************************************/
|
||||
@ -393,12 +380,13 @@ void weak_function files_initialize(void);
|
||||
* Name: files_allocate
|
||||
*
|
||||
* Description:
|
||||
* Allocate a struct files instance and associate it with an inode instance.
|
||||
* Returns the file descriptor == index into the files array.
|
||||
* Allocate a struct files instance and associate it with an inode
|
||||
* instance. Returns the file descriptor == index into the files array.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
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
|
||||
@ -407,7 +395,8 @@ int files_allocate(FAR struct inode *inode, int oflags, off_t pos, int minfd);
|
||||
* Close an inode (if open)
|
||||
*
|
||||
* Assumptions:
|
||||
* Caller holds the list semaphore because the file descriptor will be freed.
|
||||
* Caller holds the list semaphore because the file descriptor will be
|
||||
* freed.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/mount/fs_automount.c
|
||||
*
|
||||
* Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -131,11 +116,15 @@ static int automount_findinode(FAR const char *path)
|
||||
|
||||
/* Make sure that we were given an absolute path */
|
||||
|
||||
DEBUGASSERT(path && path[0] == '/');
|
||||
DEBUGASSERT(path != NULL && path[0] == '/');
|
||||
|
||||
/* Get exclusive access to the in-memory inode tree. */
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Find the inode */
|
||||
|
||||
@ -405,7 +394,8 @@ static void automount_timeout(int argc, uint32_t arg1, ...)
|
||||
|
||||
static void automount_worker(FAR void *arg)
|
||||
{
|
||||
FAR struct automounter_state_s *priv = (FAR struct automounter_state_s *)arg;
|
||||
FAR struct automounter_state_s *priv =
|
||||
(FAR struct automounter_state_s *)arg;
|
||||
FAR const struct automount_lower_s *lower;
|
||||
|
||||
DEBUGASSERT(priv && priv->lower);
|
||||
@ -461,7 +451,8 @@ static void automount_worker(FAR void *arg)
|
||||
static int automount_interrupt(FAR const struct automount_lower_s *lower,
|
||||
FAR void *arg, bool inserted)
|
||||
{
|
||||
FAR struct automounter_state_s *priv = (FAR struct automounter_state_s *)arg;
|
||||
FAR struct automounter_state_s *priv =
|
||||
(FAR struct automounter_state_s *)arg;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(lower && priv && priv->lower == lower);
|
||||
@ -522,8 +513,8 @@ static int automount_interrupt(FAR const struct automount_lower_s *lower,
|
||||
* lower - Persistent board configuration data
|
||||
*
|
||||
* Returned Value:
|
||||
* A void* handle. The only use for this handle is with automount_uninitialize().
|
||||
* NULL is returned on any failure.
|
||||
* A void* handle. The only use for this handle is with
|
||||
* automount_uninitialize(). NULL is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -608,7 +599,8 @@ FAR void *automount_initialize(FAR const struct automount_lower_s *lower)
|
||||
|
||||
void automount_uninitialize(FAR void *handle)
|
||||
{
|
||||
FAR struct automounter_state_s *priv = (FAR struct automounter_state_s *)handle;
|
||||
FAR struct automounter_state_s *priv =
|
||||
(FAR struct automounter_state_s *)handle;
|
||||
FAR const struct automount_lower_s *lower;
|
||||
|
||||
DEBUGASSERT(priv && priv->lower);
|
||||
|
@ -340,7 +340,12 @@ int mount(FAR const char *source, FAR const char *target,
|
||||
goto errout;
|
||||
}
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_inode;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||
/* Check if the inode already exists */
|
||||
@ -495,12 +500,10 @@ errout_with_semaphore:
|
||||
RELEASE_SEARCH(&desc);
|
||||
#endif
|
||||
|
||||
#if defined(BDFS_SUPPORT) || defined(MDFS_SUPPORT)
|
||||
errout_with_inode:
|
||||
|
||||
#ifdef NODFS_SUPPORT
|
||||
#if defined(BDFS_SUPPORT) || defined(MDFS_SUPPORT)
|
||||
if (drvr_inode != NULL)
|
||||
#endif
|
||||
{
|
||||
inode_release(drvr_inode);
|
||||
}
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/mount/fs_umount2.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -127,7 +112,15 @@ int umount2(FAR const char *target, unsigned int flags)
|
||||
* performed, or a negated error code on a failure.
|
||||
*/
|
||||
|
||||
inode_semtake(); /* Hold the semaphore through the unbind logic */
|
||||
/* Hold the semaphore through the unbind logic */
|
||||
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_mountpt;
|
||||
}
|
||||
|
||||
ret = mountpt_inode->u.i_mops->unbind(mountpt_inode->i_private,
|
||||
&blkdrvr_inode, flags);
|
||||
if (ret < 0)
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/mqueue/mq_close.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2013-2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -42,6 +27,7 @@
|
||||
#include <sched.h>
|
||||
#include <mqueue.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/sched.h>
|
||||
@ -186,9 +172,21 @@ int mq_close(mqd_t mqdes)
|
||||
|
||||
void mq_inode_release(FAR struct inode *inode)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Decrement the reference count on the inode */
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
/* REVISIT: Should get here only on task cancellation. The MQ inode
|
||||
* would not not be released in this case.
|
||||
*/
|
||||
|
||||
ferr("ERROR: inode_semtake() failed: %d\n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
if (inode->i_crefs > 0)
|
||||
{
|
||||
inode->i_crefs--;
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/mqueue/mq_open.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011, 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -194,7 +179,13 @@ mqd_t mq_open(FAR const char *mq_name, int oflags, ...)
|
||||
|
||||
/* Create an inode in the pseudo-filesystem at this path */
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
ret = inode_reserve(fullpath, &inode);
|
||||
inode_semgive();
|
||||
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/mqueue/mq_unlink.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2014, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -116,7 +101,13 @@ int mq_unlink(FAR const char *mq_name)
|
||||
* functioning as a directory and the directory is not empty.
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_inode;
|
||||
}
|
||||
|
||||
if (inode->i_child != NULL)
|
||||
{
|
||||
errcode = ENOTEMPTY;
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/semaphore/sem_close.c
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -83,7 +68,8 @@
|
||||
int sem_close(FAR sem_t *sem)
|
||||
{
|
||||
FAR struct nsem_inode_s *nsem;
|
||||
struct inode *inode ;
|
||||
struct inode *inode;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(sem);
|
||||
|
||||
@ -95,7 +81,17 @@ int sem_close(FAR sem_t *sem)
|
||||
|
||||
/* Decrement the reference count on the inode */
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
/* REVISIT: This failure is probably -ECANCELED meaning that the
|
||||
* thread was canceled. In this case, the semaphore will not be
|
||||
* closed.
|
||||
*/
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (inode->i_crefs > 0)
|
||||
{
|
||||
inode->i_crefs--;
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/semaphore/sem_open.c
|
||||
*
|
||||
* Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -70,7 +55,8 @@
|
||||
* may reference the semaphore associated with name using the address
|
||||
* returned by this call. The semaphore may be used in subsequent calls
|
||||
* to sem_wait(), sem_trywait(), and sem_post(). The semaphore remains
|
||||
* usable until the semaphore is closed by a successful call to sem_close().
|
||||
* usable until the semaphore is closed by a successful call to
|
||||
* sem_close().
|
||||
*
|
||||
* If a task makes multiple calls to sem_open() with the same name, then
|
||||
* the same semaphore address is returned (provided there have been no
|
||||
@ -205,7 +191,13 @@ FAR sem_t *sem_open (FAR const char *name, int oflags, ...)
|
||||
* inode will be created with a reference count of zero.
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
ret = inode_reserve(fullpath, &inode);
|
||||
inode_semgive();
|
||||
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/semaphore/sem_unlink.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2014, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -120,7 +105,13 @@ int sem_unlink(FAR const char *name)
|
||||
* functioning as a directory and the directory is not empty.
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_inode;
|
||||
}
|
||||
|
||||
if (inode->i_child != NULL)
|
||||
{
|
||||
errcode = ENOTEMPTY;
|
||||
@ -145,8 +136,8 @@ int sem_unlink(FAR const char *name)
|
||||
/* Now we do not release the reference count in the normal way (by calling
|
||||
* inode release. Rather, we call sem_close(). sem_close will decrement
|
||||
* the reference count on the inode. But it will also free the semaphore
|
||||
* if that reference count decrements to zero. Since we hold one reference,
|
||||
* that can only occur if the semaphore is not in-use.
|
||||
* if that reference count decrements to zero. Since we hold one
|
||||
* reference, that can only occur if the semaphore is not in-use.
|
||||
*/
|
||||
|
||||
inode_semgive();
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/unionfs/fs_unionfs.c
|
||||
*
|
||||
* Copyright (C) 2015, 2017-2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -155,7 +140,8 @@ static ssize_t unionfs_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen);
|
||||
static ssize_t unionfs_write(FAR struct file *filep, FAR const char *buffer,
|
||||
size_t buflen);
|
||||
static off_t unionfs_seek(FAR struct file *filep, off_t offset, int whence);
|
||||
static off_t unionfs_seek(FAR struct file *filep, off_t offset,
|
||||
int whence);
|
||||
static int unionfs_ioctl(FAR struct file *filep, int cmd,
|
||||
unsigned long arg);
|
||||
static int unionfs_sync(FAR struct file *filep);
|
||||
@ -176,8 +162,8 @@ static int unionfs_readdir(FAR struct inode *mountpt,
|
||||
static int unionfs_rewinddir(FAR struct inode *mountpt,
|
||||
FAR struct fs_dirent_s *dir);
|
||||
|
||||
static int unionfs_bind(FAR struct inode *blkdriver, FAR const void *data,
|
||||
FAR void **handle);
|
||||
static int unionfs_bind(FAR struct inode *blkdriver,
|
||||
FAR const void *data, FAR void **handle);
|
||||
static int unionfs_unbind(FAR void *handle, FAR struct inode **blkdriver,
|
||||
unsigned int flags);
|
||||
static int unionfs_statfs(FAR struct inode *mountpt,
|
||||
@ -428,7 +414,8 @@ static int unionfs_tryopen(FAR struct file *filep, FAR const char *relpath,
|
||||
****************************************************************************/
|
||||
|
||||
static int unionfs_tryopendir(FAR struct inode *inode,
|
||||
FAR const char *relpath, FAR const char *prefix,
|
||||
FAR const char *relpath,
|
||||
FAR const char *prefix,
|
||||
FAR struct fs_dirent_s *dir)
|
||||
{
|
||||
FAR const struct mountpt_operations *ops;
|
||||
@ -855,7 +842,8 @@ static int unionfs_open(FAR struct file *filep, FAR const char *relpath,
|
||||
|
||||
/* Allocate a container to hold the open file system information */
|
||||
|
||||
uf = (FAR struct unionfs_file_s *)kmm_malloc(sizeof(struct unionfs_file_s));
|
||||
uf = (FAR struct unionfs_file_s *)
|
||||
kmm_malloc(sizeof(struct unionfs_file_s));
|
||||
if (uf == NULL)
|
||||
{
|
||||
ret = -ENOMEM;
|
||||
@ -1428,7 +1416,8 @@ static int unionfs_truncate(FAR struct file *filep, off_t length)
|
||||
* Name: unionfs_opendir
|
||||
****************************************************************************/
|
||||
|
||||
static int unionfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
static int unionfs_opendir(FAR struct inode *mountpt,
|
||||
FAR const char *relpath,
|
||||
FAR struct fs_dirent_s *dir)
|
||||
{
|
||||
FAR struct unionfs_inode_s *ui;
|
||||
@ -1471,7 +1460,8 @@ static int unionfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
|
||||
/* Allocate another dirent structure for the lower file system */
|
||||
|
||||
lowerdir = (FAR struct fs_dirent_s *)kmm_zalloc(sizeof(struct fs_dirent_s));
|
||||
lowerdir = (FAR struct fs_dirent_s *)
|
||||
kmm_zalloc(sizeof(struct fs_dirent_s));
|
||||
if (lowerdir == NULL)
|
||||
{
|
||||
ret = -ENOMEM;
|
||||
@ -2194,14 +2184,16 @@ static int unionfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
|
||||
{
|
||||
if (buf1.f_bsize < buf2.f_bsize)
|
||||
{
|
||||
tmp = (((uint64_t)buf2.f_blocks * (uint64_t)buf2.f_bsize) << 16);
|
||||
tmp = (((uint64_t)buf2.f_blocks *
|
||||
(uint64_t)buf2.f_bsize) << 16);
|
||||
ratiob16 = (uint32_t)(tmp / buf1.f_bsize);
|
||||
adj = &buf2;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf->f_bsize = buf2.f_bsize;
|
||||
tmp = (((uint64_t)buf1.f_blocks * (uint64_t)buf1.f_bsize) << 16);
|
||||
tmp = (((uint64_t)buf1.f_blocks *
|
||||
(uint64_t)buf1.f_bsize) << 16);
|
||||
ratiob16 = (uint32_t)(tmp / buf2.f_bsize);
|
||||
adj = &buf1;
|
||||
}
|
||||
@ -2814,7 +2806,12 @@ int unionfs_mount(FAR const char *fspath1, FAR const char *prefix1,
|
||||
* NOTE that the inode will be created with a reference count of zero.
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = inode_reserve(mountpt, &mpinode);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -1,36 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/vfs/fs_dupfd.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011-2014, 2017 Gregory Nutt. All rights
|
||||
* reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -75,6 +59,7 @@
|
||||
int file_dup(FAR struct file *filep, int minfd)
|
||||
{
|
||||
int fd2;
|
||||
int ret;
|
||||
|
||||
/* Verify that fd is a valid, open file descriptor */
|
||||
|
||||
@ -85,7 +70,11 @@ int file_dup(FAR struct file *filep, int minfd)
|
||||
|
||||
/* Increment the reference count on the contained inode */
|
||||
|
||||
inode_addref(filep->f_inode);
|
||||
ret = inode_addref(filep->f_inode);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Then allocate a new file descriptor for the inode */
|
||||
|
||||
@ -103,8 +92,8 @@ int file_dup(FAR struct file *filep, int minfd)
|
||||
* Name: fs_dupfd OR dup
|
||||
*
|
||||
* Description:
|
||||
* Clone a file descriptor 'fd' to an arbitrary descriptor number (any value
|
||||
* greater than or equal to 'minfd'). If socket descriptors are
|
||||
* Clone a file descriptor 'fd' to an arbitrary descriptor number (any
|
||||
* value greater than or equal to 'minfd'). If socket descriptors are
|
||||
* implemented, then this is called by dup() for the case of file
|
||||
* descriptors. If socket descriptors are not implemented, then this
|
||||
* function IS dup().
|
||||
|
@ -1,35 +1,20 @@
|
||||
/****************************************************************************
|
||||
* fs/vfs/fs_link.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -78,7 +63,8 @@
|
||||
*
|
||||
* Input Parameters:
|
||||
* path1 - Points to a pathname naming an existing file.
|
||||
* path2 - Points to a pathname naming the new directory entry to be created.
|
||||
* path2 - Points to a pathname naming the new directory entry to be
|
||||
* created.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, zero (OK) is returned. Otherwise, -1 (ERROR) is returned
|
||||
@ -103,8 +89,8 @@ int link(FAR const char *path1, FAR const char *path2)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Check that no inode exists at the 'path1' and that the path up to 'path1'
|
||||
* does not lie on a mounted volume.
|
||||
/* Check that no inode exists at the 'path1' and that the path up to
|
||||
* 'path1' does not lie on a mounted volume.
|
||||
*/
|
||||
|
||||
SETUP_SEARCH(&desc, path2, false);
|
||||
@ -157,7 +143,14 @@ int link(FAR const char *path1, FAR const char *path2)
|
||||
* count of zero.
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
kmm_free(newpath2);
|
||||
errcode = -ret;
|
||||
goto errout_with_search;
|
||||
}
|
||||
|
||||
ret = inode_reserve(path2, &inode);
|
||||
inode_semgive();
|
||||
|
||||
|
@ -140,7 +140,13 @@ int mkdir(const char *pathname, mode_t mode)
|
||||
* count of zero.
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_search;
|
||||
}
|
||||
|
||||
ret = inode_reserve(pathname, &inode);
|
||||
inode_semgive();
|
||||
|
||||
|
@ -208,7 +208,11 @@ next_subdir:
|
||||
* of zero.
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout;
|
||||
}
|
||||
|
||||
ret = inode_reserve(newpath, &newinode);
|
||||
if (ret < 0)
|
||||
|
@ -143,7 +143,13 @@ int rmdir(FAR const char *pathname)
|
||||
* -EBUSY to indicate that the inode was not deleted now.
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_inode;
|
||||
}
|
||||
|
||||
ret = inode_remove(pathname);
|
||||
inode_semgive();
|
||||
|
||||
|
@ -138,7 +138,12 @@ int unlink(FAR const char *pathname)
|
||||
|
||||
if (inode->u.i_ops != NULL)
|
||||
{
|
||||
inode_semtake();
|
||||
ret = inode_semtake();
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout_with_inode;
|
||||
}
|
||||
|
||||
/* Refuse to unlink the inode if it has children. I.e., if it is
|
||||
* functioning as a directory and the directory is not empty.
|
||||
|
Loading…
Reference in New Issue
Block a user