nfsops.c (7c478bd9) nfsops.c (986fd29a)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 *
26 * Simple nfs ops - open, close, read, and lseek.
27 */
28
29#pragma ident "%Z%%M% %I% %E% SMI"
30
31#include <rpc/types.h>

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

99{
100 struct nfs_files *filep;
101
102#ifdef NFS_OPS_DEBUG
103 if ((boothowto & DBFLAGS) == DBFLAGS)
104 printf("boot_nfs_closeall(%x)\n", flag);
105#endif
106
23 * Use is subject to license terms.
24 *
25 * Simple nfs ops - open, close, read, and lseek.
26 */
27
28#pragma ident "%Z%%M% %I% %E% SMI"
29
30#include <rpc/types.h>

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

98{
99 struct nfs_files *filep;
100
101#ifdef NFS_OPS_DEBUG
102 if ((boothowto & DBFLAGS) == DBFLAGS)
103 printf("boot_nfs_closeall(%x)\n", flag);
104#endif
105
106 if (nfs_files->file.version == 0 &&
107 nfs_files->desc == 0 &&
108 nfs_files->next == NULL)
109 return;
110
107 /* delete any dynamically allocated entries */
108 while ((filep = nfs_files->next) != NULL) {
109 nfs_files->next = filep->next;
110 bkmem_free((caddr_t)filep, sizeof (struct nfs_files));
111 }
112
113 /* clear the first, static file */
114 bzero((caddr_t)nfs_files, sizeof (struct nfs_files));

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

206 filep->desc = 0;
207 return (-1);
208 }
209 bzero(&filep->file.cookie, sizeof (filep->file.cookie));
210
211#ifdef NFS_OPS_DEBUG
212 if ((boothowto & DBFLAGS) == DBFLAGS)
213 printf("boot_nfs_open(): '%s' successful, fd = 0x%x\n",
111 /* delete any dynamically allocated entries */
112 while ((filep = nfs_files->next) != NULL) {
113 nfs_files->next = filep->next;
114 bkmem_free((caddr_t)filep, sizeof (struct nfs_files));
115 }
116
117 /* clear the first, static file */
118 bzero((caddr_t)nfs_files, sizeof (struct nfs_files));

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

210 filep->desc = 0;
211 return (-1);
212 }
213 bzero(&filep->file.cookie, sizeof (filep->file.cookie));
214
215#ifdef NFS_OPS_DEBUG
216 if ((boothowto & DBFLAGS) == DBFLAGS)
217 printf("boot_nfs_open(): '%s' successful, fd = 0x%x\n",
214 path, filep->desc);
218 path, filep->desc);
215#endif
216 return (filep->desc);
217}
218
219/*
220 * close a previously opened file.
221 */
222static int

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

278 case NFS_V3:
279 count = nfs3read(&filep->file, buf, size);
280 break;
281 case NFS_V4:
282 count = nfs4read(&filep->file, buf, size);
283 break;
284 default:
285 printf("boot_nfs_read: NFS Version %d not supported\n",
219#endif
220 return (filep->desc);
221}
222
223/*
224 * close a previously opened file.
225 */
226static int

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

282 case NFS_V3:
283 count = nfs3read(&filep->file, buf, size);
284 break;
285 case NFS_V4:
286 count = nfs4read(&filep->file, buf, size);
287 break;
288 default:
289 printf("boot_nfs_read: NFS Version %d not supported\n",
286 filep->file.version);
290 filep->file.version);
287 count = -1;
288 break;
289 }
290
291#ifdef NFS_OPS_DEBUG
292 if ((boothowto & DBFLAGS) == DBFLAGS)
293 printf("boot_nfs_read(): 0x%x bytes.\n", count);
294#endif

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

377 dprintf("boot_nfs_fstat(): Bad file number 0.\n");
378 return (-1);
379 }
380
381 if ((filep = get_filep(fd)) == 0)
382 return (-1);
383
384 bzero((char *)&va, sizeof (va));
291 count = -1;
292 break;
293 }
294
295#ifdef NFS_OPS_DEBUG
296 if ((boothowto & DBFLAGS) == DBFLAGS)
297 printf("boot_nfs_read(): 0x%x bytes.\n", count);
298#endif

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

381 dprintf("boot_nfs_fstat(): Bad file number 0.\n");
382 return (-1);
383 }
384
385 if ((filep = get_filep(fd)) == 0)
386 return (-1);
387
388 bzero((char *)&va, sizeof (va));
385 va.va_mask = AT_TYPE | AT_SIZE | AT_MODE | AT_NODEID | \
386 AT_ATIME | AT_CTIME | AT_MTIME;
389 va.va_mask = AT_TYPE | AT_SIZE | AT_MODE | AT_NODEID |
390 AT_ATIME | AT_CTIME | AT_MTIME;
387
388 switch (filep->file.version) {
389 case NFS_VERSION:
390 status = nfsgetattr(&filep->file, &va);
391 break;
392 case NFS_V3:
393 status = nfs3getattr(&filep->file, &va);
394 break;
395 case NFS_V4:
396 status = nfs4getattr(&filep->file, &va);
397 break;
398 default:
399 printf("boot_nfs_fstat: NFS Version %d not supported\n",
391
392 switch (filep->file.version) {
393 case NFS_VERSION:
394 status = nfsgetattr(&filep->file, &va);
395 break;
396 case NFS_V3:
397 status = nfs3getattr(&filep->file, &va);
398 break;
399 case NFS_V4:
400 status = nfs4getattr(&filep->file, &va);
401 break;
402 default:
403 printf("boot_nfs_fstat: NFS Version %d not supported\n",
400 filep->file.version);
404 filep->file.version);
401 status = -1;
402 break;
403 }
404
405 if (status != 0)
406 return (-1);
407
408 if (va.va_size > (u_offset_t)MAXOFF_T) {

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

450 case NFS_VERSION:
451 status = nfsgetdents(&filep->file, dep, size);
452 break;
453 case NFS_V3:
454 status = nfs3getdents(&filep->file, dep, size);
455 break;
456 default:
457 printf("boot_nfs_getdents: NFS Version %d not supported\n",
405 status = -1;
406 break;
407 }
408
409 if (status != 0)
410 return (-1);
411
412 if (va.va_size > (u_offset_t)MAXOFF_T) {

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

454 case NFS_VERSION:
455 status = nfsgetdents(&filep->file, dep, size);
456 break;
457 case NFS_V3:
458 status = nfs3getdents(&filep->file, dep, size);
459 break;
460 default:
461 printf("boot_nfs_getdents: NFS Version %d not supported\n",
458 filep->file.version);
462 filep->file.version);
459 status = -1;
460 }
461
462#ifdef NFS_OPS_DEBUG
463 if ((boothowto & DBFLAGS) == DBFLAGS)
464 printf("boot_nfs_getdents(): done.\n");
465#endif
466 return (status);
467}
463 status = -1;
464 }
465
466#ifdef NFS_OPS_DEBUG
467 if ((boothowto & DBFLAGS) == DBFLAGS)
468 printf("boot_nfs_getdents(): done.\n");
469#endif
470 return (status);
471}