/* cpio.c - cpio and tar 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+");
#ifdef MODE_ODC
#define ALIGN_CPIO(x) x
struct head
{
} __attribute__ ((packed));
struct head
{
} __attribute__ ((packed));
#elif !defined (MODE_USTAR)
/* cpio support */
#ifdef MODE_BIGENDIAN
#else
#endif
struct head
{
} __attribute__ ((packed));
#else
/* tar support */
struct head
{
char typeflag;
} __attribute__ ((packed));
#endif
struct grub_cpio_data
{
#ifdef MODE_USTAR
char *linkname;
#endif
};
static inline void
{
{
while (*iptr == '/')
iptr++;
{
iptr += 2;
continue;
}
if (*iptr)
}
*optr = 0;
}
#if defined (MODE_ODC) || defined (MODE_USTAR)
static inline unsigned long long
{
unsigned long long ret = 0;
return ret;
}
static inline unsigned long long
{
unsigned long long ret = 0;
{
dig &= 0xf;
else
}
return ret;
}
#else
static inline unsigned long long
{
long long ret = 0;
#ifdef MODE_BIGENDIAN
while (size--)
#else
while (size--)
#endif
return ret;
}
#endif
static grub_err_t
{
#ifndef MODE_USTAR
return grub_errno;
#ifdef MAGIC2
#endif
)
if (mtime)
if (mode)
return grub_errno;
{
return grub_errno;
}
{
*ofs = 0;
return GRUB_ERR_NONE;
}
canonicalize (*name);
#else
{
return grub_errno;
{
*ofs = 0;
return GRUB_ERR_NONE;
}
{
return grub_errno;
*name);
if (err)
return err;
~(GRUB_DISK_SECTOR_SIZE - 1));
have_longname = 1;
continue;
}
{
{
char *n;
if (!n)
return grub_errno;
}
if (err)
return err;
~(GRUB_DISK_SECTOR_SIZE - 1));
have_longlink = 1;
continue;
}
if (!have_longname)
{
return grub_errno;
}
~(GRUB_DISK_SECTOR_SIZE - 1));
if (mtime)
if (mode)
{
{
case '2':
break;
case '0':
break;
case '5':
break;
}
}
if (!have_longlink)
{
{
char *n;
n = grub_malloc (101);
if (!n)
return grub_errno;
}
}
canonicalize (*name);
return GRUB_ERR_NONE;
}
#endif
return GRUB_ERR_NONE;
}
static struct grub_cpio_data *
{
goto fail;
#ifdef MAGIC2
#endif
)
goto fail;
if (!data)
goto fail;
return data;
fail:
#ifdef MODE_USTAR
"tar"
#else
"cpio"
#endif
" filesystem");
return 0;
}
static grub_err_t
{
char *target;
#ifndef MODE_USTAR
#endif
char *ptr;
char *lastslash;
char *rest;
*restart = 0;
return GRUB_ERR_NONE;
return GRUB_ERR_NONE;
if (*rest)
rest++;
lastslash--;
else
prefixlen = 0;
if (prefixlen)
prefixlen++;
#ifdef MODE_USTAR
#else
#endif
if (size == 0)
return GRUB_ERR_NONE;
if (!target)
return grub_errno;
#ifdef MODE_USTAR
#else
if (err)
return err;
#endif
{
*ptr = 0;
*restart = 1;
return GRUB_ERR_NONE;
}
if (prefixlen)
{
}
*ptr = 0;
*restart = 1;
return GRUB_ERR_NONE;
}
static grub_err_t
const struct grub_dirhook_info *info))
{
int symlinknest = 0;
if (!path)
return grub_errno;
*ptr = 0;
prev = 0;
if (!data)
{
return grub_errno;
}
while (1)
{
goto fail;
if (!ofs)
break;
{
char *p, *n;
while (*n == '/')
n++;
p = grub_strchr (n, '/');
if (p)
*p = 0;
{
goto fail;
}
else
{
int restart;
if (err)
goto fail;
if (restart)
{
if (++symlinknest == 8)
{
"too deep nesting of symlinks");
goto fail;
}
ofs = 0;
}
}
}
else
}
fail:
#ifdef MODE_USTAR
#endif
return grub_errno;
}
static grub_err_t
{
char *fn;
int symlinknest = 0;
if (!name)
return grub_errno;
if (!data)
{
return grub_errno;
}
while (1)
{
int restart;
goto fail;
if (!ofs)
{
break;
}
{
goto fail;
}
if (restart)
{
ofs = 0;
if (++symlinknest == 8)
{
"too deep nesting of symlinks");
goto fail;
}
goto no_match;
}
goto no_match;
return GRUB_ERR_NONE;
}
fail:
#ifdef MODE_USTAR
#endif
return grub_errno;
}
static grub_ssize_t
{
}
static grub_err_t
{
#ifdef MODE_USTAR
#endif
return grub_errno;
}
#ifdef MODE_USTAR
.name = "tarfs",
.name = "odc",
.name = "newc",
#else
.name = "cpiofs",
#endif
.dir = grub_cpio_dir,
.open = grub_cpio_open,
.read = grub_cpio_read,
.close = grub_cpio_close,
#ifdef GRUB_UTIL
.reserved_first_sector = 0,
#endif
};
#ifdef MODE_USTAR
#elif defined (MODE_BIGENDIAN)
#else
#endif
{
}
#ifdef MODE_USTAR
#elif defined (MODE_BIGENDIAN)
#else
#endif
{
}