From owner-freebsd-hackers Fri Nov 17 09:52:42 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id JAA18552 for hackers-outgoing; Fri, 17 Nov 1995 09:52:42 -0800 Received: from cls.net (freeside.cls.de [192.129.50.1]) by freefall.freebsd.org (8.6.12/8.6.6) with SMTP id JAA18538 for ; Fri, 17 Nov 1995 09:52:15 -0800 Received: by mail.cls.net (Smail3.1.29.1) from allegro.lemis.de (192.109.197.134) with smtp id ; Fri, 17 Nov 95 17:52 GMT From: grog@lemis.de (Greg Lehey) Organisation: LEMIS, Schellnhausen 2, 36325 Feldatal, Germany Phone: +49-6637-919123 Fax: +49-6637-919122 Reply-To: grog@lemis.de (Greg Lehey) Received: (grog@localhost) by allegro.lemis.de (8.6.9/8.6.9) id SAA26447 for hackers@freebsd.org; Fri, 17 Nov 1995 18:32:44 +0100 Message-Id: <199511171732.SAA26447@allegro.lemis.de> Subject: Re: elm problem - "solved" To: hackers@freebsd.org (FreeBSD Hackers) Date: Fri, 17 Nov 1995 18:32:43 +0100 (MET) X-Mailer: ELM [version 2.4 PL23] MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Content-Length: 2847 Sender: owner-hackers@freebsd.org Precedence: bulk David Greenman writes: > >> I wasn't able to get it working with fcntl locking, either. I compiled > >> and installed it long before I knew of the existance of a port (one might > >> have existed, I don't know). I've always had to use flock style locking > >> - fcntl always seemed to cause the symptoms the original complaint > >> described. > > > >I've followed this up a little, and now believe that fcntl locking is > >broken. I took an elm I compiled on BSD/386 (in fact, the one I'm > >using now) and went through with gdb. The result: the system call to > >fcntl has identical parameters in each case: > > > >(gdb) p lock_info > >$1 = { > > l_type = 3, > > l_whence = 0, > > l_start = 0, > > l_len = 0, > > l_pid = 0 > >} > > > >l_type is F_WRLCK, and it's calling fcntl with F_SETLK. This works as > >advertised with BSD/386, but returns with an invalid argument with > >FreeBSD in all versions I've tried recently. > > > >I haven't got any further (can somebody please tell me how to enter > >ddb from the keyboard? Something goes and messes up my keymap, so I > >can't get in after booting), but intend to do so some time soon. > > If you can put together a short program to demonstrate the bug, I would be > happy to find and fix it. Well, we found the problem. lock_info is of type struct flock. In BSD systems derived from Net/2, and also in Linux, SunOS 4, System V.3, struct flock is defined as /* * Advisory file segment locking data type - * information passed to system by user */ struct flock { short l_type; /* lock type: read/write, etc. */ short l_whence; /* type of l_start */ off_t l_start; /* starting offset */ off_t l_len; /* len = 0 means until end of file */ pid_t l_pid; /* lock owner */ }; In 4.4BSD, it's defined as /* * Advisory file segment locking data type - * information passed to system by user */ struct flock { off_t l_start; /* starting offset */ off_t l_len; /* len = 0 means until end of file */ pid_t l_pid; /* lock owner */ short l_type; /* lock type: read/write, etc. */ short l_whence; /* type of l_start */ }; Finally, in System V.4, including SunOS 5 (Solaris 2), it is defined as typedef struct flock { short l_type; /* Type of lock */ short l_whence; /* Flag for starting offset */ off_t l_start; /* Relative offset in bytes */ off_t l_len; /* Size; if 0 then until EOF */ long l_sysid; /* Returned with F_GETLK */ pid_t l_pid; /* Returned with F_GETLK */ long l_pad /* reserve area */ } flock_t; I really have great difficulty understanding why this change was made. It means that old FreeBSD and BSD/386 binaries won't work correctly under FreeBSD or BSD/OS Versions 2. I can't see any advantage at all in this change. Grrrr. Greg