Deleted Added
full compact
nfs_vfsops.c (25459) nfs_vfsops.c (25723)
1/*
2 * Copyright (c) 1989, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)nfs_vfsops.c 8.12 (Berkeley) 5/20/95
1/*
2 * Copyright (c) 1989, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)nfs_vfsops.c 8.12 (Berkeley) 5/20/95
37 * $Id: nfs_vfsops.c,v 1.39 1997/05/03 13:42:50 phk Exp $
37 * $Id: nfs_vfsops.c,v 1.40 1997/05/04 15:04:49 phk Exp $
38 */
39
40#include <sys/param.h>
41#include <sys/conf.h>
42#include <sys/sockio.h>
43#include <sys/signal.h>
44#include <sys/proc.h>
45#include <sys/namei.h>

--- 80 unchanged lines hidden (view full) ---

126VFS_SET(nfs_vfsops, nfs, MOUNT_NFS, VFCF_NETWORK);
127
128/*
129 * This structure must be filled in by a primary bootstrap or bootstrap
130 * server for a diskless/dataless machine. It is initialized below just
131 * to ensure that it is allocated to initialized data (.data not .bss).
132 */
133struct nfs_diskless nfs_diskless = { 0 };
38 */
39
40#include <sys/param.h>
41#include <sys/conf.h>
42#include <sys/sockio.h>
43#include <sys/signal.h>
44#include <sys/proc.h>
45#include <sys/namei.h>

--- 80 unchanged lines hidden (view full) ---

126VFS_SET(nfs_vfsops, nfs, MOUNT_NFS, VFCF_NETWORK);
127
128/*
129 * This structure must be filled in by a primary bootstrap or bootstrap
130 * server for a diskless/dataless machine. It is initialized below just
131 * to ensure that it is allocated to initialized data (.data not .bss).
132 */
133struct nfs_diskless nfs_diskless = { 0 };
134struct nfsv3_diskless nfsv3_diskless = { 0 };
134int nfs_diskless_valid = 0;
135
136SYSCTL_INT(_vfs_nfs, OID_AUTO, diskless_valid, CTLFLAG_RD,
137 &nfs_diskless_valid, 0, "");
138
139SYSCTL_STRING(_vfs_nfs, OID_AUTO, diskless_rootpath, CTLFLAG_RD,
135int nfs_diskless_valid = 0;
136
137SYSCTL_INT(_vfs_nfs, OID_AUTO, diskless_valid, CTLFLAG_RD,
138 &nfs_diskless_valid, 0, "");
139
140SYSCTL_STRING(_vfs_nfs, OID_AUTO, diskless_rootpath, CTLFLAG_RD,
140 nfs_diskless.root_hostnam, 0, "");
141 nfsv3_diskless.root_hostnam, 0, "");
141
142SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD,
142
143SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD,
143 &nfs_diskless.root_saddr, sizeof nfs_diskless.root_saddr,
144 &nfsv3_diskless.root_saddr, sizeof nfsv3_diskless.root_saddr,
144 "%Ssockaddr_in", "");
145
146SYSCTL_STRING(_vfs_nfs, OID_AUTO, diskless_swappath, CTLFLAG_RD,
145 "%Ssockaddr_in", "");
146
147SYSCTL_STRING(_vfs_nfs, OID_AUTO, diskless_swappath, CTLFLAG_RD,
147 nfs_diskless.swap_hostnam, 0, "");
148 nfsv3_diskless.swap_hostnam, 0, "");
148
149SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_swapaddr, CTLFLAG_RD,
149
150SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_swapaddr, CTLFLAG_RD,
150 &nfs_diskless.swap_saddr, sizeof nfs_diskless.swap_saddr,
151 &nfsv3_diskless.swap_saddr, sizeof nfsv3_diskless.swap_saddr,
151 "%Ssockaddr_in","");
152
153
154void nfsargs_ntoh __P((struct nfs_args *));
155static int nfs_mountdiskless __P((char *, char *, int,
156 struct sockaddr_in *, struct nfs_args *,
157 struct proc *, struct vnode **,
158 struct mount **));
152 "%Ssockaddr_in","");
153
154
155void nfsargs_ntoh __P((struct nfs_args *));
156static int nfs_mountdiskless __P((char *, char *, int,
157 struct sockaddr_in *, struct nfs_args *,
158 struct proc *, struct vnode **,
159 struct mount **));
160void nfs_convert_diskless __P((void));
159
160static int nfs_iosize(nmp)
161 struct nfsmount* nmp;
162{
163 int iosize;
164
165 /*
166 * Calculate the size used for io buffers. Use the larger
167 * of the two sizes to minimise nfs requests but make sure
168 * that it is at least one VM page to avoid wasting buffer
169 * space.
170 */
171 iosize = max(nmp->nm_rsize, nmp->nm_wsize);
172 if (iosize < PAGE_SIZE) iosize = PAGE_SIZE;
173 return iosize;
174}
175
161
162static int nfs_iosize(nmp)
163 struct nfsmount* nmp;
164{
165 int iosize;
166
167 /*
168 * Calculate the size used for io buffers. Use the larger
169 * of the two sizes to minimise nfs requests but make sure
170 * that it is at least one VM page to avoid wasting buffer
171 * space.
172 */
173 iosize = max(nmp->nm_rsize, nmp->nm_wsize);
174 if (iosize < PAGE_SIZE) iosize = PAGE_SIZE;
175 return iosize;
176}
177
178void nfs_convert_diskless()
179{
180 bcopy(&nfs_diskless.myif, &nfsv3_diskless.myif,
181 sizeof(struct ifaliasreq));
182 bcopy(&nfs_diskless.swap_args,&nfsv3_diskless.swap_args,
183 sizeof(struct nfs_args));
184 nfsv3_diskless.swap_fhsize = NFSX_V2FH;
185 bcopy(nfs_diskless.swap_fh,nfsv3_diskless.swap_fh,NFSX_V2FH);
186 bcopy(&nfs_diskless.swap_saddr,&nfsv3_diskless.swap_saddr,
187 sizeof(struct sockaddr_in));
188 bcopy(nfs_diskless.swap_hostnam,nfsv3_diskless.swap_hostnam,
189 MNAMELEN);
190 nfsv3_diskless.swap_nblks = nfs_diskless.swap_nblks;
191 bcopy(&nfs_diskless.swap_ucred, &nfsv3_diskless.swap_ucred,
192 sizeof(struct ucred));
193 bcopy(&nfs_diskless.root_args,&nfsv3_diskless.root_args,
194 sizeof(struct nfs_args));
195 nfsv3_diskless.root_fhsize = NFSX_V2FH;
196 bcopy(nfs_diskless.root_fh,nfsv3_diskless.root_fh,NFSX_V2FH);
197 bcopy(&nfs_diskless.root_saddr,&nfsv3_diskless.root_saddr,
198 sizeof(struct sockaddr_in));
199 bcopy(nfs_diskless.root_hostnam,nfsv3_diskless.root_hostnam,
200 MNAMELEN);
201 nfsv3_diskless.root_time = nfs_diskless.root_time;
202 bcopy(nfs_diskless.my_hostnam,nfsv3_diskless.my_hostnam,
203 MAXHOSTNAMELEN);
204 nfs_diskless_valid = 3;
205}
206
176/*
177 * nfs statfs call
178 */
179int
180nfs_statfs(mp, sbp, p)
181 struct mount *mp;
182 register struct statfs *sbp;
183 struct proc *p;

