]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pmdk/src/core/fs_posix.c
1 // SPDX-License-Identifier: BSD-3-Clause
2 /* Copyright 2017-2020, Intel Corporation */
5 * fs_posix.c -- file system traversal Posix implementation
16 struct fs_entry entry
;
20 * fs_new -- creates fs traversal instance
23 fs_new(const char *path
)
25 struct fs
*f
= Zalloc(sizeof(*f
));
29 const char *paths
[2] = {path
, NULL
};
30 f
->ft
= fts_open((char * const *)paths
, FTS_COMFOLLOW
| FTS_XDEV
, NULL
);
43 * fs_read -- reads an entry from the fs path
48 FTSENT
*entry
= fts_read(f
->ft
);
52 switch (entry
->fts_info
) {
54 f
->entry
.type
= FS_ENTRY_DIRECTORY
;
57 f
->entry
.type
= FS_ENTRY_FILE
;
60 f
->entry
.type
= FS_ENTRY_SYMLINK
;
63 f
->entry
.type
= FS_ENTRY_OTHER
;
67 f
->entry
.name
= entry
->fts_name
;
68 f
->entry
.namelen
= entry
->fts_namelen
;
69 f
->entry
.path
= entry
->fts_path
;
70 f
->entry
.pathlen
= entry
->fts_pathlen
;
71 f
->entry
.level
= entry
->fts_level
;
77 * fs_delete -- deletes a fs traversal instance
80 fs_delete(struct fs
*f
)