octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #63265] rmdir fails to remove directory contai


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #63265] rmdir fails to remove directory containing read-only files
Date: Wed, 26 Oct 2022 15:09:52 -0400 (EDT)

Update of bug #63265 (project octave):

                  Status:               Confirmed => Patch Submitted        

    _______________________________________________________

Follow-up Comment #10:

It looks like `mkdir` fails in this case because `unlink` fails to unlink the
read-only file.

Reading the POSIX documentation of "unlink", it is not entirely clear to me
what is supposed to happen in this case. Afaict, there is no one-to-one
equivalent to a read-only file attribute on POSIX:
https://man7.org/linux/man-pages/man2/unlink.2.html

The documentation on MSDN is pretty clear that the Microsoft implementation of
the function with a similar name is supposed to fail in this case:
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/unlink-wunlink?view=msvc-170
> Each of these functions returns 0 if successful. Otherwise, the function
returns -1 and sets errno to EACCES, which means the path specifies a
read-only file or a directory, or to ENOENT, which means the file or path
isn't found.

In any case, Matlab's `rmdir` doesn't seem to care about the read-only flag.
So, this is at least a compatibility issue for that function.

The attached patch modifies `unlink` to also delete files that have their
read-only attribute set. That also allow `rmdir` to remove directories that
contain such files.

Alternatively, we could keep the current version of `unlink` that errors when
trying to delete files with read-only attribute and add a new version that
ignores the read-only attribute.

Any opinions?

(file #53909)

    _______________________________________________________

Additional Item Attachment:

File name: bug63265-unlink-read-only-files.patch Size:1 KB
   
<https://file.savannah.gnu.org/file/bug63265-unlink-read-only-files.patch?file_id=53909>



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63265>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]