From owner-svn-src-head@FreeBSD.ORG Thu Jun 11 18:04:58 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A6571065673; Thu, 11 Jun 2009 18:04:58 +0000 (UTC) (envelope-from jmallett@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 02E128FC18; Thu, 11 Jun 2009 18:04:58 +0000 (UTC) (envelope-from jmallett@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5BI4vAJ056002; Thu, 11 Jun 2009 18:04:57 GMT (envelope-from jmallett@svn.freebsd.org) Received: (from jmallett@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5BI4v7c056000; Thu, 11 Jun 2009 18:04:57 GMT (envelope-from jmallett@svn.freebsd.org) Message-Id: <200906111804.n5BI4v7c056000@svn.freebsd.org> From: Juli Mallett Date: Thu, 11 Jun 2009 18:04:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194030 - head/lib/libufs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Thu, 11 Jun 2009 18:04:58 -0000 Author: jmallett Date: Thu Jun 11 18:04:57 2009 New Revision: 194030 URL: http://svn.freebsd.org/changeset/base/194030 Log: Allow libufs(3) functions to operate on a regular file. This makes it possible to use almost anything that uses libufs(3) against a file as an unprivileged user, e.g. tunefs(8) and dumpfs(8) against a makefs(8)-created image. Prodded by: kensmith Modified: head/lib/libufs/type.c head/lib/libufs/ufs_disk_close.3 Modified: head/lib/libufs/type.c ============================================================================== --- head/lib/libufs/type.c Thu Jun 11 17:42:02 2009 (r194029) +++ head/lib/libufs/type.c Thu Jun 11 18:04:57 2009 (r194030) @@ -108,7 +108,10 @@ again: if ((ret = stat(name, &st)) < 0) */ name = oname; } - if (ret >= 0 && S_ISCHR(st.st_mode)) { + if (ret >= 0 && S_ISREG(st.st_mode)) { + /* Possibly a disk image, give it a try. */ + ; + } else if (ret >= 0 && S_ISCHR(st.st_mode)) { /* This is what we need, do nothing. */ ; } else if ((fs = getfsfile(name)) != NULL) { Modified: head/lib/libufs/ufs_disk_close.3 ============================================================================== --- head/lib/libufs/ufs_disk_close.3 Thu Jun 11 17:42:02 2009 (r194029) +++ head/lib/libufs/ufs_disk_close.3 Thu Jun 11 18:04:57 2009 (r194030) @@ -53,7 +53,7 @@ and populate the structure pointed to by The disk is opened read-only. The specified .Fa name -may be either a mountpoint, or a device name. +may be either a mountpoint, a device name or a filesystem image. The .Fn ufs_disk_fillout function assumes there is a valid superblock and will fail if not,