chase: reuse "done" to open fd of starting point
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 20 Jul 2023 05:56:43 +0000 (14:56 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 29 Jul 2023 12:58:29 +0000 (21:58 +0900)
commit00a050b395b6c38f6dea86fd660741bba00fadf0
tree7e39438376777f825b2a5c2804ca0cab02eb2509
parentae85704760e3125bc4ee0e657d29d10c54f5411c
chase: reuse "done" to open fd of starting point

For readability that 'done' and 'fd' are always consistent with each other.

- dir_fd == AT_FDCWD:
  - path is absolute:
    - previous: fd = open("/")
    - current:  fd = openat(AT_FDCWD, "/")
  - path is relative:
    - previous: fd = openat(AT_FDCWD, ".")
    - current:  fd = openat(AT_FDCWD, ".")
- dir_fd >= 0:
  - dir_fd points to "/":
    - previous: fd = openat(dir_fd, ".")
    - current:  fd = openat(dir_fd, "/")
  - dir_fd does not point to "/":
    - previous: fd = openat(dir_fd, ".")
    - current:  fd = openat(dir_fd, ".")

Hence, this should not change any behavior. Just refactoring.
src/basic/chase.c