/*
* Copyright (c) 1995 Gordon W. Ross
* All rights reserved.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* Raw file system - for stream devices like tapes.
* No random access, only sequential read allowed.
* This exists only to allow upper level code to be
* shielded from the fact that the device must be
* read only with whole block position and size.
*/
/* Our devices are generally willing to do 8K transfers. */
#define RAWFS_BSIZE 0x2000
/*
* In-core open file.
*/
struct rawfs_file {
daddr_t fs_nextblk; /* block number to read next */
int fs_len; /* amount left in f_buf */
char * fs_ptr; /* read pointer into f_buf */
char fs_buf[RAWFS_BSIZE];
};
/*
* The actual tape driver has already been opened.
* Just allocate the I/O buffer, etc.
*/
fs = alloc(sizeof(struct rawfs_file));
fs->fs_nextblk = 0;
fs->fs_len = 0;
fs->fs_ptr = fs->fs_buf;
#ifdef DEBUG_RAWFS
printf("rawfs_write: YOU'RE NOT SUPPOSED TO GET HERE!\n");
#endif
return EROFS;
}
off_t
rawfs_seek(struct open_file *f, off_t offset, int where)
{
#ifdef DEBUG_RAWFS
printf("rawfs_seek: YOU'RE NOT SUPPOSED TO GET HERE!\n");
#endif
return EFTYPE;
}
int
rawfs_stat(struct open_file *f, struct stat *sb)
{
#ifdef DEBUG_RAWFS
printf("rawfs_stat: I'll let you live only because of exec.c\n");
#endif
/*
* Clear out the stat buffer so that the uid check
* won't fail. See sys/lib/libsa/exec.c
*/
memset(sb, 0, sizeof(*sb));
return EFTYPE;
}
/*
* Read a block from the underlying stream device
* (In our case, a tape drive.)
*/
static int
rawfs_get_block(struct open_file *f)
{
struct rawfs_file *fs;
int error;
size_t len;