* include/grub/ntfs.h: Add GRUB_NTFS_ prefix. All users updated.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-10-27 02:59:45 +02:00
parent 3be82e10a9
commit 91c3fdde0d
4 changed files with 181 additions and 156 deletions

View file

@ -21,7 +21,6 @@
#include <grub/misc.h>
#include <grub/disk.h>
#include <grub/dl.h>
#include <grub/fshelp.h>
#include <grub/ntfs.h>
GRUB_MOD_LICENSE ("GPLv3+");
@ -35,7 +34,7 @@ decomp_nextvcn (struct grub_ntfs_comp *cc)
(cc->disk,
(cc->comp_table[cc->comp_head][1] -
(cc->comp_table[cc->comp_head][0] - cc->cbuf_vcn)) * cc->spc, 0,
cc->spc << BLK_SHR, cc->cbuf))
cc->spc << GRUB_NTFS_BLK_SHR, cc->cbuf))
return grub_errno;
cc->cbuf_vcn++;
if ((cc->cbuf_vcn >= cc->comp_table[cc->comp_head][0]))
@ -47,7 +46,7 @@ decomp_nextvcn (struct grub_ntfs_comp *cc)
static grub_err_t
decomp_getch (struct grub_ntfs_comp *cc, unsigned char *res)
{
if (cc->cbuf_ofs >= (cc->spc << BLK_SHR))
if (cc->cbuf_ofs >= (cc->spc << GRUB_NTFS_BLK_SHR))
{
if (decomp_nextvcn (cc))
return grub_errno;
@ -87,7 +86,7 @@ decomp_block (struct grub_ntfs_comp *cc, char *dest)
bits = copied = tag = 0;
while (cnt > 0)
{
if (copied > COM_LEN)
if (copied > GRUB_NTFS_COM_LEN)
return grub_error (GRUB_ERR_BAD_FS,
"compression block too large");
@ -150,7 +149,7 @@ decomp_block (struct grub_ntfs_comp *cc, char *dest)
}
else
{
if (cnt != COM_LEN)
if (cnt != GRUB_NTFS_COM_LEN)
return grub_error (GRUB_ERR_BAD_FS,
"invalid compression block size");
}
@ -160,7 +159,7 @@ decomp_block (struct grub_ntfs_comp *cc, char *dest)
{
int n;
n = (cc->spc << BLK_SHR) - cc->cbuf_ofs;
n = (cc->spc << GRUB_NTFS_BLK_SHR) - cc->cbuf_ofs;
if (n > cnt)
n = cnt;
if ((dest) && (n))
@ -179,7 +178,7 @@ decomp_block (struct grub_ntfs_comp *cc, char *dest)
static grub_err_t
read_block (struct grub_ntfs_rlst *ctx, char *buf, int num)
{
int cpb = COM_SEC / ctx->comp.spc;
int cpb = GRUB_NTFS_COM_SEC / ctx->comp.spc;
while (num)
{
@ -192,7 +191,7 @@ read_block (struct grub_ntfs_rlst *ctx, char *buf, int num)
return grub_error (GRUB_ERR_BAD_FS, "invalid compression block");
ctx->comp.comp_head = ctx->comp.comp_tail = 0;
ctx->comp.cbuf_vcn = ctx->target_vcn;
ctx->comp.cbuf_ofs = (ctx->comp.spc << BLK_SHR);
ctx->comp.cbuf_ofs = (ctx->comp.spc << GRUB_NTFS_BLK_SHR);
if (ctx->target_vcn >= ctx->next_vcn)
{
if (grub_ntfs_read_run_list (ctx))
@ -200,7 +199,7 @@ read_block (struct grub_ntfs_rlst *ctx, char *buf, int num)
}
while (ctx->target_vcn + 16 > ctx->next_vcn)
{
if (ctx->flags & RF_BLNK)
if (ctx->flags & GRUB_NTFS_RF_BLNK)
break;
ctx->comp.comp_table[ctx->comp.comp_tail][0] = ctx->next_vcn;
ctx->comp.comp_table[ctx->comp.comp_tail][1] =
@ -216,15 +215,15 @@ read_block (struct grub_ntfs_rlst *ctx, char *buf, int num)
nn = num;
num -= nn;
if (ctx->flags & RF_BLNK)
if (ctx->flags & GRUB_NTFS_RF_BLNK)
{
ctx->target_vcn += nn * cpb;
if (ctx->comp.comp_tail == 0)
{
if (buf)
{
grub_memset (buf, 0, nn * COM_LEN);
buf += nn * COM_LEN;
grub_memset (buf, 0, nn * GRUB_NTFS_COM_LEN);
buf += nn * GRUB_NTFS_COM_LEN;
}
}
else
@ -234,7 +233,7 @@ read_block (struct grub_ntfs_rlst *ctx, char *buf, int num)
if (decomp_block (&ctx->comp, buf))
return grub_errno;
if (buf)
buf += COM_LEN;
buf += GRUB_NTFS_COM_LEN;
nn--;
}
}
@ -259,9 +258,9 @@ read_block (struct grub_ntfs_rlst *ctx, char *buf, int num)
(ctx->comp.comp_table[ctx->comp.comp_head][1] -
(ctx->comp.comp_table[ctx->comp.comp_head][0] -
ctx->target_vcn)) * ctx->comp.spc, 0,
tt * (ctx->comp.spc << BLK_SHR), buf))
tt * (ctx->comp.spc << GRUB_NTFS_BLK_SHR), buf))
return grub_errno;
buf += tt * (ctx->comp.spc << BLK_SHR);
buf += tt * (ctx->comp.spc << GRUB_NTFS_BLK_SHR);
}
nn -= tt;
if (ctx->target_vcn >=
@ -276,9 +275,9 @@ read_block (struct grub_ntfs_rlst *ctx, char *buf, int num)
(ctx->comp.disk,
(ctx->target_vcn - ctx->curr_vcn +
ctx->curr_lcn) * ctx->comp.spc, 0,
nn * (ctx->comp.spc << BLK_SHR), buf))
nn * (ctx->comp.spc << GRUB_NTFS_BLK_SHR), buf))
return grub_errno;
buf += nn * (ctx->comp.spc << BLK_SHR);
buf += nn * (ctx->comp.spc << GRUB_NTFS_BLK_SHR);
}
ctx->target_vcn += nn;
}
@ -294,7 +293,7 @@ ntfscomp (struct grub_ntfs_attr *at, char *dest, grub_uint32_t ofs,
grub_err_t ret;
ctx->comp.comp_head = ctx->comp.comp_tail = 0;
ctx->comp.cbuf = grub_malloc ((ctx->comp.spc) << BLK_SHR);
ctx->comp.cbuf = grub_malloc ((ctx->comp.spc) << GRUB_NTFS_BLK_SHR);
if (!ctx->comp.cbuf)
return 0;
@ -304,17 +303,17 @@ ntfscomp (struct grub_ntfs_attr *at, char *dest, grub_uint32_t ofs,
if ((vcn > ctx->target_vcn) &&
(read_block
(ctx, NULL, ((vcn - ctx->target_vcn) * ctx->comp.spc) / COM_SEC)))
(ctx, NULL, ((vcn - ctx->target_vcn) * ctx->comp.spc) / GRUB_NTFS_COM_SEC)))
{
ret = grub_errno;
goto quit;
}
if (ofs % COM_LEN)
if (ofs % GRUB_NTFS_COM_LEN)
{
grub_uint32_t t, n, o;
t = ctx->target_vcn * (ctx->comp.spc << BLK_SHR);
t = ctx->target_vcn * (ctx->comp.spc << GRUB_NTFS_BLK_SHR);
if (read_block (ctx, at->sbuf, 1))
{
ret = grub_errno;
@ -323,8 +322,8 @@ ntfscomp (struct grub_ntfs_attr *at, char *dest, grub_uint32_t ofs,
at->save_pos = t;
o = ofs % COM_LEN;
n = COM_LEN - o;
o = ofs % GRUB_NTFS_COM_LEN;
n = GRUB_NTFS_COM_LEN - o;
if (n > len)
n = len;
grub_memcpy (dest, &at->sbuf[o], n);
@ -334,19 +333,19 @@ ntfscomp (struct grub_ntfs_attr *at, char *dest, grub_uint32_t ofs,
len -= n;
}
if (read_block (ctx, dest, len / COM_LEN))
if (read_block (ctx, dest, len / GRUB_NTFS_COM_LEN))
{
ret = grub_errno;
goto quit;
}
dest += (len / COM_LEN) * COM_LEN;
len = len % COM_LEN;
dest += (len / GRUB_NTFS_COM_LEN) * GRUB_NTFS_COM_LEN;
len = len % GRUB_NTFS_COM_LEN;
if (len)
{
grub_uint32_t t;
t = ctx->target_vcn * (ctx->comp.spc << BLK_SHR);
t = ctx->target_vcn * (ctx->comp.spc << GRUB_NTFS_BLK_SHR);
if (read_block (ctx, at->sbuf, 1))
{
ret = grub_errno;