Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JI8Ck-0000Ce-78 for mharc-grub-devel@gnu.org; Thu, 24 Jan 2008 14:57:42 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JI8Ci-0000CL-EU for grub-devel@gnu.org; Thu, 24 Jan 2008 14:57:40 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JI8Ce-0000C9-UC for grub-devel@gnu.org; Thu, 24 Jan 2008 14:57:40 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JI8Ce-0000C6-P9 for grub-devel@gnu.org; Thu, 24 Jan 2008 14:57:36 -0500 Received: from nz-out-0506.google.com ([64.233.162.230]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JI8Ce-0007ym-9Z for grub-devel@gnu.org; Thu, 24 Jan 2008 14:57:36 -0500 Received: by nz-out-0506.google.com with SMTP id f1so280555nzc.21 for ; Thu, 24 Jan 2008 11:57:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=EiF0fbTxpP15PhZ7R9osoV9wcsWXv+GrlwdmYc89Z5k=; b=mmqmHznf1mepOKib03WVv5jtKRILc4kd2x9l1eIFnCYZP5K/c4MXuKqE+lIYhJnifpe7Qq5mbMde/MN3u2NioVWOow2BR6WK3t3zc+O/7BMSzdM7z3oYO4+zMuxkuc7Vkb8sj+1iEsIAHZGwe+JjiNlnqea49VO1Bcgfwzh/mGA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=LsDij1y1YkvIwvjTpvk+k/H+63ivgVxzk8AR7Zg34Fyn97/deyWh9VB10ekrmlwWq9ieFGZzstwK6eke4kDtpoLKPk4W2TG5XwBoRSf3GgvsROuKkJX+KrjQYq8yTg1wDixNXIvuU49IfgMnxYtfJngOYHInQLbC5s2vAtg3k6c= Received: by 10.110.28.2 with SMTP id b2mr648155tib.41.1201204654241; Thu, 24 Jan 2008 11:57:34 -0800 (PST) Received: by 10.110.31.8 with HTTP; Thu, 24 Jan 2008 11:57:34 -0800 (PST) Message-ID: Date: Fri, 25 Jan 2008 03:57:34 +0800 From: Bean To: "The development of GRUB 2" In-Reply-To: <87myqv430w.fsf@xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080123183004.GA19087@via.ecp.fr> <87myqv430w.fsf@xs4all.nl> X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: Re: Incomplete file listing with reiserfs partition X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 19:57:40 -0000 this is the patch, it can list all files. the main problem of the original code is that it assume that the next offset will be current offset + 1, this is not true. the offset is a hash value. it can be extracted when going through the B+ tree. * fs/reiserfs.c (grub_fshelp_node): New member next_offset. (grub_reiserfs_get_item): Save offset of the next item. (grub_reiserfs_iterate_dir): Use next_offset to find next item. diff --git a/fs/reiserfs.c b/fs/reiserfs.c index bbd1b34..a4c60ca 100644 --- a/fs/reiserfs.c +++ b/fs/reiserfs.c @@ -218,6 +218,7 @@ struct grub_fshelp_node struct grub_reiserfs_data *data; grub_uint32_t block_number; /* 0 if node is not found. */ grub_uint16_t block_position; + grub_uint64_t next_offset; enum grub_reiserfs_item_type type; /* To know how to read the header. */ struct grub_reiserfs_item_header header; }; @@ -499,6 +500,7 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data, if (! block_header) goto fail; + item->next_offset = 0; do { grub_disk_read (data->disk, @@ -542,6 +544,9 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data, #endif } block_number = grub_le_to_cpu32 (children[i].block_number); + if ((i < item_count) && (key->directory_id == keys[i].directory_id) + && (key->object_id == keys[i].object_id)) + item->next_offset = grub_reiserfs_get_key_offset(&(keys[i])); #ifdef GRUB_REISERFS_DEBUG if (i == item_count || grub_reiserfs_compare_keys (key, &(keys[i])) == 0) @@ -711,6 +716,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, struct grub_reiserfs_block_header *block_header = 0; grub_uint16_t block_size, block_position; grub_uint32_t block_number; + grub_uint64_t next_offset = item->next_offset; int ret = 0; if (item->type != GRUB_REISERFS_DIRECTORY) @@ -732,7 +738,6 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, struct grub_fshelp_node directory_item; grub_uint16_t entry_count, entry_number; struct grub_reiserfs_item_header *item_headers; - grub_uint64_t key_offset; grub_disk_read (data->disk, (((grub_disk_addr_t) block_number * block_size) @@ -939,16 +944,18 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, the current one. */ } } + + if (next_offset == 0) + break; - key_offset - = grub_reiserfs_get_key_offset (&(item_headers[block_position].key)); grub_reiserfs_set_key_offset (&(item_headers[block_position].key), - key_offset + 1); + next_offset); if (grub_reiserfs_get_item (data, &(item_headers[block_position].key), &directory_item) != GRUB_ERR_NONE) goto fail; block_number = directory_item.block_number; block_position = directory_item.block_position; + next_offset = directory_item.next_offset; } while (block_number); -- Bean