From owner-freebsd-hackers@FreeBSD.ORG Tue Jun 6 02:14:03 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5437916AE20 for ; Tue, 6 Jun 2006 01:35:24 +0000 (UTC) (envelope-from artifact.one@googlemail.com) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.176]) by mx1.FreeBSD.org (Postfix) with ESMTP id C437443D5D for ; Tue, 6 Jun 2006 01:35:20 +0000 (GMT) (envelope-from artifact.one@googlemail.com) Received: by py-out-1112.google.com with SMTP id m51so1563295pye for ; Mon, 05 Jun 2006 18:35:20 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=googlemail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ALZqJmQx9TZLdXSJB5x0gD5RuHX1YNpQ9TDr13BcAM9TEP3yObpYznlchtQJzQqxRuJTSpMt/0xXF1cLLsIDDMOODpQrTnpUxLChhHZdnmnVH/WoMbAhoX/pR9sSAq1AljvvSkxFAGZoWdfz4ipfvyWqu0GVBtkJxoyMwdMJJJ4= Received: by 10.35.53.18 with SMTP id f18mr7429468pyk; Mon, 05 Jun 2006 18:35:20 -0700 (PDT) Received: by 10.35.121.7 with HTTP; Mon, 5 Jun 2006 18:35:20 -0700 (PDT) Message-ID: <8e96a0b90606051835j363547e0q4d8a549837c27b74@mail.gmail.com> Date: Tue, 6 Jun 2006 02:35:20 +0100 From: "mal content" To: "Pieter de Goeje" In-Reply-To: <200606060208.28838.pieter@degoeje.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <8e96a0b90606041148g5674ca31r74be2e1f9c79b640@mail.gmail.com> <200606060208.28838.pieter@degoeje.nl> Cc: freebsd-hackers@freebsd.org Subject: Re: Strange behaviour from mkdir()? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Jun 2006 02:14:06 -0000 On 06/06/06, Pieter de Goeje wrote: > Hi MC, > > On Sunday 04 June 2006 20:48, mal content wrote: > > Is this expected behaviour (I'm using the mkdir utility > > for the example, but the problem occurs using the system > > call directly): > > > > # mkdir . > > mkdir: .: File exists > > # mkdir .. > > mkdir: ..: File exists > > > > Now, the unusual one: > > > > # mkdir / > > mkdir: /: Is a directory > > > > Shouldn't it say 'file exists'? > In fact, the _only_ directory that I could find that shows this behaviour > is /. (I am using 6-stable) > > > > > The mkdir() man page doesn't say that the function can set > > errno to EISDIR and yet that's what's happening here. > > > > I did some research on it, and it seems the mkdir utility is aware of the > EISDIR error. Kinda weird if you ask me, since it isn't documented. I followed the kern_mkdir() function and ended up in /src/sys/kern/vfs_lookup.c where this bit of code appears: 785: /* 786: * Check for degenerate name (e.g. / or "") 787: * which is a way of talking about a directory, 788: * e.g. like "/." or ".". 789: */ 790: if (cnp->cn_nameptr[0] == '\0') { 791: if (cnp->cn_nameiop != LOOKUP || wantparent) { 792: error = EISDIR; 793: goto bad; 794: } 795: if (dp->v_type != VDIR) { 796: error = ENOTDIR; 797: goto bad; 798: } Not sure if that code is completely correct, but what do I know... MC