/* ntfscomp.c - compression support for the NTFS filesystem */
/*
* Copyright (C) 2007 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 grub_err_t
{
if (grub_disk_read
return grub_errno;
return 0;
}
static grub_err_t
{
{
if (decomp_nextvcn (cc))
return grub_errno;
}
return 0;
}
static grub_err_t
{
return grub_errno;
return 0;
}
/* Decompress a block (4096 bytes) */
static grub_err_t
{
return grub_errno;
if (dest)
{
if (flg & 0x8000)
{
unsigned char tag;
while (cnt > 0)
{
if (copied > GRUB_NTFS_COM_LEN)
return grub_error (GRUB_ERR_BAD_FS,
"compression block too large");
if (!bits)
{
return grub_errno;
bits = 8;
cnt--;
if (cnt <= 0)
break;
}
if (tag & 1)
{
return grub_errno;
cnt -= 2;
if (!copied)
{
return 0;
}
i >>= 1)
{
lmask >>= 1;
dshift--;
}
for (i = 0; i < len; i++)
{
copied++;
}
}
else
{
unsigned char ch = 0;
return grub_errno;
cnt--;
}
tag >>= 1;
bits--;
}
return 0;
}
else
{
if (cnt != GRUB_NTFS_COM_LEN)
return grub_error (GRUB_ERR_BAD_FS,
"invalid compression block size");
}
}
while (cnt > 0)
{
int n;
if (n > cnt)
n = cnt;
if ((dest) && (n))
{
dest += n;
}
cnt -= n;
return grub_errno;
}
return 0;
}
static grub_err_t
{
while (num)
{
int nn;
{
{
if (grub_ntfs_read_run_list (ctx))
return grub_errno;
}
{
break;
if (grub_ntfs_read_run_list (ctx))
return grub_errno;
}
}
{
{
if (buf)
{
}
}
else
{
while (nn)
{
return grub_errno;
if (buf)
buf += GRUB_NTFS_COM_LEN;
nn--;
}
}
}
else
{
{
int tt;
tt =
if (buf)
{
if (grub_disk_read
return grub_errno;
}
if (ctx->target_vcn >=
}
if (nn)
{
if (buf)
{
if (grub_disk_read
return grub_errno;
}
}
}
}
return 0;
}
static grub_err_t
{
return 0;
ret = 0;
//ctx->comp.disk->read_hook = read_hook;
{
ret = grub_errno;
goto quit;
}
if (ofs % GRUB_NTFS_COM_LEN)
{
grub_uint32_t t, n, o;
{
ret = grub_errno;
goto quit;
}
o = ofs % GRUB_NTFS_COM_LEN;
n = GRUB_NTFS_COM_LEN - o;
if (n > len)
n = len;
if (n == len)
goto quit;
dest += n;
len -= n;
}
{
ret = grub_errno;
goto quit;
}
if (len)
{
{
ret = grub_errno;
goto quit;
}
}
quit:
//ctx->comp.disk->read_hook = 0;
return ret;
}
{
}
{
}