Re: Request for feedback: Filesystem API

On Aug 20, 2013 12:03 AM, "Brendan Eich" <brendan@secure.meer.net> wrote:
>
> Jonas Sicking wrote:
>> I think protection of accidentally removing a non-empty directory
belongs in UI and not in API (Unix commands land somewhere in between)
>>
>
> Unix had directory removal at user-level initially, but moved to rmdir(2)
which can fail with ENOTEMPTY, to avoid the footgun (also to abstract at
the kernel boundary over future directory entry representations, but that
could've been done in libc code).
>
> Here I will join Allen in pointing to Unix history. It is best to have rm
-r (removeDeep) be the composite operation (enumerateDeep + remove) and
remove the primitive (which fails on a non-empty directory).

OK, so remove() will remove a file or an empty directory and is atomic. If
passed a non-empty directory it fails with a "directory not empty" error.

removeDeep(), if we keep it, is a composite operation which can either
remove a file or a directory, empty or not.

/ Jonas

Received on Tuesday, 20 August 2013 07:55:32 UTC