]> git.pld-linux.org Git - packages/dietlibc.git/blob - fdopendir.patch
- release 17 (by relup.sh)
[packages/dietlibc.git] / fdopendir.patch
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3
4 # T2 SDE: package/.../dietlibc/fdopendir.patch
5 # Copyright (C) 2011 The T2 SDE Project
6
7 # More information can be found in the files COPYING and README.
8
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 # --- T2-COPYRIGHT-NOTE-END ---
16
17 Of course for udev, too, what else, ...
18
19   - Rene Rebe <rene@exactcode.de>
20
21 --- dietlibc/include/dirent.h.vanilla   2011-01-06 12:29:39.000000000 +0100
22 +++ dietlibc/include/dirent.h   2011-01-06 12:30:04.000000000 +0100
23 @@ -33,6 +33,7 @@
24  typedef struct __dirstream DIR;
25  
26  DIR *opendir (const char *__name) __THROW;
27 +DIR *fdopendir(int fd) __THROW;
28  int closedir (DIR *__dirp) __THROW;
29  struct dirent *readdir (DIR *__dirp) __THROW;
30  struct dirent64 *readdir64 (DIR *__dirp) __THROW;
31 --- dietlibc/lib/fdopendir.c.vanilla    2011-01-06 12:30:22.000000000 +0100
32 +++ dietlibc/lib/fdopendir.c    2011-01-06 12:33:58.000000000 +0100
33 @@ -0,0 +1,28 @@
34 +#include "dietdirent.h"
35 +#include <sys/mman.h>
36 +#include <unistd.h>
37 +#include <dirent.h>
38 +#include <stdlib.h>
39 +#include <fcntl.h>
40 +
41 +DIR*  fdopendir (int fd) {
42 +  DIR*  t  = NULL;
43 +  int flags = fcntl (fd, F_GETFL);
44 +  if (flags == -1 || (flags & O_DIRECTORY) == 0)
45 +    goto lose; /* TODO: set errno = ENOTDIR; */
46 +  
47 +  if ( fd >= 0 ) {
48 +    if (fcntl (fd, F_SETFD, FD_CLOEXEC) < 0)
49 +      goto lose;
50 +    t = (DIR *) mmap (NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, 
51 +               MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
52 +    if (t == MAP_FAILED)
53 +lose:
54 +      close (fd);
55 +    else
56 +      t->fd = fd;
57 +  }
58 +
59 +
60 +  return t;
61 +}
This page took 0.038393 seconds and 3 git commands to generate.