From gjm11@dpmms.cam.ac.uk  Fri May  9 20:05:18 1997
Received: from mauve.csi.cam.ac.uk (exim@mauve.csi.cam.ac.uk [131.111.8.38])
          by hub.freebsd.org (8.8.5/8.8.5) with SMTP id UAA13402
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 9 May 1997 20:05:17 -0700 (PDT)
Received: from g.pet.cam.ac.uk [131.111.209.233] 
	by mauve.csi.cam.ac.uk with smtp (Exim 1.62 #1)
	id 0wQ2TC-0004Zb-00; Sat, 10 May 1997 04:05:14 +0100
Received: from gjm11 by g.pet.cam.ac.uk with local (Exim 1.59 #1)
	id 0wQ2TB-0001rj-00; Sat, 10 May 1997 04:05:13 +0100
Message-Id: <E0wQ2TB-0001rj-00@g.pet.cam.ac.uk>
Date: Sat, 10 May 1997 04:05:13 +0100
From: gjm11@dpmms.cam.ac.uk
Reply-To: gjm11@dpmms.cam.ac.uk
To: FreeBSD-gnats-submit@freebsd.org
Subject: virtualpaper-1.4 port attempts to call mknod()
X-Send-Pr-Version: 3.2

>Number:         3572
>Category:       ports
>Synopsis:       virtualpaper-1.4 port attempts to call mknod()
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    jdp
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May  9 20:10:00 PDT 1997
>Closed-Date:    Thu Jul 10 22:21:31 PDT 1997
>Last-Modified:  Thu Jul 10 22:22:37 PDT 1997
>Originator:     Gareth McCaughan
>Release:        FreeBSD 2.2-RELEASE i386
>Organization:
all too little
>Environment:

	Bog-standard FreeBSD 2.2 system

>Description:

	The virtualpaper-1.4 port contains the following, in
	buildlectern/src/POSIX/OSUtilsPosix.m3 :

	IF Unix.mknod(M3toC.TtoS(p), Mode, 0) < 0 THEN
	  OSErrorPosix.Raise();
	END;

	Unfortunately, only root is supposed to call mknod(),
	so this is not a good idea. Calling mkfifo() instead
	(this is in a procedure called CreateFifo) seems to
	work.

>How-To-Repeat:

	Install virtualpaper-1.4 and type "BuildLectern foo.ps zog.lect".

>Fix:
	
	Declare an <*EXTERNAL*> procedure called mkfifo with the
	right type, and call that instead. The following lines of
	code do this, but I know just enough Modula-3 to be
	certain that they don't belong in the place where, in
	search of a quick fix, I put them. :-)


	in an interface file somewhere, insert:

	FROM Ctypes IMPORT char_star, int;
	FROM Utypes IMPORT mode_t;
	<*EXTERNAL*> PROCEDURE mkfifo(p: char_star; m: mode_t): int;


	in OSUtilsPosix.m3: replace the definition of CreateFifo with:

	PROCEDURE CreateFifo(p: TEXT) RAISES {OSError.E} =
	  CONST Mode = Unix.MROWNER + Unix.MWOWNER;
	  BEGIN
	    <* ASSERT pFifo=NIL *>
	    IF mkfifo(M3toC.TtoS(p), Mode) < 0 THEN
	      OSErrorPosix.Raise();
	    END;
	    pFifo := p;
	  END CreateFifo;
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports->jdp 
Responsible-Changed-By: jdp 
Responsible-Changed-When: Fri May 16 15:32:45 PDT 1997 
Responsible-Changed-Why:  
I am the maintainer of the port and also of the Modula-3 port. 

The proposed fix is 99% correct, but it will fail sometimes because of 
the way the Modula-3 garbage collector works.  The string passed to 
mkfifo() will at times be in a protected page of VM, causing the 
system call to fail with EFAULT.  The proper fix will require adding 
a wrapper for the system call to the Modula-3 runtime library, to 
ensure that the needed pages are accessible at the time the system 
call is made. 
State-Changed-From-To: open->closed 
State-Changed-By: jdp 
State-Changed-When: Thu Jul 10 22:21:31 PDT 1997 
State-Changed-Why:  
Fixed by new file "patch-ab" in virtualpaper port. 
>Unformatted:
