2010-03-17 23:49:16     FAT folder/file getting corrupted

Document created by Aaronwu Employee on Aug 21, 2013
Version 1Show Document
  • View in full screen mode

2010-03-17 23:49:16     FAT folder/file getting corrupted

Karthikeyan Jeevanandam (INDIA)

Message: 87358   

 

Dear Mike,

 

We use Bf527 and access USB external storage media. We keep files in open mode during our application and append it with details as and when needed. There is a high chance of the USB storage media being unplugged during accessing the same. Rarely we see that the file we have opened for writing becomes non deletable, same for the folder within which we have this file.

 

If we do a chkdsk in windows PC the file/folder is getting deleted automatically.

 

a. What could be the reason for the file or folder becoming non deletable ?

 

b. Is it possible to do chkdsk kind of functionality in uclinux as and when we mount the FAT disks?

 

c. If "b" is possible then is it possible to chkdsk only for particular folders? - this is because we deal with only 1 or 2 folder whose files will be in open mode always until app shutdown.

 

Pointers related to the same will be in great helpful to us.

 

Thanks in advance,

 

Karthik

QuoteReplyEditDelete

 

 

2010-03-18 01:11:50     Re: FAT folder/file getting corrupted

Mike Frysinger (UNITED STATES)

Message: 87361   

 

unplugging a device while the file system on it is in use is a terrible idea.  this is a terrible idea regardless of the operating system you're using.  you'll see random corruption under Windows if you do the same thing.  this is not a bug in Linux in any way.  the FAT file system format was not designed with this kind of usage in mind.

 

the dosfstools package provides fsck for FAT filesystems.  i doubt you'll find any utility anywhere that does "checking" on a specific folder/file.  but for information on that, read the dosfstools homepage/documentation.

 

if you want to do this kind of craziness, pick a filesystem that can withstand arbitrary power off scenarios.  you probably wont find one though that is readable under both Linux and Windows without installing drivers under Windows.

QuoteReplyEditDelete

 

 

2010-03-18 03:09:17     Re: FAT folder/file getting corrupted

Karthikeyan Jeevanandam (INDIA)

Message: 87365   

 

Thanks Mike,

 

We will check with dosfstools. We are trying to address end users problem who might not know the technical details of USB disconnection during access.

 

Regards,

 

Karthik

QuoteReplyEditDelete

 

 

2010-03-18 03:19:01     Re: FAT folder/file getting corrupted

Mike Frysinger (UNITED STATES)

Message: 87395   

 

you could try the "flush" mount option (see the mount man page)

 

you should also use fsync() / fdatasync() whenever you write data to a file

 

these might make errors less common, but you're still going to have random corruption

QuoteReplyEditDelete

 

 

2010-03-18 03:39:45     Re: FAT folder/file getting corrupted

Karthikeyan Jeevanandam (INDIA)

Message: 87396    Thanks Mike,

 

We already use the sync() call at regular intervals to achieve the same.

We are currently not using fsync() / fdatasync() as it needs the file

descriptor as an argument. Instead we use sync() so all the open streams

buffers and kernel buffers are flushed in single call.

 

I couldn't see any info regarding flush in man page of mount - can you

help on this.

QuoteReplyEditDelete

 

 

2010-03-18 03:47:38     Re: FAT folder/file getting corrupted

Mike Frysinger (UNITED STATES)

Message: 87397   

 

get a newer distro / util-linux package then if your mount(8) is outdated

 

  www.kernel.org/pub/linux/utils/util-linux-ng/

Attachments

    Outcomes