3 /* <project_name> -- <project_description>
5 * Copyright (C) 2006 - 2007
6 * Giuseppe Coviello <cjg@cruxppc.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 int (*load_file
) (void *this, char *filename
, void *buffer
);
29 void (*destroy
) (void *this);
35 static int load_file(ext2_boot_dev_t
* this, char *filename
, void *buffer
)
39 if (!ext2fs_mount(this->part_length
)) {
40 printf("** Bad ext2 partition or disk - %d:%d **\n",
41 this->discno
, this->partno
);
46 filelen
= ext2fs_open(filename
);
48 printf("** File not found %s\n", filename
);
53 if (ext2fs_read((char *)buffer
, filelen
) != filelen
) {
54 printf("\n** Unable to read \"%s\" from %d:%d **\n",
55 filename
, this->discno
, this->partno
);
65 static int destroy(ext2_boot_dev_t
* this)
71 boot_dev_t
*ext2_create(struct RdbPartition
*partition
)
73 ext2_boot_dev_t
*boot
;
76 if ((part_length
= ext2fs_set_blk_dev_full(partition
->dev_desc
,
77 partition
->info
)) == 0) {
78 printf("** Bad partition - %d:%d **\n", partition
->disk
,
79 partition
->partition
);
84 if (!ext2fs_mount(part_length
)) {
85 printf("** Bad ext2 partition or disk - %d:%d **\n",
86 partition
->disk
, partition
->partition
);
93 boot
= malloc(sizeof(ext2_boot_dev_t
));
94 boot
->load_file
= (int (*)(void *, char *, void *))load_file
;
95 boot
->destroy
= (void (*)(void *))destroy
;
96 boot
->discno
= partition
->disk
;
97 boot
->partno
= partition
->partition
;
98 boot
->part_length
= part_length
;
100 return (boot_dev_t
*) boot
;