--- 141 unchanged lines hidden (view full) ---

325 * if swdevt[0].sw_dev == NODEV
326 * - build the rootfs mount point and call mountnfs() to do the rest.
327 */
328int
329nfs_mountroot(mp)
330 struct mount *mp;
331{
332 struct mount *swap_mp;
207/*
208 * nfs statfs call
209 */
210int
211nfs_statfs(mp, sbp, p)
212 struct mount *mp;
213 register struct statfs *sbp;
214 struct proc *p;

--- 141 unchanged lines hidden (view full) ---

356 * if swdevt[0].sw_dev == NODEV
357 * - build the rootfs mount point and call mountnfs() to do the rest.
358 */
359int
360nfs_mountroot(mp)
361 struct mount *mp;
362{
363 struct mount *swap_mp;
333 struct nfs_diskless *nd = &nfs_diskless;
364 struct nfsv3_diskless *nd = &nfsv3_diskless;
334 struct socket *so;
335 struct vnode *vp;
336 struct proc *p = curproc; /* XXX */
337 int error, i;
338 u_long l;
339 char buf[128];
340
341 /*
342 * XXX time must be non-zero when we init the interface or else
343 * the arp code will wedge...
344 */
345 if (time.tv_sec == 0)
346 time.tv_sec = 1;
347
365 struct socket *so;
366 struct vnode *vp;
367 struct proc *p = curproc; /* XXX */
368 int error, i;
369 u_long l;
370 char buf[128];
371
372 /*
373 * XXX time must be non-zero when we init the interface or else
374 * the arp code will wedge...
375 */
376 if (time.tv_sec == 0)
377 time.tv_sec = 1;
378
379 if (nfs_diskless_valid==1)
380 nfs_convert_diskless();
381
348 /*
349 * XXX splnet, so networks will receive...
350 */
351 splnet();
352
353#ifdef notyet
354 /* Set up swap credentials. */
355 proc0.p_ucred->cr_uid = ntohl(nd->swap_ucred.cr_uid);

--- 49 unchanged lines hidden (view full) ---

405 if (error)
406 panic("nfs_mountroot: RTM_ADD: %d", error);
407 }
408
409 /*
410 * Create the rootfs mount point.
411 */
412 nd->root_args.fh = nd->root_fh;
382 /*
383 * XXX splnet, so networks will receive...
384 */
385 splnet();
386
387#ifdef notyet
388 /* Set up swap credentials. */
389 proc0.p_ucred->cr_uid = ntohl(nd->swap_ucred.cr_uid);

--- 49 unchanged lines hidden (view full) ---

439 if (error)
440 panic("nfs_mountroot: RTM_ADD: %d", error);
441 }
442
443 /*
444 * Create the rootfs mount point.
445 */
446 nd->root_args.fh = nd->root_fh;
413 /*
414 * If using nfsv3_diskless, replace NFSX_V2FH with nd->root_fhsize.
415 */
416 nd->root_args.fhsize = NFSX_V2FH;
447 nd->root_args.fhsize = nd->root_fhsize;
417 l = ntohl(nd->root_saddr.sin_addr.s_addr);
418 sprintf(buf,"%ld.%ld.%ld.%ld:%s",
419 (l >> 24) & 0xff, (l >> 16) & 0xff,
420 (l >> 8) & 0xff, (l >> 0) & 0xff,nd->root_hostnam);
421 printf("NFS ROOT: %s\n",buf);
422 if (error = nfs_mountdiskless(buf, "/", MNT_RDONLY,
423 &nd->root_saddr, &nd->root_args, p, &vp, &mp)) {
424 if (swap_mp) {

--- 9 unchanged lines hidden (view full) ---

434 /* Convert to DEV_BSIZE instead of Kilobyte */
435 nd->swap_nblks *= 2;
436
437 /*
438 * Create a fake mount point just for the swap vnode so that the
439 * swap file can be on a different server from the rootfs.
440 */
441 nd->swap_args.fh = nd->swap_fh;
448 l = ntohl(nd->root_saddr.sin_addr.s_addr);
449 sprintf(buf,"%ld.%ld.%ld.%ld:%s",
450 (l >> 24) & 0xff, (l >> 16) & 0xff,
451 (l >> 8) & 0xff, (l >> 0) & 0xff,nd->root_hostnam);
452 printf("NFS ROOT: %s\n",buf);
453 if (error = nfs_mountdiskless(buf, "/", MNT_RDONLY,
454 &nd->root_saddr, &nd->root_args, p, &vp, &mp)) {
455 if (swap_mp) {

--- 9 unchanged lines hidden (view full) ---

465 /* Convert to DEV_BSIZE instead of Kilobyte */
466 nd->swap_nblks *= 2;
467
468 /*
469 * Create a fake mount point just for the swap vnode so that the
470 * swap file can be on a different server from the rootfs.
471 */
472 nd->swap_args.fh = nd->swap_fh;
442 /*
443 * If using nfsv3_diskless, replace NFSX_V2FH with
444 * nd->swap_fhsize.
445 */
446 nd->swap_args.fhsize = NFSX_V2FH;
473 nd->swap_args.fhsize = nd->swap_fhsize;
447 l = ntohl(nd->swap_saddr.sin_addr.s_addr);
448 sprintf(buf,"%ld.%ld.%ld.%ld:%s",
449 (l >> 24) & 0xff, (l >> 16) & 0xff,
450 (l >> 8) & 0xff, (l >> 0) & 0xff,nd->swap_hostnam);
451 printf("NFS SWAP: %s\n",buf);
452 if (error = nfs_mountdiskless(buf, "/swap", 0,
453 &nd->swap_saddr, &nd->swap_args, p, &vp, &swap_mp))
454 return (error);

--- 574 unchanged lines hidden ---
474 l = ntohl(nd->swap_saddr.sin_addr.s_addr);
475 sprintf(buf,"%ld.%ld.%ld.%ld:%s",
476 (l >> 24) & 0xff, (l >> 16) & 0xff,
477 (l >> 8) & 0xff, (l >> 0) & 0xff,nd->swap_hostnam);
478 printf("NFS SWAP: %s\n",buf);
479 if (error = nfs_mountdiskless(buf, "/swap", 0,
480 &nd->swap_saddr, &nd->swap_args, p, &vp, &swap_mp))
481 return (error);

--- 574 unchanged lines hidden ---