Closed Bug 1199130 Opened 9 years ago Closed 7 years ago

SHARE_DELETE is enabled even when nsIFileInputStream::SHARE_DELETE not specified on Linux

Categories

(Core :: Networking: File, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: jwwang, Unassigned)

Details

(Whiteboard: [necko-backlog])

Flags: needinfo?(jduell.mcbugs)
So my understanding (both from reading nsIFileStream.idl and looking at the code) is that setting SHARE_DELETE on Linux/OSX/etc (anything but windows) has absolutely no effect: the only code that checks it to do anything is windows-only:

  https://dxr.mozilla.org/mozilla-central/source/netwerk/base/nsFileStreams.cpp#344
  
So bug 1068596 comment 27: "On Linux: nsIFileInputStream::SHARE_DELETE not specified -> file opened with SHARE_DELETE" is wrong in that whether or not SHARE_DELETE is set, we always call  OpenNSPRFileDesc() (and never OpenNSPRFileDescShareDelete()).

So I don't think there's anything to do here.  Reopen if I'm wrong.
Status: NEW → RESOLVED
Closed: 9 years ago
Flags: needinfo?(jduell.mcbugs)
Resolution: --- → INVALID
OK, let me put it this way.

On Windows, NS_NewLocalFileInputStream(i, f, -1, -1, -0) opens a file which can't be deleted before closing it.
On Linux, NS_NewLocalFileInputStream(i, f, -1, -1, -0) opens a file which can be deleted before closing it.

This is the inconsistency.
Flags: needinfo?(jduell.mcbugs)
Per comment 3.
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Is there anything we can do when operating systems does not provide an ability to make the behavior consistent?
Flags: needinfo?(jwwang)
I don't think the ability is not provided by the system (Linux). It is just that we didn't implement it.
Flags: needinfo?(jwwang)
Whiteboard: [necko-backlog]
(In reply to JW Wang [:jwwang] [:jw_wang] from comment #6)
> I don't think the ability is not provided by the system (Linux). It is just
> that we didn't implement it.

What ability concretely? Linux only supports advisory lock AFAIK.
The behavior is also documented in the .idl and expected:

https://dxr.mozilla.org/mozilla-central/rev/3cedab21a7e65e6a1c4c2294ecfb5502575a46e3/netwerk/base/nsIFileStreams.idl#84-90
>    /**
>     * This flag has no effect and is totally ignored on any platform except
>     * Windows since this is the default behavior on POSIX systems. On Windows
>     * if this flag is set then the stream is opened in a special mode that
>     * allows the OS to delete the file from disk just like POSIX.
>     */
>    const long SHARE_DELETE = 1<<5;

This is not implementable on POSIX systems due to the difference of lock semantics.
Status: REOPENED → RESOLVED
Closed: 9 years ago7 years ago
Resolution: --- → INVALID
Flags: needinfo?(jduell.mcbugs)
You need to log in before you can comment on or make changes to this bug.