Skip to content

1. fix enum fuse_readdir_flags and enum fuse_fill_dir_flags in cpp - #903

Merged
bsbernd merged 1 commit into
libfuse:masterfrom
FredyVia:master
Mar 20, 2024
Merged

bsbernd merged 1 commit into
libfuse:masterfrom
FredyVia:master

Conversation

@FredyVia

Copy link
Copy Markdown
Contributor

ref #629 , add this simple enum item to adapt cpp

@bsbernd bsbernd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you please comment what this is for? This is an unused flag now.

@bsbernd

bsbernd commented Mar 14, 2024

Copy link
Copy Markdown
Collaborator

I don't know what "adapt cpp" means.

@FredyVia

Copy link
Copy Markdown
Contributor Author

In C++, 0 cannot be converted to the corresponding enum type (fuse_fill_dir_flags), so following code couldn't be compiled
https://github.com/libfuse/libfuse/blob/master/example/hello.c

filler(buf, ".", NULL, 0, 0);
filler(buf, "..", NULL, 0, 0);

in #629, Nikratio suggests using FUSE_FILL_DIR_DEFAULTS

@bsbernd

bsbernd commented Mar 14, 2024

Copy link
Copy Markdown
Collaborator

Could you please add failing compiler output to the commit message? Also would help if this flag would get used by the project.
The current way your commit message is very confusing, the title says
"1. fix enum fuse_readdir_flags&fuse_fill_dir_flags in cpp"

What does "1." mean - what would "2.", "3.", etc?
And without explaining what is fixed and without an actual user of the change, this part is not right either "fix enum". I.e. it is less the code, but more the way you are communicating the change that needs updated.

@FredyVia

Copy link
Copy Markdown
Contributor Author
fredyvia@LittleBee ~$ gcc -Wall ~/libfuse/example/hello.c `pkg-config fuse3 --cflags --libs` -o hello // gcc compile ok!
fredyvia@LittleBee ~$ g++ -Wall ~/libfuse/example/hello.c `pkg-config fuse3 --cflags --libs` -o hello // g++ error bellow
/home/fredyvia/libfuse/example/hello.c: In function ‘int hello_readdir(const char*, void*, fuse_fill_dir_t, off_t, fuse_file_info*, fuse_readdir_flags)’:
/home/fredyvia/libfuse/example/hello.c:94:35: error: invalid conversion from ‘int’ to ‘fuse_fill_dir_flags’ [-fpermissive]
   94 |         filler(buf, ".", NULL, 0, 0);
      |                                   ^
      |                                   |
      |                                   int
/home/fredyvia/libfuse/example/hello.c:95:36: error: invalid conversion from ‘int’ to ‘fuse_fill_dir_flags’ [-fpermissive]
   95 |         filler(buf, "..", NULL, 0, 0);
      |                                    ^
      |                                    |
      |                                    int
/home/fredyvia/libfuse/example/hello.c:96:48: error: invalid conversion from ‘int’ to ‘fuse_fill_dir_flags’ [-fpermissive]
   96 |         filler(buf, options.filename, NULL, 0, 0);
      |                                                ^
      |                                                |
      |                                                int
/home/fredyvia/libfuse/example/hello.c: In function ‘int hello_read(const char*, char*, size_t, off_t, fuse_file_info*)’:
/home/fredyvia/libfuse/example/hello.c:121:20: warning: comparison of integer expressions of different signedness: ‘off_t’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
  121 |         if (offset < len) {
      |             ~~~~~~~^~~~~
/home/fredyvia/libfuse/example/hello.c: At global scope:
/home/fredyvia/libfuse/example/hello.c:137:1: error: designator order for field ‘fuse_operations::getattr’ does not match declaration order in ‘const fuse_operations’
  137 | };

We only need to add an enumeration item FUSE_FILL_DIR_DEFAULTS. If we do not add this enum item representing 0, we cannot use the filler function directly in the C++ program.

@bsbernd

bsbernd commented Mar 14, 2024

Copy link
Copy Markdown
Collaborator

So then please add that part to the commit message and please use the new enum value in example/hello.c

@FredyVia
FredyVia force-pushed the master branch 5 times, most recently from dba591b to dac9471 Compare March 14, 2024 11:46
@bsbernd

bsbernd commented Mar 14, 2024

