[PR #2131] [CLOSED] Flush after opened file size is shrinked #2347

Closed
opened 2026-03-04 02:05:04 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/s3fs-fuse/s3fs-fuse/pull/2131
Author: @ggtakec
Created: 3/16/2023
Status: Closed

Base: masterHead: fix_filesize


📝 Commits (1)

  • 67f98b7 Flush after opened file size is shrinked

📊 Changes

5 files changed (+134 additions, -10 deletions)

View changed files

📝 .gitignore (+2 -0)
📝 src/s3fs.cpp (+21 -6)
📝 test/Makefile.am (+6 -4)
📝 test/integration-test-main.sh (+24 -0)
test/truncate_read_file.c (+81 -0)

📄 Description

Relevant Issue (if applicable)

#2107

Details

There was a bug in trauncate, which shrinks files.

This bug occurs under the following conditions:

  • Open the file and shrink the file.
  • After shrinking, do read before flushing(do not close or sync).

At this time, it got the old size before shrinking from the server(Content-Length) and set old size again.
So that the read data from the reduced size to the original size padded as 0x00, and read it.
When read all of file, the read size is old length before reduction.

I added C source code to test the condition that caused the failure and included it in this PR.
(Because it is difficult to realize with a shell script, I wrote it in C source)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/s3fs-fuse/s3fs-fuse/pull/2131 **Author:** [@ggtakec](https://github.com/ggtakec) **Created:** 3/16/2023 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix_filesize` --- ### 📝 Commits (1) - [`67f98b7`](https://github.com/s3fs-fuse/s3fs-fuse/commit/67f98b79250633981f98f9e7c35d094d326abfea) Flush after opened file size is shrinked ### 📊 Changes **5 files changed** (+134 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+2 -0) 📝 `src/s3fs.cpp` (+21 -6) 📝 `test/Makefile.am` (+6 -4) 📝 `test/integration-test-main.sh` (+24 -0) ➕ `test/truncate_read_file.c` (+81 -0) </details> ### 📄 Description ### Relevant Issue (if applicable) #2107 ### Details There was a bug in trauncate, which shrinks files. This bug occurs under the following conditions: - Open the file and shrink the file. - After shrinking, do read before flushing(do not close or sync). At this time, it got the old size before shrinking from the server(Content-Length) and set old size again. So that the read data from the reduced size to the original size padded as 0x00, and read it. When read all of file, the read size is old length before reduction. I added C source code to test the condition that caused the failure and included it in this PR. (Because it is difficult to realize with a shell script, I wrote it in C source) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 02:05:04 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/s3fs-fuse#2347
No description provided.