1 /* Directory hashing for GNU Make.
2 Copyright (C) 1988,89,91,92,93,94,95,96,97 Free Software Foundation, Inc.
3 This file is part of GNU Make.
5 GNU Make is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 GNU Make is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNU Make; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
24 # define NAMLEN(dirent) strlen((dirent)->d_name)
26 # define dirent direct
27 # define NAMLEN(dirent) (dirent)->d_namlen
28 # ifdef HAVE_SYS_NDIR_H
29 # include <sys/ndir.h>
31 # ifdef HAVE_SYS_DIR_H
39 # endif /* HAVE_VMSDIR_H */
42 /* In GNU systems, <dirent.h> defines this macro for us. */
45 #define NAMLEN(d) _D_NAMLEN(d)
48 #if (defined (POSIX) || defined (WINDOWS32)) && !defined (__GNU_LIBRARY__)
49 /* Posix does not require that the d_ino field be present, and some
50 systems do not provide it. */
51 #define REAL_DIR_ENTRY(dp) 1
52 #define FAKE_DIR_ENTRY(dp)
54 #define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
55 #define FAKE_DIR_ENTRY(dp) (dp->d_ino = 1)
62 /* If it's MSDOS that doesn't have _USE_LFN, disable LFN support. */
71 static char dos_filename
[14];
75 if (filename
== 0 || _USE_LFN
)
78 /* FIXME: what about filenames which violate
79 8+3 constraints, like "config.h.in", or ".emacs"? */
80 if (strpbrk (filename
, "\"*+,;<=>?[\\]|") != 0)
85 /* First, transform the name part. */
86 for (i
= 0; *filename
!= '\0' && i
< 8 && *filename
!= '.'; ++i
)
87 *df
++ = tolower (*filename
++);
89 /* Now skip to the next dot. */
90 while (*filename
!= '\0' && *filename
!= '.')
92 if (*filename
!= '\0')
95 for (i
= 0; *filename
!= '\0' && i
< 3 && *filename
!= '.'; ++i
)
96 *df
++ = tolower (*filename
++);
99 /* Look for more dots. */
100 while (*filename
!= '\0' && *filename
!= '.')
102 if (*filename
== '.')
107 #endif /* __MSDOS__ */
110 #include "pathstuff.h"
117 #ifdef HAVE_CASE_INSENSITIVE_FS
123 static char new_filename
[136];
125 static char new_filename
[PATH_MAX
];
135 /* First, transform the name part. */
136 for (i
= 0; *filename
!= '\0'; ++i
)
138 *df
++ = tolower (*filename
);
146 #endif /* HAVE_CASE_INSENSITIVE_FS */
159 h
= (h
<< 4) + *name
++;
170 /* fake stat entry for a directory */
172 vmsstat_dir (name
, st
)
180 dir
= opendir (name
);
184 s
= strchr (name
, ':'); /* find device */
188 st
->st_dev
= (char *)vms_hash (name
);
199 st
->st_ino
[0] = h
& 0xff;
200 st
->st_ino
[1] = h
& 0xff00;
201 st
->st_ino
[2] = h
>> 16;
207 /* Hash table of directories. */
209 #ifndef DIRECTORY_BUCKETS
210 #define DIRECTORY_BUCKETS 199
213 struct directory_contents
215 struct directory_contents
*next
;
217 dev_t dev
; /* Device and inode numbers of this dir. */
220 * Inode means nothing on WINDOWS32. Even file key information is
221 * unreliable because it is random per file open and undefined
222 * for remote filesystems. The most unique attribute I can
223 * come up with is the fully qualified name of the directory. Beware
224 * though, this is also unreliable. I'm open to suggestion on a better
225 * way to emulate inode.
228 int mtime
; /* controls check for stale directory cache */
229 int fs_flags
; /* FS_FAT, FS_NTFS, ... */
232 #define FS_UNKNOWN 0x4
239 #endif /* WINDOWS32 */
240 struct dirfile
**files
; /* Files in this directory. */
241 DIR *dirstream
; /* Stream reading this directory. */
244 /* Table of directory contents hashed by device and inode number. */
245 static struct directory_contents
*directories_contents
[DIRECTORY_BUCKETS
];
249 struct directory
*next
;
251 char *name
; /* Name of the directory. */
253 /* The directory's contents. This data may be shared by several
254 entries in the hash table, which refer to the same directory
255 (identified uniquely by `dev' and `ino') under different names. */
256 struct directory_contents
*contents
;
259 /* Table of directories hashed by name. */
260 static struct directory
*directories
[DIRECTORY_BUCKETS
];
263 /* Never have more than this many directories open at once. */
265 #define MAX_OPEN_DIRECTORIES 10
267 static unsigned int open_directories
= 0;
270 /* Hash table of files in each directory. */
274 struct dirfile
*next
;
275 char *name
; /* Name of the file. */
276 char impossible
; /* This file is impossible. */
279 #ifndef DIRFILE_BUCKETS
280 #define DIRFILE_BUCKETS 107
283 static int dir_contents_file_exists_p
PARAMS ((struct directory_contents
*dir
, char *filename
));
284 static struct directory
*find_directory
PARAMS ((char *name
));
286 /* Find the directory named NAME and return its `struct directory'. */
288 static struct directory
*
289 find_directory (name
)
292 register unsigned int hash
= 0;
294 register struct directory
*dir
;
297 char fs_label
[BUFSIZ
];
298 char fs_type
[BUFSIZ
];
304 if ((*name
== '.') && (*(name
+1) == 0))
307 name
= vmsify (name
,1);
310 for (p
= name
; *p
!= '\0'; ++p
)
312 hash
%= DIRECTORY_BUCKETS
;
314 for (dir
= directories
[hash
]; dir
!= 0; dir
= dir
->next
)
315 if (strieq (dir
->name
, name
))
322 /* The directory was not found. Create a new entry for it. */
324 dir
= (struct directory
*) xmalloc (sizeof (struct directory
));
325 dir
->next
= directories
[hash
];
326 directories
[hash
] = dir
;
327 dir
->name
= savestring (name
, p
- name
);
329 /* The directory is not in the name hash table.
330 Find its device and inode numbers, and look it up by them. */
333 if (vmsstat_dir (name
, &st
) < 0)
335 if (stat (name
, &st
) < 0)
338 /* Couldn't stat the directory. Mark this by
339 setting the `contents' member to a nil pointer. */
344 /* Search the contents hash table; device and inode are the key. */
346 struct directory_contents
*dc
;
349 w32_path
= w32ify(name
, 1);
350 hash
= ((unsigned int) st
.st_dev
<< 16) | (unsigned int) st
.st_ctime
;
353 hash
= ((unsigned int) st
.st_dev
<< 16)
354 | ((unsigned int) st
.st_ino
[0]
355 + (unsigned int) st
.st_ino
[1]
356 + (unsigned int) st
.st_ino
[2]);
358 hash
= ((unsigned int) st
.st_dev
<< 16) | (unsigned int) st
.st_ino
;
361 hash
%= DIRECTORY_BUCKETS
;
363 for (dc
= directories_contents
[hash
]; dc
!= 0; dc
= dc
->next
)
365 if (strieq(dc
->path_key
, w32_path
))
367 if (dc
->dev
== st
.st_dev
369 && dc
->ino
[0] == st
.st_ino
[0]
370 && dc
->ino
[1] == st
.st_ino
[1]
371 && dc
->ino
[2] == st
.st_ino
[2])
373 && dc
->ino
== st
.st_ino
)
375 #endif /* WINDOWS32 */
380 /* Nope; this really is a directory we haven't seen before. */
382 dc
= (struct directory_contents
*)
383 xmalloc (sizeof (struct directory_contents
));
385 /* Enter it in the contents hash table. */
388 dc
->path_key
= xstrdup(w32_path
);
389 dc
->mtime
= st
.st_mtime
;
392 * NTFS is the only WINDOWS32 filesystem that bumps mtime
393 * on a directory when files are added/deleted from
397 if (GetVolumeInformation(w32_path
,
398 fs_label
, sizeof (fs_label
),
400 &fs_flags
, fs_type
, sizeof (fs_type
)) == FALSE
)
401 dc
->fs_flags
= FS_UNKNOWN
;
402 else if (!strcmp(fs_type
, "FAT"))
403 dc
->fs_flags
= FS_FAT
;
404 else if (!strcmp(fs_type
, "NTFS"))
405 dc
->fs_flags
= FS_NTFS
;
407 dc
->fs_flags
= FS_UNKNOWN
;
410 dc
->ino
[0] = st
.st_ino
[0];
411 dc
->ino
[1] = st
.st_ino
[1];
412 dc
->ino
[2] = st
.st_ino
[2];
416 #endif /* WINDOWS32 */
417 dc
->next
= directories_contents
[hash
];
418 directories_contents
[hash
] = dc
;
420 dc
->dirstream
= opendir (name
);
421 if (dc
->dirstream
== 0)
423 /* Couldn't open the directory. Mark this by
424 setting the `files' member to a nil pointer. */
429 /* Allocate an array of buckets for files and zero it. */
430 dc
->files
= (struct dirfile
**)
431 xmalloc (sizeof (struct dirfile
*) * DIRFILE_BUCKETS
);
432 bzero ((char *) dc
->files
,
433 sizeof (struct dirfile
*) * DIRFILE_BUCKETS
);
435 /* Keep track of how many directories are open. */
437 if (open_directories
== MAX_OPEN_DIRECTORIES
)
438 /* We have too many directories open already.
439 Read the entire directory and then close it. */
440 (void) dir_contents_file_exists_p (dc
, (char *) 0);
444 /* Point the name-hashed entry for DIR at its contents data. */
452 /* Return 1 if the name FILENAME is entered in DIR's hash table.
453 FILENAME must contain no slashes. */
456 dir_contents_file_exists_p (dir
, filename
)
457 register struct directory_contents
*dir
;
458 register char *filename
;
460 register unsigned int hash
;
462 register struct dirfile
*df
;
463 register struct dirent
*d
;
469 if (dir
== 0 || dir
->files
== 0)
471 /* The directory could not be stat'd or opened. */
475 filename
= dosify (filename
);
478 #ifdef HAVE_CASE_INSENSITIVE_FS
479 filename
= downcase (filename
);
483 filename
= vmsify (filename
,0);
489 if (*filename
== '\0')
491 /* Checking if the directory exists. */
495 for (p
= filename
; *p
!= '\0'; ++p
)
497 hash
%= DIRFILE_BUCKETS
;
499 /* Search the list of hashed files. */
501 for (df
= dir
->files
[hash
]; df
!= 0; df
= df
->next
)
503 if (strieq (df
->name
, filename
))
505 return !df
->impossible
;
510 /* The file was not found in the hashed list.
511 Try to read the directory further. */
513 if (dir
->dirstream
== 0)
517 * Check to see if directory has changed since last read. FAT
518 * filesystems force a rehash always as mtime does not change
519 * on directories (ugh!).
522 (dir
->fs_flags
& FS_FAT
||
523 (stat(dir
->path_key
, &st
) == 0 &&
524 st
.st_mtime
> dir
->mtime
))) {
526 /* reset date stamp to show most recent re-process */
527 dir
->mtime
= st
.st_mtime
;
529 /* make sure directory can still be opened */
530 dir
->dirstream
= opendir(dir
->path_key
);
535 return 0; /* couldn't re-read - fail */
538 /* The directory has been all read in. */
542 while ((d
= readdir (dir
->dirstream
)) != 0)
544 /* Enter the file in the hash table. */
545 register unsigned int newhash
= 0;
547 register unsigned int i
;
549 if (!REAL_DIR_ENTRY (d
))
553 for (i
= 0; i
< len
; ++i
)
554 HASHI (newhash
, d
->d_name
[i
]);
555 newhash
%= DIRFILE_BUCKETS
;
558 * If re-reading a directory, check that this file isn't already
562 for (df
= dir
->files
[newhash
]; df
!= 0; df
= df
->next
)
563 if (streq(df
->name
, d
->d_name
))
569 * If re-reading a directory, don't cache files that have
570 * already been discovered.
575 df
= (struct dirfile
*) xmalloc (sizeof (struct dirfile
));
576 df
->next
= dir
->files
[newhash
];
577 dir
->files
[newhash
] = df
;
578 df
->name
= savestring (d
->d_name
, len
);
583 /* Check if the name matches the one we're searching for. */
585 && newhash
== hash
&& strieq (d
->d_name
, filename
))
591 /* If the directory has been completely read in,
592 close the stream and reset the pointer to nil. */
596 closedir (dir
->dirstream
);
602 /* Return 1 if the name FILENAME in directory DIRNAME
603 is entered in the dir hash table.
604 FILENAME must contain no slashes. */
607 dir_file_exists_p (dirname
, filename
)
608 register char *dirname
;
609 register char *filename
;
611 return dir_contents_file_exists_p (find_directory (dirname
)->contents
,
615 /* Return 1 if the file named NAME exists. */
627 return ar_member_date (name
) != (time_t) -1;
631 dirend
= rindex (name
, ']');
633 if (dirend
== (char *)1)
634 return dir_file_exists_p ("[]", name
);
636 dirend
= rindex (name
, '/');
637 #if defined (WINDOWS32) || defined (__MSDOS__)
638 /* Forward and backslashes might be mixed. We need the rightmost one. */
640 char *bslash
= rindex(name
, '\\');
641 if (!dirend
|| bslash
> dirend
)
643 /* The case of "d:file". */
644 if (!dirend
&& name
[0] && name
[1] == ':')
647 #endif /* WINDOWS32 || __MSDOS__ */
650 return dir_file_exists_p (".", name
);
651 #else /* !VMS && !AMIGA */
652 return dir_file_exists_p ("", name
);
661 #if defined (WINDOWS32) || defined (__MSDOS__)
662 /* d:/ and d: are *very* different... */
663 if (dirend
< name
+ 3 && name
[1] == ':' &&
664 (*dirend
== '/' || *dirend
== '\\' || *dirend
== ':'))
667 dirname
= (char *) alloca (dirend
- name
+ 1);
668 bcopy (name
, dirname
, dirend
- name
);
669 dirname
[dirend
- name
] = '\0';
671 return dir_file_exists_p (dirname
, slash
+ 1);
674 /* Mark FILENAME as `impossible' for `file_impossible_p'.
675 This means an attempt has been made to search for FILENAME
676 as an intermediate file, and it has failed. */
679 file_impossible (filename
)
680 register char *filename
;
683 register char *p
= filename
;
684 register unsigned int hash
;
685 register struct directory
*dir
;
686 register struct dirfile
*new;
689 dirend
= rindex (p
, ']');
691 if (dirend
== (char *)1)
692 dir
= find_directory ("[]");
694 dirend
= rindex (p
, '/');
695 #if defined (WINDOWS32) || defined (__MSDOS__)
696 /* Forward and backslashes might be mixed. We need the rightmost one. */
698 char *bslash
= rindex(p
, '\\');
699 if (!dirend
|| bslash
> dirend
)
701 /* The case of "d:file". */
702 if (!dirend
&& p
[0] && p
[1] == ':')
705 #endif /* WINDOWS32 or __MSDOS__ */
708 dir
= find_directory ("");
709 #else /* !VMS && !AMIGA */
710 dir
= find_directory (".");
716 char *slash
= dirend
;
721 #if defined (WINDOWS32) || defined (__MSDOS__)
722 /* d:/ and d: are *very* different... */
723 if (dirend
< p
+ 3 && p
[1] == ':' &&
724 (*dirend
== '/' || *dirend
== '\\' || *dirend
== ':'))
727 dirname
= (char *) alloca (dirend
- p
+ 1);
728 bcopy (p
, dirname
, dirend
- p
);
729 dirname
[dirend
- p
] = '\0';
731 dir
= find_directory (dirname
);
732 filename
= p
= slash
+ 1;
735 for (hash
= 0; *p
!= '\0'; ++p
)
737 hash
%= DIRFILE_BUCKETS
;
739 if (dir
->contents
== 0)
741 /* The directory could not be stat'd. We allocate a contents
742 structure for it, but leave it out of the contents hash table. */
743 dir
->contents
= (struct directory_contents
*)
744 xmalloc (sizeof (struct directory_contents
));
746 dir
->contents
->path_key
= NULL
;
747 dir
->contents
->mtime
= 0;
748 #else /* WINDOWS32 */
750 dir
->contents
->dev
= 0;
751 dir
->contents
->ino
[0] = dir
->contents
->ino
[1] =
752 dir
->contents
->ino
[2] = 0;
754 dir
->contents
->dev
= dir
->contents
->ino
= 0;
756 #endif /* WINDOWS32 */
757 dir
->contents
->files
= 0;
758 dir
->contents
->dirstream
= 0;
761 if (dir
->contents
->files
== 0)
763 /* The directory was not opened; we must allocate the hash buckets. */
764 dir
->contents
->files
= (struct dirfile
**)
765 xmalloc (sizeof (struct dirfile
) * DIRFILE_BUCKETS
);
766 bzero ((char *) dir
->contents
->files
,
767 sizeof (struct dirfile
) * DIRFILE_BUCKETS
);
770 /* Make a new entry and put it in the table. */
772 new = (struct dirfile
*) xmalloc (sizeof (struct dirfile
));
773 new->next
= dir
->contents
->files
[hash
];
774 dir
->contents
->files
[hash
] = new;
775 new->name
= xstrdup (filename
);
779 /* Return nonzero if FILENAME has been marked impossible. */
782 file_impossible_p (filename
)
786 register char *p
= filename
;
787 register unsigned int hash
;
788 register struct directory_contents
*dir
;
789 register struct dirfile
*next
;
792 dirend
= rindex (filename
, ']');
794 dir
= find_directory ("[]")->contents
;
796 dirend
= rindex (filename
, '/');
797 #if defined (WINDOWS32) || defined (__MSDOS__)
798 /* Forward and backslashes might be mixed. We need the rightmost one. */
800 char *bslash
= rindex(filename
, '\\');
801 if (!dirend
|| bslash
> dirend
)
803 /* The case of "d:file". */
804 if (!dirend
&& filename
[0] && filename
[1] == ':')
805 dirend
= filename
+ 1;
807 #endif /* WINDOWS32 || __MSDOS__ */
810 dir
= find_directory ("")->contents
;
811 #else /* !VMS && !AMIGA */
812 dir
= find_directory (".")->contents
;
818 char *slash
= dirend
;
819 if (dirend
== filename
)
823 #if defined (WINDOWS32) || defined (__MSDOS__)
824 /* d:/ and d: are *very* different... */
825 if (dirend
< filename
+ 3 && filename
[1] == ':' &&
826 (*dirend
== '/' || *dirend
== '\\' || *dirend
== ':'))
829 dirname
= (char *) alloca (dirend
- filename
+ 1);
830 bcopy (p
, dirname
, dirend
- p
);
831 dirname
[dirend
- p
] = '\0';
833 dir
= find_directory (dirname
)->contents
;
834 p
= filename
= slash
+ 1;
837 if (dir
== 0 || dir
->files
== 0)
838 /* There are no files entered for this directory. */
842 p
= filename
= dosify (p
);
844 #ifdef HAVE_CASE_INSENSITIVE_FS
845 p
= filename
= downcase (p
);
848 p
= filename
= vmsify (p
, 1);
851 for (hash
= 0; *p
!= '\0'; ++p
)
853 hash
%= DIRFILE_BUCKETS
;
855 for (next
= dir
->files
[hash
]; next
!= 0; next
= next
->next
)
856 if (strieq (filename
, next
->name
))
857 return next
->impossible
;
862 /* Return the already allocated name in the
863 directory hash table that matches DIR. */
869 return find_directory (dir
)->name
;
872 /* Print the data base of directories. */
875 print_dir_data_base ()
877 register unsigned int i
, dirs
, files
, impossible
;
878 register struct directory
*dir
;
880 puts ("\n# Directories\n");
882 dirs
= files
= impossible
= 0;
883 for (i
= 0; i
< DIRECTORY_BUCKETS
; ++i
)
884 for (dir
= directories
[i
]; dir
!= 0; dir
= dir
->next
)
887 if (dir
->contents
== 0)
888 printf ("# %s: could not be stat'd.\n", dir
->name
);
889 else if (dir
->contents
->files
== 0)
891 printf ("# %s (key %s, mtime %d): could not be opened.\n",
892 dir
->name
, dir
->contents
->path_key
,dir
->contents
->mtime
);
893 #else /* WINDOWS32 */
895 printf ("# %s (device %d, inode [%d,%d,%d]): could not be opened.\n",
896 dir
->name
, dir
->contents
->dev
,
897 dir
->contents
->ino
[0], dir
->contents
->ino
[1],
898 dir
->contents
->ino
[2]);
900 printf ("# %s (device %ld, inode %ld): could not be opened.\n",
901 dir
->name
, (long int) dir
->contents
->dev
,
902 (long int) dir
->contents
->ino
);
904 #endif /* WINDOWS32 */
907 register unsigned int f
= 0, im
= 0;
908 register unsigned int j
;
909 register struct dirfile
*df
;
910 for (j
= 0; j
< DIRFILE_BUCKETS
; ++j
)
911 for (df
= dir
->contents
->files
[j
]; df
!= 0; df
= df
->next
)
917 printf ("# %s (key %s, mtime %d): ",
918 dir
->name
, dir
->contents
->path_key
, dir
->contents
->mtime
);
919 #else /* WINDOWS32 */
921 printf ("# %s (device %d, inode [%d,%d,%d]): ",
922 dir
->name
, dir
->contents
->dev
,
923 dir
->contents
->ino
[0], dir
->contents
->ino
[1],
924 dir
->contents
->ino
[2]);
926 printf ("# %s (device %ld, inode %ld): ",
928 (long)dir
->contents
->dev
, (long)dir
->contents
->ino
);
930 #endif /* WINDOWS32 */
932 fputs ("No", stdout
);
935 fputs (" files, ", stdout
);
937 fputs ("no", stdout
);
940 fputs (" impossibilities", stdout
);
941 if (dir
->contents
->dirstream
== 0)
950 fputs ("\n# ", stdout
);
952 fputs ("No", stdout
);
954 printf ("%u", files
);
955 fputs (" files, ", stdout
);
957 fputs ("no", stdout
);
959 printf ("%u", impossible
);
960 printf (" impossibilities in %u directories.\n", dirs
);
963 /* Hooks for globbing. */
967 /* Structure describing state of iterating through a directory hash table. */
971 struct directory_contents
*contents
; /* The directory being read. */
973 unsigned int bucket
; /* Current hash bucket. */
974 struct dirfile
*elt
; /* Current elt in bucket. */
977 /* Forward declarations. */
978 static __ptr_t open_dirstream
PARAMS ((const char *));
979 static struct dirent
*read_dirstream
PARAMS ((__ptr_t
));
982 open_dirstream (directory
)
983 const char *directory
;
985 struct dirstream
*new;
986 struct directory
*dir
= find_directory ((char *)directory
);
988 if (dir
->contents
== 0 || dir
->contents
->files
== 0)
989 /* DIR->contents is nil if the directory could not be stat'd.
990 DIR->contents->files is nil if it could not be opened. */
993 /* Read all the contents of the directory now. There is no benefit
994 in being lazy, since glob will want to see every file anyway. */
996 (void) dir_contents_file_exists_p (dir
->contents
, (char *) 0);
998 new = (struct dirstream
*) xmalloc (sizeof (struct dirstream
));
999 new->contents
= dir
->contents
;
1001 new->elt
= new->contents
->files
[0];
1003 return (__ptr_t
) new;
1006 static struct dirent
*
1007 read_dirstream (stream
)
1010 struct dirstream
*const ds
= (struct dirstream
*) stream
;
1011 register struct dirfile
*df
;
1013 static unsigned int bufsz
;
1015 while (ds
->bucket
< DIRFILE_BUCKETS
)
1017 while ((df
= ds
->elt
) != 0)
1020 if (!df
->impossible
)
1022 /* The glob interface wants a `struct dirent',
1025 unsigned int len
= strlen (df
->name
) + 1;
1026 if (sizeof *d
- sizeof d
->d_name
+ len
> bufsz
)
1031 if (sizeof *d
- sizeof d
->d_name
+ len
> bufsz
)
1032 bufsz
= sizeof *d
- sizeof d
->d_name
+ len
;
1033 buf
= xmalloc (bufsz
);
1035 d
= (struct dirent
*) buf
;
1037 #ifdef _DIRENT_HAVE_D_NAMLEN
1038 d
->d_namlen
= len
- 1;
1040 memcpy (d
->d_name
, df
->name
, len
);
1044 if (++ds
->bucket
== DIRFILE_BUCKETS
)
1046 ds
->elt
= ds
->contents
->files
[ds
->bucket
];
1068 /* Bogus sunos4 compiler complains (!) about & before functions. */
1069 gl
->gl_opendir
= open_dirstream
;
1070 gl
->gl_readdir
= read_dirstream
;
1071 gl
->gl_closedir
= ansi_free
;
1073 /* We don't bother setting gl_lstat, since glob never calls it.
1074 The slot is only there for compatibility with 4.4 BSD. */