18837Sjkh/* 28837Sjkh * The new sysinstall program. 38837Sjkh * 48837Sjkh * This is probably the last attempt in the `sysinstall' line, the next 58837Sjkh * generation being slated to essentially a complete rewrite. 68837Sjkh * 750479Speter * $FreeBSD$ 88837Sjkh * 98837Sjkh * Copyright (c) 1995 108837Sjkh * Jordan Hubbard. All rights reserved. 118837Sjkh * 128837Sjkh * Redistribution and use in source and binary forms, with or without 138837Sjkh * modification, are permitted provided that the following conditions 148837Sjkh * are met: 158837Sjkh * 1. Redistributions of source code must retain the above copyright 168881Srgrimes * notice, this list of conditions and the following disclaimer, 178881Srgrimes * verbatim and that no modifications are made prior to this 188837Sjkh * point in the file. 198837Sjkh * 2. Redistributions in binary form must reproduce the above copyright 208837Sjkh * notice, this list of conditions and the following disclaimer in the 218837Sjkh * documentation and/or other materials provided with the distribution. 228837Sjkh * 238837Sjkh * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND 248837Sjkh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 258837Sjkh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 268837Sjkh * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE 278837Sjkh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 288837Sjkh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 298837Sjkh * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) 308837Sjkh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 318837Sjkh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 328837Sjkh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 338837Sjkh * SUCH DAMAGE. 348837Sjkh * 358837Sjkh */ 368837Sjkh 378791Sjkh#include "sysinstall.h" 388791Sjkh#include <sys/errno.h> 398837Sjkh#include <sys/fcntl.h> 408791Sjkh#include <sys/param.h> 418791Sjkh#include <sys/mount.h> 428791Sjkh 43106053Swollman#include <limits.h> 44106053Swollman 458837SjkhBoolean NFSMounted; 4642005Sjkhstatic char mountpoint[] = "/dist"; 478837Sjkh 488837SjkhBoolean 498837SjkhmediaInitNFS(Device *dev) 508837Sjkh{ 518860Sjkh Device *netDevice = (Device *)dev->private; 5254722Sjkh WINDOW *w = savescr(); 538860Sjkh 548837Sjkh if (NFSMounted) 558837Sjkh return TRUE; 568837Sjkh 5779065Sdd if (!DEVICE_INIT(netDevice)) 589202Srgrimes return FALSE; 598860Sjkh 6021937Sjkh if (Mkdir(mountpoint)) 618837Sjkh return FALSE; 628837Sjkh 6321976Sjkh msgNotify("Mounting %s over NFS on %s", dev->name, mountpoint); 64121245Sdes if (vsystem("mount_nfs %s %s %s %s %s %s", 65121245Sdes !variable_cmp(VAR_NFS_TCP, "YES") ? "-T" : "", 66121245Sdes !variable_cmp(VAR_NFS_V3, "YES") ? "-3" : "", 67121245Sdes !variable_cmp(VAR_SLOW_ETHER, "YES") ? 68121245Sdes "-r 1024 -w 1024" : "-r 4096 -w 4096", 69121245Sdes !variable_cmp(VAR_NFS_SECURE, "YES") ? "-P" : "", 70121245Sdes dev->name, mountpoint)) { 7121937Sjkh msgConfirm("Error mounting %s on %s: %s.", dev->name, mountpoint, strerror(errno)); 7221937Sjkh if (netDevice) 7379065Sdd DEVICE_SHUTDOWN(netDevice); 7454722Sjkh restorescr(w); 758837Sjkh return FALSE; 768837Sjkh } 778837Sjkh NFSMounted = TRUE; 7842005Sjkh if (isDebug()) 7942005Sjkh msgDebug("Mounted NFS device %s onto %s\n", dev->name, mountpoint); 8054722Sjkh restorescr(w); 818837Sjkh return TRUE; 828837Sjkh} 838837Sjkh 8420315SjkhFILE * 8514321SjkhmediaGetNFS(Device *dev, char *file, Boolean probe) 868837Sjkh{ 8742005Sjkh return mediaGenericGet(mountpoint, file); 888837Sjkh} 898837Sjkh 908837Sjkhvoid 918837SjkhmediaShutdownNFS(Device *dev) 928837Sjkh{ 938837Sjkh if (!NFSMounted) 948837Sjkh return; 9542005Sjkh 96106279Skuriyama msgDebug("Unmounting NFS partition on %s\n", mountpoint); 9721937Sjkh if (unmount(mountpoint, MNT_FORCE) != 0) 9812661Speter msgConfirm("Could not unmount the NFS partition: %s", strerror(errno)); 998837Sjkh NFSMounted = FALSE; 1008837Sjkh return; 1018837Sjkh} 102