changes from ws to support diskless booting... these are "OK" on inspection

and after testing...  (actually, currently, none of the changed
code is even used...)
This commit is contained in:
cgd 1993-07-07 12:06:32 +00:00
parent b99e3b6666
commit 0b1df311fc
6 changed files with 140 additions and 16 deletions

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)nfs_bio.c 7.19 (Berkeley) 4/16/91
* $Id: nfs_bio.c,v 1.3 1993/06/30 03:35:07 andrew Exp $
* $Id: nfs_bio.c,v 1.4 1993/07/07 12:06:32 cgd Exp $
*/
#include "param.h"
@ -234,7 +234,8 @@ nfs_write(vp, uio, ioflag, cred)
* Maybe this should be above the vnode op call, but so long as
* file servers have no limits, i don't think it matters
*/
if (uio->uio_offset + uio->uio_resid >
if (p &&
uio->uio_offset + uio->uio_resid >
p->p_rlimit[RLIMIT_FSIZE].rlim_cur) {
psignal(p, SIGXFSZ);
return (EFBIG);
@ -259,6 +260,11 @@ nfs_write(vp, uio, ioflag, cred)
bn = lbn*(biosize/DEV_BSIZE);
again:
bp = getblk(vp, bn, biosize);
if (bp->b_flags&B_ERROR) {
error = bp->b_error;
brelse(bp);
return error;
}
if (bp->b_wcred == NOCRED) {
crhold(cred);
bp->b_wcred = cred;

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)nfs_subs.c 7.41 (Berkeley) 5/15/91
* $Id: nfs_subs.c,v 1.3 1993/05/21 07:38:05 cgd Exp $
* $Id: nfs_subs.c,v 1.4 1993/07/07 12:06:34 cgd Exp $
*/
/*
@ -120,15 +120,19 @@ struct mbuf *nfsm_reqh(prog, vers, procid, cred, hsiz, bpos, mb, retxid)
struct mbuf *m1;
char *ap;
int asiz, siz;
static char authnull[4*NFSX_UNSIGNED];
NFSMGETHDR(mreq);
asiz = ((((cred->cr_ngroups - 1) > numgrps) ? numgrps :
(cred->cr_ngroups - 1)) << 2);
if (cred) {
asiz = ((((cred->cr_ngroups - 1) > numgrps) ? numgrps :
(cred->cr_ngroups - 1)) << 2);
#ifdef FILLINHOST
asiz += nfsm_rndup(hostnamelen)+(9*NFSX_UNSIGNED);
asiz += nfsm_rndup(hostnamelen)+(9*NFSX_UNSIGNED);
#else
asiz += 9*NFSX_UNSIGNED;
asiz += 9*NFSX_UNSIGNED;
#endif
} else
asiz = 4 * NFSX_UNSIGNED;
/* If we need a lot, alloc a cluster ?? */
if ((asiz+hsiz+RPC_SIZ) > MHLEN)
@ -156,7 +160,10 @@ struct mbuf *nfsm_reqh(prog, vers, procid, cred, hsiz, bpos, mb, retxid)
*tl++ = procid;
/* Now we can call nfs_unixauth() and copy it in */
ap = nfs_unixauth(cred);
if (cred)
ap = nfs_unixauth(cred);
else
ap = authnull;
m = mreq;
siz = m->m_len-RPC_SIZ;
if (asiz <= siz) {

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)nfs_vfsops.c 7.31 (Berkeley) 5/6/91
* $Id: nfs_vfsops.c,v 1.2 1993/05/20 03:18:53 cgd Exp $
* $Id: nfs_vfsops.c,v 1.3 1993/07/07 12:06:36 cgd Exp $
*/
#include "param.h"
@ -183,7 +183,7 @@ nfs_mountroot()
bcopy((caddr_t)&nfs_diskless.mygateway, (caddr_t)&rt.rt_gateway,
sizeof (struct sockaddr_in));
rt.rt_flags = (RTF_UP | RTF_GATEWAY);
if (rtioctl(SIOCADDRT, (caddr_t)&rt))
if (rtioctl(SIOCADDRT, (caddr_t)&rt, curproc))
panic("nfs root route");
}
#endif /* COMPAT_43 */
@ -224,6 +224,14 @@ nfs_mountroot()
swapdev_vp = vp;
VREF(vp);
swdevt[0].sw_vp = vp;
{
struct vattr attr;
if (nfs_dogetattr(vp,&attr,0,0,0)) {
panic("nfs swap");
}
swdevt[0].sw_nblks = attr.va_size / DEV_BSIZE;
}
}
/*

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)nfs_vnops.c 7.60 (Berkeley) 5/24/91
* $Id: nfs_vnops.c,v 1.6 1993/06/03 01:12:44 cgd Exp $
* $Id: nfs_vnops.c,v 1.7 1993/07/07 12:06:37 cgd Exp $
*/
/*
@ -337,7 +337,8 @@ nfs_dogetattr(vp, vap, cred, tryhard, p)
struct mbuf *mreq, *mrep, *md, *mb, *mb2;
/* First look in the cache.. */
if (nfs_getattrcache(vp, vap) == 0)
/* cred == 0 when we are called by mountroot */
if (cred != 0 && nfs_getattrcache(vp, vap) == 0)
return (0);
nfsstats.rpccnt[NFSPROC_GETATTR]++;
nfsm_reqhead(nfs_procids[NFSPROC_GETATTR], cred, NFSX_FH);
@ -1484,7 +1485,7 @@ nfs_bmap(vp, bn, vpp, bnp)
if (vpp != NULL)
*vpp = vp;
if (bnp != NULL)
*bnp = bn * btodb(vp->v_mount->mnt_stat.f_bsize);
*bnp = bn * btodb(VFSTONFS(vp->v_mount)->nm_rsize);
return (0);
}

