]> git.ozlabs.org Git - yaboot.git/blob - include/file.h
Commit yaboot 1.3.2
[yaboot.git] / include / file.h
1 /*
2     Definitions for talking to the Open Firmware PROM on
3     Power Macintosh computers.
4
5     Copyright (C) 1999 Benjamin Herrenschmidt
6
7     This program 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 of the License, or
10     (at your option) any later version.
11
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.
16
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
20 */
21
22 #ifndef FILE_H
23 #define FILE_H
24
25 #include "types.h"
26 #include "stddef.h"
27 #include "prom.h"
28
29 struct boot_file_t;
30 #include "fs.h"
31
32 #define FILE_MAX_PATH           1024
33
34 /* Simple error codes */
35 #define FILE_ERR_OK             0
36 #define FILE_ERR_EOF            -1
37 #define FILE_ERR_NOTFOUND       -2
38 #define FILE_CANT_SEEK          -3
39 #define FILE_IOERR              -4
40 #define FILE_BAD_PATH           -5
41 #define FILE_ERR_BAD_TYPE       -6
42 #define FILE_ERR_BAD_FSYS       -7
43 #define FILE_ERR_SYMLINK_LOOP   -8
44 #define FILE_ERR_LENGTH         -9
45
46 /* Device kind */
47 #define FILE_DEVICE_BLOCK       1
48 #define FILE_DEVICE_NET         2
49
50 struct boot_fspec_t {
51         char*   dev;            /* OF device path */
52         int     part;           /* Partition number or -1 */
53         char*   file;           /* File path */
54 };
55
56 struct boot_file_t {
57
58         /* File access methods */
59         const struct fs_t *fs;
60
61         /* Filesystem private (to be broken once we have a
62          * better malloc'ator)
63          */
64
65         int             device_kind;
66         ihandle         of_device;
67         ino_t           inode;
68         __u64           pos;
69         unsigned char*  buffer;
70         __u64           len;
71 //      unsigned int    dev_blk_size;
72 //      unsigned int    part_start;
73 //      unsigned int    part_count;
74 };
75
76 extern int open_file(   const struct boot_fspec_t*      spec,
77                         struct boot_file_t*             file);
78
79 extern int validate_fspec(
80                         struct boot_fspec_t*    spec,
81                         char*                   default_device,
82                         int                     default_part);
83 extern char *parse_device_path(
84                         char*                   of_device,
85                         char**                  file_spec,
86                         int*                    partition);
87
88
89
90 #endif