Forgot tar.c
[grub2/jjazz.git] / include / grub / file.h
blobdf2e9e470e89c0bff15a5988f366f8c562510c5a
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2002,2007 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef GRUB_FILE_HEADER
20 #define GRUB_FILE_HEADER 1
22 #include <grub/types.h>
23 #include <grub/err.h>
24 #include <grub/device.h>
25 #include <grub/fs.h>
27 /* File description. */
28 struct grub_file
30 /* The underlying device. */
31 grub_device_t device;
33 /* The underlying filesystem. */
34 grub_fs_t fs;
36 /* The current offset. */
37 grub_off_t offset;
39 /* The file size. */
40 grub_off_t size;
42 /* Filesystem-specific data. */
43 void *data;
45 /* This is called when a sector is read. Used only for a disk device. */
46 void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
47 unsigned offset, unsigned length);
49 typedef struct grub_file *grub_file_t;
51 /* Get a device name from NAME. */
52 char *EXPORT_FUNC(grub_file_get_device_name) (const char *name);
54 grub_file_t EXPORT_FUNC(grub_file_open) (const char *name);
55 grub_ssize_t EXPORT_FUNC(grub_file_read) (grub_file_t file, char *buf,
56 grub_size_t len);
57 grub_off_t EXPORT_FUNC(grub_file_seek) (grub_file_t file, grub_off_t offset);
58 grub_err_t EXPORT_FUNC(grub_file_close) (grub_file_t file);
60 static inline grub_off_t
61 grub_file_size (const grub_file_t file)
63 return file->size;
66 static inline grub_off_t
67 grub_file_tell (const grub_file_t file)
69 return file->offset;
72 #endif /* ! GRUB_FILE_HEADER */