From owner-freebsd-bugs Thu Aug 7 01:30:03 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id BAA27295 for bugs-outgoing; Thu, 7 Aug 1997 01:30:03 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.5/8.8.5) id BAA27289; Thu, 7 Aug 1997 01:30:02 -0700 (PDT) Resent-Date: Thu, 7 Aug 1997 01:30:02 -0700 (PDT) Resent-Message-Id: <199708070830.BAA27289@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, tetsuya@secom-sis.co.jp Received: from secom-sis.co.jp (spiral.secom-sis.co.jp [202.218.246.72]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id BAA27145 for ; Thu, 7 Aug 1997 01:25:45 -0700 (PDT) Received: from secom-sis.co.jp ([172.27.9.50]) by spiral.secom-sis.co.jp with ESMTP id <35716-1>; Thu, 7 Aug 1997 17:25:23 +0900 Received: from juria.secom-sis.co.jp (juria.secom-sis.co.jp [172.27.2.16]) by secom-sis.co.jp (8.8.4/3.5Wpl1) with ESMTP id RAA19385 for ; Thu, 7 Aug 1997 17:30:04 +0900 (JST) Received: (from tetsuya@localhost) by juria.secom-sis.co.jp (8.8.6/3.5Wpl7-19970626s) id RAA10674; Thu, 7 Aug 1997 17:25:16 +0900 (JST) Message-Id: <199708070825.RAA10674@juria.secom-sis.co.jp> Date: Thu, 7 Aug 1997 17:25:16 +0900 From: tetsuya@secom-sis.co.jp Reply-To: tetsuya@secom-sis.co.jp To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: kern/4243: file locking doesn't work for pipe Sender: owner-freebsd-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Number: 4243 >Category: kern >Synopsis: file locking doesn't work for pipe >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Aug 7 01:30:01 PDT 1997 >Last-Modified: >Originator: Tetsuya Furukawa >Organization: Secom Information System Co.,Ltd. >Release: FreeBSD 2.2-STABLE i386 >Environment: FreeBSD 2.2-STABLE i386 on July 11, 1997 >Description: In flock() in /sys/kern/kern_descrip.c, the following statement: f (fp->f_type != DTYPE_VNODE) return (EOPNOTSUPP); rejects the file descriptor if fp->f_type == DTYPE_PIPE. F_SETLK and F_GETLK of fcntl() have also the similar statements. "Program rewriting map" (RewriteMap mapname prg:filename) of the URL rewriting module (mod_rewrite) of the Apache HTTP server uses file locking for pipe, so FreeBSD users cannot use the fine feature of "program rewriting map". >How-To-Repeat: The following program prints "flock: Operation not supported". -------- #include #include #include int main() { int fds[2]; char c; pipe(fds); if (flock(fds[1], LOCK_EX) == -1) perror("flock"); write(fds[1], "a", 1); read(fds[0], &c, 1); return 0; } -------- >Fix: Maybe, modify the three lines like if (fp->f_type != DTYPE_VNODE) into if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_PIPE) I have not tried it, and I'm not convinced that it is safe and right for I don't know detail of the kernel. >Audit-Trail: >Unformatted: