Git Product home page Git Product logo

Comments (13)

DUOLabs333 avatar DUOLabs333 commented on August 14, 2024

This also affects yarn which reads /proc/self/stat

from bindfs.

DUOLabs333 avatar DUOLabs333 commented on August 14, 2024

It seems that bindfs does not understand that stat is not an empty folder, but rather just exposes a 0-byte file instead.

from bindfs.

DUOLabs333 avatar DUOLabs333 commented on August 14, 2024

SSHFS supports this with -o direct_io, but bindfs doesn't seem to support this: fuse: unknown option(s): -o direct_io`

from bindfs.

DUOLabs333 avatar DUOLabs333 commented on August 14, 2024

ptfs works, but it is linked against fuse2. However, --forward-odirect doesn't seem to do anything.

from bindfs.

DUOLabs333 avatar DUOLabs333 commented on August 14, 2024

You have to set int direct_io; then fi->direct_io=1;

from bindfs.

mpartel avatar mpartel commented on August 14, 2024

Thanks! I'll try to find time to take a proper look and add -o direct_io soon.

from bindfs.

DUOLabs333 avatar DUOLabs333 commented on August 14, 2024

Here's something I have that works:

diff --git a/src/bindfs.c b/src/bindfs.c
index bc24154..1329ada 100644
--- a/src/bindfs.c
+++ b/src/bindfs.c
@@ -203,6 +203,8 @@ static struct Settings {
 #ifdef __linux__
     int forward_odirect;
     size_t odirect_alignment;
+    
+    int direct_io;
 #endif
 
     uid_t uid_offset;
@@ -689,6 +691,10 @@ static void *bindfs_init()
     cfg->entry_timeout = 0;
     cfg->attr_timeout = 0;
     cfg->negative_timeout = 0;
+    
+    if (settings.direct_io)
+       cfg->direct_io=1;
+
     #endif
 
     assert(settings.permchain != NULL);
@@ -706,7 +712,7 @@ static void *bindfs_init()
         bindfs_init_failed = true;
         fuse_exit(fuse_get_context()->fuse);
     }
-
+    
     return NULL;
 }
 
@@ -1252,6 +1258,7 @@ static int bindfs_create(const char *path, mode_t mode, struct fuse_file_info *f
     if (!settings.forward_odirect) {
         flags &= ~O_DIRECT;
     }
+    
 #endif
 
     fd = open(real_path, flags, mode & 0777);
@@ -1282,6 +1289,7 @@ static int bindfs_open(const char *path, struct fuse_file_info *fi)
     if (!settings.forward_odirect) {
         flags &= ~O_DIRECT;
     }
+    
 #endif
 
     fd = open(real_path, flags);
@@ -1790,7 +1798,8 @@ enum OptionKey {
     OPTKEY_ENABLE_IOCTL,
     OPTKEY_HIDE_HARD_LINKS,
     OPTKEY_RESOLVE_SYMLINKS,
-    OPTKEY_BLOCK_DEVICES_AS_FILES
+    OPTKEY_BLOCK_DEVICES_AS_FILES,
+    OPTKEY_DIRECT_IO
 };
 
 static int process_option(void *data, const char *arg, int key,
@@ -1898,7 +1907,9 @@ static int process_option(void *data, const char *arg, int key,
     case OPTKEY_BLOCK_DEVICES_AS_FILES:
         settings.block_devices_as_files = 1;
         return 0;
-
+    case OPTKEY_DIRECT_IO:
+        settings.direct_io=1;
+        return 0;
     case OPTKEY_NONOPTION:
         if (!settings.mntsrc) {
             if (strncmp(arg, "/proc/", strlen("/proc/")) == 0) {
@@ -2388,6 +2399,7 @@ int main(int argc, char *argv[])
 
         OPT2("--delete-deny", "delete-deny", OPTKEY_DELETE_DENY),
         OPT2("--rename-deny", "rename-deny", OPTKEY_RENAME_DENY),
+        OPT2("--direct_io","direct_io",OPTKEY_DIRECT_IO),
 
         OPT2("--hide-hard-links", "hide-hard-links", OPTKEY_HIDE_HARD_LINKS),
         OPT2("--resolve-symlinks", "resolve-symlinks", OPTKEY_RESOLVE_SYMLINKS),
@@ -2455,6 +2467,8 @@ int main(int argc, char *argv[])
 #ifdef __linux__
     settings.forward_odirect = 0;
     settings.odirect_alignment = 0;
+    
+    settings.direct_io = 0;
 #endif
 
     atexit(&atexit_func);

from bindfs.

DUOLabs333 avatar DUOLabs333 commented on August 14, 2024

Another, more serious issue: bindfs modifies /proc/self/exe such that it points to /usr/bin/bindfs, instead of whatever binary is accessing it.

from bindfs.

mpartel avatar mpartel commented on August 14, 2024

Thanks, for the patch! Applied with minor modifications and --direct_io -> --direct-io for consistency.

/proc/self works that way because it's the bindfs process that's reading the underlying proc. It'd need to be special-cased.

from bindfs.

mpartel avatar mpartel commented on August 14, 2024

^ actually, opted to make direct_io the default.

from bindfs.

DUOLabs333 avatar DUOLabs333 commented on August 14, 2024

Actually, you should not make this the default --- it will break mmap calls.

from bindfs.

DUOLabs333 avatar DUOLabs333 commented on August 14, 2024

As a note, a maintainer on FUSE does plan on working on making direct_io work with mmap -- rpodgorny/unionfs-fuse#117 (comment).

from bindfs.

mpartel avatar mpartel commented on August 14, 2024

Good to know, thanks!

from bindfs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.