orphan
[debian/elilo] / glue_ext2fs.c
1 /*
2  *  Copyright (C) 2001-2003 Hewlett-Packard Co.
3  *      Contributed by Stephane Eranian <eranian@hpl.hp.com>
4  *
5  * This file is part of the ELILO, the EFI Linux boot loader.
6  *
7  *  ELILO is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  ELILO 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.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with ELILO; see the file COPYING.  If not, write to the Free
19  *  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20  *  02111-1307, USA.
21  *
22  * Please check out the elilo.txt for complete documentation on how
23  * to use this program.
24  */
25 #include <efi.h>
26 #include <efilib.h>
27
28 #include "glue_ext2fs.h"
29 #include "fs/ext2fs.h"
30 #include "strops.h"
31
32
33 static INTN glue(fileops_t *this, VOID *intf);
34
35 /* object exported to fileops */
36
37 fileops_fs_t ext2fs_glue = { EXT2FS_PROTOCOL , glue, ext2fs_install, ext2fs_uninstall};
38
39 static EFI_STATUS
40 ext2fs_infosize(ext2fs_interface_t *this, fops_fd_t fd, UINT64 *sz)
41 {
42         ext2fs_stat_t st;
43         EFI_STATUS status;
44
45         if (this == NULL || sz == NULL) return EFI_INVALID_PARAMETER;
46
47         status = this->ext2fs_fstat(this, fd, &st);
48         if (status != EFI_SUCCESS) return status;
49
50         *sz  = (UINT64)st.st_size;
51
52         return EFI_SUCCESS;
53 }
54
55 static INTN
56 glue(fileops_t *fp, VOID *intf)
57 {
58         ext2fs_interface_t *ext2fs = (ext2fs_interface_t *)intf;
59
60         /* record underlying interface */
61         fp->intf = intf;
62
63         fp->open     = (fops_open_t)ext2fs->ext2fs_open;
64         fp->read     = (fops_read_t)ext2fs->ext2fs_read;
65         fp->close    = (fops_close_t)ext2fs->ext2fs_close;
66         fp->infosize = (fops_infosize_t)ext2fs_infosize; /* local override */
67         fp->seek     = (fops_seek_t)ext2fs->ext2fs_seek;
68
69         /* fill out the name of the underlying file system */
70         ext2fs->ext2fs_name(ext2fs, fp->name, FILEOPS_NAME_MAXLEN);
71
72         return 0;
73 }