bugGNUstep - Bugs: bug #29920, problem when opening a file in...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #29920: problem when opening a file in /sys using NSString stringWithContentsOfFile

Submitted by:  Riccardo Mottola <rmottola>
Submitted on:  Wed 19 May 2010 09:59:03 PM UTC  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Sat 05 Mar 2011 03:14:42 PM UTC, comment #5:

assumed fixed

Richard Frith-Macdonald <CaS>
Project Member
Sat 29 May 2010 08:07:05 AM UTC, comment #4:

I changed the code so that it doesn't treat it as an error if a read from a file fails before we have read the expected number of bytes.

Richard Frith-Macdonald <CaS>
Project Member
Mon 24 May 2010 08:48:16 AM UTC, comment #3:

The error message is surely a bit misleading.

I think it should be possible to read files on synthesized virtual filesystem. I have checked and different Linux installations on diffrent computers share the same "problem". I'd say it is currently a "bug-feature" instead of just an error.

I can try to add additional code to handle this special case. Maybe it is just sensible to remove the check for certain files.

The first question is, however, how to recognize we are treating a special file? Could checking for the first path element to be /sys a possible idea? It is a bit "broad" perhaps?
I don't see a property on the file itself to identify it, however!

Riccardo Mottola <rmottola>
Project Member
Thu 20 May 2010 10:43:34 AM UTC, comment #2:

Sounds like it's reasonable to not read the file (there's a filesystem error with the operating system reporting the wrong size for the file) ... but the error message is wrong.
It should possible say something like 'file truncated while reading'
or 'not a regular file'.
Or perhaps you want to add extra code to handle special files?

Richard Frith-Macdonald <CaS>
Project Member
Wed 19 May 2010 11:55:21 PM UTC, comment #1:

Debugging shows that gnustep relies on seeking the file from beginning to the end, determining the filesize first. Then it reads the file, if the sizes to not match, it returns error.

Apparently on these syhnthesized files, the filesize is bogus (even ls -l reports it wrongly to 4096, even if it has 1 byte)

Riccardo Mottola <rmottola>
Project Member
Wed 19 May 2010 09:59:03 PM UTC, original submission:

File NSData.m: 265. In readContentsOfFile read of file (/sys/class/power_supply/BAT0/present) contents failed - No such file or directory

however the same file can be read using "cat" from the command line and fopen() works just fine on it.

It is not due to the content either, I copied the file with a copy with the same permissions and it works just fine:
-r--r--r-- 1 root root 4096 May 19 23:22 /sys/class/power_supply/BAT0/present
-r--r--r-- 1 root root 2 May 19 23:32 /home/multix/present

the second file reads fine into a string, the first not.

Riccardo Mottola <rmottola>
Project Member

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by CaS (Posted a comment)
  • -unavailable- added by rmottola (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 05 Mar 2011 03:14:42 PM UTCCaSOpen/ClosedIn Test=>Closed
    Sat 29 May 2010 08:07:05 AM UTCCaSStatusNone=>Fixed
      Open/ClosedOpen=>In Test

    Back to the top


    Powered by Savane 3.1-cleanup1