From patchwork Wed Mar 19 19:06:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 3860411 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EA6D0BF540 for ; Wed, 19 Mar 2014 19:08:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F9C920213 for ; Wed, 19 Mar 2014 19:08:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2B9B9201E7 for ; Wed, 19 Mar 2014 19:08:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 725268973E; Wed, 19 Mar 2014 12:08:06 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-bk0-f41.google.com (mail-bk0-f41.google.com [209.85.214.41]) by gabe.freedesktop.org (Postfix) with ESMTP id 5637089755 for ; Wed, 19 Mar 2014 12:08:05 -0700 (PDT) Received: by mail-bk0-f41.google.com with SMTP id d7so650259bkh.0 for ; Wed, 19 Mar 2014 12:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wpWO+/dkLcS/IcWfBGz5UZ+KjVa/nLfD5iUAHkFD+zY=; b=olCsyoHlXBG0dyVNUtsK0iBuBhqoPz2yUqvomhxeyd4lmaF1dcc/rns+aVejnR8kvk w47Tj/txA3l4cvHSvW+57UD5dmXIcGlz3FSo/ZscpfHDl/Ph2UQHoB8xe1/J5FwMhe2d Ddn3jSUZd7cImsJxFe0JBmEr0QMjXIAQ7I63VAFAw/3Ftp8wpSP0kG/cFAa2bk1Y5FCR AYjkiWTGO2/nXI+OSVuFazdi1iqs2x3k4auD9r9lfCGQdo/z4Un9/c7I/rKvUiZ7Ey9i gNgEESq0+s0LVDSAL6eS4jhLRU1AeGxKRYYZ8PmY79YfeWRxePFXR/xJkcNoHStHYisa o3pQ== X-Received: by 10.204.75.201 with SMTP id z9mr2195255bkj.37.1395256084534; Wed, 19 Mar 2014 12:08:04 -0700 (PDT) Received: from david-tp.localdomain (stgt-5f71aff2.pool.mediaWays.net. [95.113.175.242]) by mx.google.com with ESMTPSA id c15sm20566146bky.13.2014.03.19.12.08.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Mar 2014 12:08:03 -0700 (PDT) From: David Herrmann To: linux-kernel@vger.kernel.org Subject: [PATCH man-pages 6/6] memfd_create.2: add memfd_create() man-page Date: Wed, 19 Mar 2014 20:06:51 +0100 Message-Id: <1395256011-2423-7-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1395256011-2423-1-git-send-email-dh.herrmann@gmail.com> References: <1395256011-2423-1-git-send-email-dh.herrmann@gmail.com> Cc: Matthew Wilcox , Ryan Lortie , Hugh Dickins , Johannes Weiner , Kay Sievers , dri-devel@lists.freedesktop.org, Daniel Mack , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Karol Lewandowski , Lennart Poettering , Greg Kroah-Hartman , Tejun Heo , "Michael Kerrisk \(man-pages\)" , Andrew Morton , Linus Torvalds , Alexander Viro X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The memfd_create() syscall creates anonymous files similar to O_TMPFILE but does not require an active mount-point. Signed-off-by: David Herrmann --- man2/memfd_create.2 | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 man2/memfd_create.2 diff --git a/man2/memfd_create.2 b/man2/memfd_create.2 new file mode 100644 index 0000000..3e362e0 --- /dev/null +++ b/man2/memfd_create.2 @@ -0,0 +1,110 @@ +.\" Copyright (C) 2014 David Herrmann +.\" starting from a version by Michael Kerrisk +.\" +.\" %%%LICENSE_START(GPLv2+_SW_3_PARA) +.\" This program is free software; you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation; either version 2 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public +.\" License along with this manual; if not, see +.\" . +.\" %%%LICENSE_END +.\" +.TH MEMFD_CREATE 2 2014-03-18 Linux "Linux Programmer's Manual" +.SH NAME +memfd_create \- create an anonymous file +.SH SYNOPSIS +.B #include +.sp +.BI "int memfd_create(const char *" name ", u64 " size ", u64 " flags ");" +.SH DESCRIPTION +.BR memfd_create () +creates an anonymous file and returns a file-descriptor to it. The file behaves +like regular files, thus can be modified, truncated, memory-mapped and more. +However, unlike regular files it lives in main memory and has no non-volatile +backing storage. Once all references to the file are dropped, it is +automatically released. Like all shmem-based files, memfd files support +.BR SHMEM +sealing parameters. See +.BR SHMEM_SET_SEALS " with " fcntl (2) +for more information. + +The initial size of the file is set to +.IR size ". " name +is used as internal file-name and will occur as such in +.IR /proc/self/fd/ . +The name is always prefixed with +.BR memfd: +and serves only debugging purposes. + +The following values may be bitwise ORed in +.IR flags +to change the behaviour of +.BR memfd_create (): +.TP +.BR MFD_CLOEXEC +Set the close-on-exec +.RB ( FD_CLOEXEC ) +flag on the new file descriptor. +See the description of the +.B O_CLOEXEC +flag in +.BR open (2) +for reasons why this may be useful. +.PP +Unused bits must be cleared to 0. + +As its return value, +.BR memfd_create () +returns a new file descriptor that can be used to refer to the file. +A copy of the file descriptor created by +.BR memfd_create () +is inherited by the child produced by +.BR fork (2). +The duplicate file descriptor is associated with the same file. +File descriptors created by +.BR memfd_create () +are preserved across +.BR execve (2), +unless the close-on-exec flag has been set. +.SH RETURN VALUE +On success, +.BR memfd_create () +returns a new file descriptor. +On error, \-1 is returned and +.I errno +is set to indicate the error. +.SH ERRORS +.TP +.B EINVAL +An unsupported value was specified in one of the arguments. +.TP +.B EMFILE +The per-process limit on open file descriptors has been reached. +.TP +.B ENFILE +The system-wide limit on the total number of open files has been +reached. +.TP +.B EFAULT +The name given in +.IR name +points to invalid memory. +.TP +.B ENOMEM +There was insufficient memory to create a new anonymous file. +.SH VERSIONS +to-be-defined +.SH CONFORMING TO +.BR memfd_create () +is Linux-specific. +.SH SEE ALSO +.BR shmget (2), +.BR fcntl (2),