3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2005,2006,2007,2008,2009 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/>.
21 #include <grub/file.h>
23 #include <grub/misc.h>
24 #include <grub/disk.h>
26 #include <grub/types.h>
27 #include <grub/fshelp.h>
29 GRUB_MOD_LICENSE ("GPLv3+");
31 #define XFS_INODE_EXTENTS 9
33 #define XFS_INODE_FORMAT_INO 1
34 #define XFS_INODE_FORMAT_EXT 2
35 #define XFS_INODE_FORMAT_BTREE 3
38 struct grub_xfs_sblock
40 grub_uint8_t magic
[4];
42 grub_uint8_t unused1
[24];
43 grub_uint16_t uuid
[8];
44 grub_uint8_t unused2
[8];
45 grub_uint64_t rootino
;
46 grub_uint8_t unused3
[20];
48 grub_uint8_t unused4
[20];
49 grub_uint8_t label
[12];
50 grub_uint8_t log2_bsize
;
51 grub_uint8_t log2_sect
;
52 grub_uint8_t log2_inode
;
53 grub_uint8_t log2_inop
;
54 grub_uint8_t log2_agblk
;
55 grub_uint8_t unused6
[67];
56 grub_uint8_t log2_dirblk
;
57 } __attribute__ ((packed
));
59 struct grub_xfs_dir_header
62 grub_uint8_t smallino
;
67 } parent
__attribute__ ((packed
));
68 } __attribute__ ((packed
));
70 struct grub_xfs_dir_entry
75 /* Inode number follows, 32 bits. */
76 } __attribute__ ((packed
));
78 struct grub_xfs_dir2_entry
82 } __attribute__ ((packed
));
84 typedef grub_uint32_t grub_xfs_extent
[4];
86 struct grub_xfs_btree_node
88 grub_uint8_t magic
[4];
90 grub_uint16_t numrecs
;
93 grub_uint64_t keys
[1];
94 } __attribute__ ((packed
));
96 struct grub_xfs_btree_root
99 grub_uint16_t numrecs
;
100 grub_uint64_t keys
[1];
101 } __attribute__ ((packed
));
106 grub_uint32_t nanosec
;
107 } __attribute__ ((packed
));
109 struct grub_xfs_inode
111 grub_uint8_t magic
[2];
113 grub_uint8_t version
;
115 grub_uint8_t unused2
[26];
116 struct grub_xfs_time atime
;
117 struct grub_xfs_time mtime
;
118 struct grub_xfs_time ctime
;
120 grub_uint64_t nblocks
;
121 grub_uint32_t extsize
;
122 grub_uint32_t nextents
;
123 grub_uint16_t unused3
;
124 grub_uint8_t fork_offset
;
125 grub_uint8_t unused4
[17];
131 struct grub_xfs_dir_header dirhead
;
132 struct grub_xfs_dir_entry direntry
[1];
134 grub_xfs_extent extents
[XFS_INODE_EXTENTS
];
135 struct grub_xfs_btree_root btree
;
136 } data
__attribute__ ((packed
));
137 } __attribute__ ((packed
));
139 struct grub_xfs_dirblock_tail
141 grub_uint32_t leaf_count
;
142 grub_uint32_t leaf_stale
;
143 } __attribute__ ((packed
));
145 struct grub_fshelp_node
147 struct grub_xfs_data
*data
;
150 struct grub_xfs_inode inode
;
155 struct grub_xfs_sblock sblock
;
159 grub_uint32_t agsize
;
160 struct grub_fshelp_node diropen
;
163 static grub_dl_t my_mod
;
167 /* Filetype information as used in inodes. */
168 #define FILETYPE_INO_MASK 0170000
169 #define FILETYPE_INO_REG 0100000
170 #define FILETYPE_INO_DIRECTORY 0040000
171 #define FILETYPE_INO_SYMLINK 0120000
174 GRUB_XFS_INO_AGBITS(struct grub_xfs_data
*data
)
176 return ((data
)->sblock
.log2_agblk
+ (data
)->sblock
.log2_inop
);
179 static inline grub_uint64_t
180 GRUB_XFS_INO_INOINAG (struct grub_xfs_data
*data
,
183 return (grub_be_to_cpu64 (ino
) & ((1LL << GRUB_XFS_INO_AGBITS (data
)) - 1));
186 static inline grub_uint64_t
187 GRUB_XFS_INO_AG (struct grub_xfs_data
*data
,
190 return (grub_be_to_cpu64 (ino
) >> GRUB_XFS_INO_AGBITS (data
));
193 static inline grub_disk_addr_t
194 GRUB_XFS_FSB_TO_BLOCK (struct grub_xfs_data
*data
, grub_disk_addr_t fsb
)
196 return ((fsb
>> data
->sblock
.log2_agblk
) * data
->agsize
197 + (fsb
& ((1LL << data
->sblock
.log2_agblk
) - 1)));
200 static inline grub_uint64_t
201 GRUB_XFS_EXTENT_OFFSET (grub_xfs_extent
*exts
, int ex
)
203 return ((grub_be_to_cpu32 (exts
[ex
][0]) & ~(1 << 31)) << 23
204 | grub_be_to_cpu32 (exts
[ex
][1]) >> 9);
207 static inline grub_uint64_t
208 GRUB_XFS_EXTENT_BLOCK (grub_xfs_extent
*exts
, int ex
)
210 return ((grub_uint64_t
) (grub_be_to_cpu32 (exts
[ex
][1])
212 | (grub_uint64_t
) grub_be_to_cpu32 (exts
[ex
][2]) << 11
213 | grub_be_to_cpu32 (exts
[ex
][3]) >> 21);
216 static inline grub_uint64_t
217 GRUB_XFS_EXTENT_SIZE (grub_xfs_extent
*exts
, int ex
)
219 return (grub_be_to_cpu32 (exts
[ex
][3]) & ((1 << 21) - 1));
223 GRUB_XFS_ROUND_TO_DIRENT (int pos
)
225 return ((((pos
) + 8 - 1) / 8) * 8);
229 GRUB_XFS_NEXT_DIRENT (int pos
, int len
)
231 return (pos
) + GRUB_XFS_ROUND_TO_DIRENT (8 + 1 + len
+ 2);
235 static inline grub_uint64_t
236 grub_xfs_inode_block (struct grub_xfs_data
*data
,
239 long long int inoinag
= GRUB_XFS_INO_INOINAG (data
, ino
);
240 long long ag
= GRUB_XFS_INO_AG (data
, ino
);
243 block
= (inoinag
>> data
->sblock
.log2_inop
) + ag
* data
->agsize
;
244 block
<<= (data
->sblock
.log2_bsize
- GRUB_DISK_SECTOR_BITS
);
250 grub_xfs_inode_offset (struct grub_xfs_data
*data
,
253 int inoag
= GRUB_XFS_INO_INOINAG (data
, ino
);
254 return ((inoag
& ((1 << data
->sblock
.log2_inop
) - 1)) <<
255 data
->sblock
.log2_inode
);
260 grub_xfs_read_inode (struct grub_xfs_data
*data
, grub_uint64_t ino
,
261 struct grub_xfs_inode
*inode
)
263 grub_uint64_t block
= grub_xfs_inode_block (data
, ino
);
264 int offset
= grub_xfs_inode_offset (data
, ino
);
266 /* Read the inode. */
267 if (grub_disk_read (data
->disk
, block
, offset
,
268 1 << data
->sblock
.log2_inode
, inode
))
271 if (grub_strncmp ((char *) inode
->magic
, "IN", 2))
272 return grub_error (GRUB_ERR_BAD_FS
, "not a correct XFS inode");
278 static grub_disk_addr_t
279 grub_xfs_read_block (grub_fshelp_node_t node
, grub_disk_addr_t fileblock
)
281 struct grub_xfs_btree_node
*leaf
= 0;
283 grub_xfs_extent
*exts
;
284 grub_uint64_t ret
= 0;
286 if (node
->inode
.format
== XFS_INODE_FORMAT_BTREE
)
291 leaf
= grub_malloc (node
->data
->bsize
);
295 nrec
= grub_be_to_cpu16 (node
->inode
.data
.btree
.numrecs
);
296 keys
= &node
->inode
.data
.btree
.keys
[0];
297 if (node
->inode
.fork_offset
)
298 recoffset
= (node
->inode
.fork_offset
299 - ((char *) &node
->inode
.data
.btree
.keys
- (char *) &node
->inode
))
300 / (2 * sizeof (grub_uint64_t
));
302 recoffset
= ((1 << node
->data
->sblock
.log2_inode
)
303 - ((char *) &node
->inode
.data
.btree
.keys
304 - (char *) &node
->inode
))
305 / (2 * sizeof (grub_uint64_t
));
310 for (i
= 0; i
< nrec
; i
++)
312 if (fileblock
< grub_be_to_cpu64 (keys
[i
]))
322 if (grub_disk_read (node
->data
->disk
,
323 GRUB_XFS_FSB_TO_BLOCK (node
->data
, grub_be_to_cpu64 (keys
[i
- 1 + recoffset
])) << (node
->data
->sblock
.log2_bsize
- GRUB_DISK_SECTOR_BITS
),
324 0, node
->data
->bsize
, leaf
))
327 if (grub_strncmp ((char *) leaf
->magic
, "BMAP", 4))
330 grub_error (GRUB_ERR_BAD_FS
, "not a correct XFS BMAP node");
334 nrec
= grub_be_to_cpu16 (leaf
->numrecs
);
335 keys
= &leaf
->keys
[0];
336 recoffset
= ((node
->data
->bsize
- ((char *) &leaf
->keys
338 / (2 * sizeof (grub_uint64_t
)));
341 exts
= (grub_xfs_extent
*) keys
;
343 else if (node
->inode
.format
== XFS_INODE_FORMAT_EXT
)
345 nrec
= grub_be_to_cpu32 (node
->inode
.nextents
);
346 exts
= &node
->inode
.data
.extents
[0];
350 grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET
,
351 "XFS does not support inode format %d yet",
356 /* Iterate over each extent to figure out which extent has
357 the block we are looking for. */
358 for (ex
= 0; ex
< nrec
; ex
++)
360 grub_uint64_t start
= GRUB_XFS_EXTENT_BLOCK (exts
, ex
);
361 grub_uint64_t offset
= GRUB_XFS_EXTENT_OFFSET (exts
, ex
);
362 grub_uint64_t size
= GRUB_XFS_EXTENT_SIZE (exts
, ex
);
365 if (fileblock
< offset
)
367 else if (fileblock
< offset
+ size
)
369 ret
= (fileblock
- offset
+ start
);
376 return GRUB_XFS_FSB_TO_BLOCK(node
->data
, ret
);
380 /* Read LEN bytes from the file described by DATA starting with byte
381 POS. Return the amount of read bytes in READ. */
383 grub_xfs_read_file (grub_fshelp_node_t node
,
384 void NESTED_FUNC_ATTR (*read_hook
) (grub_disk_addr_t sector
,
385 unsigned offset
, unsigned length
),
386 grub_off_t pos
, grub_size_t len
, char *buf
)
388 return grub_fshelp_read_file (node
->data
->disk
, node
, read_hook
,
389 pos
, len
, buf
, grub_xfs_read_block
,
390 grub_be_to_cpu64 (node
->inode
.size
),
391 node
->data
->sblock
.log2_bsize
392 - GRUB_DISK_SECTOR_BITS
, 0);
397 grub_xfs_read_symlink (grub_fshelp_node_t node
)
399 int size
= grub_be_to_cpu64 (node
->inode
.size
);
401 switch (node
->inode
.format
)
403 case XFS_INODE_FORMAT_INO
:
404 return grub_strndup (node
->inode
.data
.raw
, size
);
406 case XFS_INODE_FORMAT_EXT
:
409 grub_ssize_t numread
;
411 symlink
= grub_malloc (size
+ 1);
415 numread
= grub_xfs_read_file (node
, 0, 0, size
, symlink
);
421 symlink
[size
] = '\0';
430 static enum grub_fshelp_filetype
431 grub_xfs_mode_to_filetype (grub_uint16_t mode
)
433 if ((grub_be_to_cpu16 (mode
)
434 & FILETYPE_INO_MASK
) == FILETYPE_INO_DIRECTORY
)
435 return GRUB_FSHELP_DIR
;
436 else if ((grub_be_to_cpu16 (mode
)
437 & FILETYPE_INO_MASK
) == FILETYPE_INO_SYMLINK
)
438 return GRUB_FSHELP_SYMLINK
;
439 else if ((grub_be_to_cpu16 (mode
)
440 & FILETYPE_INO_MASK
) == FILETYPE_INO_REG
)
441 return GRUB_FSHELP_REG
;
442 return GRUB_FSHELP_UNKNOWN
;
447 grub_xfs_iterate_dir (grub_fshelp_node_t dir
,
449 (*hook
) (const char *filename
,
450 enum grub_fshelp_filetype filetype
,
451 grub_fshelp_node_t node
))
453 struct grub_fshelp_node
*diro
= (struct grub_fshelp_node
*) dir
;
454 auto int NESTED_FUNC_ATTR
call_hook (grub_uint64_t ino
, const char *filename
);
456 int NESTED_FUNC_ATTR
call_hook (grub_uint64_t ino
, const char *filename
)
458 struct grub_fshelp_node
*fdiro
;
461 fdiro
= grub_malloc (sizeof (struct grub_fshelp_node
)
462 - sizeof (struct grub_xfs_inode
)
463 + (1 << diro
->data
->sblock
.log2_inode
));
470 /* The inode should be read, otherwise the filetype can
471 not be determined. */
473 fdiro
->inode_read
= 1;
474 fdiro
->data
= diro
->data
;
475 err
= grub_xfs_read_inode (diro
->data
, ino
, &fdiro
->inode
);
482 return hook (filename
,
483 grub_xfs_mode_to_filetype (fdiro
->inode
.mode
),
487 switch (diro
->inode
.format
)
489 case XFS_INODE_FORMAT_INO
:
491 struct grub_xfs_dir_entry
*de
= &diro
->inode
.data
.dir
.direntry
[0];
492 int smallino
= !diro
->inode
.data
.dir
.dirhead
.smallino
;
494 grub_uint64_t parent
;
496 /* If small inode numbers are used to pack the direntry, the
497 parent inode number is small too. */
500 parent
= grub_be_to_cpu32 (diro
->inode
.data
.dir
.dirhead
.parent
.i4
);
501 parent
= grub_cpu_to_be64 (parent
);
502 /* The header is a bit smaller than usual. */
503 de
= (struct grub_xfs_dir_entry
*) ((char *) de
- 4);
507 parent
= diro
->inode
.data
.dir
.dirhead
.parent
.i8
;
510 /* Synthesize the direntries for `.' and `..'. */
511 if (call_hook (diro
->ino
, "."))
514 if (call_hook (parent
, ".."))
517 for (i
= 0; i
< diro
->inode
.data
.dir
.dirhead
.count
; i
++)
520 grub_uint8_t
*inopos
= (((grub_uint8_t
*) de
)
521 + sizeof (struct grub_xfs_dir_entry
)
523 char name
[de
->len
+ 1];
525 /* inopos might be unaligned. */
527 ino
= (((grub_uint32_t
) inopos
[0]) << 24)
528 | (((grub_uint32_t
) inopos
[1]) << 16)
529 | (((grub_uint32_t
) inopos
[2]) << 8)
530 | (((grub_uint32_t
) inopos
[3]) << 0);
532 ino
= (((grub_uint64_t
) inopos
[0]) << 56)
533 | (((grub_uint64_t
) inopos
[1]) << 48)
534 | (((grub_uint64_t
) inopos
[2]) << 40)
535 | (((grub_uint64_t
) inopos
[3]) << 32)
536 | (((grub_uint64_t
) inopos
[4]) << 24)
537 | (((grub_uint64_t
) inopos
[5]) << 16)
538 | (((grub_uint64_t
) inopos
[6]) << 8)
539 | (((grub_uint64_t
) inopos
[7]) << 0);
540 ino
= grub_cpu_to_be64 (ino
);
542 grub_memcpy (name
, de
->name
, de
->len
);
543 name
[de
->len
] = '\0';
544 if (call_hook (ino
, name
))
547 de
= ((struct grub_xfs_dir_entry
*)
548 (((char *) de
)+ sizeof (struct grub_xfs_dir_entry
) + de
->len
549 + ((smallino
? sizeof (grub_uint32_t
)
550 : sizeof (grub_uint64_t
))) - 1));
555 case XFS_INODE_FORMAT_BTREE
:
556 case XFS_INODE_FORMAT_EXT
:
558 grub_ssize_t numread
;
561 int dirblk_size
, dirblk_log2
;
563 dirblk_log2
= (dir
->data
->sblock
.log2_bsize
564 + dir
->data
->sblock
.log2_dirblk
);
565 dirblk_size
= 1 << dirblk_log2
;
567 dirblock
= grub_malloc (dirblk_size
);
571 /* Iterate over every block the directory has. */
573 blk
< (grub_be_to_cpu64 (dir
->inode
.size
)
577 /* The header is skipped, the first direntry is stored
581 int tail_start
= (dirblk_size
582 - sizeof (struct grub_xfs_dirblock_tail
));
584 struct grub_xfs_dirblock_tail
*tail
;
585 tail
= (struct grub_xfs_dirblock_tail
*) &dirblock
[tail_start
];
587 numread
= grub_xfs_read_file (dir
, 0,
589 dirblk_size
, dirblock
);
590 if (numread
!= dirblk_size
)
593 entries
= (grub_be_to_cpu32 (tail
->leaf_count
)
594 - grub_be_to_cpu32 (tail
->leaf_stale
));
596 /* Iterate over all entries within this block. */
597 while (pos
< (dirblk_size
598 - (int) sizeof (struct grub_xfs_dir2_entry
)))
600 struct grub_xfs_dir2_entry
*direntry
;
601 grub_uint8_t
*freetag
;
604 direntry
= (struct grub_xfs_dir2_entry
*) &dirblock
[pos
];
605 freetag
= (grub_uint8_t
*) direntry
;
607 if (grub_get_unaligned16 (freetag
) == 0XFFFF)
609 grub_uint8_t
*skip
= (freetag
+ sizeof (grub_uint16_t
));
611 /* This entry is not used, go to the next one. */
612 pos
+= grub_be_to_cpu16 (grub_get_unaligned16 (skip
));
617 filename
= &dirblock
[pos
+ sizeof (*direntry
)];
618 /* The byte after the filename is for the tag, which
619 is not used by GRUB. So it can be overwritten. */
620 filename
[direntry
->len
] = '\0';
622 if (call_hook (direntry
->inode
, filename
))
624 grub_free (dirblock
);
628 /* Check if last direntry in this block is
634 /* Select the next directory entry. */
635 pos
= GRUB_XFS_NEXT_DIRENT (pos
, direntry
->len
);
636 pos
= GRUB_XFS_ROUND_TO_DIRENT (pos
);
639 grub_free (dirblock
);
644 grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET
,
645 "XFS does not support inode format %d yet",
652 static struct grub_xfs_data
*
653 grub_xfs_mount (grub_disk_t disk
)
655 struct grub_xfs_data
*data
= 0;
657 data
= grub_zalloc (sizeof (struct grub_xfs_data
));
661 /* Read the superblock. */
662 if (grub_disk_read (disk
, 0, 0,
663 sizeof (struct grub_xfs_sblock
), &data
->sblock
))
666 if (grub_strncmp ((char *) (data
->sblock
.magic
), "XFSB", 4)
667 || data
->sblock
.log2_bsize
< GRUB_DISK_SECTOR_BITS
668 || ((int) data
->sblock
.log2_bsize
669 + (int) data
->sblock
.log2_dirblk
) >= 27)
671 grub_error (GRUB_ERR_BAD_FS
, "not a XFS filesystem");
675 data
= grub_realloc (data
,
676 sizeof (struct grub_xfs_data
)
677 - sizeof (struct grub_xfs_inode
)
678 + (1 << data
->sblock
.log2_inode
));
683 data
->diropen
.data
= data
;
684 data
->diropen
.ino
= data
->sblock
.rootino
;
685 data
->diropen
.inode_read
= 1;
686 data
->bsize
= grub_be_to_cpu32 (data
->sblock
.bsize
);
687 data
->agsize
= grub_be_to_cpu32 (data
->sblock
.agsize
);
692 grub_xfs_read_inode (data
, data
->diropen
.ino
, &data
->diropen
.inode
);
697 if (grub_errno
== GRUB_ERR_OUT_OF_RANGE
)
698 grub_error (GRUB_ERR_BAD_FS
, "not an XFS filesystem");
707 grub_xfs_dir (grub_device_t device
, const char *path
,
708 int (*hook
) (const char *filename
,
709 const struct grub_dirhook_info
*info
))
711 struct grub_xfs_data
*data
= 0;
712 struct grub_fshelp_node
*fdiro
= 0;
714 auto int NESTED_FUNC_ATTR
iterate (const char *filename
,
715 enum grub_fshelp_filetype filetype
,
716 grub_fshelp_node_t node
);
718 int NESTED_FUNC_ATTR
iterate (const char *filename
,
719 enum grub_fshelp_filetype filetype
,
720 grub_fshelp_node_t node
)
722 struct grub_dirhook_info info
;
723 grub_memset (&info
, 0, sizeof (info
));
724 if (node
->inode_read
)
727 info
.mtime
= grub_be_to_cpu32 (node
->inode
.mtime
.sec
);
729 info
.dir
= ((filetype
& GRUB_FSHELP_TYPE_MASK
) == GRUB_FSHELP_DIR
);
731 return hook (filename
, &info
);
734 grub_dl_ref (my_mod
);
736 data
= grub_xfs_mount (device
->disk
);
740 grub_fshelp_find_file (path
, &data
->diropen
, &fdiro
, grub_xfs_iterate_dir
,
741 grub_xfs_read_symlink
, GRUB_FSHELP_DIR
);
745 grub_xfs_iterate_dir (fdiro
, iterate
);
748 if (fdiro
!= &data
->diropen
)
754 grub_dl_unref (my_mod
);
760 /* Open a file named NAME and initialize FILE. */
762 grub_xfs_open (struct grub_file
*file
, const char *name
)
764 struct grub_xfs_data
*data
;
765 struct grub_fshelp_node
*fdiro
= 0;
767 grub_dl_ref (my_mod
);
769 data
= grub_xfs_mount (file
->device
->disk
);
773 grub_fshelp_find_file (name
, &data
->diropen
, &fdiro
, grub_xfs_iterate_dir
,
774 grub_xfs_read_symlink
, GRUB_FSHELP_REG
);
778 if (!fdiro
->inode_read
)
780 grub_xfs_read_inode (data
, fdiro
->ino
, &fdiro
->inode
);
785 if (fdiro
!= &data
->diropen
)
787 grub_memcpy (&data
->diropen
, fdiro
,
788 sizeof (struct grub_fshelp_node
)
789 - sizeof (struct grub_xfs_inode
)
790 + (1 << data
->sblock
.log2_inode
));
794 file
->size
= grub_be_to_cpu64 (data
->diropen
.inode
.size
);
801 if (fdiro
!= &data
->diropen
)
806 grub_dl_unref (my_mod
);
813 grub_xfs_read (grub_file_t file
, char *buf
, grub_size_t len
)
815 struct grub_xfs_data
*data
=
816 (struct grub_xfs_data
*) file
->data
;
818 return grub_xfs_read_file (&data
->diropen
, file
->read_hook
,
819 file
->offset
, len
, buf
);
824 grub_xfs_close (grub_file_t file
)
826 grub_free (file
->data
);
828 grub_dl_unref (my_mod
);
830 return GRUB_ERR_NONE
;
835 grub_xfs_label (grub_device_t device
, char **label
)
837 struct grub_xfs_data
*data
;
838 grub_disk_t disk
= device
->disk
;
840 grub_dl_ref (my_mod
);
842 data
= grub_xfs_mount (disk
);
844 *label
= grub_strndup ((char *) (data
->sblock
.label
), 12);
848 grub_dl_unref (my_mod
);
856 grub_xfs_uuid (grub_device_t device
, char **uuid
)
858 struct grub_xfs_data
*data
;
859 grub_disk_t disk
= device
->disk
;
861 grub_dl_ref (my_mod
);
863 data
= grub_xfs_mount (disk
);
866 *uuid
= grub_xasprintf ("%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
867 grub_be_to_cpu16 (data
->sblock
.uuid
[0]),
868 grub_be_to_cpu16 (data
->sblock
.uuid
[1]),
869 grub_be_to_cpu16 (data
->sblock
.uuid
[2]),
870 grub_be_to_cpu16 (data
->sblock
.uuid
[3]),
871 grub_be_to_cpu16 (data
->sblock
.uuid
[4]),
872 grub_be_to_cpu16 (data
->sblock
.uuid
[5]),
873 grub_be_to_cpu16 (data
->sblock
.uuid
[6]),
874 grub_be_to_cpu16 (data
->sblock
.uuid
[7]));
879 grub_dl_unref (my_mod
);
888 static struct grub_fs grub_xfs_fs
=
892 .open
= grub_xfs_open
,
893 .read
= grub_xfs_read
,
894 .close
= grub_xfs_close
,
895 .label
= grub_xfs_label
,
896 .uuid
= grub_xfs_uuid
,
898 .reserved_first_sector
= 0,
899 .blocklist_install
= 1,
906 grub_fs_register (&grub_xfs_fs
);
912 grub_fs_unregister (&grub_xfs_fs
);