Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, When the system (linux) undergoes an abrupt shutdown, on reboot few files stored in flash are getting corrupted. After reboot if I try to open those files using fopen, ...
  1. #1
    AJJ
    AJJ is offline
    Just Joined!
    Join Date
    Sep 2009
    Posts
    2

    fopen returns NULL, even when the file exists

    Hi,
    When the system (linux) undergoes an abrupt shutdown, on reboot few files stored in flash are getting corrupted. After reboot if I try to open those files using fopen, it returns a NULL pointer, so the code takes it as "File not found" case and creates a new file with default values (This overwrites the required data present in the corrupted file).

    Do anybody have any idea on how to recover the data from the file even if it is corrupted...
    As this occurs rarely I do not have the errno or the corrupted files with me.

    Any suggestions or ideas on this would help me to proceed further in debugging this issue,

    Thanks in advance...

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Please show the code you are using to open the file. In any case, it is likely that since the system panic'd you need to recover the device with fsck since it is likely that the directory structure has become munged as well. BTW, what file system are you using on your flash drive, fat32, ntfs, or ext2. For Linux use, ext2 is preferable. FAT file systems are very fragile and recovering data from an ntfs volume is problematic at best.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...