Unable to create file (editing works fine)

  • Marcin Zajaczkowski


    I am unable to create any file on a resource mounted with davfs2 (as normal user and root) .

    [myuser@myhost dav]$ touch somefile
    touch: cannot touch `somefile': No such file or directory

    I checked also with vim, cp, etc.

    I'm able to create directories and editing existing files. Creating file works fine with cadaver, so it's not probably problem with remote resource.

    I tried to set "debug most" in global config file, but I don't see any entry related to devfs2 in my logs.
    Btw, is it possible to force to davfs2 to stay in a foreground and print messages on a console?

    davfs2 was called from root:
    mount.davfs -o uid=myuser,gid=myuser http://url/dir /mnt/dav

    davfs2 1.3.3, fuse 2.7.3, Fedora 8

    Do you know what could be a reason?


    • Werner Baumann

      Werner Baumann - 2008-08-22

      Hello Marcin,

      different from cadaver, davfs2 uses Locks by default and additionally checks for existing files when creating one. The problem you describe is usually caused by servers that have a broken implementation of LOCK, sometimes by a broken implementation of HEAD. One of the options "if_match_bug 0", "use_locks 0" or "precheck 0" might help.

      But it would be better to get the logs and look for the real reason and for the Server-header.

      Are you sure your davfs2.conf is in the right place? it might be in /etc/davfs2 or in /usr/local/etc/davfs2, depending on where davfs2 is installed. "man davfs2.conf" will show the correct location.

      mount.davfs sends the debug message to the syslog daemon with facility DAEMON and log level DEBUG. In which file they will apear depends on the syslogd configuration. If they are not written to any log-file at all, you should check this configuration.

      If you can't get logging at work, you can capture the HTTP-traffic with wireshark.

      The only way to see what's going wrong, is to look at the HTTP-requests and the responses from the server. Both, the debug messages and wireshark can provide them.

      Please tell me the brand of the server in any case.

      mount.davfs will not stay in the foreground. The only way to change this, is to change the program sources.


      P.S.: davfs2 does not need fuse. It only makes use of the fuse kernel module, which is part of the kernel.

      • Marcin Zajaczkowski

        Thanks for your reply Werner.

        man davfs2.conf shows /var/cache/davfs2/davfs2.conf, but used file is in /etc/davfs2/davfs2.conf (I checked it by giving fake user as a dav_user). There is no Fedora package for the current version of davfs2 and I had to modify some older SPEC file and due to some compilation errors (I will have a look on that later) I had to hack it a little bit to make a package, so wrong path in man could be caused by that.

        I was unable to get any log from davfs2. It's enabled in davfs2.conf (e.g. debug most), but nothing is logged anywhere. I enabled daemon.debug (also daemon.*) in rsyslog.conf (and reloaded rsyslog), but without any result. But here it could be my mistake as well.

        The main problem:
        As you suspected "use_locks 0" helped, but it's only a workaround and maybe something more can be done with that.

        I captured some traffic using Wireshark and I will be able to send it to you via mail tomorrow.
        As far as I can tell now there were "404 Not Found" after a try to obtain a lock. And in addition server returns "Allow: OPTIONS, GET, HEAD, POST, DELETE, TRACE, LOCK, UNLOCK, MOVE, COPY, PROPPATCH, PROPFIND".
        I'm not sure about webdav implementation on the server side, because it's done by OpenCms (7.0.5) deployed on Apache Tomcat (5.5). It's probably some java library and I will try to find it out.

        davfs2 and fuse:
        Indeed. I incorrectly assumed that davfs2 uses libfuse like many others file systems using fuse.


    • Werner Baumann

      Werner Baumann - 2008-08-24

      Hello Marcin,

      thanks for the logs.
      It looks like a broken implementation of LOCK on the server side. As far as I can see, Apache-Coyote is only a kind of connector that forwards HTTP-requests to a servlet or java server page. The bug is probably in that servlet or server page.

      I will try to first explain what is going wrong, and then suggest means to work araound this problem with davfs2-options.

      What's going wrong:

      When you try to create a new file, this is what happens (it starts at Aug 24 09:00:39 in the log file):

      The fuse kernel module tries to lookup the file and davfs2 answers "No such file or directory". This is ok.
        p 0x8bc0e88, aaa
      RET: No such file or directory

      Now your application tries to create a new file. The fuse kernel-module sends a request to create and open this new file:
        n 0x8bc0e88, f 0104101
        pid 24271, mode 0100644

      davfs2 first checks, whether a file with the same name exists on the server (somebody might have created one, since davfs2 did a PROPFIND).
      HEAD /opencms/webdav/aaa HTTP/1.1

      HTTP/1.1 404 Not Found
      The 404 response from the server is ok. No such file exists, so we can create one.

      davfs2 will now lock the file, to prevent everbody else from creating a file with the same name. Though the file does not exist on the server, locking is perfectly ok. It will reserve the name. This is part of the WebDAV-specification and a server that claims DAV-class-2-compliance MUST support this.
      LOCK /opencms/webdav/aaa HTTP/1.1

      HTTP/1.1 404 Not Found
      The server replies with 404. This is a bug. The server must LOCK the not-yet-existing file, or must not claim to support LOCKS.

      davfsr reports the error to the fuse kernel-module (maybe davfs2 should better send I/O-error instead of "No such file or directory".
      RET: No such file or directory

      Please contact the creator of the servlet/jsp and report this bug.

      How to work around:
      Please set option "use_locks 0" in your davfs2.conf. If this is the only bug, it should work now.

      If it does not work, please send me the new debug log.

      If it works:
      Locks are intended to avoid the Lost-Update-Problem. But even without locks, they can be avoided. davfs2 checks for changes on the server, before it loads up a changed file or creates a new. By default it uses HEAD-requests for this. But there is a better way: conditional HTTP-requests, using If-Match-headers. davfs2 does not use them by default, because of a bug in older versions of Apache. Please enable conditional requests with option "if_match_bug 0".
      If it does not work now, please send me the debug logs and remove the option again.
      If it works, it is just as save as LOCK. If a file is changed on the server, while you are editing the same file, the locally changed file will not be uploaded, but will end up in the lost+found directory.


    • Werner Baumann

      Werner Baumann - 2008-08-25

      Hello Marcin!

      "man davfs2.conf shows /var/cache/davfs2/davfs2.conf, but used file is in /etc/davfs2/davfs2.conf"
      This is a bug in the davfs2.conf.5 man-page (not caused by compilation problems). I corrected it in the CVS-repository. Thanks for the hint.

      This bug is not in the mount.davfs-man-page. "man man.davfs" should show the correct locations int the FILES-section.

      The location depends on the prefix you choose when running ./configure. By default the prefix is /usr/local and the system-wide configuration file is /usr/local/etc/davfs2/davfs2.conf. With --prefix=/usr it will be /etc/davfs2/davfs2.conf.

      Now that it works with option "use_locks 0", you might *additionaly* try option "if_match_bug 0". If it works it will increase performance and relyability (a little bit). You should see "If-Match" and "If-None_Match"-headers with PUT-requests. If it does not work, I would like to analize the HTTP-traffic or debug-log.


      • Marcin Zajaczkowski

        Hello Werner,

        "if_match_bug 0" seems to work with "use_locks 0" (files are created). I also see "If-None_Match" in PUT requests.

        I have reported a problem to they mailing list:

        Hopefully the will response and fix the problem.

        Thanks you for your help.

        Best regards


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks