This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
Re: Bug in FAT32 filesystem
- From: =?big5?q?=B7=A8=B6=AE=B6W?= <vlsi235 at yahoo dot com dot tw>
- To: Savin Zlobec <savinz at users dot sourceforge dot net>
- Cc: ecos-patches at sourceware dot org
- Date: Mon, 5 Feb 2007 09:30:54 +0800 (CST)
- Subject: Re: Bug in FAT32 filesystem
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.tw; h=X-YMail-OSG:Received:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=EI67n+ZM9pDiL/mbxnvEUSOx1EwXE/57GvuCviMdqMz6qqklOlsgLLIQZ5rbWptgjMfjnTnfwbrfrfyDYxziaU6jiLHAsyCsWKNC/9XZZYlnmPnBSVGknUQKq4T/vtKva0mXmUpDNb7teOPrC2hq1eFjSlOUtnKkY/C4Gqd/sTw=;
- Reply-to: a8850607 at stmail dot fju dot edu dot tw
Hi,
Until now, the verification looks so far so good.
'Directory move' works fine.
--- Savin Zlobec <savinz@users.sourceforge.net> 說:
> > Hi,All
> > I found a bug in FAT16/32 Filesystem. When I
> > delete file in FAT32, it seems not work correctly.
> In
> > the function called "fatfs_delete_file", the start
> > cluster for "free_cluster_chain" should not be the
> > "raw_dentry.cluster", it should be
> > "(raw_dentry.cluster | raw_dentry.cluster_HI <<
> 16)"
> > for FAT32.
>
> Your fix looks fine. A quick scan through the code
> reveals at least one more place with the same type
> of error. I've attached a patch - could you please
> check 'directory move' throughout your fs tree -
> especially that the parent directory link ('..')
> was updated correctly.
>
> --
> savin
>
>
>
> > Index: fatfs_supp.c
>
===================================================================
> RCS file:
>
/cvs/ecos/ecos/packages/fs/fat/current/src/fatfs_supp.c,v
> retrieving revision 1.6
> diff -5 -u -r1.6 fatfs_supp.c
> --- fatfs_supp.c 3 Aug 2005 20:40:48 -0000 1.6
> +++ fatfs_supp.c 31 Jan 2007 15:11:57 -0000
> @@ -1263,11 +1263,11 @@
> diag_printf("FAT: FDE crt time: %u\n",
> dentry->crt_time);
> diag_printf("FAT: FDE crt date: %u\n",
> dentry->crt_date);
> diag_printf("FAT: FDE acc date: %u\n",
> dentry->acc_date);
> diag_printf("FAT: FDE wrt time: %u\n",
> dentry->wrt_time);
> diag_printf("FAT: FDE wrt date: %u\n",
> dentry->wrt_date);
> - diag_printf("FAT: FDE cluster: %u\n",
> dentry->cluster);
> + diag_printf("FAT: FDE cluster: %u\n",
> (dentry->cluster_HI << 16) | dentry->cluster);
> diag_printf("FAT: FDE size: %u\n",
> dentry->size);
> }
> #endif // TDE
>
> //
>
-------------------------------------------------------------------------
> @@ -2164,11 +2164,11 @@
> if (i > 2)
> return EPERM;
> }
>
> // Free file clusters
> - free_cluster_chain(disk, raw_dentry.cluster);
> + free_cluster_chain(disk, raw_dentry.cluster |
> (raw_dentry.cluster_HI << 16));
> raw_dentry_set_deleted(disk, &raw_dentry);
> err = write_raw_dentry(disk, &file->disk_pos,
> &raw_dentry);
> return err;
> }
>
> @@ -2402,10 +2402,11 @@
> // Deleate dentry at old location
>
> raw_dentry_set_deleted(disk, &raw_dentry);
> raw_dentry.size = 0;
> raw_dentry.cluster = 0;
> + raw_dentry.cluster_HI = 0;
> err = write_raw_dentry(disk, &target->disk_pos,
> &raw_dentry);
> if (err != ENOERR)
> return err;
>
> // Set file new position and parent cluster
> @@ -2434,11 +2435,12 @@
> else if (err != ENOERR)
> return err;
>
> if (0 == strncmp("..",
> raw_cdentry.name, 2))
> {
> - raw_cdentry.cluster =
> dir2->cluster;
> + raw_cdentry.cluster = dir2->cluster
> & 0xFFFF;
> + raw_cdentry.cluster_HI =
> dir2->cluster >> 16;
> err = write_raw_dentry(disk, &pos,
> &raw_cdentry);
> if (err != ENOERR)
> return err;
> break;
> }
>
___________________________________________________
您的生活即時通 - 溝通、娛樂、生活、工作一次搞定!
http://messenger.yahoo.com.tw/