source: bootcd/isolinux/syslinux-6.03/core/fs/readdir.c

Last change on this file was e16e8f2, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

bootstuff

  • Property mode set to 100644
File size: 950 bytes
Line 
1#include <fcntl.h>
2#include <stdio.h>
3#include <string.h>
4#include <sys/dirent.h>
5#include "fs.h"
6#include "core.h"
7
8/*
9 * Open a directory
10 */
11__export DIR *opendir(const char *path)
12{
13    int rv;
14    struct file *file;
15
16    rv = searchdir(path, O_RDONLY|O_DIRECTORY);
17    if (rv < 0)
18        return NULL;
19
20    file = handle_to_file(rv);
21
22    if (file->inode->mode != DT_DIR) {
23        _close_file(file);
24        return NULL;
25    }
26
27    return (DIR *)file;
28}
29
30/*
31 * Read one directory entry at one time.
32 */
33__export struct dirent *readdir(DIR *dir)
34{
35    static struct dirent buf;
36    struct file *dd_dir = (struct file *)dir;
37    int rv = -1;
38   
39    if (dd_dir) {
40        if (dd_dir->fs->fs_ops->readdir) {
41            rv = dd_dir->fs->fs_ops->readdir(dd_dir, &buf);
42        }
43    }
44
45    return rv < 0 ? NULL : &buf;
46}
47
48/*
49 * Close a directory
50 */
51__export int closedir(DIR *dir)
52{
53    struct file *dd_dir = (struct file *)dir;
54    _close_file(dd_dir);
55    return 0;
56}
57
58
Note: See TracBrowser for help on using the repository browser.