From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 25 07:08:57 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B4F86106566B for ; Mon, 25 Jul 2011 07:08:57 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 921438FC08 for ; Mon, 25 Jul 2011 07:08:57 +0000 (UTC) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTPS id 468A646B2D; Mon, 25 Jul 2011 03:08:57 -0400 (EDT) Date: Mon, 25 Jul 2011 08:08:57 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: exorcistkiller In-Reply-To: <1311496832217-4627557.post@n5.nabble.com> Message-ID: References: <1311496832217-4627557.post@n5.nabble.com> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-hackers@freebsd.org Subject: Re: Add setacl system call? 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: Mon, 25 Jul 2011 07:08:57 -0000 On Sun, 24 Jul 2011, exorcistkiller wrote: > Hi, I'm working on a course project in which I need to add 3 system calls. > One of which is setacl(char *name, int type, int idnum, int perms), which > set acl for a file specified by name. I used newfs as in > ftp://ftp.tw.freebsd.org/pub/FreeBSD/FreeBSD-current/src/sbin/newfs/ to make > this new filesystem, named myfs (which really is UFS2) and mounted it. > > My question is: > 1) where to start with? > 2) Is this filesystem actually a userland UFS and I can use functions in > libufs(3)? > 3) What about functions in ufs_acl.c? Should the acls be stored on the > extended attributes blocks? Does FreeBSD 8.2 support it? > > I know I'm asking stupid questions, but a small hint might help me a lot. > Thank you so much.. Hi... er.. exorcistkiller... (*) This being FreeBSD, you may want to start with the existing programmer documentation, which should prove quite useful given your goals. Try acl(3) for userspace, and acl(9) for the kernel. You are doing this in the context of a course, so the constraints may be somewhat artificial. However, normally my advice to someone wanting to add a new ACL implementation to FreeBSD would be to start with our existing implementation, which supports both POSIX.1e and NFSv4 ACLs (and is extensible to new ACL types without changing the current APIs (much)). For example, if I were going to teach our native system call API about AFS ACLs, I'd start by perusing the above man pages and code, including: src/bin/*acl* # Commands for manipulating ACLs src/lib/libc/posix1e # Library routines src/sys/kern/*acl* # File system-independent code src/sys/sys/acl.h # File system-independent header As you've already found, ufs_acl.c contains the implementation for UFS; ZFS, NFS, etc, have similar-looking files with markedly different contents. In general, if something looks file system-independent, we try to put it in the centralised files in kern, rather than replicate the code across file systems. Roughly half the code in the kern directory has to do with calls *into* the file system, and the other half is a library of routines called *by* the file system. Robert