Attempt to fix the BSD RAW-CHKPATH failures: In Samba3 we rely on opendir
returning ENOTDIR when the file opened is not a directory. Can we merge this
back into Samba4?
This includes the tabs->spaces fix requested by Stefan.
Volker
(This used to be commit
7b9ee1171ddc89537ba3b286f20c722fb70c980b)
DIR *opendir(const char *dname)
{
struct dir_buf *d;
+ struct stat sb;
d = malloc(sizeof(*d));
if (d == NULL) {
errno = ENOMEM;
free(d);
return NULL;
}
+ if (fstat(d->fd, &sb) < 0) {
+ close(d->fd);
+ free(d);
+ return NULL;
+ }
+ if (!S_ISDIR(sb.st_mode)) {
+ close(d->fd);
+ free(d);
+ errno = ENOTDIR;
+ return NULL;
+ }
d->ofs = 0;
d->seekpos = 0;
d->nbytes = 0;
DIR *opendir(const char *dname)
{
struct dir_buf *d;
+ struct stat sb;
d = malloc(sizeof(*d));
if (d == NULL) {
errno = ENOMEM;
free(d);
return NULL;
}
+ if (fstat(d->fd, &sb) < 0) {
+ close(d->fd);
+ free(d);
+ return NULL;
+ }
+ if (!S_ISDIR(sb.st_mode)) {
+ close(d->fd);
+ free(d);
+ errno = ENOTDIR;
+ return NULL;
+ }
d->ofs = 0;
d->seekpos = 0;
d->nbytes = 0;