posix: include: dirent: rework the dirent.h header
Declare standard functions and split type definitions into sys/dirent.h . Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This commit is contained in:
parent
c0e0fc5d7f
commit
2423219ea1
3 changed files with 61 additions and 20 deletions
|
|
@ -1,40 +1,46 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018 Intel Corporation
|
* Copyright (c) 2018 Intel Corporation
|
||||||
|
* Copyright (c) 2024 Tenstorrent AI ULC
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ZEPHYR_INCLUDE_POSIX_DIRENT_H_
|
#ifndef ZEPHYR_INCLUDE_POSIX_DIRENT_H_
|
||||||
#define ZEPHYR_INCLUDE_POSIX_DIRENT_H_
|
#define ZEPHYR_INCLUDE_POSIX_DIRENT_H_
|
||||||
|
|
||||||
#include <limits.h>
|
#include <zephyr/posix/sys/dirent.h>
|
||||||
|
#include <zephyr/toolchain.h>
|
||||||
#include <zephyr/posix/posix_types.h>
|
|
||||||
|
|
||||||
#ifdef CONFIG_POSIX_FILE_SYSTEM
|
|
||||||
#include <zephyr/fs/fs.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void DIR;
|
#if (_POSIX_C_SOURCE >= 200809L) || (_XOPEN_SOURCE >= 700)
|
||||||
|
int alphasort(const struct dirent **d1, const struct dirent **d2);
|
||||||
struct dirent {
|
#endif
|
||||||
unsigned int d_ino;
|
|
||||||
char d_name[PATH_MAX + 1];
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Directory related operations */
|
|
||||||
DIR *opendir(const char *dirname);
|
|
||||||
int closedir(DIR *dirp);
|
int closedir(DIR *dirp);
|
||||||
|
#if (_POSIX_C_SOURCE >= 200809L) || (_XOPEN_SOURCE >= 700)
|
||||||
|
int dirfd(DIR *dirp);
|
||||||
|
#endif
|
||||||
|
DIR *fdopendir(int fd);
|
||||||
|
DIR *opendir(const char *dirname);
|
||||||
struct dirent *readdir(DIR *dirp);
|
struct dirent *readdir(DIR *dirp);
|
||||||
|
#if (_POSIX_C_SOURCE >= 199506L) || (_XOPEN_SOURCE >= 500)
|
||||||
int readdir_r(DIR *ZRESTRICT dirp, struct dirent *ZRESTRICT entry,
|
int readdir_r(DIR *ZRESTRICT dirp, struct dirent *ZRESTRICT entry,
|
||||||
struct dirent **ZRESTRICT result);
|
struct dirent **ZRESTRICT result);
|
||||||
|
#endif
|
||||||
|
void rewinddir(DIR *dirp);
|
||||||
|
#if (_POSIX_C_SOURCE >= 200809L) || (_XOPEN_SOURCE >= 700)
|
||||||
|
int scandir(const char *dir, struct dirent ***namelist, int (*sel)(const struct dirent *),
|
||||||
|
int (*compar)(const struct dirent **, const struct dirent **));
|
||||||
|
#endif
|
||||||
|
#if defined(_XOPEN_SOURCE)
|
||||||
|
void seekdir(DIR *dirp, long loc);
|
||||||
|
long telldir(DIR *dirp);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* CONFIG_POSIX_FILE_SYSTEM */
|
#endif /* ZEPHYR_INCLUDE_POSIX_DIRENT_H_ */
|
||||||
|
|
||||||
#endif /* ZEPHYR_INCLUDE_POSIX_DIRENT_H_ */
|
|
||||||
|
|
|
||||||
37
include/zephyr/posix/sys/dirent.h
Normal file
37
include/zephyr/posix/sys/dirent.h
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024 Tenstorrent AI ULC
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZEPHYR_INCLUDE_POSIX_SYS_DIRENT_H_
|
||||||
|
#define ZEPHYR_INCLUDE_POSIX_SYS_DIRENT_H_
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#include <zephyr/posix/posix_features.h>
|
||||||
|
|
||||||
|
#if !defined(NAME_MAX) && defined(_XOPEN_SOURCE)
|
||||||
|
#define NAME_MAX _XOPEN_NAME_MAX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(NAME_MAX) && defined(_POSIX_C_SOURCE)
|
||||||
|
#define NAME_MAX _POSIX_NAME_MAX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef void DIR;
|
||||||
|
|
||||||
|
struct dirent {
|
||||||
|
unsigned int d_ino;
|
||||||
|
char d_name[NAME_MAX + 1];
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ZEPHYR_INCLUDE_POSIX_SYS_DIRENT_H_ */
|
||||||
|
|
@ -7,11 +7,9 @@
|
||||||
#include "fs_priv.h"
|
#include "fs_priv.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <zephyr/fs/fs.h>
|
#include <zephyr/fs/fs.h>
|
||||||
#include <zephyr/posix/posix_features.h>
|
|
||||||
#include <zephyr/posix/dirent.h>
|
#include <zephyr/posix/dirent.h>
|
||||||
#include <zephyr/sys/util.h>
|
#include <zephyr/sys/util.h>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue