/* ntfs.c - NTFS filesystem */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
GRUB_MOD_LICENSE ("GPLv3+");
static inline grub_uint16_t
{
}
static inline grub_uint32_t
{
}
static inline grub_uint64_t
{
}
static grub_err_t
{
int ss;
char *pu;
buf -= 2;
while (ss > 0)
{
pu += 2;
ss--;
}
return 0;
}
int cached,
void
unsigned offset,
unsigned length));
int cached,
void
unsigned offset,
unsigned length));
static void
{
}
static void
{
}
static char *
{
{
{
{
char *new_pos;
{
if ((grub_disk_read
||
return NULL;
if (fixup
"FILE"))
return NULL;
}
else
{
return NULL;
}
while ((unsigned char) *new_pos != 0xFF)
{
if (((unsigned char) *new_pos ==
{
return new_pos;
}
}
"can\'t find 0x%X in attribute list",
return NULL;
}
}
return NULL;
}
{
}
{
char *pa;
return NULL;
if (pa[8])
{
int n;
& (~(GRUB_DISK_SECTOR_SIZE - 1)));
return NULL;
{
"fail to read non-resident attribute list");
return NULL;
}
}
else
{
}
{
break;
}
return NULL;
{
+ 1));
{
break;
if (read_attr
return NULL;
}
}
goto retry;
}
return NULL;
}
static char *
unsigned char attr)
{
char *pa;
return NULL;
{
while (1)
{
break;
return pa;
}
}
return pa;
}
static char *
{
grub_disk_addr_t r, v;
r = 0;
v = 1;
while (nn--)
{
r += v * (*(unsigned char *) (run++));
v <<= 8;
}
if ((sig) && (r & (v >> 1)))
r -= v;
*val = r;
return run;
}
{
char *run;
if (!c1)
{
{
unsigned offset,
unsigned length);
if (run)
{
if (run[8] == 0)
return grub_error (GRUB_ERR_BAD_FS,
"$DATA should be non-resident");
goto retry;
}
}
}
if (val == 0)
else
return 0;
}
static grub_disk_addr_t
{
{
if (grub_ntfs_read_run_list (ctx))
return -1;
}
else
}
static grub_err_t
unsigned offset,
unsigned length))
{
if (len == 0)
return 0;
if (pa[8] == 0)
{
return 0;
}
else
{
if (!cached)
{
{
if (n > len)
n = len;
if (n == len)
return 0;
dest += n;
len -= n;
ofs += n;
}
}
else
{
return grub_errno;
}
}
else
{
if (grub_ntfs_read_run_list (ctx))
return grub_errno;
}
{
st0 =
if (st1 ==
{
if (grub_ntfs_read_run_list (ctx))
return grub_errno;
}
return 0;
}
{
unsigned int pow;
return grub_errno;
}
vcn) :
}
static grub_err_t
unsigned offset,
unsigned length))
{
char *save_cur;
unsigned char attr;
char *pp;
{
char *pa;
{
break;
break;
}
}
if (pp)
else
ret =
"attribute not found");
return ret;
}
static grub_err_t
{
if (read_attr
}
static grub_err_t
{
unsigned short flag;
return grub_errno;
return grub_errno;
if ((flag & 1) == 0)
if ((flag & 2) == 0)
{
char *pa;
if (!pa[8])
else
}
else
return 0;
}
static void
{
}
static int
int NESTED_FUNC_ATTR
enum grub_fshelp_filetype filetype,
{
char *np;
int ns;
while (1)
{
break;
/*
* Ignore files in DOS namespace, as they will reappear as Win32
* names.
*/
{
{
return 0;
}
if (attr & GRUB_NTFS_ATTR_REPARSE)
else if (attr & GRUB_NTFS_ATTR_DIRECTORY)
else
if (!fdiro)
return 0;
else
return 0;
{
int i;
for (i = 0; i < ns; i++)
+ 2 * i));
}
if (namespace)
{
return 1;
}
}
}
return 0;
}
struct symlink_descriptor
{
} __attribute__ ((packed));
static char *
{
grub_size_t i;
char *pa;
return NULL;
return NULL;
{
return NULL;
}
sizeof (struct symlink_descriptor), 1, 0);
if (err)
return NULL;
{
case 0xa000000c:
break;
case 0xa0000003:
off = (sizeof (struct symlink_descriptor)
break;
default:
return NULL;
}
if (!buf16)
return NULL;
if (err)
return NULL;
if (!buf)
{
return NULL;
}
for (i = 0; i < len / 2; i++)
{
if (buf16[i] == '\\')
buf16[i] = '/';
}
*end = '\0';
/* Split the sequence to avoid GCC thinking that this is a trigraph. */
{
end -= 6;
}
return buf;
}
static int
int NESTED_FUNC_ATTR
enum grub_fshelp_filetype filetype,
{
unsigned char *bitmap;
int ret = 0;
if (!mft->inode_read)
{
return 0;
}
while (1)
{
{
goto done;
}
/* Resident, Namelen=4, Offset=0x18, Flags=0x00, Name="$I30" */
continue;
continue;
break;
}
if (ret)
goto done;
bitmap_len = 0;
{
int ofs;
/* Namelen=4, Name="$I30" */
{
goto done;
if (is_resident)
{
}
else
{
{
"fails to read non-resident $BITMAP");
goto done;
}
}
break;
}
}
{
/* Non-resident, Namelen=4, Offset=0x40, Flags=0, Name="$I30" */
break;
}
{
goto done;
}
if (bitmap)
{
grub_disk_addr_t v, i;
goto done;
v = 1;
{
if (*bitmap & v)
{
if ((read_attr
goto done;
if (ret)
goto done;
}
v <<= 1;
if (v >= 0x100)
{
v = 1;
bitmap++;
}
}
}
done:
return ret;
}
static struct grub_ntfs_data *
{
if (!disk)
goto fail;
if (!data)
goto fail;
/* Read the BPB. */
goto fail;
goto fail;
if (bpb.clusters_per_mft > 0)
else
if (bpb.clusters_per_index > 0)
else
goto fail;
goto fail;
if (grub_disk_read
goto fail;
goto fail;
goto fail;
goto fail;
return data;
fail:
if (data)
{
}
return 0;
}
static grub_err_t
const struct grub_dirhook_info *info))
{
enum grub_fshelp_filetype filetype,
enum grub_fshelp_filetype filetype,
{
- 86400ULL * 365 * (1970 - 1601)
- 86400ULL * ((1970 - 1601) / 4) + 86400ULL * ((1970 - 1601) / 100);
}
if (!data)
goto fail;
if (grub_errno)
goto fail;
fail:
{
}
if (data)
{
}
return grub_errno;
}
static grub_err_t
{
if (!data)
goto fail;
if (grub_errno)
goto fail;
{
{
goto fail;
}
}
return 0;
fail:
if (data)
{
}
return grub_errno;
}
static grub_ssize_t
{
return (grub_errno) ? 0 : len;
}
static grub_err_t
{
if (data)
{
}
return grub_errno;
}
static grub_err_t
{
char *pa;
*label = 0;
if (!data)
goto fail;
0, GRUB_FSHELP_REG);
if (grub_errno)
goto fail;
if (!mft->inode_read)
{
goto fail;
goto fail;
}
{
char *buf;
int len;
{
int i;
for (i = 0; i < len; i++)
'\0';
}
}
fail:
{
}
if (data)
{
}
return grub_errno;
}
static grub_err_t
{
if (data)
{
char *ptr;
if (*uuid)
}
else
return grub_errno;
}
{
.name = "ntfs",
.dir = grub_ntfs_dir,
.open = grub_ntfs_open,
.read = grub_ntfs_read,
.close = grub_ntfs_close,
.label = grub_ntfs_label,
.uuid = grub_ntfs_uuid,
#ifdef GRUB_UTIL
.reserved_first_sector = 1,
#endif
.next = 0
};
{
}
{
}