17c208ed6SRick Macklem /*- 251369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 351369649SPedro F. Giffuni * 47c208ed6SRick Macklem * Copyright (c) 1991, 1993 57c208ed6SRick Macklem * The Regents of the University of California. All rights reserved. 67c208ed6SRick Macklem * 77c208ed6SRick Macklem * This code is derived from software contributed to Berkeley by 87c208ed6SRick Macklem * Rick Macklem at The University of Guelph. 97c208ed6SRick Macklem * 107c208ed6SRick Macklem * Redistribution and use in source and binary forms, with or without 117c208ed6SRick Macklem * modification, are permitted provided that the following conditions 127c208ed6SRick Macklem * are met: 137c208ed6SRick Macklem * 1. Redistributions of source code must retain the above copyright 147c208ed6SRick Macklem * notice, this list of conditions and the following disclaimer. 157c208ed6SRick Macklem * 2. Redistributions in binary form must reproduce the above copyright 167c208ed6SRick Macklem * notice, this list of conditions and the following disclaimer in the 177c208ed6SRick Macklem * documentation and/or other materials provided with the distribution. 18fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors 197c208ed6SRick Macklem * may be used to endorse or promote products derived from this software 207c208ed6SRick Macklem * without specific prior written permission. 217c208ed6SRick Macklem * 227c208ed6SRick Macklem * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 237c208ed6SRick Macklem * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 247c208ed6SRick Macklem * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 257c208ed6SRick Macklem * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 267c208ed6SRick Macklem * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 277c208ed6SRick Macklem * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 287c208ed6SRick Macklem * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 297c208ed6SRick Macklem * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 307c208ed6SRick Macklem * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 317c208ed6SRick Macklem * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 327c208ed6SRick Macklem * SUCH DAMAGE. 337c208ed6SRick Macklem */ 347c208ed6SRick Macklem 357c208ed6SRick Macklem #ifndef _NFSCLIENT_NFSDISKLESS_H_ 367c208ed6SRick Macklem #define _NFSCLIENT_NFSDISKLESS_H_ 377c208ed6SRick Macklem 387c208ed6SRick Macklem /* 397c208ed6SRick Macklem * Structure that must be initialized for a diskless nfs client. 407c208ed6SRick Macklem * This structure is used by nfs_mountroot() to set up the root vnode, 417c208ed6SRick Macklem * and to do a partial ifconfig(8) and route(8) so that the critical net 427c208ed6SRick Macklem * interface can communicate with the server. 437c208ed6SRick Macklem * The primary bootstrap is expected to fill in the appropriate fields before 447c208ed6SRick Macklem * starting the kernel. 457c208ed6SRick Macklem * Currently only works for AF_INET protocols. 467c208ed6SRick Macklem * NB: All fields are stored in net byte order to avoid hassles with 477c208ed6SRick Macklem * client/server byte ordering differences. 487c208ed6SRick Macklem */ 497c208ed6SRick Macklem 507c208ed6SRick Macklem /* 517c208ed6SRick Macklem * I have defined a new structure that can handle an NFS Version 3 file handle 527c208ed6SRick Macklem * but the kernel still expects the old Version 2 one to be provided. The 537c208ed6SRick Macklem * changes required in nfs_vfsops.c for using the new are documented there in 547c208ed6SRick Macklem * comments. (I felt that breaking network booting code by changing this 557c208ed6SRick Macklem * structure would not be prudent at this time, since almost all servers are 567c208ed6SRick Macklem * still Version 2 anyhow.) 577c208ed6SRick Macklem */ 587c208ed6SRick Macklem struct nfsv3_diskless { 597c208ed6SRick Macklem struct ifaliasreq myif; /* Default interface */ 607c208ed6SRick Macklem struct sockaddr_in mygateway; /* Default gateway */ 617c208ed6SRick Macklem struct nfs_args root_args; /* Mount args for root fs */ 627c208ed6SRick Macklem int root_fhsize; /* Size of root file handle */ 637c208ed6SRick Macklem u_char root_fh[NFSX_V3FHMAX]; /* File handle of root dir */ 647c208ed6SRick Macklem struct sockaddr_in root_saddr; /* Address of root server */ 657c208ed6SRick Macklem char root_hostnam[MNAMELEN]; /* Host name for mount pt */ 667c208ed6SRick Macklem long root_time; /* Timestamp of root fs */ 677c208ed6SRick Macklem char my_hostnam[MAXHOSTNAMELEN]; /* Client host name */ 687c208ed6SRick Macklem }; 697c208ed6SRick Macklem 707c208ed6SRick Macklem /* 717c208ed6SRick Macklem * Old arguments to mount NFS 727c208ed6SRick Macklem */ 737c208ed6SRick Macklem struct onfs_args { 747c208ed6SRick Macklem struct sockaddr *addr; /* file server address */ 757c208ed6SRick Macklem int addrlen; /* length of address */ 767c208ed6SRick Macklem int sotype; /* Socket type */ 777c208ed6SRick Macklem int proto; /* and Protocol */ 787c208ed6SRick Macklem u_char *fh; /* File handle to be mounted */ 797c208ed6SRick Macklem int fhsize; /* Size, in bytes, of fh */ 807c208ed6SRick Macklem int flags; /* flags */ 817c208ed6SRick Macklem int wsize; /* write size in bytes */ 827c208ed6SRick Macklem int rsize; /* read size in bytes */ 837c208ed6SRick Macklem int readdirsize; /* readdir size in bytes */ 847c208ed6SRick Macklem int timeo; /* initial timeout in .1 secs */ 857c208ed6SRick Macklem int retrans; /* times to retry send */ 867c208ed6SRick Macklem int maxgrouplist; /* Max. size of group list */ 877c208ed6SRick Macklem int readahead; /* # of blocks to readahead */ 887c208ed6SRick Macklem int leaseterm; /* Term (sec) of lease */ 897c208ed6SRick Macklem int deadthresh; /* Retrans threshold */ 907c208ed6SRick Macklem char *hostname; /* server's name */ 917c208ed6SRick Macklem }; 927c208ed6SRick Macklem 937c208ed6SRick Macklem struct nfs_diskless { 947c208ed6SRick Macklem struct ifaliasreq myif; /* Default interface */ 957c208ed6SRick Macklem struct sockaddr_in mygateway; /* Default gateway */ 967c208ed6SRick Macklem struct onfs_args root_args; /* Mount args for root fs */ 977c208ed6SRick Macklem u_char root_fh[NFSX_V2FH]; /* File handle of root dir */ 987c208ed6SRick Macklem struct sockaddr_in root_saddr; /* Address of root server */ 997c208ed6SRick Macklem char root_hostnam[MNAMELEN]; /* Host name for mount pt */ 1007c208ed6SRick Macklem long root_time; /* Timestamp of root fs */ 1017c208ed6SRick Macklem char my_hostnam[MAXHOSTNAMELEN]; /* Client host name */ 1027c208ed6SRick Macklem }; 1037c208ed6SRick Macklem 1047c208ed6SRick Macklem #ifdef _KERNEL 1057c208ed6SRick Macklem extern struct nfsv3_diskless nfsv3_diskless; 1067c208ed6SRick Macklem extern struct nfs_diskless nfs_diskless; 1077c208ed6SRick Macklem extern int nfs_diskless_valid; 1087c208ed6SRick Macklem void bootpc_init(void); 1097c208ed6SRick Macklem void nfs_setup_diskless(void); 1107c208ed6SRick Macklem void nfs_parse_options(const char *, struct nfs_args *); 1117c208ed6SRick Macklem #endif 1127c208ed6SRick Macklem 1137c208ed6SRick Macklem #endif 114