From owner-freebsd-bugs@FreeBSD.ORG Wed May 16 20:00:14 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 023231065674 for ; Wed, 16 May 2012 20:00:13 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 082C88FC14 for ; Wed, 16 May 2012 20:00:13 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q4GK0ClA017267 for ; Wed, 16 May 2012 20:00:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q4GK0C11017266; Wed, 16 May 2012 20:00:12 GMT (envelope-from gnats) Resent-Date: Wed, 16 May 2012 20:00:12 GMT Resent-Message-Id: <201205162000.q4GK0C11017266@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Spencer Minear Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B5ED1106566B for ; Wed, 16 May 2012 19:59:44 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id A131D8FC0A for ; Wed, 16 May 2012 19:59:44 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q4GJxidb053894 for ; Wed, 16 May 2012 19:59:44 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q4GJximB053893; Wed, 16 May 2012 19:59:44 GMT (envelope-from nobody) Message-Id: <201205161959.q4GJximB053893@red.freebsd.org> Date: Wed, 16 May 2012 19:59:44 GMT From: Spencer Minear To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/167979: DIOCGDINFO ioctl does not work on 8.2 file systems X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 May 2012 20:00:14 -0000 >Number: 167979 >Category: kern >Synopsis: DIOCGDINFO ioctl does not work on 8.2 file systems >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed May 16 20:00:12 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Spencer Minear >Release: FreeBSD 8.2 >Organization: McAfee >Environment: FreeBSD freebe1.scur.com 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Fri Feb 18 02:24:46 UTC 2011 root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 >Description: Use of ioctl(fd, DIOCGDINFO, &dl) fails with a 'Inappropriate ioctl for device' message when run on a file system like ad0s1a. On a similar 7.2 system one receives the expected "Filesystem type 4.2BSD" type of information. My analysis suggests that the problem is related to changes in the GEOM layer, specifically the introduction of the PART class. In 7.2 the ioctl ends up getting to the underlying BSD geom layer and obtains the required information. In 8.3 the ioctl appears to get to a PART entry that has the name of the device, but does not know how to get to the underlying BSD layer to find out the file type. In addition I've noted that if you have a slice that contains a number of BSD file systems, that are not being used, the device information shows many devices with completely bogus names like /dev/ad0s3aa, /dev/ad0s3ac, etc. In most cases these names get repeated. If the file system ad0s3a is mounted then all off the bogus names disappear. It appears that the mount action will initiate geom spoil processing that cleans up these entries. The following simple test program was used to show that the ioctl behavior changes between FreeBSD 7.2 and 8.2. #include #include #include #include #include #include #include #include #define FSTYPENAMES #include int main(int argc, char** argv) { struct disklabel dl; int fd; char *dev; char *dev_path; char p; struct stat sb; u_char t; const char *vfstype; if (argc != 2) { printf("Usage: tstdioginfo device\n"); exit(1); } dev = argv[1]; asprintf(&dev_path, "/dev/%s", dev); if (stat(dev_path, &sb) != 0) { err(1, "Failed to stat dev %s\n", dev); exit(1); } p = dev[strlen(dev) - 1]; /* deduce the file system type from the disk label */ if ((fd = open(dev_path, O_RDONLY)) == -1) err(1, "cannot open '%s'", dev_path); if (ioctl(fd, DIOCGDINFO, &dl) == -1) { (void) close(fd); err(1, "DIOCGDIFNO failed on '%s'", dev); } if ((p - 'a') >= dl.d_npartitions) errx(1, "partition `%s' is not defined on disk", dev); if ((t = dl.d_partitions[p - 'a'].p_fstype) >= FSMAXTYPES) errx(1, "partition `%s' is not of a legal vfstype", dev); if ((vfstype = fstypenames[t]) == NULL) errx(1, "vfstype `%s' on partition `%s' is not supported", fstypenames[t], dev); printf("Filesystem type %s\n", vfstype); return(0); } >How-To-Repeat: Run the test program >Fix: None Known >Release-Note: >Audit-Trail: >Unformatted: