From owner-svn-src-head@FreeBSD.ORG Wed Jun 24 04:56:13 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 D4B7E106564A; Wed, 24 Jun 2009 04:56:13 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C2C028FC08; Wed, 24 Jun 2009 04:56:13 +0000 (UTC) (envelope-from cperciva@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 n5O4uDdW001949; Wed, 24 Jun 2009 04:56:13 GMT (envelope-from cperciva@svn.freebsd.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5O4uDND001946; Wed, 24 Jun 2009 04:56:13 GMT (envelope-from cperciva@svn.freebsd.org) Message-Id: <200906240456.n5O4uDND001946@svn.freebsd.org> From: Colin Percival Date: Wed, 24 Jun 2009 04:56:13 +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: r194807 - head/usr.sbin/sysinstall 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: Wed, 24 Jun 2009 04:56:14 -0000 Author: cperciva Date: Wed Jun 24 04:56:13 2009 New Revision: 194807 URL: http://svn.freebsd.org/changeset/base/194807 Log: Add detection of UFS filesystems. PR: bin/135565 Submitted by: Daniel O'Connor Reviewed by: randi MFC after: 1 month Modified: head/usr.sbin/sysinstall/devices.c head/usr.sbin/sysinstall/ufs.c Modified: head/usr.sbin/sysinstall/devices.c ============================================================================== --- head/usr.sbin/sysinstall/devices.c Wed Jun 24 04:45:03 2009 (r194806) +++ head/usr.sbin/sysinstall/devices.c Wed Jun 24 04:56:13 2009 (r194807) @@ -421,7 +421,7 @@ skipif: } } - /* Finally, go get the disks and look for DOS partitions to register */ + /* Finally, go get the disks and look for partitions to register */ if ((names = Disk_Names()) != NULL) { int i; @@ -458,7 +458,11 @@ skipif: if (isDebug()) msgDebug("Found a disk device named %s\n", names[i]); - /* Look for existing DOS partitions to register as "DOS media devices" */ + /* Look for existing DOS partitions to register as "DOS media devices" + * XXX: libdisks handling of extended partitions is too + * simplistic - it does not handle them containing (for + * example) UFS partitions + */ for (c1 = d->chunks->part; c1; c1 = c1->next) { if (c1->type == fat || c1->type == efi || c1->type == extended) { Device *dev; @@ -470,8 +474,25 @@ skipif: mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL); dev->private = c1; if (isDebug()) - msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name); + msgDebug("Found a DOS partition %s\n", c1->name); + } else if (c1->type == freebsd) { + Device *dev; + char devname[80]; + Chunk *c2; + + for (c2 = c1->part; c2; c2 = c2->next) { + if (c2->type != part || c2->subtype != 7) + continue; + /* Got one! */ + snprintf(devname, sizeof devname, "/dev/%s", c1->name); + dev = deviceRegister(c2->name, c2->name, strdup(devname), DEVICE_TYPE_UFS, TRUE, + mediaInitUFS, mediaGetUFS, mediaShutdownUFS, NULL); + dev->private = c2; + if (isDebug()) + msgDebug("Found a UFS sub-partition %s\n", c2->name); + } } + } } free(names); Modified: head/usr.sbin/sysinstall/ufs.c ============================================================================== --- head/usr.sbin/sysinstall/ufs.c Wed Jun 24 04:45:03 2009 (r194806) +++ head/usr.sbin/sysinstall/ufs.c Wed Jun 24 04:56:13 2009 (r194807) @@ -39,11 +39,47 @@ #include "sysinstall.h" #include #include +#include +#include -/* No init or shutdown routines necessary - all done in mediaSetUFS() */ +static Boolean UFSMounted; +static char mountpoint[] = "/dist"; + +Boolean +mediaInitUFS(Device *dev) +{ + struct ufs_args args; + + if (UFSMounted) + return TRUE; + + Mkdir(mountpoint); + memset(&args, 0, sizeof(args)); + args.fspec = dev->devname; + + if (mount("ufs", mountpoint, MNT_RDONLY, (caddr_t)&args) == -1) { + msgConfirm("Error mounting %s on %s: %s (%u)", args.fspec, mountpoint, strerror(errno), errno); + return FALSE; + } + UFSMounted = TRUE; + return TRUE; +} FILE * mediaGetUFS(Device *dev, char *file, Boolean probe) { return mediaGenericGet((char *)dev->private, file); } + +void +mediaShutdownUFS(Device *dev) +{ + if (!UFSMounted) + return; + if (unmount(mountpoint, MNT_FORCE) != 0) + msgConfirm("Could not unmount the UFS partition from %s: %s", + mountpoint, strerror(errno)); + else + UFSMounted = FALSE; + return; +}