Skip to content

[BUG] Incorrect Parent Directory Resolution in the Pseudo Filesystem #1847

@roodni

Description

@roodni

Describe the bug
In the pseudo filesystem, .. for a child directory of the root points to itself instead of the root.
Is this the intended behavior?
Note that this issue does not occur for deeper directories.

open Js_of_ocaml
let () =
  Sys_js.create_file ~name:"/foo/bar/baz" ~content:"";

  Sys.readdir "/foo/.."
    |> Array.to_list
    |> String.concat ","
    |> print_endline; (* Expected foo, but got bar *)

  Sys.readdir "/foo/bar/.."
    |> Array.to_list
    |> String.concat ","
    |> print_endline; (* bar *)

Expected behavior
/foo/.. may have to point to /.

Checking the source code, I found the following line:

if (ncomp.length > 1) ncomp.pop();

ncomp.length >= 1 may be correct instead of ncomp.length > 1.

Versions

$ js_of_ocaml --version
6.0.1

$ ocamlc -version
5.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions