OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libc/] [misc/] [dirent/] [closedir.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
#include <dirent.h>
2
#include <errno.h>
3
#include <stdlib.h>
4
#include <unistd.h>
5
#include "dirstream.h"
6
 
7
 
8
int closedir(DIR * dir)
9
{
10
        int fd;
11
 
12
        if (!dir) {
13
                __set_errno(EBADF);
14
                return -1;
15
        }
16
 
17
        /* We need to check dd_fd. */
18
        if (dir->dd_fd == -1) {
19
                __set_errno(EBADF);
20
                return -1;
21
        }
22
#ifdef __UCLIBC_HAS_THREADS__
23
        __pthread_mutex_lock(&(dir->dd_lock));
24
#endif
25
        fd = dir->dd_fd;
26
        dir->dd_fd = -1;
27
#ifdef __UCLIBC_HAS_THREADS__
28
        __pthread_mutex_unlock(&(dir->dd_lock));
29
#endif
30
        free(dir->dd_buf);
31
        free(dir);
32
        return close(fd);
33
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.