View File

@ -34,12 +34,13 @@
* SUCH DAMAGE.
*
* from: @(#)nfsdiskless.h 7.1 (Berkeley) 3/4/91
* $Id: nfsdiskless.h,v 1.3 1993/05/20 03:19:03 cgd Exp $
* $Id: nfsdiskless.h,v 1.4 1993/07/07 12:06:39 cgd Exp $
*/
#ifndef _NFS_NFSDISKLESS_H_
#define _NFS_NFSDISKLESS_H_
#define NFS_NAMELEN 256
/*
* Structure that must be initialized for a diskless nfs client.
* This structure is used by nfs_mountroot() to set up the root and swap
@ -54,11 +55,11 @@ struct nfs_diskless {
struct nfs_args swap_args; /* Mount args for swap file */
u_char swap_fh[NFS_FHSIZE]; /* Swap file's file handle */
struct sockaddr swap_saddr; /* Address of swap server */
char *swap_hostnam; /* Host name for mount pt */
char swap_hostnam[NFS_NAMELEN]; /* Host name for mount pt */
struct nfs_args root_args; /* Mount args for root fs */
u_char root_fh[NFS_FHSIZE]; /* File handle of root dir */
struct sockaddr root_saddr; /* Address of root server */
char *root_hostnam; /* Host name for mount pt */
char root_hostnam[NFS_NAMELEN]; /* Host name for mount pt */
};
#endif /* !_NFS_NFSDISKLESS_H_ */

101
sys/nfs/swapnfs.c Normal file
View File

@ -0,0 +1,101 @@
/*
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Rick Macklem at The University of Guelph.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)nfsswapvmunix.c 7.1 (Berkeley) 3/4/91
* $Id: swapnfs.c,v 1.1 1993/07/07 12:06:40 cgd Exp $
*/
/*
* Sample NFS swapvmunix configuration file.
* This should be filled in by the bootstrap program.
* See /sys/nfs/nfsdiskless.h for details of the fields.
*/
#include "../sys/param.h"
#include "../sys/conf.h"
#include "../sys/socket.h"
#include "../sys/mount.h"
#include "../net/if.h"
#include "../nfs/nfsv2.h"
#include "../nfs/nfsdiskless.h"
dev_t rootdev = NODEV;
dev_t argdev = NODEV;
dev_t dumpdev = NODEV;
struct swdevt swdevt[] = {
{ NODEV, 0, 0 },
{ 0, 0, 0 }
};
extern int nfs_mountroot();
int (*mountroot)() = nfs_mountroot;
/* We start with transfer sizes of 4K during boot */
/* as the WD8003 has problems to support 8K of back to back packets */
struct nfs_diskless nfs_diskless = {
{ 0 }, /* myif */
{ 0 }, /* mygateway */
{ /* swap_args */
0, /* addr */
0, /* sotype */
0, /* proto */
0, /* fh */
NFSMNT_WSIZE|NFSMNT_RSIZE, /* flags */
4096, /* wsize */
4096, /* rsize */
0, /* timeo */
0, /* retrans */
0 /* hostname */
},
{ 0 }, /* swap_fh */
{ 0 }, /* swap_saddr */
{ 0 }, /* swap_hostnam */
{ /* root_args */
0, /* addr */
0, /* sotype */
0, /* proto */
0, /* fh */
NFSMNT_WSIZE|NFSMNT_RSIZE, /* flags */
4096, /* wsize */
4096, /* rsize */
0, /* timeo */
0, /* retrans */
0 /* hostname */
},
{ 0 }, /* root_fh */
{ 0 }, /* root_saddr */
{ 0 } /* root_hostnam */
};