Menu

#432 Unhelpful error message if a directory is specified on the command line

v1.6.0
closed-fixed
None
5
2021-02-28
2018-08-05
No

Steps to reproduce:

  • Start Fuse from the command line, specifying a directory as an option (e.g. ./fuse z80 in the build directory)

Expected result:

A vaguely helpful error message telling you that you tried to open a directory.

Actual result:

./fuse: error: error reading file: expected 4096 bytes, but read only 0
./fuse: error initialising -- giving up!

(The "expected" obviously varies with the size of the directory on disk)

Discussion

  • Sergio Baldoví

    Sergio Baldoví - 2018-12-30

    Patch proposal with a message good enough to me:

    ./fuse: error: couldn't open 'z80': No such file or directory

     
    • Alberto Garcia

      Alberto Garcia - 2019-01-06

      I see two problems with this patch:

      1) The access() call is unnecessary. If the user has no access to the file then the stat() call will fail anyway, producing the expected result.
      2) If there's an error the calling function prints a message based on the value of errno, but S_ISREG() doesn't set errno upon failure, so you get undefined behaviour.

      Alternative for the second problem: set errno yourself to EINVAL or something like that before returning 0 if S_ISREG() fails.

      Another alternative, possibly better, is to get rid of the compat_file_exists() call that you have in this patch add that S_ISREG() logic to compat_file_open(). That function should only open regular files, or is there any case in which that function needs to open anything else?

       
      • Sergio Baldoví

        Sergio Baldoví - 2019-01-07

        Thanks. Your proposal is better. I think compat_file_open() should open only files. Pipes (e.g. --rs232-rx) are handled in other way. Patch attached.

         
        • Alberto Garcia

          Alberto Garcia - 2019-01-08

          Looks good to me!

           
  • Sergio Baldoví

    Sergio Baldoví - 2019-01-13
    • status: open --> pending-fixed
    • assigned_to: Sergio Baldoví
    • Group: future --> NextRelease
     
  • Sergio Baldoví

    Sergio Baldoví - 2019-01-13

    Thanks all. Committed in [d9ce57].

     

    Related

    Commit: [d9ce57]

  • Sergio Baldoví

    Sergio Baldoví - 2021-02-06
    • status: pending-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB