From owner-svn-src-head@freebsd.org Wed Jul 29 17:16:55 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7B1489AE287; Wed, 29 Jul 2015 17:16:55 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5296477B; Wed, 29 Jul 2015 17:16:55 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6THGtAv044687; Wed, 29 Jul 2015 17:16:55 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6THGsqF044685; Wed, 29 Jul 2015 17:16:54 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201507291716.t6THGsqF044685@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Wed, 29 Jul 2015 17:16:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r286020 - in head/sys: kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jul 2015 17:16:55 -0000 Author: ed Date: Wed Jul 29 17:16:53 2015 New Revision: 286020 URL: https://svnweb.freebsd.org/changeset/base/286020 Log: Introduce falloc_caps() to create descriptors with capabilties in place. falloc_noinstall() followed by finstall() allows you to create and install file descriptors with custom capabilities. Add falloc_caps() that can do both of these actions in one go. This will be used by CloudABI to create pipes with custom capabilities. Reviewed by: mjg Modified: head/sys/kern/kern_descrip.c head/sys/sys/filedesc.h Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Wed Jul 29 17:05:42 2015 (r286019) +++ head/sys/kern/kern_descrip.c Wed Jul 29 17:16:53 2015 (r286020) @@ -1707,7 +1707,8 @@ fdallocn(struct thread *td, int minfd, i * release the FILEDESC lock. */ int -falloc(struct thread *td, struct file **resultfp, int *resultfd, int flags) +falloc_caps(struct thread *td, struct file **resultfp, int *resultfd, int flags, + struct filecaps *fcaps) { struct file *fp; int error, fd; @@ -1716,7 +1717,7 @@ falloc(struct thread *td, struct file ** if (error) return (error); /* no reference held on error */ - error = finstall(td, fp, &fd, flags, NULL); + error = finstall(td, fp, &fd, flags, fcaps); if (error) { fdrop(fp, td); /* one reference (fp only) */ return (error); Modified: head/sys/sys/filedesc.h ============================================================================== --- head/sys/sys/filedesc.h Wed Jul 29 17:05:42 2015 (r286019) +++ head/sys/sys/filedesc.h Wed Jul 29 17:16:53 2015 (r286020) @@ -146,6 +146,10 @@ enum { /* Flags for kern_dup(). */ #define FDDUP_FLAG_CLOEXEC 0x1 /* Atomically set UF_EXCLOSE. */ +/* For backward compatibility. */ +#define falloc(td, resultfp, resultfd, flags) \ + falloc_caps(td, resultfp, resultfd, flags, NULL) + struct thread; void filecaps_init(struct filecaps *fcaps); @@ -156,8 +160,8 @@ void filecaps_free(struct filecaps *fcap int closef(struct file *fp, struct thread *td); int dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode, int openerror, int *indxp); -int falloc(struct thread *td, struct file **resultfp, int *resultfd, - int flags); +int falloc_caps(struct thread *td, struct file **resultfp, int *resultfd, + int flags, struct filecaps *fcaps); int falloc_noinstall(struct thread *td, struct file **resultfp); void _finstall(struct filedesc *fdp, struct file *fp, int fd, int flags, struct filecaps *fcaps);