Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support fstat larger than 4G while st_size is 64bit on Windows #1074

Closed
wants to merge 3 commits into from

Conversation

likema
Copy link
Contributor

@likema likema commented Apr 11, 2020

Summary by CodeRabbit

  • Bug Fixes
    • Improved file size handling to ensure accurate reporting for large files that exceed 32-bit limits.

@@ -2,6 +2,7 @@
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_fcntl.h"
#include "ace/OS_NS_errno.h"
#include "ace/OS_NS_time.h"
Copy link
Member

Choose a reason for hiding this comment

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

Consider moving ACE_MAKE_QWORD so this include isn't needed.

@jwillemsen jwillemsen added the needs review Needs to be reviewed label May 7, 2020
else
{
stp->st_size = fdata.nFileSizeLow;
stp->st_size = ACE_MAKE_QWORD(fdata.nFileSizeLow, fdata.nFileSizeHigh);
Copy link
Member

@jwillemsen jwillemsen Jun 8, 2020

Choose a reason for hiding this comment

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

Could this be ACE_COMBINE_PARTS?

Copy link
Member

Choose a reason for hiding this comment

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

What about the ACE_OS::stat functions, do they have the same problem?

@jwillemsen
Copy link
Member

Looks to be reported in the past, see http://bugzilla.dre.vanderbilt.edu/show_bug.cgi?id=4079

Copy link
Member

@jwillemsen jwillemsen left a comment

Choose a reason for hiding this comment

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

Needs some more testing and check whether the macro is correct

@jwillemsen
Copy link
Member

Any suggestions for a test?

Copy link
Contributor

coderabbitai bot commented Feb 2, 2025

Walkthrough

The changes update the file handling in the fstat function within the ACE/ace/OS_NS_sys_stat.inl file. A new include for ace/OS_NS_time.h has been added. The logic in fstat for setting the st_size field now uses the ACE_MAKE_QWORD macro to combine fdata.nFileSizeLow and fdata.nFileSizeHigh into a 64-bit value, improving support for large file sizes. The remainder of the function, including error handling and field assignments, remains unchanged.

Changes

File Change Summary
ACE/.../OS_NS_sys_stat.inl Added include directive for ace/OS_NS_time.h; modified fstat to build a 64-bit file size using ACE_MAKE_QWORD from low and high file size values.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller
    participant fstat as fstat()
    participant MAKER as ACE_MAKE_QWORD Macro

    Caller->>fstat: Call fstat(file_descriptor)
    fstat->>fstat: Retrieve file data (nFileSizeLow, nFileSizeHigh)
    fstat->>MAKER: Combine low and high file size values
    MAKER-->>fstat: Return 64-bit file size
    fstat->>Caller: Return updated ACE_stat with st_size set
Loading

Poem

Hop along the code trail, clear and bright,
A new include hopped in with delight.
Sizes combine in a clever dance,
64-bit magic in every prance.
From a rabbit’s heart, let changes take flight!
🐰✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f11974 and f91e995.

📒 Files selected for processing (1)
  • ACE/ace/OS_NS_sys_stat.inl (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: ubuntu-20.04 g++-10 ACE for TAO
  • GitHub Check: ubuntu-20.04 clang++-12
  • GitHub Check: ubuntu-20.04 clang++-11
  • GitHub Check: ubuntu-20.04 clang++-10
  • GitHub Check: VS2022Release64
  • GitHub Check: VS2022Debug64
  • GitHub Check: VS2022WChar
  • GitHub Check: VS2019Debug64Cxx20
  • GitHub Check: VS2019Debug64Cxx17
  • GitHub Check: VS2019Release32
  • GitHub Check: VS2019Debug32
  • GitHub Check: VS2019Release64
  • GitHub Check: VS2019Debug64
  • GitHub Check: macos-14-C++
  • GitHub Check: windows-2019 vs2019
  • GitHub Check: VS2019WChar
  • GitHub Check: macos-13-C++
  • GitHub Check: ubuntu-22.04 g++-12
  • GitHub Check: ubuntu-20.04 g++-10
  • GitHub Check: MINGW64-gcc
🔇 Additional comments (4)
ACE/ace/OS_NS_sys_stat.inl (4)

5-5: Consider moving ACE_MAKE_QWORD macro definition.

The include is needed for ACE_Time_Value, but ACE_MAKE_QWORD could potentially be moved to reduce include dependencies.


40-46: LGTM! Well-structured platform-specific handling.

The conditional compilation correctly handles file size limitations on 32-bit Windows systems where 64-bit file offsets aren't enabled.


49-49: Consider using ACE_COMBINE_PARTS for consistency.

The ACE_COMBINE_PARTS macro might be more appropriate here for maintaining consistency across the codebase.


186-196: Verify large file support in ACE_OS::stat.

The ACE_OS::stat function might have similar large file handling issues on Windows. Consider applying similar changes to ensure consistent behavior.

Run the following script to analyze the implementation:

✅ Verification successful

Large File Support Verified for Windows in ACE_OS::stat

  • The macro definitions in ACE/ace/OS_NS_sys_stat.h correctly map ACE_STAT_FUNC_NAME to Windows’ 64-bit stat functions (_stat64/_stati64) when _FILE_OFFSET_BITS is 64.
  • ACE/ace/config-win32-common.h ensures that _FILE_OFFSET_BITS is defined as 64 on Windows, so ACE_OS::stat consistently uses the proper large file support implementation.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check ACE_OS::stat implementation for large file support
# Search for Windows-specific stat implementation and its file size handling

# Look for stat implementation in Windows-specific code
rg -A 10 "ACE_STAT_FUNC_NAME|GetFileAttributesEx" --type cpp

# Look for potential large file handling macros
rg "_FILE_OFFSET_BITS|_LARGEFILE" --type cpp

Length of output: 4230


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jwillemsen
Copy link
Member

Looks this is the same as #2254?

@likema
Copy link
Contributor Author

likema commented Feb 7, 2025

Looks this is the same as #2254?

Yes.

@likema likema closed this Feb 7, 2025
@likema likema deleted the win-fstat-64-bit branch February 7, 2025 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Needs to be reviewed
Development

Successfully merging this pull request may close these issues.

4 participants