Commit | Line | Data |
---|---|---|
455b164d SL |
1 | #ifndef lint |
2 | static char sccsid[] = "@(#)opendir.c 4.5 (Berkeley) %G%"; | |
3 | #endif | |
5f4e4c0f | 4 | |
13d423cf | 5 | #include <sys/param.h> |
455b164d | 6 | #include <sys/dir.h> |
5f4e4c0f KM |
7 | |
8 | /* | |
9 | * open a directory. | |
10 | */ | |
11 | DIR * | |
12 | opendir(name) | |
13 | char *name; | |
14 | { | |
79004ddf | 15 | register DIR *dirp; |
5b80a1f6 | 16 | register int fd; |
5f4e4c0f | 17 | |
5b80a1f6 | 18 | if ((fd = open(name, 0)) == -1) |
5f4e4c0f | 19 | return NULL; |
13d423cf | 20 | if ((dirp = (DIR *)malloc(sizeof(DIR))) == NULL) { |
5b80a1f6 | 21 | close (fd); |
79004ddf KM |
22 | return NULL; |
23 | } | |
5b80a1f6 | 24 | dirp->dd_fd = fd; |
5f4e4c0f KM |
25 | dirp->dd_loc = 0; |
26 | return dirp; | |
27 | } |