MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / close

Function close

components/dfs/dfs_v2/src/dfs_posix.c:284–308  ·  view source on GitHub ↗

* this function is a POSIX compliant version, which will close the open * file descriptor. * * @param fd the file descriptor. * * @return 0 on successful, -1 on failed. */

Source from the content-addressed store, hash-verified

282 * @return 0 on successful, -1 on failed.
283 */
284int close(int fd)
285{
286 int result;
287 struct dfs_file *file;
288
289 file = fd_get(fd);
290 if (file == NULL)
291 {
292 rt_set_errno(-EBADF);
293
294 return -1;
295 }
296
297 result = dfs_file_close(file);
298 if (result < 0)
299 {
300 rt_set_errno(result);
301
302 return -1;
303 }
304
305 fd_release(fd);
306
307 return 0;
308}
309RTM_EXPORT(close);
310
311/**

Callers 1

dfs_devfs_device_addFunction · 0.50

Calls 4

rt_set_errnoFunction · 0.85
fd_getFunction · 0.70
dfs_file_closeFunction · 0.70
fd_releaseFunction · 0.70

Tested by

no test coverage detected