1 /**************************************************************************** 2 * include/fs/file.h 3 * 4 * Copyright (C) 2007-2009, 2011-2013, 2015-2018 Gregory Nutt. All rights 5 * reserved. 6 * Author: Gregory Nutt <gnutt@nuttx.org> 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in 16 * the documentation and/or other materials provided with the 17 * distribution. 18 * 3. Neither the name NuttX nor the names of its contributors may be 19 * used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 29 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 * 35 ****************************************************************************/ 36 37 #ifndef __INCLUDE_FS_FILE_H 38 #define __INCLUDE_FS_FILE_H 39 40 /**************************************************************************** 41 * Included Files 42 ****************************************************************************/ 43 44 #include "vfs_config.h" 45 46 #include "sys/types.h" 47 #include "stdarg.h" 48 #include "stdint.h" 49 50 #include "semaphore.h" 51 52 #ifdef __cplusplus 53 #if __cplusplus 54 extern "C" { 55 #endif /* __cplusplus */ 56 #endif /* __cplusplus */ 57 58 /**************************************************************************** 59 * Global Function Prototypes 60 ****************************************************************************/ 61 62 /* Callback used by foreach_mountpoints to traverse all mountpoints in the 63 * pseudo-file system. 64 */ 65 66 struct statfs; /* Forward reference */ 67 typedef int (*foreach_mountpoint_t)(const char *mountpoint, 68 struct statfs *statbuf, 69 void *arg); 70 71 struct filelist *sched_getfiles(void); 72 73 /* fs/fs_sendfile.c *************************************************/ 74 /**************************************************************************** 75 * Name: sendfile 76 * 77 * Description: 78 * Copy data between one file descriptor and another. 79 * 80 ****************************************************************************/ 81 ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count); 82 83 /** 84 * @ingroup fs 85 * @brief get the path by a given file fd. 86 * 87 * @par Description: 88 * The function is used for getting the path by a given file fd. 89 * 90 * @attention 91 * <ul> 92 * <li>Only support file fd, not any dir fd.</li> 93 * </ul> 94 * 95 * @param fd [IN] Type #int file fd. 96 * @param path [IN] Type #char ** address of the location to return the path reference. 97 * 98 * @retval #0 get path success 99 * @retval #~0 get path failed 100 * 101 * @par Dependency: 102 * <ul><li>fs.h: the header file that contains the API declaration.</li></ul> 103 * @see 104 * 105 * @since 2020-1-8 106 */ 107 108 extern int get_path_from_fd(int fd, char **path); 109 bool get_bit(int i); 110 111 #ifdef __cplusplus 112 #if __cplusplus 113 } 114 #endif /* __cplusplus */ 115 #endif /* __cplusplus */ 116 #endif /* __INCLUDE_FS_FILE_H */ 117