4 * Open Hack'Ware BIOS raw file system management
6 * Copyright (c) 2004-2005 Jocelyn Mayer
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License V2
10 * as published by the Free Software Foundation
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "../libpart/libpart.h"
28 /* Raw filesystem (ie no filesystem) */
29 static inode_t
*fs_raw_get_inode (inode_t
*parent
, const unsigned char *name
)
39 flags
= INODE_TYPE_DIR
;
41 new = malloc(sizeof(inode_t
));
42 memset(new, 0, sizeof(inode_t
));
44 new->name
= strdup(name
);
49 static void fs_raw_put_inode (inode_t
*inode
)
54 static uint32_t fs_raw_map_bloc (unused inode_t
*inode
, uint32_t bloc
)
57 /* XXX: can't figure out why I did this... */
58 /* && inode == inode->fs->bootfile*/
60 bloc
+= inode
->blocs
[0].bloc
;
65 static inode_t
*fs_raw_get_special_inode (fs_t
*fs
, int type
)
67 const unsigned char *name
;
68 inode_t
*new, *parent
, **inp
;
78 if (fs
->root
!= NULL
) {
81 flags
= INODE_TYPE_DIR
;
88 if (fs
->bootfile
!= NULL
) {
89 dprintf("bootfile already exists\n");
92 new = part_private_get(fs_part(fs
));
93 if (fs
->bootdir
== NULL
) {
94 dprintf("Get boot directory\n");
95 fs
->bootdir
= fs_raw_get_special_inode(fs
, FILE_BOOTDIR
);
99 dprintf("Fix bootfile\n");
100 new->parent
= parent
;
103 dprintf("New bootfile\n");
104 flags
= INODE_TYPE_FILE
| INODE_FLAG_EXEC
| INODE_FLAG_BOOT
;
111 if (fs
->bootdir
!= NULL
) {
114 flags
= INODE_TYPE_DIR
;
124 new = malloc(sizeof(inode_t
));
125 memset(new, 0, sizeof(inode_t
));
127 new->parent
= parent
;
129 new->name
= strdup(name
);
137 static fs_ops_t fs_ops_raw
= {
141 &fs_raw_get_special_inode
,
144 int fs_raw_set_bootfile (part_t
*part
,
145 uint32_t start_bloc
, uint32_t start_offset
,
146 uint32_t size_bloc
, uint32_t size_offset
)
150 new = malloc(sizeof(inode_t
));
153 DPRINTF("%s: pos %d %d size %d %d\n", __func__
, start_bloc
, start_offset
,
154 size_bloc
, size_offset
);
155 memset(new, 0, sizeof(inode_t
));
156 new->flags
= INODE_TYPE_FILE
| INODE_FLAG_EXEC
| INODE_FLAG_BOOT
;
157 new->name
= "ofwboot";
158 new->blocs
[0].bloc
= start_bloc
;
159 new->blocs
[0].offset
= start_offset
;
160 new->size
.bloc
= size_bloc
;
161 new->size
.offset
= size_offset
;
162 new->nb_blocs
= size_bloc
;
163 part_private_set(part
, new);
168 int fs_raw_probe (part_t
*part
, uint32_t *size
,
169 fs_ops_t
**fs_ops
, unsigned char **name
,
170 unused
void **private)
172 DPRINTF("%s: %p map_bloc %p\n", __func__
, &fs_ops_raw
, &fs_raw_map_bloc
);
173 *fs_ops
= &fs_ops_raw
;
175 *size
= part_size(part
);