18791Sjkh/* 28791Sjkh * The new sysinstall program. 38791Sjkh * 48791Sjkh * This is probably the last attempt in the `sysinstall' line, the next 58791Sjkh * generation being slated to essentially a complete rewrite. 68791Sjkh * 750479Speter * $FreeBSD$ 88791Sjkh * 98791Sjkh * Copyright (c) 1995 108791Sjkh * Jordan Hubbard. All rights reserved. 118791Sjkh * Copyright (c) 1995 128791Sjkh * Gary J Palmer. All rights reserved. 138791Sjkh * 148791Sjkh * Redistribution and use in source and binary forms, with or without 158791Sjkh * modification, are permitted provided that the following conditions 168791Sjkh * are met: 178791Sjkh * 1. Redistributions of source code must retain the above copyright 188881Srgrimes * notice, this list of conditions and the following disclaimer, 198881Srgrimes * verbatim and that no modifications are made prior to this 208791Sjkh * point in the file. 218791Sjkh * 2. Redistributions in binary form must reproduce the above copyright 228791Sjkh * notice, this list of conditions and the following disclaimer in the 238791Sjkh * documentation and/or other materials provided with the distribution. 248791Sjkh * 258791Sjkh * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND 268791Sjkh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 278791Sjkh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 288791Sjkh * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE 298791Sjkh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 308791Sjkh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 318791Sjkh * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) 328791Sjkh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 338791Sjkh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 348791Sjkh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 358791Sjkh * SUCH DAMAGE. 368791Sjkh * 378791Sjkh */ 388791Sjkh 398791Sjkh#include "sysinstall.h" 408837Sjkh#include <sys/fcntl.h> 418837Sjkh#include <sys/param.h> 42194807Scperciva#include <sys/mount.h> 43194807Scperciva#include <ufs/ufs/ufsmount.h> 448791Sjkh 45194807Scpercivastatic Boolean UFSMounted; 46194807Scpercivastatic char mountpoint[] = "/dist"; 478791Sjkh 48194807ScpercivaBoolean 49194807ScpercivamediaInitUFS(Device *dev) 50194807Scperciva{ 51194807Scperciva struct ufs_args args; 52194807Scperciva 53194807Scperciva if (UFSMounted) 54194807Scperciva return TRUE; 55194807Scperciva 56194807Scperciva Mkdir(mountpoint); 57194807Scperciva memset(&args, 0, sizeof(args)); 58194807Scperciva args.fspec = dev->devname; 59194807Scperciva 60194807Scperciva if (mount("ufs", mountpoint, MNT_RDONLY, (caddr_t)&args) == -1) { 61194807Scperciva msgConfirm("Error mounting %s on %s: %s (%u)", args.fspec, mountpoint, strerror(errno), errno); 62194807Scperciva return FALSE; 63194807Scperciva } 64194807Scperciva UFSMounted = TRUE; 65194807Scperciva return TRUE; 66194807Scperciva} 67194807Scperciva 6820315SjkhFILE * 6914321SjkhmediaGetUFS(Device *dev, char *file, Boolean probe) 708791Sjkh{ 7142005Sjkh return mediaGenericGet((char *)dev->private, file); 728791Sjkh} 73194807Scperciva 74194807Scpercivavoid 75194807ScpercivamediaShutdownUFS(Device *dev) 76194807Scperciva{ 77194807Scperciva if (!UFSMounted) 78194807Scperciva return; 79194807Scperciva if (unmount(mountpoint, MNT_FORCE) != 0) 80194807Scperciva msgConfirm("Could not unmount the UFS partition from %s: %s", 81194807Scperciva mountpoint, strerror(errno)); 82194807Scperciva else 83194807Scperciva UFSMounted = FALSE; 84194807Scperciva return; 85194807Scperciva} 86