2 * Creation Date: <2003/11/26 16:55:47 samuel>
3 * Time-stamp: <2004/01/07 19:41:54 samuel>
7 * pseudodisk (contains files exported from linux)
9 * Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se)
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
18 #include "libopenbios/bindings.h"
19 #include "osi_calls.h"
20 #include "libc/string.h"
21 #include "libopenbios/ofmem.h"
24 #include "osi_calls.h"
25 #include "pseudofs_sh.h"
36 DECLARE_NODE( pdisk, INSTALL_OPEN, sizeof(pdisk_data_t), "/mol/pseudo-disk/disk" );
39 pdisk_open( pdisk_data_t *pb )
41 char *ep, *name = NULL;
44 pb->myargs = my_args_copy();
45 /* printk("pdisk-open: %s\n", pb->myargs ); */
47 part = strtol( pb->myargs, &ep, 10 );
49 if( (name=strchr(pb->myargs, ',')) ) {
59 if( !name || !strlen(name) )
62 if( (pb->fd=PseudoFSOpen(name)) < 0 )
64 pb->size = PseudoFSGetSize( pb->fd );
73 /* ( addr len -- actual ) */
75 pdisk_read( pdisk_data_t *pb )
78 char *dest = (char*)POP();
82 memset( dest, 0, len );
86 /* dest is not "mol-DMA" safe (might have a nontrivial mapping) */
87 for( cnt=0; cnt<len; ) {
89 int n = MIN( len-cnt, sizeof(buf) );
91 n = PseudoFSRead( pb->fd, pb->seekpos, buf, n );
95 memcpy( dest+cnt, buf, n );
102 /* ( addr len -- actual ) */
104 pdisk_write( pdisk_data_t *pb )
106 POP(); POP(); PUSH(-1);
107 printk("pdisk write\n");
110 /* ( pos.lo pos.hi -- status ) */
112 pdisk_seek( pdisk_data_t *pb )
123 pb->seekpos = pos_lo;
130 pdisk_tell( pdisk_data_t *pb )
132 DPUSH( pb->seekpos );
137 pdisk_get_path( pdisk_data_t *pb )
139 PUSH( (int)pb->name );
144 pdisk_get_fstype( pdisk_data_t *pb )
146 PUSH( (int)"PSEUDO" );
151 pdisk_volume_name( pdisk_data_t *pb )
153 PUSH( (int)"Virtual Volume" );
157 pdisk_block_size( pdisk_data_t *pb )
162 NODE_METHODS( pdisk ) = {
163 { "open", pdisk_open },
164 { "read", pdisk_read },
165 { "write", pdisk_write },
166 { "seek", pdisk_seek },
167 { "tell", pdisk_tell },
168 { "block-size", pdisk_block_size },
169 { "get-path", pdisk_get_path },
170 { "get-fstype", pdisk_get_fstype },
171 { "volume-name", pdisk_volume_name },
175 pseudodisk_init( void )
177 REGISTER_NODE( pdisk );