From owner-svn-src-stable@freebsd.org Fri Jan 20 17:38:13 2017 Return-Path: Delivered-To: svn-src-stable@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 88118CB84D4; Fri, 20 Jan 2017 17:38:13 +0000 (UTC) (envelope-from wblock@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 4A8D61285; Fri, 20 Jan 2017 17:38:13 +0000 (UTC) (envelope-from wblock@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v0KHcCE3047772; Fri, 20 Jan 2017 17:38:12 GMT (envelope-from wblock@FreeBSD.org) Received: (from wblock@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v0KHcChh047771; Fri, 20 Jan 2017 17:38:12 GMT (envelope-from wblock@FreeBSD.org) Message-Id: <201701201738.v0KHcChh047771@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wblock set sender to wblock@FreeBSD.org using -f From: Warren Block Date: Fri, 20 Jan 2017 17:38:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r312549 - stable/11/lib/libc/sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jan 2017 17:38:13 -0000 Author: wblock (doc committer) Date: Fri Jan 20 17:38:12 2017 New Revision: 312549 URL: https://svnweb.freebsd.org/changeset/base/312549 Log: MFC 312083: Update the shm_open.2 man page to reflect objective reality. Sponsored by: iXsystems Modified: stable/11/lib/libc/sys/shm_open.2 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/sys/shm_open.2 ============================================================================== --- stable/11/lib/libc/sys/shm_open.2 Fri Jan 20 17:35:31 2017 (r312548) +++ stable/11/lib/libc/sys/shm_open.2 Fri Jan 20 17:38:12 2017 (r312549) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 18, 2013 +.Dd January 13, 2017 .Dt SHM_OPEN 2 .Os .Sh NAME @@ -171,7 +171,8 @@ and .Dv O_TRUNC flags may be used in portable programs. .Pp -The result of using +.Tn POSIX +specifications state that the result of using .Xr open 2 , .Xr read 2 , or @@ -179,19 +180,43 @@ or on a shared memory object, or on the descriptor returned by .Fn shm_open , is undefined. -It is also undefined whether the shared memory object itself, or its -contents, persist across reboots. -.Pp -In FreeBSD, +However, the +.Fx +kernel implementation explicitly includes support for .Xr read 2 and -.Xr write 2 -on a shared memory object will fail with -.Er EOPNOTSUPP -and neither shared memory objects nor their contents persist across reboots. +.Xr write 2 . +.Pp +Neither shared memory objects nor their contents persist across reboots. +.Pp +Writes do not extend shared memory objects, so +.Xr ftruncate 2 +must be called before any data can be written. +See +.Sx EXAMPLES . +.Sh EXAMPLES +This example fails without the call to +.Xr ftruncate 2 : +.Bd -literal -compact + + uint8_t buffer[getpagesize()]; + ssize_t len; + int fd; + + fd = shm_open(SHM_ANON, O_RDWR | O_CREAT, 0600); + if (fd < 0) + err(EX_OSERR, "%s: shm_open", __func__); + if (ftruncate(fd, getpagesize()) < 0) + err(EX_IOERR, "%s: ftruncate", __func__); + len = pwrite(fd, buffer, getpagesize(), 0); + if (len < 0) + err(EX_IOERR, "%s: pwrite", __func__); + if (len != getpagesize()) + errx(EX_IOERR, "%s: pwrite length mismatch", __func__); +.Ed .Sh ERRORS -The following errors are defined for -.Fn shm_open : +.Fn shm_open +fails with these error codes for these conditions: .Bl -tag -width Er .It Bq Er EINVAL A flag other than @@ -235,8 +260,8 @@ are specified and the named shared memor The required permissions (for reading or reading and writing) are denied. .El .Pp -The following errors are defined for -.Fn shm_unlink : +.Fn shm_unlink +fails with these error codes for these conditions: .Bl -tag -width Er .It Bq Er EFAULT The