From owner-freebsd-current Fri Dec 13 9:28:47 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7967437B401 for ; Fri, 13 Dec 2002 09:28:45 -0800 (PST) Received: from gilliam.users.flyingcroc.net (gilliam.users.flyingcroc.net [207.246.128.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id EF9BD43ED4 for ; Fri, 13 Dec 2002 09:28:44 -0800 (PST) (envelope-from joek@mail.flyingcroc.net) Received: from mail.flyingcroc.net (zircon.staff.flyingcroc.net [207.246.150.92]) by gilliam.users.flyingcroc.net (8.9.3/8.9.3) with ESMTP id JAA68117 for ; Fri, 13 Dec 2002 09:28:44 -0800 (PST) Message-ID: <3DFA18CC.8090205@mail.flyingcroc.net> Date: Fri, 13 Dec 2002 09:28:44 -0800 From: Joe Kelsey User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.1) Gecko/20021211 X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-current@freebsd.org Subject: Re: Posix Semaphores in -CURRENT References: <3DF8F08E.8050809@mail.flyingcroc.net> <3DFA0771.BDFC87A8@mindspring.com> <3DFA0DAC.2070801@mail.flyingcroc.net> <3DFA1251.C4755C5B@mindspring.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Terry Lambert wrote: > Get me the exact file you are concerned about, and I will stare > at it with you. I think, though, that if there is a problem, it's > just that you are catching things in mid-implementation (POSIX > semaphores were supported in the other scope, but not system, > until very recently; there's even magic POSIX manifests that tell > you not to use them). src/sys/kern/uipc_sem.c, version 1.3: ... #define SEM_MAX_NAMELEN 14 ... static int sem_create(td, name, ksret, mode, value) ... if (value > SEM_VALUE_MAX) return (EINVAL); ret = malloc(sizeof(*ret), M_SEM, M_WAITOK | M_ZERO); if (name != NULL) { len = strlen(name); if (len > SEM_MAX_NAMELEN) { free(ret, M_SEM); return (ENAMETOOLONG); } /* name must start with a '/' but not contain one. */ if (*name != '/' || len < 2 || index(name + 1, '/') != NULL) { free(ret, M_SEM); return (EINVAL); } The comment makes it look like this code allows a 14-character named semaphore which *must* start with a slash and cannot contain embedded slashes. In other words, it does *not* conform to pathname semantics. If some other part of the system already verifies that the named semaphore is actually an empty directory entry, then why is there a name length restriction and why is there a '/' check? If this is a bug, I will happily submit a PR. I wanted some feedback before doing so. I am interested in playing with the semantics of posix semaphores. It looks to me as though they could be implemented more resource-efficiently than SVID semaphores and really do have different semantics. I really want to try to understand what will and won't be released in 5.0. How will I enable these for testing/use and will they work in a portable way? The only way to answer those questions right now is to examine the source. I am trying to understand the source, especially in how it may or may not restrict use of semaphores. /Joe To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message