1
/* ntfs.c - NTFS filesystem */
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
6
* This program 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
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
20
#include <grub/file.h>
22
#include <grub/misc.h>
23
#include <grub/disk.h>
25
#include <grub/fshelp.h>
26
#include <grub/ntfs.h>
27
#include <grub/charset.h>
29
static grub_dl_t my_mod;
31
ntfscomp_func_t grub_ntfscomp_func;
34
fixup (struct grub_ntfs_data *data, char *buf, int len, char *magic)
40
if (grub_memcmp (buf, magic, 4))
41
return grub_error (GRUB_ERR_BAD_FS, "%s label not found", magic);
43
ss = u16at (buf, 6) - 1;
44
if (ss * (int) data->blocksize != len * GRUB_DISK_SECTOR_SIZE)
45
return grub_error (GRUB_ERR_BAD_FS, "size not match",
46
ss * (int) data->blocksize,
47
len * GRUB_DISK_SECTOR_SIZE);
48
pu = buf + u16at (buf, 4);
53
buf += data->blocksize;
55
if (u16at (buf, 0) != us)
56
return grub_error (GRUB_ERR_BAD_FS, "fixup signature not match");
57
v16at (buf, 0) = v16at (pu, 0);
64
static grub_err_t read_mft (struct grub_ntfs_data *data, char *buf,
66
static grub_err_t read_attr (struct grub_ntfs_attr *at, char *dest,
67
grub_disk_addr_t ofs, grub_size_t len,
70
NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t
75
static grub_err_t read_data (struct grub_ntfs_attr *at, char *pa, char *dest,
76
grub_disk_addr_t ofs, grub_size_t len,
79
NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t
85
init_attr (struct grub_ntfs_attr *at, struct grub_ntfs_file *mft)
88
at->flags = (mft == &mft->data->mmft) ? AF_MMFT : 0;
89
at->attr_nxt = mft->buf + u16at (mft->buf, 0x14);
90
at->attr_end = at->emft_buf = at->edat_buf = at->sbuf = NULL;
94
free_attr (struct grub_ntfs_attr *at)
96
grub_free (at->emft_buf);
97
grub_free (at->edat_buf);
102
find_attr (struct grub_ntfs_attr *at, unsigned char attr)
104
if (at->flags & AF_ALST)
107
while (at->attr_nxt < at->attr_end)
109
at->attr_cur = at->attr_nxt;
110
at->attr_nxt += u16at (at->attr_cur, 4);
111
if (((unsigned char) *at->attr_cur == attr) || (attr == 0))
115
if (at->flags & AF_MMFT)
118
(at->mft->data->disk, v32at (at->attr_cur, 0x10), 0,
122
(at->mft->data->disk, v32at (at->attr_cur, 0x14), 0,
123
512, at->emft_buf + 512)))
127
(at->mft->data, at->emft_buf, at->mft->data->mft_size,
133
if (read_mft (at->mft->data, at->emft_buf,
134
u32at (at->attr_cur, 0x10)))
138
new_pos = &at->emft_buf[u16at (at->emft_buf, 0x14)];
139
while ((unsigned char) *new_pos != 0xFF)
141
if (((unsigned char) *new_pos ==
142
(unsigned char) *at->attr_cur)
143
&& (u16at (new_pos, 0xE) == u16at (at->attr_cur, 0x18)))
147
new_pos += u16at (new_pos, 4);
149
grub_error (GRUB_ERR_BAD_FS,
150
"can\'t find 0x%X in attribute list",
151
(unsigned char) *at->attr_cur);
157
at->attr_cur = at->attr_nxt;
158
while ((unsigned char) *at->attr_cur != 0xFF)
160
at->attr_nxt += u16at (at->attr_cur, 4);
161
if ((unsigned char) *at->attr_cur == AT_ATTRIBUTE_LIST)
162
at->attr_end = at->attr_cur;
163
if (((unsigned char) *at->attr_cur == attr) || (attr == 0))
165
at->attr_cur = at->attr_nxt;
171
at->emft_buf = grub_malloc (at->mft->data->mft_size << BLK_SHR);
172
if (at->emft_buf == NULL)
180
n = ((u32at (pa, 0x30) + GRUB_DISK_SECTOR_SIZE - 1)
181
& (~(GRUB_DISK_SECTOR_SIZE - 1)));
182
at->attr_cur = at->attr_end;
183
at->edat_buf = grub_malloc (n);
186
if (read_data (at, pa, at->edat_buf, 0, n, 0, 0))
188
grub_error (GRUB_ERR_BAD_FS,
189
"fail to read non-resident attribute list");
192
at->attr_nxt = at->edat_buf;
193
at->attr_end = at->edat_buf + u32at (pa, 0x30);
197
at->attr_nxt = at->attr_end + u16at (pa, 0x14);
198
at->attr_end = at->attr_end + u32at (pa, 4);
200
at->flags |= AF_ALST;
201
while (at->attr_nxt < at->attr_end)
203
if (((unsigned char) *at->attr_nxt == attr) || (attr == 0))
205
at->attr_nxt += u16at (at->attr_nxt, 4);
207
if (at->attr_nxt >= at->attr_end)
210
if ((at->flags & AF_MMFT) && (attr == AT_DATA))
212
at->flags |= AF_GPOS;
213
at->attr_cur = at->attr_nxt;
215
v32at (pa, 0x10) = at->mft->data->mft_start;
216
v32at (pa, 0x14) = at->mft->data->mft_start + 1;
217
pa = at->attr_nxt + u16at (pa, 4);
218
while (pa < at->attr_end)
220
if ((unsigned char) *pa != attr)
224
u32at (pa, 0x10) * (at->mft->data->mft_size << BLK_SHR),
225
at->mft->data->mft_size << BLK_SHR, 0, 0))
229
at->attr_nxt = at->attr_cur;
230
at->flags &= ~AF_GPOS;
238
locate_attr (struct grub_ntfs_attr *at, struct grub_ntfs_file *mft,
244
if ((pa = find_attr (at, attr)) == NULL)
246
if ((at->flags & AF_ALST) == 0)
250
if ((pa = find_attr (at, attr)) == NULL)
252
if (at->flags & AF_ALST)
255
grub_errno = GRUB_ERR_NONE;
258
pa = find_attr (at, attr);
264
read_run_data (char *run, int nn, grub_disk_addr_t * val, int sig)
266
grub_disk_addr_t r, v;
273
r += v * (*(unsigned char *) (run++));
277
if ((sig) && (r & (v >> 1)))
285
grub_ntfs_read_run_list (struct grub_ntfs_rlst * ctx)
288
grub_disk_addr_t val;
293
c1 = ((unsigned char) (*run) & 0xF);
294
c2 = ((unsigned char) (*run) >> 4);
297
if ((ctx->attr) && (ctx->attr->flags & AF_ALST))
299
void NESTED_FUNC_ATTR (*save_hook) (grub_disk_addr_t sector,
303
save_hook = ctx->comp.disk->read_hook;
304
ctx->comp.disk->read_hook = 0;
305
run = find_attr (ctx->attr, (unsigned char) *ctx->attr->attr_cur);
306
ctx->comp.disk->read_hook = save_hook;
310
return grub_error (GRUB_ERR_BAD_FS,
311
"$DATA should be non-resident");
313
run += u16at (run, 0x20);
318
return grub_error (GRUB_ERR_BAD_FS, "run list overflown");
320
run = read_run_data (run + 1, c1, &val, 0); /* length of current VCN */
321
ctx->curr_vcn = ctx->next_vcn;
322
ctx->next_vcn += val;
323
run = read_run_data (run, c2, &val, 1); /* offset to previous LCN */
324
ctx->curr_lcn += val;
326
ctx->flags |= RF_BLNK;
328
ctx->flags &= ~RF_BLNK;
333
static grub_disk_addr_t
334
grub_ntfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t block)
336
struct grub_ntfs_rlst *ctx;
338
ctx = (struct grub_ntfs_rlst *) node;
339
if (block >= ctx->next_vcn)
341
if (grub_ntfs_read_run_list (ctx))
343
return ctx->curr_lcn;
346
return (ctx->flags & RF_BLNK) ? 0 : (block -
347
ctx->curr_vcn + ctx->curr_lcn);
351
read_data (struct grub_ntfs_attr *at, char *pa, char *dest,
352
grub_disk_addr_t ofs, grub_size_t len, int cached,
353
void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
357
grub_disk_addr_t vcn;
358
struct grub_ntfs_rlst cc, *ctx;
363
grub_memset (&cc, 0, sizeof (cc));
366
ctx->comp.spc = at->mft->data->spc;
367
ctx->comp.disk = at->mft->data->disk;
371
if (ofs + len > u32at (pa, 0x10))
372
return grub_error (GRUB_ERR_BAD_FS, "read out of range");
373
grub_memcpy (dest, pa + u32at (pa, 0x14) + ofs, len);
377
if (u16at (pa, 0xC) & FLAG_COMPRESSED)
378
ctx->flags |= RF_COMP;
380
ctx->flags &= ~RF_COMP;
381
ctx->cur_run = pa + u16at (pa, 0x20);
383
if (ctx->flags & RF_COMP)
386
return grub_error (GRUB_ERR_BAD_FS, "attribute can\'t be compressed");
390
if ((ofs & (~(COM_LEN - 1))) == at->save_pos)
394
n = COM_LEN - (ofs - at->save_pos);
398
grub_memcpy (dest, at->sbuf + ofs - at->save_pos, n);
409
at->sbuf = grub_malloc (COM_LEN);
410
if (at->sbuf == NULL)
415
vcn = ctx->target_vcn = (ofs >> COM_LOG_LEN) * (COM_SEC / ctx->comp.spc);
416
ctx->target_vcn &= ~0xF;
419
vcn = ctx->target_vcn = grub_divmod64 (ofs >> BLK_SHR, ctx->comp.spc, 0);
421
ctx->next_vcn = u32at (pa, 0x10);
423
while (ctx->next_vcn <= ctx->target_vcn)
425
if (grub_ntfs_read_run_list (ctx))
429
if (at->flags & AF_GPOS)
431
grub_disk_addr_t st0, st1;
434
grub_divmod64 (ofs >> BLK_SHR, ctx->comp.spc, &m);
437
(ctx->target_vcn - ctx->curr_vcn + ctx->curr_lcn) * ctx->comp.spc + m;
440
(ctx->next_vcn - ctx->curr_vcn + ctx->curr_lcn) * ctx->comp.spc)
442
if (grub_ntfs_read_run_list (ctx))
444
st1 = ctx->curr_lcn * ctx->comp.spc;
446
v32at (dest, 0) = st0;
447
v32at (dest, 4) = st1;
451
if (!(ctx->flags & RF_COMP))
455
if (!grub_fshelp_log2blksize (ctx->comp.spc, &pow))
456
grub_fshelp_read_file (ctx->comp.disk, (grub_fshelp_node_t) ctx,
457
read_hook, ofs, len, dest,
458
grub_ntfs_read_block, ofs + len, pow);
462
return (grub_ntfscomp_func) ? grub_ntfscomp_func (at, dest, ofs, len, ctx,
464
grub_error (GRUB_ERR_BAD_FS, "ntfscomp module not loaded");
468
read_attr (struct grub_ntfs_attr *at, char *dest, grub_disk_addr_t ofs,
469
grub_size_t len, int cached,
470
void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
479
save_cur = at->attr_cur;
480
at->attr_nxt = at->attr_cur;
481
attr = (unsigned char) *at->attr_nxt;
482
if (at->flags & AF_ALST)
485
grub_disk_addr_t vcn;
487
vcn = grub_divmod64 (ofs, at->mft->data->spc << BLK_SHR, 0);
488
pa = at->attr_nxt + u16at (at->attr_nxt, 4);
489
while (pa < at->attr_end)
491
if ((unsigned char) *pa != attr)
493
if (u32at (pa, 8) > vcn)
499
pp = find_attr (at, attr);
501
ret = read_data (at, pp, dest, ofs, len, cached, read_hook);
504
(grub_errno) ? grub_errno : grub_error (GRUB_ERR_BAD_FS,
505
"attribute not found");
506
at->attr_cur = save_cur;
511
read_mft (struct grub_ntfs_data *data, char *buf, grub_uint32_t mftno)
514
(&data->mmft.attr, buf, mftno * ((grub_disk_addr_t) data->mft_size << BLK_SHR),
515
data->mft_size << BLK_SHR, 0, 0))
516
return grub_error (GRUB_ERR_BAD_FS, "read MFT 0x%X fails", mftno);
517
return fixup (data, buf, data->mft_size, "FILE");
521
init_file (struct grub_ntfs_file *mft, grub_uint32_t mftno)
527
mft->buf = grub_malloc (mft->data->mft_size << BLK_SHR);
528
if (mft->buf == NULL)
531
if (read_mft (mft->data, mft->buf, mftno))
534
flag = u16at (mft->buf, 0x16);
536
return grub_error (GRUB_ERR_BAD_FS, "MFT 0x%X is not in use", mftno);
542
pa = locate_attr (&mft->attr, mft, AT_DATA);
544
return grub_error (GRUB_ERR_BAD_FS, "no $DATA in MFT 0x%X", mftno);
547
mft->size = u32at (pa, 0x10);
549
mft->size = u64at (pa, 0x30);
551
if ((mft->attr.flags & AF_ALST) == 0)
552
mft->attr.attr_end = 0; /* Don't jump to attribute list */
555
init_attr (&mft->attr, mft);
561
free_file (struct grub_ntfs_file *mft)
563
free_attr (&mft->attr);
564
grub_free (mft->buf);
568
list_file (struct grub_ntfs_file *diro, char *pos,
570
(*hook) (const char *filename,
571
enum grub_fshelp_filetype filetype,
572
grub_fshelp_node_t node))
579
char *ustr, namespace;
581
if (pos[0xC] & 2) /* end signature */
585
ns = (unsigned char) *(np++);
589
* Ignore files in DOS namespace, as they will reappear as Win32
592
if ((ns) && (namespace != 2))
594
enum grub_fshelp_filetype type;
595
struct grub_ntfs_file *fdiro;
599
grub_error (GRUB_ERR_BAD_FS, "64-bit MFT number");
604
(u32at (pos, 0x48) & ATTR_DIRECTORY) ? GRUB_FSHELP_DIR :
607
fdiro = grub_zalloc (sizeof (struct grub_ntfs_file));
611
fdiro->data = diro->data;
612
fdiro->ino = u32at (pos, 0);
614
ustr = grub_malloc (ns * 4 + 1);
617
*grub_utf16_to_utf8 ((grub_uint8_t *) ustr, (grub_uint16_t *) np,
621
type |= GRUB_FSHELP_CASE_INSENSITIVE;
623
if (hook (ustr, type, fdiro))
631
pos += u16at (pos, 8);
637
grub_ntfs_iterate_dir (grub_fshelp_node_t dir,
639
(*hook) (const char *filename,
640
enum grub_fshelp_filetype filetype,
641
grub_fshelp_node_t node))
643
unsigned char *bitmap;
644
struct grub_ntfs_attr attr, *at;
645
char *cur_pos, *indx, *bmp;
647
grub_size_t bitmap_len;
648
struct grub_ntfs_file *mft;
650
mft = (struct grub_ntfs_file *) dir;
652
if (!mft->inode_read)
654
if (init_file (mft, mft->ino))
665
if ((cur_pos = find_attr (at, AT_INDEX_ROOT)) == NULL)
667
grub_error (GRUB_ERR_BAD_FS, "no $INDEX_ROOT");
671
/* Resident, Namelen=4, Offset=0x18, Flags=0x00, Name="$I30" */
672
if ((u32at (cur_pos, 8) != 0x180400) ||
673
(u32at (cur_pos, 0x18) != 0x490024) ||
674
(u32at (cur_pos, 0x1C) != 0x300033))
676
cur_pos += u16at (cur_pos, 0x14);
677
if (*cur_pos != 0x30) /* Not filename index */
682
cur_pos += 0x10; /* Skip index root */
683
ret = list_file (mft, cur_pos + u16at (cur_pos, 0), hook);
691
while ((cur_pos = find_attr (at, AT_BITMAP)) != NULL)
695
ofs = (unsigned char) cur_pos[0xA];
696
/* Namelen=4, Name="$I30" */
697
if ((cur_pos[9] == 4) &&
698
(u32at (cur_pos, ofs) == 0x490024) &&
699
(u32at (cur_pos, ofs + 4) == 0x300033))
701
int is_resident = (cur_pos[8] == 0);
703
bitmap_len = ((is_resident) ? u32at (cur_pos, 0x10) :
704
u32at (cur_pos, 0x28));
706
bmp = grub_malloc (bitmap_len);
712
grub_memcpy (bmp, (char *) (cur_pos + u16at (cur_pos, 0x14)),
717
if (read_data (at, cur_pos, bmp, 0, bitmap_len, 0, 0))
719
grub_error (GRUB_ERR_BAD_FS,
720
"fails to read non-resident $BITMAP");
723
bitmap_len = u32at (cur_pos, 0x30);
726
bitmap = (unsigned char *) bmp;
732
cur_pos = locate_attr (at, mft, AT_INDEX_ALLOCATION);
733
while (cur_pos != NULL)
735
/* Non-resident, Namelen=4, Offset=0x40, Flags=0, Name="$I30" */
736
if ((u32at (cur_pos, 8) == 0x400401) &&
737
(u32at (cur_pos, 0x40) == 0x490024) &&
738
(u32at (cur_pos, 0x44) == 0x300033))
740
cur_pos = find_attr (at, AT_INDEX_ALLOCATION);
743
if ((!cur_pos) && (bitmap))
745
grub_error (GRUB_ERR_BAD_FS, "$BITMAP without $INDEX_ALLOCATION");
751
grub_disk_addr_t v, i;
753
indx = grub_malloc (mft->data->idx_size << BLK_SHR);
758
for (i = 0; i < (grub_disk_addr_t)bitmap_len * 8; i++)
763
(at, indx, i * (mft->data->idx_size << BLK_SHR),
764
(mft->data->idx_size << BLK_SHR), 0, 0))
765
|| (fixup (mft->data, indx, mft->data->idx_size, "INDX")))
767
ret = list_file (mft, &indx[0x18 + u16at (indx, 0x18)], hook);
788
static struct grub_ntfs_data *
789
grub_ntfs_mount (grub_disk_t disk)
791
struct grub_ntfs_bpb bpb;
792
struct grub_ntfs_data *data = 0;
797
data = (struct grub_ntfs_data *) grub_zalloc (sizeof (*data));
804
if (grub_disk_read (disk, 0, 0, sizeof (bpb), &bpb))
807
if (grub_memcmp ((char *) &bpb.oem_name, "NTFS", 4))
810
data->blocksize = grub_le_to_cpu16 (bpb.bytes_per_sector);
811
data->spc = bpb.sectors_per_cluster * (data->blocksize >> BLK_SHR);
813
if (bpb.clusters_per_mft > 0)
814
data->mft_size = data->spc * bpb.clusters_per_mft;
816
data->mft_size = 1 << (-bpb.clusters_per_mft - BLK_SHR);
818
if (bpb.clusters_per_index > 0)
819
data->idx_size = data->spc * bpb.clusters_per_index;
821
data->idx_size = 1 << (-bpb.clusters_per_index - BLK_SHR);
823
data->mft_start = grub_le_to_cpu64 (bpb.mft_lcn) * data->spc;
825
if ((data->mft_size > MAX_MFT) || (data->idx_size > MAX_IDX))
828
data->mmft.data = data;
829
data->cmft.data = data;
831
data->mmft.buf = grub_malloc (data->mft_size << BLK_SHR);
836
(disk, data->mft_start, 0, data->mft_size << BLK_SHR, data->mmft.buf))
839
data->uuid = grub_le_to_cpu64 (bpb.num_serial);
841
if (fixup (data, data->mmft.buf, data->mft_size, "FILE"))
844
if (!locate_attr (&data->mmft.attr, &data->mmft, AT_DATA))
847
if (init_file (&data->cmft, FILE_ROOT))
853
grub_error (GRUB_ERR_BAD_FS, "not an ntfs filesystem");
857
free_file (&data->mmft);
858
free_file (&data->cmft);
865
grub_ntfs_dir (grub_device_t device, const char *path,
866
int (*hook) (const char *filename,
867
const struct grub_dirhook_info *info))
869
struct grub_ntfs_data *data = 0;
870
struct grub_fshelp_node *fdiro = 0;
872
auto int NESTED_FUNC_ATTR iterate (const char *filename,
873
enum grub_fshelp_filetype filetype,
874
grub_fshelp_node_t node);
876
int NESTED_FUNC_ATTR iterate (const char *filename,
877
enum grub_fshelp_filetype filetype,
878
grub_fshelp_node_t node)
880
struct grub_dirhook_info info;
881
grub_memset (&info, 0, sizeof (info));
882
info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
884
return hook (filename, &info);
887
grub_dl_ref (my_mod);
889
data = grub_ntfs_mount (device->disk);
893
grub_fshelp_find_file (path, &data->cmft, &fdiro, grub_ntfs_iterate_dir,
899
grub_ntfs_iterate_dir (fdiro, iterate);
902
if ((fdiro) && (fdiro != &data->cmft))
909
free_file (&data->mmft);
910
free_file (&data->cmft);
914
grub_dl_unref (my_mod);
920
grub_ntfs_open (grub_file_t file, const char *name)
922
struct grub_ntfs_data *data = 0;
923
struct grub_fshelp_node *mft = 0;
925
grub_dl_ref (my_mod);
927
data = grub_ntfs_mount (file->device->disk);
931
grub_fshelp_find_file (name, &data->cmft, &mft, grub_ntfs_iterate_dir,
937
if (mft != &data->cmft)
939
free_file (&data->cmft);
940
grub_memcpy (&data->cmft, mft, sizeof (*mft));
942
if (!data->cmft.inode_read)
944
if (init_file (&data->cmft, data->cmft.ino))
949
file->size = data->cmft.size;
958
free_file (&data->mmft);
959
free_file (&data->cmft);
963
grub_dl_unref (my_mod);
969
grub_ntfs_read (grub_file_t file, char *buf, grub_size_t len)
971
struct grub_ntfs_file *mft;
973
mft = &((struct grub_ntfs_data *) file->data)->cmft;
975
mft->attr.save_pos = 1;
977
read_attr (&mft->attr, buf, file->offset, len, 1, file->read_hook);
978
return (grub_errno) ? 0 : len;
982
grub_ntfs_close (grub_file_t file)
984
struct grub_ntfs_data *data;
990
free_file (&data->mmft);
991
free_file (&data->cmft);
995
grub_dl_unref (my_mod);
1001
grub_ntfs_label (grub_device_t device, char **label)
1003
struct grub_ntfs_data *data = 0;
1004
struct grub_fshelp_node *mft = 0;
1007
grub_dl_ref (my_mod);
1011
data = grub_ntfs_mount (device->disk);
1015
grub_fshelp_find_file ("/$Volume", &data->cmft, &mft, grub_ntfs_iterate_dir,
1016
0, GRUB_FSHELP_REG);
1021
if (!mft->inode_read)
1023
mft->buf = grub_malloc (mft->data->mft_size << BLK_SHR);
1024
if (mft->buf == NULL)
1027
if (read_mft (mft->data, mft->buf, mft->ino))
1031
init_attr (&mft->attr, mft);
1032
pa = find_attr (&mft->attr, AT_VOLUME_NAME);
1033
if ((pa) && (pa[8] == 0) && (u32at (pa, 0x10)))
1038
len = u32at (pa, 0x10) / 2;
1039
buf = grub_malloc (len * 4 + 1);
1040
pa += u16at (pa, 0x14);
1041
*grub_utf16_to_utf8 ((grub_uint8_t *) buf, (grub_uint16_t *) pa, len) =
1047
if ((mft) && (mft != &data->cmft))
1054
free_file (&data->mmft);
1055
free_file (&data->cmft);
1059
grub_dl_unref (my_mod);
1065
grub_ntfs_uuid (grub_device_t device, char **uuid)
1067
struct grub_ntfs_data *data;
1068
grub_disk_t disk = device->disk;
1070
grub_dl_ref (my_mod);
1072
data = grub_ntfs_mount (disk);
1076
*uuid = grub_xasprintf ("%016llx", (unsigned long long) data->uuid);
1078
for (ptr = *uuid; *ptr; ptr++)
1079
*ptr = grub_toupper (*ptr);
1084
grub_dl_unref (my_mod);
1091
static struct grub_fs grub_ntfs_fs =
1094
.dir = grub_ntfs_dir,
1095
.open = grub_ntfs_open,
1096
.read = grub_ntfs_read,
1097
.close = grub_ntfs_close,
1098
.label = grub_ntfs_label,
1099
.uuid = grub_ntfs_uuid,
1101
.reserved_first_sector = 1,
1106
GRUB_MOD_INIT (ntfs)
1108
grub_fs_register (&grub_ntfs_fs);
1112
GRUB_MOD_FINI (ntfs)
1114
grub_fs_unregister (&grub_ntfs_fs);