Copy link
Copy Markdown
Collaborator

Thanks, much better, please remove all debug printf. Could you please also change the commit message to something like

Add FUSE_FILL_DIR_DEFAULTS enum

In order to use the fuse_fill_dir_t function in a C++ program, add the enum item: 
FUSE_FILL_DIR_DEFAULTS

Without this change g++ compilation failed with
fredyvia@LittleBee ~$ gcc -Wall ~/libfuse/example/hello.c `pkg-config fuse3 --cflags --libs` -o hello // gcc compile ok!
fredyvia@LittleBee ~$ g++ -Wall ~/libfuse/example/hello.c `pkg-config fuse3 --cflags --libs` -o hello // g++ error bellow
/home/fredyvia/libfuse/example/hello.c: In function ‘int hello_readdir(const char*, void*, fuse_fill_dir_t, off_t, fuse_file_info*, fuse_readdir_flags)’:
/home/fredyvia/libfuse/example/hello.c:94:35: error: invalid conversion from ‘int’ to ‘fuse_fill_dir_flags’ [-fpermissive]
   94 |         filler(buf, ".", NULL, 0, 0);
      |                                   ^
      |                                   |
      |                                   int


Please feel free to change the text, but please limit subject line to 69 characters. Commit message should be around max 79 chars, except of pasted compiler output.

@FredyVia
FredyVia force-pushed the master branch 2 times, most recently from 1fe56ee to 1dabf6e Compare March 14, 2024 13:08
@bsbernd

bsbernd commented Mar 19, 2024

Copy link
Copy Markdown
Collaborator

Sorry for the delay, there is an out-of-the-sudden test failure - it was working the days/commits before and now reproducibly stalls. Tested old commits - same issue.
The patch looks good to me, but I would like to get tests past it - right now cannot merge anything until I have tracked down what is the issue.

In order to use the fuse_fill_dir_t function in a C++ program, add the enum item:
FUSE_FILL_DIR_DEFAULTS

Without this change g++ compilation failed with
example/hello.c:94:35: error: invalid conversion from ‘int’ to ‘fuse_fill_dir_flags’ [-fpermissive]
   94 |         filler(buf, ".", NULL, 0, 0);
      |                                   ^
      |                                   |
      |                                   int
@bsbernd
bsbernd merged commit c021e91 into libfuse:master Mar 20, 2024
bsbernd added a commit to bsbernd/libfuse that referenced this pull request Mar 29, 2024
* master: (24 commits)
  Add support for FUSE_CAP_HANDLE_KILLPRIV_V2
  Fix FUSE_CAP_DIRECT_IO_ALLOW_MMAP - use new numerical value
  Install all test/build python packages from requirements.txt
  fix readdirplus when filler is called with zero offset (libfuse#896)
  reset got_init after handling FUSE_DESTROY message (libfuse#910)
  ci-build.sh: Fix checking for function arguments (libfuse#909)
  Add FUSE_FILL_DIR_DEFAULTS enum (libfuse#903)
  Fix example/fix-notify_inval_inode.c (libfuse#908)
  Bump actions/checkout from 4.1.1 to 4.1.2 (libfuse#905)
  Add final "meson setup --reconfigure" to README.md
  /test_ctests / test_notify1: Print cmdline on failure
  Add glibc backtrace to signal handler
  ci-build.sh: Add back test without versioned symbols
  Build clang/sanitized build first
  Fix use-after-free in example/poll.c
  Add back s-bit for compiled fusermount
  Fix test failures: Create missing mount dir
  ci-build.sh: Reduce pytest --maxfail from 99 to 1
  ci-build.sh: Always install and add s-bit for fusermount3
  ci-build.sh: Run ASAN and UBSAN at the same time
  ...
bsbernd added a commit to bsbernd/libfuse that referenced this pull request Feb 20, 2025
* remotes/upstream/master:
  Fix FUSE_CAP_DIRECT_IO_ALLOW_MMAP - use new numerical value
  Install all test/build python packages from requirements.txt
  fix readdirplus when filler is called with zero offset (libfuse#896)
  reset got_init after handling FUSE_DESTROY message (libfuse#910)
  ci-build.sh: Fix checking for function arguments (libfuse#909)
  Add FUSE_FILL_DIR_DEFAULTS enum (libfuse#903)
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