2009-07-20 Vladimir Serbinenko <phcoder@gmail.com>

Fix AtheFS support.

	* fs/afs.c: Fix comments style.
	(grub_afs_blockrun): Declare as packed.
	(grub_afs_datastream): Likewise.
	(grub_afs_bnode): Likewise.
	(grub_afs_btree): Likewise.
	(grub_afs_sblock): Likewise.
	Declare `name' as char.
	(grub_afs_inode): Declare as packed.
	Change void *vnode to grub_uint32_t unused.
	(grub_afs_iterate_dir): Check that key_size is positive.
	(grub_afs_mount): Don't read superblock twice.
	(grub_afs_dir): Don't free node in case of errorx
	grub_fshelp_find_file already handles this.
	(grub_afs_open): Likewise.
This commit is contained in:
phcoder 2009-07-20 09:48:25 +00:00
parent 5680109e00
commit 186f3189a1
2 changed files with 43 additions and 29 deletions

View file

@ -1,3 +1,22 @@
2009-07-20 Vladimir Serbinenko <phcoder@gmail.com>
Fix AtheFS support.
* fs/afs.c: Fix comments style.
(grub_afs_blockrun): Declare as packed.
(grub_afs_datastream): Likewise.
(grub_afs_bnode): Likewise.
(grub_afs_btree): Likewise.
(grub_afs_sblock): Likewise.
Declare `name' as char.
(grub_afs_inode): Declare as packed.
Change void *vnode to grub_uint32_t unused.
(grub_afs_iterate_dir): Check that key_size is positive.
(grub_afs_mount): Don't read superblock twice.
(grub_afs_dir): Don't free node in case of errorx
grub_fshelp_find_file already handles this.
(grub_afs_open): Likewise.
2009-07-19 Pavel Roskin <proski@gnu.org> 2009-07-19 Pavel Roskin <proski@gnu.org>
* Makefile.in: Remove LIBLZO and enable_lzo. * Makefile.in: Remove LIBLZO and enable_lzo.

View file

