mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 07:45:16 +08:00
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:
committed by
Abdelatif Guettouche
parent
156963a903
commit
a4d6af8343
+20
-31
@@ -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().
|
||||
|
||||
+24
-31
@@ -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();
|
||||
|
||||
|
||||
+7
-1
@@ -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();
|
||||
|
||||
|
||||
+5
-1
@@ -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)
|
||||
|
||||
+7
-1
@@ -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();
|
||||
|
||||
|
||||
+6
-1
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user