svn commit: samba r19011 - in branches/SAMBA_3_0/source/lib/replace: .

vlendec at samba.org vlendec at samba.org
Sat Sep 30 14:12:03 GMT 2006


Author: vlendec
Date: 2006-09-30 14:12:02 +0000 (Sat, 30 Sep 2006)
New Revision: 19011

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19011

Log:
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?

Volker

Modified:
   branches/SAMBA_3_0/source/lib/replace/repdir_getdents.c
   branches/SAMBA_3_0/source/lib/replace/repdir_getdirentries.c


Changeset:
Modified: branches/SAMBA_3_0/source/lib/replace/repdir_getdents.c
===================================================================
--- branches/SAMBA_3_0/source/lib/replace/repdir_getdents.c	2006-09-30 09:45:53 UTC (rev 19010)
+++ branches/SAMBA_3_0/source/lib/replace/repdir_getdents.c	2006-09-30 14:12:02 UTC (rev 19011)
@@ -68,6 +68,7 @@
 DIR *opendir(const char *dname)
 {
 	struct dir_buf *d;
+	struct stat sb;
 	d = malloc(sizeof(*d));
 	if (d == NULL) {
 		errno = ENOMEM;
@@ -78,6 +79,17 @@
 		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;

Modified: branches/SAMBA_3_0/source/lib/replace/repdir_getdirentries.c
===================================================================
--- branches/SAMBA_3_0/source/lib/replace/repdir_getdirentries.c	2006-09-30 09:45:53 UTC (rev 19010)
+++ branches/SAMBA_3_0/source/lib/replace/repdir_getdirentries.c	2006-09-30 14:12:02 UTC (rev 19011)
@@ -70,6 +70,7 @@
 DIR *opendir(const char *dname)
 {
 	struct dir_buf *d;
+	struct stat sb;
 	d = malloc(sizeof(*d));
 	if (d == NULL) {
 		errno = ENOMEM;
@@ -80,6 +81,17 @@
 		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;



More information about the samba-cvs mailing list