@ -1,7 +1,7 @@
/* afs.c - The native AtheOS file-system. */ /* afs.c - The native AtheOS file-system. */
/* /*
* GRUB -- GRand Unified Bootloader * GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc. * Copyright (C) 2008,2009 Free Software Foundation, Inc.
* *
* GRUB is free software: you can redistribute it and/or modify * GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -29,7 +29,7 @@
#define GRUB_AFS_DIRECT_BLOCK_COUNT 12 #define GRUB_AFS_DIRECT_BLOCK_COUNT 12
#define GRUB_AFS_BLOCKS_PER_DI_RUN 4 #define GRUB_AFS_BLOCKS_PER_DI_RUN 4
#define GRUB_AFS_SBLOCK_MAGIC1 0x41465331 /* AFS1 */ #define GRUB_AFS_SBLOCK_MAGIC1 0x41465331 /* AFS1. */
#define GRUB_AFS_SBLOCK_MAGIC2 0xdd121031 #define GRUB_AFS_SBLOCK_MAGIC2 0xdd121031
#define GRUB_AFS_SBLOCK_MAGIC3 0x15b6830e #define GRUB_AFS_SBLOCK_MAGIC3 0x15b6830e
@ -81,7 +81,7 @@ struct grub_afs_blockrun
grub_uint32_t group; grub_uint32_t group;
grub_uint16_t start; grub_uint16_t start;
grub_uint16_t len; grub_uint16_t len;
}; } __attribute__ ((packed));
struct grub_afs_datastream struct grub_afs_datastream
{ {
@ -92,7 +92,7 @@ struct grub_afs_datastream
struct grub_afs_blockrun double_indirect; struct grub_afs_blockrun double_indirect;
grub_afs_off_t max_double_indirect_range; grub_afs_off_t max_double_indirect_range;
grub_afs_off_t size; grub_afs_off_t size;
}; } __attribute__ ((packed));
struct grub_afs_bnode struct grub_afs_bnode
{ {
@ -102,7 +102,7 @@ struct grub_afs_bnode
grub_uint32_t key_count; grub_uint32_t key_count;
grub_uint32_t key_size; grub_uint32_t key_size;
char key_data[0]; char key_data[0];
}; } __attribute__ ((packed));
struct grub_afs_btree struct grub_afs_btree
{ {
@ -111,7 +111,7 @@ struct grub_afs_btree
grub_uint32_t tree_depth; grub_uint32_t tree_depth;
grub_afs_bvalue_t last_node; grub_afs_bvalue_t last_node;
grub_afs_bvalue_t first_free; grub_afs_bvalue_t first_free;
} ; } __attribute__ ((packed));
struct grub_afs_sblock struct grub_afs_sblock
{ {
@ -124,8 +124,10 @@ struct grub_afs_sblock
grub_afs_off_t used_blocks; grub_afs_off_t used_blocks;
grub_uint32_t inode_size; grub_uint32_t inode_size;
grub_uint32_t magic2; grub_uint32_t magic2;
grub_uint32_t block_per_group; // Number of blocks per allocation group (Max 65536) grub_uint32_t block_per_group; /* Number of blocks per allocation
grub_uint32_t alloc_group_shift; // Number of bits to shift a group number to get a byte address. group. (Max 65536) */
grub_uint32_t alloc_group_shift; /* Number of bits to shift a group
number to get a byte address. */
grub_uint32_t alloc_group_count; grub_uint32_t alloc_group_count;
grub_uint32_t flags; grub_uint32_t flags;
struct grub_afs_blockrun log_block; struct grub_afs_blockrun log_block;
@ -133,12 +135,13 @@ struct grub_afs_sblock
grub_uint32_t valid_log_blocks; grub_uint32_t valid_log_blocks;
grub_uint32_t log_size; grub_uint32_t log_size;
grub_uint32_t magic3; grub_uint32_t magic3;
struct grub_afs_blockrun root_dir; // Root dir inode. struct grub_afs_blockrun root_dir; /* Root dir inode. */
struct grub_afs_blockrun deleted_files; // Directory containing files scheduled for deletion. struct grub_afs_blockrun deleted_files; /* Directory containing files
struct grub_afs_blockrun index_dir; // Directory of index files. scheduled for deletion. */
struct grub_afs_blockrun index_dir; /* Directory of index files. */
grub_uint32_t boot_loader_size; grub_uint32_t boot_loader_size;
grub_uint32_t pad[7]; grub_uint32_t pad[7];
}; } __attribute__ ((packed));
struct grub_afs_inode struct grub_afs_inode
{ {
@ -153,13 +156,13 @@ struct grub_afs_inode
grub_afs_bigtime modified_time; grub_afs_bigtime modified_time;
struct grub_afs_blockrun parent; struct grub_afs_blockrun parent;
struct grub_afs_blockrun attrib_dir; struct grub_afs_blockrun attrib_dir;
grub_uint32_t index_type; /* Key data-key only used for index files */ grub_uint32_t index_type; /* Key data-key only used for index files. */
grub_uint32_t inode_size; grub_uint32_t inode_size;
void* vnode; grub_uint32_t unused;
struct grub_afs_datastream stream; struct grub_afs_datastream stream;
grub_uint32_t pad[4]; grub_uint32_t pad[4];
grub_uint32_t small_data[1]; grub_uint32_t small_data[1];
}; } __attribute__ ((packed));
struct grub_fshelp_node struct grub_fshelp_node
{ {
@ -307,8 +310,8 @@ grub_afs_iterate_dir (grub_fshelp_node_t dir,
struct grub_afs_sblock *sb = &dir->data->sblock; struct grub_afs_sblock *sb = &dir->data->sblock;
int i; int i;
if ((! dir->inode.stream.size) || if ((dir->inode.stream.size == 0)
((U32 (sb, dir->inode.mode) & GRUB_AFS_S_IFMT) != GRUB_AFS_S_IFDIR)) || ((U32 (sb, dir->inode.mode) & GRUB_AFS_S_IFMT) != GRUB_AFS_S_IFDIR))
return 0; return 0;
grub_afs_read_file (dir, 0, 0, sizeof (head), (char *) &head); grub_afs_read_file (dir, 0, 0, sizeof (head), (char *) &head);
@ -343,7 +346,7 @@ grub_afs_iterate_dir (grub_fshelp_node_t dir,
key_start = U16 (sb, (cur_key > 0) ? index[cur_key - 1] : 0); key_start = U16 (sb, (cur_key > 0) ? index[cur_key - 1] : 0);
key_size = U16 (sb, index[cur_key]) - key_start; key_size = U16 (sb, index[cur_key]) - key_start;
if (key_size) if (key_size > 0)
{ {
char filename [key_size + 1]; char filename [key_size + 1];
struct grub_fshelp_node *fdiro; struct grub_fshelp_node *fdiro;
@ -470,15 +473,8 @@ grub_afs_mount (grub_disk_t disk)
goto fail; goto fail;
if (! grub_afs_validate_sblock (&data->sblock)) if (! grub_afs_validate_sblock (&data->sblock))
{
if (grub_disk_read (disk, 1 * 2, 0, sizeof (struct grub_afs_sblock),
&data->sblock))
goto fail; goto fail;
if (! grub_afs_validate_sblock (&data->sblock))
goto fail;
}
data->diropen.data = data; data->diropen.data = data;
data->inode = &data->diropen.inode; data->inode = &data->diropen.inode;
data->disk = disk; data->disk = disk;
@ -524,8 +520,6 @@ grub_afs_open (struct grub_file *file, const char *name)
return 0; return 0;
fail: fail:
if (fdiro != &data->diropen)
grub_free (fdiro);
grub_free (data); grub_free (data);
grub_dl_unref (my_mod); grub_dl_unref (my_mod);
@ -588,9 +582,10 @@ grub_afs_dir (grub_device_t device, const char *path,
grub_afs_iterate_dir (fdiro, iterate); grub_afs_iterate_dir (fdiro, iterate);
fail:
if (fdiro != &data->diropen) if (fdiro != &data->diropen)
grub_free (fdiro); grub_free (fdiro);
fail:
grub_free (data); grub_free (data);
grub_dl_unref (my_mod); grub_dl_unref (my_mod);