/* affs.c - Amiga Fast FileSystem. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005,2006,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.
*
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
GRUB_MOD_LICENSE ("GPLv3+");
/* The affs bootblock. */
struct grub_affs_bblock
{
} __attribute__ ((packed));
/* Set if the filesystem is a AFFS filesystem. Otherwise this is an
OFS filesystem. */
/* The affs rootblock. */
struct grub_affs_rblock
{
} __attribute__ ((packed));
struct grub_affs_time
{
} __attribute__ ((packed));
/* The second part of a file header block. */
struct grub_affs_file
{
} __attribute__ ((packed));
/* The location of `struct grub_affs_file' relative to the end of a
file header block. */
/* The offset in both the rootblock and the file header block for the
hashtable, symlink and block pointers (all synonyms). */
struct grub_fshelp_node
{
};
/* Information about a "mounted" affs filesystem. */
struct grub_affs_data
{
/* Blocksize in sectors. */
int blocksize;
/* The number of entries in the hashtable. */
int htsize;
};
static grub_disk_addr_t
{
if (!node->block_cache)
{
* sizeof (node->block_cache[0]));
if (!node->block_cache)
return -1;
node->last_block_cache = 0;
}
/* Files are at most 2G on AFFS, so no need for 64-bit division. */
/* Find the block that points to the fileblock we are looking up by
following the chain until the right table is reached. */
{
if (grub_errno)
return 0;
}
/* Translate the fileblock to the block within the right table. */
if (grub_errno)
return 0;
return grub_be_to_cpu32 (pos);
}
static struct grub_affs_data *
{
int checksum = 0;
int blocksize = 0;
if (!data)
return 0;
/* Read the bootblock. */
if (grub_errno)
goto fail;
/* Make sure this is an affs filesystem. */
{
goto fail;
}
/* Test if the filesystem is a OFS filesystem. */
{
goto fail;
}
/* No sane person uses more than 8KB for a block. At least I hope
for that person because in that case this won't work. */
if (!rootblock)
goto fail;
/* Read the rootblock. */
if (grub_errno)
goto fail;
/* The filesystem blocksize is not stored anywhere in the filesystem
itself. One way to determine it is reading blocks for the
rootblock until the checksum is correct. */
{
unsigned int i;
for (i = 0; i < GRUB_DISK_SECTOR_SIZE / sizeof (*currblock); i++)
if (checksum == 0)
break;
}
if (checksum != 0)
{
goto fail;
}
blocksize++;
return data;
fail:
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
return 0;
}
static char *
{
char *symlink;
- 225);
if (!symlink)
return 0;
if (grub_errno)
{
return 0;
}
return symlink;
}
static int
int NESTED_FUNC_ATTR
enum grub_fshelp_filetype filetype,
{
int i;
const struct grub_affs_file *fil);
const struct grub_affs_file *fil)
{
int type;
if (!node)
{
return 1;
}
else
{
return 1;
}
return 0;
}
/* Create the directory entries for `.' and `..'. */
if (!node)
return 1;
return 1;
{
if (!node)
return 1;
return 1;
}
if (!hashtable)
return 1;
if (grub_errno)
goto fail;
{
if (!hashtable[i])
continue;
/* Every entry in the hashtable can be chained. Read the entire
chain. */
while (next)
{
if (grub_errno)
goto fail;
return 1;
}
}
return 0;
fail:
return 0;
}
/* Open a file named NAME and initialize FILE. */
static grub_err_t
{
if (!data)
goto fail;
if (grub_errno)
goto fail;
return 0;
fail:
return grub_errno;
}
static grub_err_t
{
return GRUB_ERR_NONE;
}
/* Read LEN bytes data from FILE into BUF. */
static grub_ssize_t
{
}
static grub_err_t
const struct grub_dirhook_info *info))
{
enum grub_fshelp_filetype filetype,
enum grub_fshelp_filetype filetype,
{
+ 8 * 365 * 86400 + 86400 * 2;
}
if (!data)
goto fail;
if (grub_errno)
goto fail;
fail:
return grub_errno;
}
static grub_err_t
{
if (data)
{
/* The rootblock maps quite well on a file header block, it's
something we can use here. */
if (grub_errno)
return 0;
if (*label)
}
else
*label = 0;
return grub_errno;
}
{
.name = "affs",
.dir = grub_affs_dir,
.open = grub_affs_open,
.read = grub_affs_read,
.close = grub_affs_close,
.label = grub_affs_label,
#ifdef GRUB_UTIL
.reserved_first_sector = 0,
#endif
.next = 0
};
{
}
{
}