patch: fix apache-ant in linux emulation

Johannes Hofmann johannes.hofmann at gmx.de
Thu Apr 8 13:56:45 PDT 2010


ant does not compile any .java files when run under linux emulation.
The reason is missing support for the O_DIRECTORY flag in open(2).
The patch below adds this and makes ant work.
However it would probabely better - though more invasive to add
O_DIRECTORY to native open(2) and simply pass the flag.

Cheers,
Johannes


diff --git a/sys/emulation/linux/i386/linux.h b/sys/emulation/linux/i386/linux.h
index 2e9a238..a0ba8ef 100644
--- a/sys/emulation/linux/i386/linux.h
+++ b/sys/emulation/linux/i386/linux.h
@@ -494,6 +494,7 @@ extern struct ioctl_map linux_ioctl_map;
 #define	LINUX_O_NDELAY		LINUX_O_NONBLOCK
 #define	LINUX_O_SYNC		010000
 #define	LINUX_FASYNC		020000
+#define	LINUX_O_DIRECTORY	00200000
 
 #define	LINUX_F_DUPFD		0
 #define	LINUX_F_GETFD		1
diff --git a/sys/emulation/linux/linux_file.c b/sys/emulation/linux/linux_file.c
index bb0ba0a..3d6f39e 100644
--- a/sys/emulation/linux/linux_file.c
+++ b/sys/emulation/linux/linux_file.c
@@ -160,6 +160,20 @@ sys_linux_open(struct linux_open_args *args)
 			fdrop(fp);
 		}
 	}
+
+	if (error == 0 && args->flags & LINUX_O_DIRECTORY) {
+		struct file *fp;
+		struct vnode *vp;
+
+		fp = holdfp(p->p_fd, args->sysmsg_iresult, -1);
+		if (fp) {
+			vp = (struct vnode *) fp->f_data;
+        		if (vp->v_type != VDIR)
+				error = ENOTDIR;
+			fdrop(fp);
+		}
+	}
+
 	rel_mplock();
 #ifdef DEBUG
 	if (ldebug(open))





More information about the Submit mailing list