]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - GRUB2/grub-2.04/include/grub/fs.h
Update PhyDrive.c
[Ventoy.git] / GRUB2 / grub-2.04 / include / grub / fs.h
1 /* fs.h - filesystem manager */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2002,2003,2004,2007,2008,2009 Free Software Foundation, Inc.
5 *
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef GRUB_FS_HEADER
21 #define GRUB_FS_HEADER 1
22
23 #include <grub/device.h>
24 #include <grub/symbol.h>
25 #include <grub/types.h>
26
27 #include <grub/list.h>
28 /* For embedding types. */
29 #ifdef GRUB_UTIL
30 #include <grub/partition.h>
31 #endif
32
33 /* Forward declaration is required, because of mutual reference. */
34 struct grub_file;
35
36 struct grub_dirhook_info
37 {
38 unsigned dir:1;
39 unsigned mtimeset:1;
40 unsigned case_insensitive:1;
41 unsigned inodeset:1;
42 grub_int32_t mtime;
43 grub_uint64_t inode;
44 grub_uint64_t size;
45 };
46
47 typedef int (*grub_fs_dir_hook_t) (const char *filename,
48 const struct grub_dirhook_info *info,
49 void *data);
50
51 /* Filesystem descriptor. */
52 struct grub_fs
53 {
54 /* The next filesystem. */
55 struct grub_fs *next;
56 struct grub_fs **prev;
57
58 /* My name. */
59 const char *name;
60
61 /* Call HOOK with each file under DIR. */
62 grub_err_t (*fs_dir) (grub_device_t device, const char *path,
63 grub_fs_dir_hook_t hook, void *hook_data);
64
65 /* Open a file named NAME and initialize FILE. */
66 grub_err_t (*fs_open) (struct grub_file *file, const char *name);
67
68 /* Read LEN bytes data from FILE into BUF. */
69 grub_ssize_t (*fs_read) (struct grub_file *file, char *buf, grub_size_t len);
70
71 /* Close the file FILE. */
72 grub_err_t (*fs_close) (struct grub_file *file);
73
74 /* Return the label of the device DEVICE in LABEL. The label is
75 returned in a grub_malloc'ed buffer and should be freed by the
76 caller. */
77 grub_err_t (*fs_label) (grub_device_t device, char **label);
78
79 /* Return the uuid of the device DEVICE in UUID. The uuid is
80 returned in a grub_malloc'ed buffer and should be freed by the
81 caller. */
82 grub_err_t (*fs_uuid) (grub_device_t device, char **uuid);
83
84 /* Get writing time of filesystem. */
85 grub_err_t (*fs_mtime) (grub_device_t device, grub_int32_t *timebuf);
86
87 #ifdef GRUB_UTIL
88 /* Determine sectors available for embedding. */
89 grub_err_t (*fs_embed) (grub_device_t device, unsigned int *nsectors,
90 unsigned int max_nsectors,
91 grub_embed_type_t embed_type,
92 grub_disk_addr_t **sectors);
93
94 /* Whether this filesystem reserves first sector for DOS-style boot. */
95 int reserved_first_sector;
96
97 /* Whether blocklist installs have a chance to work. */
98 int blocklist_install;
99 #endif
100 };
101 typedef struct grub_fs *grub_fs_t;
102
103 /* This is special, because block lists are not files in usual sense. */
104 extern struct grub_fs grub_fs_blocklist;
105
106 /* This hook is used to automatically load filesystem modules.
107 If this hook loads a module, return non-zero. Otherwise return zero.
108 The newly loaded filesystem is assumed to be inserted into the head of
109 the linked list GRUB_FS_LIST through the function grub_fs_register. */
110 typedef int (*grub_fs_autoload_hook_t) (void);
111 extern grub_fs_autoload_hook_t EXPORT_VAR(grub_fs_autoload_hook);
112 extern grub_fs_t EXPORT_VAR (grub_fs_list);
113
114 #ifndef GRUB_LST_GENERATOR
115 static inline void
116 grub_fs_register (grub_fs_t fs)
117 {
118 grub_list_push (GRUB_AS_LIST_P (&grub_fs_list), GRUB_AS_LIST (fs));
119 }
120 #endif
121
122 static inline void
123 grub_fs_unregister (grub_fs_t fs)
124 {
125 grub_list_remove (GRUB_AS_LIST (fs));
126 }
127
128 #define FOR_FILESYSTEMS(var) FOR_LIST_ELEMENTS((var), (grub_fs_list))
129
130 grub_fs_t EXPORT_FUNC(grub_fs_probe) (grub_device_t device);
131
132 #endif /* ! GRUB_FS_HEADER */