/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Simple nfs ops - open, close, read, and lseek.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "clnt.h"
#include <errno.h>
#include "nfs_inet.h"
#include <sys/bootdebug.h>
#include "brpc.h"
#include <rpcsvc/nfs_prot.h>
#include "socket_inet.h"
#include "mac.h"
};
static struct nfs_files {
int desc;
{0, 0, 0},
};
static int boot_nfs_close(int fd);
static void boot_nfs_closeall(int flag);
"nfs",
};
/*
* bootops.c calls a closeall() function to close all open files. Since
* we only permit one open file at a time (not counting the device), this
* is simple to implement.
*/
/*ARGSUSED*/
static void
{
#ifdef NFS_OPS_DEBUG
#endif
return;
/* delete any dynamically allocated entries */
}
/* clear the first, static file */
/* Close device */
mac_fini();
}
/*
* Get a file pointer given a file descriptor. Return 0 on error
*/
static struct nfs_files *
{
return (filep);
}
return (NULL);
}
/*
* Unmount the root fs -- not supported for this fstype.
*/
int
boot_nfs_unmountroot(void)
{
return (-1);
}
/*
* open a file for reading. Note: writing is NOT supported.
*/
static int
{
int got_filep;
#ifdef NFS_OPS_DEBUG
#endif
/* file can only be opened readonly. */
dprintf("boot_nfs_open: files can only be opened O_RDONLY.\n");
return (-1);
}
dprintf("boot_nfs_open: NULL or EMPTY pathname argument.\n");
return (-1);
}
/* Try and find a vacant file pointer */
do {
break; /* We've got a file pointer */
}
/* Get next entry if not at end of list */
/* If a a vacant file pointer cannot be found, make one */
if (!got_filep) {
bkmem_zalloc(sizeof (struct nfs_files))) == 0) {
dprintf("open: Cannot allocate file pointer\n");
return (-1);
}
}
#ifdef NFS_OPS_DEBUG
#endif
/* zero file pointer */
return (-1);
}
#ifdef NFS_OPS_DEBUG
printf("boot_nfs_open(): '%s' successful, fd = 0x%x\n",
#endif
}
/*
* close a previously opened file.
*/
static int
{
#ifdef NFS_OPS_DEBUG
#endif
return (0);
/*
* zero file pointer
*/
/*
* "close" the fd.
*/
return (0);
}
/*
* read from a file.
*/
static ssize_t
{
int count = 0;
if (fd == 0) {
dprintf("boot_nfs_read: Bad file number.\n");
return (-1);
}
dprintf("boot_nfs_read: Bad address.\n");
return (-1);
}
#ifdef NFS_OPS_DEBUG
#endif
/* initialize for read */
return (-1);
case NFS_VERSION:
break;
case NFS_V3:
break;
case NFS_V4:
break;
default:
printf("boot_nfs_read: NFS Version %d not supported\n",
count = -1;
break;
}
#ifdef NFS_OPS_DEBUG
#endif
return (count);
}
/*
* lseek - move read file pointer.
*/
static off_t
{
#ifdef NFS_OPS_DEBUG
#endif
if (fd == 0) {
dprintf("boot_nfs_lseek: Bad file number.\n");
return (-1);
}
return (-1);
switch (whence) {
case SEEK_SET:
/*
* file ptr is set to offset from beginning of file
*/
break;
case SEEK_CUR:
/*
* file ptr is set to offset from current position
*/
break;
case SEEK_END:
/*
* file ptr is set to current size of file plus offset.
* But since we only support reading, this is illegal.
*/
default:
/*
* invalid offset origin
*/
dprintf("boot_nfs_lseek: invalid whence value.\n");
return (-1);
}
#ifdef notyet
#else
/*
* BROKE - lseek should return the offset seeked to on a
* successful seek, not zero - This must be fixed in the
* kernel before It can be fixed here.
*/
return (0);
#endif /* notyet */
}
/*
* This version of fstat supports mode, size, inode #, and times only.
* It can be enhanced if more is required,
*/
static int
{
int status;
#ifdef NFS_OPS_DEBUG
}
#endif
if (fd == 0) {
dprintf("boot_nfs_fstat(): Bad file number 0.\n");
return (-1);
}
return (-1);
case NFS_VERSION:
break;
case NFS_V3:
break;
case NFS_V4:
break;
default:
printf("boot_nfs_fstat: NFS Version %d not supported\n",
status = -1;
break;
}
if (status != 0)
return (-1);
dprintf("boot_nfs_fstat(): File too large.\n");
return (-1);
}
#ifdef NFS_OPS_DEBUG
printf("boot_nfs_fstat(): done.\n");
#endif
return (0);
}
static int
{
int status;
#ifdef NFS_OPS_DEBUG
}
#endif
if (fd == 0) {
dprintf("boot_nfs_getdents(): Bad file number 0.\n");
return (-1);
}
return (-1);
case NFS_VERSION:
break;
case NFS_V3:
break;
default:
printf("boot_nfs_getdents: NFS Version %d not supported\n",
status = -1;
}
#ifdef NFS_OPS_DEBUG
printf("boot_nfs_getdents(): done.\n");
#endif
return (status);
}