Skip to content

Re-open the temporary file after editing - #64

Merged
ac000 merged 1 commit into
masterfrom
file-reopen
Oct 11, 2026
Merged

ac000 merged 1 commit into
masterfrom
file-reopen

Conversation

@ac000

@ac000 ac000 commented Oct 11, 2026

Copy link
Copy Markdown
Owner

This is to handle cases where an editor replaces the file with the edited version where by the file will have a different inode. E.g.,

Before saving the edited file

$ ls -l /proc/191852/fd/3 && grep ino /proc/191852/fdinfo/3
lrwx------ 1 andrew andrew 64 Oct 11 14:16 /proc/191852/fd/3 -> /tmp/.itsa_accounting_adjustments.jJxHVx.json
ino: 44354

After saving

$ ls -l /proc/191852/fd/3 && grep ino /proc/191852/fdinfo/3
lrwx------ 1 andrew andrew 64 Oct 11 14:16 /proc/191852/fd/3 -> /tmp/.itsa_accounting_adjustments.jJxHVx.json
ino: 44583

So even though it's still the same file, it now has a different inode number.

This renames the open_editor() fucntion to edit_file() as it now does this extra thing...

Copilot AI balanced review requested due to automatic review settings October 11, 2026 13:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The reopened /tmp path must reject symlinks and validate the resulting file.

1 open finding
What changed in this PR

Reopens edited temporary files so inode-replacing editors produce updated descriptors.

Changes:

  • Renames open_editor() to edit_file().
  • Reopens the temporary file after editing.
  • Updates all callers to receive the new descriptor.
File Description
src/​itsa.c Adds post-edit reopening and updates editor call sites.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/itsa.c
This is to handle cases where an editor *replaces* the file with the
edited version where by the file will have a different inode. E.g.,

Before saving the edited file

  $ ls -l /proc/191852/fd/3 && grep ino /proc/191852/fdinfo/3
  lrwx------ 1 andrew andrew 64 Oct 11 14:16 /proc/191852/fd/3 -> /tmp/.itsa_accounting_adjustments.jJxHVx.json
  ino:	44354

After saving

  $ ls -l /proc/191852/fd/3 && grep ino /proc/191852/fdinfo/3
  lrwx------ 1 andrew andrew 64 Oct 11 14:16 /proc/191852/fd/3 -> /tmp/.itsa_accounting_adjustments.jJxHVx.json
  ino:	44583

So even though it's still the *same* file, it now has a different inode
number.

This renames the open_editor() fucntion to edit_file() as it now does
this extra thing...

Signed-off-by: Andrew Clayton <ac@sigsegv.uk>
Copilot AI balanced review requested due to automatic review settings October 11, 2026 13:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused change correctly handles replaced files while validating reopened descriptors.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

@ac000
ac000 merged commit 7e6bd0b into master Oct 11, 2026
8 checks passed
@ac000
ac000 deleted the file-reopen branch October 11, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants