Closed Bug 82205 Opened 25 years ago Closed 25 years ago

nsLocalFile::IsSpecial (Unix) is broken [PATCH]

Categories

(Core :: XPCOM, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla0.9.3

People

(Reporter: tenthumbs, Assigned: kandrot)

Details

Attachments

(5 files)

This bug comes from a discussion in bug 81927. In mozilla/xpcom/io/nsLocalFileUnix.cpp, the nsLocalFile::IsSpecial uses S_ISLNK(mCachedStat.st_mode). Since mCachedStat appears to be the result of a stat system call, not lstat, S_ISLNK will always fail. Now it is possible to "fix" this by calling lstat in this method, but I think that's exactly the wrong thing to do. One almost never, except in a listing context, needs to know whether a file is a symlink. It's the target that's important. For example, if I symlinked ~/.signature to some regular file I would expect mozilla to use that file. If I symlinked the cache directory to another director on another disk with lots of space so I can have a 1GB cache, that should also work. In addition, there's a quite nice IsSymlink method available. For these reasons, the attached patch just removes S_ISLNK. Now it is also true that lxr doesn't show any place where IsSpecial is actually used but it is exposed in libxpcom.so so it's not like this can be totally ignored.
Crap! After 5 minutes, the attachment POST timed out. Stupid bugzilla. Here's th patch. I create an attachment when bugzilla feels better. --- mozilla/xpcom/io/nsLocalFileUnix.cpp.orig Tue May 22 13:53:16 2001 +++ mozilla/xpcom/io/nsLocalFileUnix.cpp Tue May 22 16:00:49 2001 @@ -1161,8 +1161,7 @@ { NS_ENSURE_ARG_POINTER(_retval); VALIDATE_STAT_CACHE(); - *_retval = !S_ISLNK(mCachedStat.st_mode) && - !S_ISREG(mCachedStat.st_mode) && + *_retval = !S_ISREG(mCachedStat.st_mode) && !S_ISDIR(mCachedStat.st_mode); return NS_OK; }
Attached patch patchSplinter Review
No comment from bug owner?
Edward, the patch looks okay to me... a link really isn't a special. What is holding this up?
The hold up would be an r=, sr=, and a=. I do not know what the ramifications of this change would be, though there does not seem to be any. If I knew this code, I would have given an r=. Can the hold up be by-passed by someone who knows the code giving it an r=, then sr=, then I will submit it for a=? Thanks.
Status: NEW → ASSIGNED
Perhaps it is better to detect what a file is rather than what it is not. New patch upcoming.
Attached patch updating patchSplinter Review
js> o.path; /dev/zero js> o.isFile(); false js> o.isDirectory(); false js> o.isSymlink(); false js> o.isSpecial(); true js> tested and looks good to me. r=pete Lets get this in. Someone want to sr= this bug? --pete
tenthumbs mark this to milestone to 0.9.3. Lets get all these nsLocalFile fixes in to this target. --pete
Ok, I'll risk Mozilla's wrath. Changing milestone.
Target Milestone: --- → mozilla0.9.3
Looks good to me, sr=jst
tenthumbs, do you want to check this in? We are a go . . . --pete
Provided the tree is open . . . ;-) --pete
I don't have checkin privileges so someone else will have to do the deed.
checked in please resolve this to fixed Thanks --pete
Resolving fixed.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
pete, BeOS build is broken now because there is no S_ISSOCK in BeOS. In BeOS, a file can't be a socket. So please do like this. #if !defined(XP_BEOS) *_retval = S_ISCHR(mCachedStat.st_mode) || S_ISBLK(mCachedStat.st_mode) || S_ISFIFO(mCachedStat.st_mode) || S_ISSOCK(mCachedStat.st_mode); #else *_retval = S_ISCHR(mCachedStat.st_mode) || S_ISBLK(mCachedStat.st_mode) || S_ISFIFO(mCachedStat.st_mode); #endif
reopen this bug.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Crap! New patch against current version. Take the last one. Twitchy thumbs on my part made a double attachment.
Someone should note somewhere that BEOS isn't POSIX compliant.
I checked in the BeOS fix as a build bustage fix.
Status: REOPENED → RESOLVED
Closed: 25 years ago25 years ago
Resolution: --- → FIXED
Mike, thanks. I just got back online today due to upgrades i've been doing to my home network. Sorry for the delayed response and thanks for ckecking in the fix Mike. --pete
Thanks!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: