From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Verych Subject: code example (Re: euidaccess() as syscall) Date: Mon, 5 May 2008 21:21:44 +0200 Message-ID: References: <8499950a0805020959g5114c9c9wa3803a9d1eab3147@mail.gmail.com> <20080502170603.GJ14976@parisc-linux.org> <8499950a0805021013g76261641r847ab18e648693a1@mail.gmail.com> <20080502173343.GB1240@shareable.org> <8499950a0805021145l6df18c1ew425a2398589ad7f7@mail.gmail.com> To: linux fs Return-path: Received: from barikada.upol.cz ([158.194.242.200]:34665 "EHLO barikada.upol.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761957AbYEETQy (ORCPT ); Mon, 5 May 2008 15:16:54 -0400 Received: from flower (flower.upol.cz [158.194.64.22]) by barikada.upol.cz (Spam Firewall) with ESMTP id 0138F129807 for ; Mon, 5 May 2008 21:00:26 +0200 (CEST) Received: from flower (flower.upol.cz [158.194.64.22]) by barikada.upol.cz with ESMTP id W8v45JgscwlCq99O for ; Mon, 05 May 2008 21:00:26 +0200 (CEST) Received: from olecom by flower with local (Exim 4.63) (envelope-from ) id 1Jt6Fs-0005uc-8Z for linux-fsdevel@vger.kernel.org; Mon, 05 May 2008 21:21:44 +0200 In-Reply-To: <8499950a0805021145l6df18c1ew425a2398589ad7f7@mail.gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: > Unneeded code path is there, but i'm not sure run overhead is > measurable. Inflexibility and bug reports are, however. Based on stripped, thus raceless-in-kernel linux-2.6/fs/open.c:sys_faccessat() Example expects non-error part to be likely, doesn't use "goto" in basic stuff, isn't going to be used with unlikely_buggy(optimizing) GCC. Comments? # lang:C asmlinkage long sys_feuidaccessat(int dfd, const char __user *filename, int mode) { struct nameidata nd; int res; /* where's F_OK, X_OK, W_OK, R_OK? */ if (!(mode & ~S_IRWXO)) { /* here */ res = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd); if (!res) { res = vfs_permission(&nd, mode); /* SuS v2 requires we report a read only fs too */ if (res || special_file(nd.dentry->d_inode->i_mode) || !(mode & S_IWOTH)) {} else if (IS_RDONLY(nd.dentry->d_inode)) res = -EROFS; path_release(&nd); } return res; } return -EINVAL; } # -- sed 'sed && sh + olecom = love' << '' -o--=O`C #oo'L O <___=E M