* grub-core/fs/affs.c (grub_affs_mount): Support AFFS bootblock in
sector 1.
This commit is contained in:
parent
473959f052
commit
b78c312722
2 changed files with 76 additions and 72 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2012-09-26 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/fs/affs.c (grub_affs_mount): Support AFFS bootblock in
|
||||||
|
sector 1.
|
||||||
|
|
||||||
2012-09-24 Colin Watson <cjwatson@ubuntu.com>
|
2012-09-24 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
* util/grub-install.in: Make the error message if $source_dir
|
* util/grub-install.in: Make the error message if $source_dir
|
||||||
|
|
|
@ -97,6 +97,7 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
#define AFFS_MAX_LOG_BLOCK_SIZE 4
|
#define AFFS_MAX_LOG_BLOCK_SIZE 4
|
||||||
|
#define AFFS_MAX_SUPERBLOCK 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,36 +185,33 @@ grub_affs_mount (grub_disk_t disk)
|
||||||
{
|
{
|
||||||
struct grub_affs_data *data;
|
struct grub_affs_data *data;
|
||||||
grub_uint32_t *rootblock = 0;
|
grub_uint32_t *rootblock = 0;
|
||||||
struct grub_affs_rblock *rblock;
|
struct grub_affs_rblock *rblock = 0;
|
||||||
int log_blocksize = 0;
|
int log_blocksize = 0;
|
||||||
|
int bsnum = 0;
|
||||||
|
|
||||||
data = grub_zalloc (sizeof (struct grub_affs_data));
|
data = grub_zalloc (sizeof (struct grub_affs_data));
|
||||||
if (!data)
|
if (!data)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
for (bsnum = 0; bsnum < AFFS_MAX_SUPERBLOCK + 1; bsnum++)
|
||||||
|
{
|
||||||
/* Read the bootblock. */
|
/* Read the bootblock. */
|
||||||
grub_disk_read (disk, 0, 0, sizeof (struct grub_affs_bblock),
|
grub_disk_read (disk, bsnum, 0, sizeof (struct grub_affs_bblock),
|
||||||
&data->bblock);
|
&data->bblock);
|
||||||
if (grub_errno)
|
if (grub_errno)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* Make sure this is an affs filesystem. */
|
/* Make sure this is an affs filesystem. */
|
||||||
if (grub_strncmp ((char *) (data->bblock.type), "DOS", 3))
|
if (grub_strncmp ((char *) (data->bblock.type), "DOS", 3) != 0
|
||||||
{
|
|
||||||
grub_error (GRUB_ERR_BAD_FS, "not an AFFS filesystem");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Test if the filesystem is a OFS filesystem. */
|
/* Test if the filesystem is a OFS filesystem. */
|
||||||
if (! (data->bblock.flags & GRUB_AFFS_FLAG_FFS))
|
|| !(data->bblock.flags & GRUB_AFFS_FLAG_FFS))
|
||||||
{
|
continue;
|
||||||
grub_error (GRUB_ERR_BAD_FS, "OFS not yet supported");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No sane person uses more than 8KB for a block. At least I hope
|
/* 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. */
|
for that person because in that case this won't work. */
|
||||||
rootblock = grub_malloc (GRUB_DISK_SECTOR_SIZE << AFFS_MAX_LOG_BLOCK_SIZE);
|
if (!rootblock)
|
||||||
|
rootblock = grub_malloc (GRUB_DISK_SECTOR_SIZE
|
||||||
|
<< AFFS_MAX_LOG_BLOCK_SIZE);
|
||||||
if (!rootblock)
|
if (!rootblock)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
@ -234,6 +232,11 @@ grub_affs_mount (grub_disk_t disk)
|
||||||
(grub_uint64_t) grub_be_to_cpu32 (data->bblock.rootblock)
|
(grub_uint64_t) grub_be_to_cpu32 (data->bblock.rootblock)
|
||||||
<< log_blocksize, 0,
|
<< log_blocksize, 0,
|
||||||
GRUB_DISK_SECTOR_SIZE << log_blocksize, rootblock);
|
GRUB_DISK_SECTOR_SIZE << log_blocksize, rootblock);
|
||||||
|
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
|
||||||
|
{
|
||||||
|
grub_errno = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (grub_errno)
|
if (grub_errno)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
@ -250,28 +253,24 @@ grub_affs_mount (grub_disk_t disk)
|
||||||
checksum += grub_be_to_cpu32 (currblock[i]);
|
checksum += grub_be_to_cpu32 (currblock[i]);
|
||||||
|
|
||||||
if (checksum == 0)
|
if (checksum == 0)
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (log_blocksize > AFFS_MAX_LOG_BLOCK_SIZE)
|
|
||||||
{
|
{
|
||||||
grub_error (GRUB_ERR_BAD_FS, "AFFS blocksize couldn't be determined");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
data->log_blocksize = log_blocksize;
|
data->log_blocksize = log_blocksize;
|
||||||
data->disk = disk;
|
data->disk = disk;
|
||||||
data->htsize = grub_be_to_cpu32 (rblock->htsize);
|
data->htsize = grub_be_to_cpu32 (rblock->htsize);
|
||||||
data->diropen.data = data;
|
data->diropen.data = data;
|
||||||
data->diropen.block = grub_be_to_cpu32 (data->bblock.rootblock);
|
data->diropen.block = grub_be_to_cpu32 (data->bblock.rootblock);
|
||||||
data->diropen.parent = NULL;
|
data->diropen.parent = NULL;
|
||||||
grub_memcpy (&data->diropen.di, rootblock, sizeof (data->diropen.di));
|
grub_memcpy (&data->diropen.di, rootblock,
|
||||||
|
sizeof (data->diropen.di));
|
||||||
grub_free (rootblock);
|
grub_free (rootblock);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
|
if (grub_errno == GRUB_ERR_NONE || grub_errno == GRUB_ERR_OUT_OF_RANGE)
|
||||||
grub_error (GRUB_ERR_BAD_FS, "not an AFFS filesystem");
|
grub_error (GRUB_ERR_BAD_FS, "not an AFFS filesystem");
|
||||||
|
|
||||||
grub_free (data);
|
grub_free (data);
|
||||||
|
|
Loading…
Reference in a new issue