removed accidental commit
[grub2/phcoder.git] / fs / xfs.c
blobddaba57206e8196fe832a1ae82431abbe12f1124
1 /* xfs.c - XFS. */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2005,2006,2007,2008 Free Software Foundation, Inc.
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.
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.
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/>.
20 #include <grub/err.h>
21 #include <grub/file.h>
22 #include <grub/mm.h>
23 #include <grub/misc.h>
24 #include <grub/disk.h>
25 #include <grub/dl.h>
26 #include <grub/types.h>
27 #include <grub/fshelp.h>
29 #define XFS_INODE_EXTENTS 9
31 #define XFS_INODE_FORMAT_INO 1
32 #define XFS_INODE_FORMAT_EXT 2
33 #define XFS_INODE_FORMAT_BTREE 3
36 struct grub_xfs_sblock
38 grub_uint8_t magic[4];
39 grub_uint32_t bsize;
40 grub_uint8_t unused1[24];
41 grub_uint16_t uuid[8];
42 grub_uint8_t unused2[8];
43 grub_uint64_t rootino;
44 grub_uint8_t unused3[20];
45 grub_uint32_t agsize;
46 grub_uint8_t unused4[20];
47 grub_uint8_t label[12];
48 grub_uint8_t log2_bsize;
49 grub_uint8_t unused5[2];
50 grub_uint8_t log2_inop;
51 grub_uint8_t log2_agblk;
52 grub_uint8_t unused6[67];
53 grub_uint8_t log2_dirblk;
54 } __attribute__ ((packed));
56 struct grub_xfs_dir_header
58 grub_uint8_t count;
59 grub_uint8_t smallino;
60 union
62 grub_uint32_t i4;
63 grub_uint64_t i8;
64 } parent __attribute__ ((packed));
65 } __attribute__ ((packed));
67 struct grub_xfs_dir_entry
69 grub_uint8_t len;
70 grub_uint16_t offset;
71 char name[1];
72 /* Inode number follows, 32 bits. */
73 } __attribute__ ((packed));
75 struct grub_xfs_dir2_entry
77 grub_uint64_t inode;
78 grub_uint8_t len;
79 } __attribute__ ((packed));
81 typedef grub_uint32_t grub_xfs_extent[4];
83 struct grub_xfs_btree_node
85 grub_uint8_t magic[4];
86 grub_uint16_t level;
87 grub_uint16_t numrecs;
88 grub_uint64_t left;
89 grub_uint64_t right;
90 grub_uint64_t keys[1];
91 } __attribute__ ((packed));
93 struct grub_xfs_btree_root
95 grub_uint16_t level;
96 grub_uint16_t numrecs;
97 grub_uint64_t keys[1];
98 } __attribute__ ((packed));
100 struct grub_xfs_inode
102 grub_uint8_t magic[2];
103 grub_uint16_t mode;
104 grub_uint8_t version;
105 grub_uint8_t format;
106 grub_uint8_t unused2[50];
107 grub_uint64_t size;
108 grub_uint64_t nblocks;
109 grub_uint32_t extsize;
110 grub_uint32_t nextents;
111 grub_uint8_t unused3[20];
112 union
114 char raw[156];
115 struct dir
117 struct grub_xfs_dir_header dirhead;
118 struct grub_xfs_dir_entry direntry[1];
119 } dir;
120 grub_xfs_extent extents[XFS_INODE_EXTENTS];
121 struct grub_xfs_btree_root btree;
122 } data __attribute__ ((packed));
123 } __attribute__ ((packed));
125 struct grub_xfs_dirblock_tail
127 grub_uint32_t leaf_count;
128 grub_uint32_t leaf_stale;
129 } __attribute__ ((packed));
131 struct grub_fshelp_node
133 struct grub_xfs_data *data;
134 struct grub_xfs_inode inode;
135 grub_uint64_t ino;
136 int inode_read;
139 struct grub_xfs_data
141 struct grub_xfs_sblock sblock;
142 struct grub_xfs_inode *inode;
143 grub_disk_t disk;
144 int pos;
145 int bsize;
146 int agsize;
147 struct grub_fshelp_node diropen;
151 static grub_dl_t my_mod;
155 /* Filetype information as used in inodes. */
156 #define FILETYPE_INO_MASK 0170000
157 #define FILETYPE_INO_REG 0100000
158 #define FILETYPE_INO_DIRECTORY 0040000
159 #define FILETYPE_INO_SYMLINK 0120000
161 #define GRUB_XFS_INO_AGBITS(data) \
162 ((data)->sblock.log2_agblk + (data)->sblock.log2_inop)
163 #define GRUB_XFS_INO_INOINAG(data, ino) \
164 (grub_be_to_cpu64 (ino) & ((1 << GRUB_XFS_INO_AGBITS (data)) - 1))
165 #define GRUB_XFS_INO_AG(data,ino) \
166 (grub_be_to_cpu64 (ino) >> GRUB_XFS_INO_AGBITS (data))
168 #define GRUB_XFS_FSB_TO_BLOCK(data, fsb) \
169 (((fsb) >> (data)->sblock.log2_agblk) * (data)->agsize \
170 + ((fsb) & ((1 << (data)->sblock.log2_agblk) - 1)))
172 #define GRUB_XFS_EXTENT_OFFSET(exts,ex) \
173 ((grub_be_to_cpu32 (exts[ex][0]) & ~(1 << 31)) << 23 \
174 | grub_be_to_cpu32 (exts[ex][1]) >> 9)
176 #define GRUB_XFS_EXTENT_BLOCK(exts,ex) \
177 ((grub_uint64_t) (grub_be_to_cpu32 (exts[ex][1]) \
178 & (0x1ff)) << 43 \
179 | (grub_uint64_t) grub_be_to_cpu32 (exts[ex][2]) << 11 \
180 | grub_be_to_cpu32 (exts[ex][3]) >> 21)
182 #define GRUB_XFS_EXTENT_SIZE(exts,ex) \
183 (grub_be_to_cpu32 (exts[ex][3]) & ((1 << 20) - 1))
185 #define GRUB_XFS_ROUND_TO_DIRENT(pos) ((((pos) + 8 - 1) / 8) * 8)
186 #define GRUB_XFS_NEXT_DIRENT(pos,len) \
187 (pos) + GRUB_XFS_ROUND_TO_DIRENT (8 + 1 + len + 2)
189 static inline int
190 grub_xfs_inode_block (struct grub_xfs_data *data,
191 grub_uint64_t ino)
193 long long int inoinag = GRUB_XFS_INO_INOINAG (data, ino);
194 long long ag = GRUB_XFS_INO_AG (data, ino);
195 long long block;
197 block = (inoinag >> 4) + ag * data->agsize;
198 block <<= (data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS);
199 return block;
203 static inline int
204 grub_xfs_inode_offset (struct grub_xfs_data *data,
205 grub_uint64_t ino)
207 int inoag = GRUB_XFS_INO_INOINAG (data, ino);
208 return (inoag & ((1 << 4) - 1)) << 8;
212 static grub_err_t
213 grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino,
214 struct grub_xfs_inode *inode)
216 int block = grub_xfs_inode_block (data, ino);
217 int offset = grub_xfs_inode_offset (data, ino);
219 /* Read the inode. */
220 if (grub_disk_read (data->disk, block, offset,
221 sizeof (struct grub_xfs_inode), inode))
222 return grub_errno;
224 if (grub_strncmp ((char *) inode->magic, "IN", 2))
225 return grub_error (GRUB_ERR_BAD_FS, "not a correct XFS inode.\n");
227 return 0;
231 static grub_disk_addr_t
232 grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
234 struct grub_xfs_btree_node *leaf = 0;
235 int ex, nrec;
236 grub_xfs_extent *exts;
237 grub_uint64_t ret = 0;
239 if (node->inode.format == XFS_INODE_FORMAT_BTREE)
241 grub_uint64_t *keys;
243 leaf = grub_malloc (node->data->sblock.bsize);
244 if (leaf == 0)
245 return 0;
247 nrec = grub_be_to_cpu16 (node->inode.data.btree.numrecs);
248 keys = &node->inode.data.btree.keys[0];
251 int i;
253 for (i = 0; i < nrec; i++)
255 if (fileblock < grub_be_to_cpu64 (keys[i]))
256 break;
259 /* Sparse block. */
260 if (i == 0)
262 grub_free (leaf);
263 return 0;
266 if (grub_disk_read (node->data->disk,
267 grub_be_to_cpu64 (keys[i - 1 + XFS_INODE_EXTENTS])
268 << (node->data->sblock.log2_bsize
269 - GRUB_DISK_SECTOR_BITS),
270 0, node->data->sblock.bsize, leaf))
271 return 0;
273 if (grub_strncmp ((char *) leaf->magic, "BMAP", 4))
275 grub_free (leaf);
276 grub_error (GRUB_ERR_BAD_FS, "not a correct XFS BMAP node.\n");
277 return 0;
280 nrec = grub_be_to_cpu16 (leaf->numrecs);
281 keys = &leaf->keys[0];
282 } while (leaf->level);
283 exts = (grub_xfs_extent *) keys;
285 else if (node->inode.format == XFS_INODE_FORMAT_EXT)
287 nrec = grub_be_to_cpu32 (node->inode.nextents);
288 exts = &node->inode.data.extents[0];
290 else
292 grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
293 "xfs does not support inode format %d yet",
294 node->inode.format);
295 return 0;
298 /* Iterate over each extent to figure out which extent has
299 the block we are looking for. */
300 for (ex = 0; ex < nrec; ex++)
302 grub_uint64_t start = GRUB_XFS_EXTENT_BLOCK (exts, ex);
303 grub_uint64_t offset = GRUB_XFS_EXTENT_OFFSET (exts, ex);
304 grub_uint64_t size = GRUB_XFS_EXTENT_SIZE (exts, ex);
306 /* Sparse block. */
307 if (fileblock < offset)
308 break;
309 else if (fileblock < offset + size)
311 ret = (fileblock - offset + start);
312 break;
316 if (leaf)
317 grub_free (leaf);
319 return GRUB_XFS_FSB_TO_BLOCK(node->data, ret);
323 /* Read LEN bytes from the file described by DATA starting with byte
324 POS. Return the amount of read bytes in READ. */
325 static grub_ssize_t
326 grub_xfs_read_file (grub_fshelp_node_t node,
327 void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
328 unsigned offset, unsigned length),
329 int pos, grub_size_t len, char *buf)
331 return grub_fshelp_read_file (node->data->disk, node, read_hook,
332 pos, len, buf, grub_xfs_read_block,
333 grub_be_to_cpu64 (node->inode.size),
334 node->data->sblock.log2_bsize
335 - GRUB_DISK_SECTOR_BITS);
339 static char *
340 grub_xfs_read_symlink (grub_fshelp_node_t node)
342 int size = grub_be_to_cpu64 (node->inode.size);
344 switch (node->inode.format)
346 case XFS_INODE_FORMAT_INO:
347 return grub_strndup (node->inode.data.raw, size);
349 case XFS_INODE_FORMAT_EXT:
351 char *symlink;
352 grub_ssize_t numread;
354 symlink = grub_malloc (size + 1);
355 if (!symlink)
356 return 0;
358 numread = grub_xfs_read_file (node, 0, 0, size, symlink);
359 if (numread != size)
361 grub_free (symlink);
362 return 0;
364 symlink[size] = '\0';
365 return symlink;
369 return 0;
373 static enum grub_fshelp_filetype
374 grub_xfs_mode_to_filetype (grub_uint16_t mode)
376 if ((grub_be_to_cpu16 (mode)
377 & FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY)
378 return GRUB_FSHELP_DIR;
379 else if ((grub_be_to_cpu16 (mode)
380 & FILETYPE_INO_MASK) == FILETYPE_INO_SYMLINK)
381 return GRUB_FSHELP_SYMLINK;
382 else if ((grub_be_to_cpu16 (mode)
383 & FILETYPE_INO_MASK) == FILETYPE_INO_REG)
384 return GRUB_FSHELP_REG;
385 return GRUB_FSHELP_UNKNOWN;
389 static int
390 grub_xfs_iterate_dir (grub_fshelp_node_t dir,
391 int NESTED_FUNC_ATTR
392 (*hook) (const char *filename,
393 enum grub_fshelp_filetype filetype,
394 grub_fshelp_node_t node))
396 struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir;
397 auto int NESTED_FUNC_ATTR call_hook (grub_uint64_t ino, char *filename);
399 int NESTED_FUNC_ATTR call_hook (grub_uint64_t ino, char *filename)
401 struct grub_fshelp_node *fdiro;
403 fdiro = grub_malloc (sizeof (struct grub_fshelp_node));
404 if (!fdiro)
405 return 0;
407 /* The inode should be read, otherwise the filetype can
408 not be determined. */
409 fdiro->ino = ino;
410 fdiro->inode_read = 1;
411 fdiro->data = diro->data;
412 grub_xfs_read_inode (diro->data, ino, &fdiro->inode);
414 return hook (filename,
415 grub_xfs_mode_to_filetype (fdiro->inode.mode),
416 fdiro);
419 switch (diro->inode.format)
421 case XFS_INODE_FORMAT_INO:
423 struct grub_xfs_dir_entry *de = &diro->inode.data.dir.direntry[0];
424 int smallino = !diro->inode.data.dir.dirhead.smallino;
425 int i;
426 grub_uint64_t parent;
428 /* If small inode numbers are used to pack the direntry, the
429 parent inode number is small too. */
430 if (smallino)
432 parent = grub_be_to_cpu32 (diro->inode.data.dir.dirhead.parent.i4);
433 parent = grub_cpu_to_be64 (parent);
434 /* The header is a bit smaller than usual. */
435 de = (struct grub_xfs_dir_entry *) ((char *) de - 4);
437 else
439 parent = diro->inode.data.dir.dirhead.parent.i8;
442 /* Synthesize the direntries for `.' and `..'. */
443 if (call_hook (diro->ino, "."))
444 return 1;
446 if (call_hook (parent, ".."))
447 return 1;
449 for (i = 0; i < diro->inode.data.dir.dirhead.count; i++)
451 grub_uint64_t ino;
452 void *inopos = (((char *) de)
453 + sizeof (struct grub_xfs_dir_entry)
454 + de->len - 1);
455 char name[de->len + 1];
457 if (smallino)
459 ino = grub_be_to_cpu32 (*(grub_uint32_t *) inopos);
460 ino = grub_cpu_to_be64 (ino);
462 else
463 ino = *(grub_uint64_t *) inopos;
465 grub_memcpy (name, de->name, de->len);
466 name[de->len] = '\0';
467 if (call_hook (ino, name))
468 return 1;
470 de = ((struct grub_xfs_dir_entry *)
471 (((char *) de)+ sizeof (struct grub_xfs_dir_entry) + de->len
472 + ((smallino ? sizeof (grub_uint32_t)
473 : sizeof (grub_uint64_t))) - 1));
475 break;
478 case XFS_INODE_FORMAT_BTREE:
479 case XFS_INODE_FORMAT_EXT:
481 grub_ssize_t numread;
482 char *dirblock;
483 grub_uint64_t blk;
484 int dirblk_size, dirblk_log2;
486 dirblk_log2 = (dir->data->sblock.log2_bsize
487 + dir->data->sblock.log2_dirblk);
488 dirblk_size = 1 << dirblk_log2;
490 dirblock = grub_malloc (dirblk_size);
491 if (! dirblock)
492 return 0;
494 /* Iterate over every block the directory has. */
495 for (blk = 0;
496 blk < (grub_be_to_cpu64 (dir->inode.size)
497 >> dirblk_log2);
498 blk++)
500 /* The header is skipped, the first direntry is stored
501 from byte 16. */
502 int pos = 16;
503 int entries;
504 int tail_start = (dirblk_size
505 - sizeof (struct grub_xfs_dirblock_tail));
507 struct grub_xfs_dirblock_tail *tail;
508 tail = (struct grub_xfs_dirblock_tail *) &dirblock[tail_start];
510 numread = grub_xfs_read_file (dir, 0,
511 blk << dirblk_log2,
512 dirblk_size, dirblock);
513 if (numread != dirblk_size)
514 return 0;
516 entries = (grub_be_to_cpu32 (tail->leaf_count)
517 - grub_be_to_cpu32 (tail->leaf_stale));
519 /* Iterate over all entries within this block. */
520 while (pos < (dirblk_size
521 - (int) sizeof (struct grub_xfs_dir2_entry)))
523 struct grub_xfs_dir2_entry *direntry;
524 grub_uint16_t *freetag;
525 char *filename;
527 direntry = (struct grub_xfs_dir2_entry *) &dirblock[pos];
528 freetag = (grub_uint16_t *) direntry;
530 if (*freetag == 0XFFFF)
532 grub_uint16_t *skip = (grub_uint16_t *) (freetag + 1);
534 /* This entry is not used, go to the next one. */
535 pos += grub_be_to_cpu16 (*skip);
537 continue;
540 filename = &dirblock[pos + sizeof (*direntry)];
541 /* The byte after the filename is for the tag, which
542 is not used by GRUB. So it can be overwritten. */
543 filename[direntry->len] = '\0';
545 if (call_hook (direntry->inode, filename))
547 grub_free (dirblock);
548 return 1;
551 /* Check if last direntry in this block is
552 reached. */
553 entries--;
554 if (!entries)
555 break;
557 /* Select the next directory entry. */
558 pos = GRUB_XFS_NEXT_DIRENT (pos, direntry->len);
559 pos = GRUB_XFS_ROUND_TO_DIRENT (pos);
562 grub_free (dirblock);
563 break;
566 default:
567 grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
568 "xfs does not support inode format %d yet",
569 diro->inode.format);
571 return 0;
575 static struct grub_xfs_data *
576 grub_xfs_mount (grub_disk_t disk)
578 struct grub_xfs_data *data = 0;
580 data = grub_malloc (sizeof (struct grub_xfs_data));
581 if (!data)
582 return 0;
584 /* Read the superblock. */
585 if (grub_disk_read (disk, 0, 0,
586 sizeof (struct grub_xfs_sblock), &data->sblock))
587 goto fail;
589 if (grub_strncmp ((char *) (data->sblock.magic), "XFSB", 4))
591 grub_error (GRUB_ERR_BAD_FS, "not a xfs filesystem");
592 goto fail;
595 data->diropen.data = data;
596 data->diropen.ino = data->sblock.rootino;
597 data->diropen.inode_read = 1;
598 data->bsize = grub_be_to_cpu32 (data->sblock.bsize);
599 data->agsize = grub_be_to_cpu32 (data->sblock.agsize);
601 data->disk = disk;
602 data->inode = &data->diropen.inode;
603 data->pos = 0;
605 grub_xfs_read_inode (data, data->diropen.ino, data->inode);
607 return data;
608 fail:
610 if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
611 grub_error (GRUB_ERR_BAD_FS, "not an xfs filesystem");
613 grub_free (data);
615 return 0;
619 static grub_err_t
620 grub_xfs_dir (grub_device_t device, const char *path,
621 int (*hook) (const char *filename,
622 const struct grub_dirhook_info *info))
624 struct grub_xfs_data *data = 0;
625 struct grub_fshelp_node *fdiro = 0;
627 auto int NESTED_FUNC_ATTR iterate (const char *filename,
628 enum grub_fshelp_filetype filetype,
629 grub_fshelp_node_t node);
631 int NESTED_FUNC_ATTR iterate (const char *filename,
632 enum grub_fshelp_filetype filetype,
633 grub_fshelp_node_t node)
635 struct grub_dirhook_info info;
636 grub_memset (&info, 0, sizeof (info));
637 info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
638 grub_free (node);
639 return hook (filename, &info);
642 grub_dl_ref (my_mod);
644 data = grub_xfs_mount (device->disk);
645 if (!data)
646 goto fail;
648 grub_fshelp_find_file (path, &data->diropen, &fdiro, grub_xfs_iterate_dir,
649 grub_xfs_read_symlink, GRUB_FSHELP_DIR);
650 if (grub_errno)
651 goto fail;
653 grub_xfs_iterate_dir (fdiro, iterate);
655 fail:
656 if (fdiro != &data->diropen)
657 grub_free (fdiro);
658 grub_free (data);
660 grub_dl_unref (my_mod);
662 return grub_errno;
664 return 0;
668 /* Open a file named NAME and initialize FILE. */
669 static grub_err_t
670 grub_xfs_open (struct grub_file *file, const char *name)
672 struct grub_xfs_data *data;
673 struct grub_fshelp_node *fdiro = 0;
675 grub_dl_ref (my_mod);
677 data = grub_xfs_mount (file->device->disk);
678 if (!data)
679 goto fail;
681 grub_fshelp_find_file (name, &data->diropen, &fdiro, grub_xfs_iterate_dir,
682 grub_xfs_read_symlink, GRUB_FSHELP_REG);
683 if (grub_errno)
684 goto fail;
686 if (!fdiro->inode_read)
688 grub_xfs_read_inode (data, fdiro->ino, &fdiro->inode);
689 if (grub_errno)
690 goto fail;
693 grub_memcpy (data->inode,
694 &fdiro->inode,
695 sizeof (struct grub_xfs_inode));
696 grub_free (fdiro);
698 file->size = grub_be_to_cpu64 (data->inode->size);
699 file->data = data;
700 file->offset = 0;
702 return 0;
704 fail:
705 if (fdiro != &data->diropen)
706 grub_free (fdiro);
707 grub_free (data);
709 grub_dl_unref (my_mod);
711 return grub_errno;
715 static grub_ssize_t
716 grub_xfs_read (grub_file_t file, char *buf, grub_size_t len)
718 struct grub_xfs_data *data =
719 (struct grub_xfs_data *) file->data;
721 return grub_xfs_read_file (&data->diropen, file->read_hook,
722 file->offset, len, buf);
726 static grub_err_t
727 grub_xfs_close (grub_file_t file)
729 grub_free (file->data);
731 grub_dl_unref (my_mod);
733 return GRUB_ERR_NONE;
737 static grub_err_t
738 grub_xfs_label (grub_device_t device, char **label)
740 struct grub_xfs_data *data;
741 grub_disk_t disk = device->disk;
743 grub_dl_ref (my_mod);
745 data = grub_xfs_mount (disk);
746 if (data)
747 *label = grub_strndup ((char *) (data->sblock.label), 12);
748 else
749 *label = 0;
751 grub_dl_unref (my_mod);
753 grub_free (data);
755 return grub_errno;
758 static grub_err_t
759 grub_xfs_uuid (grub_device_t device, char **uuid)
761 struct grub_xfs_data *data;
762 grub_disk_t disk = device->disk;
764 grub_dl_ref (my_mod);
766 data = grub_xfs_mount (disk);
767 if (data)
769 *uuid = grub_malloc (sizeof ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"));
770 grub_sprintf (*uuid, "%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
771 grub_be_to_cpu16 (data->sblock.uuid[0]), grub_be_to_cpu16 (data->sblock.uuid[1]),
772 grub_be_to_cpu16 (data->sblock.uuid[2]), grub_be_to_cpu16 (data->sblock.uuid[3]),
773 grub_be_to_cpu16 (data->sblock.uuid[4]), grub_be_to_cpu16 (data->sblock.uuid[5]),
774 grub_be_to_cpu16 (data->sblock.uuid[6]), grub_be_to_cpu16 (data->sblock.uuid[7]));
776 else
777 *uuid = NULL;
779 grub_dl_unref (my_mod);
781 grub_free (data);
783 return grub_errno;
788 static struct grub_fs grub_xfs_fs =
790 .name = "xfs",
791 .dir = grub_xfs_dir,
792 .open = grub_xfs_open,
793 .read = grub_xfs_read,
794 .close = grub_xfs_close,
795 .label = grub_xfs_label,
796 .uuid = grub_xfs_uuid,
797 .next = 0
800 GRUB_MOD_INIT(xfs)
802 grub_fs_register (&grub_xfs_fs);
803 my_mod = mod;
806 GRUB_MOD_FINI(xfs)
808 grub_fs_unregister (&grub_xfs_fs);