Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LioKv-0007Bj-AJ for mharc-grub-devel@gnu.org; Sun, 15 Mar 2009 07:16:57 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LioKt-0007Bd-Jk for grub-devel@gnu.org; Sun, 15 Mar 2009 07:16:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LioKo-0007BB-2n for grub-devel@gnu.org; Sun, 15 Mar 2009 07:16:54 -0400 Received: from [199.232.76.173] (port=55064 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LioKn-0007B8-Ta for grub-devel@gnu.org; Sun, 15 Mar 2009 07:16:49 -0400 Received: from mail-bw0-f172.google.com ([209.85.218.172]:55609) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LioKn-0006sz-Ei for grub-devel@gnu.org; Sun, 15 Mar 2009 07:16:49 -0400 Received: by bwz20 with SMTP id 20so3249510bwz.42 for ; Sun, 15 Mar 2009 04:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type; bh=Wyfts0Dp7gj7lIj1cbSc0/ykiFDIvJVuoiG1wvTx98g=; b=sIKRn5EyqXe+Ck85DfLlJuiRpnF4aBpAqFcxoQRkf7sqbJP29zZkuUJNpQoGDrTBdG U6iKcvQPfUA2acjbtiNVBRx9IlSUjCQpmJJZHlFiTysww66Ztdg8QszxegSdcatKf9pO BtQu8j8hoW/elORqBUsfmD6SQBOEXprqLS/K4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; b=DHHr1F/wtfSvAtl9neJZaqlHSKaT52HTG24yVWy8GGZqRfBxWy/rXzN8BZKeYQ8+Rq EOb5ystBZGWXcRA2QSRwExd690PqXv4wie8gh2+PrjgWIQJDRKWz8y4JNCs2HSPeXKIT I3k3v8PsDrDYTrAkDzTqS7QbWKelrBrf+aWVI= Received: by 10.103.160.9 with SMTP id m9mr1594146muo.53.1237115807832; Sun, 15 Mar 2009 04:16:47 -0700 (PDT) Received: from ?192.168.1.25? (125-116.62-81.cust.bluewin.ch [81.62.116.125]) by mx.google.com with ESMTPS id s11sm7792088mue.47.2009.03.15.04.16.46 (version=SSLv3 cipher=RC4-MD5); Sun, 15 Mar 2009 04:16:47 -0700 (PDT) Message-ID: <49BCE39E.4040402@gmail.com> Date: Sun, 15 Mar 2009 12:16:46 +0100 From: phcoder User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: The development of GRUB 2 References: <49AAB6E6.2080805@gmail.com> <20090313191030.GB17068@thorin> In-Reply-To: <20090313191030.GB17068@thorin> Content-Type: multipart/mixed; boundary="------------020207030504040302000905" X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [PATCH] FAT, UFS and mtime 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: Sun, 15 Mar 2009 11:16:56 -0000 This is a multi-part message in MIME format. --------------020207030504040302000905 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit UFS part (not related to mtime) 2009-03-15 Vladimir Serbinenko UFS improvements * fs/ufs.c (GRUB_UFS_BSD_DIRENT): new definition (struct grub_ufs_dirent): added fields for non-BSD dirents (grub_ufs_get_file_block): fixed double indirect handling (grub_ufs_find_file): support for non-BSD dirents (grub_ufs_dir): support for non-BSD dirents Robert Millan wrote: > On Sun, Mar 01, 2009 at 05:25:10PM +0100, phcoder wrote: >> Hello all. It seems that gcc has trouble with -m32 when structure is >> passed as argument. So I replaced that part by a pointer. Also I made >> some improvements to ufs code to support solaris branch of ufs. I tested >> it also with freebsd and netbsd's branch and it works fine on it too. >> As my 3 FS patches: mtime, FAT and UFS are interdependent I submit a >> patch with all 3 features. If it's really necessary I can split them but >> it requires a lot of unnecessary work > > Please do. It is definitely confusing to review patches that merge > unrelated things. > > Also, please don't include the changelog entry in your patch, since those > break too easily. Just paste it at the top of your mail. > -- Regards Vladimir 'phcoder' Serbinenko --------------020207030504040302000905 Content-Type: text/x-diff; name="ufs.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ufs.diff" diff --git a/fs/ufs.c b/fs/ufs.c index e6eacd3..9a3cd69 100644 --- a/fs/ufs.c +++ b/fs/ufs.c @@ -54,6 +54,8 @@ grub_le_to_cpu##bits1 (data->inode.field) : \ grub_le_to_cpu##bits2 (data->inode2.field)) #define INODE_SIZE(data) INODE_ENDIAN (data,size,32,64) +#define INODE_NBLOCKS(data) INODE_ENDIAN (data,nblocks,32,64) + #define INODE_MODE(data) INODE_ENDIAN (data,mode,16,16) #define INODE_BLKSZ(data) (data->ufs_type == UFS1 ? 4 : 8) #define INODE_DIRBLOCKS(data,blk) INODE_ENDIAN \ @@ -174,8 +176,15 @@ struct grub_ufs_dirent { grub_uint32_t ino; grub_uint16_t direntlen; - grub_uint8_t filetype; - grub_uint8_t namelen; + union + { + grub_uint16_t namelen; + struct + { + grub_uint8_t filetype_bsd; + grub_uint8_t namelen_bsd; + }; + }; } __attribute__ ((packed)); /* Information about a "mounted" ufs filesystem. */ @@ -234,22 +243,23 @@ grub_ufs_get_file_block (struct grub_ufs_data *data, unsigned int blk) blk -= indirsz; /* Double indirect block. */ - if (blk < UFS_BLKSZ (sblock) / indirsz) + if (blk < indirsz * indirsz) { grub_uint32_t indir[UFS_BLKSZ (sblock) >> 2]; grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 1) << log2_blksz, 0, sizeof (indir), (char *) indir); grub_disk_read (data->disk, - (data->ufs_type == UFS1) ? - indir[blk / indirsz] : indir [(blk / indirsz) << 1], + ((data->ufs_type == UFS1) ? + indir[blk / indirsz] : indir [(blk / indirsz) << 1]) + << log2_blksz, 0, sizeof (indir), (char *) indir); return (data->ufs_type == UFS1) ? indir[blk % indirsz] : indir[(blk % indirsz) << 1]; } - + grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "ufs does not support triple indirect blocks"); return 0; @@ -386,9 +396,8 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino) if (++data->linknest > GRUB_UFS_MAX_SYMLNK_CNT) return grub_error (GRUB_ERR_SYMLINK_LOOP, "too deep nesting of symlinks"); - - if (INODE_SIZE (data) < (GRUB_UFS_DIRBLKS + GRUB_UFS_INDIRBLKS - * INODE_BLKSZ (data))) + + if (INODE_NBLOCKS (data) == 0) grub_strcpy (symlink, (char *) INODE (data, symlink)); else { @@ -447,6 +456,7 @@ grub_ufs_find_file (struct grub_ufs_data *data, const char *path) do { struct grub_ufs_dirent dirent; + int namelen; if (grub_strlen (name) == 0) return GRUB_ERR_NONE; @@ -454,15 +464,18 @@ grub_ufs_find_file (struct grub_ufs_data *data, const char *path) if (grub_ufs_read_file (data, 0, pos, sizeof (dirent), (char *) &dirent) < 0) return grub_errno; + + namelen = (data->ufs_type == UFS2) + ? dirent.namelen_bsd : grub_le_to_cpu16 (dirent.namelen); { - char filename[dirent.namelen + 1]; + char filename[namelen + 1]; if (grub_ufs_read_file (data, 0, pos + sizeof (dirent), - dirent.namelen, filename) < 0) + namelen, filename) < 0) return grub_errno; - filename[dirent.namelen] = '\0'; + filename[namelen] = '\0'; if (!grub_strcmp (name, filename)) { @@ -595,21 +608,25 @@ grub_ufs_dir (grub_device_t device, const char *path, while (pos < INODE_SIZE (data)) { struct grub_ufs_dirent dirent; + int namelen; if (grub_ufs_read_file (data, 0, pos, sizeof (dirent), (char *) &dirent) < 0) break; + + namelen = (data->ufs_type == UFS2) + ? dirent.namelen_bsd : grub_le_to_cpu16 (dirent.namelen); { - char filename[dirent.namelen + 1]; + char filename[namelen + 1]; struct grub_dirhook_info info; grub_memset (&info, 0, sizeof (info)); if (grub_ufs_read_file (data, 0, pos + sizeof (dirent), - dirent.namelen, filename) < 0) + namelen, filename) < 0) break; - filename[dirent.namelen] = '\0'; + filename[namelen] = '\0'; if (data->ufs_type == UFS1) { struct grub_ufs_inode inode; --------------020207030504040302000905--