From owner-freebsd-fs@FreeBSD.ORG Sat Mar 12 17:03:34 2011 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 65DC81065670 for ; Sat, 12 Mar 2011 17:03:34 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id D49EB8FC18 for ; Sat, 12 Mar 2011 17:03:33 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p2CH1NlE075490 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 12 Mar 2011 19:01:23 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p2CH1Nkv044625; Sat, 12 Mar 2011 19:01:23 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p2CH1Ni0044624; Sat, 12 Mar 2011 19:01:23 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 12 Mar 2011 19:01:23 +0200 From: Kostik Belousov To: freebsd-fs@freebsd.org, freebsd-standards@freebsd.org Message-ID: <20110312170123.GT78089@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="oT9u3ind7B9FXzeC" Content-Disposition: inline User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: Subject: open(O_NOFOLLOW) error when encountered symlink X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Mar 2011 17:03:34 -0000 --oT9u3ind7B9FXzeC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello, I noted the following discussion and commits in the gnu tar repository: http://lists.gnu.org/archive/html/bug-tar/2010-11/msg00080.html http://git.savannah.gnu.org/cgit/tar.git/commit/?id=1584b72ff271e7f826dd64d7a1c7cd2f66504acb http://git.savannah.gnu.org/cgit/tar.git/commit/?id=649b747913d2b289e904b5f1d222af886acd209c The issue is that in case of open(path, O_NOFOLLOW), when path is naming a symlink, FreeBSD returns EMLINK error. On the other hand, the POSIX requirement is absolutely clear that it shall be ELOOP. I found FreeBSD commit r35088 that specifically changed the error code from the required ELOOP to EMLINK. I doubt that somebody can remember a reason for the change done more then 12 years ago. Anybody have strong objections against the patch below ? diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2 index deca8bc..20877b5 100644 --- a/lib/libc/sys/open.2 +++ b/lib/libc/sys/open.2 @@ -318,7 +318,7 @@ is specified and the named file would reside on a read-only file system. The process has already reached its limit for open file descriptors. .It Bq Er ENFILE The system file table is full. -.It Bq Er EMLINK +.It Bq Er ELOOP .Dv O_NOFOLLOW was specified and the target is a symbolic link. .It Bq Er ENXIO diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 7b5cad1..c7985ef 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -194,7 +194,7 @@ restart: vp = ndp->ni_vp; } if (vp->v_type == VLNK) { - error = EMLINK; + error = ELOOP; goto bad; } if (vp->v_type == VSOCK) { --oT9u3ind7B9FXzeC Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk17puMACgkQC3+MBN1Mb4ig0ACcDtap15B/FoQHS7dsaErvo3NU WbgAoO8kSt4R5lAnVBPQBFu5ZFFLvl9B =JrMX -----END PGP SIGNATURE----- --oT9u3ind7B9FXzeC--