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