Skip to content

fix: set storfs size_t type alias to just standard size_t#27

Open
prashantrahul141 wants to merge 1 commit into
matt001k:developfrom
prashantrahul141:fix/different-size_t
Open

fix: set storfs size_t type alias to just standard size_t#27
prashantrahul141 wants to merge 1 commit into
matt001k:developfrom
prashantrahul141:fix/different-size_t

Conversation

@prashantrahul141

@prashantrahul141 prashantrahul141 commented Mar 3, 2026

Copy link
Copy Markdown
Collaborator

This patch sets storfs's different size_t type alises to be just size_t for better portability across different word size machines

closes #26
closes #23

@prashantrahul141

Copy link
Copy Markdown
Collaborator Author

This fixes the seg fault in #26. I will write tests which will make sure to catch all these locally or in the ci.

Comment thread include/storfs.h Outdated

/** @brief Describes the page location */
typedef uint32_t storfs_page_t;
typedef size_t storfs_page_t;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This should stay at uint32_t. In the snode work this is expected to be 4 bytes to fit properly in the calculations of the SNode struct size (see: https://github.com/matt001k/STORfs/blob/e6d535fd008dd13e6c706cb7577d8dbaf23c5342/src/snode.h#L31C1-L60C70). This value should be locked in at either uint32_t or uint64_t, doing so will ensure that there is consistency across platforms and the FS stays compatible across platforms agnostic of the storage device.

@prashantrahul141 prashantrahul141 Mar 4, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This seems to be the cause of seg fault in #26. Using uint32_t triggers the seg fault while keeping it to uint64_t doesn't? Think we should pin this to uint64_t?

The performance overhead of keeping it to uint64_t on 32bit systems wouldn't be much I think.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

All of the file access functions (fputs, fgets, open, etc.) will need to be updated once the SNode Directory Hash Table is implemented, rendering the current implementations stale.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

You can think of bitmap.c, snode.c and soon hash.c as the new engine to this car we are building 😄
I am extremely close to finishing snode.c then I will have time to write a design document for hash.c.
Following that, all of the file access functions can easily be re-written.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I see, is it possible to keep snode's size calculation dynamic? maybe via sizeof? This will allow us to keep storfs_page_t as size_t and the size of snode will also be consistent.

Comment thread include/storfs.h Outdated
Comment thread include/storfs.h

/** @brief Filesize alias for filesize register */
typedef uint32_t storfs_file_size_t;
typedef size_t storfs_file_size_t;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This may be able to be deleted in the future.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Can you elaborate what exactly you mean? storfs_file_size_t seems to be used at exactly two places across the code base:

  1. storfs_file_size_t
  2. storfs_file_size_t fileSize;

This patch sets storfs's different size_t type alises to be just size_t
for better portability across different word size machines

Signed-off-by: Prashant Rahul <prashantrahul141@protonmail.com>
@matt001k

matt001k commented Mar 6, 2026

Copy link
Copy Markdown
Owner

Sorry I will be chewing on this one for a bit more as the snode work wraps up.

@prashantrahul141

Copy link
Copy Markdown
Collaborator Author

No problem! please take your time. I am currently writing some unit tests as I mentioned earlier

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.

Segmentation fault when running test example Deciding size of storfs_size_t and storfs_page_t

2 participants